[ { "theorem_id": 1, "title": "circle_average", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let is_add_monoid = new_definition\n `is_add_monoid (zero:A) (add:A->A->A) <=>\n (!x. add x zero = x) /\\\n (!x y. add x y = add y x) /\\\n (!x y z. add (add x y) z = add x (add y z))`;;\n\nlet is_integral = new_definition\n `is_integral (integral:(A->A)->A) (add:A->A->A) (zero:A) <=>\n (!g h. (!t. g t = h t) ==> integral g = integral h) /\\\n (!c. integral (\\t. c) = c) /\\\n (!f g. integral (\\t. add (f t) (g t)) =\n add (integral f) (integral g)) /\\\n (!f c. integral (\\t. f (add t c)) = integral f)`;;\n\nlet circleMap = new_definition\n `circleMap (add:A->A->A) c t = add t c`;;\n\nlet circleAverage = new_definition\n `circleAverage (integral:(A->A)->A) (add:A->A->A) (f:A->A) c =\n integral (\\t. f (circleMap add c t))`;;\n\nlet dest_add_monoid th = CONJUNCTS (REWRITE_RULE[is_add_monoid] th);;\nlet dest_integral th = CONJUNCTS (REWRITE_RULE[is_integral] th);;\n\nlet circleMap_zero = `!(zero:A) (add:A->A->A).\n is_add_monoid zero add ==> !t:A. circleMap add zero t = t`;;\n\nlet circleAverage_zero = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_add_monoid zero add /\\ is_integral integral add zero ==>\n !f:A->A. circleAverage integral add f zero = integral f`;;\n\nlet circleAverage_add = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_integral integral add zero ==>\n !(f:A->A) (g:A->A) (c:A).\n circleAverage integral add (\\z. add (f z) (g z)) c =\n add (circleAverage integral add f c) (circleAverage integral add g c)`;;\n\nlet circleAverage_fun_add = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_add_monoid zero add /\\ is_integral integral add zero ==>\n !(f:A->A) (c:A).\n circleAverage integral add (\\z. f (add z c)) zero =\n circleAverage integral add f c`;;\n\nlet circleMap_add = `!(zero:A) (add:A->A->A).\n is_add_monoid zero add ==>\n !(c:A) (d:A) (t:A).\n circleMap add (add c d) t = circleMap add c (circleMap add d t)`;;\n\nlet circleAverage_shift = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_add_monoid zero add /\\ is_integral integral add zero ==>\n !(f:A->A) (c:A) (d:A).\n circleAverage integral add f (add c d) =\n circleAverage integral add (\\z. f (add z d)) c`;;\n\nlet circleAverage_const = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_integral integral add zero ==>\n !(k:A) (c:A). circleAverage integral add (\\z. k) c = k`;;\n\nlet circleAverage_add_const = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_integral integral add zero ==>\n !(f:A->A) (k:A) (c:A).\n circleAverage integral add (\\z. add (f z) k) c =\n add (circleAverage integral add f c) k`;;\n\nlet circleAverage_comm_add = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_add_monoid zero add /\\ is_integral integral add zero ==>\n !(f:A->A) (g:A->A) (c:A).\n circleAverage integral add (\\z. add (f z) (g z)) c =\n circleAverage integral add (\\z. add (g z) (f z)) c`;;\n\nlet circleAverage_add_assoc = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_add_monoid zero add /\\ is_integral integral add zero ==>\n !(f:A->A) (g:A->A) (h:A->A) (c:A).\n circleAverage integral add (\\z. add (add (f z) (g z)) (h z)) c =\n add (circleAverage integral add f c)\n (add (circleAverage integral add g c)\n (circleAverage integral add h c))`;;\n\nlet circleAverage_center_comm = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_add_monoid zero add /\\ is_integral integral add zero ==>\n !(f:A->A) (c:A) (d:A).\n circleAverage integral add f (add c d) =\n circleAverage integral add f (add d c)`;;\n\nlet circleAverage_center_independent = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_integral integral add zero ==>\n !(f:A->A) (c:A). circleAverage integral add f c = integral f`;;\n\nlet circleAverage_center_eq = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_integral integral add zero ==>\n !(f:A->A) (c:A) (d:A).\n circleAverage integral add f c = circleAverage integral add f d`;;\n\nlet circleAverage_idempotent = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_integral integral add zero ==>\n !(f:A->A) (c:A).\n circleAverage integral add (\\z. circleAverage integral add f z) c =\n circleAverage integral add f c`;;\n\nlet circleAverage_of_zero_integral = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_integral integral add zero ==>\n !(f:A->A) (c:A).\n integral f = zero ==> circleAverage integral add f c = zero`;;\n\nlet circleAverage_linear = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_integral integral add zero ==>\n !(f:A->A) (g:A->A) (c:A).\n circleAverage integral add (\\z. add (f z) (g z)) c =\n add (circleAverage integral add f c) (circleAverage integral add g c)`;;\n\nlet circleAverage_shift_commute = `!(zero:A) (add:A->A->A) (integral:(A->A)->A).\n is_add_monoid zero add /\\ is_integral integral add zero ==>\n !(f:A->A) (c:A) (d:A).\n circleAverage integral add (\\z. f (circleMap add d z)) c =\n circleAverage integral add f (add c d)`;;" }, { "theorem_id": 1, "title": "circle_average", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory circle_average\n imports Main\nbegin\n\nsection \"CircleAverage\"\n\nlocale circle_average_setup =\n fixes zero :: \"'r\"\n and add :: \"'r \\ 'r \\ 'r\" (infixl \"+C\" 65)\n and integral :: \"('r \\ 'r) \\ 'r\"\n assumes add_zero : \"\\x. x +C zero = x\"\n and add_comm : \"\\x y. x +C y = y +C x\"\n and add_assoc : \"\\x y z. (x +C y) +C z = x +C (y +C z)\"\n and integral_ext : \"\\g h. (\\\\. g \\ = h \\) \\ integral g = integral h\"\n and integral_const: \"\\c. integral (\\_. c) = c\"\n and integral_add : \"\\f g. integral (\\\\. f \\ +C g \\) = integral f +C integral g\"\n and integral_shift: \"\\f c. integral (\\\\. f (\\ +C c)) = integral f\"\nbegin\n\ndefinition circleMap :: \"'r \\ 'r \\ 'r\"\n where \"circleMap c \\ \\ \\ +C c\"\n\ndefinition circleAverage :: \"('r \\ 'r) \\ 'r \\ 'r\"\n where \"circleAverage f c \\ integral (\\\\. f (circleMap c \\))\"\n\nlemma circleMap_zero: \"circleMap zero \\ = \\\"\n by sorry\n\nlemma circleAverage_zero: \"circleAverage f zero = integral f\"\n by sorry\n\nlemma circleAverage_add:\n \"circleAverage (\\z. f z +C g z) c =\n circleAverage f c +C circleAverage g c\"\n by sorry\n\nlemma circleAverage_fun_add:\n \"circleAverage (\\z. f (z +C c)) zero = circleAverage f c\"\n by sorry\n\nlemma circleMap_add:\n \"circleMap (c +C d) \\ = circleMap c (circleMap d \\)\"\n by sorry\n\nlemma circleAverage_shift:\n \"circleAverage f (c +C d) = circleAverage (\\z. f (z +C d)) c\"\n by sorry\n\nlemma circleAverage_const:\n \"circleAverage (\\_. k) c = k\"\n by sorry\n\nlemma circleAverage_add_const:\n \"circleAverage (\\z. f z +C k) c = circleAverage f c +C k\"\n by sorry\n\nlemma circleAverage_comm_add:\n \"circleAverage (\\z. f z +C g z) c =\n circleAverage (\\z. g z +C f z) c\"\n by sorry\n\nlemma circleAverage_add_assoc:\n \"circleAverage (\\z. (f z +C g z) +C h z) c =\n circleAverage f c +C (circleAverage g c +C circleAverage h c)\"\n by sorry\n\nlemma circleAverage_center_comm:\n \"circleAverage f (c +C d) = circleAverage f (d +C c)\"\n by sorry\n\nlemma circleAverage_center_independent:\n \"circleAverage f c = integral f\"\n by sorry\n\nlemma circleAverage_center_eq:\n \"circleAverage f c = circleAverage f d\"\n by sorry\n\nlemma circleAverage_idempotent:\n \"circleAverage (\\z. circleAverage f z) c = circleAverage f c\"\n by sorry\n\nlemma circleAverage_of_zero_integral:\n \"integral f = zero \\ circleAverage f c = zero\"\n by sorry\n\nlemma circleAverage_linear:\n \"circleAverage (\\z. f z +C g z) c =\n circleAverage f c +C circleAverage g c\"\n by sorry\n\nlemma circleAverage_shift_commute:\n \"circleAverage (\\z. f (circleMap d z)) c =\n circleAverage f (c +C d)\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 1, "title": "circle_average", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "class AddMonoid (R : Type) where\n zero : R\n add : R → R → R\n add_zero : ∀ x, add x zero = x\n add_comm : ∀ x y, add x y = add y x\n add_assoc : ∀ x y z, add (add x y) z = add x (add y z)\n\nnamespace CircleAverage\nvariable {R : Type} [AddMonoid R]\n\naxiom integral : (R → R) → R\naxiom integral_ext : ∀ (g h : R → R), (∀ θ, g θ = h θ) → integral g = integral h\naxiom integral_const : ∀ (c : R), integral (fun _ => c) = c\naxiom integral_add : ∀ (f g : R → R),\n integral (fun θ => AddMonoid.add (f θ) (g θ)) =\n AddMonoid.add (integral f) (integral g)\naxiom integral_shift : ∀ (f : R → R) (c : R),\n integral (fun θ => f (AddMonoid.add θ c)) = integral f\n\ndef circleMap (c θ : R) : R := AddMonoid.add θ c\nnoncomputable def circleAverage (f : R → R) (c : R) : R :=\n integral (fun θ => f (circleMap c θ))\n\ntheorem circleMap_zero (θ : R) :\n circleMap AddMonoid.zero θ = θ := by sorry\ntheorem circleAverage_zero (f : R → R) :\n circleAverage f AddMonoid.zero = integral f := by sorry\ntheorem circleAverage_add (f g : R → R) (c : R) :\n circleAverage (fun z => AddMonoid.add (f z) (g z)) c =\n AddMonoid.add (circleAverage f c) (circleAverage g c) := by sorry\ntheorem circleAverage_fun_add (f : R → R) (c : R) :\n circleAverage (fun z => f (AddMonoid.add z c)) AddMonoid.zero =\n circleAverage f c := by sorry\ntheorem circleMap_add (c d θ : R) :\n circleMap (AddMonoid.add c d) θ =\n circleMap c (circleMap d θ) := by sorry\ntheorem circleAverage_shift (f : R → R) (c d : R) :\n circleAverage f (AddMonoid.add c d) =\n circleAverage (fun z => f (AddMonoid.add z d)) c := by sorry\ntheorem circleAverage_const (k c : R) :\n circleAverage (fun _ => k) c = k := by sorry\ntheorem circleAverage_add_const (f : R → R) (k c : R) :\n circleAverage (fun z => AddMonoid.add (f z) k) c =\n AddMonoid.add (circleAverage f c) k := by sorry\ntheorem circleAverage_comm_add (f g : R → R) (c : R) :\n circleAverage (fun z => AddMonoid.add (f z) (g z)) c =\n circleAverage (fun z => AddMonoid.add (g z) (f z)) c := by sorry\ntheorem circleAverage_add_assoc (f g h : R → R) (c : R) :\n circleAverage (fun z => AddMonoid.add (AddMonoid.add (f z) (g z)) (h z)) c =\n AddMonoid.add (circleAverage f c)\n (AddMonoid.add (circleAverage g c) (circleAverage h c)) := by sorry\ntheorem circleAverage_center_comm (f : R → R) (c d : R) :\n circleAverage f (AddMonoid.add c d) =\n circleAverage f (AddMonoid.add d c) := by sorry\ntheorem circleAverage_center_independent (f : R → R) (c : R) :\n circleAverage f c = integral f := by sorry\ntheorem circleAverage_center_eq (f : R → R) (c d : R) :\n circleAverage f c = circleAverage f d := by sorry\ntheorem circleAverage_idempotent (f : R → R) (c : R) :\n circleAverage (fun z => circleAverage f z) c = circleAverage f c := by sorry\ntheorem circleAverage_of_zero_integral (f : R → R) (c : R) (H : integral f = AddMonoid.zero) :\n circleAverage f c = AddMonoid.zero := by sorry\ntheorem circleAverage_linear (f g : R → R) (c : R) :\n circleAverage (fun z => AddMonoid.add (f z) (g z)) c =\n AddMonoid.add (circleAverage f c) (circleAverage g c) := by sorry\ntheorem circleAverage_shift_commute (f : R → R) (c d : R) :\n circleAverage (fun z => f (circleMap d z)) c =\n circleAverage f (AddMonoid.add c d) := by sorry\nend CircleAverage\n" }, { "theorem_id": 1, "title": "circle_average", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Class AddMonoid (R : Type) := {\n zero : R;\n add : R -> R -> R;\n add_zero : forall x, add x zero = x;\n add_comm : forall x y, add x y = add y x;\n add_assoc : forall x y z, add (add x y) z = add x (add y z)\n}.\n\nSection CircleAverage.\n Context {R : Type} {M : AddMonoid R}.\n\n Axiom integral : (R -> R) -> R.\n Axiom integral_ext : forall g h,\n (forall θ, g θ = h θ) ->\n integral g = integral h.\n Axiom integral_const : forall c,\n integral (fun _ => c) = c.\n Axiom integral_add : forall f g,\n integral (fun θ => add (f θ) (g θ)) =\n add (integral f) (integral g).\n\n Axiom integral_shift : forall f c,\n integral (fun θ => f (add θ c)) = integral f.\n\n\n Definition circleMap (c θ : R) : R := add θ c.\n\n Definition circleAverage (f : R -> R) (c : R) : R :=\n integral (fun θ => f (circleMap c θ)).\n\n Lemma circleMap_zero :\n forall θ, circleMap zero θ = θ.\nProof.\nAdmitted.\n\n Lemma circleAverage_zero :\n forall f, circleAverage f zero = integral f.\nProof.\nAdmitted.\n\n Lemma circleAverage_add :\n forall f g c,\n circleAverage (fun z => add (f z) (g z)) c =\n add (circleAverage f c) (circleAverage g c).\nProof.\nAdmitted.\n\n Theorem circleAverage_fun_add :\n forall f c,\n circleAverage (fun z => f (add z c)) zero =\n circleAverage f c.\nProof.\nAdmitted.\n\n Lemma circleMap_add :\n forall c d θ,\n circleMap (add c d) θ =\n circleMap c (circleMap d θ).\nProof.\nAdmitted.\n\n Lemma circleAverage_shift :\n forall f c d,\n circleAverage f (add c d) =\n circleAverage (fun z => f (add z d)) c.\nProof.\nAdmitted.\n\n Lemma circleAverage_const :\n forall k c, circleAverage (fun _ => k) c = k.\nProof.\nAdmitted.\n\n Lemma circleAverage_add_const :\n forall f k c,\n circleAverage (fun z => add (f z) k) c =\n add (circleAverage f c) k.\nProof.\nAdmitted.\n\n Lemma circleAverage_comm_add :\n forall f g c,\n circleAverage (fun z => add (f z) (g z)) c =\n circleAverage (fun z => add (g z) (f z)) c.\nProof.\nAdmitted.\n\n Lemma circleAverage_add_assoc :\n forall f g h c,\n circleAverage (fun z => add (add (f z) (g z)) (h z)) c =\n add (circleAverage f c)\n (add (circleAverage g c) (circleAverage h c)).\nProof.\nAdmitted.\n\n Lemma circleAverage_center_comm :\n forall f c d,\n circleAverage f (add c d) =\n circleAverage f (add d c).\nProof.\nAdmitted.\n Lemma circleAverage_center_independent :\n forall f c,\n circleAverage f c = integral f.\nProof.\nAdmitted.\n\n Lemma circleAverage_center_eq :\n forall f c d,\n circleAverage f c = circleAverage f d.\nProof.\nAdmitted.\n\n Lemma circleAverage_idempotent :\n forall f c,\n circleAverage (fun z => circleAverage f z) c = circleAverage f c.\nProof.\nAdmitted.\n\n Lemma circleAverage_of_zero_integral :\n forall f c,\n integral f = zero -> circleAverage f c = zero.\nProof.\nAdmitted.\n\n Lemma circleAverage_linear :\n forall f g c,\n circleAverage (fun z => add (f z) (g z)) c =\n add (circleAverage f c) (circleAverage g c).\nProof.\nAdmitted.\n \n Lemma circleAverage_shift_commute :\n forall f c d,\n circleAverage (fun z => f (circleMap d z)) c =\n circleAverage f (add c d).\nProof.\nAdmitted.\nEnd CircleAverage.\n" }, { "theorem_id": 2, "title": "comp_commute", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let myComp = new_definition\n `myComp (g:B->C) (f:A->B) = (\\x:A. g (f x))`;;\n\nlet myId = new_definition\n `myId = (\\x:A. x)`;;\n\nlet comp_assoc = `!h g f. myComp h (myComp g f) = myComp (myComp h g) f`;;\n\nlet comp_id_l = `!f:A->B. myComp myId f = f`;;\n\nlet comp_id_r = `!f:A->B. myComp f myId = f`;;\n\nlet commute = new_definition\n `commute (f:A->A) (g:A->A) <=> myComp f g = myComp g f`;;\n\nlet commute_symm = `!f g. commute f g ==> commute g f`;;\n\nlet commute_with_id_l = `!f:A->A. commute f myId`;;\n\nlet commute_with_id_r = `!f:A->A. commute myId f`;;\n\nlet commute_refl = `!f:A->A. commute f f`;;\n\nlet commute_congr = `!f1 f2 g1 g2:A->A.\n f1 = f2 ==> g1 = g2 ==> commute f1 g1 ==> commute f2 g2`;;\n\nlet commute_transport_left_id = `!f g:A->A. commute f g ==> commute (myComp myId f) g`;;\n\nlet commute_transport_right_id = `!f g:A->A. commute f g ==> commute f (myComp myId g)`;;" }, { "theorem_id": 2, "title": "comp_commute", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory comp_commute\n imports Main\nbegin\n\nsection \"CompCommute\"\n\ndefinition myComp :: \"('b \\ 'c) \\ ('a \\ 'b) \\ ('a \\ 'c)\"\n where \"myComp g f \\ \\x. g (f x)\"\n\ndefinition myId :: \"'a \\ 'a\"\n where \"myId \\ \\x. x\"\n\nlemma comp_assoc:\n \"myComp h (myComp g f) = myComp (myComp h g) f\"\n by sorry\n\nlemma comp_id_l:\n \"myComp myId f = f\"\n by sorry\n\nlemma comp_id_r:\n \"myComp f myId = f\"\n by sorry\n\ndefinition commute :: \"('a \\ 'a) \\ ('a \\ 'a) \\ bool\"\n where \"commute f g \\ myComp f g = myComp g f\"\n\nlemma commute_symm:\n \"commute f g \\ commute g f\"\n by sorry\n\nlemma commute_with_id_l:\n \"commute f myId\"\n by sorry\n\nlemma commute_with_id_r:\n \"commute myId f\"\n by sorry\n\nlemma commute_refl:\n \"commute f f\"\n by sorry\n\nlemma commute_congr:\n \"f1 = f2 \\ g1 = g2 \\ commute f1 g1 \\ commute f2 g2\"\n by sorry\n\nlemma commute_transport_left_id:\n \"commute f g \\ commute (myComp myId f) g\"\n by sorry\n\nlemma commute_transport_right_id:\n \"commute f g \\ commute f (myComp myId g)\"\n by sorry\n\nend" }, { "theorem_id": 2, "title": "comp_commute", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "universe u v w\n\nnamespace CompCommute\n\nvariable {α : Type u} {β : Type v} {γ : Type w}\n\ndef comp {α β γ} (g : β → γ) (f : α → β) : α → γ := fun x => g (f x)\ndef id {α} : α → α := fun x => x\n\naxiom comp_assoc : ∀ {α β γ δ} (h : γ → δ) (g : β → γ) (f : α → β), comp h (comp g f) = comp (comp h g) f\naxiom comp_id_l : ∀ {α β} (f : α → β), comp (id) f = f\naxiom comp_id_r : ∀ {α β} (f : α → β), comp f id = f\n\ndef commute {α} (f g : α → α) : Prop := comp f g = comp g f\n\ntheorem commute_symm {α} (f g : α → α) : commute f g → commute g f := by sorry\ntheorem commute_with_id_l {α} (f : α → α) : commute f (id) := by sorry\ntheorem commute_with_id_r {α} (f : α → α) : commute (id) f := by sorry\ntheorem commute_refl {α} (f : α → α) : commute f f := by sorry\ntheorem commute_congr {α} (f1 f2 g1 g2 : α → α) :\n f1 = f2 → g1 = g2 → commute f1 g1 → commute f2 g2 := by sorry\ntheorem commute_transport_left_id {α} (f g : α → α) :\n commute f g → commute (comp (id) f) g := by sorry\ntheorem commute_transport_right_id {α} (f g : α → α) :\n commute f g → commute f (comp (id) g) := by sorry\nend CompCommute\n" }, { "theorem_id": 2, "title": "comp_commute", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Section CompCommute.\n Universes u v w.\n Definition comp {α β γ : Type} (g : β -> γ) (f : α -> β) : α -> γ := fun x => g (f x).\n Definition id {α : Type} : α -> α := fun x => x.\n\n Class FunProps := {\n comp_assoc : forall {α β γ δ} (h : γ -> δ) (g : β -> γ) (f : α -> β), comp h (comp g f) = comp (comp h g) f;\n comp_id_l : forall {α β} (f : α -> β), comp (@id β) f = f;\n comp_id_r : forall {α β} (f : α -> β), comp f (@id α) = f\n }.\n\n Definition commute {α : Type} (f g : α -> α) : Prop := comp f g = comp g f.\n\n Context {FP : FunProps}.\n\n Lemma commute_symm : forall {α} (f g : α -> α), commute f g -> commute g f.\nProof.\nAdmitted.\n\n Lemma commute_with_id_l : forall {α} (f : α -> α), commute f (@id α).\nProof.\nAdmitted.\n\n Lemma commute_with_id_r : forall {α} (f : α -> α), commute (@id α) f.\nProof.\nAdmitted.\n\n Lemma commute_refl : forall {α} (f : α -> α), commute f f.\nProof.\nAdmitted.\n\n Lemma commute_congr : forall {α} (f1 f2 g1 g2 : α -> α),\n f1 = f2 -> g1 = g2 -> commute f1 g1 -> commute f2 g2.\nProof.\nAdmitted.\n\n Lemma commute_transport_left_id : forall {α} (f g : α -> α),\n commute f g -> commute (comp (@id α) f) g.\nProof.\nAdmitted.\n\n Lemma commute_transport_right_id : forall {α} (f g : α -> α),\n commute f g -> commute f (comp (@id α) g).\nProof.\nAdmitted.\n\nEnd CompCommute.\n" }, { "theorem_id": 3, "title": "galois", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let field_like = new_definition\n `field_like (zero_F:'a) (one_F:'a) (add_F:'a->'a->'a) (mul_F:'a->'a->'a)\n (opp_F:'a->'a) (inv_F:'a->'a) <=>\n (!x:'a y:'a. add_F x y = add_F y x) /\\\n (!x:'a y:'a z:'a. add_F (add_F x y) z = add_F x (add_F y z)) /\\\n (!x:'a. add_F x zero_F = x) /\\\n (!x:'a. add_F (opp_F x) x = zero_F) /\\\n (!x:'a y:'a. mul_F x y = mul_F y x) /\\\n (!x:'a y:'a z:'a. mul_F (mul_F x y) z = mul_F x (mul_F y z)) /\\\n (!x:'a. mul_F one_F x = x) /\\\n (!x:'a. ~(x = zero_F) ==> mul_F (inv_F x) x = one_F) /\\\n (!x:'a y:'a z:'a. mul_F x (add_F y z) = add_F (mul_F x y) (mul_F x z)) /\\\n ~(zero_F = one_F) /\\\n (!x:'a. ~(x = zero_F) ==> ~(inv_F x = zero_F))`;;\n\nlet tower = new_definition\n `tower (solv:'a->bool) (mp:'a->'a) (splt:'a->bool) <=>\n (!p:'a q:'a. solv p ==> solv (mp q) ==> solv q) /\\\n (!p:'a. solv p ==> solv (mp p)) /\\\n (!p:'a. splt p ==> solv p)`;;\n\nlet zero_add = `!zero_F:'f one_F:'f (add_F:'f->'f->'f) (mul_F:'f->'f->'f)\n (opp_F:'f->'f) (inv_F:'f->'f).\n field_like zero_F one_F add_F mul_F opp_F inv_F ==> !x:'f. add_F zero_F x = x`;;\n\nlet mul_one_r = `!zero_F:'f one_F:'f (add_F:'f->'f->'f) (mul_F:'f->'f->'f)\n (opp_F:'f->'f) (inv_F:'f->'f).\n field_like zero_F one_F add_F mul_F opp_F inv_F ==> !x. mul_F x one_F = x`;;\n\nlet mul_inv_r = `!zero_F:'f one_F:'f (add_F:'f->'f->'f) (mul_F:'f->'f->'f)\n (opp_F:'f->'f) (inv_F:'f->'f).\n field_like zero_F one_F add_F mul_F opp_F inv_F ==>\n !x. ~(x = zero_F) ==> mul_F x (inv_F x) = one_F`;;\n\nlet add_cancel_l = `!zero_F:'f one_F:'f (add_F:'f->'f->'f) (mul_F:'f->'f->'f)\n (opp_F:'f->'f) (inv_F:'f->'f).\n field_like zero_F one_F add_F mul_F opp_F inv_F ==>\n !x y z. add_F x y = add_F x z ==> y = z`;;\n\nlet add_cancel_r = `!zero_F:'f one_F:'f (add_F:'f->'f->'f) (mul_F:'f->'f->'f)\n (opp_F:'f->'f) (inv_F:'f->'f).\n field_like zero_F one_F add_F mul_F opp_F inv_F ==>\n !x y z. add_F y x = add_F z x ==> y = z`;;\n\nlet mul_cancel_l = `!zero_F:'f one_F:'f (add_F:'f->'f->'f) (mul_F:'f->'f->'f)\n (opp_F:'f->'f) (inv_F:'f->'f).\n field_like zero_F one_F add_F mul_F opp_F inv_F ==>\n !x y z. ~(x = zero_F) ==> mul_F x y = mul_F x z ==> y = z`;;\n\nlet mul_cancel_r = `!zero_F:'f one_F:'f (add_F:'f->'f->'f) (mul_F:'f->'f->'f)\n (opp_F:'f->'f) (inv_F:'f->'f).\n field_like zero_F one_F add_F mul_F opp_F inv_F ==>\n !x y z. ~(x = zero_F) ==> mul_F y x = mul_F z x ==> y = z`;;\n\nlet inv_unique = `!zero_F:'f one_F:'f (add_F:'f->'f->'f) (mul_F:'f->'f->'f)\n (opp_F:'f->'f) (inv_F:'f->'f).\n field_like zero_F one_F add_F mul_F opp_F inv_F ==>\n !x y. ~(x = zero_F) ==> mul_F x y = one_F ==> y = inv_F x`;;\n\nlet inv_involutive = `!zero_F:'f one_F:'f (add_F:'f->'f->'f) (mul_F:'f->'f->'f)\n (opp_F:'f->'f) (inv_F:'f->'f).\n field_like zero_F one_F add_F mul_F opp_F inv_F ==>\n !x. ~(x = zero_F) ==> inv_F (inv_F x) = x`;;\n\nlet gal_isSolvable_tower = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a q:'a.\n tower solv mp splt ==> solv p ==> solv (mp q) ==> solv q`;;\n\nlet gal_isSolvable_double_tower = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a q:'a r:'a.\n tower solv mp splt ==> solv p ==> solv (mp q) ==> solv (mp r) ==> solv r`;;\n\nlet gal_isSolvable_triple_tower = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a q:'a r:'a s:'a.\n tower solv mp splt ==> solv p ==> solv (mp q) ==> solv (mp r) ==> solv (mp s) ==> solv s`;;\n\nlet gal_isSolvable_quadruple_tower = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a q:'a r:'a s:'a t:'a.\n tower solv mp splt ==> solv p ==> solv (mp q) ==> solv (mp r) ==> solv (mp s) ==> solv (mp t) ==> solv t`;;\n\nlet gal_isSolvable_map_poly = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a.\n tower solv mp splt ==> solv p ==> solv (mp p)`;;\n\nlet gal_isSolvable_of_split = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a.\n tower solv mp splt ==> splt p ==> solv p`;;\n\nlet gal_isSolvable_split_tower = `!solv:'a->bool mp:'a->'a splt:'a->bool q:'a r:'a.\n tower solv mp splt ==> splt q ==> solv (mp r) ==> solv r`;;\n\nlet gal_isSolvable_two_step_map = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a.\n tower solv mp splt ==> solv p ==> solv (mp (mp p))`;;\n\nlet gal_isSolvable_three_step_map = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a.\n tower solv mp splt ==> solv p ==> solv (mp (mp (mp p)))`;;\n\nlet gal_isSolvable_map_poly_comp = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a.\n tower solv mp splt ==> solv p ==> solv (mp (mp p))`;;\n\nlet gal_isSolvable_mutual_split = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a q:'a.\n tower solv mp splt ==> splt p ==> splt q ==> solv p /\\ solv q`;;\n\nlet gal_isSolvable_map_after_split = `!solv:'a->bool mp:'a->'a splt:'a->bool p:'a.\n tower solv mp splt ==> splt p ==> solv (mp p)`;;\n\nlet gal_isSolvable_tower_split = `!solv:'a->bool mp:'a->'a splt:'a->bool q:'a r:'a.\n tower solv mp splt ==> splt q ==> solv (mp r) ==> solv r`;;" }, { "theorem_id": 3, "title": "galois", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory galois\n imports Main\nbegin\n\nsection \"Galois\"\n\nlocale field_like =\n fixes zero_F one_F :: \"'f\"\n and add_F :: \"'f \\ 'f \\ 'f\" (infixl \"+F\" 65)\n and mul_F :: \"'f \\ 'f \\ 'f\" (infixl \"*F\" 70)\n and opp_F :: \"'f \\ 'f\"\n and inv_F :: \"'f \\ 'f\"\n assumes add_comm : \"\\x y. x +F y = y +F x\"\n and add_assoc : \"\\x y z. (x +F y) +F z = x +F (y +F z)\"\n and add_zero : \"\\x. x +F zero_F = x\"\n and add_inv_l : \"\\x. opp_F x +F x = zero_F\"\n and mul_comm : \"\\x y. x *F y = y *F x\"\n and mul_assoc : \"\\x y z. (x *F y) *F z = x *F (y *F z)\"\n and mul_one_l : \"\\x. one_F *F x = x\"\n and mul_inv_l : \"\\x. x \\ zero_F \\ inv_F x *F x = one_F\"\n and distrib_l : \"\\x y z. x *F (y +F z) = (x *F y) +F (x *F z)\"\n and zero_neq_one: \"zero_F \\ one_F\"\n and inv_nonzero : \"\\x. x \\ zero_F \\ inv_F x \\ zero_F\"\nbegin\n\nlemma zero_add: \"zero_F +F x = x\"\n by sorry\n\nlemma mul_one_r: \"x *F one_F = x\"\n by sorry\n\nlemma mul_inv_r: \"x \\ zero_F \\ x *F inv_F x = one_F\"\n by sorry\n\nlemma add_cancel_l: \"x +F y = x +F z \\ y = z\"\n by sorry\n\nlemma add_cancel_r: \"y +F x = z +F x \\ y = z\"\n by sorry\n\nlemma mul_cancel_l: \"x \\ zero_F \\ x *F y = x *F z \\ y = z\"\n by sorry\n\nlemma mul_cancel_r: \"x \\ zero_F \\ y *F x = z *F x \\ y = z\"\n by sorry\n\nlemma inv_unique: \"x \\ zero_F \\ x *F y = one_F \\ y = inv_F x\"\n by sorry\n\nlemma inv_involutive: \"x \\ zero_F \\ inv_F (inv_F x) = x\"\n by sorry\n\nend\n\nlocale tower =\n fixes S :: \"'p \\ bool\"\n and mp :: \"'p \\ 'p\"\n and splt :: \"'p \\ bool\"\n assumes scalar_tower : \"\\p q. S p \\ S (mp q) \\ S q\"\n and map_solv : \"\\p. S p \\ S (mp p)\"\n and splits_solv : \"\\p. splt p \\ S p\"\nbegin\n\nlemma gal_isSolvable_tower:\n \"S p \\ S (mp q) \\ S q\"\n by sorry\n\nlemma gal_isSolvable_double_tower:\n \"S p \\ S (mp q) \\ S (mp r) \\ S r\"\n by sorry\n\nlemma gal_isSolvable_triple_tower:\n \"S p \\ S (mp q) \\ S (mp r) \\ S (mp s) \\ S s\"\n by sorry\n\nlemma gal_isSolvable_quadruple_tower:\n \"S p \\ S (mp q) \\ S (mp r) \\ S (mp s) \\ S (mp t) \\ S t\"\n by sorry\n\nlemma gal_isSolvable_map_poly:\n \"S p \\ S (mp p)\"\n by sorry\n\nlemma gal_isSolvable_of_split:\n \"splt p \\ S p\"\n by sorry\n\nlemma gal_isSolvable_split_tower:\n \"splt q \\ S (mp r) \\ S r\"\n by sorry\n\nlemma gal_isSolvable_two_step_map:\n \"S p \\ S (mp (mp p))\"\n by sorry\n\nlemma gal_isSolvable_three_step_map:\n \"S p \\ S (mp (mp (mp p)))\"\n by sorry\n\nlemma gal_isSolvable_map_poly_comp:\n \"S p \\ S (mp (mp p))\"\n by sorry\n\nlemma gal_isSolvable_mutual_split:\n \"splt p \\ splt q \\ S p \\ S q\"\n by sorry\n\nlemma gal_isSolvable_map_after_split:\n \"splt p \\ S (mp p)\"\n by sorry\n\nlemma gal_isSolvable_tower_split:\n \"splt q \\ S (mp r) \\ S r\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 3, "title": "galois", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "class Field (F : Type) where\n zero_F : F\n one_F : F\n add_F : F → F → F\n mul_F : F → F → F\n opp_F : F → F\n inv_F : F → F\n\n add_comm : ∀ x y, add_F x y = add_F y x\n add_assoc : ∀ x y z, add_F (add_F x y) z = add_F x (add_F y z)\n add_zero : ∀ x, add_F x zero_F = x\n add_inv_l : ∀ x, add_F (opp_F x) x = zero_F\n\n mul_comm : ∀ x y, mul_F x y = mul_F y x\n mul_assoc : ∀ x y z, mul_F (mul_F x y) z = mul_F x (mul_F y z)\n mul_one_l : ∀ x, mul_F one_F x = x\n mul_inv_l : ∀ x, x ≠ zero_F → mul_F (inv_F x) x = one_F\n\n distrib_l : ∀ x y z, mul_F x (add_F y z) = add_F (mul_F x y) (mul_F x z)\n\n zero_neq_one : zero_F ≠ one_F\n inv_nonzero : ∀ x, x ≠ zero_F → inv_F x ≠ zero_F\n\nnamespace FieldProperties\nvariable {F : Type} [HF : Field F]\nopen Field\n\ninfixl:65 \"+\" => add_F\ninfixl:70 \"*\" => mul_F\nprefix:100 \"-\" => opp_F\nprefix:100 \"/\" => inv_F\n\ntheorem add_cancel_l (x y z : F) : x + y = x + z → y = z := by sorry\ntheorem add_cancel_r (x y z : F) : y + x = z + x → y = z := by sorry\ntheorem mul_cancel_l (x y z : F) (h : x ≠ zero_F) : x * y = x * z → y = z := by sorry\ntheorem mul_cancel_r (x y z : F) (h : x ≠ zero_F) : y * x = z * x → y = z := by sorry\ntheorem inv_unique (x y : F) (h : x ≠ zero_F) (H : x * y = one_F) : y = inv_F x := by sorry\ntheorem inv_involutive (x : F) (h : x ≠ zero_F) : inv_F (inv_F x) = x := by sorry\nend FieldProperties\n\nclass IsSolvable (G : Type) : Prop\n\nnamespace Tower\nvariable {polynomial : Type → Type}\nvariable {SplittingField : ∀ {F : Type}, polynomial F → Type}\nvariable {algebraMap : ∀ {F K : Type}, F → K}\nvariable {Splits : ∀ {F K : Type}, polynomial F → (F → K) → Prop}\nvariable {map_poly : ∀ {F K : Type}, polynomial F → (F → K) → polynomial K}\nvariable {Gal : ∀ {F : Type}, polynomial F → Type}\n\nvariable {F : Type}\nvariable (p q r s t : polynomial F)\nvariable (K L : Type)\n\naxiom map_poly_comp : ∀ {F K L : Type} (p : polynomial F)\n (f : F → K) (g : K → L), map_poly (map_poly p f) g = map_poly p (fun x => g (f x))\naxiom isSolvable_of_isScalarTower : ∀ {F K : Type} {p q : polynomial F},\n IsSolvable (Gal p) → IsSolvable (Gal (map_poly q (@algebraMap F K))) → IsSolvable (Gal q)\naxiom isSolvable_map_poly : ∀ {F K : Type} (p : polynomial F),\n IsSolvable (Gal p) → IsSolvable (Gal (map_poly p (@algebraMap F K)))\naxiom isSolvable_of_splits : ∀ {F K : Type} (p : polynomial F) (f : F → K),\n Splits p f → IsSolvable (Gal p)\n\ntheorem gal_isSolvable_tower\n (hp : IsSolvable (Gal p))\n (hq : IsSolvable (Gal (map_poly q (@algebraMap F (SplittingField p))))) :\n IsSolvable (Gal q) := by sorry\ntheorem gal_isSolvable_double_tower\n (hp : IsSolvable (Gal p))\n (hq : IsSolvable (Gal (map_poly q (@algebraMap F (SplittingField p)))))\n (hr : IsSolvable (Gal (map_poly r (@algebraMap F (SplittingField q))))) :\n IsSolvable (Gal r) := by sorry\ntheorem gal_isSolvable_triple_tower\n (hp : IsSolvable (Gal p))\n (hq : IsSolvable (Gal (map_poly q (@algebraMap F (SplittingField p)))))\n (hr : IsSolvable (Gal (map_poly r (@algebraMap F (SplittingField q)))))\n (hs : IsSolvable (Gal (map_poly s (@algebraMap F (SplittingField r))))) :\n IsSolvable (Gal s) := by sorry\ntheorem gal_isSolvable_quadruple_tower\n (hp : IsSolvable (Gal p))\n (hq : IsSolvable (Gal (map_poly q (@algebraMap F (SplittingField p)))))\n (hr : IsSolvable (Gal (map_poly r (@algebraMap F (SplittingField q)))))\n (hs : IsSolvable (Gal (map_poly s (@algebraMap F (SplittingField r)))))\n (ht : IsSolvable (Gal (map_poly t (@algebraMap F (SplittingField s))))) :\n IsSolvable (Gal t) := by sorry\ntheorem gal_isSolvable_map_poly (hp : IsSolvable (Gal p)) :\n IsSolvable (Gal (map_poly p (@algebraMap F K))) := by sorry\ntheorem gal_isSolvable_of_split\n (hsplit : Splits p (@algebraMap F (SplittingField p))) :\n IsSolvable (Gal p) := by sorry\ntheorem gal_isSolvable_split_tower\n (hsplit : Splits q (@algebraMap F (SplittingField p))) :\n IsSolvable (Gal q) := by sorry\ntheorem gal_isSolvable_two_step_map (hp : IsSolvable (Gal p)) :\n IsSolvable (Gal (map_poly (map_poly p (@algebraMap F K)) (@algebraMap K L))) := by sorry\ntheorem gal_isSolvable_three_step_map {M : Type}\n (hp : IsSolvable (Gal p)) :\n IsSolvable (Gal (map_poly (map_poly (map_poly p (@algebraMap F K))\n (@algebraMap K L))\n (@algebraMap L M))) := by sorry\ntheorem gal_isSolvable_map_poly_comp (hp : IsSolvable (Gal p)) :\n IsSolvable (Gal (map_poly (map_poly p (@algebraMap F K)) (@algebraMap K L))) := by sorry\ntheorem gal_isSolvable_mutual_split\n (hsplit_p : Splits p (@algebraMap F (SplittingField q)))\n (hsplit_q : Splits q (@algebraMap F (SplittingField p))) :\n IsSolvable (Gal p) ∧ IsSolvable (Gal q) := by sorry\ntheorem gal_isSolvable_tower_split\n (hsplit_q : Splits q (@algebraMap F (SplittingField p)))\n (hr : IsSolvable (Gal (map_poly r (@algebraMap F (SplittingField q))))) :\n IsSolvable (Gal r) := by sorry\ntheorem gal_isSolvable_map_after_split\n (hsplit : Splits p (@algebraMap F (SplittingField p))) :\n IsSolvable (Gal (map_poly p (@algebraMap F K))) := by sorry\nend Tower\n" }, { "theorem_id": 3, "title": "galois", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Class Field (F : Type) := {\n zero_F : F;\n one_F : F;\n add_F : F -> F -> F;\n mul_F : F -> F -> F;\n opp_F : F -> F;\n inv_F : F -> F;\n\n add_comm : forall x y, add_F x y = add_F y x;\n add_assoc : forall x y z, add_F (add_F x y) z = add_F x (add_F y z);\n add_zero : forall x, add_F x zero_F = x;\n add_inv_l : forall x, add_F (opp_F x) x = zero_F;\n\n mul_comm : forall x y, mul_F x y = mul_F y x;\n mul_assoc : forall x y z, mul_F (mul_F x y) z = mul_F x (mul_F y z);\n mul_one_l : forall x, mul_F one_F x = x;\n mul_inv_l : forall x, x <> zero_F -> mul_F (inv_F x) x = one_F;\n\n distrib_l : forall x y z, mul_F x (add_F y z) = add_F (mul_F x y) (mul_F x z);\n\n zero_neq_one : zero_F <> one_F;\n inv_nonzero : forall x, x <> zero_F -> inv_F x <> zero_F;\n}.\n\nSection FieldProperties.\n Context {F : Type} {HF : Field F}.\n\n Infix \"+\" := add_F.\n Infix \"*\" := mul_F.\n Notation \"- x\" := (opp_F x).\n Notation \"/ x\" := (inv_F x).\n Notation \"0\" := zero_F.\n Notation \"1\" := one_F.\n\n Lemma add_cancel_l (x y z : F) : x + y = x + z -> y = z.\nProof.\nAdmitted.\n\n Lemma add_cancel_r (x y z : F) : y + x = z + x -> y = z.\nProof.\nAdmitted.\n\n Lemma mul_cancel_l (x y z : F) : x <> 0 -> x * y = x * z -> y = z.\nProof.\nAdmitted.\n\n Lemma mul_cancel_r (x y z : F) : x <> 0 -> y * x = z * x -> y = z.\nProof.\nAdmitted.\n\n Lemma inv_unique (x y : F) : x <> 0 -> x * y = 1 -> y = inv_F x.\nProof.\nAdmitted.\n\n Lemma inv_involutive (x : F) : x <> 0 -> inv_F (inv_F x) = x.\nProof.\nAdmitted.\n\nEnd FieldProperties.\n\nClass IsSolvable (G : Type) : Prop.\n\nSection Tower.\n Variable polynomial : Type -> Type.\n Variable SplittingField : forall {F : Type}, polynomial F -> Type.\n Variable algebraMap : forall {F K : Type}, F -> K.\n Variable Splits : forall {F K : Type}, polynomial F -> (F -> K) -> Prop.\n Variable map_poly : forall {F K : Type}, polynomial F -> (F -> K) -> polynomial K.\n Variable Gal : forall {F : Type}, polynomial F -> Type.\n\n Context {F : Type}.\n Variables p q r s t : polynomial F.\n Variables K L : Type.\n\n Variables u v : polynomial F.\n Axiom map_poly_comp :\n forall {F K L : Type} (p : polynomial F)\n (f : F -> K) (g : K -> L),\n map_poly (map_poly p f) g\n = map_poly p (fun x => g (f x)).\n Axiom isSolvable_of_isScalarTower :\n forall {F K : Type} {p q : polynomial F},\n IsSolvable (Gal p) ->\n IsSolvable (Gal (map_poly q (@algebraMap F K))) ->\n IsSolvable (Gal q).\n\n Axiom isSolvable_map_poly :\n forall {F K : Type} (p : polynomial F),\n IsSolvable (Gal p) ->\n IsSolvable (Gal (map_poly p (@algebraMap F K))).\n\n\n Axiom isSolvable_of_splits :\n forall {F K : Type} (p : polynomial F) (f : F -> K),\n Splits p f -> IsSolvable (Gal p).\n\n Theorem gal_isSolvable_tower\n (hp : IsSolvable (Gal p))\n (hq : IsSolvable (Gal (map_poly q (@algebraMap F (SplittingField p)))))\n : IsSolvable (Gal q).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_double_tower\n (hp : IsSolvable (Gal p))\n (hq : IsSolvable (Gal (map_poly q (@algebraMap F (SplittingField p)))))\n (hr : IsSolvable (Gal (map_poly r (@algebraMap F (SplittingField q)))))\n : IsSolvable (Gal r).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_triple_tower\n (hp : IsSolvable (Gal p))\n (hq : IsSolvable (Gal (map_poly q (@algebraMap F (SplittingField p)))))\n (hr : IsSolvable (Gal (map_poly r (@algebraMap F (SplittingField q)))))\n (hs : IsSolvable (Gal (map_poly s (@algebraMap F (SplittingField r)))))\n : IsSolvable (Gal s).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_quadruple_tower\n (hp : IsSolvable (Gal p))\n (hq : IsSolvable (Gal (map_poly q (@algebraMap F (SplittingField p)))))\n (hr : IsSolvable (Gal (map_poly r (@algebraMap F (SplittingField q)))))\n (hs : IsSolvable (Gal (map_poly s (@algebraMap F (SplittingField r)))))\n (ht : IsSolvable (Gal (map_poly t (@algebraMap F (SplittingField s)))))\n : IsSolvable (Gal t).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_map_poly\n (hp : IsSolvable (Gal p))\n : IsSolvable (Gal (map_poly p (@algebraMap F K))).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_of_split\n (hsplit : Splits p (@algebraMap F (SplittingField p)))\n : IsSolvable (Gal p).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_split_tower\n (hsplit : Splits q (@algebraMap F (SplittingField p)))\n : IsSolvable (Gal q).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_two_step_map\n (hp : IsSolvable (Gal p))\n : IsSolvable\n (Gal (map_poly (map_poly p (@algebraMap F K)) (@algebraMap K L))).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_three_step_map\n {M : Type}\n (hp : IsSolvable (Gal p))\n : IsSolvable\n (Gal\n (map_poly\n (map_poly\n (map_poly p (@algebraMap F K))\n (@algebraMap K L))\n (@algebraMap L M))).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_map_poly_comp\n (hp : IsSolvable (Gal p))\n : IsSolvable\n (Gal\n (map_poly\n (map_poly p (@algebraMap F K))\n (@algebraMap K L))).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_mutual_split\n (hsplit_p : Splits p (@algebraMap F (SplittingField q)))\n (hsplit_q : Splits q (@algebraMap F (SplittingField p)))\n : IsSolvable (Gal p) /\\ IsSolvable (Gal q).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_tower_split\n (hsplit_q : Splits q (@algebraMap F (SplittingField p)))\n (hr : IsSolvable (Gal (map_poly r (@algebraMap F (SplittingField q)))))\n : IsSolvable (Gal r).\nProof.\nAdmitted.\n\n Theorem gal_isSolvable_map_after_split\n (hsplit : Splits p (@algebraMap F (SplittingField p)))\n : IsSolvable (Gal (map_poly p (@algebraMap F K))).\nProof.\nAdmitted.\n\nEnd Tower.\n" }, { "theorem_id": 4, "title": "graph_paths", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "needs \"Library/rstc.ml\";;\n\nlet path = new_definition\n `path (E:A->A->bool) u v <=> RTC E u v`;;\n\nlet undirected = new_definition\n `undirected (E:A->A->bool) <=> !x y. E x y ==> E y x`;;\n\nlet erev = new_definition\n `erev (E:A->A->bool) x y <=> E y x`;;\n\nlet path_refl = `!E:A->A->bool v. path E v v`;;\n\nlet path_trans = `!E:A->A->bool u v w. path E u v ==> path E v w ==> path E u w`;;\n\nlet trans = path_trans;;\n\nlet edge_path = `!E:A->A->bool u v. E u v ==> path E u v`;;\n\nlet concat_edge_right = `!E:A->A->bool u v w. path E u v ==> E v w ==> path E u w`;;\n\nlet concat = path_trans;;\n\nlet concat_edge_left = `!E:A->A->bool u v w. E u v ==> path E v w ==> path E u w`;;\n\nlet concat3 = `!E:A->A->bool u v w t.\n path E u v ==> path E v w ==> path E w t ==> path E u t`;;\n\nlet reverse_in_Erev = `!E:A->A->bool u v. path E u v ==> path (erev E) v u`;;\n\nlet reverse_path = `!E:A->A->bool u v. undirected E ==> path E u v ==> path E v u`;;\n\nlet cycle_refl = `!E:A->A->bool v w. path E v w ==> path E w v ==> path E v v`;;" }, { "theorem_id": 4, "title": "graph_paths", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory graph_paths\n imports Main\nbegin\n\nsection \"GraphPaths\"\n\ninductive Path :: \"('a \\ 'a \\ bool) \\ 'a \\ 'a \\ bool\"\n for E :: \"'a \\ 'a \\ bool\"\nwhere\n Pnil: \"Path E v v\"\n| Pstep: \"Path E u v \\ E v w \\ Path E u w\"\n\ndefinition undirected :: \"('a \\ 'a \\ bool) \\ bool\"\n where \"undirected E \\ \\x y. E x y \\ E y x\"\n\ndefinition Erev :: \"('a \\ 'a \\ bool) \\ 'a \\ 'a \\ bool\"\n where \"Erev E x y \\ E y x\"\n\nlemma path_refl: \"Path E v v\"\n by sorry\n\nlemma path_trans:\n assumes \"Path E u v\" \"Path E v w\" shows \"Path E u w\"\n by sorry\n\nlemma trans: \"Path E u v \\ Path E v w \\ Path E u w\"\n by sorry\n\nlemma edge_path: \"E u v \\ Path E u v\"\n by sorry\n\nlemma concat_edge_right: \"Path E u v \\ E v w \\ Path E u w\"\n by sorry\n\nlemma concat: \"Path E u v \\ Path E v w \\ Path E u w\"\n by sorry\n\nlemma concat_edge_left: \"E u v \\ Path E v w \\ Path E u w\"\n by sorry\n\nlemma concat3:\n \"Path E u v \\ Path E v w \\ Path E w t \\ Path E u t\"\n by sorry\n\nlemma reverse_cons:\n assumes hE: \"undirected E\" and e: \"E m v\" and ih: \"Path E m u\"\n shows \"Path E v u\"\n by sorry\n\nlemma reverse_path:\n assumes hE: \"undirected E\" and p: \"Path E u v\"\n shows \"Path E v u\"\n by sorry\n\nlemma reverse_cons_Erev:\n assumes e: \"E m v\" and ih: \"Path (Erev E) m u\"\n shows \"Path (Erev E) v u\"\n by sorry\n\nlemma reverse_in_Erev:\n assumes p: \"Path E u v\"\n shows \"Path (Erev E) v u\"\n by sorry\n\nlemma cycle_refl:\n \"Path E v w \\ Path E w v \\ Path E v v\"\n by sorry\n\nend" }, { "theorem_id": 4, "title": "graph_paths", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "universe u\n\nnamespace GraphPath\n\nvariable {V : Type u}\n\ndef Edge (V : Type u) := V → V → Prop\n\ninductive Path (E : Edge V) : V → V → Prop\n| nil : ∀ v, Path E v v\n| step : ∀ {u v w}, Path E u v → E v w → Path E u w\n\n\nvariable {E : Edge V}\n\ntheorem refl (v : V) : Path (E:=E) v v := Path.nil v\n\ntheorem trans {u v w : V} : Path (E:=E) u v → Path (E:=E) v w → Path (E:=E) u w := by sorry\ndef Erev (E : Edge V) : Edge V := fun x y => E y x\n\ndef undirected (E : Edge V) : Prop := ∀ x y, E x y → E y x\n\ntheorem reverse_path {u v : V} (hE : undirected E) :\n Path (E:=E) u v → Path (E:=E) v u := by sorry\ntheorem concat_edge_right {u v w : V} :\n Path (E:=E) u v → E v w → Path (E:=E) u w := by sorry\ntheorem concat {u v w : V} :\n Path (E:=E) u v → Path (E:=E) v w → Path (E:=E) u w := by sorry\ntheorem edge_path {u v : V} : E u v → Path (E:=E) u v := by sorry\ntheorem concat_edge_left {u v w : V} :\n E u v → Path (E:=E) v w → Path (E:=E) u w := by sorry\ntheorem concat3 {u v w t : V} :\n Path (E:=E) u v → Path (E:=E) v w → Path (E:=E) w t → Path (E:=E) u t := by sorry\ntheorem reverse_in_Erev {u v : V} :\n Path (E:=E) u v → Path (E:=Erev E) v u := by sorry\ntheorem cycle_refl {v w : V} :\n Path (E:=E) v w → Path (E:=E) w v → Path (E:=E) v v := by sorry\nend GraphPath\n" }, { "theorem_id": 4, "title": "graph_paths", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "\n\n\n\nSection Graph.\n Variable V : Type.\n Definition Edge := V -> V -> Prop.\n\n Inductive Path (E : Edge) : V -> V -> Prop :=\n | Pnil : forall v, Path E v v\n | Pstep : forall u v w, Path E u v -> E v w -> Path E u w.\n\n Lemma path_refl (E : Edge) (v : V) : Path E v v.\nProof.\nAdmitted.\n\n Fixpoint append_right (E : Edge) (v w : V) (p2 : Path E v w)\n {struct p2} : forall u : V, Path E u v -> Path E u w :=\n match p2 with\n | @Pnil _ v0 => fun _ p1 => p1\n | @Pstep _ v0 y z pv Eyz => fun u p1 => Pstep E u y z (append_right E v0 y pv u p1) Eyz\n end.\n\n Lemma trans (E : Edge) (u v w : V) :\n Path E u v -> Path E v w -> Path E u w.\nProof.\nAdmitted.\n\n Definition undirected (E : Edge) : Prop := forall x y, E x y -> E y x.\n\n\n\n\n Lemma concat_edge_right (E : Edge) (u v w : V) :\n Path E u v -> E v w -> Path E u w.\nProof.\nAdmitted.\n\n Lemma concat (E : Edge) (u v w : V) :\n Path E u v -> Path E v w -> Path E u w.\nProof.\nAdmitted.\n\n\n Lemma edge_path (E : Edge) (u v : V) : E u v -> Path E u v.\nProof.\nAdmitted.\n\n Lemma concat_edge_left (E : Edge) (u v w : V) :\n E u v -> Path E v w -> Path E u w.\nProof.\nAdmitted.\n\n Lemma concat3 (E : Edge) (u v w t : V) :\n Path E u v -> Path E v w -> Path E w t -> Path E u t.\nProof.\nAdmitted.\n\n Definition Erev (E : Edge) : Edge := fun x y => E y x.\n\n Lemma reverse_in_Erev (E : Edge) (u v : V) :\n Path E u v -> Path (Erev E) v u.\nProof.\nAdmitted.\n\n Lemma cycle_refl (E : Edge) (v w : V) :\n Path E v w -> Path E w v -> Path E v v.\nProof.\nAdmitted.\n\nEnd Graph.\n" }, { "theorem_id": 5, "title": "group", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "needs \"Library/grouptheory.ml\";;\n\nlet is_group = new_definition\n `is_group (mul:A->A->A) (e:A) (ginv:A->A) <=>\n (!a b c. mul a (mul b c) = mul (mul a b) c) /\\\n (!a. mul a e = a) /\\\n (!a. mul e a = a) /\\\n (!a. mul (ginv a) a = e) /\\\n (!a. mul a (ginv a) = e)`;;\n\nlet INTRO_GROUP_HYPS =\n REWRITE_TAC[is_group] THEN REPEAT GEN_TAC THEN\n DISCH_THEN (CONJUNCTS_THEN2 ASSUME_TAC\n (CONJUNCTS_THEN2 ASSUME_TAC\n (CONJUNCTS_THEN2 ASSUME_TAC\n (CONJUNCTS_THEN2 ASSUME_TAC ASSUME_TAC))));;\n\nlet FUN_CONG = `!f:A->B x y. x = y ==> f x = f y`;;\n\nlet babel_group = new_definition\n `babel_group (mul:A->A->A) (e:A) (ginv:A->A) = group(UNIV,e,ginv,mul)`;;\n\nlet BABEL_GROUP = `!mul:A->A->A (e:A) (ginv:A->A).\n is_group mul e ginv\n ==> group_carrier (babel_group mul e ginv) = UNIV /\\\n group_id (babel_group mul e ginv) = e /\\\n group_inv (babel_group mul e ginv) = ginv /\\\n group_mul (babel_group mul e ginv) = mul`;;\n\nlet MUL_LEFT_CANCEL = `!mul:A->A->A (e:A) (ginv:A->A). is_group mul e ginv ==>\n !a b c:A. mul a b = mul a c ==> b = c`;;\n\nlet MUL_RIGHT_CANCEL = `!mul:A->A->A (e:A) (ginv:A->A). is_group mul e ginv ==>\n !a b c:A. mul b a = mul c a ==> b = c`;;\n\nlet INV_INV = `!mul:A->A->A (e:A) (ginv:A->A). is_group mul e ginv ==> !a:A. ginv (ginv a) = a`;;\n\nlet INV_MUL = `!mul:A->A->A (e:A) (ginv:A->A). is_group mul e ginv ==>\n !a b:A. ginv (mul a b) = mul (ginv b) (ginv a)`;;\n\nlet INV_EQ_OF_MUL_EQ_ONE = `!mul:A->A->A (e:A) (ginv:A->A). is_group mul e ginv ==>\n !a b:A. mul a b = e ==> b = ginv a`;;\n\nlet is_group_comm = new_definition\n `is_group_comm (mul:A->A->A) (e:A) (ginv:A->A) <=>\n is_group mul e ginv /\\ (!a b. mul a b = mul b a)`;;\n\nlet MUL_ROTATE' = `!mul (e:A) ginv. is_group_comm mul e ginv ==>\n !a b c. mul a (mul b c) = mul b (mul c a)`;;\n\nlet is_group_action = new_definition\n `is_group_action (mul:A->A->A) (e:A) (ginv:A->A) (act:A->B->B) <=>\n is_group mul e ginv /\\\n (!x. act e x = x) /\\\n (!(g:A) (h:A) (x:B). act (mul g h) x = act g (act h x))`;;\n\nlet INTRO_ACTION_HYPS =\n REWRITE_TAC[is_group_action] THEN REPEAT GEN_TAC THEN\n DISCH_THEN (CONJUNCTS_THEN2 ASSUME_TAC\n (CONJUNCTS_THEN2 ASSUME_TAC ASSUME_TAC));;\n\nlet GROUP_ACTION_REFL_TAC () =\n ASM_REWRITE_TAC[is_group_action] THEN REFL_TAC;;\n\nlet BABEL_GROUP_ACTION = `!mul:A->A->A (e:A) (ginv:A->A) (act:A->B->B).\n is_group_action mul e ginv act\n ==> group_action (babel_group mul e ginv) UNIV act`;;\n\nlet ACT_INV = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !g x. act (ginv g) (act g x) = x`;;\n\nlet ACT_INV_SPEC = `!mul (e:A) ginv (act:A->B->B) g x. is_group_action mul e ginv act ==>\n act (ginv g) (act g x) = x`;;\n\nlet ACT_INV_R = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !g x. act g (act (ginv g) x) = x`;;\n\nlet ACT_INV_R_SPEC = `!mul (e:A) ginv (act:A->B->B) g x. is_group_action mul e ginv act ==>\n act g (act (ginv g) x) = x`;;\n\nlet ACT_INV_R_SYM = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !g x. x = act g (act (ginv g) x)`;;\n\nlet is_orbit = new_definition\n `is_orbit (act:A->B->B) x y <=> ?g. act g x = y`;;\n\nlet is_stabilizer = new_definition\n `is_stabilizer (act:A->B->B) x g <=> act g x = x`;;\n\nlet BABEL_ORBIT = `!mul:A->A->A (e:A) (ginv:A->A) (act:A->B->B) x y.\n is_group mul e ginv\n ==> (group_orbit (babel_group mul e ginv) UNIV act x y <=>\n is_orbit act x y)`;;\n\nlet ORBIT_REFL = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x. is_orbit act x x`;;\n\nlet ORBIT_SYM = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x y. is_orbit act x y ==> is_orbit act y x`;;\n\nlet ORBIT_TRANS = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x y z. is_orbit act x y ==> is_orbit act y z ==> is_orbit act x z`;;\n\nlet ORBIT_PARTITION = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x y z. is_orbit act x y ==>\n (is_orbit act x z <=> is_orbit act y z)`;;\n\nlet STABILIZER_MUL = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x g h. is_stabilizer act x g ==> is_stabilizer act x h ==>\n is_stabilizer act x (mul g h)`;;\n\nlet STABILIZER_INV = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x g. is_stabilizer act x g ==> is_stabilizer act x (ginv g)`;;\n\nlet STABILIZER_ONE = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x. is_stabilizer act x e`;;\n\nlet STABILIZER_CONJUGATE = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x g h. is_stabilizer act x h ==>\n is_stabilizer act (act g x) (mul (mul g h) (ginv g))`;;\n\nlet CONJUGATE_MUL_CANCEL_LEFT = `!mul:A->A->A (e:A) (ginv:A->A) g h.\n is_group mul e ginv\n ==> mul g (mul (mul (ginv g) h) g) = mul h g`;;\n\nlet CONJUGATE_MUL_CANCEL = `!mul:A->A->A (e:A) (ginv:A->A) g h.\n is_group mul e ginv\n ==> mul (mul g (mul (mul (ginv g) h) g)) (ginv g) = h`;;\n\nlet STABILIZER_CONJUGATE_ORBIT_FWD = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x y g h. act g x = y ==>\n is_stabilizer act y h ==>\n is_stabilizer act x (mul (mul (ginv g) h) g)`;;\n\nlet STABILIZER_CONJUGATE_ORBIT_REV = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x y g h. act g x = y ==>\n is_stabilizer act x (mul (mul (ginv g) h) g) ==>\n is_stabilizer act y h`;;\nlet STABILIZER_CONJUGATE_ORBIT = `!mul (e:A) ginv (act:A->B->B). is_group_action mul e ginv act ==>\n !x y g h. act g x = y ==>\n (is_stabilizer act y h <=>\n is_stabilizer act x (mul (mul (ginv g) h) g))`;;" }, { "theorem_id": 5, "title": "group", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory group\n imports Main\nbegin\n\nlocale group =\n fixes mul :: \"'a => 'a => 'a\" (infixl \"**\" 70)\n and one :: \"'a\"\n and inv :: \"'a => 'a\"\n assumes mul_assoc : \"a ** (b ** c) = (a ** b) ** c\"\n and mul_one : \"a ** one = a\"\n and one_mul : \"one ** a = a\"\n and mul_inv_l : \"inv a ** a = one\"\n and mul_inv_r : \"a ** inv a = one\"\nbegin\n\nlemma mul_left_cancel:\n assumes h: \"a ** b = a ** c\"\n shows \"b = c\"\n by sorry\n\nlemma mul_right_cancel:\n assumes h: \"b ** a = c ** a\"\n shows \"b = c\"\n by sorry\n\nlemma inv_inv: \"inv (inv a) = a\"\n by sorry\n\nlemma inv_mul: \"inv (a ** b) = inv b ** inv a\"\n by sorry\n\nlemma inv_eq_of_mul_eq_one:\n assumes h: \"a ** b = one\"\n shows \"b = inv a\"\n by sorry\n\nend \n\nlocale group_comm = group +\n assumes mul_comm : \"a ** b = b ** a\"\nbegin\n\nlemma mul_rotate': \"a ** (b ** c) = b ** (c ** a)\"\n by sorry\n\nend \n\nlocale group_action =\n group mul one inv\n for mul :: \"'a => 'a => 'a\" (infixl \"**\" 70)\n and one :: \"'a\"\n and inv :: \"'a => 'a\" +\n fixes act :: \"'a => 'b => 'b\" (infixr \"acts\" 73)\n assumes act_one : \"one acts x = x\"\n and act_mul : \"(g ** h) acts x = g acts (h acts x)\"\nbegin\n\nlemma act_inv: \"inv g acts (g acts x) = x\"\n by sorry\n\nlemma act_inv_r: \"g acts (inv g acts x) = x\"\n by sorry\n\ndefinition orbit :: \"'b => 'b => bool\"\n where \"orbit x y == (EX g. g acts x = y)\"\n\ndefinition stabilizer :: \"'b => 'a => bool\"\n where \"stabilizer x g == g acts x = x\"\n\nlemma orbit_refl: \"orbit x x\"\n by sorry\n\nlemma orbit_sym:\n assumes \"orbit x y\"\n shows \"orbit y x\"\n by sorry\n\nlemma orbit_trans:\n assumes \"orbit x y\" \"orbit y z\"\n shows \"orbit x z\"\n by sorry\n\nlemma orbit_partition:\n assumes hxy: \"orbit x y\"\n shows \"orbit x z = orbit y z\"\n by sorry\n\nlemma stabilizer_mul:\n assumes \"stabilizer x g\" \"stabilizer x h\"\n shows \"stabilizer x (g ** h)\"\n by sorry\n\nlemma stabilizer_inv:\n assumes hg: \"stabilizer x g\"\n shows \"stabilizer x (inv g)\"\n by sorry\n\nlemma stabilizer_one: \"stabilizer x one\"\n by sorry\n\nlemma stabilizer_conjugate:\n assumes hh: \"stabilizer x h\"\n shows \"stabilizer (g acts x) (g ** h ** inv g)\"\n by sorry\n\nlemma stabilizer_conjugate_orbit:\n assumes hxy: \"g acts x = y\"\n shows \"stabilizer y h = stabilizer x (inv g ** h ** g)\"\n by sorry\n\nend \n\nend" }, { "theorem_id": 5, "title": "group", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "class Group (G : Type) where\n inv : G → G\n one : G\n mul : G → G → G\n mul_assoc : ∀ a b c : G, mul a (mul b c) = mul (mul a b) c\n mul_one : ∀ a : G, mul a one = a\n one_mul : ∀ a : G, mul one a = a\n mul_inv_l : ∀ a : G, mul (inv a) a = one\n mul_inv_r : ∀ a : G, mul a (inv a) = one\n\nnamespace Group\n\ninfixl:70 \" * \" => Group.mul\npostfix:max \"⁻¹\" => Group.inv\n\nclass GroupComm (G : Type) [Group G] where\n mul_comm : ∀ a b : G, a * b = b * a\n\nsection MulRotate\n variable {G : Type} [Group G] [GroupComm G]\n\n theorem mul_rotate' (a b c : G) : a * (b * c) = b * (c * a) := by sorry\nend MulRotate\nsection GroupLemmas\n variable {G : Type} [Group G]\n\n theorem mul_left_cancel (a b c : G) (h : a * b = a * c) : b = c := by sorry\n theorem mul_right_cancel (a b c : G) (h : b * a = c * a) : b = c := by sorry\n theorem inv_inv (a : G) : (a⁻¹)⁻¹ = a := by sorry\n theorem inv_mul (a b : G) : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n theorem inv_eq_of_mul_eq_one (a b : G) (h : a * b = one) : b = a⁻¹ := by sorry\nend GroupLemmas\n\nclass Act (G : Type) (X : Type) [Group G] where\n act : G → X → X\n act_one : ∀ x : X, act one x = x\n act_mul : ∀ g h : G, ∀ x : X, act (g * h) x = act g (act h x)\n\n\nsection ActionLemmas\n variable {G : Type} {X : Type}\n [Group G] [Act G X]\n\n infixr:73 \" • \" => Act.act\n\n theorem act_inv (g : G) (x : X) : g⁻¹ • (g • x) = x := by sorry\n theorem act_inv_r (g : G) (x : X) : g • (g⁻¹ • x) = x := by sorry\n def orbit {G : Type} {X : Type} [Group G] [Act G X] (x : X) : X → Prop :=\n fun y => ∃ g : G, g • x = y\n\n def stabilizer (x : X) : G → Prop := fun g => g • x = x\n\n theorem orbit_refl\n (x : X) : orbit (G:=G) x x := by sorry\n theorem orbit_sym (x y : X) (h : orbit (G:=G) x y) : orbit (G:=G) y x := by sorry\n theorem orbit_trans (x y z : X) (h1 : orbit (G:=G) x y) (h2 : orbit (G:=G) y z) : orbit (G:=G) x z := by sorry\n theorem orbit_partition (x y : X) (hxy : orbit (G:=G) x y) (z : X) :\n orbit (G:=G) x z ↔ orbit (G:=G) y z := by sorry\n theorem stabilizer_mul (x : X) (g h : G)\n (hg : stabilizer x g) (hh : stabilizer x h) : stabilizer x (g * h) := by sorry\n theorem stabilizer_inv (x : X) (g : G) (hg : stabilizer x g) : stabilizer x g⁻¹ := by sorry\n theorem stabilizer_one (x : X) : stabilizer (G:=G) x one := by sorry\n theorem stabilizer_conjugate (x : X) (g h : G)\n (hh : stabilizer x h) : stabilizer (g • x) (g * h * g⁻¹) := by sorry\n theorem stabilizer_conjugate_orbit (x y : X) (g : G) (hxy : g • x = y) (h : G) :\n stabilizer y h ↔ stabilizer x (g⁻¹ * h * g) := by sorry\nend ActionLemmas\n\nend Group\n" }, { "theorem_id": 5, "title": "group", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Class Group (G : Type) := {\n inv : G -> G;\n one : G;\n mul : G -> G -> G;\n mul_assoc : forall a b c, mul a (mul b c) = mul (mul a b) c;\n mul_one : forall a, mul a one = a;\n one_mul : forall a, mul one a = a;\n mul_inv_l : forall a, mul (inv a) a = one;\n mul_inv_r : forall a, mul a (inv a) = one\n}.\n\nInfix \"*\" := mul (at level 40, left associativity).\nNotation \"1\" := one.\nNotation \"x ^-1\" := (inv x) (at level 35, right associativity).\n\n\nClass GroupComm (G : Type) `{Group G} := {\n mul_comm : forall a b, a * b = b * a\n}.\n\nSection MulRotate.\n Variable G : Type.\n Context `{GroupComm G}.\n\n Lemma mul_rotate' (a b c : G) : a * (b * c) = b * (c * a).\nProof.\nAdmitted.\nEnd MulRotate.\n\nSection GroupLemmas.\n Context {G : Type} `{Group G}.\n\n Lemma mul_left_cancel (a b c : G) :\n a * b = a * c -> b = c.\nProof.\nAdmitted.\n\n Lemma mul_right_cancel (a b c : G) :\n b * a = c * a -> b = c.\nProof.\nAdmitted.\n\n Lemma inv_inv (a : G) : (a^-1)^-1 = a.\nProof.\nAdmitted.\n\n Lemma inv_mul (a b : G) :\n (a * b)^-1 = b^-1 * a^-1.\nProof.\nAdmitted.\n\n Lemma inv_eq_of_mul_eq_one (a b : G) :\n a * b = 1 -> b = a^-1.\nProof.\nAdmitted.\n\nEnd GroupLemmas.\n\nClass Act (G X : Type) `{Group G}:= \n{\n act : G -> X -> X;\n act_one : forall x, act 1 x = x;\n act_mul : forall g h x, act (g * h) x = act g (act h x)\n\n}.\nInfix \"•\" := act (at level 50, left associativity).\n\n\nSection ActionLemmas.\n Context {G X : Type} `{Act G X}.\n\n Lemma act_inv (g : G) (x : X) :\n g^-1 • (g • x) = x.\nProof.\nAdmitted.\n\n Lemma act_inv_r (g : G) (x : X) :\n g • (g^-1 • x) = x.\nProof.\nAdmitted.\n\n Definition orbit (x : X) : X -> Prop :=\n fun y => exists g : G, g • x = y.\n\n Definition stabilizer (x : X) : G -> Prop :=\n fun g => g • x = x.\n\n Lemma orbit_refl (x : X) : orbit x x.\nProof.\nAdmitted.\n\n Lemma orbit_sym (x y : X) :\n orbit x y -> orbit y x.\nProof.\nAdmitted.\n\n Lemma orbit_trans (x y z : X) :\n orbit x y -> orbit y z -> orbit x z.\nProof.\nAdmitted.\n\n Lemma orbit_partition (x y : X) :\n orbit x y -> forall z, orbit x z <-> orbit y z.\nProof.\nAdmitted.\n\n Lemma stabilizer_mul (x : X) (g h : G) :\n stabilizer x g -> stabilizer x h -> stabilizer x (g * h).\nProof.\nAdmitted.\n\n Lemma stabilizer_inv (x : X) (g : G) :\n stabilizer x g -> stabilizer x (g^-1).\nProof.\nAdmitted.\n\n Lemma stabilizer_one (x : X) :\n stabilizer x 1.\nProof.\nAdmitted.\n\n Lemma stabilizer_conjugate (x : X) (g h : G) :\n stabilizer x h -> stabilizer (g • x) (g * h * g^-1).\nProof.\nAdmitted.\n\n Lemma stabilizer_conjugate_orbit (x y : X) (g : G) :\n g • x = y ->\n forall h, stabilizer y h <-> stabilizer x (g^-1 * h * g).\nProof.\nAdmitted.\n\nEnd ActionLemmas.\n" }, { "theorem_id": 6, "title": "ideals", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let cring = new_definition\n `cring (zero:'r) (oneR:'r) (add:'r->'r->'r) (mul:'r->'r->'r) (opp:'r->'r) <=>\n (!x y. add x y = add y x) /\\\n (!x y z. add (add x y) z = add x (add y z)) /\\\n (!x. add x zero = x) /\\\n (!x. add x (opp x) = zero) /\\\n (!x y. mul x y = mul y x) /\\\n (!x y z. mul (mul x y) z = mul x (mul y z)) /\\\n (!x. mul x oneR = x) /\\\n (!a x y. mul a (add x y) = add (mul a x) (mul a y)) /\\\n (!x y. opp (add x y) = add (opp x) (opp y))`;;\n\nlet IsIdeal = new_definition\n `IsIdeal (zero:'r) (add:'r->'r->'r) (mul:'r->'r->'r) (opp:'r->'r)\n (ideal:'r->bool) <=>\n ideal zero /\\\n (!x y. ideal x /\\ ideal y ==> ideal (add x y)) /\\\n (!x. ideal x ==> ideal (opp x)) /\\\n (!a x. ideal x ==> ideal (mul a x))`;;\n\nlet inter = new_definition\n `inter (fam:'i->'r->bool) = (\\x:'r. !i. fam i x)`;;\n\nlet add_rearrange = `!zeroR:'r oneR:'r (add:'r->'r->'r) (mul:'r->'r->'r) (opp:'r->'r).\n cring zeroR oneR add mul opp ==>\n !a:'r b c d. add (add a b) (add c d) = add (add a c) (add b d)`;;\n\nlet ideal_sum = new_definition\n `ideal_sum (add:'r->'r->'r) (ideal1:'r->bool) (ideal2:'r->bool) =\n (\\x:'r. ?a b. ideal1 a /\\ ideal2 b /\\ x = add a b)`;;\n\nlet inter_isIdeal = `!zeroR oneR add mul opp (fam:'i->'r->bool).\n cring zeroR oneR add mul opp ==>\n (!i. IsIdeal zeroR add mul opp (fam i)) ==>\n IsIdeal zeroR add mul opp (inter fam)`;;\n\nlet sum_isIdeal = `!zeroR oneR add mul opp (ideal1:'r->bool) (ideal2:'r->bool).\n cring zeroR oneR add mul opp ==>\n IsIdeal zeroR add mul opp ideal1 ==>\n IsIdeal zeroR add mul opp ideal2 ==>\n IsIdeal zeroR add mul opp (ideal_sum add ideal1 ideal2)`;;" }, { "theorem_id": 6, "title": "ideals", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory ideals\n imports Main\nbegin\n\nsection \"Ideals\"\n\nlocale cring =\n fixes zero :: \"'r\"\n and one :: \"'r\"\n and add :: \"'r \\ 'r \\ 'r\" (infixl \"+R\" 65)\n and mul :: \"'r \\ 'r \\ 'r\" (infixl \"*R\" 70)\n and opp :: \"'r \\ 'r\"\n assumes add_comm : \"\\x y. x +R y = y +R x\"\n and add_assoc : \"\\x y z. (x +R y) +R z = x +R (y +R z)\"\n and add_zero : \"\\x. x +R zero = x\"\n and add_opp : \"\\x. x +R opp x = zero\"\n and mul_comm : \"\\x y. x *R y = y *R x\"\n and mul_assoc : \"\\x y z. (x *R y) *R z = x *R (y *R z)\"\n and mul_one : \"\\x. x *R one = x\"\n and dist_l : \"\\a x y. a *R (x +R y) = (a *R x) +R (a *R y)\"\n and opp_add : \"\\x y. opp (x +R y) = opp x +R opp y\"\nbegin\n\nlemma add_left_comm: \"x +R (y +R z) = y +R (x +R z)\"\n by sorry\n\nlemma zero_add: \"zero +R x = x\"\n by sorry\n\ndefinition IsIdeal :: \"('r \\ bool) \\ bool\"\n where \"IsIdeal I \\\n I zero \\\n (\\x y. I x \\ I y \\ I (x +R y)) \\\n (\\x. I x \\ I (opp x)) \\\n (\\a x. I x \\ I (a *R x))\"\n\ndefinition Inter :: \"('i \\ 'r \\ bool) \\ 'r \\ bool\"\n where \"Inter F \\ \\x. \\i. F i x\"\n\nlemma inter_isIdeal:\n assumes h: \"\\i. IsIdeal (F i)\"\n shows \"IsIdeal (Inter F)\"\n by sorry\n\ndefinition isum :: \"('r \\ bool) \\ ('r \\ bool) \\ 'r \\ bool\"\n where \"isum I J \\ \\x. \\a b. I a \\ J b \\ x = a +R b\"\n\nlemma sum_isIdeal:\n assumes hI: \"IsIdeal I\" and hJ: \"IsIdeal J\"\n shows \"IsIdeal (isum I J)\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 6, "title": "ideals", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "class CRing (R : Type) where\n zero : R\n one : R\n add : R → R → R\n mul : R → R → R\n opp : R → R\n\n add_comm : ∀ x y, add x y = add y x\n add_assoc : ∀ x y z, add (add x y) z = add x (add y z)\n add_zero : ∀ x, add x zero = x\n add_opp : ∀ x, add x (opp x) = zero\n\n mul_comm : ∀ x y, mul x y = mul y x\n mul_assoc : ∀ x y z, mul (mul x y) z = mul x (mul y z)\n mul_one : ∀ x, mul x one = x\n dist_l : ∀ a x y, mul a (add x y) = add (mul a x) (mul a y)\n opp_add : ∀ x y, opp (add x y) = add (opp x) (opp y)\n\nnamespace Ideals\n\nvariable {R : Type} [CR : CRing R]\nopen CRing\n\ninfixl:65 \"+R\" => CRing.add\ninfixl:70 \"*R\" => CRing.mul\nprefix:100 \"-R\" => CRing.opp\n\ndef IsIdeal (I : R → Prop) : Prop :=\n (I CR.zero) ∧\n (∀ x y, I x → I y → I (x +R y)) ∧\n (∀ x, I x → I (-R x)) ∧\n (∀ a x, I x → I (a *R x))\n\ndef Inter {ι : Type} (F : ι → (R → Prop)) : R → Prop :=\n fun x => ∀ i, F i x\n\ntheorem inter_isIdeal {ι : Type} (F : ι → (R → Prop))\n (h : ∀ i, IsIdeal (F i)) : IsIdeal (Inter F) := by sorry\ndef sum (I J : R → Prop) : R → Prop :=\n fun x => ∃ a b, I a ∧ J b ∧ x = a +R b\n\ntheorem sum_isIdeal (I J : R → Prop) (hI : IsIdeal I) (hJ : IsIdeal J) :\n IsIdeal (sum I J) := by sorry\nend Ideals\n" }, { "theorem_id": 6, "title": "ideals", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Require Import Coq.Init.Logic.\n\nClass CRing := {\n R : Type;\n zero : R;\n one : R;\n add : R -> R -> R;\n mul : R -> R -> R;\n opp : R -> R;\n\n add_comm : forall x y, add x y = add y x;\n add_assoc : forall x y z, add (add x y) z = add x (add y z);\n add_zero : forall x, add x zero = x;\n zero_add : forall x, add zero x = x;\n add_opp : forall x, add x (opp x) = zero;\n\n mul_comm : forall x y, mul x y = mul y x;\n mul_assoc : forall x y z, mul (mul x y) z = mul x (mul y z);\n mul_one : forall x, mul x one = x;\n dist_l : forall a x y, mul a (add x y) = add (mul a x) (mul a y);\n opp_add : forall x y, opp (add x y) = add (opp x) (opp y)\n}.\n\nSection Ideals.\n Context {K : CRing}.\n\n Infix \"+R\" := add (at level 65).\n Infix \"*R\" := mul (at level 70).\n Notation \"-R x\" := (opp x) (at level 100).\n\n Record IsIdeal (I : R -> Prop) : Prop := {\n ideal_zero : I zero;\n ideal_add : forall x y, I x -> I y -> I (x +R y);\n ideal_opp : forall x, I x -> I (-R x);\n ideal_mul : forall a x, I x -> I (a *R x)\n }.\n\n Definition Inter {I : Type} (F : I -> R -> Prop) : R -> Prop :=\n fun x => forall i, F i x.\n\n Lemma inter_isIdeal {I : Type} (F : I -> R -> Prop)\n (h : forall i, IsIdeal (F i)) : IsIdeal (Inter F).\nProof.\nAdmitted.\n\n Definition sum (I J : R -> Prop) : R -> Prop :=\n fun x => exists a b, I a /\\ J b /\\ (a +R b) = x.\n\n Lemma sum_isIdeal (I J : R -> Prop)\n (hI : IsIdeal I) (hJ : IsIdeal J) : IsIdeal (sum I J).\nProof.\nAdmitted.\n\nEnd Ideals." }, { "theorem_id": 7, "title": "inner_product", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let is_inner_context = new_definition\n `is_inner_context (zeroR:R) (oneR:R)\n (add:R->R->R) (mul:R->R->R) (opp:R->R)\n (addV:V->V->V) (oppV:V->V) (smul:R->V->V)\n (ip:V->V->R) <=>\n (!x y. add x y = add y x) /\\\n (!x y z. add (add x y) z = add x (add y z)) /\\\n (!x. add x zeroR = x) /\\\n (!x. add zeroR x = x) /\\\n (!x. opp (opp x) = x) /\\\n (!x. mul (opp oneR) x = opp x) /\\\n (!u. oppV u = smul (opp oneR) u) /\\\n (!u v w. ip (addV u v) w = add (ip u w) (ip v w)) /\\\n (!a u v. ip (smul a u) v = mul a (ip u v)) /\\\n (!u v w. ip u (addV v w) = add (ip u v) (ip u w)) /\\\n (!a u v. ip u (smul a v) = mul a (ip u v)) /\\\n (!u v. ip u v = ip v u)`;;\n\nlet subV = new_definition\n `subV (addV:V->V->V) (oppV:V->V) u v = addV u (oppV v)`;;\n\nlet INTRO_INNER_HYPS =\n REWRITE_TAC[is_inner_context] THEN REPEAT GEN_TAC THEN\n DISCH_THEN (fun th -> ASSUME_TAC th THEN MAP_EVERY ASSUME_TAC (CONJUNCTS th));;\n\nlet ip_neg_left = `!zeroR oneR add mul opp (addV:V->V->V) oppV smul ip u v.\n is_inner_context zeroR oneR add mul opp addV oppV smul ip\n ==> ip (oppV u) v = opp (ip u v)`;;\n\nlet ip_neg_right = `!zeroR oneR add mul opp (addV:V->V->V) oppV smul ip u v.\n is_inner_context zeroR oneR add mul opp addV oppV smul ip\n ==> ip u (oppV v) = opp (ip u v)`;;\n\nlet ip_add_add = `!zeroR oneR add mul opp (addV:V->V->V) oppV smul ip u v.\n is_inner_context zeroR oneR add mul opp addV oppV smul ip\n ==> ip (addV u v) (addV u v) =\n add (add (ip u u) (ip v u)) (add (ip u v) (ip v v))`;;\n\nlet opp_opp_ctx = `!zeroR oneR add mul opp (addV:V->V->V) oppV smul ip x.\n is_inner_context zeroR oneR add mul opp addV oppV smul ip\n ==> opp (opp x) = x`;;\n\nlet add_zero_right_ctx = `!zeroR oneR add mul opp (addV:V->V->V) oppV smul ip x.\n is_inner_context zeroR oneR add mul opp addV oppV smul ip\n ==> add x zeroR = x`;;\n\nlet add_zero_left_ctx = `!zeroR oneR add mul opp (addV:V->V->V) oppV smul ip x.\n is_inner_context zeroR oneR add mul opp addV oppV smul ip\n ==> add zeroR x = x`;;\n\nlet ip_symm_ctx = `!zeroR oneR add mul opp (addV:V->V->V) oppV smul ip u v.\n is_inner_context zeroR oneR add mul opp addV oppV smul ip\n ==> ip u v = ip v u`;;\n\nlet ip_sub_sub = `!zeroR oneR add mul opp (addV:V->V->V) oppV smul ip u v.\n is_inner_context zeroR oneR add mul opp addV oppV smul ip\n ==> ip (subV addV oppV u v) (subV addV oppV u v) =\n add (add (ip u u) (opp (ip v u))) (add (opp (ip u v)) (ip v v))`;;\n\nlet pythagoras = `!zeroR oneR add mul opp (addV:V->V->V) oppV smul ip u v.\n is_inner_context zeroR oneR add mul opp addV oppV smul ip\n ==> ip u v = zeroR\n ==> ip (addV u v) (addV u v) = add (ip u u) (ip v v)`;;\n\nlet parallelogram = `!zeroR oneR add mul opp (addV:V->V->V) oppV smul ip u v.\n is_inner_context zeroR oneR add mul opp addV oppV smul ip\n ==> add (ip (addV u v) (addV u v))\n (ip (subV addV oppV u v) (subV addV oppV u v)) =\n add (add (add (ip u u) (ip v u)) (add (ip u v) (ip v v)))\n (add (add (ip u u) (opp (ip v u))) (add (opp (ip u v)) (ip v v)))`;;" }, { "theorem_id": 7, "title": "inner_product", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory inner_product\n imports Main\nbegin\n\nsection \"InnerProduct\"\n\nlocale inner_product =\n fixes zero_R one_R :: \"'r\"\n and add_R :: \"'r \\ 'r \\ 'r\" (infixl \"+R\" 65)\n and mul_R :: \"'r \\ 'r \\ 'r\" (infixl \"*R\" 70)\n and opp_R :: \"'r \\ 'r\"\n and zeroV :: \"'v\"\n and addV :: \"'v \\ 'v \\ 'v\" (infixl \"+V\" 65)\n and oppV :: \"'v \\ 'v\"\n and smul :: \"'r \\ 'v \\ 'v\"\n and ip :: \"'v \\ 'v \\ 'r\"\n \n assumes add_R_comm : \"\\x y. x +R y = y +R x\"\n and add_R_assoc : \"\\x y z. (x +R y) +R z = x +R (y +R z)\"\n and add_R_zero : \"\\x. x +R zero_R = x\"\n and zero_R_add : \"\\x. zero_R +R x = x\"\n and add_R_opp : \"\\x. x +R opp_R x = zero_R\"\n and mul_R_comm : \"\\x y. x *R y = y *R x\"\n and mul_R_assoc : \"\\x y z. (x *R y) *R z = x *R (y *R z)\"\n and mul_R_one : \"\\x. x *R one_R = x\"\n and mul_opp_one : \"\\x. opp_R one_R *R x = opp_R x\"\n and opp_R_opp : \"\\x. opp_R (opp_R x) = x\"\n \n and addV_comm : \"\\u v. u +V v = v +V u\"\n and addV_assoc : \"\\u v w. (u +V v) +V w = u +V (v +V w)\"\n and addV_zero : \"\\u. u +V zeroV = u\"\n and smul_addV : \"\\a u v. smul a (u +V v) = smul a u +V smul a v\"\n and one_smul : \"\\u. smul one_R u = u\"\n and opp_smul_one : \"\\u. oppV u = smul (opp_R one_R) u\"\n \n and lin_left_add : \"\\u v w. ip (u +V v) w = ip u w +R ip v w\"\n and lin_left_smul : \"\\a u v. ip (smul a u) v = a *R ip u v\"\n and lin_right_add : \"\\u v w. ip u (v +V w) = ip u v +R ip u w\"\n and lin_right_smul: \"\\a u v. ip u (smul a v) = a *R ip u v\"\n and ip_symm : \"\\u v. ip u v = ip v u\"\nbegin\n\ndefinition subV :: \"'v \\ 'v \\ 'v\" (infixl \"-V\" 65)\n where \"u -V v \\ u +V oppV v\"\n\nlemma add_R_left_comm: \"x +R (y +R z) = y +R (x +R z)\"\n by sorry\n\nlemma ip_neg_left: \"ip (oppV u) v = opp_R (ip u v)\"\n by sorry\n\nlemma ip_neg_right: \"ip u (oppV v) = opp_R (ip u v)\"\n by sorry\n\nlemma ip_add_add:\n \"ip (u +V v) (u +V v) =\n (ip u u +R ip v u) +R (ip u v +R ip v v)\"\n by sorry\n\nlemma ip_neg_neg: \"ip (oppV v) (oppV v) = ip v v\"\n by sorry\n\nlemma ip_sub_sub:\n \"ip (u -V v) (u -V v) =\n (ip u u +R opp_R (ip v u)) +R (opp_R (ip u v) +R ip v v)\"\n by sorry\n\nlemma pythagoras:\n assumes h: \"ip u v = zero_R\"\n shows \"ip (u +V v) (u +V v) = ip u u +R ip v v\"\n by sorry\n\nlemma parallelogram:\n \"ip (u +V v) (u +V v) +R ip (u -V v) (u -V v) =\n ((ip u u +R ip v u) +R (ip u v +R ip v v)) +R\n ((ip u u +R opp_R (ip v u)) +R (opp_R (ip u v) +R ip v v))\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 7, "title": "inner_product", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "namespace Linear\n\nclass Field (R : Type) where\n zero : R\n one : R\n add : R → R → R\n mul : R → R → R\n opp : R → R\n\n add_comm : ∀ x y, add x y = add y x\n add_assoc : ∀ x y z, add (add x y) z = add x (add y z)\n add_zero : ∀ x, add x zero = x\n zero_add : ∀ x, add zero x = x\n add_opp : ∀ x, add x (opp x) = zero\n\n mul_comm : ∀ x y, mul x y = mul y x\n mul_assoc : ∀ x y z, mul (mul x y) z = mul x (mul y z)\n mul_one : ∀ x, mul x one = x\n dist_l : ∀ x y z, mul x (add y z) = add (mul x y) (mul x z)\n\n opp_add : ∀ x y, opp (add x y) = add (opp x) (opp y)\n mul_opp_one : ∀ x, mul (opp one) x = opp x\n opp_opp : ∀ x, opp (opp x) = x\n\ninfixl:65 \"+R\" => Field.add\ninfixl:70 \"*R\" => Field.mul\nprefix:100 \"-R\" => Field.opp\n\nclass VSpace (R : Type) [Field R] (V : Type) where\n zeroV : V\n addV : V → V → V\n oppV : V → V\n smul : R → V → V\n\n addV_comm : ∀ u v, addV u v = addV v u\n addV_assoc : ∀ u v w, addV (addV u v) w = addV u (addV v w)\n addV_zero : ∀ u, addV u zeroV = u\n addV_opp : ∀ u, addV u (oppV u) = zeroV\n\n smul_addV : ∀ a u v, smul a (addV u v) = addV (smul a u) (smul a v)\n addR_smul : ∀ a b u, smul (a +R b) u = addV (smul a u) (smul b u)\n mul_smul : ∀ a b u, smul (a *R b) u = smul a (smul b u)\n one_smul : ∀ u, smul Field.one u = u\n smul_zero : ∀ a, smul a zeroV = zeroV\n opp_smul_one : ∀ u, oppV u = smul (Field.opp Field.one) u\n\ninfixl:65 \"+V\" => VSpace.addV\nprefix:100 \"-V\" => VSpace.oppV\nnotation:70 a \" •V \" u => VSpace.smul a u\n\ndef subV {R : Type} {V : Type} [Field R] [VSpace R V] (u v : V) : V :=\n VSpace.addV (R := R) (V := V) u (VSpace.oppV (R := R) (V := V) v)\ninfixl:65 \" -V \" => subV\n\nclass Inner (R : Type) (V : Type) [Field R] [VSpace R V] where\n ip : V → V → R\n\n lin_left_add : ∀ u v w,\n ip (VSpace.addV (R := R) (V := V) u v) w = (ip u w) +R (ip v w)\n lin_left_smul : ∀ a u v,\n ip (VSpace.smul (R := R) (V := V) a u) v = a *R (ip u v)\n\n lin_right_add : ∀ u v w,\n ip u (VSpace.addV (R := R) (V := V) v w) = (ip u v) +R (ip u w)\n lin_right_smul : ∀ a u v,\n ip u (VSpace.smul (R := R) (V := V) a v) = a *R (ip u v)\n\n symm : ∀ u v, ip u v = ip v u\n\n\nvariable {R : Type} {V : Type}\nvariable [Field R] [VSpace R V] [Inner R V]\n\ntheorem ip_neg_left (u v : V) :\n Inner.ip (R := R) (V := V)\n (VSpace.oppV (R := R) (V := V) u) v\n = Field.opp (Inner.ip (R := R) (V := V) u v) := by sorry\ntheorem ip_neg_right (u v : V) :\n Inner.ip (R := R) (V := V) u\n (VSpace.oppV (R := R) (V := V) v)\n = Field.opp (Inner.ip (R := R) (V := V) u v) := by sorry\ntheorem ip_add_add (u v : V) :\n Inner.ip (R := R) (V := V)\n (VSpace.addV (R := R) (V := V) u v)\n (VSpace.addV (R := R) (V := V) u v)\n = ((Inner.ip (R := R) (V := V) u u +R Inner.ip (R := R) (V := V) v u)\n +R (Inner.ip (R := R) (V := V) u v +R Inner.ip (R := R) (V := V) v v)) := by sorry\ntheorem ip_sub_sub (u v : V) :\n Inner.ip (R := R) (V := V)\n (subV (R := R) (V := V) u v)\n (subV (R := R) (V := V) u v)\n = ((Inner.ip (R := R) (V := V) u u +R Field.opp (Inner.ip (R := R) (V := V) v u))\n +R (Field.opp (Inner.ip (R := R) (V := V) u v) +R Inner.ip (R := R) (V := V) v v)) := by sorry\ntheorem pythagoras (u v : V)\n (h : Inner.ip (R := R) (V := V) u v = Field.zero) :\n Inner.ip (R := R) (V := V)\n (VSpace.addV (R := R) (V := V) u v)\n (VSpace.addV (R := R) (V := V) u v)\n = (Inner.ip (R := R) (V := V) u u +R Inner.ip (R := R) (V := V) v v) := by sorry\ntheorem parallelogram (u v : V) :\n (Inner.ip (R := R) (V := V)\n (VSpace.addV (R := R) (V := V) u v)\n (VSpace.addV (R := R) (V := V) u v)\n +R Inner.ip (R := R) (V := V)\n (subV (R := R) (V := V) u v)\n (subV (R := R) (V := V) u v))\n = (((Inner.ip (R := R) (V := V) u u +R Inner.ip (R := R) (V := V) v u)\n +R (Inner.ip (R := R) (V := V) u v +R Inner.ip (R := R) (V := V) v v))\n +R ((Inner.ip (R := R) (V := V) u u +R Field.opp (Inner.ip (R := R) (V := V) v u))\n +R ((Field.opp (Inner.ip (R := R) (V := V) u v))\n +R Inner.ip (R := R) (V := V) v v))) := by sorry\nend Linear\n" }, { "theorem_id": 7, "title": "inner_product", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Class Field := {\n R0 : Type;\n zeroR : R0;\n oneR : R0;\n addR : R0 -> R0 -> R0;\n mulR : R0 -> R0 -> R0;\n oppR : R0 -> R0;\n\n addR_comm : forall x y, addR x y = addR y x;\n addR_assoc : forall x y z, addR (addR x y) z = addR x (addR y z);\n addR_zero : forall x, addR x zeroR = x;\n zeroR_add : forall x, addR zeroR x = x;\n addR_opp : forall x, addR x (oppR x) = zeroR;\n\n mulR_comm : forall x y, mulR x y = mulR y x;\n mulR_assoc : forall x y z, mulR (mulR x y) z = mulR x (mulR y z);\n mulR_one : forall x, mulR x oneR = x;\n distR_l : forall x y z, mulR x (addR y z) = addR (mulR x y) (mulR x z);\n\n oppR_add : forall x y, oppR (addR x y) = addR (oppR x) (oppR y);\n mulR_opp_one : forall x, mulR (oppR oneR) x = oppR x;\n oppR_opp : forall x, oppR (oppR x) = x\n}.\n\nSection Linear.\n Context {F : Field}.\n\n Infix \"+R\" := addR (at level 65).\n Infix \"*R\" := mulR (at level 70).\n Notation \"-R x\" := (oppR x) (at level 100).\n\n Class VSpace := {\n V0 : Type;\n zeroV : V0;\n addV : V0 -> V0 -> V0;\n oppV : V0 -> V0;\n smul : R0 -> V0 -> V0;\n\n addV_comm : forall u v, addV u v = addV v u;\n addV_assoc : forall u v w, addV (addV u v) w = addV u (addV v w);\n addV_zero : forall u, addV u zeroV = u;\n addV_opp : forall u, addV u (oppV u) = zeroV;\n\n smul_addV : forall a u v, smul a (addV u v) = addV (smul a u) (smul a v);\n addR_smul : forall a b u, smul (a +R b) u = addV (smul a u) (smul b u);\n mul_smul : forall a b u, smul (a *R b) u = smul a (smul b u);\n one_smul : forall u, smul oneR u = u;\n smul_zeroV : forall a, smul a zeroV = zeroV;\n opp_smul_one : forall u, oppV u = smul (oppR oneR) u\n }.\n\n Infix \"+V\" := addV (at level 65).\n Notation \"-V x\" := (oppV x) (at level 100).\n Notation \"a •V x\" := (smul a x) (at level 70).\n Definition subV {VS : VSpace} (u v : V0) := addV u (oppV v).\n Infix \"-V\" := subV (at level 65).\n\n Class Inner `{VS : VSpace} := {\n ip : V0 -> V0 -> R0;\n\n lin_left_add : forall u v w, (ip (u +V v) w) = ((ip u w) +R (ip v w));\n lin_left_smul : forall a u v, (ip (a •V u) v) = (a *R (ip u v));\n\n lin_right_add : forall u v w, (ip u (v +V w)) = ((ip u v) +R (ip u w));\n lin_right_smul : forall a u v, (ip u (a •V v)) = (a *R (ip u v));\n\n symm : forall u v, ip u v = ip v u\n }.\n\n Context `{VS : VSpace} `{IN : Inner}.\n\n Notation \"⟪ x , y ⟫\" := (ip x y) (at level 80).\n\n Lemma ip_neg_left : forall u v, ⟪-V u, v⟫ = -R ⟪u, v⟫.\nProof.\nAdmitted.\n\n Lemma ip_neg_right : forall u v, ⟪u, -V v⟫ = -R ⟪u, v⟫.\nProof.\nAdmitted.\n\n Lemma ip_add_add : forall u v,\n ⟪u +V v, u +V v⟫ = ((⟪u,u⟫ +R ⟪v,u⟫) +R (⟪u,v⟫ +R ⟪v,v⟫)).\nProof.\nAdmitted.\n\n Lemma ip_sub_sub : forall u v,\n ⟪u -V v, u -V v⟫ = ((⟪u,u⟫ +R (-R ⟪v,u⟫)) +R ((-R ⟪u,v⟫) +R ⟪v,v⟫)).\nProof.\nAdmitted.\n\n Lemma pythagoras : forall u v,\n ⟪u,v⟫ = zeroR ->\n ⟪u +V v, u +V v⟫ = (⟪u,u⟫ +R ⟪v,v⟫).\nProof.\nAdmitted.\n\n Lemma parallelogram : forall u v,\n (⟪u +V v, u +V v⟫ +R ⟪u -V v, u -V v⟫)\n = (((⟪u,u⟫ +R ⟪v,u⟫) +R (⟪u,v⟫ +R ⟪v,v⟫))\n +R ((⟪u,u⟫ +R (-R ⟪v,u⟫)) +R ((-R ⟪u,v⟫) +R ⟪v,v⟫))).\nProof.\nAdmitted.\n\nEnd Linear." }, { "theorem_id": 8, "title": "integral_comp_neg_Iic", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "new_type (\"R\",0);;\n\nlet is_integral_context = new_definition\n `is_integral_context (zero:R) (oneR:R)\n (add:R->R->R) (opp:R->R) (mul:R->R->R)\n (le:R->R->bool) (lt:R->R->bool) (absR:R->R)\n (sigma:(R->bool)->(R->R)->R) <=>\n (!x y. add x y = add y x) /\\\n (!x y z. add (add x y) z = add x (add y z)) /\\\n (!x. add x zero = x) /\\\n (!x. add (opp x) x = zero) /\\\n (!x y z. add x z = add y z ==> x = y) /\\\n (!x y. mul x y = mul y x) /\\\n (!x y z. mul (mul x y) z = mul x (mul y z)) /\\\n (!x. mul x oneR = x) /\\\n (!x y z. mul x (add y z) = add (mul x y) (mul x z)) /\\\n (!x. opp (opp x) = x) /\\\n (!x y. le x y \\/ le y x) /\\\n (!x y. le x y \\/ ~(le x y)) /\\\n (!x y. le x y ==> le y x ==> x = y) /\\\n (!x. le x x) /\\\n (!x y z. le x y ==> le y z ==> le x z) /\\\n (!x y. le x y ==> le (opp y) (opp x)) /\\\n (!x y. lt x y <=> (le x y /\\ ~(x = y))) /\\\n (!x y. lt x y ==> lt (opp y) (opp x)) /\\\n (!x. le zero x ==> absR x = x) /\\\n (!x. le x zero ==> absR x = opp x) /\\\n (!x. le zero (absR x)) /\\\n (!x. absR (opp x) = absR x) /\\\n (!x y. le (absR (add x y)) (add (absR x) (absR y))) /\\\n (!D f c. sigma D (\\x. mul c (f x)) = mul c (sigma D f)) /\\\n (!D f g. (!x. D x ==> f x = g x) ==> sigma D f = sigma D g) /\\\n (!D. sigma D (\\x. zero) = zero) /\\\n (!D f g. sigma D (\\x. add (f x) (g x)) = add (sigma D f) (sigma D g)) /\\\n (!D E f. (!x. D x ==> E x ==> F) ==> sigma (\\x. D x \\/ E x) f = add (sigma D f) (sigma E f)) /\\\n (!D f g. (!x. D x ==> le (f x) (g x)) ==> le (sigma D f) (sigma D g)) /\\\n (!D E f. (!x. D x <=> E x) ==> sigma D f = sigma E f)`;;\n\nlet iic = new_definition `iic (le:R->R->bool) c x <=> le x c`;;\nlet ioi = new_definition `ioi (lt:R->R->bool) c x <=> lt c x`;;\nlet iio = new_definition `iio (lt:R->R->bool) c x <=> lt x c`;;\n\nlet unionD = new_definition `unionD (D:R->bool) (E:R->bool) x <=> D x \\/ E x`;;\nlet interD = new_definition `interD (D:R->bool) (E:R->bool) x <=> D x /\\ E x`;;\n\nlet preimage = new_definition `preimage (g:R->R) (D:R->bool) x <=> D (g x)`;;\n\nlet INTRO_INT_HYPS =\n REWRITE_TAC[is_integral_context] THEN REPEAT GEN_TAC THEN\n DISCH_THEN (fun th -> ASSUME_TAC th THEN MAP_EVERY ASSUME_TAC (CONJUNCTS th));;\n\nlet ASSUM_MATCH_TAC pat ttac =\n ASSUM_LIST\n (fun asms ->\n let th =\n find\n (fun th ->\n try\n let (_,tinst,_) = term_match [] pat (concl th) in\n forall (fun (v,t) -> t = v) tinst\n with Failure _ -> false)\n asms in\n ttac th);;\n\nlet lt_irrefl = new_axiom\n (`!zero oneR add opp mul le lt absR sigma x.\n is_integral_context zero oneR add opp mul le lt absR sigma ==> ~(lt x x)`);;\n\nlet lt_trans_strict = new_axiom\n (`!zero oneR add opp mul le lt absR sigma x y z.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> lt x y ==> lt y z ==> lt x z`);;\n\nlet preimage_union = new_axiom\n (`!D E (g:R->R) x.\n preimage g (unionD D E) x <=> preimage g D x \\/ preimage g E x`);;\n\nlet preimage_inter = new_axiom\n (`!D E (g:R->R) x.\n preimage g (interD D E) x <=> preimage g D x /\\ preimage g E x`);;\n\nlet preimage_neg_Ioi = new_axiom\n (`!zero oneR add opp mul le lt absR sigma c x.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> (preimage opp (ioi lt c) x <=> lt x (opp c))`);;\n\nlet preimage_neg_Iic = new_axiom\n (`!zero oneR add opp mul le lt absR sigma c x.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> (preimage opp (iic le c) x <=> iic le x (opp c))`);;\n\nlet preimage_comp = new_axiom\n (`!D (g:R->R) (h:R->R) x.\n preimage g (preimage h D) x <=> preimage (\\x. h (g x)) D x`);;\n\nlet integral_neg = new_axiom\n (`!zero oneR add opp mul le lt absR sigma D phi.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> sigma D (\\x. opp (phi x)) = opp (sigma D phi)`);;\n\nlet integral_sub = new_axiom\n (`!zero oneR add opp mul le lt absR sigma D f g.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> sigma D (\\x. add (f x) (opp (g x))) = add (sigma D f) (opp (sigma D g))`);;\n\nlet sigma_empty = new_axiom\n (`!zero oneR add opp mul le lt absR sigma f.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> sigma (\\x. F) f = zero`);;\n\nlet sigma_bilinear = new_axiom\n (`!zero oneR add opp mul le lt absR sigma D f g c d.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> sigma D (\\x. add (mul c (f x)) (mul d (g x))) =\n add (mul c (sigma D f)) (mul d (sigma D g))`);;\n\nlet sigma_le_monotone = new_axiom\n (`!zero oneR add opp mul le lt absR sigma D f g.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> (!x. D x ==> le (f x) (g x)) ==> le (sigma D f) (sigma D g)`);;\n\nlet sigma_nonneg = new_axiom\n (`!zero oneR add opp mul le lt absR sigma D f.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> (!x. D x ==> le zero (f x)) ==> le zero (sigma D f)`);;\n\nlet sigma_split = new_axiom\n (`!zero oneR add opp mul le lt absR sigma D P f.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> (!x. D x ==> P x \\/ ~(P x))\n ==> sigma D f =\n add (sigma (\\x. D x /\\ P x) f) (sigma (\\x. D x /\\ ~(P x)) f)`);;\n\nlet sigma_preimage_neg_Ioi = new_axiom\n (`!zero oneR add opp mul le lt absR sigma f c.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> sigma (preimage opp (ioi lt c)) f = sigma (iio lt (opp c)) f`);;\n\nlet sigma_abs_bound = new_axiom\n (`!zero oneR add opp mul le lt absR sigma D f.\n is_integral_context zero oneR add opp mul le lt absR sigma\n ==> le (absR (sigma D f)) (sigma D (\\x. absR (f x)))`);;" }, { "theorem_id": 8, "title": "integral_comp_neg_Iic", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory integral_comp_neg_Iic\n imports Main\nbegin\n\nsection \"Integrals\"\n\nlocale integrals_setup =\n fixes zero one :: \"'r\"\n and add :: \"'r \\ 'r \\ 'r\" (infixl \"+R\" 65)\n and opp :: \"'r \\ 'r\"\n and mul :: \"'r \\ 'r \\ 'r\" (infixl \"*R\" 70)\n and leR :: \"'r \\ 'r \\ bool\" (infix \"\\R\" 50)\n and ltR :: \"'r \\ 'r \\ bool\" (infix \" 'r\"\n and sigma :: \"('r \\ bool) \\ ('r \\ 'r) \\ 'r\"\n \n assumes\n add_comm : \"\\x y. x +R y = y +R x\"\n and add_assoc : \"\\x y z. (x +R y) +R z = x +R (y +R z)\"\n and add_zero : \"\\x. x +R zero = x\"\n and add_opp : \"\\x. opp x +R x = zero\"\n and add_right_cancel : \"\\x y z. x +R z = y +R z \\ x = y\"\n and mul_comm : \"\\x y. x *R y = y *R x\"\n and mul_assoc : \"\\x y z. (x *R y) *R z = x *R (y *R z)\"\n and mul_one : \"\\x. x *R one = x\"\n and dist_l : \"\\x y z. x *R (y +R z) = (x *R y) +R (x *R z)\"\n and opp_inv : \"\\x. opp (opp x) = x\"\n and add_le_compat : \"\\x y z. x \\R y \\ (x +R z) \\R (y +R z)\"\n and le_opp : \"\\x y. x \\R y \\ opp y \\R opp x\"\n and le_antisymm : \"\\x y. x \\R y \\ y \\R x \\ x = y\"\n and lt_opp : \"\\x y. x opp y x. x \\R x\"\n and le_trans : \"\\x y z. x \\R y \\ y \\R z \\ x \\R z\"\n and le_total : \"\\x y. x \\R y \\ y \\R x\"\n and lt_def : \"\\x y. (x (x \\R y \\ x \\ y)\"\n and abs_pos : \"\\x. zero \\R x \\ absR x = x\"\n and abs_neg : \"\\x. x \\R zero \\ absR x = opp x\"\n and abs_nonneg : \"\\x. zero \\R absR x\"\n and abs_opp : \"\\x. absR (opp x) = absR x\"\n and abs_triangle : \"\\x y. absR (x +R y) \\R (absR x +R absR y)\"\n \n and sigma_mul_const : \"\\D f c. sigma D (\\x. c *R f x) = c *R sigma D f\"\n and sigma_congr : \"\\D f g. (\\x. D x \\ f x = g x) \\ sigma D f = sigma D g\"\n and sigma_zero : \"\\D. sigma D (\\_. zero) = zero\"\n and sigma_add : \"\\D f g. sigma D (\\x. f x +R g x) = sigma D f +R sigma D g\"\n and sigma_union_disjoint :\n \"\\D E f. (\\x. D x \\ E x \\ False) \\\n sigma (\\x. D x \\ E x) f = sigma D f +R sigma E f\"\n and sigma_le : \"\\D f g. (\\x. D x \\ f x \\R g x) \\ sigma D f \\R sigma D g\"\n and sigma_dom_congr :\n \"\\D E f. (\\x. D x \\ E x) \\ sigma D f = sigma E f\"\nbegin\n\ndefinition Iic :: \"'r \\ 'r \\ bool\" where \"Iic c x \\ x \\R c\"\ndefinition Ioi :: \"'r \\ 'r \\ bool\" where \"Ioi c x \\ c 'r \\ bool\" where \"Iio c x \\ x 'r) \\ ('r \\ bool) \\ 'r \\ bool\"\n where \"preimage g D x \\ D (g x)\"\n\nlemma add_opp_r: \"x +R opp x = zero\"\n by sorry\n\nlemma lt_irrefl: \"\\ (x y x x. D x \\ E x) x \\ preimage g D x \\ preimage g E x\"\n by sorry\n\nlemma preimage_inter:\n \"preimage g (\\x. D x \\ E x) x \\ preimage g D x \\ preimage g E x\"\n by sorry\n\nlemma preimage_neg_Ioi: \"preimage opp (Ioi c) x \\ x opp c \\R x\"\n by sorry\n\nlemma preimage_comp:\n \"preimage g (preimage h D) x \\ preimage (\\x. h (g x)) D x\"\n by sorry\n\nlemma integral_neg: \"sigma D (\\x. opp (f x)) = opp (sigma D f)\"\n by sorry\n\nlemma integral_sub:\n \"sigma D (\\x. f x +R opp (g x)) = sigma D f +R opp (sigma D g)\"\n by sorry\n\nlemma sigma_empty: \"sigma (\\_. False) f = zero\"\n by sorry\n\nlemma sigma_bilinear:\n \"sigma D (\\x. (c *R f x) +R (d *R g x)) =\n (c *R sigma D f) +R (d *R sigma D g)\"\n by sorry\n\nlemma sigma_le_monotone:\n \"(\\x. D x \\ f x \\R g x) \\ sigma D f \\R sigma D g\"\n by sorry\n\nlemma sigma_nonneg:\n \"(\\x. D x \\ zero \\R f x) \\ zero \\R sigma D f\"\n by sorry\n\nlemma sigma_split:\n \"sigma D f =\n sigma (\\x. D x \\ P x) f +R sigma (\\x. D x \\ \\ P x) f\"\n by sorry\n\nlemma sigma_preimage_neg_Ioi:\n \"sigma (preimage opp (Ioi c)) f = sigma (Iio (opp c)) f\"\n by sorry\n\nlemma sigma_abs_bound:\n \"absR (sigma D f) \\R sigma D (\\x. absR (f x))\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 8, "title": "integral_comp_neg_Iic", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "class RField (R : Type) where\n zero : R\n one : R\n add : R → R → R\n opp : R → R\n mul : R → R → R\n le : R → R → Prop\n lt : R → R → Prop\n abs : R → R\n\n add_comm : ∀ x y, add x y = add y x\n add_assoc : ∀ x y z, add (add x y) z = add x (add y z)\n add_zero : ∀ x, add x zero = x\n add_opp : ∀ x, add (opp x) x = zero\n add_right_cancel : ∀ x y z, add x z = add y z → x = y\n\n mul_comm : ∀ x y, mul x y = mul y x\n mul_assoc : ∀ x y z, mul (mul x y) z = mul x (mul y z)\n mul_one : ∀ x, mul x one = x\n dist_l : ∀ x y z, mul x (add y z) = add (mul x y) (mul x z)\n opp_involutive : ∀ x, opp (opp x) = x\n\n add_le_compat : ∀ x y z, le x y → le (add x z) (add y z)\n mul_le_compat : ∀ x y z, le zero z → le x y → le (mul x z) (mul y z)\n zero_le_one : le zero one\n le_total : ∀ x y, le x y ∨ le y x\n\n le_dec : ∀ x y, (le x y) ∨ ¬ (le x y)\n\n le_opp : ∀ x y, le x y → le (opp y) (opp x)\n le_antisymm : ∀ x y, le x y → le y x → x = y\n lt_opp : ∀ x y, lt x y → lt (opp y) (opp x)\n le_refl : ∀ x, le x x\n le_trans : ∀ x y z, le x y → le y z → le x z\n lt_def : ∀ x y, lt x y ↔ (le x y ∧ x ≠ y)\n\n abs_pos : ∀ x, le zero x → abs x = x\n abs_neg : ∀ x, le x zero → abs x = opp x\n abs_nonneg : ∀ x, le zero (abs x)\n abs_opp : ∀ x, abs (opp x) = abs x\n abs_triangle : ∀ x y, le (abs (add x y)) (add (abs x) (abs y))\n\nclass Integral (R : Type) [RField R] where\n sigma : (R → Prop) → (R → R) → R\n sigma_mul_const : ∀ (D : R → Prop) (f : R → R) (c : R),\n sigma D (fun x => RField.mul c (f x)) = RField.mul c (sigma D f)\n sigma_congr : ∀ D f g, (∀ x, D x → f x = g x) → sigma D f = sigma D g\n sigma_zero : ∀ D, sigma D (fun _ => RField.zero) = RField.zero\n sigma_add : ∀ D f g, sigma D (fun x => RField.add (f x) (g x)) = RField.add (sigma D f) (sigma D g)\n\n sigma_union_disjoint : ∀ (D E : R → Prop) (f : R → R),\n (∀ x, D x → E x → False) →\n sigma (fun x => D x ∨ E x) f = RField.add (sigma D f) (sigma E f)\n sigma_le : ∀ D f g, (∀ x, D x → RField.le (f x) (g x)) → RField.le (sigma D f) (sigma D g)\n sigma_dom_congr : ∀ D E f, (∀ x, D x ↔ E x) → sigma D f = sigma E f\n\nnamespace Integrals\n\nvariable {R : Type} [RF : RField R] [I : Integral R]\nopen RField\nopen Integral\n\n-- Notations\nprefix:100 \"-\" => opp\ninfixl:65 \" + \" => add\ninfixl:70 \" * \" => mul\ninfixl:70 \" <= \" => le\ninfixl:70 \" < \" => lt\n\n-- Domains\ndef Iic (c : R) : R → Prop := fun x => x <= c\ndef Ioi (c : R) : R → Prop := fun x => c < x\ndef Iio (c : R) : R → Prop := fun x => x < c\ndef union (D E : R → Prop) : R → Prop := fun x => D x ∨ E x\ndef inter (D E : R → Prop) : R → Prop := fun x => D x ∧ E x\n\n-- Lemma lt_irrefl\ntheorem lt_irrefl (x : R) : ¬ (x < x) := by sorry\ntheorem lt_trans_strict (x y z : R) (Hxy : x < y) (Hyz : y < z) : x < z := by sorry\ndef preimage (g : R → R) (D : R → Prop) : R → Prop :=\n fun x => D (g x)\n\ntheorem preimage_union (D E : R → Prop) (g : R → R) (x : R) :\n preimage g (union D E) x ↔ preimage g D x ∨ preimage g E x := by sorry\ntheorem preimage_inter (D E : R → Prop) (g : R → R) (x : R) :\n preimage g (inter D E) x ↔ preimage g D x ∧ preimage g E x := by sorry\ntheorem preimage_neg_Ioi (c x : R) :\n preimage opp (Ioi c) x ↔ x < opp c := by sorry\ntheorem preimage_neg_Iic (c x : R) :\n preimage opp (Iic c) x ↔ Iic x (opp c) := by sorry\ntheorem preimage_comp (D : R → Prop) (g h : R → R) (x : R) :\n preimage g (preimage h D) x ↔ preimage (fun x => h (g x)) D x := by sorry\ntheorem integral_neg (D : R → Prop) (f : R → R) :\n sigma D (fun x => opp (f x)) = opp (sigma D f) := by sorry\ntheorem integral_sub (D : R → Prop) (f g : R → R) :\n sigma D (fun x => add (f x) (opp (g x))) = add (sigma D f) (opp (sigma D g)) := by sorry\ntheorem sigma_empty (f : R → R) :\n sigma (fun _ => False) f = zero := by sorry\ntheorem sigma_bilinear (D : R → Prop) (f g : R → R) (c d : R) :\n sigma D (fun x => add (mul c (f x)) (mul d (g x))) =\n add (mul c (sigma D f)) (mul d (sigma D g)) := by sorry\ntheorem sigma_le_monotone (D : R → Prop) (f g : R → R) :\n (∀ x, D x → le (f x) (g x)) → le (sigma D f) (sigma D g) := by sorry\ntheorem sigma_nonneg (D : R → Prop) (f : R → R) :\n (∀ x, D x → le zero (f x)) → le zero (sigma D f) := by sorry\ntheorem sigma_split (D : R → Prop) (P : R → Prop) (f : R → R)\n (P_dec : ∀ x, D x → P x ∨ ¬ P x) :\n sigma D f =\n add (sigma (fun x => D x ∧ P x) f)\n (sigma (fun x => D x ∧ ¬ P x) f) := by sorry\ntheorem sigma_preimage_neg_Ioi (f : R → R) (c : R) :\n sigma (preimage opp (Ioi c)) f = sigma (Iio (opp c)) f := by sorry\ntheorem sigma_abs_bound (D : R → Prop) (f : R → R) :\n le (abs (sigma D f)) (sigma D (fun x => abs (f x))) := by sorry\nend Integrals\n" }, { "theorem_id": 8, "title": "integral_comp_neg_Iic", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "\nClass RField (R : Type) := {\n zero : R;\n one : R;\n add : R -> R -> R;\n opp : R -> R;\n mul : R -> R -> R;\n le : R -> R -> Prop;\n lt : R -> R -> Prop;\n abs : R -> R;\n\n add_comm : forall x y, add x y = add y x;\n add_assoc : forall x y z, add (add x y) z = add x (add y z);\n add_zero : forall x, add x zero = x;\n add_opp : forall x, add (opp x) x = zero;\n add_right_cancel : forall x y z, add x z = add y z -> x = y;\n\n mul_comm : forall x y, mul x y = mul y x;\n mul_assoc : forall x y z, mul (mul x y) z = mul x (mul y z);\n mul_one : forall x, mul x one = x;\n dist_l : forall x y z, mul x (add y z) = add (mul x y) (mul x z);\n opp_involutive : forall x, opp (opp x) = x;\n\n add_le_compat : forall x y z, le x y -> le (add x z) (add y z);\n mul_le_compat : forall x y z, le zero z -> le x y -> le (mul x z) (mul y z);\n zero_le_one : le zero one;\n le_total : forall x y, le x y \\/ le y x;\n \n le_dec : forall x y, { le x y } + { ~ le x y };\n\n le_opp : forall x y, le x y -> le (opp y) (opp x);\n le_antisymm : forall x y, le x y -> le y x -> x = y;\n lt_opp : forall x y, lt x y -> lt (opp y) (opp x);\n le_refl : forall x, le x x;\n le_trans : forall x y z, le x y -> le y z -> le x z;\n lt_def : forall x y, lt x y <-> (le x y /\\ x <> y);\n\n abs_pos : forall x, le zero x -> abs x = x;\n abs_neg : forall x, le x zero -> abs x = opp x;\n abs_nonneg : forall x, le zero (abs x);\n abs_opp : forall x, abs (opp x) = abs x;\n abs_triangle : forall x y, le (abs (add x y)) (add (abs x) (abs y));\n}.\n\n\nClass Integral (R : Type) `{RField R} := {\n sigma : (R -> Prop) -> (R -> R) -> R;\n sigma_mul_const : forall (D : R -> Prop) (f : R -> R) (c : R),\n sigma D (fun x => mul c (f x)) = mul c (sigma D f);\n sigma_congr : forall D f g,\n (forall x, D x -> f x = g x) -> sigma D f = sigma D g;\n sigma_zero : forall D, sigma D (fun _ => zero) = zero;\n sigma_add : forall D f g,\n sigma D (fun x => add (f x) (g x)) = add (sigma D f) (sigma D g);\n\n sigma_union_disjoint : forall (D E : R -> Prop) (f : R -> R),\n (forall x, D x -> E x -> False) ->\n sigma (fun x => D x \\/ E x) f = add (sigma D f) (sigma E f);\n sigma_le : forall D f g,\n (forall x, D x -> le (f x) (g x)) -> le (sigma D f) (sigma D g);\n sigma_dom_congr : forall D E f,\n (forall x, D x <-> E x) -> sigma D f = sigma E f\n}.\n\nSection Integrals.\n Variable (R : Type).\n Context `{RField R} `{Integral R}.\n\n Notation \"- x\" := (opp x) : integral_scope.\n Infix \"+\" := add : integral_scope.\n Infix \"*\" := mul : integral_scope.\n Infix \"<=\" := le : integral_scope.\n Infix \"<\" := lt : integral_scope.\n Open Scope integral_scope.\n\n Definition Iic (c : R) : R -> Prop := fun x => x <= c.\n Definition Ioi (c : R) : R -> Prop := fun x => c < x.\n Definition Iio (c : R) : R -> Prop := fun x => x < c.\n Definition union (D E : R -> Prop) : R -> Prop := fun x => D x \\/ E x.\n Definition inter (D E : R -> Prop) : R -> Prop := fun x => D x /\\ E x.\n\n Lemma lt_irrefl : forall x, ~ lt x x.\nProof.\nAdmitted.\n\n Lemma lt_trans_strict : forall x y z, lt x y -> lt y z -> lt x z.\nProof.\nAdmitted.\n\n\n Definition preimage (g : R -> R) (D : R -> Prop) : R -> Prop :=\n fun x => D (g x).\n\n Lemma preimage_union (D E : R -> Prop) (g : R -> R) (x : R) :\n preimage g (union D E) x <-> preimage g D x \\/ preimage g E x.\nProof.\nAdmitted.\n\n Lemma preimage_inter (D E : R -> Prop) (g : R -> R) (x : R) :\n preimage g (inter D E) x <-> preimage g D x /\\ preimage g E x.\nProof.\nAdmitted.\n\n Lemma preimage_neg_Ioi (c x : R) :\n preimage opp (Ioi c) x <-> lt x (opp c).\nProof.\nAdmitted.\n\n Lemma preimage_neg_Iic (c x: R) :\n preimage opp (Iic c) x <-> Iic x (opp c).\nProof.\nAdmitted.\n\n Lemma preimage_comp (D : R -> Prop) (g h: R -> R) :\n forall x, preimage g (preimage h D) x <-> preimage (fun x => h (g x)) D x.\nProof.\nAdmitted.\n\n Lemma integral_neg (D : R -> Prop) (f: R -> R) :\n sigma D (fun x => opp (f x)) = opp (sigma D f).\nProof.\nAdmitted.\n\n Lemma integral_sub (D : R -> Prop) (f g: R -> R):\n sigma D (fun x => add (f x) (opp (g x))) = add (sigma D f) (opp (sigma D g)).\nProof.\nAdmitted.\n\n Lemma sigma_empty (f : R -> R) :\n sigma (fun _ => False) f = zero.\nProof.\nAdmitted.\n\n Lemma sigma_bilinear (D : R -> Prop) (f g: R -> R) (c d: R) :\n sigma D (fun x => add (mul c (f x)) (mul d (g x))) =\n add (mul c (sigma D f)) (mul d (sigma D g)).\nProof.\nAdmitted.\n\n Lemma sigma_le_monotone (D : R -> Prop) (f g: R -> R) :\n (forall x, D x -> le (f x) (g x)) ->\n le (sigma D f) (sigma D g).\nProof.\nAdmitted.\n\n Lemma sigma_nonneg (D : R -> Prop) (f: R -> R) :\n (forall x, D x -> le zero (f x)) ->\n le zero (sigma D f).\nProof.\nAdmitted.\n\n Lemma sigma_split (D : R -> Prop) (P : R -> Prop) (f : R -> R)\n (P_dec : forall x, D x -> P x \\/ ~ P x) :\n sigma D f =\n add (sigma (fun x => D x /\\ P x) f)\n (sigma (fun x => D x /\\ ~ P x) f).\nProof.\nAdmitted.\n\n Lemma sigma_preimage_neg_Ioi (f: R -> R) (c: R) :\n sigma (preimage opp (Ioi c)) f = sigma (Iio (opp c)) f.\nProof.\nAdmitted.\n\n Lemma sigma_abs_bound {D f} :\n le (abs (sigma D f)) (sigma D (fun x => abs (f x))).\nProof.\nAdmitted.\n\n\nEnd Integrals.\n" }, { "theorem_id": 9, "title": "lattice_like", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let is_lattice_like = new_definition\n `is_lattice_like (le_rel:A->A->bool) (inf_op:A->A->A) (sup_op:A->A->A) <=>\n (!x. le_rel x x) /\\\n (!x y z. le_rel x y /\\ le_rel y z ==> le_rel x z) /\\\n (!x y. le_rel x y /\\ le_rel y x ==> x = y) /\\\n (!a b. le_rel (inf_op a b) a) /\\\n (!a b. le_rel (inf_op a b) b) /\\\n (!c a b. le_rel c a /\\ le_rel c b ==> le_rel c (inf_op a b)) /\\\n (!a b. le_rel a (sup_op a b)) /\\\n (!a b. le_rel b (sup_op a b)) /\\\n (!a b c. le_rel a c /\\ le_rel b c ==> le_rel (sup_op a b) c)`;;\n\nlet INTRO_LATTICE_HYPS =\n REWRITE_TAC[is_lattice_like] THEN REPEAT GEN_TAC THEN\n DISCH_THEN (fun th -> MAP_EVERY ASSUME_TAC (CONJUNCTS th));;\n\nlet inf_comm = `!(le_rel:A->A->bool) (inf_op:A->A->A) (sup_op:A->A->A).\n is_lattice_like le_rel inf_op sup_op ==> !a b:A. inf_op a b = inf_op b a`;;\n\nlet sup_comm = `!(le_rel:A->A->bool) (inf_op:A->A->A) (sup_op:A->A->A).\n is_lattice_like le_rel inf_op sup_op ==> !a b:A. sup_op a b = sup_op b a`;;\n\nlet inf_assoc = `!(le_rel:A->A->bool) (inf_op:A->A->A) (sup_op:A->A->A).\n is_lattice_like le_rel inf_op sup_op ==>\n !a b c:A. inf_op (inf_op a b) c = inf_op a (inf_op b c)`;;\n\nlet sup_assoc = `!(le_rel:A->A->bool) (inf_op:A->A->A) (sup_op:A->A->A).\n is_lattice_like le_rel inf_op sup_op ==>\n !a b c:A. sup_op (sup_op a b) c = sup_op a (sup_op b c)`;;\n\nlet inf_absorption = `!(le_rel:A->A->bool) (inf_op:A->A->A) (sup_op:A->A->A).\n is_lattice_like le_rel inf_op sup_op ==> !a b:A. inf_op a (sup_op a b) = a`;;\n\nlet sup_absorption = `!(le_rel:A->A->bool) (inf_op:A->A->A) (sup_op:A->A->A).\n is_lattice_like le_rel inf_op sup_op ==> !a b:A. sup_op a (inf_op a b) = a`;;" }, { "theorem_id": 9, "title": "lattice_like", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory lattice_like\n imports Main\nbegin\n\nsection \"LatticeLike\"\n\nlocale lattice_like =\n fixes le :: \"'a \\ 'a \\ bool\" (infix \"\\\" 50)\n and inf :: \"'a \\ 'a \\ 'a\" (infixl \"\\\" 60)\n and sup :: \"'a \\ 'a \\ 'a\" (infixl \"\\\" 65)\n assumes le_refl : \"\\x. x \\ x\"\n and le_trans : \"\\x y z. x \\ y \\ y \\ z \\ x \\ z\"\n and le_antisym: \"\\x y. x \\ y \\ y \\ x \\ x = y\"\n and le_inf_left : \"\\a b. inf a b \\ a\"\n and le_inf_right : \"\\a b. inf a b \\ b\"\n and le_inf_intro : \"\\c a b. c \\ a \\ c \\ b \\ c \\ inf a b\"\n and le_sup_left : \"\\a b. a \\ sup a b\"\n and le_sup_right : \"\\a b. b \\ sup a b\"\n and sup_le_intro : \"\\a b c. a \\ c \\ b \\ c \\ sup a b \\ c\"\nbegin\n\nlemma inf_comm: \"a \\ b = b \\ a\"\n by sorry\n\nlemma sup_comm: \"a \\ b = b \\ a\"\n by sorry\n\nlemma inf_assoc: \"(a \\ b) \\ c = a \\ (b \\ c)\"\n by sorry\n\nlemma sup_assoc: \"(a \\ b) \\ c = a \\ (b \\ c)\"\n by sorry\n\nlemma inf_absorption: \"a \\ (a \\ b) = a\"\n by sorry\n\nlemma sup_absorption: \"a \\ (a \\ b) = a\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 9, "title": "lattice_like", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "universe u\n\nclass LatticeLike (A : Type u) where\n le : A → A → Prop\n inf : A → A → A\n sup : A → A → A\n\n le_refl : ∀ x, le x x\n le_trans : ∀ {x y z}, le x y → le y z → le x z\n le_antisym : ∀ {x y}, le x y → le y x → x = y\n\n le_inf_left : ∀ a b, le (inf a b) a\n le_inf_right : ∀ a b, le (inf a b) b\n le_inf_intro : ∀ {c a b}, le c a → le c b → le c (inf a b)\n\n le_sup_left : ∀ a b, le a (sup a b)\n le_sup_right : ∀ a b, le b (sup a b)\n sup_le_intro : ∀ {a b c}, le a c → le b c → le (sup a b) c\n\nnamespace LatticeLike\n\nvariable {A : Type u} [L : LatticeLike A]\n\ninfix:50 \" ≤ \" => LatticeLike.le\ninfixl:65 \" ⊓ \" => LatticeLike.inf\ninfixl:70 \" ⊔ \" => LatticeLike.sup\n\ntheorem inf_comm (a b : A) : a ⊓ b = b ⊓ a := by sorry\ntheorem sup_comm (a b : A) : a ⊔ b = b ⊔ a := by sorry\ntheorem inf_assoc (a b c : A) : (a ⊓ b) ⊓ c = a ⊓ (b ⊓ c) := by sorry\ntheorem sup_assoc (a b c : A) : (a ⊔ b) ⊔ c = a ⊔ (b ⊔ c) := by sorry\ntheorem inf_absorption (a b : A) : a ⊓ (a ⊔ b) = a := by sorry\ntheorem sup_absorption (a b : A) : a ⊔ (a ⊓ b) = a := by sorry\nend LatticeLike\n" }, { "theorem_id": 9, "title": "lattice_like", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Class LatticeLike (A : Type) := {\n le : A -> A -> Prop;\n inf : A -> A -> A;\n sup : A -> A -> A;\n\n le_refl : forall x, le x x;\n le_trans : forall x y z, le x y -> le y z -> le x z;\n le_antisym : forall x y, le x y -> le y x -> x = y;\n\n le_inf_left : forall a b, le (inf a b) a;\n le_inf_right : forall a b, le (inf a b) b;\n le_inf_intro : forall c a b, le c a -> le c b -> le c (inf a b);\n\n le_sup_left : forall a b, le a (sup a b);\n le_sup_right : forall a b, le b (sup a b);\n sup_le_intro : forall a b c, le a c -> le b c -> le (sup a b) c\n}.\n\nSection LatticeFacts.\n Context {A : Type} {L : LatticeLike A}.\n\n Infix \"≤\" := le (at level 70, no associativity).\n\n Notation \"x ⊓ y\" := (inf x y) (at level 40).\n Notation \"x ⊔ y\" := (sup x y) (at level 50).\n\n Lemma inf_comm (a b : A) : a ⊓ b = b ⊓ a.\nProof.\nAdmitted.\n\n Lemma sup_comm (a b : A) : a ⊔ b = b ⊔ a.\nProof.\nAdmitted.\n\n Lemma inf_assoc (a b c : A) : (a ⊓ b) ⊓ c = a ⊓ (b ⊓ c).\nProof.\nAdmitted.\n\n Lemma sup_assoc (a b c : A) : (a ⊔ b) ⊔ c = a ⊔ (b ⊔ c).\nProof.\nAdmitted.\n\n Lemma inf_absorption (a b : A) : a ⊓ (a ⊔ b) = a.\nProof.\nAdmitted.\n\n Lemma sup_absorption (a b : A) : a ⊔ (a ⊓ b) = a.\nProof.\nAdmitted.\n\nEnd LatticeFacts.\n" }, { "theorem_id": 10, "title": "limits_uniqueness", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let limit = new_definition\n `limit zero lt absV le sub natLe u l <=>\n !eps. lt zero eps ==>\n ?N. !n. natLe N n ==> le (absV (sub (u n) l)) eps`;;\n\nlet abs_sub_triangle = `!(absV:A->A) (le:A->A->bool) (add:A->A->A) (sub:A->A->A) (x:A) (y:A) (z:A).\n (!u v w. sub u w = add (sub u v) (sub v w)) /\\\n (!u v. le (absV (add u v)) (add (absV u) (absV v))) /\\\n (!u v w. le u v ==> le v w ==> le u w) ==>\n le (absV (sub x z)) (add (absV (sub x y)) (absV (sub y z)))`;;\n\nlet limit_unique = `!zero add absV le lt sub natLe natMax u l m.\n (!x y. natLe x (natMax x y)) /\\\n (!x y. natLe y (natMax x y)) /\\\n (!x y z. sub x z = add (sub x y) (sub y z)) /\\\n (!x y. absV (sub x y) = absV (sub y x)) /\\\n (!x y z. le x y ==> le y z ==> le x z) /\\\n (!a b c d. le a b ==> le c d ==> le (add a c) (add b d)) /\\\n (!x y. le (absV (add x y)) (add (absV x) (absV y))) /\\\n (!x y. sub x y = zero ==> x = y) /\\\n (!x. (!eps. lt zero eps ==> le (absV x) (add eps eps)) ==> x = zero) /\\\n limit zero lt absV le sub natLe u l ==>\n limit zero lt absV le sub natLe u m ==>\n l = m`;;" }, { "theorem_id": 10, "title": "limits_uniqueness", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory limits_uniqueness\n imports Main\nbegin\n\nsection \"LimitsUniqueness\"\n\nlocale abs_field =\n fixes zero :: \"'r\"\n and one :: \"'r\"\n and add :: \"'r \\ 'r \\ 'r\" (infixl \"+R\" 65)\n and mul :: \"'r \\ 'r \\ 'r\" (infixl \"*R\" 70)\n and opp :: \"'r \\ 'r\"\n and absV :: \"'r \\ 'r\"\n and le :: \"'r \\ 'r \\ bool\" (infix \"\\\" 50)\n and lt :: \"'r \\ 'r \\ bool\" (infix \"\\\" 50)\n \n and natLe :: \"'n \\ 'n \\ bool\"\n and natMax :: \"'n \\ 'n \\ 'n\"\n assumes le_max_left : \"\\x y. natLe x (natMax x y)\"\n and le_max_right : \"\\x y. natLe y (natMax x y)\"\n and add_comm : \"\\x y. x +R y = y +R x\"\n and add_assoc : \"\\x y z. (x +R y) +R z = x +R (y +R z)\"\n and add_zero : \"\\x. x +R zero = x\"\n and add_opp : \"\\x. x +R opp x = zero\"\n and opp_add : \"\\x y. opp (x +R y) = opp x +R opp y\"\n and le_refl : \"\\x. x \\ x\"\n and le_trans : \"\\x y z. x \\ y \\ y \\ z \\ x \\ z\"\n and add_le_add : \"\\a b c d. a \\ b \\ c \\ d \\ a +R c \\ b +R d\"\n and abs_nonneg : \"\\x. zero \\ absV x\"\n and abs_triangle : \"\\x y. absV (x +R y) \\ absV x +R absV y\"\n and abs_sub_symm : \"\\x y. absV (x +R opp y) = absV (y +R opp x)\"\n and sub_decomp : \"\\x y z. x +R opp z = (x +R opp y) +R (y +R opp z)\"\n and sub_eq_zero : \"\\x y. x +R opp y = zero \\ x = y\"\n and eq_of_forall_eps2 :\n \"\\x. (\\eps. zero \\ eps \\ absV x \\ eps +R eps) \\ x = zero\"\nbegin\n\ndefinition sub :: \"'r \\ 'r \\ 'r\"\n where \"sub x y \\ x +R opp y\"\n\ndefinition limit :: \"('n \\ 'r) \\ 'r \\ bool\"\n where \"limit u l \\\n \\eps. zero \\ eps \\\n (\\N. \\n. natLe N n \\ absV (sub (u n) l) \\ eps)\"\n\nlemma sub_self_zero: \"sub x x = zero\"\n by sorry\n\nlemma sub_decomp_lem: \"sub x z = (sub x y) +R (sub y z)\"\n by sorry\n\nlemma abs_sub_triangle:\n \"absV (sub x z) \\ absV (sub x y) +R absV (sub y z)\"\n by sorry\n\nlemma abs_sub_symm_lem: \"absV (sub x y) = absV (sub y x)\"\n by sorry\n\ntheorem limit_unique:\n assumes Hl: \"limit u l\" and Hm: \"limit u m\"\n shows \"l = m\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 10, "title": "limits_uniqueness", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "class AbsField (R : Type) where\n zero : R\n one : R\n add : R → R → R\n mul : R → R → R\n opp : R → R\n abs : R → R\n le : R → R → Prop\n lt : R → R → Prop\n\n\n NatAlt : Type\n NatAltle : NatAlt → NatAlt → Prop\n NatAltMax : NatAlt → NatAlt → NatAlt\n le_max_left : ∀ x y, NatAltle x (NatAltMax x y)\n le_max_right : ∀ x y, NatAltle y (NatAltMax x y)\n\n add_comm : ∀ x y, add x y = add y x\n add_assoc : ∀ x y z, add (add x y) z = add x (add y z)\n add_zero : ∀ x, add x zero = x\n add_opp : ∀ x, add x (opp x) = zero\n opp_add : ∀ x y, opp (add x y) = add (opp x) (opp y)\n mul_comm : ∀ x y, mul x y = mul y x\n mul_assoc : ∀ x y z, mul (mul x y) z = mul x (mul y z)\n mul_one : ∀ x, mul x one = x\n\n le_refl : ∀ x, le x x\n le_trans : ∀ x y z, le x y → le y z → le x z\n add_le_add : ∀ a b c d, le a b → le c d → le (add a c) (add b d)\n\n abs_nonneg : ∀ x, le zero (abs x)\n abs_triangle : ∀ x y, le (abs (add x y)) (add (abs x) (abs y))\n abs_opp : ∀ x, abs (opp x) = abs x\n abs_sub_symm : ∀ x y, abs (add x (opp y)) = abs (add y (opp x))\n\n\n sub_decomp : ∀ x y z, add x (opp z) = add (add x (opp y)) (add y (opp z))\n sub_eq_zero : ∀ x y, add x (opp y) = zero → x = y\n\n eq_of_forall_eps2 : ∀ x, (∀ eps, lt zero eps → le (abs x) (add eps eps)) → x = zero\n\nnamespace Limits\n\nvariable {R : Type} [AR : AbsField R]\n\n\n\n\ndef sub (x y : R) : R := AbsField.add x (AbsField.opp y)\n\ndef limit (u : (AbsField.NatAlt (R := R)) → R) (l : R) : Prop :=\n ∀ eps : R, AbsField.lt AbsField.zero eps →\n ∃ N : AbsField.NatAlt (R := R),\n ∀ n : AbsField.NatAlt (R := R),\n AbsField.NatAltle (R := R) N n →\n AbsField.le (AbsField.abs (sub (u n) l)) eps\n\ntheorem sub_self_zero (x : R) : sub x x = AbsField.zero := by sorry\ntheorem sub_decomp (x y z : R) : sub x z = AR.add (sub x y) (sub y z) := by sorry\ntheorem abs_sub_triangle (x y z : R) :\n AbsField.le (AbsField.abs (sub x z)) (AbsField.add (AbsField.abs (sub x y)) (AbsField.abs (sub y z))) := by sorry\ntheorem abs_sub_nonneg (x y : R) : AR.le AR.zero (AR.abs (sub x y)) := by sorry\ntheorem limit_unique (u : (AbsField.NatAlt (R := R)) → R) (l m : R) :\n limit u l → limit u m → l = m := by sorry\nend Limits\n" }, { "theorem_id": 10, "title": "limits_uniqueness", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Class AbsField := {\n R0 : Type;\n zero : R0;\n one : R0;\n add : R0 -> R0 -> R0;\n mul : R0 -> R0 -> R0;\n opp : R0 -> R0;\n abs : R0 -> R0;\n leR : R0 -> R0 -> Prop;\n ltR : R0 -> R0 -> Prop;\n\n\n N0 : Type;\n Nle : N0 -> N0 -> Prop;\n Nmax : N0 -> N0 -> N0;\n Nle_max_l : forall x y, Nle x (Nmax x y);\n Nle_max_r : forall x y, Nle y (Nmax x y);\n\n add_comm : forall x y, add x y = add y x;\n add_assoc : forall x y z, add (add x y) z = add x (add y z);\n add_zero : forall x, add x zero = x;\n add_opp : forall x, add x (opp x) = zero;\n mul_comm : forall x y, mul x y = mul y x;\n mul_assoc : forall x y z, mul (mul x y) z = mul x (mul y z);\n mul_one : forall x, mul x one = x;\n\n le_refl : forall x, leR x x;\n le_trans : forall x y z, leR x y -> leR y z -> leR x z;\n add_le_add : forall a b c d, leR a b -> leR c d -> leR (add a c) (add b d);\n\n abs_nonneg : forall x, leR zero (abs x);\n abs_triangle : forall x y, leR (abs (add x y)) (add (abs x) (abs y));\n abs_opp : forall x, abs (opp x) = abs x;\n abs_sub_symm : forall x y, abs (add x (opp y)) = abs (add y (opp x));\n sub_decomp : forall x y z, add x (opp z) = add (add x (opp y)) (add y (opp z));\n sub_eq_zero : forall x y, add x (opp y) = zero -> x = y;\n\n\n eq_of_forall_eps2 : forall x, (forall eps, ltR zero eps -> leR (abs x) (add eps eps)) -> x = zero\n}.\n\nSection Limits.\n Context {A : AbsField}.\n\n Infix \"+R\" := add (at level 65).\n Notation \"-R x\" := (opp x) (at level 100).\n\n Definition sub (x y : R0) : R0 := add x (opp y).\n\n Definition limit (u : N0 -> R0) (l : R0) : Prop :=\n forall eps, ltR zero eps -> exists N, forall n, Nle N n -> leR (abs (sub (u n) l)) eps.\n\n Lemma abs_sub_triangle (x y z : R0) :\n leR (abs (sub x z)) (add (abs (sub x y)) (abs (sub y z))).\nProof.\nAdmitted.\n\n Theorem limit_unique (u : N0 -> R0) (l m : R0) :\n limit u l -> limit u m -> l = m.\nProof.\nAdmitted.\n\nEnd Limits.\n" }, { "theorem_id": 11, "title": "linear_map", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let is_linear_map = new_definition\n `is_linear_map (zeroV:'v) (addV:'v->'v->'v) (smul:'r->'v->'v)\n (zeroW:'w) (addW:'w->'w->'w) (smulW:'r->'w->'w)\n (toFun:'v->'w) <=>\n (!u v. addV u v = addV v u) /\\\n (!u v w. addV (addV u v) w = addV u (addV v w)) /\\\n (!u. addV u zeroV = u) /\\\n (!a. smul a zeroV = zeroV) /\\\n (!u v. addW u v = addW v u) /\\\n (!u v w. addW (addW u v) w = addW u (addW v w)) /\\\n (!u. addW u zeroW = u) /\\\n (!a. smulW a zeroW = zeroW) /\\\n (!u v. toFun (addV u v) = addW (toFun u) (toFun v)) /\\\n (!a u. toFun (smul a u) = smulW a (toFun u))`;;\n\nlet ker = new_definition\n `ker (toFun:'v->'w) (zeroW:'w) x <=> toFun x = zeroW`;;\n\nlet im = new_definition\n `im (toFun:'v->'w) y <=> ?x. toFun x = y`;;\n\nlet ker_add = `!zeroV addV smul zeroW addW smulW (toFun:'v->'w) x y.\n is_linear_map zeroV addV smul zeroW addW smulW toFun ==>\n ker toFun zeroW x ==> ker toFun zeroW y ==> ker toFun zeroW (addV x y)`;;\n\nlet ker_smul = `!zeroV addV smul zeroW addW smulW (toFun:'v->'w) a x.\n is_linear_map zeroV addV smul zeroW addW smulW toFun ==>\n ker toFun zeroW x ==> ker toFun zeroW (smul a x)`;;\n\nlet im_add = `!zeroV addV smul zeroW addW smulW (toFun:'v->'w) y z.\n is_linear_map zeroV addV smul zeroW addW smulW toFun ==>\n im toFun y ==> im toFun z ==> im toFun (addW y z)`;;\n\nlet im_smul = `!zeroV addV smul zeroW addW smulW (toFun:'v->'w) a y.\n is_linear_map zeroV addV smul zeroW addW smulW toFun ==>\n im toFun y ==> im toFun (smulW a y)`;;" }, { "theorem_id": 11, "title": "linear_map", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory linear_map\n imports Main\nbegin\n\nsection \"LinearMap\"\n\nlocale linear_map_setup =\n fixes zeroV :: \"'v\"\n and addV :: \"'v \\ 'v \\ 'v\" (infixl \"+V\" 65)\n and smul :: \"'r \\ 'v \\ 'v\" (infixr \"\\V\" 70)\n and zeroW :: \"'w\"\n and addW :: \"'w \\ 'w \\ 'w\" (infixl \"+W\" 65)\n and smulW :: \"'r \\ 'w \\ 'w\" (infixr \"\\W\" 70)\n and toFun :: \"'v \\ 'w\"\n \n assumes addV_comm : \"\\u v. u +V v = v +V u\"\n and addV_assoc : \"\\u v w. (u +V v) +V w = u +V (v +V w)\"\n and addV_zero : \"\\u. u +V zeroV = u\"\n and smul_zeroV : \"\\a. a \\V zeroV = zeroV\"\n \n and addW_comm : \"\\u v. u +W v = v +W u\"\n and addW_assoc : \"\\u v w. (u +W v) +W w = u +W (v +W w)\"\n and addW_zero : \"\\u. u +W zeroW = u\"\n and smulW_zero : \"\\a. a \\W zeroW = zeroW\"\n \n and map_add : \"\\u v. toFun (u +V v) = toFun u +W toFun v\"\n and map_smul : \"\\a u. toFun (a \\V u) = a \\W toFun u\"\nbegin\n\ndefinition ker :: \"'v \\ bool\"\n where \"ker x \\ toFun x = zeroW\"\n\ndefinition im :: \"'w \\ bool\"\n where \"im y \\ \\x. toFun x = y\"\n\nlemma ker_add:\n assumes \"ker x\" \"ker y\" shows \"ker (x +V y)\"\n by sorry\n\nlemma ker_smul:\n assumes \"ker x\" shows \"ker (a \\V x)\"\n by sorry\n\nlemma im_add:\n assumes \"im y\" \"im z\" shows \"im (y +W z)\"\n by sorry\n\nlemma im_smul:\n assumes \"im y\" shows \"im (a \\W y)\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 11, "title": "linear_map", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "class Field (R : Type) where\n zero : R\n one : R\n add : R → R → R\n mul : R → R → R\n opp : R → R\n add_comm : ∀ x y, add x y = add y x\n add_assoc : ∀ x y z, add (add x y) z = add x (add y z)\n add_zero : ∀ x, add x zero = x\n add_opp : ∀ x, add x (opp x) = zero\n mul_comm : ∀ x y, mul x y = mul y x\n mul_assoc : ∀ x y z, mul (mul x y) z = mul x (mul y z)\n mul_one : ∀ x, mul x one = x\n dist_l : ∀ a x y, mul a (add x y) = add (mul a x) (mul a y)\n\nnamespace Lin\n\nvariable {R : Type} [FR : Field R]\nopen Field\n\ninfixl:65 \"+R\" => Field.add\ninfixl:70 \"*R\" => Field.mul\nprefix:100 \"-R\" => Field.opp\n\nclass VSpace (R : Type) [Field R] (V : Type) where\n zeroV : V\n addV : V → V → V\n oppV : V → V\n smul : R → V → V\n addV_comm : ∀ u v, addV u v = addV v u\n addV_assoc : ∀ u v w, addV (addV u v) w = addV u (addV v w)\n addV_zero : ∀ u, addV u zeroV = u\n addV_opp : ∀ u, addV u (oppV u) = zeroV\n smul_addV : ∀ a u v, smul a (addV u v) = addV (smul a u) (smul a v)\n addR_smul : ∀ a b u, smul (a +R b) u = addV (smul a u) (smul b u)\n mul_smul : ∀ a b u, smul (a *R b) u = smul a (smul b u)\n one_smul : ∀ u, smul Field.one u = u\n smul_zero : ∀ a, smul a zeroV = zeroV\n\nattribute [simp] VSpace.addV_zero VSpace.smul_zero\n\ninfixl:65 \"+V\" => VSpace.addV\nnotation:70 a \" •V \" u => VSpace.smul a u\n\nstructure LMap (V W : Type) [VSpace R V] [VSpace R W] where\n toFun : V → W\n map_add : ∀ u v, toFun (VSpace.addV (R:=R) u v)\n = VSpace.addV (R:=R) (toFun u) (toFun v)\n map_smul : ∀ a u, toFun (VSpace.smul (R:=R) a u)\n = VSpace.smul (R:=R) a (toFun u)\n\nattribute [simp] LMap.map_add LMap.map_smul\n\nvariable {V W U : Type}\nvariable [VSpace R V] [VSpace R W] [VSpace R U]\n\ndef ker (L : LMap (R:=R) V W) : V → Prop := fun x => L.toFun x = VSpace.zeroV (R:=R)\ndef im (L : LMap (R:=R) V W) : W → Prop := fun y => ∃ x, L.toFun x = y\n\ndef comp (g : LMap (R:=R) W U) (f : LMap (R:=R) V W) : LMap (R:=R) V U :=\n{ toFun := fun x => g.toFun (f.toFun x)\n, map_add := by sorry\ntheorem ker_add {L : LMap (R:=R) V W} {x y : V} :\n ker L x → ker L y → ker L (VSpace.addV (R:=R) x y) := by sorry\ntheorem ker_smul {L : LMap (R:=R) V W} {a : R} {x : V} :\n ker L x → ker L (VSpace.smul (R:=R) a x) := by sorry\ntheorem im_add {L : LMap (R:=R) V W} {y z : W} :\n im L y → im L z → im L (VSpace.addV (R:=R) y z) := by sorry\ntheorem im_smul {L : LMap (R:=R) V W} {a : R} {y : W} :\n im L y → im L (VSpace.smul (R:=R) a y) := by sorry\nend Lin\n" }, { "theorem_id": 11, "title": "linear_map", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "\n\n\n\n\n\n\nClass Field := {\n R0 : Type;\n zeroR : R0;\n oneR : R0;\n addR : R0 -> R0 -> R0;\n mulR : R0 -> R0 -> R0;\n oppR : R0 -> R0;\n addR_comm : forall x y, addR x y = addR y x;\n addR_assoc : forall x y z, addR (addR x y) z = addR x (addR y z);\n addR_zero : forall x, addR x zeroR = x;\n addR_opp : forall x, addR x (oppR x) = zeroR;\n mulR_comm : forall x y, mulR x y = mulR y x;\n mulR_assoc : forall x y z, mulR (mulR x y) z = mulR x (mulR y z);\n mulR_one : forall x, mulR x oneR = x;\n distR_l : forall a x y, mulR a (addR x y) = addR (mulR a x) (mulR a y)\n}.\n\nSection Lin.\n Context {F : Field}.\n Infix \"+R\" := addR (at level 65).\n Infix \"*R\" := mulR (at level 70).\n Notation \"-R x\" := (oppR x) (at level 100).\n\n Class VSpace := {\n V0 : Type;\n zeroV : V0;\n addV : V0 -> V0 -> V0;\n oppV : V0 -> V0;\n smul : R0 -> V0 -> V0;\n addV_comm : forall u v, addV u v = addV v u;\n addV_assoc : forall u v w, addV (addV u v) w = addV u (addV v w);\n addV_zero : forall u, addV u zeroV = u;\n addV_opp : forall u, addV u (oppV u) = zeroV;\n smul_addV : forall a u v, smul a (addV u v) = addV (smul a u) (smul a v);\n addR_smul : forall a b u, smul (a +R b) u = addV (smul a u) (smul b u);\n mul_smul : forall a b u, smul (a *R b) u = smul a (smul b u);\n one_smul : forall u, smul oneR u = u;\n smul_zeroV : forall a, smul a zeroV = zeroV\n }.\n\n Infix \"+V\" := addV (at level 65).\n Notation \"a •V x\" := (smul a x) (at level 70).\n\n Record Lin `{VS1 : VSpace} `{VS2 : VSpace} := {\n toFun : V0 -> V0;\n map_add : forall u v, toFun (u +V v) = addV (toFun u) (toFun v);\n map_smul : forall a u, toFun (a •V u) = smul a (toFun u)\n }.\n\n Definition ker `{VS1 : VSpace} `{VS2 : VSpace} (L : Lin) : V0 -> Prop :=\n fun x => toFun L x = zeroV.\n Definition im `{VS1 : VSpace} `{VS2 : VSpace} (L : Lin) : V0 -> Prop :=\n fun y => exists x, toFun L x = y.\n\n Lemma ker_add `{VS1 : VSpace} `{VS2 : VSpace}\n (L : Lin) (x y : V0) :\n ker L x -> ker L y -> ker L (x +V y).\nProof.\nAdmitted.\n\n Lemma ker_smul `{VS1 : VSpace} `{VS2 : VSpace}\n (L : Lin) (a : R0) (x : V0) : ker L x -> ker L (a •V x).\nProof.\nAdmitted.\n\n Lemma im_add `{VS1 : VSpace} `{VS2 : VSpace}\n (L : Lin) (y z : V0) :\n im L y -> im L z -> im L (y +V z).\nProof.\nAdmitted.\n\n Lemma im_smul `{VS1 : VSpace} `{VS2 : VSpace}\n (L : Lin) (a : R0) (y : V0) :\n im L y -> im L (a •V y).\nProof.\nAdmitted.\n\nEnd Lin.\n" }, { "theorem_id": 12, "title": "polynomial", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let subR = new_definition\n `subR (addR:R->R->R) (oppR:R->R) (x:R) (y:R) = addR x (oppR y)`;;\n\nlet x_def = new_definition\n `X (monomial:num->R->P) (oneR:R) = monomial (SUC 0) oneR`;;\n\nlet c_def = new_definition\n `C (monomial:num->R->P) (c:R) = monomial 0 c`;;\n\nlet x_minus_def = new_definition\n `X_minus (monomial:num->R->P) (addP:P->P->P) (oppR:R->R) (oneR:R) (a:R) =\n addP (X monomial oneR) (C monomial (oppR a))`;;\n\nlet is_root = new_definition\n `is_root (eval:P->R->R) (zeroR:R) (a:R) (p:P) <=> eval p a = zeroR`;;\n\nlet poly_of_roots = new_recursive_definition list_RECURSION\n `poly_of_roots (monomial:num->R->P) (addP:P->P->P) (oppR:R->R) (oneR:R)\n (mulP:P->P->P) (oneP:P) [] = oneP /\\\n poly_of_roots monomial addP oppR oneR mulP oneP (CONS a xs) =\n mulP (X_minus monomial addP oppR oneR a)\n (poly_of_roots monomial addP oppR oneR mulP oneP xs)`;;\n\nlet is_poly_context = new_definition\n `is_poly_context\n (zeroR:R) (oneR:R) (addR:R->R->R) (mulR:R->R->R) (oppR:R->R)\n (zeroP:P) (oneP:P) (addP:P->P->P) (mulP:P->P->P) (oppP:P->P)\n (degree:P->num) (monomial:num->R->P) (eval:P->R->R) <=>\n ~(oneR = zeroR) /\\\n (!x y. addR x y = addR y x) /\\\n (!x y z. addR (addR x y) z = addR x (addR y z)) /\\\n (!x. addR x zeroR = x) /\\\n (!x. addR zeroR x = x) /\\\n (!x. addR x (oppR x) = zeroR) /\\\n (!x. addR (oppR x) x = zeroR) /\\\n (!x y. mulR x y = mulR y x) /\\\n (!x y z. mulR (mulR x y) z = mulR x (mulR y z)) /\\\n (!x. mulR x oneR = x) /\\\n (!x. mulR oneR x = x) /\\\n (!x y z. mulR x (addR y z) = addR (mulR x y) (mulR x z)) /\\\n (!x. mulR x zeroR = zeroR) /\\\n (!x. mulR zeroR x = zeroR) /\\\n (!x y. mulR x y = zeroR ==> x = zeroR \\/ y = zeroR) /\\\n ~(oneP = zeroP) /\\\n (!x y. addP x y = addP y x) /\\\n (!x y z. addP (addP x y) z = addP x (addP y z)) /\\\n (!x. addP x zeroP = x) /\\\n (!x. addP zeroP x = x) /\\\n (!x. addP x (oppP x) = zeroP) /\\\n (!x. addP (oppP x) x = zeroP) /\\\n (!x y. mulP x y = mulP y x) /\\\n (!x y z. mulP (mulP x y) z = mulP x (mulP y z)) /\\\n (!x. mulP x oneP = x) /\\\n (!x. mulP oneP x = x) /\\\n (!x y z. mulP x (addP y z) = addP (mulP x y) (mulP x z)) /\\\n (!x. mulP x zeroP = zeroP) /\\\n (!x. mulP zeroP x = zeroP) /\\\n (!x y. mulP x y = zeroP ==> x = zeroP \\/ y = zeroP) /\\\n (C monomial zeroR = zeroP) /\\\n (C monomial oneR = oneP) /\\\n (degree zeroP = 0) /\\\n (!p q x. eval (addP p q) x = addR (eval p x) (eval q x)) /\\\n (!p q x. eval (mulP p q) x = mulR (eval p x) (eval q x)) /\\\n (!c x. eval (C monomial c) x = c) /\\\n (!x. eval (X monomial oneR) x = x) /\\\n (!c. ~(c = zeroR) ==> degree (C monomial c) = 0) /\\\n (!p. degree p = 0 <=> ?c. p = C monomial c) /\\\n (!a. degree (X_minus monomial addP oppR oneR a) = SUC 0) /\\\n (!p q. ~(p = zeroP) /\\ ~(q = zeroP) ==> degree (mulP p q) = degree p + degree q) /\\\n (!p a. ?q r. p = addP (mulP q (X_minus monomial addP oppR oneR a)) r /\\ degree r = 0)`;;\n\nlet sub_eq_zero_l = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (a:R) (b:R).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> subR addR oppR a b = zeroR ==> a = b`);;\n\nlet root_factor = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (p:P) (a:R).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> is_root eval zeroR a p\n ==> ?q. p = mulP q (X_minus monomial addP oppR oneR a)`);;\n\nlet root_transfer = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (p:P) (q:P)\n (a:R) (b:R).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> p = mulP q (X_minus monomial addP oppR oneR a)\n ==> ~(b = a)\n ==> is_root eval zeroR b p\n ==> is_root eval zeroR b q`);;\n\nlet X_MINUS_NONZERO = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (a:R).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> ~(X_minus monomial addP oppR oneR a = zeroP)`);;\n\nlet x_minus_nonzero = X_MINUS_NONZERO;;\n\nlet constant_root_zero = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (p:P) (a:R).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> degree p = 0 ==> is_root eval zeroR a p ==> p = zeroP`);;\n\nlet root_of_product = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (p:P) (q:P) (a:R).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> is_root eval zeroR a (mulP p q) ==> is_root eval zeroR a p \\/ is_root eval zeroR a q`);;\n\nlet root_scale_constant = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (p:P) (c:R) (a:R).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> ~(c = zeroR) ==> (is_root eval zeroR a p <=> is_root eval zeroR a (mulP (C monomial c) p))`);;\n\nlet poly_of_roots_nonzero = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (xs:R list).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> ~(poly_of_roots monomial addP oppR oneR mulP oneP xs = zeroP)`);;\n\nlet deg_poly_of_roots = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (xs:R list).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> degree (poly_of_roots monomial addP oppR oneR mulP oneP xs) = LENGTH xs`);;\n\nlet root_factor_list = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (p:P) (xs:R list).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> ALL_DISTINCT xs\n ==> (!a. MEM a xs ==> is_root eval zeroR a p)\n ==> ?q. p = mulP q (poly_of_roots monomial addP oppR oneR mulP oneP xs)`);;\n\nlet degree_factorisation = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (p:P) (xs:R list) (q:P).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> p = mulP q (poly_of_roots monomial addP oppR oneR mulP oneP xs)\n ==> ~(q = zeroP)\n ==> degree p = degree q + LENGTH xs`);;\n\nlet roots_le_degree = new_axiom\n (`!zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval (p:P) (xs:R list).\n is_poly_context zeroR oneR addR mulR oppR zeroP oneP addP mulP oppP degree monomial eval\n ==> ALL_DISTINCT xs\n ==> (!a. MEM a xs ==> is_root eval zeroR a p)\n ==> ~(p = zeroP)\n ==> LENGTH xs <= degree p`);;" }, { "theorem_id": 12, "title": "polynomial", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory polynomial\n imports Main\nbegin\n\ndatatype mynat = Nat_O | Nat_S mynat\n\nfun mynat_add :: \"mynat \\ mynat \\ mynat\" where\n \"mynat_add Nat_O m = m\"\n| \"mynat_add (Nat_S n') m = Nat_S (mynat_add n' m)\"\n\ninductive mynat_le :: \"mynat \\ mynat \\ bool\" where\n le_n : \"mynat_le n n\"\n| le_S : \"mynat_le n m \\ mynat_le n (Nat_S m)\"\n\nlemma mynat_zero_le: \"mynat_le Nat_O n\"\n by sorry\n\nlemma mynat_add_zero_r: \"mynat_add n Nat_O = n\"\n by sorry\n\nlemma mynat_succ_le_succ: \"mynat_le n m \\ mynat_le (Nat_S n) (Nat_S m)\"\n by sorry\n\nlemma mynat_add_S_r: \"mynat_add m (Nat_S n) = Nat_S (mynat_add m n)\"\n by sorry\n\nlemma mynat_add_comm: \"mynat_add n m = mynat_add m n\"\n by sorry\n\ndatatype 'a mylist = NilL | ConsL 'a \"'a mylist\"\n\ninductive InL :: \"'a \\ 'a mylist \\ bool\" where\n In_head : \"InL x (ConsL x xs)\"\n| In_tail : \"InL x xs \\ InL x (ConsL y xs)\"\n\ninductive NoDupL :: \"'a mylist \\ bool\" where\n ND_nil : \"NoDupL NilL\"\n| ND_cons : \"\\ InL x xs \\ NoDupL xs \\ NoDupL (ConsL x xs)\"\n\nfun lengthL :: \"'a mylist \\ mynat\" where\n \"lengthL NilL = Nat_O\"\n| \"lengthL (ConsL _ rest) = Nat_S (lengthL rest)\"\n\nlocale polynomial_setup =\n fixes zero_r :: \"'r\"\n and one_r :: \"'r\"\n and opp_r :: \"'r \\ 'r\"\n and add_r :: \"'r \\ 'r \\ 'r\" (infixl \\+R\\ 65)\n and mul_r :: \"'r \\ 'r \\ 'r\" (infixl \\*R\\ 70)\n and zero_p :: \"'p\"\n and one_p :: \"'p\"\n and opp_p :: \"'p \\ 'p\"\n and add_p :: \"'p \\ 'p \\ 'p\" (infixl \\+P\\ 65)\n and mul_p :: \"'p \\ 'p \\ 'p\" (infixl \\*P\\ 70)\n and degree :: \"'p \\ mynat\"\n and monomial :: \"mynat \\ 'r \\ 'p\"\n and eval :: \"'p \\ 'r \\ 'r\"\n assumes\n r_one_neq_zero : \"one_r \\ zero_r\"\n and r_add_comm : \"\\x y. x +R y = y +R x\"\n and r_add_assoc : \"\\x y z. (x +R y) +R z = x +R (y +R z)\"\n and r_add_zero : \"\\x. x +R zero_r = x\"\n and r_add_opp : \"\\x. x +R opp_r x = zero_r\"\n and r_mul_comm : \"\\x y. x *R y = y *R x\"\n and r_mul_assoc : \"\\x y z. (x *R y) *R z = x *R (y *R z)\"\n and r_mul_one : \"\\x. x *R one_r = x\"\n and r_dist_l : \"\\x y z. x *R (y +R z) = (x *R y) +R (x *R z)\"\n and r_mul_zero : \"\\x. x *R zero_r = zero_r\"\n and r_no_zero_div : \"\\x y. x *R y = zero_r \\ x = zero_r \\ y = zero_r\"\n and p_one_neq_zero : \"one_p \\ zero_p\"\n and p_add_comm : \"\\x y. x +P y = y +P x\"\n and p_add_zero : \"\\x. x +P zero_p = x\"\n and p_mul_comm : \"\\x y. x *P y = y *P x\"\n and p_mul_assoc : \"\\x y z. (x *P y) *P z = x *P (y *P z)\"\n and p_mul_one : \"\\x. x *P one_p = x\"\n and p_mul_zero : \"\\x. x *P zero_p = zero_p\"\n and p_no_zero_div : \"\\x y. x *P y = zero_p \\ x = zero_p \\ y = zero_p\"\n and deg_zero : \"degree zero_p = Nat_O\"\n and eval_add : \"\\p q x. eval (p +P q) x = eval p x +R eval q x\"\n and eval_mul : \"\\p q x. eval (p *P q) x = eval p x *R eval q x\"\n and eval_C_ax : \"\\c x. eval (monomial Nat_O c) x = c\"\n and eval_X_ax : \"\\x. eval (monomial (Nat_S Nat_O) one_r) x = x\"\n and deg_C_ax : \"\\c. c \\ zero_r \\ degree (monomial Nat_O c) = Nat_O\"\n and deg_constant : \"\\p. (degree p = Nat_O) \\ (\\c. p = monomial Nat_O c)\"\n and deg_X_minus_ax : \"\\a. degree (monomial (Nat_S Nat_O) one_r +P monomial Nat_O (opp_r a)) = Nat_S Nat_O\"\n and deg_mul : \"\\p q. p \\ zero_p \\ q \\ zero_p \\\n degree (p *P q) = mynat_add (degree p) (degree q)\"\n and C_zero_ax : \"monomial Nat_O zero_r = zero_p\"\n and C_one_ax : \"monomial Nat_O one_r = one_p\"\n and euclid_X_minus_ax :\n \"\\p a. \\q r.\n p = q *P (monomial (Nat_S Nat_O) one_r +P monomial Nat_O (opp_r a)) +P r\n \\ degree r = Nat_O\"\nbegin\n\ndefinition X :: \"'p\" where\n \"X = monomial (Nat_S Nat_O) one_r\"\n\ndefinition C :: \"'r \\ 'p\" where\n \"C c = monomial Nat_O c\"\n\ndefinition X_minus :: \"'r \\ 'p\" where\n \"X_minus a = X +P C (opp_r a)\"\n\nfun poly_of_roots :: \"'r mylist \\ 'p\" where\n \"poly_of_roots NilL = one_p\"\n| \"poly_of_roots (ConsL a xs) = X_minus a *P poly_of_roots xs\"\n\ndefinition is_root :: \"'r \\ 'p \\ bool\" where\n \"is_root a p \\ eval p a = zero_r\"\n\nlemma X_minus_unfold:\n \"X_minus a = monomial (Nat_S Nat_O) one_r +P monomial Nat_O (opp_r a)\"\n by sorry\n\nlemma eval_C: \"eval (C c) x = c\"\n by sorry\n\nlemma eval_X: \"eval X x = x\"\n by sorry\n\nlemma deg_X_minus: \"degree (X_minus a) = Nat_S Nat_O\"\n by sorry\n\nlemma C_zero: \"C zero_r = zero_p\"\n by sorry\n\nlemma C_one: \"C one_r = one_p\"\n by sorry\n\nlemma deg_C: \"c \\ zero_r \\ degree (C c) = Nat_O\"\n by sorry\n\nlemma euclid_X_minus: \"\\q r. p = q *P X_minus a +P r \\ degree r = Nat_O\"\n by sorry\n\nlemma r_opp_add: \"opp_r x +R x = zero_r\"\n by sorry\n\nlemma r_add_zero_l: \"zero_r +R x = x\"\n by sorry\n\nlemma sub_eq_zero_l: \"x +R opp_r y = zero_r \\ x = y\"\n by sorry\n\nlemma eval_X_minus: \"eval (X_minus a) b = b +R opp_r a\"\n by sorry\n\nlemma X_minus_nonzero: \"X_minus a \\ zero_p\"\n by sorry\n\nlemma p_add_zero_l: \"zero_p +P x = x\"\n by sorry\n\nlemma p_mul_zero_l: \"zero_p *P x = zero_p\"\n by sorry\n\nlemma p_mul_one_l: \"one_p *P x = x\"\n by sorry\n\nlemma root_factor: \"is_root a p \\ \\q. p = q *P X_minus a\"\n by sorry\n\nlemma root_transfer:\n \"p = q *P X_minus a \\ b \\ a \\ is_root b p \\ is_root b q\"\n by sorry\n\nlemma roots_le_degree:\n \"NoDupL xs \\ (\\a. InL a xs \\ is_root a p) \\ p \\ zero_p \\\n mynat_le (lengthL xs) (degree p)\"\n by sorry\n\nlemma constant_root_zero:\n \"degree p = Nat_O \\ is_root a p \\ p = zero_p\"\n by sorry\n\nlemma root_of_product:\n \"is_root a (p *P q) \\ is_root a p \\ is_root a q\"\n by sorry\n\nlemma root_scale_constant:\n \"c \\ zero_r \\ (is_root a p \\ is_root a (C c *P p))\"\n by sorry\n\nlemma poly_of_roots_nonzero: \"poly_of_roots xs \\ zero_p\"\n by sorry\n\nlemma deg_poly_of_roots: \"degree (poly_of_roots xs) = lengthL xs\"\n by sorry\n\nlemma root_factor_list:\n \"NoDupL xs \\ (\\a. InL a xs \\ is_root a p) \\\n \\q. p = q *P poly_of_roots xs\"\n by sorry\n\nlemma degree_factorisation:\n \"p = q *P poly_of_roots xs \\ q \\ zero_p \\\n degree p = mynat_add (degree q) (lengthL xs)\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 12, "title": "polynomial", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "inductive mynat : Type\n| O : mynat\n| S : mynat → mynat\nderiving DecidableEq\n\nopen mynat\n\ndef mynat_add : mynat → mynat → mynat\n| O, m => m\n| (S n'), m => S (mynat_add n' m)\n\ntheorem mynat_add_O_left (m : mynat) :\n mynat_add O m = m := rfl\n\ntheorem mynat_add_S_left (n m : mynat) :\n mynat_add (S n) m = S (mynat_add n m) := rfl\n\ninductive mynat_le : mynat → mynat → Prop := by sorry\nopen mynat_le\n\ntheorem mynat_zero_le (n : mynat) : mynat_le O n := by sorry\ntheorem mynat_add_zero_r : ∀ n, mynat_add n O = n := by sorry\ntheorem mynat_succ_le_succ {n m : mynat} :\n mynat_le n m → mynat_le (S n) (S m) := by sorry\ntheorem mynat_add_S_r : ∀ m n, mynat_add m (S n) = S (mynat_add m n) := by sorry\ntheorem mynat_add_comm : ∀ n m, mynat_add n m = mynat_add m n := by sorry\nnamespace mylist\n\nnotation h \"::L\" t => mylist.consL h t\n\nend mylist\n\nopen mylist\n\n\ninductive InL {A : Type} (x : A) : mylist A → Prop\n| In_head : ∀ xs, InL x (x ::L xs)\n| In_tail : ∀ y xs, InL (x := x) xs → InL (x := x) (y ::L xs)\n\ninductive NoDupL {A : Type} : mylist A → Prop\n| ND_nil : NoDupL mylist.nilL\n| ND_cons : ∀ x xs, (¬ InL x xs) → NoDupL xs → NoDupL (x ::L xs)\n\ndef lengthL {A : Type} : mylist A → mynat\n| mylist.nilL => O\n| (_ ::L tl)=> S (lengthL tl)\n\nclass ring (R : Type) where\n (zero : R)\n (opp : R → R)\n (one : R)\n (add : R → R → R)\n (mul : R → R → R)\n\n (one_neq_zero : one ≠ zero)\n\n (add_comm : ∀ x y, add x y = add y x)\n (add_assoc : ∀ x y z, add (add x y) z = add x (add y z))\n (add_zero : ∀ x, add x zero = x)\n (add_opp : ∀ x, add x (opp x) = zero)\n\n (mul_comm : ∀ x y, mul x y = mul y x)\n (mul_assoc : ∀ x y z, mul (mul x y) z = mul x (mul y z))\n (mul_one : ∀ x, mul x one = x)\n (dist_l : ∀ x y z, mul x (add y z) = add (mul x y) (mul x z))\n (mul_zero : ∀ x, mul x zero = zero)\n\n (no_zero_div :\n ∀ x y, mul x y = zero → x = zero ∨ y = zero)\n\nnotation:35 \"-R \" x => ring.opp x\nsection Polynomial\n\nvariable {R : Type} [rR : ring R]\nvariable {polynomial : Type} [rP : ring polynomial]\n\n\nvariable (degree : polynomial → mynat)\nvariable (monomial : mynat → R → polynomial)\nvariable (eval : polynomial → R → R)\n\n\n\nlocal notation:55 x \" -R \" y => rR.add x (rR.opp y)\n\n\ndef X (monomial : mynat → R → polynomial) : polynomial :=\n monomial (S O) rR.one\n\ndef C (monomial : mynat → R → polynomial) (c : R) : polynomial :=\n monomial O c\n\ndef X_minus (monomial : mynat → R → polynomial) (a : R) : polynomial :=\n rP.add (X monomial) (C monomial (rR.opp a))\n\n\naxiom C_zero : C monomial rR.zero = rP.zero\naxiom C_one : C monomial rR.one = rP.one\n\naxiom deg_zero : degree rP.zero = O\n\naxiom eval_add : ∀ (p q : polynomial) (x : R), eval (rP.add p q) x = rR.add (eval p x) (eval q x)\naxiom eval_mul : ∀ (p q : polynomial) (x : R), eval (rP.mul p q) x = rR.mul (eval p x) (eval q x)\naxiom eval_C : ∀ (c : R) (x : R), eval (C monomial c) x = c\naxiom eval_X : ∀ (x : R), eval (X monomial) x = x\n\naxiom deg_C : ∀ (c : R), c ≠ rR.zero → degree (C monomial c) = O\naxiom deg_constant : ∀ (p : polynomial), degree p = O ↔ ∃ c : R, p = C monomial c\naxiom deg_X_minus : ∀ (a : R), degree (X_minus monomial a) = S O\naxiom deg_mul : ∀ (p q : polynomial), p ≠ rP.zero → q ≠ rP.zero →\n degree (rP.mul p q) = mynat_add (degree p) (degree q)\n\n\n\naxiom euclid_X_minus :\n ∀ p a, ∃ (q r' : polynomial),\n (p = rP.add (rP.mul q (X_minus monomial a)) r') ∧ (degree r' = O)\n\n\n\n\n\n\n\ntheorem sub_eq_zero_l : ∀ a b : R, rR.add a (rR.opp b) = rR.zero → a = b := by sorry\ndef is_root (eval : polynomial → R → R) (a : R) (p : polynomial) : Prop := eval p a = rR.zero\n\n\n\n\ntheorem root_factor\n (degree : polynomial → mynat)\n (monomial : mynat → R → polynomial)\n (eval : polynomial → R → R)\n (p : polynomial) (a : R) :\n is_root eval a p → ∃ q : polynomial, p = rP.mul q (X_minus monomial a)\n:= by sorry\ntheorem root_transfer\n (degree : polynomial → mynat)\n (monomial : mynat → R → polynomial)\n (eval : polynomial → R → R)\n (p q : polynomial) (a b : R) :\n p = rP.mul q (X_minus monomial a) →\n b ≠ a →\n is_root eval b p →\n is_root eval b q\n:= by sorry\ntheorem roots_le_degree\n (degree : polynomial → mynat)\n (monomial : mynat → R → polynomial)\n (eval : polynomial → R → R)\n (p : polynomial) (xs : mylist R) :\n NoDupL xs →\n (∀ a, InL a xs → is_root eval a p) →\n p ≠ rP.zero →\n mynat_le (lengthL xs) (degree p)\n:= by sorry\ndef poly_of_roots (monomial : mynat → R → polynomial) : mylist R → polynomial\n| mylist.nilL => rP.one\n| mylist.consL a xs => rP.mul (X_minus monomial a) (poly_of_roots monomial xs)\n\n\ntheorem X_minus_nonzero\n (degree : polynomial → mynat)\n (monomial : mynat → R → polynomial) :\n ∀ a, (X_minus monomial a) ≠ rP.zero := by sorry\ntheorem constant_root_zero\n (degree : polynomial → mynat)\n (monomial : mynat → R → polynomial)\n (eval : polynomial → R → R)\n (p : polynomial) (a : R) :\n degree p = O → is_root eval a p → p = rP.zero := by sorry\ntheorem root_of_product\n (eval : polynomial → R → R)\n (p q : polynomial) (a : R) :\n is_root eval a (rP.mul p q) → is_root eval a p ∨ is_root eval a q := by sorry\ntheorem root_scale_constant\n (monomial : mynat → R → polynomial)\n (eval : polynomial → R → R)\n (p : polynomial) (c a : R) :\n c ≠ rR.zero → (is_root eval a p ↔ is_root eval a (rP.mul (C monomial c) p)) := by sorry\ntheorem poly_of_roots_nonzero\n (degree : polynomial → mynat)\n (monomial : mynat → R → polynomial) :\n ∀ (xs : mylist R), poly_of_roots monomial xs ≠ rP.zero := by sorry\ntheorem deg_poly_of_roots\n (xs : mylist R) :\n degree (poly_of_roots monomial xs) = lengthL xs := by sorry\ntheorem root_factor_list\n (degree : polynomial → mynat)\n (monomial : mynat → R → polynomial)\n (eval : polynomial → R → R) :\n ∀ (p : polynomial) (xs : mylist R),\n NoDupL xs →\n (∀ a, InL a xs → is_root eval a p) →\n ∃ q, p = rP.mul q (poly_of_roots monomial xs)\n:= by sorry\ntheorem degree_factorisation :\n ∀ (p : polynomial) (xs : mylist R) (q : polynomial),\n p = rP.mul q (poly_of_roots monomial xs) →\n q ≠ rP.zero →\n degree p = mynat_add (degree q) (lengthL xs)\n:= by sorry\nend Polynomial\n" }, { "theorem_id": 12, "title": "polynomial", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Inductive mynat : Type :=\n| O : mynat\n| S : mynat -> mynat.\n\nFixpoint mynat_add (n m : mynat) : mynat :=\n match n with\n | O => m\n | S n' => S (mynat_add n' m)\n end.\n\nInductive mynat_le : mynat -> mynat -> Prop :=\n| le_n : forall n, mynat_le n n\n| le_S : forall n m, mynat_le n m -> mynat_le n (S m).\n\nLemma mynat_zero_le (n : mynat) : mynat_le O n.\nProof.\nAdmitted.\n\nLemma mynat_add_zero_r : forall n, mynat_add n O = n.\nProof.\nAdmitted.\n\nLemma mynat_succ_le_succ (n m : mynat) :\n mynat_le n m -> mynat_le (S n) (S m).\nProof.\nAdmitted.\n\nLemma mynat_add_S_r : forall m n,\n mynat_add m (S n) = S (mynat_add m n).\nProof.\nAdmitted.\n\nLemma mynat_add_comm : forall n m, mynat_add n m = mynat_add m n.\nProof.\nAdmitted.\n\nInductive mylist (A : Type) : Type :=\n| nilL : mylist A\n| consL : A -> mylist A -> mylist A.\n\nArguments nilL {A}.\nArguments consL {A} _ _.\nInfix \"::L\" := consL (at level 60, right associativity).\n\nInductive InL {A : Type} (x : A) : mylist A -> Prop :=\n| In_head : forall xs, InL x (x ::L xs)\n| In_tail : forall y xs, InL x xs -> InL x (y ::L xs).\n\nInductive NoDupL {A : Type} : mylist A -> Prop :=\n| ND_nil : NoDupL nilL\n| ND_cons : forall x xs, (~ InL x xs) -> NoDupL xs -> NoDupL (x ::L xs).\n\nFixpoint lengthL {A : Type} (xs : mylist A) : mynat :=\n match xs with\n | nilL => O\n | _ ::L tl => S (lengthL tl)\n end.\n\nClass ring (R : Type) := {\n zero : R;\n opp : R -> R;\n one : R;\n add : R -> R -> R;\n mul : R -> R -> R;\n\n one_neq_zero : one <> zero;\n\n add_comm : forall x y, add x y = add y x;\n add_assoc : forall x y z, add (add x y) z = add x (add y z);\n add_zero : forall x, add x zero = x;\n add_opp : forall x, add x (opp x) = zero;\n\n mul_comm : forall x y, mul x y = mul y x;\n mul_assoc : forall x y z, mul (mul x y) z = mul x (mul y z);\n mul_one : forall x, mul x one = x;\n dist_l : forall x y z, mul x (add y z) = add (mul x y) (mul x z);\n mul_zero : forall x, mul x zero = zero;\n \n no_zero_div :\n forall x y, mul x y = zero -> x = zero \\/ y = zero\n}.\n\nNotation \"x +R y\" := (add x y) (at level 50, left associativity).\nNotation \"-R x\" := (opp x) (at level 35).\nNotation \"x -R y\" := (add x (opp y)) (at level 55).\nNotation \"x *R y\" := (mul x y) (at level 40).\n\nSection Polynomial.\n Context {R : Type} `{ring R}.\n\n Context {polynomial : Type} `{ring polynomial}.\n\n Variable degree : polynomial -> mynat.\n Variable monomial : mynat -> R -> polynomial.\n\n Variable eval : polynomial -> R -> R.\n\n Definition X : polynomial := monomial (S O) one.\n Definition C (c:R) : polynomial := monomial O c.\n Definition X_minus (a:R) : polynomial := X +R C (-R a).\n\n Axiom C_zero : C zero = zero.\n Axiom C_one : C one = one.\n\n Axiom deg_zero : degree zero = O.\n\n Axiom eval_add : forall p q x, eval (p +R q) x = eval p x +R eval q x.\n Axiom eval_mul : forall p q x, eval (p *R q) x = eval p x *R eval q x.\n Axiom eval_C : forall c x, eval (C c) x = c.\n Axiom eval_X : forall x, eval X x = x.\n\n Axiom deg_C : forall c, c <> zero -> degree (C c) = O.\n Axiom deg_constant : forall p, degree p = O <-> exists c, p = C c.\n Axiom deg_X_minus : forall a, degree (X_minus a) = S O.\n Axiom deg_mul : forall p q,\n p <> zero -> q <> zero ->\n degree (p *R q) = mynat_add (degree p) (degree q).\n\n Axiom euclid_X_minus :\n forall p a, exists q r,\n p = q *R X_minus a +R r\n /\\ degree r = O.\n\n \n Lemma sub_eq_zero_l `{ring R} : forall a b, a -R b = zero -> a = b.\nProof.\nAdmitted.\n\n Lemma root_factor :\n forall p a, eval p a = zero ->\n exists q, p = q *R X_minus a.\nProof.\nAdmitted.\n\n Lemma root_transfer :\n forall p q a b,\n p = q *R X_minus a ->\n b <> a ->\n eval p b = zero ->\n eval q b = zero.\nProof.\nAdmitted.\n\n Definition root (a:R) (p:polynomial) : Prop := eval p a = zero.\n\n Theorem roots_le_degree :\n forall p (xs:mylist R),\n NoDupL xs ->\n (forall a, InL a xs -> root a p) ->\n p <> zero ->\n mynat_le (lengthL xs) (degree p).\nProof.\nAdmitted.\n\n Fixpoint poly_of_roots (xs : mylist R) : polynomial :=\n match xs with\n | nilL => one\n | consL a xs' => X_minus a *R poly_of_roots xs'\n end.\n\n Lemma X_minus_nonzero : forall a, X_minus a <> zero.\nProof.\nAdmitted.\n\n Lemma constant_root_zero :\n forall p a, degree p = O -> root a p -> p = zero.\nProof.\nAdmitted.\n\n Lemma root_of_product :\n forall p q a, root a (p *R q) -> root a p \\/ root a q.\nProof.\nAdmitted.\n\n Lemma root_scale_constant :\n forall p c a, c <> zero -> (root a p <-> root a (C c *R p)).\nProof.\nAdmitted.\n\n Lemma poly_of_roots_nonzero : forall xs, poly_of_roots xs <> zero.\nProof.\nAdmitted.\n\n Lemma deg_poly_of_roots :\n forall xs, degree (poly_of_roots xs) = lengthL xs.\nProof.\nAdmitted.\n\n\n Lemma root_factor_list :\n forall p xs,\n NoDupL xs ->\n (forall a, InL a xs -> root a p) ->\n exists q, p = q *R poly_of_roots xs.\nProof.\nAdmitted.\n\n Lemma degree_factorisation :\n forall p xs q,\n p = q *R poly_of_roots xs ->\n q <> zero ->\n degree p = mynat_add (degree q) (lengthL xs).\nProof.\nAdmitted.\n\nEnd Polynomial.\n" }, { "theorem_id": 13, "title": "probability", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "new_type (\"R\",0);;\nnew_type (\"W\",0);;\n\nlet subR = new_definition\n `subR (addR:R->R->R) (oppR:R->R) (x:R) (y:R) = addR x (oppR y)`;;\n\nlet ev_false = new_definition\n `ev_false:W->bool = (\\w. F)`;;\n\nlet ev_true = new_definition\n `ev_true:W->bool = (\\w. T)`;;\n\nlet ev_inter = new_definition\n `ev_inter (A:W->bool) (B:W->bool) = (\\w. A w /\\ B w)`;;\n\nlet ev_union = new_definition\n `ev_union (A:W->bool) (B:W->bool) = (\\w. A w \\/ B w)`;;\n\nlet ev_compl = new_definition\n `ev_compl (A:W->bool) = (\\w. ~(A w))`;;\n\nlet ev_diff = new_definition\n `ev_diff (A:W->bool) (B:W->bool) = (\\w. A w /\\ ~(B w))`;;\n\nlet disjoint = new_definition\n `disjoint (A:W->bool) (B:W->bool) <=> !w. ~(ev_inter A B w)`;;\n\nlet pairwise_disjoint = new_recursive_definition list_RECURSION\n `pairwise_disjoint ([]:(W->bool)list) = T /\\\n pairwise_disjoint (CONS (A:W->bool) xs) =\n ((!B. MEM B xs ==> disjoint A B) /\\ pairwise_disjoint xs)`;;\n\nlet bigUnion = new_recursive_definition list_RECURSION\n `bigUnion ([]:(W->bool)list) = ev_false /\\\n bigUnion (CONS (A:W->bool) xs) = ev_union A (bigUnion xs)`;;\n\nlet fold_add = new_recursive_definition list_RECURSION\n `fold_add (addR:R->R->R) (zeroR:R) ([]:R list) = zeroR /\\\n fold_add addR zeroR (CONS x xs) = addR x (fold_add addR zeroR xs)`;;\n\nlet indep = new_definition\n `indep (prob:(W->bool)->R) (mulR:R->R->R) (A:W->bool) (B:W->bool) <=>\n prob (ev_inter A B) = mulR (prob A) (prob B)`;;\n\nnew_constant\n (\"is_prob_context\",\n `:R->R->(R->R->R)->(R->R->R)->(R->R)->((W->bool)->R)->((W->bool)->(W->bool)->R)->bool`);;\n\nlet is_prob_context = new_axiom\n `!zeroR oneR addR mulR oppR prob cprob.\n is_prob_context zeroR oneR addR mulR oppR prob cprob <=>\n ~(oneR = zeroR) /\\\n\t (!x y. addR x y = addR y x) /\\\n\t (!x y z. addR (addR x y) z = addR x (addR y z)) /\\\n\t (!x y z. addR x z = addR y z ==> x = y) /\\\n\t (!x. addR x zeroR = x) /\\\n\t (!x. addR zeroR x = x) /\\\n\t (!x. addR x (oppR x) = zeroR) /\\\n\t (!x. addR (oppR x) x = zeroR) /\\\n (!x y. mulR x y = mulR y x) /\\\n (!x y z. mulR (mulR x y) z = mulR x (mulR y z)) /\\\n (!x. mulR x oneR = x) /\\\n (!x. mulR oneR x = x) /\\\n (!x y z. mulR x (addR y z) = addR (mulR x y) (mulR x z)) /\\\n (!x. mulR x zeroR = zeroR) /\\\n (!x. mulR zeroR x = zeroR) /\\\n (!x y. mulR x y = zeroR ==> x = zeroR \\/ y = zeroR) /\\\n (!A B. (!w. A w <=> B w) ==> prob A = prob B) /\\\n (prob ev_false = zeroR) /\\\n (prob ev_true = oneR) /\\\n (!A B. prob (ev_union A B) =\n addR (prob A) (addR (prob B) (oppR (prob (ev_inter A B))))) /\\\n (!A. prob (ev_compl A) = addR oneR (oppR (prob A))) /\\\n (!A B. prob (ev_inter A B) = mulR (cprob A B) (prob B)) /\\\n (oppR zeroR = zeroR) /\\\n (!x. oppR (oppR x) = x) /\\\n (!x y. mulR x (oppR y) = oppR (mulR x y)) /\\\n (!x y. mulR (oppR x) y = oppR (mulR x y)) /\\\n (!A B. disjoint A B ==> prob (ev_union A B) = addR (prob A) (prob B)) /\\\n (!A xs. pairwise_disjoint (CONS A xs) ==> disjoint A (bigUnion xs))`;;\n\nlet INTRO_PROB_HYPS =\n REWRITE_TAC[is_prob_context] THEN REPEAT GEN_TAC THEN\n DISCH_THEN STRIP_ASSUME_TAC;;\n\nlet ASSUM_MATCH_TAC pat ttac =\n ASSUM_LIST\n (fun asms ->\n let th =\n find\n (fun th ->\n try\n let (_,tinst,_) = term_match [] pat (concl th) in\n forall (fun (v,t) -> t = v) tinst\n with Failure _ -> false)\n asms in\n ttac th);;\n\nlet FUN_CONG = `!f:A->B x y. x = y ==> f x = f y`;;\n\nlet add_right_cancel = `!zeroR oneR addR mulR oppR prob cprob (x:R) (y:R) (z:R).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> addR x z = addR y z ==> x = y`;;\n\nlet prob_union_comm = `!zeroR oneR addR mulR oppR prob cprob (A:W->bool) (B:W->bool).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> prob (ev_union A B) = prob (ev_union B A)`;;\n\nlet prob_union_idem = `!zeroR oneR addR mulR oppR prob cprob (A:W->bool).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> prob (ev_union A A) = prob A`;;\n\nlet prob_diff = new_axiom\n (`!zeroR oneR addR mulR oppR prob cprob (A:W->bool) (B:W->bool).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> prob (ev_diff A B) =\n subR addR oppR (prob A) (prob (ev_inter A B))`);;\n\nlet bayes_symm = new_axiom\n (`!zeroR oneR addR mulR oppR prob cprob (A:W->bool) (B:W->bool).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> mulR (cprob A B) (prob B) = mulR (cprob B A) (prob A)`);;\n\nlet law_total_prob = new_axiom\n (`!zeroR oneR addR mulR oppR prob cprob (A:W->bool) (B:W->bool).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> prob A =\n addR (mulR (cprob A B) (prob B))\n (mulR (cprob A (ev_compl B)) (prob (ev_compl B)))`);;\n\nlet prob_union_indep = new_axiom\n (`!zeroR oneR addR mulR oppR prob cprob (A:W->bool) (B:W->bool).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> indep prob mulR A B\n ==> prob (ev_union A B) =\n addR (prob A) (addR (prob B) (oppR (mulR (prob A) (prob B))))`);;\n\nlet indep_compl_right = new_axiom\n (`!zeroR oneR addR mulR oppR prob cprob (A:W->bool) (B:W->bool).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> indep prob mulR A B\n ==> indep prob mulR A (ev_compl B)`);;\n\nlet indep_symm = new_axiom\n (`!zeroR oneR addR mulR oppR prob cprob (A:W->bool) (B:W->bool).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> indep prob mulR A B ==> indep prob mulR B A`);;\n\nlet indep_compl_left = new_axiom\n (`!zeroR oneR addR mulR oppR prob cprob (A:W->bool) (B:W->bool).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> indep prob mulR A B ==> indep prob mulR (ev_compl A) B`);;\n\nlet prob_bigUnion_disjoint = new_axiom\n (`!zeroR oneR addR mulR oppR prob cprob (xs:(W->bool) list).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> pairwise_disjoint xs\n ==> prob (bigUnion xs) = fold_add addR zeroR (MAP prob xs)`);;\n\nlet prob_bigUnion_disjoint_zero = new_axiom\n (`!zeroR oneR addR mulR oppR prob cprob (xs:(W->bool) list).\n is_prob_context zeroR oneR addR mulR oppR prob cprob\n ==> pairwise_disjoint xs\n ==> (!A. MEM A xs ==> prob A = zeroR)\n ==> prob (bigUnion xs) = zeroR`);;" }, { "theorem_id": 13, "title": "probability", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory probability\n imports Main\nbegin\n\nsection \"Lists\"\n\ndatatype 'a mylist = NilL | ConsL 'a \"'a mylist\"\n\nprimrec mapL :: \"('a \\ 'b) \\ 'a mylist \\ 'b mylist\" where\n \"mapL f NilL = NilL\"\n| \"mapL f (ConsL x xs) = ConsL (f x) (mapL f xs)\"\n\nprimrec fold_addL :: \"('a \\ 'a \\ 'a) \\ 'a \\ 'a mylist \\ 'a\" where\n \"fold_addL add z NilL = z\"\n| \"fold_addL add z (ConsL x xs) = add x (fold_addL add z xs)\"\n\ninductive InL :: \"'a \\ 'a mylist \\ bool\" where\n In_head : \"InL x (ConsL x xs)\"\n| In_tail : \"InL x xs \\ InL x (ConsL y xs)\"\n\ninductive NoDupL :: \"'a mylist \\ bool\" where\n ND_nil : \"NoDupL NilL\"\n| ND_cons : \"\\\\ InL x xs; NoDupL xs\\ \\ NoDupL (ConsL x xs)\"\n\nsection \"Event algebra\"\n\ntype_synonym 'a event = \"'a \\ bool\"\n\ndefinition ev_false :: \"'a event\" where \"ev_false \\ \\_. False\"\ndefinition ev_true :: \"'a event\" where \"ev_true \\ \\_. True\"\ndefinition ev_inter :: \"'a event \\ 'a event \\ 'a event\"\n where \"ev_inter A B \\ \\\\. A \\ \\ B \\\"\ndefinition ev_union :: \"'a event \\ 'a event \\ 'a event\"\n where \"ev_union A B \\ \\\\. A \\ \\ B \\\"\ndefinition ev_compl :: \"'a event \\ 'a event\"\n where \"ev_compl A \\ \\\\. \\ A \\\"\ndefinition ev_diff :: \"'a event \\ 'a event \\ 'a event\"\n where \"ev_diff A B \\ \\\\. A \\ \\ \\ B \\\"\n\ndefinition disjoint :: \"'a event \\ 'a event \\ bool\"\n where \"disjoint A B \\ \\\\. \\ (A \\ \\ B \\)\"\n\nfun pairwise_disjoint :: \"('a event) mylist \\ bool\" where\n \"pairwise_disjoint NilL = True\"\n| \"pairwise_disjoint (ConsL _ NilL) = True\"\n| \"pairwise_disjoint (ConsL A (ConsL B xs)) =\n (disjoint A B \\\n (\\C. InL C (ConsL B xs) \\ disjoint A C) \\\n pairwise_disjoint (ConsL B xs))\"\n\nprimrec bigUnion :: \"('a event) mylist \\ 'a event\" where\n \"bigUnion NilL = ev_false\"\n| \"bigUnion (ConsL A xs) = ev_union A (bigUnion xs)\"\n\nlemma ev_inter_comm:\n \"\\\\. ev_inter A B \\ \\ ev_inter B A \\\"\n by sorry\n\nlemma ev_union_comm:\n \"\\\\. ev_union A B \\ \\ ev_union B A \\\"\n by sorry\n\nlemma ev_inter_assoc:\n \"\\\\. ev_inter (ev_inter A B) C \\ \\ ev_inter A (ev_inter B C) \\\"\n by sorry\n\nlemma ev_union_assoc:\n \"\\\\. ev_union (ev_union A B) C \\ \\ ev_union A (ev_union B C) \\\"\n by sorry\n\nlemma ev_inter_distrib_left:\n \"\\\\. ev_inter A (ev_union B C) \\ \\ ev_union (ev_inter A B) (ev_inter A C) \\\"\n by sorry\n\nlemma disjoint_bigUnion:\n \"(\\C. InL C xs \\ disjoint A C) \\ disjoint A (bigUnion xs)\"\n by sorry\n\nsection \"Probability\"\n\nlocale probability_setup =\n fixes zero one :: \"'r\"\n and add :: \"'r \\ 'r \\ 'r\" (infixl \"+R\" 65)\n and opp :: \"'r \\ 'r\"\n and mul :: \"'r \\ 'r \\ 'r\" (infixl \"*R\" 70)\n and prob :: \"('a \\ bool) \\ 'r\"\n and cprob :: \"('a \\ bool) \\ ('a \\ bool) \\ 'r\"\n \n assumes\n add_comm : \"\\x y. x +R y = y +R x\"\n and add_assoc : \"\\x y z. (x +R y) +R z = x +R (y +R z)\"\n and add_zero : \"\\x. x +R zero = x\"\n and add_opp : \"\\x. x +R opp x = zero\"\n and mul_comm : \"\\x y. x *R y = y *R x\"\n and mul_assoc : \"\\x y z. (x *R y) *R z = x *R (y *R z)\"\n and mul_one : \"\\x. x *R one = x\"\n and dist_l : \"\\x y z. x *R (y +R z) = (x *R y) +R (x *R z)\"\n and mul_zero : \"\\x. x *R zero = zero\"\n and opp_zero : \"opp zero = zero\"\n and opp_opp : \"\\x. opp (opp x) = x\"\n and opp_mul_right : \"\\x y. x *R opp y = opp (x *R y)\"\n and opp_mul_left : \"\\x y. opp x *R y = opp (x *R y)\"\n \n and prob_ext : \"\\A B. (\\\\. A \\ \\ B \\) \\ prob A = prob B\"\n and prob_false_ax : \"prob ev_false = zero\"\n and prob_true_ax : \"prob ev_true = one\"\n and prob_union_ax :\n \"\\A B. prob (ev_union A B) =\n prob A +R (prob B +R opp (prob (ev_inter A B)))\"\n and prob_compl_ax : \"\\A. prob (ev_compl A) = one +R opp (prob A)\"\n and cprob_mul : \"\\A B. prob (ev_inter A B) = cprob A B *R prob B\"\n and prob_union_disjoint :\n \"\\A B. disjoint A B \\\n prob (ev_union A B) = prob A +R prob B\"\n and disjoint_head_tail :\n \"\\A xs. pairwise_disjoint (ConsL A xs) \\\n disjoint A (bigUnion xs)\"\n and indep_compl_both_ax :\n \"\\A B. prob (ev_inter A B) = prob A *R prob B \\\n prob (ev_inter (ev_compl A) (ev_compl B)) =\n prob (ev_compl A) *R prob (ev_compl B)\"\n and inclusion_exclusion_three :\n \"\\A B C.\n prob (ev_union (ev_union A B) C) =\n prob A +R (prob B +R (prob C +R\n opp (prob (ev_inter A B) +R\n (prob (ev_inter A C) +R\n (prob (ev_inter B C) +R\n opp (prob (ev_inter (ev_inter A B) C)))))))\"\nbegin\n\nlemma zero_add: \"zero +R x = x\"\n by sorry\n\nlemma add_opp_comm: \"opp x +R x = zero\"\n by sorry\n\nlemma sub_of_eq: \"a = b +R c \\ c = a +R opp b\"\n by sorry\n\ndefinition indep :: \"('a \\ bool) \\ ('a \\ bool) \\ bool\"\n where \"indep A B \\ prob (ev_inter A B) = prob A *R prob B\"\n\nlemma prob_union_comm:\n \"prob (ev_union A B) = prob (ev_union B A)\"\n by sorry\n\nlemma prob_union_idem:\n \"prob (ev_union A A) = prob A\"\n by sorry\n\nlemma prob_diff:\n \"prob (ev_diff A B) = prob A +R opp (prob (ev_inter A B))\"\n by sorry\n\nlemma bayes_symm:\n \"cprob A B *R prob B = cprob B A *R prob A\"\n by sorry\n\nlemma law_total_prob:\n \"prob A =\n cprob A B *R prob B +R cprob A (ev_compl B) *R prob (ev_compl B)\"\n by sorry\n\nlemma prob_union_indep:\n \"indep A B \\\n prob (ev_union A B) =\n prob A +R (prob B +R opp (prob A *R prob B))\"\n by sorry\n\nlemma indep_symm: \"indep A B \\ indep B A\"\n by sorry\n\nlemma indep_compl_right: \"indep A B \\ indep A (ev_compl B)\"\n by sorry\n\nlemma indep_compl_left: \"indep A B \\ indep (ev_compl A) B\"\n by sorry\n\nlemma indep_compl_both: \"indep A B \\ indep (ev_compl A) (ev_compl B)\"\n by sorry\n\nlemma prob_bigUnion_disjoint:\n \"pairwise_disjoint xs \\\n prob (bigUnion xs) = fold_addL (+R) zero (mapL prob xs)\"\n by sorry\n\nlemma prob_bigUnion_disjoint_zero:\n \"pairwise_disjoint xs \\\n (\\A. InL A xs \\ prob A = zero) \\\n prob (bigUnion xs) = zero\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 13, "title": "probability", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "inductive mynat : Type\n| O : mynat\n| S : mynat → mynat\nderiving DecidableEq\n\nopen mynat\n\ndef mynat_add : mynat → mynat → mynat\n| O, m => m\n| (S n'), m => S (mynat_add n' m)\n\ntheorem mynat_add_O_left (m : mynat) :\n mynat_add O m = m := rfl\n\ntheorem mynat_add_S_left (n m : mynat) :\n mynat_add (S n) m = S (mynat_add n m) := rfl\n\ninductive mylist (A : Type) : Type := by sorry\nnamespace mylist\n\nnotation h \"::L\" t => mylist.consL h t\n\ndef mapL {A B : Type} (f : A → B) : mylist A → mylist B\n| mylist.nilL => mylist.nilL\n| (x ::L xs) => f x ::L mapL f xs\n\ndef fold_add {R : Type} (add : R → R → R) (z : R) : mylist R → R\n| mylist.nilL => z\n| (x ::L xs) => add x (fold_add add z xs)\n\nend mylist\n\nopen mylist\n\ninductive InL {A : Type} (x : A) : mylist A → Prop\n| In_head : ∀ xs, InL x (x ::L xs)\n| In_tail : ∀ y xs, InL (x := x) xs → InL (x := x) (y ::L xs)\n\ninductive NoDupL {A : Type} : mylist A → Prop\n| ND_nil : NoDupL mylist.nilL\n| ND_cons : ∀ x xs, (¬ InL x xs) → NoDupL xs → NoDupL (x ::L xs)\n\nclass ring (R : Type) where\n (zero : R)\n (opp : R → R)\n (one : R)\n (add : R → R → R)\n (mul : R → R → R)\n\n (one_neq_zero : one ≠ zero)\n\n (add_comm : ∀ x y, add x y = add y x)\n (add_assoc : ∀ x y z, add (add x y) z = add x (add y z))\n (add_zero : ∀ x, add x zero = x)\n (add_opp : ∀ x, add x (opp x) = zero)\n\n (mul_comm : ∀ x y, mul x y = mul y x)\n (mul_assoc : ∀ x y z, mul (mul x y) z = mul x (mul y z))\n (mul_one : ∀ x, mul x one = x)\n (dist_l : ∀ x y z, mul x (add y z) = add (mul x y) (mul x z))\n (mul_zero : ∀ x, mul x zero = zero)\n\n (no_zero_div :\n ∀ x y, mul x y = zero → x = zero ∨ y = zero)\n\nnotation:35 \"-R \" x => ring.opp x\n\nsection Probability\n\nvariable {R : Type} [rR : ring R]\nvariable {Ω : Type}\n\ndef event (Ω : Type) := Ω → Prop\n\ndef ev_false : event Ω := fun _ => False\ndef ev_true : event Ω := fun _ => True\n\ndef ev_inter (A B : event Ω) : event Ω := fun ω => A ω ∧ B ω\ndef ev_union (A B : event Ω) : event Ω := fun ω => A ω ∨ B ω\ndef ev_compl (A : event Ω) : event Ω := fun ω => ¬ A ω\ndef ev_diff (A B : event Ω) : event Ω := fun ω => A ω ∧ ¬ B ω\n\ntheorem ev_inter_comm (A B : event Ω) : ∀ ω, (ev_inter A B) ω ↔ (ev_inter B A) ω := by sorry\ntheorem ev_union_comm (A B : event Ω) : ∀ ω, (ev_union A B) ω ↔ (ev_union B A) ω := by sorry\ntheorem ev_inter_assoc (A B C : event Ω) : ∀ ω,\n (ev_inter (ev_inter A B) C) ω ↔ (ev_inter A (ev_inter B C)) ω := by sorry\ntheorem ev_union_assoc (A B C : event Ω) : ∀ ω,\n (ev_union (ev_union A B) C) ω ↔ (ev_union A (ev_union B C)) ω := by sorry\ntheorem ev_inter_distrib_left (A B C : event Ω) : ∀ ω,\n (ev_inter A (ev_union B C)) ω ↔ (ev_union (ev_inter A B) (ev_inter A C)) ω := by sorry\ndef disjoint (A B : event Ω) : Prop := ∀ ω, ¬ ((ev_inter A B) ω)\n\ndef pairwise_disjoint : mylist (event Ω) → Prop\n| mylist.nilL => True\n| (_ ::L mylist.nilL) => True\n| (A ::L (B ::L xs)) => disjoint A B ∧ (∀ C, InL C (B ::L xs) → disjoint A C) ∧ pairwise_disjoint (B ::L xs)\n\ndef bigUnion : mylist (event Ω) → event Ω\n| mylist.nilL => ev_false\n| (A ::L xs) => ev_union A (bigUnion xs)\n\nvariable (prob : event Ω → R)\n\naxiom prob_ext : ∀ {A B : event Ω}, (∀ ω, A ω ↔ B ω) → prob A = prob B\naxiom prob_false : prob ev_false = rR.zero\naxiom prob_true : prob ev_true = rR.one\n\naxiom prob_union : ∀ (A B : event Ω),\n prob (ev_union A B) = rR.add (prob A) (rR.add (prob B) (rR.opp (prob (ev_inter A B))))\n\naxiom prob_compl : ∀ (A : event Ω), prob (ev_compl A) = rR.add rR.one (rR.opp (prob A))\n\naxiom em : ∀ p : Prop, p ∨ ¬ p\n\naxiom cprob : event Ω → event Ω → R\naxiom cprob_mul : ∀ A B, prob (ev_inter A B) = rR.mul (cprob A B) (prob B)\n\ndef indep (A B : event Ω) : Prop := prob (ev_inter A B) = rR.mul (prob A) (prob B)\n\nlocal notation:55 x \" -R \" y => rR.add x (rR.opp y)\n\naxiom opp_zero : rR.opp rR.zero = rR.zero\naxiom opp_opp : ∀ x, rR.opp (rR.opp x) = x\naxiom opp_mul_right : ∀ x y, rR.mul x (rR.opp y) = rR.opp (rR.mul x y)\naxiom opp_mul_left : ∀ x y, rR.mul (rR.opp x) y = rR.opp (rR.mul x y)\n\naxiom prob_union_disjoint : ∀ (A B : event Ω), disjoint A B → prob (ev_union A B) = rR.add (prob A) (prob B)\naxiom disjoint_head_tail : ∀ (A : event Ω) (xs : mylist (event Ω)), pairwise_disjoint (A ::L xs) → disjoint A (bigUnion xs)\n\ntheorem prob_union_comm (A B : event Ω) :\n prob (ev_union A B) = prob (ev_union B A) := by sorry\ntheorem prob_union_idem (A : event Ω) :\n prob (ev_union A A) = prob A := by sorry\ntheorem prob_diff (A B : event Ω) :\n prob (ev_diff A B) = prob A -R prob (ev_inter A B) := by sorry\ntheorem bayes_symm (A B : event Ω) :\n rR.mul (cprob A B) (prob B) = rR.mul (cprob B A) (prob A) := by sorry\ntheorem law_total_prob (A B : event Ω) :\n prob A = rR.add (rR.mul (cprob A B) (prob B)) (rR.mul (cprob A (ev_compl B)) (prob (ev_compl B))) := by sorry\ntheorem prob_union_indep (A B : event Ω) :\n indep (prob := prob) A B →\n prob (ev_union A B) = rR.add (prob A) (rR.add (prob B) (rR.opp (rR.mul (prob A) (prob B)))) := by sorry\ntheorem indep_compl_right (A B : event Ω) :\n indep (prob := prob) A B → indep (prob := prob) A (ev_compl B) := by sorry\ntheorem indep_symm (A B : event Ω) :\n indep (prob := prob) A B → indep (prob := prob) B A := by sorry\ntheorem indep_compl_left (A B : event Ω) :\n indep (prob := prob) A B → indep (prob := prob) (ev_compl A) B := by sorry\naxiom indep_compl_both (A B : event Ω) :\n indep (prob := prob) A B → indep (prob := prob) (ev_compl A) (ev_compl B)\n\ntheorem prob_bigUnion_disjoint\n (xs : mylist (event Ω))\n (hp : pairwise_disjoint xs) :\n prob (bigUnion xs)\n = mylist.fold_add rR.add rR.zero (mylist.mapL prob xs) := by sorry\ntheorem prob_bigUnion_disjoint_zero\n (xs : mylist (event Ω))\n (hp : pairwise_disjoint xs)\n (hzero : ∀ A, InL A xs → prob A = rR.zero) :\n prob (bigUnion xs) = rR.zero := by sorry\naxiom inclusion_exclusion_three (A B C : event Ω) :\n prob (ev_union (ev_union A B) C)\n = rR.add (prob A)\n (rR.add (prob B)\n (rR.add (prob C)\n (rR.opp (rR.add (prob (ev_inter A B))\n (rR.add (prob (ev_inter A C))\n (rR.add (prob (ev_inter B C))\n (rR.opp (prob (ev_inter (ev_inter A B) C)))))))))\n\nend Probability\n" }, { "theorem_id": 13, "title": "probability", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Inductive mynat : Type :=\n| O : mynat\n| S : mynat -> mynat.\n\nInductive mylist (A : Type) : Type :=\n| nilL : mylist A\n| consL : A -> mylist A -> mylist A.\n\nArguments nilL {A}.\nArguments consL {A} _ _.\nInfix \"::L\" := consL (at level 60, right associativity).\n\nInductive InL {A : Type} (x : A) : mylist A -> Prop :=\n| In_head : forall xs, InL x (x ::L xs)\n| In_tail : forall y xs, InL x xs -> InL x (y ::L xs).\n\nInductive NoDupL {A : Type} : mylist A -> Prop :=\n| ND_nil : NoDupL nilL\n| ND_cons : forall x xs, (~ InL x xs) -> NoDupL xs -> NoDupL (x ::L xs).\n\nFixpoint mapL {A B} (f : A -> B) (xs : mylist A) : mylist B :=\n match xs with\n | nilL => nilL\n | consL x xs => consL (f x) (mapL f xs)\n end.\n\nClass ring (R : Type) := {\n zero : R;\n opp : R -> R;\n one : R;\n add : R -> R -> R;\n mul : R -> R -> R;\n\n one_neq_zero : one <> zero;\n\n add_comm : forall x y, add x y = add y x;\n add_assoc : forall x y z, add (add x y) z = add x (add y z);\n add_zero : forall x, add x zero = x;\n add_opp : forall x, add x (opp x) = zero;\n\n mul_comm : forall x y, mul x y = mul y x;\n mul_assoc : forall x y z, mul (mul x y) z = mul x (mul y z);\n mul_one : forall x, mul x one = x;\n dist_l : forall x y z, mul x (add y z) = add (mul x y) (mul x z);\n mul_zero : forall x, mul x zero = zero;\n\n no_zero_div : forall x y, mul x y = zero -> x = zero \\/ y = zero\n}.\n\nNotation \"x +R y\" := (add x y) (at level 50, left associativity).\nNotation \"-R x\" := (opp x) (at level 35).\nNotation \"x -R y\" := (add x (opp y)) (at level 55).\nNotation \"x *R y\" := (mul x y) (at level 40).\n\nSection Probability.\n Context {R : Type} `{ring R}.\n Variable Omega : Type.\n\n Definition event := Omega -> Prop.\n Definition ev_false : event := fun _ => False.\n Definition ev_true : event := fun _ => True.\n Definition ev_inter (A B : event) : event := fun w => A w /\\ B w.\n Definition ev_union (A B : event) : event := fun w => A w \\/ B w.\n Definition ev_compl (A : event) : event := fun w => ~ A w.\n Definition ev_diff (A B : event) : event := fun w => A w /\\ ~ B w.\n\n Definition disjoint (A B : event) : Prop := forall w, ~ (A w /\\ B w).\n\n Inductive pairwise_disjoint : mylist event -> Prop :=\n | pd_nil : pairwise_disjoint nilL\n | pd_one : forall A, pairwise_disjoint (A ::L nilL)\n | pd_cons : forall A B xs,\n disjoint A B -> (forall C, InL C (B ::L xs) -> disjoint A C) ->\n pairwise_disjoint (B ::L xs) ->\n pairwise_disjoint (A ::L B ::L xs).\n\n Fixpoint bigUnion (xs : mylist event) : event :=\n match xs with\n | nilL => ev_false\n | consL A xs' => ev_union A (bigUnion xs')\n end.\n\n Variable prob : event -> R.\n\n Axiom prob_ext : forall A B, (forall w, A w <-> B w) -> prob A = prob B.\n Axiom prob_false : prob ev_false = zero.\n Axiom prob_true : prob ev_true = one.\n Axiom prob_union : forall A B,\n prob (ev_union A B) = prob A +R (prob B +R -R (prob (ev_inter A B))).\n Axiom prob_compl : forall A, prob (ev_compl A) = one +R -R (prob A).\n\n Axiom classic : forall P:Prop, P \\/ ~ P.\n\n Variable cprob : event -> event -> R.\n Axiom cprob_mul : forall A B, prob (ev_inter A B) = cprob A B *R prob B.\n\n Definition indep (A B : event) : Prop :=\n prob (ev_inter A B) = prob A *R prob B.\n\n\n Axiom opp_zero : opp zero = zero.\n Axiom opp_opp : forall x, opp (opp x) = x.\n Axiom opp_mul_right : forall x y, x *R (opp y) = opp (x *R y).\n Axiom opp_mul_left : forall x y, (opp x) *R y = opp (x *R y).\n\n Axiom prob_union_disjoint : forall A B, disjoint A B -> prob (ev_union A B) = prob A +R prob B.\n Axiom disjoint_head_tail : forall A xs, pairwise_disjoint (A ::L xs) -> disjoint A (bigUnion xs).\n\n Lemma prob_union_comm A B :\n prob (ev_union A B) = prob (ev_union B A).\nProof.\nAdmitted.\n\n Lemma prob_union_idem A : prob (ev_union A A) = prob A.\nProof.\nAdmitted.\n\n Lemma prob_diff A B : prob (ev_diff A B) = prob A -R prob (ev_inter A B).\nProof.\nAdmitted.\n\n Lemma bayes_symm A B : cprob A B *R prob B = cprob B A *R prob A.\nProof.\nAdmitted.\n\n Lemma law_total_prob A B :\n prob A = cprob A B *R prob B +R cprob A (ev_compl B) *R prob (ev_compl B).\nProof.\nAdmitted.\n\n Lemma prob_union_indep A B : indep A B ->\n prob (ev_union A B) = prob A +R (prob B +R -R (prob A *R prob B)).\nProof.\nAdmitted.\n\n Lemma indep_symm A B : indep A B -> indep B A.\nProof.\nAdmitted.\n\n Lemma indep_compl_right A B : indep A B -> indep A (ev_compl B).\nProof.\nAdmitted.\n\n Lemma indep_compl_left A B : indep A B -> indep (ev_compl A) B.\nProof.\nAdmitted.\n\n Axiom indep_compl_both : forall A B, indep A B -> indep (ev_compl A) (ev_compl B).\n\n Fixpoint fold_add (xs : mylist R) : R :=\n match xs with\n | nilL => zero\n | consL x xs' => x +R fold_add xs'\n end.\n\n Lemma prob_bigUnion_disjoint : forall xs,\n pairwise_disjoint xs -> prob (bigUnion xs) = fold_add (mapL prob xs).\nProof.\nAdmitted.\n\n Lemma prob_bigUnion_disjoint_zero : forall xs,\n pairwise_disjoint xs -> (forall A, InL A xs -> prob A = zero) -> prob (bigUnion xs) = zero.\nProof.\nAdmitted.\n\n Axiom inclusion_exclusion_three : forall A B C,\n prob (ev_union (ev_union A B) C)\n = prob A +R (prob B +R (prob C +R -R (prob (ev_inter A B) +R (prob (ev_inter A C) +R (prob (ev_inter B C) +R -R (prob (ev_inter (ev_inter A B) C))))))).\n\nEnd Probability.\n" }, { "theorem_id": 14, "title": "set_algebra", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let sUnion = new_definition\n `sUnion (A:'a->bool) (B:'a->bool) = \\x. A x \\/ B x`;;\n\nlet sInter = new_definition\n `sInter (A:'a->bool) (B:'a->bool) = \\x. A x /\\ B x`;;\n\nlet sCompl = new_definition\n `sCompl (A:'a->bool) = \\x. ~A x`;;\n\nlet inter_distrib_left = `!A B C x. sInter A (sUnion B C) x <=> sUnion (sInter A B) (sInter A C) x`;;\n\nlet inter_distrib_right = `!A B C x. sInter (sUnion A B) C x <=> sUnion (sInter A C) (sInter B C) x`;;\n\nlet de_morgan_union = `!A B x. sCompl (sUnion A B) x <=> sInter (sCompl A) (sCompl B) x`;;\n\nlet de_morgan_inter = `!A B x. sCompl (sInter A B) x <=> sUnion (sCompl A) (sCompl B) x`;;" }, { "theorem_id": 14, "title": "set_algebra", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory set_algebra\n imports Main\nbegin\n\nsection \"SetAlgebra\"\n\ndefinition sUnion :: \"('a \\ bool) \\ ('a \\ bool) \\ ('a \\ bool)\"\n where \"sUnion A B \\ \\x. A x \\ B x\"\n\ndefinition sInter :: \"('a \\ bool) \\ ('a \\ bool) \\ ('a \\ bool)\"\n where \"sInter A B \\ \\x. A x \\ B x\"\n\ndefinition sCompl :: \"('a \\ bool) \\ ('a \\ bool)\"\n where \"sCompl A \\ \\x. \\ A x\"\n\nlemma inter_distrib_left:\n \"\\x. sInter A (sUnion B C) x \\ sUnion (sInter A B) (sInter A C) x\"\n by sorry\n\nlemma inter_distrib_right:\n \"\\x. sInter (sUnion A B) C x \\ sUnion (sInter A C) (sInter B C) x\"\n by sorry\n\nlemma de_morgan_union:\n \"\\x. sCompl (sUnion A B) x \\ sInter (sCompl A) (sCompl B) x\"\n by sorry\n\nlemma de_morgan_inter:\n \"\\x. sCompl (sInter A B) x \\ sUnion (sCompl A) (sCompl B) x\"\n by sorry\n\nend" }, { "theorem_id": 14, "title": "set_algebra", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "\n\n\n\n\n\n\nuniverse u\n\nnamespace SetAlgebra\n\nvariable {X : Type u}\n\naxiom classic : ∀ P : Prop, P ∨ ¬ P\n\ndef sUnion (A B : X → Prop) : X → Prop := fun x => A x ∨ B x\ndef sInter (A B : X → Prop) : X → Prop := fun x => A x ∧ B x\ndef sCompl (A : X → Prop) : X → Prop := fun x => ¬ A x\n\ninfixl:65 \" ∪s \" => sUnion\ninfixl:70 \" ∩s \" => sInter\nprefix:100 \"ᶜs\" => sCompl\n\ntheorem inter_distrib_left (A B C : X → Prop) :\n ∀ x, (A ∩s (B ∪s C)) x ↔ ((A ∩s B) ∪s (A ∩s C)) x := by sorry\ntheorem inter_distrib_right (A B C : X → Prop) :\n ∀ x, ((A ∪s B) ∩s C) x ↔ ((A ∩s C) ∪s (B ∩s C)) x := by sorry\ntheorem de_morgan_union (A B : X → Prop) :\n ∀ x, (ᶜs (A ∪s B)) x ↔ (ᶜs A ∩s ᶜs B) x := by sorry\ntheorem de_morgan_inter (A B : X → Prop) :\n ∀ x, (ᶜs (A ∩s B)) x ↔ (ᶜs A ∪s ᶜs B) x := by sorry\nend SetAlgebra\n" }, { "theorem_id": 14, "title": "set_algebra", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Section SetAlgebra.\n Variable X : Type.\n Axiom classic : forall P:Prop, P \\/ ~P.\n\n Definition sUnion (A B : X -> Prop) : X -> Prop := fun x => A x \\/ B x.\n Definition sInter (A B : X -> Prop) : X -> Prop := fun x => A x /\\ B x.\n Definition sCompl (A : X -> Prop) : X -> Prop := fun x => ~ A x.\n\n Lemma inter_distrib_left (A B C : X -> Prop) :\n forall x, (sInter A (sUnion B C)) x <-> (sUnion (sInter A B) (sInter A C)) x.\nProof.\nAdmitted.\n\n Lemma inter_distrib_right (A B C : X -> Prop) :\n forall x, (sInter (sUnion A B) C) x <-> (sUnion (sInter A C) (sInter B C)) x.\nProof.\nAdmitted.\n\n Lemma de_morgan_union (A B : X -> Prop) :\n forall x, (sCompl (sUnion A B)) x <-> (sInter (sCompl A) (sCompl B)) x.\nProof.\nAdmitted.\n\n Lemma de_morgan_inter (A B : X -> Prop) :\n forall x, (sCompl (sInter A B)) x <-> (sUnion (sCompl A) (sCompl B)) x.\nProof.\nAdmitted.\n\nEnd SetAlgebra.\n" }, { "theorem_id": 15, "title": "supinf", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "new_type (\"R\",0);;\n\nlet is_supinf_context = new_definition\n `is_supinf_context (zero_nat:num) (Succ:num->num)\n\t (NatAltle:num->num->bool)\n\t (zero:R) (oneR:R) (add:R->R->R) (mul:R->R->R)\n\t (opp:R->R) (invR:R->R)\n\t (Rle:R->R->bool) (Rlt:R->R->bool) (Rabs:R->R)\n\t (ofNat:num->R) <=>\n (!n. NatAltle n n) /\\\n (!n m. NatAltle n m ==> NatAltle n (Succ m)) /\\\n (!n. NatAltle n (Succ n)) /\\\n (!x y. add x y = add y x) /\\\n (!x y z. add (add x y) z = add x (add y z)) /\\\n (!x. add x zero = x) /\\\n (!x. add (opp x) x = zero) /\\\n (!x y. add x (add y (opp x)) = y) /\\\n (!x y. mul x y = mul y x) /\\\n (!x y z. mul (mul x y) z = mul x (mul y z)) /\\\n (!x. mul x oneR = x) /\\\n (!x y z. mul x (add y z) = add (mul x y) (mul x z)) /\\\n (!x. add x (opp zero) = x) /\\\n (!x. Rle x x) /\\\n (!x y z. Rle x y /\\ Rle y z ==> Rle x z) /\\\n (!x y. Rle x y /\\ Rle y x ==> x = y) /\\\n (!x y. Rlt x y <=> (Rle x y /\\ ~(x = y))) /\\\n (!x. Rle (add x (opp zero)) (Rabs x)) /\\\n (!x. Rlt zero x ==> Rlt zero (invR x)) /\\\n (!x y z. Rle y z ==> Rle (add x y) (add x z)) /\\\n (!x. Rlt zero x ==> invR (invR x) = x) /\\\n\t (!n. Rlt zero (ofNat (Succ n))) /\\\n\t (!m n. NatAltle m n ==> Rle (ofNat m) (ofNat n)) /\\\n\t (ofNat zero_nat = zero) /\\\n\t (!n. ofNat (Succ n) = add (ofNat n) oneR) /\\\n (!x y. Rlt x y \\/ x = y \\/ Rlt y x) /\\\n (!a b. Rlt zero a /\\ Rlt zero b /\\ Rle a b ==> Rle (invR b) (invR a)) /\\\n (!x y. Rlt x y ==> ?eps. Rlt zero eps /\\ Rlt (add x eps) y) /\\\n\t (!x. ?n. Rle x (ofNat n))`;;\n\nlet sub = new_definition\n `sub (add:R->R->R) (opp:R->R) x y = add x (opp y)`;;\n\nlet up_bounds = new_definition\n `up_bounds (Rle:R->R->bool) (A:R->bool) x <=>\n !a. A a ==> Rle a x`;;\n\nlet is_maximum = new_definition\n `is_maximum (Rle:R->R->bool) (A:R->bool) x <=>\n A x /\\ up_bounds Rle A x`;;\n\nlet low_bounds = new_definition\n `low_bounds (Rle:R->R->bool) (A:R->bool) x <=>\n !a. A a ==> Rle x a`;;\n\nlet is_inf = new_definition\n `is_inf (Rle:R->R->bool) (A:R->bool) x <=>\n is_maximum Rle (low_bounds Rle A) x`;;\n\nlet limit = new_definition\n `limit (zero:R) (Rlt:R->R->bool) (Rabs:R->R) (Rle:R->R->bool)\n (subf:R->R->R) (NatAltle:num->num->bool) u l <=>\n !eps. Rlt zero eps ==> ?N. !n. NatAltle N n ==> Rle (Rabs (subf (u n) l)) eps`;;\n\nlet INTRO_SUPINF_HYPS =\n REWRITE_TAC[is_supinf_context] THEN REPEAT GEN_TAC THEN\n DISCH_THEN (fun th -> ASSUME_TAC th THEN MAP_EVERY ASSUME_TAC (CONJUNCTS th));;\n\nlet ASSUM_MATCH_TAC pat ttac =\n ASSUM_LIST\n (fun asms ->\n let th =\n find\n (fun th ->\n try\n let (_,tinst,_) = term_match [] pat (concl th) in\n forall (fun (v,t) -> t = v) tinst\n with Failure _ -> false)\n asms in\n ttac th);;\n\nlet add_sub_cancel_r = new_axiom\n (`!zero_nat Succ NatAltle (zero:R) oneR add mul opp invR Rle Rlt Rabs ofNat a b.\n is_supinf_context zero_nat Succ NatAltle zero oneR add mul opp invR Rle Rlt Rabs ofNat\n ==> add a (sub add opp b a) = b`);;\n\nlet RABS_POS = new_axiom\n (`!zero_nat Succ NatAltle (zero:R) oneR add mul opp invR Rle Rlt Rabs ofNat t.\n is_supinf_context zero_nat Succ NatAltle zero oneR add mul opp invR Rle Rlt Rabs ofNat\n ==> Rle t (Rabs t)`);;\n\nlet unique_max = new_axiom\n (`!zero_nat Succ NatAltle (zero:R) oneR add mul opp invR Rle Rlt Rabs ofNat (A:R->bool) x y.\n is_supinf_context zero_nat Succ NatAltle zero oneR add mul opp invR Rle Rlt Rabs ofNat\n ==> is_maximum Rle A x ==> is_maximum Rle A y ==> x = y`);;\n\nlet inf_lt = new_axiom\n (`!zero_nat Succ NatAltle (zero:R) oneR add mul opp invR Rle Rlt Rabs ofNat (A:R->bool) x y.\n is_supinf_context zero_nat Succ NatAltle zero oneR add mul opp invR Rle Rlt Rabs ofNat\n ==> is_inf Rle A x ==> Rlt x y ==> ?a. A a /\\ Rlt a y`);;\n\nlet le_of_le_add_eps = new_axiom\n (`!zero_nat Succ NatAltle (zero:R) oneR add mul opp invR Rle Rlt Rabs ofNat x y.\n is_supinf_context zero_nat Succ NatAltle zero oneR add mul opp invR Rle Rlt Rabs ofNat\n ==> (!eps. Rlt zero eps ==> Rle y (add x eps))\n ==> Rle y x`);;\n\nlet le_lim = new_axiom\n (`!zero_nat Succ NatAltle (zero:R) oneR add mul opp invR Rle Rlt Rabs ofNat (u:num->R) x y.\n is_supinf_context zero_nat Succ NatAltle zero oneR add mul opp invR Rle Rlt Rabs ofNat\n ==> limit zero Rlt Rabs Rle (sub add opp) NatAltle u x\n ==> (!n. Rle y (u n))\n ==> Rle y x`);;\n\nlet inv_succ_pos = new_axiom\n (`!zero_nat Succ NatAltle (zero:R) oneR add mul opp invR Rle Rlt Rabs ofNat n.\n is_supinf_context zero_nat Succ NatAltle zero oneR add mul opp invR Rle Rlt Rabs ofNat\n ==> Rlt zero (invR (ofNat (Succ n)))`);;\n\nlet limit_inv_succ = new_axiom\n (`!zero_nat Succ NatAltle (zero:R) oneR add mul opp invR Rle Rlt Rabs ofNat eps.\n is_supinf_context zero_nat Succ NatAltle zero oneR add mul opp invR Rle Rlt Rabs ofNat\n ==> Rlt zero eps\n ==> ?N. !n. NatAltle N n ==> Rle (invR (ofNat (Succ n))) eps`);;" }, { "theorem_id": 15, "title": "supinf", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory supinf\n imports Main\nbegin\n\nsection \"SupInf\"\n\nlocale complete_ordered_field =\n fixes zero_nat :: \"'n\"\n and succ :: \"'n \\ 'n\"\n and nat_le :: \"'n \\ 'n \\ bool\"\n and zero one :: \"'r\"\n and add :: \"'r \\ 'r \\ 'r\" (infixl \"+R\" 65)\n and mul :: \"'r \\ 'r \\ 'r\" (infixl \"*R\" 70)\n and opp inv :: \"'r \\ 'r\"\n and rle :: \"'r \\ 'r \\ bool\" (infix \"\\R\" 50)\n and rlt :: \"'r \\ 'r \\ bool\" (infix \" 'r\"\n and inr :: \"'n \\ 'r\"\n assumes nat_le_refl : \"\\n. nat_le n n\"\n and le_succ_of_le : \"\\n m. nat_le n m \\ nat_le n (succ m)\"\n and le_succ : \"\\n. nat_le n (succ n)\"\n and add_comm : \"\\x y. x +R y = y +R x\"\n and add_assoc : \"\\x y z. (x +R y) +R z = x +R (y +R z)\"\n and add_zero : \"\\x. x +R zero = x\"\n and add_opp : \"\\x. opp x +R x = zero\"\n and mul_comm : \"\\x y. x *R y = y *R x\"\n and mul_assoc : \"\\x y z. (x *R y) *R z = x *R (y *R z)\"\n and mul_one : \"\\x. x *R one = x\"\n and sub_zero : \"\\x. x +R opp zero = x\"\n and rle_refl : \"\\x. x \\R x\"\n and rle_trans : \"\\x y z. x \\R y \\ y \\R z \\ x \\R z\"\n and rle_antisym : \"\\x y. x \\R y \\ y \\R x \\ x = y\"\n and rlt_def : \"\\x y. (x (x \\R y \\ x \\ y)\"\n and rle_abs : \"\\x. x +R opp zero \\R rabs x\"\n and rinv_pos : \"\\x. zero zero x y z. y \\R z \\ x +R y \\R x +R z\"\n and rinv_involutive : \"\\x. zero inv (inv x) = x\"\n and inr_pos : \"\\n. zero m n. nat_le m n \\ inr m \\R inr n\"\n and inr_zero : \"inr zero_nat = zero\"\n and inr_succ : \"\\n. inr (succ n) = inr n +R one\"\n and rtotal_order : \"\\x y. (x x = y \\ (y a b. zero zero a \\R b \\ inv b \\R inv a\"\n and eps_between :\n \"\\x y. x \\eps. zero x +R eps x. \\n. x \\R inr n\"\n and completeness :\n \"\\A. (\\ub. \\a. A a \\ ub \\R a) \\\n \\sup. (\\a. A a \\ a \\R sup) \\\n (\\y. (\\a. A a \\ a \\R y) \\ sup \\R y)\"\nbegin\n\nlemma add_opp_r: \"x +R opp x = zero\"\n by sorry\n\nlemma rlt_le: \"x x \\R y\"\n by sorry\n\nlemma rlt_ne: \"x x \\ y\"\n by sorry\n\nlemma rlt_intro: \"x \\R y \\ x \\ y \\ x bool) \\ 'r \\ bool\"\n where \"up_bounds A x \\ \\a. A a \\ a \\R x\"\n\ndefinition is_maximum :: \"'r \\ ('r \\ bool) \\ bool\"\n where \"is_maximum a A \\ A a \\ up_bounds A a\"\n\ndefinition low_bounds :: \"('r \\ bool) \\ 'r \\ bool\"\n where \"low_bounds A x \\ \\a. A a \\ x \\R a\"\n\ndefinition is_inf :: \"'r \\ ('r \\ bool) \\ bool\"\n where \"is_inf x A \\ is_maximum x (low_bounds A)\"\n\ndefinition limit :: \"('n \\ 'r) \\ 'r \\ bool\"\n where \"limit u l \\\n \\eps. zero \n (\\N. \\n. nat_le N n \\ rabs (u n +R opp l) \\R eps)\"\n\nlemma add_sub_cancel_r: \"a +R (b +R opp a) = b\"\n by sorry\n\nlemma rabs_pos: \"t \\R rabs t\"\n by sorry\n\nlemma unique_max:\n assumes \"is_maximum x A\" \"is_maximum y A\"\n shows \"x = y\"\n by sorry\n\nlemma inf_lt:\n assumes hinf: \"is_inf x A\" and hlt: \"x a. A a \\ a eps. zero y \\R x +R eps\"\n shows \"y \\R x\"\n by sorry\n\nlemma le_lim:\n assumes hlim : \"limit u x\"\n and hle : \"\\n. y \\R u n\"\n shows \"y \\R x\"\n by sorry\n\nlemma inv_succ_pos: \"zero N. \\n. nat_le N n \\ inv (inr (succ n)) \\R eps\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 15, "title": "supinf", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "class CompleteOrderedField where\n R : Type\n NatAlt : Type\n zero_nat : NatAlt\n Succ : NatAlt -> NatAlt\n NatAltle : NatAlt -> NatAlt -> Prop\n\n zero : R\n one : R\n add : R → R → R\n mul : R → R → R\n opp : R → R\n inv : R → R\n Rle : R → R → Prop\n Rlt : R → R → Prop\n Rabs : R → R\n INR : NatAlt → R\n\n NatAltle_n : ∀ n : NatAlt, NatAltle n n\n le_succ_of_le : ∀ n m: NatAlt, NatAltle n m → NatAltle n (Succ m)\n le_succ : ∀ n : NatAlt, NatAltle n (Succ n)\n\n add_comm : ∀ x y : R, add x y = add y x\n add_assoc : ∀ x y z : R, add (add x y) z = add x (add y z)\n add_zero : ∀ x : R, add x zero = x\n add_opp : ∀ x : R, add (opp x) x = zero\n mul_comm : ∀ x y : R, mul x y = mul y x\n mul_assoc : ∀ x y z : R, mul (mul x y) z = mul x (mul y z)\n mul_one : ∀ x : R, mul x one = x\n dist_l : ∀ x y z : R, mul x (add y z) = add (mul x y) (mul x z)\n sub_zero : ∀ x : R, add x (opp zero) = x\n Rle_refl : ∀ x : R, Rle x x\n Rle_trans : ∀ x y z : R, Rle x y → Rle y z → Rle x z\n Rle_antisym : ∀ x y : R, Rle x y → Rle y x → x = y\n Rlt_def : ∀ x y : R, Rlt x y ↔ (Rle x y ∧ x ≠ y)\n Rle_abs : ∀ x : R, Rle (add x (opp zero)) (Rabs x)\n Rinv_0_lt_compat : ∀ x : R, Rlt zero x → Rlt zero (inv x)\n Rplus_le_compat_l : ∀ x y z : R, Rle y z → Rle (add x y) (add x z)\n Rinv_involutive : ∀ x : R, Rlt zero x → inv (inv x) = x\n INR_pos : ∀ n, Rlt zero (INR (Succ n))\n INR_le : ∀ m n, (NatAltle m n) → Rle (INR m) (INR n)\n INR_0 : INR zero_nat = zero\n INR_S : ∀ n, INR (Succ n) = add (INR n) one\n Rtotal_order : ∀ x y : R, Rlt x y ∨ x = y ∨ Rlt y x\n Rle_inv_contravar : ∀ a b : R, Rlt zero a → Rlt zero b → Rle a b → Rle (inv b) (inv a)\n eps_between : ∀ x y : R, Rlt x y → ∃ eps, Rlt zero eps ∧ Rlt (add x eps) y\n archimedean : ∀ x : R, ∃ n, Rle x (INR n)\n completeness : ∀ (A : R → Prop),\n (∃ ub, ∀ a, A a → Rle ub a) →\n ∃ sup, (∀ a, A a → Rle a sup) ∧ ∀ y, (∀ a, A a → Rle a y) → Rle sup y\n\nnamespace SupInf\n\nvariable [F : CompleteOrderedField]\nopen CompleteOrderedField (R zero one add mul opp inv Rle Rlt Rabs INR NatAltle)\n\ninfixl:65 \" + \" => add\ninfixl:70 \" * \" => mul\nprefix:100 \"-\" => opp\nnotation x \" - \" y:65 => add x (opp y)\nprefix:100 \"/\" => inv\ninfixl:70 \" <= \" => NatAltle\ninfixl:70 \" <=R \" => Rle\ninfixl:70 \" Rlt\ninfixl:70 \" >R \" => (fun x y => Rlt y x)\nnotation \"|\" x \"|\" => Rabs x\n\n\nlocal notation \"R\" => F.R\n\ndef up_bounds (A : R → Prop) : R → Prop :=\n fun x => ∀ a, A a → a <=R x\n\ndef is_maximum (a : R) (A : R → Prop) : Prop :=\n A a ∧ up_bounds A a\n\ninfix:70 \" is_a_max_of \" => is_maximum\n\ntheorem add_sub_cancel_r (a b : R) :\n a + (b - a) = b := by sorry\ntheorem Rabs_pos (t : R) : t <=R |t| := by sorry\ntheorem unique_max (A : R → Prop) (x y : R) :\n x is_a_max_of A → y is_a_max_of A → x = y := by sorry\ndef low_bounds (A : R → Prop) : R → Prop :=\n fun x => ∀ a, A a → x <=R a\n\ndef is_inf (x : R) (A : R → Prop) : Prop :=\n is_maximum x (low_bounds A)\n\ninfix:70 \" is_an_inf_of \" => is_inf\n\naxiom classic : ∀ P : Prop, P ∨ ¬P\n\ntheorem inf_lt (A : R → Prop) (x : R) :\n x is_an_inf_of A → ∀ y, x R F.zero → y <=R (x + eps)) → y <=R x := by sorry\ndef limit (u : F.NatAlt → R) (l : R) : Prop :=\n ∀ eps, eps >R F.zero → ∃ N : F.NatAlt, ∀ n : F.NatAlt, N <= n → |u n - l| <=R eps\n\ntheorem le_lim (x y : R) (u : F.NatAlt → R) :\n limit u x → (∀ n : F.NatAlt, y <=R u n) → y <=R x := by sorry\ntheorem inv_succ_pos (n : F.NatAlt) : F.zero R F.zero) :\n ∃ N, ∀ n : F.NatAlt, N <= n → /F.INR (F.Succ n) <=R eps := by sorry\nend SupInf\n" }, { "theorem_id": 15, "title": "supinf", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Class CompleteOrderedField := {\n R : Type;\n NatAlt : Type;\n zero_nat : NatAlt;\n Succ : NatAlt -> NatAlt;\n NatAltle : NatAlt -> NatAlt -> Prop;\n\n zero : R;\n one : R;\n add : R -> R -> R;\n mul : R -> R -> R;\n opp : R -> R;\n inv : R -> R;\n Rle : R -> R -> Prop;\n Rlt : R -> R -> Prop;\n Rabs : R -> R;\n INR : NatAlt -> R;\n\n le_succ_of_le : forall n m, NatAltle n m -> NatAltle n (Succ m);\n le_succ : forall n, NatAltle n (Succ n);\n NatAltle_n : forall n : NatAlt, NatAltle n n;\n\n add_comm : forall x y, add x y = add y x;\n add_assoc : forall x y z, add (add x y) z = add x (add y z);\n add_zero : forall x, add x zero = x;\n add_opp : forall x, add (opp x) x = zero;\n mul_comm : forall x y, mul x y = mul y x;\n mul_assoc : forall x y z, mul (mul x y) z = mul x (mul y z);\n mul_one : forall x, mul x one = x;\n dist_l : forall x y z, mul x (add y z) = add (mul x y) (mul x z);\n sub_zero : forall x, add x (opp zero) = x;\n\n Rle_refl : forall x, Rle x x;\n Rle_trans : forall x y z, Rle x y -> Rle y z -> Rle x z;\n Rle_antisym : forall x y, Rle x y -> Rle y x -> x = y;\n Rlt_def : forall x y, Rlt x y <-> (Rle x y /\\ x <> y);\n Rle_abs : forall x, Rle (add x (opp zero)) (Rabs x);\n Rinv_0_lt_compat : forall x, Rlt zero x -> Rlt zero (inv x);\n Rplus_le_compat_l : forall x y z, Rle y z -> Rle (add x y) (add x z);\n Rinv_involutive : forall x, Rlt zero x -> inv (inv x) = x;\n\n INR_pos : forall n, Rlt zero (INR (Succ n));\n INR_le : forall m n, NatAltle m n -> Rle (INR m) (INR n);\n INR_0 : INR zero_nat = zero;\n INR_S : forall n, INR (Succ n) = add (INR n) one;\n\n Rtotal_order : forall x y, Rlt x y \\/ x = y \\/ Rlt y x;\n Rle_inv_contravar : forall a b, Rlt zero a -> Rlt zero b -> Rle a b -> Rle (inv b) (inv a);\n eps_between : forall x y, Rlt x y -> exists eps, Rlt zero eps /\\ Rlt (add x eps) y;\n\n archimedean : forall x, exists n, Rle x (INR n);\n completeness : forall A : R -> Prop,\n (exists ub, forall a, A a -> Rle ub a) ->\n exists sup,\n (forall a, A a -> Rle a sup) /\\\n (forall y, (forall a, A a -> Rle a y) -> Rle sup y)\n}.\n\nSection SupInf.\n Context {F : CompleteOrderedField}.\n\n Infix \"+\" := add.\n Infix \"*\" := mul.\n Notation \"- x\" := (opp x).\n Notation \"x - y\" := (add x (opp y)).\n Notation \"/ x\" := (inv x).\n Infix \"<=\" := NatAltle (at level 70).\n\n Infix \"<=R\" := Rle (at level 70).\n Infix \"R\" := (fun x y => Rlt y x) (at level 70).\n Notation \"| x |\" := (Rabs x) (at level 40).\n\n Definition up_bounds (A : R -> Prop) (x : R) : Prop :=\n forall a, A a -> Rle a x.\n \n Definition is_maximum (a : R) (A : R -> Prop) : Prop :=\n A a /\\ up_bounds A a.\n Infix \"is_a_max_of\" := is_maximum (at level 70).\n Lemma add_sub_cancel_r : forall a b : R,\n a + (b - a) = b.\nProof.\nAdmitted.\n Print add_sub_cancel_r.\n Lemma Rabs_pos (t : R) : t <=R |t|.\nProof.\nAdmitted.\n Print Rabs_pos.\n \n Lemma unique_max (A : R -> Prop) (x y : R) :\n x is_a_max_of A -> y is_a_max_of A -> x = y.\nProof.\nAdmitted.\n \n Definition low_bounds (A : R -> Prop) : R -> Prop :=\n fun x => forall a, A a -> x <=R a.\n\n Definition is_inf (x : R) (A : R -> Prop) : Prop :=\n is_maximum x (low_bounds A).\n Infix \"is_an_inf_of\" := is_inf (at level 70).\n \n Axiom classic : forall P:Prop, P \\/ ~P.\n Lemma inf_lt (A : R -> Prop) (x : R) :\n x is_an_inf_of A -> forall y, x exists a, A a /\\ a R zero -> y <=R x + eps) -> y <=R x.\nProof.\nAdmitted.\n \n Definition limit (u : NatAlt -> R) (l : R) : Prop :=\n forall eps, eps >R zero -> exists N, forall n : NatAlt, (N <= n) -> |u n - l| <=R eps.\n\n Lemma le_lim (x y : R) (u : NatAlt -> R) :\n limit u x -> (forall n : NatAlt, y <=R u n) -> y <=R x.\nProof.\nAdmitted.\n\n Lemma inv_succ_pos : forall n, zero R zero ->\n exists N, forall n : NatAlt, (N <= n) -> / INR (Succ n) <=R eps.\nProof.\nAdmitted.\n\n\nEnd SupInf.\n\n" }, { "theorem_id": 16, "title": "zero_le_one_elem", "source": "babel-formal", "tier": "a", "prover": "hol-light", "content": "let one_matrix = new_definition\n `one_matrix (decEq:M->M->bool) (oneA:A) (zeroA:A) =\n (\\i j. if decEq i j then oneA else zeroA)`;;\n\nlet zero_matrix = new_definition\n `zero_matrix (zeroA:A) = (\\i j. zeroA)`;;\n\nlet matrix_le = new_definition\n `matrix_le (le:A->A->bool) (A0:M->M->A) (B0:M->M->A) <=>\n !i j. le (A0 i j) (B0 i j)`;;\n\nlet matrix_eq = new_definition\n `matrix_eq (A0:M->M->A) (B0:M->M->A) <=> !i j. A0 i j = B0 i j`;;\n\nlet zero_le_one_elem = `!decEq (zeroA:A) oneA (le:A->A->bool) i j.\n le zeroA oneA ==> le zeroA zeroA ==> le zeroA (one_matrix decEq oneA zeroA i j)`;;\n\nlet zero_le_one_matrix = `!decEq (zeroA:A) oneA (le:A->A->bool).\n le zeroA oneA ==> le zeroA zeroA ==>\n matrix_le le (zero_matrix zeroA) (one_matrix decEq oneA zeroA)`;;\n\nlet matrix_le_refl = `!le:A->A->bool. (!x. le x x) ==> !A0:M->M->A. matrix_le le A0 A0`;;\n\nlet matrix_le_trans = `!le:A->A->bool.\n (!x y z. le x y ==> le y z ==> le x z) ==>\n !A0 B0 C0:M->M->A.\n matrix_le le A0 B0 ==> matrix_le le B0 C0 ==> matrix_le le A0 C0`;;\n\nlet matrix_eq_refl = `!A0:M->M->A. matrix_eq A0 A0`;;\n\nlet matrix_eq_sym = `!A0 B0:M->M->A. matrix_eq A0 B0 ==> matrix_eq B0 A0`;;\n\nlet matrix_eq_trans = `!A0 B0 C0:M->M->A. matrix_eq A0 B0 ==> matrix_eq B0 C0 ==> matrix_eq A0 C0`;;\n\nlet matrix_eq_le = `!le:A->A->bool.\n (!x. le x x) ==>\n !A0 B0:M->M->A. matrix_eq A0 B0 ==> matrix_le le A0 B0 /\\ matrix_le le B0 A0`;;\n\nlet matrix_le_antisymm = `!le:A->A->bool.\n (!x y. le x y ==> le y x ==> x = y) ==>\n !A0 B0:M->M->A.\n matrix_le le A0 B0 ==> matrix_le le B0 A0 ==> matrix_eq A0 B0`;;" }, { "theorem_id": 16, "title": "zero_le_one_elem", "source": "babel-formal", "tier": "a", "prover": "isabelle", "content": "theory zero_le_one_elem\n imports Main\nbegin\n\nsection \"ZeroLeOneElem\"\n\nlocale zero_le_one_setup =\n fixes decEq :: \"'m \\ 'm \\ bool\"\n and zero :: \"'a\"\n and one :: \"'a\"\n and le :: \"'a \\ 'a \\ bool\" (infix \"\\\" 50)\n and le_antisym :: \"'a \\ 'a \\ 'a \\ 'a \\ bool\"\n assumes le_refl : \"\\x. x \\ x\"\n and le_trans : \"\\x y z. x \\ y \\ y \\ z \\ x \\ z\"\n and zero_le_one : \"zero \\ one\"\n and zero_le_zero : \"zero \\ zero\"\n and le_antisym : \"\\x y. x \\ y \\ y \\ x \\ x = y\"\nbegin\n\ndefinition One_matrix :: \"'m \\ 'm \\ 'a\"\n where \"One_matrix i j \\ if decEq i j then one else zero\"\n\ndefinition Zero_matrix :: \"'m \\ 'm \\ 'a\"\n where \"Zero_matrix \\ \\_ _. zero\"\n\ndefinition matrix_le :: \"('m \\ 'm \\ 'a) \\ ('m \\ 'm \\ 'a) \\ bool\"\n where \"matrix_le A B \\ \\i j. A i j \\ B i j\"\n\ndefinition matrix_eq :: \"('m \\ 'm \\ 'a) \\ ('m \\ 'm \\ 'a) \\ bool\"\n where \"matrix_eq A B \\ \\i j. A i j = B i j\"\n\nlemma zero_le_one_elem: \"zero \\ One_matrix i j\"\n by sorry\n\nlemma Zero_le_One_matrix: \"matrix_le Zero_matrix One_matrix\"\n by sorry\n\nlemma matrix_le_refl: \"matrix_le A A\"\n by sorry\n\nlemma matrix_le_trans: \"matrix_le A B \\ matrix_le B C \\ matrix_le A C\"\n by sorry\n\nlemma matrix_eq_refl: \"matrix_eq A A\"\n by sorry\n\nlemma matrix_eq_sym: \"matrix_eq A B \\ matrix_eq B A\"\n by sorry\n\nlemma matrix_eq_trans: \"matrix_eq A B \\ matrix_eq B C \\ matrix_eq A C\"\n by sorry\n\nlemma matrix_eq_le: \"matrix_eq A B \\ matrix_le A B \\ matrix_le B A\"\n by sorry\n\nlemma matrix_le_antisymm: \"matrix_le A B \\ matrix_le B A \\ matrix_eq A B\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 16, "title": "zero_le_one_elem", "source": "babel-formal", "tier": "a", "prover": "lean4", "content": "universe u\n\nclass DecidableEqAlt (A : Type u) where\n decEq : (x y : A) → Bool\n\nclass ZeroAlt (A : Type u) where\n zero : A\n\nclass OneAlt (A : Type u) where\n one : A\n\nclass Preorder (A : Type u) where\n le : A → A → Prop\n refl : ∀ x, le x x\n trans : ∀ {x y z}, le x y → le y z → le x z\n\ninfix:50 \" ≤ \" => Preorder.le\n\nclass ZeroLEOneClass (A : Type u) [ZeroAlt A] [OneAlt A] [Preorder A] : Prop where\n zero_le_one : (ZeroAlt.zero : A) ≤ (OneAlt.one : A)\n zero_le_zero : (ZeroAlt.zero : A) ≤ (ZeroAlt.zero : A)\n\nnamespace Matrix\n variable (m : Type u) [DecidableEqAlt m]\n variable (α : Type u) [ZeroAlt α] [OneAlt α] [Preorder α] [ZeroLEOneClass α]\n abbrev matrix := m → m → α\n\n\n def One_matrix : matrix m α :=\n fun i j => if DecidableEqAlt.decEq i j then OneAlt.one else ZeroAlt.zero\n\n theorem zero_le_one_elem\n (i j : m) : (ZeroAlt.zero : α) ≤ One_matrix m α i j := by sorry\n def Zero_matrix : matrix m α := fun _ _ => ZeroAlt.zero\n\n def matrix_le (A B : matrix m α) : Prop := ∀ i j, A i j ≤ B i j\n\n theorem Zero_le_One_matrix : matrix_le m α (Zero_matrix m α) (One_matrix m α) := by sorry\n theorem matrix_le_refl (A : matrix m α) : matrix_le m α A A := by sorry\n theorem matrix_le_trans (A B C : matrix m α) :\n matrix_le m α A B → matrix_le m α B C → matrix_le m α A C := by sorry\n def matrix_eq (A B : matrix m α) : Prop := ∀ i j, A i j = B i j\n\n theorem matrix_eq_refl (A : matrix m α) : matrix_eq m α A A := by sorry\n theorem matrix_eq_sym (A B : matrix m α) : matrix_eq m α A B → matrix_eq m α B A := by sorry\n theorem matrix_eq_trans (A B C : matrix m α) :\n matrix_eq m α A B → matrix_eq m α B C → matrix_eq m α A C := by sorry\n theorem matrix_eq_le (A B : matrix m α) :\n matrix_eq m α A B → matrix_le m α A B ∧ matrix_le m α B A := by sorry\n class PartialOrder (A : Type u) [Preorder A] : Prop where\n le_antisym : ∀ {x y : A}, x ≤ y → y ≤ x → x = y\n\n variable [PartialOrder α]\n\n theorem matrix_le_antisymm (A B : matrix m α) :\n matrix_le m α A B → matrix_le m α B A → matrix_eq m α A B := by sorry\nend Matrix\n" }, { "theorem_id": 16, "title": "zero_le_one_elem", "source": "babel-formal", "tier": "a", "prover": "rocq", "content": "Class DecidableEqAlt (A : Type) := {\n dec_eq : forall x y : A, {x = y} + {x <> y}\n}.\n\nClass ZeroAlt (A : Type) := zero : A.\nClass OneAlt (A : Type) := one : A.\n\nClass Preorder (A : Type) := {\n le : A -> A -> Prop;\n Preorder_Reflexive : forall x, le x x;\n Preorder_Transitive : forall x y z, le x y -> le y z -> le x z\n}.\n\nInfix \"≤\" := le (at level 70, no associativity).\n\nClass ZeroLEOneClass (A : Type)\n `{ZeroAlt A} `{OneAlt A} `{Preorder A} := {\n zero_le_one : zero ≤ (one : A);\n zero_le_zero : zero ≤ (zero : A)\n}.\n\nSection Matrix.\n Variable (m : Type).\n Context `{DecidableEqAlt m}.\n\n Variable (α : Type).\n Context `{ZeroLEOneClass α}.\n\n Definition matrix := m -> m -> α.\n\n Definition One_matrix : matrix :=\n fun i j => if dec_eq i j then one else zero.\n\n Lemma zero_le_one_elem (i j : m) :\n zero ≤ (One_matrix : matrix) i j.\nProof.\nAdmitted.\n\n Definition Zero_matrix : matrix := fun _ _ => zero.\n\n Definition matrix_le (A B : matrix) : Prop :=\n forall i j, A i j ≤ B i j.\n Infix \"≤ₘ\" := matrix_le (at level 70).\n\n Lemma Zero_le_One_matrix : Zero_matrix ≤ₘ One_matrix.\nProof.\nAdmitted.\n\n Lemma matrix_le_refl (A : matrix) : A ≤ₘ A.\nProof.\nAdmitted.\n\n Lemma matrix_le_trans (A B C : matrix) :\n A ≤ₘ B -> B ≤ₘ C -> A ≤ₘ C.\nProof.\nAdmitted.\n\n Definition matrix_eq (A B : matrix) : Prop :=\n forall i j, A i j = B i j.\n Infix \"≃ₘ\" := matrix_eq (at level 70).\n\n Lemma matrix_eq_refl (A : matrix) : A ≃ₘ A.\nProof.\nAdmitted.\n\n Lemma matrix_eq_sym (A B : matrix) : A ≃ₘ B -> B ≃ₘ A.\nProof.\nAdmitted.\n\n Lemma matrix_eq_trans (A B C : matrix) :\n A ≃ₘ B -> B ≃ₘ C -> A ≃ₘ C.\nProof.\nAdmitted.\n\n Lemma matrix_eq_le (A B : matrix) :\n A ≃ₘ B -> A ≤ₘ B /\\ B ≤ₘ A.\nProof.\nAdmitted.\n\n Class PartialOrder (A : Type) `{Preorder A} := {\n le_antisym : forall x y, x ≤ y -> y ≤ x -> x = y\n }.\n Context {PO : PartialOrder α}.\n\n Lemma matrix_le_antisymm (A B : matrix) :\n A ≤ₘ B -> B ≤ₘ A -> A ≃ₘ B.\nProof.\nAdmitted.\nEnd Matrix.\n" }, { "theorem_id": 17, "title": "001_the_irrationality_of_the_square_root_of_2", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";; \nneeds \"Library/floor.ml\";; \n\nlet IRRATIONAL_SQRT_NONSQUARE = `!n. rational(sqrt(&n)) ==> ?m. n = m EXP 2`;;\n\nlet IRRATIONAL_SQRT_PRIME = `!p. prime p ==> ~rational(sqrt(&p))`;;\n\nlet IRRATIONAL_SQRT_2 = `~rational(sqrt(&2))`;;" }, { "theorem_id": 17, "title": "001_the_irrationality_of_the_square_root_of_2", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "\nsection \\Pieces of computational Algebra\\\n\ntheory Computational_Algebra\nimports\n Euclidean_Algorithm\n Factorial_Ring\n Formal_Laurent_Series\n Fraction_Field\n Fundamental_Theorem_Algebra\n Group_Closure\n Normalized_Fraction\n Nth_Powers\n Polynomial_FPS\n Polynomial\n Polynomial_Factorial\n Primes\n Squarefree\nbegin\n\nend\n" }, { "theorem_id": 17, "title": "001_the_irrationality_of_the_square_root_of_2", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Yury Kudryashov\n-/\nmodule\n\npublic import Mathlib.Algebra.Algebra.Rat\npublic import Mathlib.Data.Nat.Prime.Int\npublic import Mathlib.Data.Rat.Sqrt\npublic import Mathlib.Data.Real.Sqrt\npublic import Mathlib.RingTheory.Algebraic.Basic\npublic import Mathlib.Tactic.IntervalCases\n\n/-!\n# Irrational real numbers\n\nIn this file we define a predicate `Irrational` on `ℝ`, prove that the `n`-th root of an integer\nnumber is irrational if it is not integer, and that `√(q : ℚ)` is irrational if and only if\n`¬IsSquare q ∧ 0 ≤ q`.\n\nWe also provide dot-style constructors like `Irrational.add_ratCast`, `Irrational.ratCast_sub` etc.\n\nWith the `Decidable` instances in this file, is possible to prove `Irrational √n` using `decide`,\nwhen `n` is a numeric literal or cast;\nbut this only works if you `unseal Nat.sqrt.iter in` before the theorem where you use this proof.\n-/\n\n@[expose] public section\n\n\nopen Rat Real\n\n/-- A real number is irrational if it is not equal to any rational number. -/\ndef Irrational (x : ℝ) :=\n x ∉ Set.range ((↑) : ℚ → ℝ)\n\ntheorem irrational_iff_ne_rational (x : ℝ) : Irrational x ↔ ∀ a b : ℤ, b ≠ 0 → x ≠ a / b := by sorry\ntheorem Irrational.ne_rational {x : ℝ} (hx : Irrational x) (a b : ℤ) : x ≠ a / b := by sorry\ntheorem exists_rat_of_not_irrational {x : ℝ} (hx : ¬ Irrational x) : ∃ (q : ℚ), x = q := by sorry\ntheorem Transcendental.irrational {r : ℝ} (tr : Transcendental ℚ r) : Irrational r := by sorry\ntheorem irrational_nrt_of_notint_nrt {x : ℝ} (n : ℕ) (m : ℤ) (hxr : x ^ n = m)\n (hv : ¬∃ y : ℤ, x = y) (hnpos : 0 < n) : Irrational x := by sorry\ntheorem irrational_nrt_of_n_not_dvd_multiplicity {x : ℝ} (n : ℕ) {m : ℤ} (hm : m ≠ 0) (p : ℕ)\n [hp : Fact p.Prime] (hxr : x ^ n = m)\n (hv : multiplicity (p : ℤ) m % n ≠ 0) :\n Irrational x := by sorry\ntheorem irrational_sqrt_of_multiplicity_odd (m : ℤ) (hm : 0 < m) (p : ℕ) [hp : Fact p.Prime]\n (Hpv : multiplicity (p : ℤ) m % 2 = 1) :\n Irrational (√m) :=\n @irrational_nrt_of_n_not_dvd_multiplicity _ 2 _ (Ne.symm (ne_of_lt hm)) p hp\n (sq_sqrt (Int.cast_nonneg hm.le)) (by rw [Hpv]; exact one_ne_zero)\n\n@[simp] theorem not_irrational_zero : ¬Irrational 0 := not_not_intro ⟨0, Rat.cast_zero⟩\n@[simp] theorem not_irrational_one : ¬Irrational 1 := not_not_intro ⟨1, Rat.cast_one⟩\n\ntheorem irrational_sqrt_ratCast_iff_of_nonneg {q : ℚ} (hq : 0 ≤ q) :\n Irrational (√q) ↔ ¬IsSquare q := by sorry\ntheorem irrational_sqrt_ratCast_iff {q : ℚ} :\n Irrational (√q) ↔ ¬IsSquare q ∧ 0 ≤ q := by sorry\ntheorem irrational_sqrt_intCast_iff_of_nonneg {z : ℤ} (hz : 0 ≤ z) :\n Irrational (√z) ↔ ¬IsSquare z := by sorry\ntheorem irrational_sqrt_intCast_iff {z : ℤ} :\n Irrational (√z) ↔ ¬IsSquare z ∧ 0 ≤ z := by sorry\ntheorem irrational_sqrt_natCast_iff {n : ℕ} : Irrational (√n) ↔ ¬IsSquare n := by sorry\ntheorem irrational_sqrt_ofNat_iff {n : ℕ} [n.AtLeastTwo] :\n Irrational √(ofNat(n)) ↔ ¬IsSquare ofNat(n) :=\n irrational_sqrt_natCast_iff\n\ntheorem Nat.Prime.irrational_sqrt {p : ℕ} (hp : Nat.Prime p) : Irrational (√p) :=\n irrational_sqrt_natCast_iff.mpr hp.not_isSquare\n\n/-- **Irrationality of the Square Root of 2** -/\ntheorem irrational_sqrt_two : Irrational (√2) := by sorry\ninstance {n : ℕ} [n.AtLeastTwo] : Decidable (Irrational √(ofNat(n))) :=\n decidable_of_iff' _ irrational_sqrt_ofNat_iff\n\ninstance (n : ℕ) : Decidable (Irrational (√n)) :=\n decidable_of_iff' _ irrational_sqrt_natCast_iff\n\ninstance (z : ℤ) : Decidable (Irrational (√z)) :=\n decidable_of_iff' _ irrational_sqrt_intCast_iff\n\ninstance (q : ℚ) : Decidable (Irrational (√q)) :=\n decidable_of_iff' _ irrational_sqrt_ratCast_iff\n\n/-!\n### Dot-style operations on `Irrational`\n\n#### Coercion of a rational/integer/natural number is not irrational\n-/\n\n\nnamespace Irrational\n\nvariable {x : ℝ}\n\n/-!\n#### Irrational number is not equal to a rational/integer/natural number\n-/\n\n\ntheorem ne_rat (h : Irrational x) (q : ℚ) : x ≠ q := fun hq => h ⟨q, hq.symm⟩\n\ntheorem ne_int (h : Irrational x) (m : ℤ) : x ≠ m := by sorry\ntheorem ne_nat (h : Irrational x) (m : ℕ) : x ≠ m :=\n h.ne_int m\n\ntheorem ne_zero (h : Irrational x) : x ≠ 0 := mod_cast h.ne_nat 0\n\ntheorem ne_one (h : Irrational x) : x ≠ 1 := by simpa only [Nat.cast_one] using h.ne_nat 1\n\n@[simp] theorem ne_ofNat (h : Irrational x) (n : ℕ) [n.AtLeastTwo] : x ≠ ofNat(n) :=\n h.ne_nat n\n\nend Irrational\n\n@[simp]\ntheorem Rat.not_irrational (q : ℚ) : ¬Irrational q := fun h => h ⟨q, rfl⟩\n\n@[simp]\ntheorem Int.not_irrational (m : ℤ) : ¬Irrational m := fun h => h.ne_int m rfl\n\n@[simp]\ntheorem Nat.not_irrational (m : ℕ) : ¬Irrational m := fun h => h.ne_nat m rfl\n\n@[simp] theorem not_irrational_ofNat (n : ℕ) [n.AtLeastTwo] : ¬Irrational ofNat(n) :=\n n.not_irrational\nnamespace Irrational\n\nvariable (q : ℚ) {x y : ℝ}\n\n/-!\n#### Addition of rational/integer/natural numbers\n-/\n\n\n/-- If `x + y` is irrational, then at least one of `x` and `y` is irrational. -/\ntheorem add_cases : Irrational (x + y) → Irrational x ∨ Irrational y := by sorry\ntheorem of_ratCast_add (h : Irrational (q + x)) : Irrational x :=\n h.add_cases.resolve_left q.not_irrational\ntheorem ratCast_add (h : Irrational x) : Irrational (q + x) :=\n of_ratCast_add (-q) <| by rwa [cast_neg, neg_add_cancel_left]\ntheorem of_add_ratCast : Irrational (x + q) → Irrational x :=\n add_comm (↑q) x ▸ of_ratCast_add q\ntheorem add_ratCast (h : Irrational x) : Irrational (x + q) :=\n add_comm (↑q) x ▸ h.ratCast_add q\ntheorem of_intCast_add (m : ℤ) (h : Irrational (m + x)) : Irrational x := by sorry\ntheorem of_add_intCast (m : ℤ) (h : Irrational (x + m)) : Irrational x :=\n of_intCast_add m <| add_comm x m ▸ h\ntheorem intCast_add (h : Irrational x) (m : ℤ) : Irrational (m + x) := by sorry\ntheorem add_intCast (h : Irrational x) (m : ℤ) : Irrational (x + m) :=\n add_comm (↑m) x ▸ h.intCast_add m\ntheorem of_natCast_add (m : ℕ) (h : Irrational (m + x)) : Irrational x :=\n h.of_intCast_add m\ntheorem of_add_natCast (m : ℕ) (h : Irrational (x + m)) : Irrational x :=\n h.of_add_intCast m\ntheorem natCast_add (h : Irrational x) (m : ℕ) : Irrational (m + x) :=\n h.intCast_add m\ntheorem add_natCast (h : Irrational x) (m : ℕ) : Irrational (x + m) :=\n h.add_intCast m\n/-!\n#### Negation\n-/\n\n\ntheorem of_neg (h : Irrational (-x)) : Irrational x := fun ⟨q, hx⟩ => h ⟨-q, by rw [cast_neg, hx]⟩\n\nprotected theorem neg (h : Irrational x) : Irrational (-x) :=\n of_neg <| by rwa [neg_neg]\n\n/-!\n#### Subtraction of rational/integer/natural numbers\n-/\n\n\ntheorem sub_ratCast (h : Irrational x) : Irrational (x - q) := by sorry\ntheorem ratCast_sub (h : Irrational x) : Irrational (q - x) := by sorry\ntheorem of_sub_ratCast (h : Irrational (x - q)) : Irrational x :=\n of_add_ratCast (-q) <| by simpa only [cast_neg, sub_eq_add_neg] using h\ntheorem of_ratCast_sub (h : Irrational (q - x)) : Irrational x :=\n of_neg (of_ratCast_add q (by simpa only [sub_eq_add_neg] using h))\ntheorem sub_intCast (h : Irrational x) (m : ℤ) : Irrational (x - m) := by sorry\ntheorem intCast_sub (h : Irrational x) (m : ℤ) : Irrational (m - x) := by sorry\ntheorem of_sub_intCast (m : ℤ) (h : Irrational (x - m)) : Irrational x :=\n of_sub_ratCast m <| by rwa [Rat.cast_intCast]\ntheorem of_intCast_sub (m : ℤ) (h : Irrational (m - x)) : Irrational x :=\n of_ratCast_sub m <| by rwa [Rat.cast_intCast]\ntheorem sub_natCast (h : Irrational x) (m : ℕ) : Irrational (x - m) :=\n h.sub_intCast m\ntheorem natCast_sub (h : Irrational x) (m : ℕ) : Irrational (m - x) :=\n h.intCast_sub m\ntheorem of_sub_natCast (m : ℕ) (h : Irrational (x - m)) : Irrational x :=\n h.of_sub_intCast m\ntheorem of_natCast_sub (m : ℕ) (h : Irrational (m - x)) : Irrational x :=\n h.of_intCast_sub m\n/-!\n#### Multiplication by rational numbers\n-/\n\n\ntheorem mul_cases : Irrational (x * y) → Irrational x ∨ Irrational y := by sorry\ntheorem of_mul_ratCast (h : Irrational (x * q)) : Irrational x :=\n h.mul_cases.resolve_right q.not_irrational\ntheorem mul_ratCast (h : Irrational x) {q : ℚ} (hq : q ≠ 0) : Irrational (x * q) :=\n of_mul_ratCast q⁻¹ <| by rwa [mul_assoc, ← cast_mul, mul_inv_cancel₀ hq, cast_one, mul_one]\ntheorem of_ratCast_mul : Irrational (q * x) → Irrational x :=\n mul_comm x q ▸ of_mul_ratCast q\ntheorem ratCast_mul (h : Irrational x) {q : ℚ} (hq : q ≠ 0) : Irrational (q * x) :=\n mul_comm x q ▸ h.mul_ratCast hq\ntheorem of_mul_intCast (m : ℤ) (h : Irrational (x * m)) : Irrational x :=\n of_mul_ratCast m <| by rwa [cast_intCast]\ntheorem of_intCast_mul (m : ℤ) (h : Irrational (m * x)) : Irrational x :=\n of_ratCast_mul m <| by rwa [cast_intCast]\ntheorem mul_intCast (h : Irrational x) {m : ℤ} (hm : m ≠ 0) : Irrational (x * m) := by sorry\ntheorem intCast_mul (h : Irrational x) {m : ℤ} (hm : m ≠ 0) : Irrational (m * x) :=\n mul_comm x m ▸ h.mul_intCast hm\ntheorem of_mul_natCast (m : ℕ) (h : Irrational (x * m)) : Irrational x :=\n h.of_mul_intCast m\ntheorem of_natCast_mul (m : ℕ) (h : Irrational (m * x)) : Irrational x :=\n h.of_intCast_mul m\ntheorem mul_natCast (h : Irrational x) {m : ℕ} (hm : m ≠ 0) : Irrational (x * m) :=\n h.mul_intCast <| Int.natCast_ne_zero.2 hm\ntheorem natCast_mul (h : Irrational x) {m : ℕ} (hm : m ≠ 0) : Irrational (m * x) :=\n h.intCast_mul <| Int.natCast_ne_zero.2 hm\n/-!\n#### Inverse\n-/\n\n\ntheorem of_inv (h : Irrational x⁻¹) : Irrational x := fun ⟨q, hq⟩ => h <| hq ▸ ⟨q⁻¹, q.cast_inv⟩\n\nprotected theorem inv (h : Irrational x) : Irrational x⁻¹ :=\n of_inv <| by rwa [inv_inv]\n\n/-!\n#### Division\n-/\n\n\ntheorem div_cases (h : Irrational (x / y)) : Irrational x ∨ Irrational y :=\n h.mul_cases.imp id of_inv\n\ntheorem of_ratCast_div (h : Irrational (q / x)) : Irrational x :=\n (h.of_ratCast_mul q).of_inv\ntheorem of_div_ratCast (h : Irrational (x / q)) : Irrational x :=\n h.div_cases.resolve_right q.not_irrational\ntheorem ratCast_div (h : Irrational x) {q : ℚ} (hq : q ≠ 0) : Irrational (q / x) :=\n h.inv.ratCast_mul hq\ntheorem div_ratCast (h : Irrational x) {q : ℚ} (hq : q ≠ 0) : Irrational (x / q) := by sorry\ntheorem of_intCast_div (m : ℤ) (h : Irrational (m / x)) : Irrational x :=\n h.div_cases.resolve_left m.not_irrational\ntheorem of_div_intCast (m : ℤ) (h : Irrational (x / m)) : Irrational x :=\n h.div_cases.resolve_right m.not_irrational\ntheorem intCast_div (h : Irrational x) {m : ℤ} (hm : m ≠ 0) : Irrational (m / x) :=\n h.inv.intCast_mul hm\ntheorem div_intCast (h : Irrational x) {m : ℤ} (hm : m ≠ 0) : Irrational (x / m) := by sorry\ntheorem of_natCast_div (m : ℕ) (h : Irrational (m / x)) : Irrational x :=\n h.of_intCast_div m\ntheorem of_div_natCast (m : ℕ) (h : Irrational (x / m)) : Irrational x :=\n h.of_div_intCast m\ntheorem natCast_div (h : Irrational x) {m : ℕ} (hm : m ≠ 0) : Irrational (m / x) :=\n h.inv.natCast_mul hm\ntheorem div_natCast (h : Irrational x) {m : ℕ} (hm : m ≠ 0) : Irrational (x / m) :=\n h.div_intCast <| by rwa [Int.natCast_ne_zero]\ntheorem of_one_div (h : Irrational (1 / x)) : Irrational x :=\n of_ratCast_div 1 <| by rwa [cast_one]\n\n/-!\n#### Natural and integer power\n-/\n\n\ntheorem of_mul_self (h : Irrational (x * x)) : Irrational x :=\n h.mul_cases.elim id id\n\ntheorem of_pow : ∀ n : ℕ, Irrational (x ^ n) → Irrational x := by sorry\nopen Int in\ntheorem of_zpow : ∀ m : ℤ, Irrational (x ^ m) → Irrational x := by sorry\nend Irrational\n\nsection Polynomial\n\nopen Polynomial\n\nvariable (x : ℝ) (p : ℤ[X])\n\ntheorem one_lt_natDegree_of_irrational_root (hx : Irrational x) (p_nonzero : p ≠ 0)\n (x_is_root : aeval x p = 0) : 1 < p.natDegree := by sorry\nend Polynomial\n\nsection\n\nvariable {q : ℚ} {m : ℤ} {n : ℕ} {x : ℝ}\n\nopen Irrational\n\n/-!\n### Simplification lemmas about operations\n-/\n\n\n@[simp]\ntheorem irrational_ratCast_add_iff : Irrational (q + x) ↔ Irrational x :=\n ⟨of_ratCast_add q, ratCast_add q⟩\n@[simp]\ntheorem irrational_intCast_add_iff : Irrational (m + x) ↔ Irrational x :=\n ⟨of_intCast_add m, fun h => h.intCast_add m⟩\n@[simp]\ntheorem irrational_natCast_add_iff : Irrational (n + x) ↔ Irrational x :=\n ⟨of_natCast_add n, fun h => h.natCast_add n⟩\n@[simp]\ntheorem irrational_add_ratCast_iff : Irrational (x + q) ↔ Irrational x :=\n ⟨of_add_ratCast q, add_ratCast q⟩\n@[simp]\ntheorem irrational_add_intCast_iff : Irrational (x + m) ↔ Irrational x :=\n ⟨of_add_intCast m, fun h => h.add_intCast m⟩\n@[simp]\ntheorem irrational_add_natCast_iff : Irrational (x + n) ↔ Irrational x :=\n ⟨of_add_natCast n, fun h => h.add_natCast n⟩\n@[simp]\ntheorem irrational_ratCast_sub_iff : Irrational (q - x) ↔ Irrational x :=\n ⟨of_ratCast_sub q, ratCast_sub q⟩\n@[simp]\ntheorem irrational_intCast_sub_iff : Irrational (m - x) ↔ Irrational x :=\n ⟨of_intCast_sub m, fun h => h.intCast_sub m⟩\n@[simp]\ntheorem irrational_natCast_sub_iff : Irrational (n - x) ↔ Irrational x :=\n ⟨of_natCast_sub n, fun h => h.natCast_sub n⟩\n@[simp]\ntheorem irrational_sub_ratCast_iff : Irrational (x - q) ↔ Irrational x :=\n ⟨of_sub_ratCast q, sub_ratCast q⟩\n@[simp]\ntheorem irrational_sub_intCast_iff : Irrational (x - m) ↔ Irrational x :=\n ⟨of_sub_intCast m, fun h => h.sub_intCast m⟩\n@[simp]\ntheorem irrational_sub_natCast_iff : Irrational (x - n) ↔ Irrational x :=\n ⟨of_sub_natCast n, fun h => h.sub_natCast n⟩\n@[simp]\ntheorem irrational_neg_iff : Irrational (-x) ↔ Irrational x :=\n ⟨of_neg, Irrational.neg⟩\n\n@[simp]\ntheorem irrational_inv_iff : Irrational x⁻¹ ↔ Irrational x :=\n ⟨of_inv, Irrational.inv⟩\n\n@[simp]\ntheorem irrational_ratCast_mul_iff : Irrational (q * x) ↔ q ≠ 0 ∧ Irrational x :=\n ⟨fun h => ⟨Rat.cast_ne_zero.1 <| left_ne_zero_of_mul h.ne_zero, h.of_ratCast_mul q⟩, fun h =>\n h.2.ratCast_mul h.1⟩\n@[simp]\ntheorem irrational_mul_ratCast_iff : Irrational (x * q) ↔ q ≠ 0 ∧ Irrational x := by sorry\ntheorem irrational_intCast_mul_iff : Irrational (m * x) ↔ m ≠ 0 ∧ Irrational x := by sorry\ntheorem irrational_mul_intCast_iff : Irrational (x * m) ↔ m ≠ 0 ∧ Irrational x := by sorry\ntheorem irrational_natCast_mul_iff : Irrational (n * x) ↔ n ≠ 0 ∧ Irrational x := by sorry\ntheorem irrational_mul_natCast_iff : Irrational (x * n) ↔ n ≠ 0 ∧ Irrational x := by sorry\ntheorem irrational_ratCast_div_iff : Irrational (q / x) ↔ q ≠ 0 ∧ Irrational x := by sorry\ntheorem irrational_div_ratCast_iff : Irrational (x / q) ↔ q ≠ 0 ∧ Irrational x := by sorry\ntheorem irrational_intCast_div_iff : Irrational (m / x) ↔ m ≠ 0 ∧ Irrational x := by sorry\ntheorem irrational_div_intCast_iff : Irrational (x / m) ↔ m ≠ 0 ∧ Irrational x := by sorry\ntheorem irrational_natCast_div_iff : Irrational (n / x) ↔ n ≠ 0 ∧ Irrational x := by sorry\ntheorem irrational_div_natCast_iff : Irrational (x / n) ↔ n ≠ 0 ∧ Irrational x := by sorry\ntheorem exists_irrational_btwn {x y : ℝ} (h : x < y) : ∃ r, Irrational r ∧ x < r ∧ r < y :=\n let ⟨q, ⟨hq1, hq2⟩⟩ := exists_rat_btwn ((sub_lt_sub_iff_right (√2)).mpr h)\n ⟨q + √2, irrational_sqrt_two.ratCast_add _, sub_lt_iff_lt_add.mp hq1, lt_sub_iff_add_lt.mp hq2⟩\n\nend\n" }, { "theorem_id": 17, "title": "001_the_irrationality_of_the_square_root_of_2", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From Coq Require Import ArithRing.\nFrom Coq Require Import Compare_dec.\nFrom Coq Require Import Wf_nat.\nFrom Coq Require Import Arith.\nFrom Coq Require Import Lia.\n \nTheorem minus_minus : forall a b c : nat, a - b - c = a - (b + c).\nProof.\nAdmitted.\n \nRemark expand_mult2 : forall x : nat, 2 * x = x + x.\nProof.\nAdmitted.\n \nTheorem lt_neq : forall x y : nat, x < y -> x <> y.\nProof.\nAdmitted.\n\n#[local] Hint Resolve lt_neq : core.\n \nTheorem monotonic_inverse :\n forall f : nat -> nat,\n (forall x y : nat, x < y -> f x < f y) ->\n forall x y : nat, f x < f y -> x < y.\nProof.\nAdmitted.\n \nTheorem mult_lt : forall a b c : nat, c <> 0 -> a < b -> a * c < b * c.\nProof.\nAdmitted.\n \nRemark add_sub_square_identity :\n forall a b : nat,\n (b + a - b) * (b + a - b) = (b + a) * (b + a) + b * b - 2 * ((b + a) * b).\nProof.\nAdmitted.\n \nTheorem sub_square_identity :\n forall a b : nat, b <= a -> (a - b) * (a - b) = a * a + b * b - 2 * (a * b).\nProof.\nAdmitted.\n \nTheorem square_monotonic : forall x y : nat, x < y -> x * x < y * y.\nProof.\nAdmitted.\n \nTheorem root_monotonic : forall x y : nat, x * x < y * y -> x < y.\nProof.\nAdmitted.\n \nRemark square_recompose : forall x y : nat, x * y * (x * y) = x * x * (y * y).\nProof.\nAdmitted.\n \nRemark mult2_recompose : forall x y : nat, x * (2 * y) = x * 2 * y.\nProof.\nAdmitted.\n\nSection sqrt2_decrease.\n\nVariables (p q : nat) (pos_q : 0 < q) (hyp_sqrt : p * p = 2 * (q * q)).\n \nTheorem sqrt_q_non_zero : 0 <> q * q.\nProof.\nAdmitted.\n\n#[local] Hint Resolve sqrt_q_non_zero : core.\n \nLtac solve_comparison :=\n apply root_monotonic; repeat rewrite square_recompose; rewrite hyp_sqrt;\n rewrite mult2_recompose; apply mult_lt; auto with arith.\n \nTheorem comparison1 : q < p.\nProof.\nAdmitted.\n \nTheorem comparison2 : 2 * p < 3 * q.\nProof.\nAdmitted.\n \nTheorem comparison3 : 4 * q < 3 * p.\nProof.\nAdmitted.\n\n#[local] Hint Resolve comparison1 comparison2 comparison3: arith.\n \nTheorem comparison4 : 3 * q - 2 * p < q.\nProof.\nAdmitted.\n \nRemark mult_minus_distr_l : forall a b c : nat, a * (b - c) = a * b - a * c.\nProof.\nAdmitted.\n \nRemark minus_eq_decompose :\n forall a b c d : nat, a = b -> c = d -> a - c = b - d.\nProof.\nAdmitted.\n \nTheorem new_equality :\n (3 * p - 4 * q) * (3 * p - 4 * q) = 2 * ((3 * q - 2 * p) * (3 * q - 2 * p)).\nProof.\nAdmitted.\n\nEnd sqrt2_decrease.\n\n#[local] Hint Resolve Nat.lt_le_incl comparison2: sqrt.\n \nTheorem sqrt2_not_rational :\n forall p q : nat, q <> 0 -> p * p = 2 * (q * q) -> False.\nProof.\nAdmitted." }, { "theorem_id": 18, "title": "002_the_fundamental_theorem_of_algebra", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";;\n\nprioritize_num();;\n\nlet nproduct = new_definition `nproduct = iterate ( * )`;;\n\nlet NPRODUCT_CLAUSES = `(!f. nproduct {} f = 1) /\\\n (!x f s. FINITE(s)\n ==> (nproduct (x INSERT s) f =\n if x IN s then nproduct s f else f(x) * nproduct s f))`;;\n\nlet NPRODUCT_EQ_1_EQ = `!s f. FINITE s ==> (nproduct s f = 1 <=> !x. x IN s ==> f(x) = 1)`;;\n\nlet NPRODUCT_SPLITOFF = `!x:A f s. FINITE s\n ==> nproduct s f =\n (if x IN s then f(x) else 1) * nproduct (s DELETE x) f`;;\n\nlet NPRODUCT_SPLITOFF_HACK = `!x:A f s. nproduct s f =\n if FINITE s then\n (if x IN s then f(x) else 1) * nproduct (s DELETE x) f\n else nproduct s f`;;\n\nlet NPRODUCT_EQ = `!f g s. FINITE s /\\ (!x. x IN s ==> f x = g x)\n ==> nproduct s f = nproduct s g`;;\n\nlet NPRODUCT_EQ_GEN = `!f g s t. FINITE s /\\ s = t /\\ (!x. x IN s ==> f x = g x)\n ==> nproduct s f = nproduct t g`;;\n\nlet PRIME_DIVIDES_NPRODUCT = `!p s f. prime p /\\ FINITE s /\\ p divides (nproduct s f)\n ==> ?x. x IN s /\\ p divides (f x)`;;\n\nlet NPRODUCT_CANCEL_PRIME = `!s p m f j.\n p EXP j * nproduct (s DELETE p) (\\p. p EXP (f p)) = p * m\n ==> prime p /\\ FINITE s /\\ (!x. x IN s ==> prime x)\n ==> ~(j = 0) /\\\n p EXP (j - 1) * nproduct (s DELETE p) (\\p. p EXP (f p)) = m`;;\n\nlet FTA = `!n. ~(n = 0)\n ==> ?!i. FINITE {p | ~(i p = 0)} /\\\n (!p. ~(i p = 0) ==> prime p) /\\\n n = nproduct {p | ~(i p = 0)} (\\p. p EXP (i p))`;;" }, { "theorem_id": 18, "title": "002_the_fundamental_theorem_of_algebra", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Fundamental Theorem of Algebra\\\n\ntheory Fundamental_Theorem_Algebra\nimports Polynomial Complex_Main\nbegin\n\nsubsection \\More lemmas about module of complex numbers\\\n\ntext \\The triangle inequality for cmod\\\n\nlemma complex_mod_triangle_sub: \"cmod w \\ cmod (w + z) + norm z\"\n by sorry\n\nsubsection \\Basic lemmas about polynomials\\\n\nlemma poly_bound_exists:\n fixes p :: \"'a::{comm_semiring_0,real_normed_div_algebra} poly\"\n shows \"\\m. m > 0 \\ (\\z. norm z \\ r \\ norm (poly p z) \\ m)\"\n by sorry\n\ntext \\Offsetting the variable in a polynomial gives another of same degree\\\n\ndefinition offset_poly :: \"'a::comm_semiring_0 poly \\ 'a \\ 'a poly\"\n where \"offset_poly p h = fold_coeffs (\\a q. smult h q + pCons a q) p 0\"\n\nlemma offset_poly_0: \"offset_poly 0 h = 0\"\n by sorry\n\nlemma offset_poly_pCons:\n \"offset_poly (pCons a p) h =\n smult h (offset_poly p h) + pCons a (offset_poly p h)\"\n by sorry\n\nlemma offset_poly_single [simp]: \"offset_poly [:a:] h = [:a:]\"\n by sorry\n\nlemma poly_offset_poly: \"poly (offset_poly p h) x = poly p (h + x)\"\n by sorry\n\nlemma offset_poly_eq_0_lemma: \"smult c p + pCons a p = 0 \\ p = 0\"\n by sorry\n\nlemma offset_poly_eq_0_iff [simp]: \"offset_poly p h = 0 \\ p = 0\"\n by sorry\n\nlemma degree_offset_poly [simp]: \"degree (offset_poly p h) = degree p\"\n by sorry\n\ndefinition \"psize p = (if p = 0 then 0 else Suc (degree p))\"\n\nlemma psize_eq_0_iff [simp]: \"psize p = 0 \\ p = 0\"\n by sorry\n\nlemma poly_offset:\n fixes p :: \"'a::comm_ring_1 poly\"\n shows \"\\q. psize q = psize p \\ (\\x. poly q x = poly p (a + x))\"\n by sorry\n\ntext \\An alternative useful formulation of completeness of the reals\\\nlemma real_sup_exists:\n assumes ex: \"\\x. P x\"\n and bz: \"\\z. \\x. P x \\ x < z\"\n shows \"\\s::real. \\y. (\\x. P x \\ y < x) \\ y < s\"\n by sorry\n\nsubsection \\Fundamental theorem of algebra\\\n\nlemma unimodular_reduce_norm:\n assumes md: \"cmod z = 1\"\n shows \"cmod (z + 1) < 1 \\ cmod (z - 1) < 1 \\ cmod (z + \\) < 1 \\ cmod (z - \\) < 1\"\n by sorry\n\ntext \\Hence we can always reduce modulus of \\1 + b z^n\\ if nonzero\\\nlemma reduce_poly_simple:\n assumes b: \"b \\ 0\"\n and n: \"n \\ 0\"\n shows \"\\z. cmod (1 + b * z^n) < 1\"\n by sorry\n\ntext \\Bolzano-Weierstrass type property for closed disc in complex plane.\\\n\nlemma metric_bound_lemma: \"cmod (x - y) \\ \\Re x - Re y\\ + \\Im x - Im y\\\"\n by sorry\n\nlemma Bolzano_Weierstrass_complex_disc:\n assumes r: \"\\n. cmod (s n) \\ r\"\n shows \"\\f z. strict_mono (f :: nat \\ nat) \\ (\\e >0. \\N. \\n \\ N. cmod (s (f n) - z) < e)\"\n by sorry\n\ntext \\Polynomial is continuous.\\\n\nlemma poly_cont:\n fixes p :: \"'a::{comm_semiring_0,real_normed_div_algebra} poly\"\n assumes ep: \"e > 0\"\n shows \"\\d >0. \\w. 0 < norm (w - z) \\ norm (w - z) < d \\ norm (poly p w - poly p z) < e\"\n by sorry\n\ntext \\Hence a polynomial attains minimum on a closed disc\n in the complex plane.\\\nlemma poly_minimum_modulus_disc: \"\\z. \\w. cmod w \\ r \\ cmod (poly p z) \\ cmod (poly p w)\"\n by sorry\n\ntext \\Nonzero polynomial in z goes to infinity as z does.\\\n\nlemma poly_infinity:\n fixes p:: \"'a::{comm_semiring_0,real_normed_div_algebra} poly\"\n assumes ex: \"p \\ 0\"\n shows \"\\r. \\z. r \\ norm z \\ d \\ norm (poly (pCons a p) z)\"\n by sorry\n\ntext \\Hence polynomial's modulus attains its minimum somewhere.\\\nlemma poly_minimum_modulus: \"\\z.\\w. cmod (poly p z) \\ cmod (poly p w)\"\n by sorry\n\ntext \\Constant function (non-syntactic characterization).\\\ndefinition \"constant f \\ (\\x y. f x = f y)\"\n\nlemma nonconstant_length: \"\\ constant (poly p) \\ psize p \\ 2\"\n by sorry\n\nlemma poly_replicate_append: \"poly (monom 1 n * p) (x::'a::comm_ring_1) = x^n * poly p x\"\n by sorry\n\ntext \\Decomposition of polynomial, skipping zero coefficients after the first.\\\n\nlemma poly_decompose_lemma:\n assumes nz: \"\\ (\\z. z \\ 0 \\ poly p z = (0::'a::idom))\"\n shows \"\\k a q. a \\ 0 \\ Suc (psize q + k) = psize p \\ (\\z. poly p z = z^k * poly (pCons a q) z)\"\n by sorry\n\nlemma poly_decompose:\n fixes p :: \"'a::idom poly\"\n assumes nc: \"\\ constant (poly p)\"\n shows \"\\k a q. a \\ 0 \\ k \\ 0 \\\n psize q + k + 1 = psize p \\\n (\\z. poly p z = poly p 0 + z^k * poly (pCons a q) z)\" \n by sorry\n\ntext \\Fundamental theorem of algebra\\\n\ntheorem fundamental_theorem_of_algebra:\n assumes nc: \"\\ constant (poly p)\"\n shows \"\\z::complex. poly p z = 0\"\n by sorry\n\ntext \\Alternative version with a syntactic notion of constant polynomial.\\\n\nlemma fundamental_theorem_of_algebra_alt:\n assumes nc: \"\\ (\\a l. a \\ 0 \\ l = 0 \\ p = pCons a l)\"\n shows \"\\z. poly p z = (0::complex)\"\n by sorry\n\nsubsection \\Nullstellensatz, degrees and divisibility of polynomials\\\n\nlemma nullstellensatz_lemma:\n fixes p :: \"complex poly\"\n assumes \"\\x. poly p x = 0 \\ poly q x = 0\"\n and \"degree p = n\"\n and \"n \\ 0\"\n shows \"p dvd (q ^ n)\"\n by sorry\n\nlemma nullstellensatz_univariate:\n \"(\\x. poly p x = (0::complex) \\ poly q x = 0) \\\n p dvd (q ^ (degree p)) \\ (p = 0 \\ q = 0)\"\n by sorry\n\ntext \\Useful lemma\\\nlemma constant_degree:\n fixes p :: \"'a::{idom,ring_char_0} poly\"\n shows \"constant (poly p) \\ degree p = 0\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma complex_poly_decompose:\n \"smult (lead_coeff p) (\\z|poly p z = 0. [:-z, 1:] ^ order z p) = (p :: complex poly)\"\n by sorry\n\ninstance complex :: alg_closed_field\n by standard (use fundamental_theorem_of_algebra constant_degree neq0_conv in blast)\n\nlemma size_proots_complex: \"size (proots (p :: complex poly)) = degree p\"\n by sorry\n\nlemma complex_poly_decompose_multiset:\n \"smult (lead_coeff p) (\\x\\#proots p. [:-x, 1:]) = (p :: complex poly)\"\n by sorry\n\nlemma complex_poly_decompose':\n obtains root where \"smult (lead_coeff p) (\\iz|poly p z = 0. [:-z, 1:]) = (p :: complex poly)\"\n by sorry\n\ntext \\Arithmetic operations on multivariate polynomials.\\\n\nlemma mpoly_base_conv:\n fixes x :: \"'a::comm_ring_1\"\n shows \"0 = poly 0 x\" \"c = poly [:c:] x\" \"x = poly [:0,1:] x\"\n by sorry\n\nlemma mpoly_norm_conv:\n fixes x :: \"'a::comm_ring_1\"\n shows \"poly [:0:] x = poly 0 x\" \"poly [:poly 0 y:] x = poly 0 x\"\n by sorry\n\nlemma mpoly_sub_conv:\n fixes x :: \"'a::comm_ring_1\"\n shows \"poly p x - poly q x = poly p x + -1 * poly q x\"\n by sorry\n\nlemma poly_pad_rule: \"poly p x = 0 \\ poly (pCons 0 p) x = 0\"\n by sorry\n\nlemma poly_cancel_eq_conv:\n fixes x :: \"'a::field\"\n shows \"x = 0 \\ a \\ 0 \\ y = 0 \\ a * y - b * x = 0\"\n by sorry\n\nlemma poly_divides_pad_rule:\n fixes p:: \"('a::comm_ring_1) poly\"\n assumes pq: \"p dvd q\"\n shows \"p dvd (pCons 0 q)\"\n by sorry\n\nlemma poly_divides_conv0:\n fixes p:: \"'a::field poly\"\n assumes lgpq: \"degree q < degree p\" and lq: \"p \\ 0\"\n shows \"p dvd q \\ q = 0\"\n by sorry\n\nlemma poly_divides_conv1:\n fixes p :: \"'a::field poly\"\n assumes a0: \"a \\ 0\"\n and pp': \"p dvd p'\"\n and qrp': \"smult a q - p' = r\"\n shows \"p dvd q \\ p dvd r\"\n by sorry\n\nlemma basic_cqe_conv1:\n \"(\\x. poly p x = 0 \\ poly 0 x \\ 0) \\ False\"\n \"(\\x. poly 0 x \\ 0) \\ False\"\n \"(\\x. poly [:c:] x \\ 0) \\ c \\ 0\"\n \"(\\x. poly 0 x = 0) \\ True\"\n \"(\\x. poly [:c:] x = 0) \\ c = 0\"\n by sorry\n\nlemma basic_cqe_conv2:\n assumes l: \"p \\ 0\"\n shows \"\\x. poly (pCons a (pCons b p)) x = (0::complex)\"\n by sorry\n\nlemma basic_cqe_conv_2b: \"(\\x. poly p x \\ (0::complex)) \\ p \\ 0\"\n by sorry\n\nlemma basic_cqe_conv3:\n fixes p q :: \"complex poly\"\n assumes l: \"p \\ 0\"\n shows \"(\\x. poly (pCons a p) x = 0 \\ poly q x \\ 0) \\ \\ (pCons a p) dvd (q ^ psize p)\"\n by sorry\n\nlemma basic_cqe_conv4:\n fixes p q :: \"complex poly\"\n assumes h: \"\\x. poly (q ^ n) x = poly r x\"\n shows \"p dvd (q ^ n) \\ p dvd r\"\n by sorry\n\nlemma poly_const_conv:\n fixes x :: \"'a::comm_ring_1\"\n shows \"poly [:c:] x = y \\ c = y\"\n by sorry\n\nend" }, { "theorem_id": 18, "title": "002_the_fundamental_theorem_of_algebra", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2019 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Junyan Xu, Yury Kudryashov\n-/\nmodule\n\npublic import Mathlib.Analysis.Calculus.Deriv.Polynomial\npublic import Mathlib.Analysis.Complex.Liouville\npublic import Mathlib.FieldTheory.PolynomialGaloisGroup\npublic import Mathlib.LinearAlgebra.Complex.FiniteDimensional\npublic import Mathlib.Topology.Algebra.Polynomial\n\n/-!\n# The fundamental theorem of algebra\n\nThis file proves that every nonconstant complex polynomial has a root using Liouville's theorem.\n\nAs a consequence, the complex numbers are algebraically closed.\n\nWe also provide some specific results about the Galois groups of ℚ-polynomials with specific numbers\nof non-real roots.\n\nWe also show that an irreducible real polynomial has degree at most two.\n-/\n\n@[expose] public section\n\nopen Polynomial Bornology Complex\n\nopen scoped ComplexConjugate\n\nnamespace Complex\n\n/-- **Fundamental theorem of algebra**: every nonconstant complex polynomial\n has a root. -/\ntheorem exists_root {f : ℂ[X]} (hf : 0 < degree f) : ∃ z : ℂ, IsRoot f z := by sorry\ninstance isAlgClosed : IsAlgClosed ℂ :=\n IsAlgClosed.of_exists_root _ fun _p _ hp => Complex.exists_root <| degree_pos_of_irreducible hp\n\nend Complex\n\n/-- An algebraic extension of ℝ is isomorphic to either ℝ or ℂ as an ℝ-algebra. -/\ntheorem Real.nonempty_algEquiv_or (F : Type*) [Field F] [Algebra ℝ F] [Algebra.IsAlgebraic ℝ F] :\n Nonempty (F ≃ₐ[ℝ] ℝ) ∨ Nonempty (F ≃ₐ[ℝ] ℂ) :=\n IsAlgClosed.nonempty_algEquiv_or_of_finrank_eq_two F Complex.finrank_real_complex\n\nnamespace Polynomial.Gal\n\nsection Rationals\n\ntheorem splits_ℚ_ℂ {p : ℚ[X]} : Fact ((p.map (algebraMap ℚ ℂ)).Splits) :=\n ⟨IsAlgClosed.splits _⟩\n\nattribute [local instance] splits_ℚ_ℂ\nattribute [local ext] Complex.ext\n\n/-- The number of complex roots equals the number of real roots plus\nthe number of roots not fixed by complex conjugation (i.e. with some imaginary component). -/\ntheorem card_complex_roots_eq_card_real_add_card_not_gal_inv (p : ℚ[X]) :\n (p.rootSet ℂ).toFinset.card =\n (p.rootSet ℝ).toFinset.card +\n (galActionHom p ℂ (restrict p ℂ\n (AlgEquiv.restrictScalars ℚ Complex.conjAe))).support.card := by sorry\ntheorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)\n (p_deg : p.natDegree.Prime)\n (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :\n Function.Bijective (galActionHom p ℂ) := by sorry\ntheorem galActionHom_bijective_of_prime_degree' {p : ℚ[X]} (p_irr : Irreducible p)\n (p_deg : p.natDegree.Prime)\n (p_roots1 : Fintype.card (p.rootSet ℝ) + 1 ≤ Fintype.card (p.rootSet ℂ))\n (p_roots2 : Fintype.card (p.rootSet ℂ) ≤ Fintype.card (p.rootSet ℝ) + 3) :\n Function.Bijective (galActionHom p ℂ) := by sorry\nend Rationals\n\nend Polynomial.Gal\n\nlemma Polynomial.mul_star_dvd_of_aeval_eq_zero_im_ne_zero (p : ℝ[X]) {z : ℂ} (h0 : aeval z p = 0)\n (hz : z.im ≠ 0) : (X - C ((starRingEnd ℂ) z)) * (X - C z) ∣ map (algebraMap ℝ ℂ) p := by sorry\nlemma Polynomial.quadratic_dvd_of_aeval_eq_zero_im_ne_zero (p : ℝ[X]) {z : ℂ} (h0 : aeval z p = 0)\n (hz : z.im ≠ 0) : X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2) ∣ p := by sorry\nlemma Irreducible.natDegree_le_two {p : ℝ[X]} (hp : Irreducible p) : natDegree p ≤ 2 := by sorry\nlemma Irreducible.degree_le_two {p : ℝ[X]} (hp : Irreducible p) : degree p ≤ 2 :=\n natDegree_le_iff_degree_le.1 hp.natDegree_le_two\n" }, { "theorem_id": 18, "title": "002_the_fundamental_theorem_of_algebra", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Export CoRN.fta.CPoly_Rev.\nRequire Export CoRN.fta.FTAreg.\nImport CRing_Homomorphisms.coercions." }, { "theorem_id": 19, "title": "003_the_denumerability_of_the_rational_numbers", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/card.ml\";;\n\nprioritize_real();;\n\nlet rational = new_definition\n `rational(r) <=> ?p q. ~(q = 0) /\\ (abs(r) = &p / &q)`;;\n\nlet countable = new_definition\n `countable s <=> s <=_c (UNIV:num->bool)`;;\n\nlet COUNTABLE_RATIONALS = `countable { x:real | rational(x)}`;;\n\nlet denumerable = new_definition\n `denumerable s <=> s =_c (UNIV:num->bool)`;;\n\nlet DENUMERABLE_RATIONALS = `denumerable { x:real | rational(x)}`;;\n\nlet DENUMERABLE_RATIONALS_EXPAND = `?rat:num->real. (!n. rational(rat n)) /\\\n (!x. rational x ==> ?!n. x = rat n)`;;" }, { "theorem_id": 19, "title": "003_the_denumerability_of_the_rational_numbers", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Encoding (almost) everything into natural numbers\\\n\ntheory Countable\nimports Old_Datatype HOL.Rat Nat_Bijection\nbegin\n\nsubsection \\The class of countable types\\\n\nclass countable =\n assumes ex_inj: \"\\to_nat :: 'a \\ nat. inj to_nat\"\n\nlemma countable_classI:\n fixes f :: \"'a \\ nat\"\n assumes \"\\x y. f x = f y \\ x = y\"\n shows \"OFCLASS('a, countable_class)\"\n by sorry\n\nsubsection \\Conversion functions\\\n\ndefinition to_nat :: \"'a::countable \\ nat\" where\n \"to_nat = (SOME f. inj f)\"\n\ndefinition from_nat :: \"nat \\ 'a::countable\" where\n \"from_nat = inv (to_nat :: 'a \\ nat)\"\n\nlemma inj_to_nat [simp]: \"inj to_nat\"\n by sorry\n\nlemma inj_on_to_nat[simp, intro]: \"inj_on to_nat S\"\n by sorry\n\nlemma surj_from_nat [simp]: \"surj from_nat\"\n by sorry\n\nlemma to_nat_split [simp]: \"to_nat x = to_nat y \\ x = y\"\n by sorry\n\nlemma from_nat_to_nat [simp]:\n \"from_nat (to_nat x) = x\"\n by sorry\n\nsubsection \\Finite types are countable\\\n\nsubclass (in finite) countable\nproof\n obtain n and f :: \"nat \\ 'a\"\n where \"UNIV = f ` {i. i < n}\" \n by (metis finite_conv_nat_seg_image local.finite)\n then show \"\\to_nat :: 'a \\ nat. inj to_nat\" \n by (meson finite_imp_inj_to_nat_seg local.finite)\nqed\n\nsubsection \\Automatically proving countability of old-style datatypes\\\n\ncontext\nbegin\n\nqualified inductive finite_item :: \"'a Old_Datatype.item \\ bool\" where\n undefined: \"finite_item undefined\"\n| In0: \"finite_item x \\ finite_item (Old_Datatype.In0 x)\"\n| In1: \"finite_item x \\ finite_item (Old_Datatype.In1 x)\"\n| Leaf: \"finite_item (Old_Datatype.Leaf a)\"\n| Scons: \"\\finite_item x; finite_item y\\ \\ finite_item (Old_Datatype.Scons x y)\"\n\nqualified function nth_item :: \"nat \\ ('a::countable) Old_Datatype.item\"\nwhere\n \"nth_item 0 = undefined\"\n| \"nth_item (Suc n) =\n (case sum_decode n of\n Inl i \\\n (case sum_decode i of\n Inl j \\ Old_Datatype.In0 (nth_item j)\n | Inr j \\ Old_Datatype.In1 (nth_item j))\n | Inr i \\\n (case sum_decode i of\n Inl j \\ Old_Datatype.Leaf (from_nat j)\n | Inr j \\\n (case prod_decode j of\n (a, b) \\ Old_Datatype.Scons (nth_item a) (nth_item b))))\"\nby pat_completeness auto\n\nlemma le_sum_encode_Inl: \"x \\ y \\ x \\ sum_encode (Inl y)\"\n by sorry\n\nlemma le_sum_encode_Inr: \"x \\ y \\ x \\ sum_encode (Inr y)\"\n by sorry\n\nqualified termination\nby (relation \"measure id\")\n (auto simp flip: sum_encode_eq prod_encode_eq\n simp: le_imp_less_Suc le_sum_encode_Inl le_sum_encode_Inr\n le_prod_encode_1 le_prod_encode_2)\n\nlemma nth_item_covers: \"finite_item x \\ \\n. nth_item n = x\"\n by sorry\n\ntheorem countable_datatype:\n fixes Rep :: \"'b \\ ('a::countable) Old_Datatype.item\"\n fixes Abs :: \"('a::countable) Old_Datatype.item \\ 'b\"\n fixes rep_set :: \"('a::countable) Old_Datatype.item \\ bool\"\n assumes type: \"type_definition Rep Abs (Collect rep_set)\"\n assumes finite_item: \"\\x. rep_set x \\ finite_item x\"\n shows \"OFCLASS('b, countable_class)\"\n by sorry\n\nML \\\n fun old_countable_datatype_tac ctxt =\n SUBGOAL (fn (goal, _) =>\n let\n val ty_name =\n (case goal of\n (_ $ Const (\\<^const_name>\\Pure.type\\, Type (\\<^type_name>\\itself\\, [Type (n, _)]))) => n\n | _ => raise Match)\n val typedef_info = hd (Typedef.get_info ctxt ty_name)\n val typedef_thm = #type_definition (snd typedef_info)\n val pred_name =\n (case HOLogic.dest_Trueprop (Thm.concl_of typedef_thm) of\n (_ $ _ $ _ $ (_ $ Const (n, _))) => n\n | _ => raise Match)\n val induct_info = Inductive.the_inductive_global ctxt pred_name\n val pred_names = #names (fst induct_info)\n val induct_thms = #inducts (snd induct_info)\n val alist = pred_names ~~ induct_thms\n val induct_thm = the (AList.lookup (op =) alist pred_name)\n val vars = rev (Term.add_vars (Thm.prop_of induct_thm) [])\n val insts = vars |> map (fn (_, T) => try (Thm.cterm_of ctxt)\n (Const (\\<^const_name>\\Countable.finite_item\\, T)))\n val induct_thm' = Thm.instantiate' [] insts induct_thm\n val rules = @{thms finite_item.intros}\n in\n SOLVED' (fn i => EVERY\n [resolve_tac ctxt @{thms countable_datatype} i,\n resolve_tac ctxt [typedef_thm] i,\n eresolve_tac ctxt [induct_thm'] i,\n REPEAT (resolve_tac ctxt rules i ORELSE assume_tac ctxt i)]) 1\n end)\n\\\n\nend\n\nsubsection \\Automatically proving countability of datatypes\\\n\nML_file \\../Tools/BNF/bnf_lfp_countable.ML\\\n\nML \\\nfun countable_datatype_tac ctxt st =\n (case \\<^try>\\HEADGOAL (old_countable_datatype_tac ctxt) st\\ of\n SOME res => res\n | NONE => BNF_LFP_Countable.countable_datatype_tac ctxt st);\n\nfun countable_tac ctxt =\n SELECT_GOAL (countable_datatype_tac ctxt);\n\\\n\nmethod_setup countable_datatype = \\\n Scan.succeed (SIMPLE_METHOD o countable_datatype_tac)\n\\ \"prove countable class instances for datatypes\"\n\nsubsection \\More Countable types\\\n\ntext \\Naturals\\\n\ninstance nat :: countable\n by (rule countable_classI [of \"id\"]) simp\n\ntext \\Pairs\\\n\ninstance prod :: (countable, countable) countable\n by (rule countable_classI [of \"\\(x, y). prod_encode (to_nat x, to_nat y)\"])\n (auto simp add: prod_encode_eq)\n\ntext \\Sums\\\n\ninstance sum :: (countable, countable) countable\n by (rule countable_classI [of \"(\\x. case x of Inl a \\ to_nat (False, to_nat a)\n | Inr b \\ to_nat (True, to_nat b))\"])\n (simp split: sum.split_asm)\n\ntext \\Integers\\\n\ninstance int :: countable\n by (rule countable_classI [of int_encode]) (simp add: int_encode_eq)\n\ntext \\Options\\\n\ninstance option :: (countable) countable\n by countable_datatype\n\ntext \\Lists\\\n\ninstance list :: (countable) countable\n by countable_datatype\n\ntext \\String literals\\\n\ninstance String.literal :: countable\n by (rule countable_classI [of \"to_nat \\ String.explode\"]) (simp add: String.explode_inject)\n\ntext \\Functions\\\n\ninstance \"fun\" :: (finite, countable) countable\nproof\n obtain xs :: \"'a list\" where xs: \"set xs = UNIV\"\n using finite_list [OF finite_UNIV] ..\n show \"\\to_nat::('a \\ 'b) \\ nat. inj to_nat\"\n proof\n show \"inj (\\f. to_nat (map f xs))\"\n by (metis (no_types, lifting) ext UNIV_I injI map_eq_conv to_nat_split xs)\n qed\nqed\n\ntext \\Typereps\\\n\ninstance typerep :: countable\n by countable_datatype\n\nsubsection \\The rationals are countably infinite\\\n\ndefinition nat_to_rat_surj :: \"nat \\ rat\" where\n \"nat_to_rat_surj n = (let (a, b) = prod_decode n in Fract (int_decode a) (int_decode b))\"\n\nlemma surj_nat_to_rat_surj: \"surj nat_to_rat_surj\"\n by sorry\n\nlemma Rats_eq_range_nat_to_rat_surj: \"\\ = range nat_to_rat_surj\"\n by sorry\n\ncontext field_char_0\nbegin\n\nlemma Rats_eq_range_of_rat_o_nat_to_rat_surj:\n \"\\ = range (of_rat \\ nat_to_rat_surj)\"\n by sorry\n\nlemma surj_of_rat_nat_to_rat_surj:\n \"r \\ \\ \\ \\n. r = of_rat (nat_to_rat_surj n)\"\n by sorry\n\nend\n\ninstance rat :: countable\nproof\n show \"\\to_nat::rat \\ nat. inj to_nat\"\n using surj_imp_inj_inv surj_nat_to_rat_surj by blast\nqed\n\ntheorem rat_denum: \"\\f :: nat \\ rat. surj f\"\n by sorry\n\nend" }, { "theorem_id": 19, "title": "003_the_denumerability_of_the_rational_numbers", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2019 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nmodule\n\npublic import Mathlib.Algebra.Ring.Rat\npublic import Mathlib.Data.Rat.Encodable\npublic import Mathlib.Algebra.CharZero.Infinite\npublic import Mathlib.Logic.Denumerable\n\n/-!\n# Denumerability of ℚ\n\nThis file proves that ℚ is denumerable.\n\nThe fact that ℚ has cardinality ℵ₀ is proved in `Mathlib/Data/Rat/Cardinal.lean`\n-/\n\n@[expose] public section\n\nassert_not_exists Module Field\n\nnamespace Rat\n\nopen Denumerable\n\n/-- **Denumerability of the Rational Numbers** -/\ninstance instDenumerable : Denumerable ℚ := ofEncodableOfInfinite ℚ\n\nend Rat\n" }, { "theorem_id": 19, "title": "003_the_denumerability_of_the_rational_numbers", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Definition identity (A:Type) := fun (a:A) => a.\nDefinition compose (A B C:Type) (g:B->C) (f:A->B) := fun (a:A) => g(f a).\n\nSection Denumerability.\n\nDefinition same_cardinality (A:Type) (B:Type) :=\n {f:A->B & { g:B->A | \n (forall b,(compose _ _ _ f g) b = (identity B) b) /\\\n forall a,(compose _ _ _ g f) a = (identity A) a}}.\n\nDefinition is_denumerable A := same_cardinality A nat.\n\nLemma same_cardinality_transitive :\n forall A B C, same_cardinality A B -> same_cardinality B C -> same_cardinality A C.\nProof.\nAdmitted.\n\nLemma is_denumerable_transitive :\n forall A B, is_denumerable A -> same_cardinality B A -> is_denumerable B.\nProof.\nAdmitted.\n\nEnd Denumerability.\n\nFrom Coq Require Import ZArith.\nFrom Coq Require Import Lia.\n\nDefinition Z_to_nat_i (z:Z) :nat :=\n match z with \n | Z0 => O\n | Zpos p => Nat.double (nat_of_P p)\n | Zneg p => pred (Nat.double (nat_of_P p))\n end.\n\nLemma odd_pred2n: forall n : nat, Nat.\nProof.\nAdmitted.\n\nLemma even_2n : forall n : nat, Nat.\nProof.\nAdmitted.\n\nLemma even_odd_exists_dec : forall n, {p : nat | n = Nat.\nProof.\nAdmitted.\n\nDefinition nat_to_Z_i (n:nat) := \n match even_odd_exists_dec n with\n | inl s => let (k, _) := s in Z_of_nat k\n | inr s => let (k, _) := s in Z.opp (Z_of_nat k)\n end.\n\nLemma double_eq_half_eq:forall m n, Nat.\nProof.\nAdmitted.\n\nLemma parity_mismatch_not_eq:forall m n, Nat.\nProof.\nAdmitted.\n\nLemma even_double : forall n, Nat.\nProof.\nAdmitted.\n\nLemma double_S_neq_pred:forall m n, ~Nat.\nProof.\nAdmitted.\n\nLemma eq_add_pred : forall n m : nat, pred n = pred m -> {n = m} + {n < 2 /\\ m < 2}.\nProof.\nAdmitted.\n\nLemma nat_to_Z_to_nat_i : forall (z:Z), nat_to_Z_i (Z_to_nat_i z) = z.\nProof.\nAdmitted.\n\nLemma Z_to_nat_to_Z_i : forall (n:nat), Z_to_nat_i (nat_to_Z_i n) = n.\nProof.\nAdmitted. \n\nTheorem Z_is_denumerable:is_denumerable Z.\nProof.\nAdmitted.\n\nFrom QArithSternBrocot Require Import Q_field.\n\nFixpoint positive_to_Qpositive_i (p:positive) : Qpositive := \n match p with \n | xI p => nR (positive_to_Qpositive_i p)\n | xO p => dL (positive_to_Qpositive_i p)\n | xH => One\n end. \n\nDefinition Z_to_Q_i (z:Z) :=\n match z with \n | Z0 => Zero\n | Zpos p => Qpos (positive_to_Qpositive_i p)\n | Zneg p => Qneg (positive_to_Qpositive_i p)\n end. \n\nFixpoint Qpositive_to_positive_i (qp:Qpositive) : positive := \n match qp with \n | nR qp => xI (Qpositive_to_positive_i qp)\n | dL qp => xO (Qpositive_to_positive_i qp)\n | One => xH\n end. \n\nDefinition Q_to_Z_i (q:Q) :=\n match q with \n | Zero => Z0\n | Qpos qp => Zpos (Qpositive_to_positive_i qp)\n | Qneg qp => Zneg (Qpositive_to_positive_i qp)\n end. \n\nLemma Qpositive_to_positive_to_Qpositive_i : forall (p:positive), Qpositive_to_positive_i (positive_to_Qpositive_i p) = p.\nProof.\nAdmitted.\n\nLemma positive_to_Qpositive_to_positive_i : forall qp, positive_to_Qpositive_i (Qpositive_to_positive_i qp) = qp.\nProof.\nAdmitted.\n\nLemma Q_to_Z_to_Q_i : forall (z:Z), Q_to_Z_i (Z_to_Q_i z) = z.\nProof.\nAdmitted.\n\nLemma Z_to_Q_to_Z_i : forall (q:Q), Z_to_Q_i (Q_to_Z_i q) = q.\nProof.\nAdmitted.\n\nTheorem Q_is_denumerable: is_denumerable Q.\nProof.\nAdmitted." }, { "theorem_id": 20, "title": "004_pythagorean_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/misc.ml\";;\nneeds \"Multivariate/vectors.ml\";;\n\nlet PYTHAGORAS = `!A B C:real^2.\n orthogonal (A - B) (C - B)\n ==> norm(C - A) pow 2 = norm(B - A) pow 2 + norm(C - B) pow 2`;;\n\nlet PYTHAGORAS = `!A B C:real^2.\n orthogonal (A - B) (C - B)\n ==> norm(C - A) pow 2 = norm(B - A) pow 2 + norm(C - B) pow 2`;;" }, { "theorem_id": 20, "title": "004_pythagorean_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Finite-Dimensional Inner Product Spaces\\\n\ntheory Euclidean_Space\nimports\n L2_Norm\n Inner_Product\n Product_Vector\nbegin\n\nsubsection\\<^marker>\\tag unimportant\\ \\Interlude: Some properties of real sets\\\n\nlemma seq_mono_lemma:\n assumes \"\\(n::nat) \\ m. (d n :: real) < e n\"\n and \"\\n \\ m. e n \\ e m\"\n shows \"\\n \\ m. d n < e m\"\n by sorry\n\nsubsection \\Type class of Euclidean spaces\\\n\nclass euclidean_space = real_inner +\n fixes Basis :: \"'a set\"\n assumes nonempty_Basis [simp]: \"Basis \\ {}\"\n assumes finite_Basis [simp]: \"finite Basis\"\n assumes inner_Basis:\n \"\\u \\ Basis; v \\ Basis\\ \\ inner u v = (if u = v then 1 else 0)\"\n assumes euclidean_all_zero_iff:\n \"(\\u\\Basis. inner x u = 0) \\ (x = 0)\"\n\nsyntax \"_type_dimension\" :: \"type \\ nat\" (\\(\\indent=1 notation=\\mixfix type dimension\\\\DIM/(1'(_')))\\)\nsyntax_consts \"_type_dimension\" \\ card\ntranslations \"DIM('a)\" \\ \"CONST card (CONST Basis :: 'a set)\"\ntyped_print_translation \\\n [(\\<^const_syntax>\\card\\,\n fn ctxt => fn _ => fn [Const (\\<^const_syntax>\\Basis\\, Type (\\<^type_name>\\set\\, [T]))] =>\n Syntax.const \\<^syntax_const>\\_type_dimension\\ $ Syntax_Phases.term_of_typ ctxt T)]\n\\\n\nlemma (in euclidean_space) norm_Basis[simp]: \"u \\ Basis \\ norm u = 1\"\n by sorry\n\nlemma (in euclidean_space) inner_same_Basis[simp]: \"u \\ Basis \\ inner u u = 1\"\n by sorry\n\nlemma (in euclidean_space) inner_not_same_Basis: \"u \\ Basis \\ v \\ Basis \\ u \\ v \\ inner u v = 0\"\n by sorry\n\nlemma (in euclidean_space) sgn_Basis: \"u \\ Basis \\ sgn u = u\"\n by sorry\n\nlemma inner_sum_Basis[simp]: \"i \\ Basis \\ inner (\\Basis) i = 1\"\n by sorry\n\nlemma (in euclidean_space) Basis_zero [simp]: \"0 \\ Basis\"\n by sorry\n\nlemma (in euclidean_space) nonzero_Basis: \"u \\ Basis \\ u \\ 0\"\n by sorry\n\nlemma (in euclidean_space) SOME_Basis: \"(SOME i. i \\ Basis) \\ Basis\"\n by sorry\n\nlemma norm_some_Basis [simp]: \"norm (SOME i. i \\ Basis) = 1\"\n by sorry\n\nlemma (in euclidean_space) inner_sum_left_Basis[simp]:\n \"b \\ Basis \\ inner (\\i\\Basis. f i *\\<^sub>R i) b = f b\"\n by sorry\n\nlemma (in euclidean_space) euclidean_eqI:\n assumes b: \"\\b. b \\ Basis \\ inner x b = inner y b\" shows \"x = y\"\n by sorry\n\nlemma (in euclidean_space) euclidean_eq_iff:\n \"x = y \\ (\\b\\Basis. inner x b = inner y b)\"\n by sorry\n\nlemma (in euclidean_space) euclidean_representation_sum:\n \"(\\i\\Basis. f i *\\<^sub>R i) = b \\ (\\i\\Basis. f i = inner b i)\"\n by sorry\n\nlemma (in euclidean_space) euclidean_representation_sum':\n \"b = (\\i\\Basis. f i *\\<^sub>R i) \\ (\\i\\Basis. f i = inner b i)\"\n by sorry\n\nlemma (in euclidean_space) euclidean_representation: \"(\\b\\Basis. inner x b *\\<^sub>R b) = x\"\n by sorry\n\nlemma (in euclidean_space) euclidean_inner: \"inner x y = (\\b\\Basis. (inner x b) * (inner y b))\"\n by sorry\n\nlemma (in euclidean_space) choice_Basis_iff:\n fixes P :: \"'a \\ real \\ bool\"\n shows \"(\\i\\Basis. \\x. P i x) \\ (\\x. \\i\\Basis. P i (inner x i))\"\n by sorry\n\nlemma (in euclidean_space) bchoice_Basis_iff:\n fixes P :: \"'a \\ real \\ bool\"\n shows \"(\\i\\Basis. \\x\\A. P i x) \\ (\\x. \\i\\Basis. inner x i \\ A \\ P i (inner x i))\"\n by sorry\n\nlemma (in euclidean_space) euclidean_representation_sum_fun:\n \"(\\x. \\b\\Basis. inner (f x) b *\\<^sub>R b) = f\"\n by sorry\n\nlemma euclidean_isCont:\n assumes \"\\b. b \\ Basis \\ isCont (\\x. (inner (f x) b) *\\<^sub>R b) x\"\n shows \"isCont f x\"\n by sorry\n\nlemma DIM_positive [simp]: \"0 < DIM('a::euclidean_space)\"\n by sorry\n\nlemma DIM_ge_Suc0 [simp]: \"Suc 0 \\ card Basis\"\n by sorry\n\nlemma sum_inner_Basis_scaleR [simp]:\n fixes f :: \"'a::euclidean_space \\ 'b::real_vector\"\n assumes \"b \\ Basis\" shows \"(\\i\\Basis. (inner i b) *\\<^sub>R f i) = f b\"\n by sorry\n\nlemma sum_inner_Basis_eq [simp]:\n assumes \"b \\ Basis\" shows \"(\\i\\Basis. (inner i b) * f i) = f b\"\n by sorry\n\nlemma sum_if_inner [simp]:\n assumes \"i \\ Basis\" \"j \\ Basis\"\n shows \"inner (\\k\\Basis. if k = i then f i *\\<^sub>R i else g k *\\<^sub>R k) j = (if j=i then f j else g j)\"\n by sorry\n\nlemma norm_le_componentwise:\n \"(\\b. b \\ Basis \\ abs(inner x b) \\ abs(inner y b)) \\ norm x \\ norm y\"\n by sorry\n\nlemma Basis_le_norm: \"b \\ Basis \\ \\inner x b\\ \\ norm x\"\n by sorry\n\nlemma norm_bound_Basis_le: \"b \\ Basis \\ norm x \\ e \\ \\inner x b\\ \\ e\"\n by sorry\n\nlemma norm_bound_Basis_lt: \"b \\ Basis \\ norm x < e \\ \\inner x b\\ < e\"\n by sorry\n\nlemma norm_le_l1: \"norm x \\ (\\b\\Basis. \\inner x b\\)\"\n by sorry\n\nlemma sum_norm_allsubsets_bound:\n fixes f :: \"'a \\ 'n::euclidean_space\"\n assumes fP: \"finite P\"\n and fPs: \"\\Q. Q \\ P \\ norm (sum f Q) \\ e\"\n shows \"(\\x\\P. norm (f x)) \\ 2 * real DIM('n) * e\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Subclass relationships\\\n\ninstance euclidean_space \\ perfect_space\nproof\n fix x :: 'a show \"\\ open {x}\"\n proof\n assume \"open {x}\"\n then obtain e where \"0 < e\" and e: \"\\y. dist y x < e \\ y = x\"\n unfolding open_dist by fast\n define y where \"y = x + scaleR (e/2) (SOME b. b \\ Basis)\"\n have [simp]: \"(SOME b. b \\ Basis) \\ Basis\"\n by (rule someI_ex) (auto simp: ex_in_conv)\n from \\0 < e\\ have \"y \\ x\"\n unfolding y_def by (auto intro!: nonzero_Basis)\n from \\0 < e\\ have \"dist y x < e\"\n unfolding y_def by (simp add: dist_norm)\n from \\y \\ x\\ and \\dist y x < e\\ show \"False\"\n using e by simp\n qed\nqed\n\nsubsection \\Class instances\\\n\nsubsubsection\\<^marker>\\tag unimportant\\ \\Type \\<^typ>\\real\\\\\n\ninstantiation real :: euclidean_space\nbegin\n\ndefinition\n [simp]: \"Basis = {1::real}\"\n\ninstance\n by standard auto\n\nend\n\nlemma DIM_real[simp]: \"DIM(real) = 1\"\n by sorry\n\nsubsubsection\\<^marker>\\tag unimportant\\ \\Type \\<^typ>\\complex\\\\\n\ninstantiation complex :: euclidean_space\nbegin\n\ndefinition Basis_complex_def: \"Basis = {1, \\}\"\n\ninstance\n by standard (auto simp add: Basis_complex_def intro: complex_eqI split: if_split_asm)\n\nend\n\nlemma DIM_complex[simp]: \"DIM(complex) = 2\"\n by sorry\n\nlemma complex_Basis_1 [iff]: \"(1::complex) \\ Basis\"\n by sorry\n\nlemma complex_Basis_i [iff]: \"\\ \\ Basis\"\n by sorry\n\nsubsubsection\\<^marker>\\tag unimportant\\ \\Type \\<^typ>\\'a \\ 'b\\\\\n\ninstantiation prod :: (real_inner, real_inner) real_inner\nbegin\n\ndefinition inner_prod_def:\n \"inner x y = inner (fst x) (fst y) + inner (snd x) (snd y)\"\n\nlemma inner_Pair [simp]: \"inner (a, b) (c, d) = inner a c + inner b d\"\n by sorry\n\ninstance\nproof\n fix r :: real\n fix x y z :: \"'a::real_inner \\ 'b::real_inner\"\n show \"inner x y = inner y x\"\n unfolding inner_prod_def\n by (simp add: inner_commute)\n show \"inner (x + y) z = inner x z + inner y z\"\n unfolding inner_prod_def\n by (simp add: inner_add_left)\n show \"inner (scaleR r x) y = r * inner x y\"\n unfolding inner_prod_def\n by (simp add: distrib_left)\n show \"0 \\ inner x x\"\n unfolding inner_prod_def\n by (intro add_nonneg_nonneg inner_ge_zero)\n show \"inner x x = 0 \\ x = 0\"\n unfolding inner_prod_def prod_eq_iff\n by (simp add: add_nonneg_eq_0_iff)\n show \"norm x = sqrt (inner x x)\"\n unfolding norm_prod_def inner_prod_def\n by (simp add: power2_norm_eq_inner)\nqed\n\nend\n\nlemma inner_Pair_0: \"inner x (0, b) = inner (snd x) b\" \"inner x (a, 0) = inner (fst x) a\"\n by sorry\n\ninstantiation prod :: (euclidean_space, euclidean_space) euclidean_space\nbegin\n\ndefinition\n \"Basis = (\\u. (u, 0)) ` Basis \\ (\\v. (0, v)) ` Basis\"\n\nlemma sum_Basis_prod_eq:\n fixes f::\"('a*'b)\\('a*'b)\"\n shows \"sum f Basis = sum (\\i. f (i, 0)) Basis + sum (\\i. f (0, i)) Basis\"\n by sorry\n\ninstance proof\n show \"(Basis :: ('a \\ 'b) set) \\ {}\"\n unfolding Basis_prod_def by simp\nnext\n show \"finite (Basis :: ('a \\ 'b) set)\"\n unfolding Basis_prod_def by simp\nnext\n fix u v :: \"'a \\ 'b\"\n assume \"u \\ Basis\" and \"v \\ Basis\"\n thus \"inner u v = (if u = v then 1 else 0)\"\n unfolding Basis_prod_def inner_prod_def\n by (auto simp add: inner_Basis split: if_split_asm)\nnext\n fix x :: \"'a \\ 'b\"\n show \"(\\u\\Basis. inner x u = 0) \\ x = 0\"\n unfolding Basis_prod_def ball_Un ball_simps\n by (simp add: inner_prod_def prod_eq_iff euclidean_all_zero_iff)\nqed\n\nlemma DIM_prod[simp]: \"DIM('a \\ 'b) = DIM('a) + DIM('b)\"\n by sorry\n\nend\n\nsubsection \\Locale instances\\\n\nlemma finite_dimensional_vector_space_euclidean:\n \"finite_dimensional_vector_space " }, { "theorem_id": 20, "title": "004_pythagorean_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers\n-/\nmodule\n\npublic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Arctan\npublic import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine\n\n/-!\n# Right-angled triangles\n\nThis file proves basic geometric results about distances and angles in (possibly degenerate)\nright-angled triangles in real inner product spaces and Euclidean affine spaces.\n\n## Implementation notes\n\nResults in this file are generally given in a form with only those non-degeneracy conditions\nneeded for the particular result, rather than requiring affine independence of the points of a\ntriangle unnecessarily.\n\n## References\n\n* https://en.wikipedia.org/wiki/Pythagorean_theorem\n\n-/\n\npublic section\n\n\nnoncomputable section\n\nopen scoped EuclideanGeometry\n\nopen scoped Real\n\nopen scoped RealInnerProductSpace\n\nnamespace InnerProductGeometry\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]\n\n/-- Pythagorean theorem, if-and-only-if vector angle form. -/\ntheorem norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two (x y : V) :\n ‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ angle x y = π / 2 := by sorry\ntheorem norm_add_sq_eq_norm_sq_add_norm_sq' (x y : V) (h : angle x y = π / 2) :\n ‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ :=\n (norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two x y).2 h\n\n/-- Pythagorean theorem, subtracting vectors, if-and-only-if vector angle form. -/\ntheorem norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two (x y : V) :\n ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ angle x y = π / 2 := by sorry\ntheorem norm_sub_sq_eq_norm_sq_add_norm_sq' (x y : V) (h : angle x y = π / 2) :\n ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ :=\n (norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two x y).2 h\n\n/-- An angle in a right-angled triangle expressed using `arccos`. -/\ntheorem angle_add_eq_arccos_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n angle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by sorry\ntheorem angle_add_eq_arcsin_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y ≠ 0) :\n angle x (x + y) = Real.arcsin (‖y‖ / ‖x + y‖) := by sorry\ntheorem angle_add_eq_arctan_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0) :\n angle x (x + y) = Real.arctan (‖y‖ / ‖x‖) := by sorry\ntheorem angle_add_pos_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :\n 0 < angle x (x + y) := by sorry\ntheorem angle_add_le_pi_div_two_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n angle x (x + y) ≤ π / 2 := by sorry\ntheorem angle_add_lt_pi_div_two_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0) :\n angle x (x + y) < π / 2 := by sorry\ntheorem cos_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n Real.cos (angle x (x + y)) = ‖x‖ / ‖x + y‖ := by sorry\ntheorem sin_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y ≠ 0) :\n Real.sin (angle x (x + y)) = ‖y‖ / ‖x + y‖ := by sorry\ntheorem tan_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n Real.tan (angle x (x + y)) = ‖y‖ / ‖x‖ := by sorry\ntheorem cos_angle_add_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n Real.cos (angle x (x + y)) * ‖x + y‖ = ‖x‖ := by sorry\ntheorem sin_angle_add_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n Real.sin (angle x (x + y)) * ‖x + y‖ = ‖y‖ := by sorry\ntheorem tan_angle_add_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y = 0) :\n Real.tan (angle x (x + y)) * ‖x‖ = ‖y‖ := by sorry\ntheorem norm_div_cos_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y = 0) :\n ‖x‖ / Real.cos (angle x (x + y)) = ‖x + y‖ := by sorry\ntheorem norm_div_sin_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :\n ‖y‖ / Real.sin (angle x (x + y)) = ‖x + y‖ := by sorry\ntheorem norm_div_tan_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :\n ‖y‖ / Real.tan (angle x (x + y)) = ‖x‖ := by sorry\ntheorem angle_sub_eq_arccos_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n angle x (x - y) = Real.arccos (‖x‖ / ‖x - y‖) := by sorry\ntheorem angle_sub_eq_arcsin_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y ≠ 0) :\n angle x (x - y) = Real.arcsin (‖y‖ / ‖x - y‖) := by sorry\ntheorem angle_sub_eq_arctan_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0) :\n angle x (x - y) = Real.arctan (‖y‖ / ‖x‖) := by sorry\ntheorem angle_sub_pos_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :\n 0 < angle x (x - y) := by sorry\ntheorem angle_sub_le_pi_div_two_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n angle x (x - y) ≤ π / 2 := by sorry\ntheorem angle_sub_lt_pi_div_two_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0) :\n angle x (x - y) < π / 2 := by sorry\ntheorem cos_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n Real.cos (angle x (x - y)) = ‖x‖ / ‖x - y‖ := by sorry\ntheorem sin_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y ≠ 0) :\n Real.sin (angle x (x - y)) = ‖y‖ / ‖x - y‖ := by sorry\ntheorem tan_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n Real.tan (angle x (x - y)) = ‖y‖ / ‖x‖ := by sorry\ntheorem cos_angle_sub_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n Real.cos (angle x (x - y)) * ‖x - y‖ = ‖x‖ := by sorry\ntheorem sin_angle_sub_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :\n Real.sin (angle x (x - y)) * ‖x - y‖ = ‖y‖ := by sorry\ntheorem tan_angle_sub_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y = 0) :\n Real.tan (angle x (x - y)) * ‖x‖ = ‖y‖ := by sorry\ntheorem norm_div_cos_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y = 0) :\n ‖x‖ / Real.cos (angle x (x - y)) = ‖x - y‖ := by sorry\ntheorem norm_div_sin_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :\n ‖y‖ / Real.sin (angle x (x - y)) = ‖x - y‖ := by sorry\ntheorem norm_div_tan_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :\n ‖y‖ / Real.tan (angle x (x - y)) = ‖x‖ := by sorry\nend InnerProductGeometry\n\nnamespace EuclideanGeometry\n\nopen InnerProductGeometry\n\nvariable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]\n [NormedAddTorsor V P]\n\n/-- **Pythagorean theorem**, if-and-only-if angle-at-point form. -/\ntheorem dist_sq_eq_dist_sq_add_dist_sq_iff_angle_eq_pi_div_two (p₁ p₂ p₃ : P) :\n dist p₁ p₃ * dist p₁ p₃ = dist p₁ p₂ * dist p₁ p₂ + dist p₃ p₂ * dist p₃ p₂ ↔\n ∠ p₁ p₂ p₃ = π / 2 := by sorry\ntheorem angle_eq_arccos_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2) :\n ∠ p₂ p₃ p₁ = Real.arccos (dist p₃ p₂ / dist p₁ p₃) := by sorry\ntheorem angle_eq_arcsin_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2)\n (h0 : p₁ ≠ p₂ ∨ p₃ ≠ p₂) : ∠ p₂ p₃ p₁ = Real.arcsin (dist p₁ p₂ / dist p₁ p₃) := by sorry\ntheorem angle_eq_arctan_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2)\n (h0 : p₃ ≠ p₂) : ∠ p₂ p₃ p₁ = Real.arctan (dist p₁ p₂ / dist p₃ p₂) := by sorry\ntheorem angle_pos_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2)\n (h0 : p₁ ≠ p₂ ∨ p₃ = p₂) : 0 < ∠ p₂ p₃ p₁ := by sorry\ntheorem angle_le_pi_div_two_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2) :\n ∠ p₂ p₃ p₁ ≤ π / 2 := by sorry\ntheorem angle_lt_pi_div_two_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2)\n (h0 : p₃ ≠ p₂) : ∠ p₂ p₃ p₁ < π / 2 := by sorry\ntheorem cos_angle_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2) :\n Real.cos (∠ p₂ p₃ p₁) = dist p₃ p₂ / dist p₁ p₃ := by sorry\ntheorem sin_angle_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2)\n (h0 : p₁ ≠ p₂ ∨ p₃ ≠ p₂) : Real.sin (∠ p₂ p₃ p₁) = dist p₁ p₂ / dist p₁ p₃ := by sorry\ntheorem tan_angle_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2) :\n Real.tan (∠ p₂ p₃ p₁) = dist p₁ p₂ / dist p₃ p₂ := by sorry\ntheorem cos_angle_mul_dist_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2) :\n Real.cos (∠ p₂ p₃ p₁) * dist p₁ p₃ = dist p₃ p₂ := by sorry\ntheorem sin_angle_mul_dist_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2) :\n Real.sin (∠ p₂ p₃ p₁) * dist p₁ p₃ = dist p₁ p₂ := by sorry\ntheorem tan_angle_mul_dist_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2)\n (h0 : p₁ = p₂ ∨ p₃ ≠ p₂) : Real.tan (∠ p₂ p₃ p₁) * dist p₃ p₂ = dist p₁ p₂ := by sorry\ntheorem dist_div_cos_angle_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2)\n (h0 : p₁ = p₂ ∨ p₃ ≠ p₂) : dist p₃ p₂ / Real.cos (∠ p₂ p₃ p₁) = dist p₁ p₃ := by sorry\ntheorem dist_div_sin_angle_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2)\n (h0 : p₁ ≠ p₂ ∨ p₃ = p₂) : dist p₁ p₂ / Real.sin (∠ p₂ p₃ p₁) = dist p₁ p₃ := by sorry\ntheorem dist_div_tan_angle_of_angle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = π / 2)\n (h0 : p₁ ≠ p₂ ∨ p₃ = p₂) : dist p₁ p₂ / Real.tan (∠ p₂ p₃ p₁) = dist p₃ p₂ := by sorry\nend EuclideanGeometry\n" }, { "theorem_id": 20, "title": "004_pythagorean_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From HighSchoolGeometry Require Export distance_euclidienne.\nSet Implicit Arguments.\nUnset Strict Implicit.\n \nLemma carre_scalaire_somme :\n forall A B C D : PO,\n scalaire (add_PP (vec A B) (vec C D)) (add_PP (vec A B) (vec C D)) =\n 2 * scalaire (vec A B) (vec C D) +\n (scalaire (vec A B) (vec A B) + scalaire (vec C D) (vec C D)) :>R.\nProof.\nAdmitted.\n \nLemma difference_Pythagore :\n forall A B C : PO,\n scalaire (vec B C) (vec B C) =\n scalaire (vec A B) (vec A B) + scalaire (vec A C) (vec A C) +\n -2 * scalaire (vec A B) (vec A C) :>R.\nProof.\nAdmitted.\n \nLemma triangle_Pythagore :\n forall A B C : PO,\n scalaire (vec A B) (vec A C) = 0 <->\n scalaire (vec B C) (vec B C) =\n scalaire (vec A B) (vec A B) + scalaire (vec A C) (vec A C) :>R.\nProof.\nAdmitted.\n \nTheorem Pythagore :\n forall A B C : PO,\n orthogonal (vec A B) (vec A C) <->\n Rsqr (distance B C) = Rsqr (distance A B) + Rsqr (distance A C) :>R.\nProof.\nAdmitted.\n \nLemma longueur_mediane :\n forall A B C I : PO,\n I = milieu B C ->\n Rsqr (distance A B) + Rsqr (distance A C) =\n R2 * (Rsqr (distance A I) + Rsqr (distance I B)) :>R.\nProof.\nAdmitted.\n \nLemma demi_longueur :\n forall A B I : PO,\n I = milieu A B -> Rsqr (distance A B) = R4 * Rsqr (distance A I) :>R.\nProof.\nAdmitted.\n \nTheorem mediane :\n forall A B C I : PO,\n I = milieu B C ->\n R4 * Rsqr (distance A I) =\n R2 * (Rsqr (distance A B) + Rsqr (distance A C)) - Rsqr (distance B C) :>R.\nProof.\nAdmitted.\n \nLemma rectangle_Pythagore :\n forall A B C : PO,\n orthogonal (vec A B) (vec A C) <->\n scalaire (vec B C) (vec B C) =\n scalaire (vec A B) (vec A B) + scalaire (vec A C) (vec A C) :>R.\nProof.\nAdmitted.\nFrom HighSchoolGeometry Require Export projection_orthogonale.\n \nLemma Pythagore_projete_orthogonal :\n forall A B C H : PO,\n A <> B :>PO ->\n H = projete_orthogonal A B C :>PO ->\n Rsqr (distance A C) = Rsqr (distance H A) + Rsqr (distance H C) :>R /\\\n Rsqr (distance B C) = Rsqr (distance H B) + Rsqr (distance H C) :>R.\nProof.\nAdmitted.\n \nLemma scalaire_difference_carre :\n forall A B I M : PO,\n I = milieu A B ->\n scalaire (vec M A) (vec M B) = Rsqr (distance M I) + - Rsqr (distance I A).\nProof.\nAdmitted.\n \nLemma egalite_scalaire_deux_projetes :\n forall A B C H K : PO,\n A <> B ->\n A <> C ->\n H = projete_orthogonal A B C ->\n K = projete_orthogonal A C B ->\n scalaire (vec A B) (vec A H) = scalaire (vec A K) (vec A C).\nProof.\nAdmitted.\n \nLemma projete_distance_Rlt :\n forall A B C H : PO,\n A <> B ->\n H <> B -> H = projete_orthogonal A B C -> distance C H < distance C B.\nProof.\nAdmitted.\nParameter distance_droite : PO -> DR -> R.\n \nAxiom\n distance_droite_def :\n forall A B C H : PO,\n A <> B ->\n H = projete_orthogonal A B C ->\n distance_droite C (droite A B) = distance C H.\n \nLemma existence_distance_droite :\n forall A B C : PO,\n A <> B -> exists d : R, d = distance_droite C (droite A B).\nProof.\nAdmitted." }, { "theorem_id": 21, "title": "007_law_of_quadratic_reciprocity", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";;\nneeds \"Library/pocklington.ml\";;\nneeds \"Library/products.ml\";;\n\nprioritize_num();;\n\nlet IN_NUMSEG_1 = `!p i. i IN 1..p - 1 <=> 0 < i /\\ i < p`;;\n\nlet EVEN_DIV = `!n. EVEN n <=> n = 2 * (n DIV 2)`;;\n\nlet CONG_MINUS1_SQUARE = `2 <= p ==> ((p - 1) * (p - 1) == 1) (mod p)`;;\n\nlet CONG_EXP_MINUS1 = `!p n. 2 <= p ==> ((p - 1) EXP n == if EVEN n then 1 else p - 1) (mod p)`;;\n\nlet NOT_CONG_MINUS1 = `!p. 3 <= p ==> ~(p - 1 == 1) (mod p)`;;\n\nlet CONG_COND_LEMMA = `!p x y. 3 <= p /\\\n ((if x then 1 else p - 1) == (if y then 1 else p - 1)) (mod p)\n ==> (x <=> y)`;;\n\nlet FINITE_SUBCROSS = `!s:A->bool t:B->bool.\n FINITE s /\\ FINITE t ==> FINITE {x,y | x IN s /\\ y IN t /\\ P x y}`;;\n\nlet CARD_SUBCROSS_DETERMINATE = `FINITE s /\\ FINITE t /\\ (!x. x IN s /\\ p(x) ==> f(x) IN t)\n ==> CARD {(x:A),(y:B) | x IN s /\\ y IN t /\\ y = f x /\\ p x} =\n CARD {x | x IN s /\\ p(x)}`;;\n\nlet CARD_SUBCROSS_SWAP = `CARD {y,x | y IN 1..m /\\ x IN 1..n /\\ P x y} =\n CARD {x,y | x IN 1..n /\\ y IN 1..m /\\ P x y}`;;\n\nparse_as_infix(\"is_quadratic_residue\",(12,\"right\"));;\n\nlet is_quadratic_residue = new_definition\n `y is_quadratic_residue rel <=> ?x. (x EXP 2 == y) (rel)`;;\n\nlet IS_QUADRATIC_RESIDUE = `!a p. ~(p = 0) /\\ ~(p divides a)\n ==> (a is_quadratic_residue (mod p) <=>\n ?x. 0 < x /\\ x < p /\\ (x EXP 2 == a) (mod p))`;;\n\nlet IS_QUADRATIC_RESIDUE_COMMON = `!a p. prime p /\\ coprime(a,p)\n ==> (a is_quadratic_residue (mod p) <=>\n ?x. 0 < x /\\ x < p /\\ (x EXP 2 == a) (mod p))`;;\n\nlet QUADRATIC_RESIDUE_PAIR_ADD = `!p x y. prime p\n ==> (((x + y) EXP 2 == x EXP 2) (mod p) <=>\n p divides y \\/ p divides (2 * x + y))`;;\n\nlet QUADRATIC_RESIDUE_PAIR = `!p x y. prime p\n ==> ((x EXP 2 == y EXP 2) (mod p) <=>\n p divides (x + y) \\/ p divides (dist(x,y)))`;;\n\nlet IS_QUADRATIC_RESIDUE_PAIR = `!a p. prime p /\\ coprime(a,p)\n ==> (a is_quadratic_residue (mod p) <=>\n ?x y. 0 < x /\\ x < p /\\ 0 < y /\\ y < p /\\ x + y = p /\\\n (x EXP 2 == a) (mod p) /\\ (y EXP 2 == a) (mod p) /\\\n !z. 0 < z /\\ z < p /\\ (z EXP 2 == a) (mod p)\n ==> z = x \\/ z = y)`;;\n\nlet QUADRATIC_RESIDUE_PAIR_PRODUCT = `!p x. 0 < x /\\ x < p /\\ (x EXP 2 == a) (mod p)\n ==> (x * (p - x) == (p - 1) * a) (mod p)`;;\n\nlet legendre = new_definition\n `(legendre:num#num->int)(a,p) =\n if ~(coprime(a,p)) then &0\n else if a is_quadratic_residue (mod p) then &1\n else --(&1)`;;\n\nlet nproduct = new_definition `nproduct = iterate ( * )`;;\n\nlet CONG_NPRODUCT = `!f g s. FINITE s /\\ (!x. x IN s ==> (f x == g x) (mod n))\n ==> (nproduct s f == nproduct s g) (mod n)`;;\n\nlet NPRODUCT_DELTA_CONST = `!c s. FINITE s\n ==> nproduct s (\\x. if p(x) then c else 1) =\n c EXP (CARD {x | x IN s /\\ p(x)})`;;\n\nlet COPRIME_NPRODUCT = `!f p s. FINITE s /\\ (!x. x IN s ==> coprime(p,f x))\n ==> coprime(p,nproduct s f)`;;\n\nlet FACT_NPRODUCT = `!n. FACT(n) = nproduct(1..n) (\\i. i)`;;\n\nlet NPRODUCT_PAIRUP_INDUCT = `!f r n s k. s HAS_SIZE (2 * n) /\\\n (!x:A. x IN s ==> ?!y. y IN s /\\ ~(y = x) /\\\n (f(x) * f(y) == k) (mod r))\n ==> (nproduct s f == k EXP n) (mod r)`;;\n\nlet QUADRATIC_NONRESIDUE_FACT = `!a p. prime p /\\ ODD(p) /\\\n coprime(a,p) /\\ ~(a is_quadratic_residue (mod p))\n ==> (a EXP ((p - 1) DIV 2) == FACT(p - 1)) (mod p)`;;\n\nlet QUADRATIC_RESIDUE_FACT = `!a p. prime p /\\ ODD(p) /\\\n coprime(a,p) /\\ a is_quadratic_residue (mod p)\n ==> (a EXP ((p - 1) DIV 2) == FACT(p - 2)) (mod p)`;;\n\nlet WILSON_LEMMA = `!p. prime(p) ==> (FACT(p - 2) == 1) (mod p)`;;\n\nlet WILSON_IMP = `!p. prime(p) ==> (FACT(p - 1) == p - 1) (mod p)`;;\n\nlet WILSON = `!p. ~(p = 1) ==> (prime p <=> (FACT(p - 1) == p - 1) (mod p))`;;\n\nlet EULER_CRITERION = `!a p. prime p /\\ coprime(a,p)\n ==> (a EXP ((p - 1) DIV 2) ==\n (if a is_quadratic_residue (mod p) then 1 else p - 1)) (mod p)`;;\n\nlet GAUSS_LEMMA_1 = `prime p /\\ coprime(a,p) /\\ 2 * r + 1 = p\n ==> nproduct(1..r) (\\x. let b = (a * x) MOD p in\n if b <= r then b else p - b) =\n nproduct(1..r) (\\x. x)`;;\n\nlet GAUSS_LEMMA_2 = `prime p /\\ coprime(a,p) /\\ 2 * r + 1 = p\n ==> (nproduct(1..r) (\\x. let b = (a * x) MOD p in\n if b <= r then b else p - b) ==\n (p - 1) EXP (CARD {x | x IN 1..r /\\ r < (a * x) MOD p}) *\n a EXP r * nproduct(1..r) (\\x. x)) (mod p)`;;\n\nlet GAUSS_LEMMA_3 = `prime p /\\ coprime(a,p) /\\ 2 * r + 1 = p\n ==> ((p - 1) EXP CARD {x | x IN 1..r /\\ r < (a * x) MOD p} *\n (if a is_quadratic_residue mod p then 1 else p - 1) == 1) (mod p)`;;\n\nlet GAUSS_LEMMA_4 = `prime p /\\ coprime(a,p) /\\ 2 * r + 1 = p\n ==> ((if EVEN(CARD{x | x IN 1..r /\\ r < (a * x) MOD p}) then 1 else p - 1) *\n (if a is_quadratic_residue mod p then 1 else p - 1) == 1) (mod p)`;;\n\nlet GAUSS_LEMMA = `!a p r. prime p /\\ coprime(a,p) /\\ 2 * r + 1 = p\n ==> (a is_quadratic_residue (mod p) <=>\n EVEN(CARD {x | x IN 1..r /\\ r < (a * x) MOD p}))`;;\n\nlet GAUSS_LEMMA_SYM = `!p q r s. prime p /\\ prime q /\\ coprime(p,q) /\\\n 2 * r + 1 = p /\\ 2 * s + 1 = q\n ==> (q is_quadratic_residue (mod p) <=>\n EVEN(CARD {x,y | x IN 1..r /\\ y IN 1..s /\\\n q * x < p * y /\\ p * y <= q * x + r}))`;;\n\nlet GAUSS_LEMMA_SYM' = `!p q r s. prime p /\\ prime q /\\ coprime(p,q) /\\\n 2 * r + 1 = p /\\ 2 * s + 1 = q\n ==> (p is_quadratic_residue (mod q) <=>\n EVEN(CARD {x,y | x IN 1..r /\\ y IN 1..s /\\\n p * y < q * x /\\ q * x <= p * y + s}))`;;\n\nlet RECIPROCITY_SET_LEMMA = `!a b c d r s.\n a UNION b UNION c UNION d = (1..r) CROSS (1..s) /\\\n PAIRWISE DISJOINT [a;b;c;d] /\\ CARD b = CARD c\n ==> ((EVEN(CARD a) <=> EVEN(CARD d)) <=> ~(ODD r /\\ ODD s))`;;\n\nlet RECIPROCITY_SIMPLE = `!p q r s.\n prime p /\\\n prime q /\\\n coprime (p,q) /\\\n 2 * r + 1 = p /\\\n 2 * s + 1 = q\n ==> ((q is_quadratic_residue (mod p) <=>\n p is_quadratic_residue (mod q)) <=>\n ~(ODD r /\\ ODD s))`;;\n\nlet RECIPROCITY_LEGENDRE = `!p q. prime p /\\ prime q /\\ ODD p /\\ ODD q /\\ ~(p = q)\n ==> legendre(p,q) * legendre(q,p) =\n --(&1) pow ((p - 1) DIV 2 * (q - 1) DIV 2)`;;" }, { "theorem_id": 21, "title": "007_law_of_quadratic_reciprocity", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory Quadratic_Reciprocity\nimports Gauss\nbegin\n\ntext \\\n The proof is based on Gauss's fifth proof, which can be found at\n \\<^url>\\https://www.lehigh.edu/~shw2/q-recip/gauss5.pdf\\.\n\\\n\nlocale QR =\n fixes p :: \"nat\"\n fixes q :: \"nat\"\n assumes p_prime: \"prime p\"\n assumes p_ge_2: \"2 < p\"\n assumes q_prime: \"prime q\"\n assumes q_ge_2: \"2 < q\"\n assumes pq_neq: \"p \\ q\"\nbegin\n\nlemma odd_p: \"odd p\"\n by sorry\n\nlemma p_ge_0: \"0 < int p\"\n by sorry\n \nlemma p_eq2: \"int p = (2 * ((int p - 1) div 2)) + 1\"\n by sorry\n\nlemma odd_q: \"odd q\"\n by sorry\n\nlemma q_ge_0: \"0 < int q\"\n by sorry\n\nlemma q_eq2: \"int q = (2 * ((int q - 1) div 2)) + 1\"\n by sorry\n\nlemma pq_eq2: \"int p * int q = (2 * ((int p * int q - 1) div 2)) + 1\"\n by sorry\n\nlemma pq_coprime: \"coprime p q\"\n by sorry\n\nlemma pq_coprime_int: \"coprime (int p) (int q)\"\n by sorry\n\nlemma qp_ineq: \"int p * k \\ (int p * int q - 1) div 2 \\ k \\ (int q - 1) div 2\"\n by sorry\n\nlemma QRqp: \"QR q p\"\n by sorry\n\nlemma pq_commute: \"int p * int q = int q * int p\"\n by sorry\n\nlemma pq_ge_0: \"int p * int q > 0\"\n by sorry\n\ndefinition \"r = ((p - 1) div 2) * ((q - 1) div 2)\"\ndefinition \"m = card (GAUSS.E p q)\"\ndefinition \"n = card (GAUSS.E q p)\"\n\nabbreviation \"Res k \\ {0 .. k - 1}\" for k :: int\nabbreviation \"Res_ge_0 k \\ {0 <.. k - 1}\" for k :: int\nabbreviation \"Res_0 k \\ {0::int}\" for k :: int\nabbreviation \"Res_l k \\ {0 <.. (k - 1) div 2}\" for k :: int\nabbreviation \"Res_h k \\ {(k - 1) div 2 <.. k - 1}\" for k :: int\n\nabbreviation \"Sets_pq r0 r1 r2 \\\n {(x::int). x \\ r0 (int p * int q) \\ x mod p \\ r1 (int p) \\ x mod q \\ r2 (int q)}\"\n\ndefinition \"A = Sets_pq Res_l Res_l Res_h\"\ndefinition \"B = Sets_pq Res_l Res_h Res_l\"\ndefinition \"C = Sets_pq Res_h Res_h Res_l\"\ndefinition \"D = Sets_pq Res_l Res_h Res_h\"\ndefinition \"E = Sets_pq Res_l Res_0 Res_h\"\ndefinition \"F = Sets_pq Res_l Res_h Res_0\"\n\ndefinition \"a = card A\"\ndefinition \"b = card B\"\ndefinition \"c = card C\"\ndefinition \"d = card D\"\ndefinition \"e = card E\"\ndefinition \"f = card F\"\n\nlemma Gpq: \"GAUSS p q\"\n by sorry\n\nlemma Gqp: \"GAUSS q p\"\n by sorry\n\nlemma QR_lemma_01: \"(\\x. x mod q) ` E = GAUSS.E q p\"\n by sorry\n\nlemma QR_lemma_02: \"e = n\"\n by sorry\n\nlemma QR_lemma_03: \"f = m\"\n by sorry\n\ndefinition f_1 :: \"int \\ int \\ int\"\n where \"f_1 x = ((x mod p), (x mod q))\"\n\ndefinition P_1 :: \"int \\ int \\ int \\ bool\"\n where \"P_1 res x \\ x mod p = fst res \\ x mod q = snd res \\ x \\ Res (int p * int q)\"\n\ndefinition g_1 :: \"int \\ int \\ int\"\n where \"g_1 res = (THE x. P_1 res x)\"\n\nlemma P_1_lemma:\n fixes res :: \"int \\ int\"\n assumes \"0 \\ fst res\" \"fst res < p\" \"0 \\ snd res\" \"snd res < q\"\n shows \"\\!x. P_1 res x\"\n by sorry\n\nlemma g_1_lemma:\n fixes res :: \"int \\ int\"\n assumes \"0 \\ fst res\" \"fst res < p\" \"0 \\ snd res\" \"snd res < q\"\n shows \"P_1 res (g_1 res)\"\n by sorry\n\ndefinition \"BuC = Sets_pq Res_ge_0 Res_h Res_l\"\n\nlemma finite_BuC [simp]:\n \"finite BuC\"\n by sorry\n\nlemma QR_lemma_04: \"card BuC = card (Res_h p \\ Res_l q)\"\n by sorry\n\nlemma QR_lemma_05: \"card (Res_h p \\ Res_l q) = r\"\n by sorry\n\nlemma QR_lemma_06: \"b + c = r\"\n by sorry\n\ndefinition f_2:: \"int \\ int\"\n where \"f_2 x = (int p * int q) - x\"\n\nlemma f_2_lemma_1: \"f_2 (f_2 x) = x\"\n by sorry\n\nlemma f_2_lemma_2: \"[f_2 x = int p - x] (mod p)\"\n by sorry\n\nlemma f_2_lemma_3: \"f_2 x \\ S \\ x \\ f_2 ` S\"\n by sorry\n\nlemma QR_lemma_07:\n \"f_2 ` Res_l (int p * int q) = Res_h (int p * int q)\"\n \"f_2 ` Res_h (int p * int q) = Res_l (int p * int q)\"\n by sorry\n\nlemma QR_lemma_08:\n \"f_2 x mod p \\ Res_l p \\ x mod p \\ Res_h p\"\n \"f_2 x mod p \\ Res_h p \\ x mod p \\ Res_l p\"\n by sorry\n\nlemma QR_lemma_09:\n \"f_2 x mod q \\ Res_l q \\ x mod q \\ Res_h q\"\n \"f_2 x mod q \\ Res_h q \\ x mod q \\ Res_l q\"\n by sorry\n\nlemma QR_lemma_10: \"a = c\"\n by sorry\n\ndefinition \"BuD = Sets_pq Res_l Res_h Res_ge_0\"\ndefinition \"BuDuF = Sets_pq Res_l Res_h Res\"\n\ndefinition f_3 :: \"int \\ int \\ int\"\n where \"f_3 x = (x mod p, x div p + 1)\"\n\ndefinition g_3 :: \"int \\ int \\ int\"\n where \"g_3 x = fst x + (snd x - 1) * p\"\n\nlemma QR_lemma_11: \"card BuDuF = card (Res_h p \\ Res_l q)\"\n by sorry\n\nlemma QR_lemma_12: \"b + d + m = r\"\n by sorry\n\nlemma QR_lemma_13: \"a + d + n = r\"\n by sorry\n\nlemma QR_lemma_14: \"(-1::int) ^ (m + n) = (-1) ^ r\"\n by sorry\n\nlemma Quadratic_Reciprocity:\n \"Legendre p q * Legendre q p = (-1::int) ^ ((p - 1) div 2 * ((q - 1) div 2))\"\n by sorry\n\nend\n\ntheorem Quadratic_Reciprocity:\n assumes \"prime p\" \"2 < p\" \"prime q\" \"2 < q\" \"p \\ q\"\n shows \"Legendre p q * Legendre q p = (-1::int) ^ ((p - 1) div 2 * ((q - 1) div 2))\"\n by sorry\n\ntheorem Quadratic_Reciprocity_int:\n assumes \"prime (nat p)\" \"2 < p\" \"prime (nat q)\" \"2 < q\" \"p \\ q\"\n shows \"Legendre p q * Legendre q p = (-1::int) ^ (nat ((p - 1) div 2 * ((q - 1) div 2)))\"\n by sorry\n\nend" }, { "theorem_id": 21, "title": "007_law_of_quadratic_reciprocity", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Michael Stoll\n-/\nmodule\n\npublic import Mathlib.NumberTheory.LegendreSymbol.Basic\npublic import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.GaussSum\n\n/-!\n# Quadratic reciprocity.\n\n## Main results\n\nWe prove the law of quadratic reciprocity, see `legendreSym.quadratic_reciprocity` and\n`legendreSym.quadratic_reciprocity'`, as well as the\ninterpretations in terms of existence of square roots depending on the congruence mod 4,\n`ZMod.exists_sq_eq_prime_iff_of_mod_four_eq_one` and\n`ZMod.exists_sq_eq_prime_iff_of_mod_four_eq_three`.\n\nWe also prove the supplementary laws that give conditions for when `2` or `-2`\nis a square modulo a prime `p`:\n`legendreSym.at_two` and `ZMod.exists_sq_eq_two_iff` for `2` and\n`legendreSym.at_neg_two` and `ZMod.exists_sq_eq_neg_two_iff` for `-2`.\n\n## Implementation notes\n\nThe proofs use results for quadratic characters on arbitrary finite fields\nfrom `NumberTheory.LegendreSymbol.QuadraticChar.GaussSum`, which in turn are based on\nproperties of quadratic Gauss sums as provided by `NumberTheory.LegendreSymbol.GaussSum`.\n\n## Tags\n\nquadratic residue, quadratic nonresidue, Legendre symbol, quadratic reciprocity\n-/\n\npublic section\n\n\nopen Nat\n\nsection Values\n\nvariable {p : ℕ} [Fact p.Prime]\n\nopen ZMod\n\n/-!\n### The value of the Legendre symbol at `2` and `-2`\n\nSee `jacobiSym.at_two` and `jacobiSym.at_neg_two` for the corresponding statements\nfor the Jacobi symbol.\n-/\n\n\nnamespace legendreSym\n\n/-- `legendreSym p 2` is given by `χ₈ p`. -/\ntheorem at_two (hp : p ≠ 2) : legendreSym p 2 = χ₈ p := by sorry\ntheorem at_neg_two (hp : p ≠ 2) : legendreSym p (-2) = χ₈' p := by sorry\nend legendreSym\n\nnamespace ZMod\n\n/-- `2` is a square modulo an odd prime `p` iff `p` is congruent to `1` or `7` mod `8`. -/\ntheorem exists_sq_eq_two_iff (hp : p ≠ 2) : IsSquare (2 : ZMod p) ↔ p % 8 = 1 ∨ p % 8 = 7 := by sorry\ntheorem exists_sq_eq_neg_two_iff (hp : p ≠ 2) : IsSquare (-2 : ZMod p) ↔ p % 8 = 1 ∨ p % 8 = 3 := by sorry\nend ZMod\n\nend Values\n\nsection Reciprocity\n\n/-!\n### The Law of Quadratic Reciprocity\n\nSee `jacobiSym.quadratic_reciprocity` and variants for a version of Quadratic Reciprocity\nfor the Jacobi symbol.\n-/\n\n\nvariable {p q : ℕ} [Fact p.Prime] [Fact q.Prime]\n\nnamespace legendreSym\n\nopen ZMod\n\n/-- **The Law of Quadratic Reciprocity**: if `p` and `q` are distinct odd primes, then\n`(q / p) * (p / q) = (-1)^((p-1)(q-1)/4)`. -/\ntheorem quadratic_reciprocity (hp : p ≠ 2) (hq : q ≠ 2) (hpq : p ≠ q) :\n legendreSym q p * legendreSym p q = (-1) ^ (p / 2 * (q / 2)) := by sorry\ntheorem quadratic_reciprocity' (hp : p ≠ 2) (hq : q ≠ 2) :\n legendreSym q p = (-1) ^ (p / 2 * (q / 2)) * legendreSym p q := by sorry\ntheorem quadratic_reciprocity_one_mod_four (hp : p % 4 = 1) (hq : q ≠ 2) :\n legendreSym q p = legendreSym p q := by sorry\ntheorem quadratic_reciprocity_three_mod_four (hp : p % 4 = 3) (hq : q % 4 = 3) :\n legendreSym q p = -legendreSym p q := by sorry\nend legendreSym\n\nnamespace ZMod\n\nopen legendreSym\n\n/-- If `p` and `q` are odd primes and `p % 4 = 1`, then `q` is a square mod `p` iff\n`p` is a square mod `q`. -/\ntheorem exists_sq_eq_prime_iff_of_mod_four_eq_one (hp1 : p % 4 = 1) (hq1 : q ≠ 2) :\n IsSquare (q : ZMod p) ↔ IsSquare (p : ZMod q) := by sorry\ntheorem exists_sq_eq_prime_iff_of_mod_four_eq_three (hp3 : p % 4 = 3) (hq3 : q % 4 = 3)\n (hpq : p ≠ q) : IsSquare (q : ZMod p) ↔ ¬IsSquare (p : ZMod q) := by sorry\nend ZMod\n\nend Reciprocity\n" }, { "theorem_id": 21, "title": "007_law_of_quadratic_reciprocity", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Zhints.\nRequire Import Zpow_facts.\nRequire Import BinInt. Import Z.\nRequire Import Znat.\nRequire Import Zeuclid. Import ZEuclid.\nRequire Import Znumtheory.\nRequire Import Reciprocity.Reciprocity.Finite. Import FiniteTypes.\nRequire Import Reciprocity.Reciprocity.Accumulation. Import Accum.\nRequire Import Classical.\nRequire Import Lia.\n\nLemma Zpos_induction (P : Z -> Prop) :\n P 0 ->\n (forall n : Z, 0 <= n -> P n -> P (succ n)) ->\n (forall n : Z, 0 <= n -> P n).\nProof.\nAdmitted.\nLet f' u := exist (fun k => 1 <= k <= p - 1) (f u) (f'_exists u).\nLet f'_injective :\n injection f'.\nProof.\nAdmitted.\nLet f'_surjective :\n surjection f'.\nProof.\nAdmitted.\nLet card_U :\n cardinality {u : Z | 1 <= u <= p - 1} (Z.to_nat (p - 1)).\nProof.\nAdmitted.\nLet U_finite :\n finite {u : Z | 1 <= u <= p - 1}.\nProof.\nAdmitted.\n\nLet P' := product Z (ZpZmult p) (ZpZmult_comm p) (ZpZmult_assoc p) 1 _ U_finite (fun x => `x).\nLet P'_not_0 :\n P' mod p <> 0.\nProof.\nAdmitted.\nLet P'1 :\n product Z (ZpZmult p) (ZpZmult_comm p) (ZpZmult_assoc p) 1 _ U_finite (compose (proj1_sig (P := fun k => 1 <= k <= p - 1)) f') =\n (ZpZmult p) (product Z (ZpZmult p) (ZpZmult_comm p) (ZpZmult_assoc p) 1 _ U_finite (fun x => `x))\n (product Z (ZpZmult p) (ZpZmult_comm p) (ZpZmult_assoc p) 1 _ U_finite (fun x => a)).\nProof.\nAdmitted.\nLet P'2 :\n product Z (ZpZmult p) (ZpZmult_comm p) (ZpZmult_assoc p) 1 _ U_finite (compose (proj1_sig (P := fun k => 1 <= k <= p - 1)) f') = P'.\nProof.\nAdmitted.\nLet P'3 :\n (product Z (ZpZmult p) (ZpZmult_comm p) (ZpZmult_assoc p) 1 _ U_finite (fun x => a)) mod p = (a ^ (p - 1)) mod p.\nProof.\nAdmitted.\nTheorem FLT :\n (a ^ (p - 1)) mod p = 1.\nProof.\nAdmitted.\nLet U_finite :\n finite {x : Z | 1 <= x <= p - 1}.\nProof.\nAdmitted.\nTheorem Wilson :\n product Z (ZpZmult p) (ZpZmult_comm p) (ZpZmult_assoc p) 1 _ U_finite (fun x => `x)\n = -1 mod p.\nProof.\nAdmitted.\nLet if_a_0 :\n a mod p = 0 -> 0 mod p = (a ^ ((p - 1) / 2)) mod p.\nProof.\nAdmitted.\nLet if_a_square :\n a mod p <> 0 -> (exists y, (y ^ 2) mod p = a mod p) ->\n 1 mod p = (a ^ ((p - 1) / 2)) mod p.\nProof.\nAdmitted.\nLet if_a_not_square :\n a mod p <> 0 -> (forall y, (y * y) mod p <> a mod p) ->\n -1 mod p = (a ^ ((p - 1) / 2)) mod p.\nProof.\nAdmitted.\nTheorem Eulers_criterion :\n (legendre p a) mod p = a ^ ((p - 1) / 2) mod p.\nProof.\nAdmitted.\nLet p_positive_rev :\n p > 0.\nProof.\nAdmitted.\nLet p_not_0 :\n p <> 0.\nProof.\nAdmitted.\nLet eq_mod_2 :\n forall x y : Z, (x + y) mod 2 = 0 -> x mod 2 = y mod 2.\nProof.\nAdmitted.\nLet div_mod_mod_2_even :\n forall a : Z, a mod 2 = 0 -> (a / p) mod 2 = (a mod p) mod 2.\nProof.\nAdmitted.\nLet div_mod_mod_2_odd :\n forall a : Z, a mod 2 = 1 -> (a / p) mod 2 = (a mod p + 1) mod 2.\nProof.\nAdmitted.\n\nVariable q : Z.\nHypothesis q_not_0 : q mod p <> 0.\nHypothesis q_postive : q >= 0.\n\nLet r (u : {u : Z | 1 <= u <= p - 1 /\\ u mod 2 = 0}) :=\n (q * `u) mod p.\nLet r_positive :\n forall (u : {u : Z | 1 <= u <= p - 1 /\\ u mod 2 = 0}), 0 <= r u.\nProof.\nAdmitted.\nLet r' (u : {u : Z | 1 <= u <= p - 1 /\\ u mod 2 = 0}) :=\n ((Zpower (-1) (r u)) * (r u)) mod p.\nLet r''_ex (u : {u : Z | 1 <= u <= p - 1 /\\ u mod 2 = 0}) :\n 1 <= (r' u) <= p - 1 /\\ (r' u) mod 2 = 0.\nProof.\nAdmitted.\nLet r'' (u : {u : Z | 1 <= u <= p - 1 /\\ u mod 2 = 0}) :=\n exist (fun k => 1 <= k <= p - 1 /\\ k mod 2 = 0) (r' u) (r''_ex u).\nLet r''_inj1 :\n forall u1 u2, r' u1 = r' u2 -> Even (r u1) -> Odd (r u2) -> r u1 = r u2.\nProof.\nAdmitted.\nLet r''_injective :\n injection r''.\nProof.\nAdmitted.\nLet r''_surjective :\n surjection r''.\nProof.\nAdmitted.\n\nLet card_R :\n cardinality {u : Z | 1 <= u <= p - 1 /\\ u mod 2 = 0} (Z.to_nat ((p - 1) / 2)).\nProof.\nAdmitted.\n\nLet R_finite :\n finite {u : Z | 1 <= u <= p - 1 /\\ u mod 2 = 0}.\nProof.\nAdmitted.\n\nLet mlt := ZpZmult p.\nLet mlt_comm := ZpZmult_comm p.\nLet mlt_assoc := ZpZmult_assoc p.\nLet one_id := one_idemp p p_prime.\n\nLet P := product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun x => `x).\nLet P_not_0 :\n P mod p <> 0.\nProof.\nAdmitted.\nLet P1 :\n product Z mlt mlt_comm mlt_assoc 1 _ R_finite r =\n mlt (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun x => q)) P.\nProof.\nAdmitted.\nLet P2 :\n product Z mlt mlt_comm mlt_assoc 1 _ R_finite r' =\n mlt (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => (-1) ^ (r u)))\n (product Z mlt mlt_comm mlt_assoc 1 _ R_finite r).\nProof.\nAdmitted.\nLet P3 :\n product Z mlt mlt_comm mlt_assoc 1 _ R_finite r' = P.\nProof.\nAdmitted.\nLet P4 :\n mlt (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => (-1) ^ (r u)))\n (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => (-1) ^ (r u)))\n = 1.\nProof.\nAdmitted.\nLet P5 :\n mlt P ((product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => (-1) ^ (r u)))) =\n mlt (product Z mlt mlt_comm mlt_assoc 1 _ R_finite r) 1.\nProof.\nAdmitted.\nLet P6 :\n mlt P (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => (-1) ^ (r u))) =\n mlt P (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => q)).\nProof.\nAdmitted.\nLet P7 :\n (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => (-1) ^ (r u))) mod p =\n (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => q)) mod p.\nProof.\nAdmitted.\nLet P8 :\n (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => (-1) ^ (r u))) =\n (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => (-1) ^ ((q * `u) / p))).\nProof.\nAdmitted.\nLet P9 :\n (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => (-1) ^ ((q * `u) / p))) mod p =\n (m1_pow (product Z Zplus Zplus_comm Zplus_assoc 0 _ R_finite (fun u => (q * `u) / p))) mod p.\nProof.\nAdmitted.\nLet P10 :\n (product Z mlt mlt_comm mlt_assoc 1 _ R_finite (fun u => q)) mod p =\n (q ^ ((p - 1) / 2)) mod p.\nProof.\nAdmitted.\nLet Eisensteins_lemma_mod_p :\n (legendre p q) mod p = (m1_pow (product Z Zplus Zplus_comm Zplus_assoc 0 _ R_finite (fun u => (q * `u) / p))) mod p.\nProof.\nAdmitted.\nLet p_not_2 :\n p <> 2.\nProof.\nAdmitted.\nLemma Eisensteins_lemma1 :\n legendre p q = m1_pow (product Z Zplus Zplus_comm Zplus_assoc 0 _ R_finite (fun u => (q * `u) / p)).\nProof.\nAdmitted.\nHypothesis q_odd : q mod 2 = 1.\nHypothesis q_prime : prime q.\nLet E1 :\n (product Z Zplus Zplus_comm Zplus_assoc 0 _ R_finite (fun u => (q * `u) / p)) mod 2 =\n (product Z Zplus Zplus_comm Zplus_assoc 0 _ U_finite (fun u => (q * `u) / p)) mod 2.\nProof.\nAdmitted.\nDefinition EL := (product Z Zplus Zplus_comm Zplus_assoc 0 _ U_finite (fun u => (q * `u) / p)).\nLemma EL1 :\n 0 <= EL.\nProof.\nAdmitted.\nLet q_ge_1 :\n q > 1.\nProof.\nAdmitted.\nLet p_not_2 :\n p <> 2.\nProof.\nAdmitted.\nLet q_not_2 :\n q <> 2.\nProof.\nAdmitted.\nLet p2_pos :\n (p - 1) / 2 > 0.\nProof.\nAdmitted.\nLet q2_pos :\n (q - 1) / 2 > 0.\nProof.\nAdmitted.\nLet p_mod_q_not_0 :\n p mod q <> 0.\nProof.\nAdmitted.\nLet q_mod_p_not_0 :\n q mod p <> 0.\nProof.\nAdmitted.\nLet a := EL p p_prime p_odd q.\nLet b := EL q q_prime q_odd p.\nLet QR1 :\n cardinality {s : {s : Z * Z | 1 <= fst s <= (p - 1) / 2 /\\ 1 <= snd s <= (q - 1) / 2} |\n p * snd `s <= q * fst `s}\n (Z.to_nat a).\nProof.\nAdmitted.\nLet QR2 :\n cardinality {s : {s : Z * Z | 1 <= fst s <= (p - 1) / 2 /\\ 1 <= snd s <= (q - 1) / 2} |\n ~ (p * snd `s <= q * fst `s)}\n (Z.to_nat b).\nProof.\nAdmitted.\nLet QR3 :\n cardinality {s : Z * Z | 1 <= fst s <= (p - 1) / 2 /\\ 1 <= snd s <= (q - 1) / 2}\n (Z.to_nat a + Z.to_nat b).\nProof.\nAdmitted.\nLet QR4 :\n cardinality {s : Z * Z | 1 <= fst s <= (p - 1) / 2 /\\ 1 <= snd s <= (q - 1) / 2}\n (Z.to_nat (((p - 1) / 2) * ((q - 1) / 2))).\nProof.\nAdmitted.\nLet QR5 :\n (Z.to_nat a + Z.to_nat b)%nat = (Z.to_nat (((p - 1) / 2) * ((q - 1) / 2))).\nProof.\nAdmitted.\nLet QR6 :\n a + b = ((p - 1) / 2) * ((q - 1) / 2).\nProof.\nAdmitted.\nTheorem Quadratic_reciprocity :\n (legendre p q) * (legendre q p) = (-1) ^ (((p - 1) / 2) * ((q - 1) / 2)).\nProof.\nAdmitted.\nEnd Quadratic_reciprocity.\n" }, { "theorem_id": 22, "title": "010_euler_s_generalization_of_fermat_s_little_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "loadt \"Library/binary.ml\";;\n\nlet NSUM_BOUND_LEMMA = `!f a b n. nsum(a..b) f = n ==> !i. a <= i /\\ i <= b ==> f(i) <= n`;;\n\nlet CARD_EQ_LEMMA = `!f:A->B g s t.\n FINITE s /\\ FINITE t /\\\n (!x. x IN s ==> f(x) IN t) /\\\n (!y. y IN t ==> g(y) IN s) /\\\n (!x. x IN s ==> g(f x) = x) /\\\n (!y. y IN t ==> f(g y) = y)\n ==> FINITE s /\\ FINITE t /\\ CARD s = CARD t`;;\n\nlet index = define\n `index n = if n = 0 then 0 else if ODD n then 0 else SUC(index(n DIV 2))`;;\n\nlet oddpart = define\n `oddpart n = if n = 0 then 0 else if ODD n then n else oddpart(n DIV 2)`;;\n\nlet INDEX_ODDPART_WORK = `!n. n = 2 EXP (index n) * oddpart n /\\ (ODD(oddpart n) <=> ~(n = 0))`;;\n\nlet INDEX_ODDPART_DECOMPOSITION = `!n. n = 2 EXP (index n) * oddpart n`;;\n\nlet ODD_ODDPART = `!n. ODD(oddpart n) <=> ~(n = 0)`;;\n\nlet ODDPART_LE = `!n. oddpart n <= n`;;\n\nlet INDEX_ODDPART_UNIQUE = `!i m i' m'. ODD m /\\ ODD m'\n ==> (2 EXP i * m = 2 EXP i' * m' <=> i = i' /\\ m = m')`;;\n\nlet INDEX_ODDPART = `!i m. ODD m ==> index(2 EXP i * m) = i /\\ oddpart(2 EXP i * m) = m`;;\n\nparse_as_infix(\"partitions\",(12,\"right\"));;\n\nlet partitions = new_definition\n `p partitions n <=> (!i. ~(p i = 0) ==> 1 <= i /\\ i <= n) /\\\n nsum(1..n) (\\i. p(i) * i) = n`;;\n\nlet PARTITIONS_BOUND = `!p n. p partitions n ==> !i. p(i) <= n`;;\n\nlet FINITE_PARTITIONS_LEMMA = `!m n. FINITE {p | (!i. p(i) <= n) /\\ !i. m <= i ==> p(i) = 0}`;;\n\nlet FINITE_PARTITIONS = `!n. FINITE {p | p partitions n}`;;\n\nlet FINITE_SUBSET_PARTITIONS = `!P n. FINITE {p | p partitions n /\\ P p}`;;\n\nlet odd_of_distinct = new_definition\n `odd_of_distinct p =\n \\i. if ODD i then nsum {j | p(2 EXP j * i) = 1} (\\j. 2 EXP j) else 0`;;\n\nlet distinct_of_odd = new_definition\n `distinct_of_odd p = \\i. if (index i) IN bitset (p(oddpart i)) then 1 else 0`;;\n\nlet ODD_ODD_OF_DISTINCT = `!p i. ~(odd_of_distinct p i = 0) ==> ODD i`;;\n\nlet DISTINCT_DISTINCT_OF_ODD = `!p i. distinct_of_odd p i <= 1`;;\n\nlet SUPPORT_ODD_OF_DISTINCT = `!p. (!i. ~(p i = 0) ==> i <= n)\n ==> !i. ~(odd_of_distinct p i = 0) ==> 1 <= i /\\ i <= n`;;\n\nlet SUPPORT_DISTINCT_OF_ODD = `!p. (!i. p(i) * i <= n) /\\\n (!i. ~(p i = 0) ==> ODD i)\n ==> !i. ~(distinct_of_odd p i = 0) ==> 1 <= i /\\ i <= n`;;\n\nlet ODD_OF_DISTINCT_OF_ODD = `!p. (!i. ~(p(i) = 0) ==> ODD i)\n ==> odd_of_distinct (distinct_of_odd p) = p`;;\n\nlet DISTINCT_OF_ODD_OF_DISTINCT = `!p. (!i. ~(p i = 0) ==> 1 <= i /\\ i <= n) /\\ (!i. p(i) <= 1)\n ==> distinct_of_odd (odd_of_distinct p) = p`;;\n\nlet NSUM_DISTINCT_OF_ODD = `!p. (!i. ~(p i = 0) ==> 1 <= i /\\ i <= n) /\\\n (!i. p(i) * i <= n) /\\\n (!i. ~(p(i) = 0) ==> ODD i)\n ==> nsum(1..n) (\\i. distinct_of_odd p i * i) =\n nsum(1..n) (\\i. p i * i)`;;\n\nlet DISTINCT_OF_ODD = `!p. p IN {p | p partitions n /\\ !i. ~(p(i) = 0) ==> ODD i}\n ==> (distinct_of_odd p) IN {p | p partitions n /\\ !i. p(i) <= 1}`;;\n\nlet ODD_OF_DISTINCT = `!p. p IN {p | p partitions n /\\ !i. p(i) <= 1}\n ==> (odd_of_distinct p) IN\n {p | p partitions n /\\ !i. ~(p(i) = 0) ==> ODD i}`;;\n\nlet EULER_PARTITION_THEOREM = `FINITE {p | p partitions n /\\ !i. p(i) <= 1} /\\\n FINITE {p | p partitions n /\\ !i. ~(p(i) = 0) ==> ODD i} /\\\n CARD {p | p partitions n /\\ !i. p(i) <= 1} =\n CARD {p | p partitions n /\\ !i. ~(p(i) = 0) ==> ODD i}`;;" }, { "theorem_id": 22, "title": "010_euler_s_generalization_of_fermat_s_little_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Fundamental facts about Euler's totient function\\\n\ntheory Totient\nimports\n Complex_Main\n \"HOL-Computational_Algebra.Primes\"\n Cong\nbegin\n \ndefinition totatives :: \"nat \\ nat set\" where\n \"totatives n = {k \\ {0<..n}. coprime k n}\"\n\nlemma in_totatives_iff: \"k \\ totatives n \\ k > 0 \\ k \\ n \\ coprime k n\"\n by sorry\n \nlemma totatives_code [code]: \"totatives n = Set.filter (\\k. coprime k n) {0<..n}\"\n by sorry\n \nlemma finite_totatives [simp]: \"finite (totatives n)\"\n by sorry\n \nlemma totatives_subset: \"totatives n \\ {0<..n}\"\n by sorry\n \nlemma zero_not_in_totatives [simp]: \"0 \\ totatives n\"\n by sorry\n \nlemma totatives_le: \"x \\ totatives n \\ x \\ n\"\n by sorry\n \nlemma totatives_less: \n assumes \"x \\ totatives n\" \"n > 1\"\n shows \"x < n\"\n by sorry\n\nlemma totatives_0 [simp]: \"totatives 0 = {}\"\n by sorry\n\nlemma totatives_1 [simp]: \"totatives 1 = {Suc 0}\"\n by sorry\n\nlemma totatives_Suc_0 [simp]: \"totatives (Suc 0) = {Suc 0}\"\n by sorry\n\nlemma one_in_totatives [simp]: \"n > 0 \\ Suc 0 \\ totatives n\"\n by sorry\n\nlemma totatives_eq_empty_iff [simp]: \"totatives n = {} \\ n = 0\"\n by sorry\n \nlemma minus_one_in_totatives:\n assumes \"n \\ 2\"\n shows \"n - 1 \\ totatives n\"\n by sorry\n\nlemma power_in_totatives:\n assumes \"m > 1\" \"coprime m g\"\n shows \"g ^ i mod m \\ totatives m\"\n by sorry\n\nlemma totatives_prime_power_Suc:\n assumes \"prime p\"\n shows \"totatives (p ^ Suc n) = {0<..p^Suc n} - (\\m. p * m) ` {0<..p^n}\"\n by sorry\n\nlemma totatives_prime: \"prime p \\ totatives p = {0<.. 1\" \"m2 > 1\" \"coprime m1 m2\"\n shows \"bij_betw (\\x. (x mod m1, x mod m2)) (totatives (m1 * m2)) \n (totatives m1 \\ totatives m2)\"\n by sorry\n\nlemma bij_betw_totatives_gcd_eq:\n fixes n d :: nat\n assumes \"d dvd n\" \"n > 0\"\n shows \"bij_betw (\\k. k * d) (totatives (n div d)) {k\\{0<..n}. gcd k n = d}\"\n by sorry\n\ndefinition totient :: \"nat \\ nat\" where\n \"totient n = card (totatives n)\"\n \nprimrec totient_naive :: \"nat \\ nat \\ nat \\ nat\" where\n \"totient_naive 0 acc n = acc\"\n| \"totient_naive (Suc k) acc n =\n (if coprime (Suc k) n then totient_naive k (acc + 1) n else totient_naive k acc n)\"\n \nlemma totient_naive:\n \"totient_naive k acc n = card {x \\ {0<..k}. coprime x n} + acc\"\n by sorry\n \nlemma totient_code_naive [code]: \"totient n = totient_naive n 0 n\"\n by sorry\n\nlemma totient_le: \"totient n \\ n\"\n by sorry\n \nlemma totient_less: \n assumes \"n > 1\"\n shows \"totient n < n\"\n by sorry\n\nlemma totient_0 [simp]: \"totient 0 = 0\"\n by sorry\n\nlemma totient_Suc_0 [simp]: \"totient (Suc 0) = Suc 0\"\n by sorry\n\nlemma totient_1 [simp]: \"totient 1 = Suc 0\"\n by sorry\n\nlemma totient_0_iff [simp]: \"totient n = 0 \\ n = 0\"\n by sorry\n\nlemma totient_gt_0_iff [simp]: \"totient n > 0 \\ n > 0\"\n by sorry\n\nlemma totient_gt_1:\n assumes \"n > 2\"\n shows \"totient n > 1\"\n by sorry\n\nlemma card_gcd_eq_totient:\n \"n > 0 \\ d dvd n \\ card {k\\{0<..n}. gcd k n = d} = totient (n div d)\"\n by sorry\n \nlemma totient_divisor_sum: \"(\\d | d dvd n. totient d) = n\"\n by sorry\n\nlemma totient_mult_coprime:\n assumes \"coprime m n\"\n shows \"totient (m * n) = totient m * totient n\"\n by sorry\n\nlemma totient_prime_power_Suc:\n assumes \"prime p\"\n shows \"totient (p ^ Suc n) = p ^ n * (p - 1)\"\n by sorry\n\nlemma totient_prime_power:\n assumes \"prime p\" \"n > 0\"\n shows \"totient (p ^ n) = p ^ (n - 1) * (p - 1)\"\n by sorry\n\nlemma totient_imp_prime:\n assumes \"totient p = p - 1\" \"p > 0\"\n shows \"prime p\"\n by sorry\n \nlemma totient_prime:\n assumes \"prime p\"\n shows \"totient p = p - 1\"\n by sorry\n\nlemma totient_2 [simp]: \"totient 2 = 1\"\n and totient_3 [simp]: \"totient 3 = 2\"\n and totient_5 [simp]: \"totient 5 = 4\"\n and totient_7 [simp]: \"totient 7 = 6\"\n by sorry\n \nlemma totient_4 [simp]: \"totient 4 = 2\"\n and totient_8 [simp]: \"totient 8 = 4\"\n and totient_9 [simp]: \"totient 9 = 6\"\n by sorry\n \nlemma totient_6 [simp]: \"totient 6 = 2\"\n by sorry\n\nlemma totient_even:\n assumes \"n > 2\"\n shows \"even (totient n)\"\n by sorry\n\nlemma totient_prod_coprime:\n assumes \"pairwise coprime (f ` A)\" \"inj_on f A\"\n shows \"totient (prod f A) = (\\a\\A. totient (f a))\"\n by sorry\n\nlemma prime_power_eq_imp_eq:\n fixes p q :: \"'a :: factorial_semiring\"\n assumes \"prime p\" \"prime q\" \"m > 0\"\n assumes \"p ^ m = q ^ n\"\n shows \"p = q\"\n by sorry\n\nlemma totient_formula1:\n assumes \"n > 0\"\n shows \"totient n = (\\p\\prime_factors n. p ^ (multiplicity p n - 1) * (p - 1))\"\n by sorry\n\nlemma totient_dvd:\n assumes \"m dvd n\"\n shows \"totient m dvd totient n\"\n by sorry\n \nlemma totient_dvd_mono:\n assumes \"m dvd n\" \"n > 0\"\n shows \"totient m \\ totient n\"\n by sorry\n\nlemma prime_factors_power: \"n > 0 \\ prime_factors (x ^ n) = prime_factors x\"\n by sorry\n\nlemma totient_formula2:\n \"real (totient n) = real n * (\\p\\prime_factors n. 1 - 1 / real p)\"\n by sorry\n\nlemma totient_gcd: \"totient (a * b) * totient (gcd a b) = totient a * totient b * gcd a b\"\n by sorry\n \nlemma totient_mult: \"totient (a * b) = totient a * totient b * gcd a b div totient (gcd a b)\"\n by sorry\n\nlemma of_nat_eq_1_iff: \"of_nat x = (1 :: 'a :: {semiring_1, semiring_char_0}) \\ x = 1\"\n by sorry\n\nlemma odd_imp_coprime_nat:\n assumes \"odd (n::nat)\"\n shows \"coprime n 2\"\n by sorry\n\nlemma totient_double: \"totient (2 * n) = (if even n then 2 * totient n else totient n)\"\n by sorry\n\nlemma totient_power_Suc: \"totient (n ^ Suc m) = n ^ m * totient n\"\n by sorry\n \nlemma totient_power: \"m > 0 \\ totient (n ^ m) = n ^ (m - 1) * totient n\"\n by sorry\n\nlemma totient_gcd_lcm: \"totient (gcd a b) * totient (lcm a b) = totient a * totient b\"\n by sorry\n\nend" }, { "theorem_id": 22, "title": "010_euler_s_generalization_of_fermat_s_little_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Joey van Langen, Casper Putz\n-/\nmodule\n\npublic import Mathlib.Algebra.CharP.Algebra\npublic import Mathlib.Algebra.CharP.Reduced\npublic import Mathlib.Algebra.Field.ZMod\npublic import Mathlib.Data.Nat.Prime.Int\npublic import Mathlib.Data.ZMod.ValMinAbs\npublic import Mathlib.LinearAlgebra.FreeModule.Finite.Matrix\npublic import Mathlib.FieldTheory.Finiteness\npublic import Mathlib.FieldTheory.Galois.Notation\npublic import Mathlib.FieldTheory.Perfect\npublic import Mathlib.FieldTheory.Separable\npublic import Mathlib.RingTheory.IntegralDomain\n\n/-!\n# Finite fields\n\nThis file contains basic results about finite fields.\nThroughout most of this file, `K` denotes a finite field\nand `q` is notation for the cardinality of `K`.\n\nSee `RingTheory.IntegralDomain` for the fact that the unit group of a finite field is a\ncyclic group, as well as the fact that every finite integral domain is a field\n(`Fintype.fieldOfDomain`).\n\n## Main results\n\n1. `Fintype.card_units`: The unit group of a finite field has cardinality `q - 1`.\n2. `sum_pow_units`: The sum of `x^i`, where `x` ranges over the units of `K`, is\n - `q-1` if `q-1 ∣ i`\n - `0` otherwise\n3. `FiniteField.card`: The cardinality `q` is a power of the characteristic of `K`.\n See `FiniteField.card'` for a variant.\n\n## Notation\n\nThroughout most of this file, `K` denotes a finite field\nand `q` is notation for the cardinality of `K`.\n\n## Implementation notes\n\nWhile `Fintype Kˣ` can be inferred from `Fintype K` in the presence of `DecidableEq K`,\nin this file we take the `Fintype Kˣ` argument directly to reduce the chance of typeclass\ndiamonds, as `Fintype` carries data.\n\n-/\n\n@[expose] public section\n\n\nvariable {K : Type*} {R : Type*}\n\nlocal notation \"q\" => Fintype.card K\n\nopen Finset\n\nopen scoped Polynomial\n\nnamespace FiniteField\n\nsection Polynomial\n\nvariable [CommRing R] [IsDomain R]\n\nopen Polynomial\n\n/-- The cardinality of a field is at most `n` times the cardinality of the image of a degree `n`\n polynomial -/\ntheorem card_image_polynomial_eval [DecidableEq R] [Fintype R] {p : R[X]} (hp : 0 < p.degree) :\n Fintype.card R ≤ natDegree p * #(univ.image fun x => eval x p) :=\n Finset.card_le_mul_card_image _ _ (fun a _ =>\n calc\n _ = #(p - C a).roots.toFinset :=\n congr_arg card (by simp [Finset.ext_iff, ← mem_roots_sub_C hp])\n _ ≤ Multiset.card (p - C a).roots := Multiset.toFinset_card_le _\n _ ≤ _ := card_roots_sub_C' hp)\n\n/-- If `f` and `g` are quadratic polynomials, then the `f.eval a + g.eval b = 0` has a solution. -/\ntheorem exists_root_sum_quadratic [Fintype R] {f g : R[X]} (hf2 : degree f = 2) (hg2 : degree g = 2)\n (hR : Fintype.card R % 2 = 1) : ∃ a b, f.eval a + g.eval b = 0 :=\n letI := Classical.decEq R\n suffices ¬Disjoint (univ.image fun x : R => eval x f)\n (univ.image fun x : R => eval x (-g)) by\n simp only [disjoint_left, mem_image] at this\n push Not at this\n rcases this with ⟨x, ⟨a, _, ha⟩, ⟨b, _, hb⟩⟩\n exact ⟨a, b, by rw [ha, ← hb, eval_neg, neg_add_cancel]⟩\n fun hd : Disjoint _ _ =>\n lt_irrefl (2 * #((univ.image fun x : R => eval x f) ∪ univ.image fun x : R => eval x (-g))) <|\n calc 2 * #((univ.image fun x : R => eval x f) ∪ univ.image fun x : R => eval x (-g))\n ≤ 2 * Fintype.card R := Nat.mul_le_mul_left _ (Finset.card_le_univ _)\n _ = Fintype.card R + Fintype.card R := two_mul _\n _ < natDegree f * #(univ.image fun x : R => eval x f) +\n natDegree (-g) * #(univ.image fun x : R => eval x (-g)) :=\n (add_lt_add_of_lt_of_le\n (lt_of_le_of_ne (card_image_polynomial_eval (by rw [hf2]; decide))\n (mt (congr_arg (· % 2)) (by simp [natDegree_eq_of_degree_eq_some hf2, hR])))\n (card_image_polynomial_eval (by rw [degree_neg, hg2]; decide)))\n _ = 2 * #((univ.image fun x : R => eval x f) ∪ univ.image fun x : R => eval x (-g)) := by sorry\nend Polynomial\n\ntheorem prod_univ_units_id_eq_neg_one [CommRing K] [IsDomain K] [Fintype Kˣ] :\n ∏ x : Kˣ, x = (-1 : Kˣ) := by sorry\ntheorem card_cast_subgroup_card_ne_zero [Ring K] [NoZeroDivisors K] [Nontrivial K]\n (G : Subgroup Kˣ) [Fintype G] : (Fintype.card G : K) ≠ 0 := by sorry\ntheorem sum_subgroup_units_eq_zero [Ring K] [NoZeroDivisors K]\n {G : Subgroup Kˣ} [Fintype G] (hg : G ≠ ⊥) :\n ∑ x : G, (x.val : K) = 0 := by sorry\ntheorem sum_subgroup_units [Ring K] [NoZeroDivisors K]\n {G : Subgroup Kˣ} [Fintype G] [Decidable (G = ⊥)] :\n ∑ x : G, (x.val : K) = if G = ⊥ then 1 else 0 := by sorry\ntheorem sum_subgroup_pow_eq_zero [CommRing K] [NoZeroDivisors K]\n {G : Subgroup Kˣ} [Fintype G] {k : ℕ} (k_pos : k ≠ 0) (k_lt_card_G : k < Fintype.card G) :\n ∑ x : G, ((x : Kˣ) : K) ^ k = 0 := by sorry\nvariable [GroupWithZero K] [Fintype K]\n\ntheorem pow_card_sub_one_eq_one (a : K) (ha : a ≠ 0) : a ^ (q - 1) = 1 := by sorry\ntheorem pow_card (a : K) : a ^ q = a := by sorry\ntheorem pow_card_pow (n : ℕ) (a : K) : a ^ q ^ n = a := by sorry\nend\n\nvariable (K) [Field K] [Fintype K]\n\n/-- The cardinality `q` is a power of the characteristic of `K`. -/\n@[stacks 09HY \"first part\"]\ntheorem card (p : ℕ) [CharP K p] : ∃ n : ℕ+, Nat.Prime p ∧ q = p ^ (n : ℕ) := by sorry\ntheorem card' : ∃ (p : ℕ), CharP K p ∧ ∃ (n : ℕ+), Nat.Prime p ∧ Fintype.card K = p ^ (n : ℕ) :=\n let ⟨p, hc⟩ := CharP.exists K\n ⟨p, hc, @FiniteField.card K _ _ p hc⟩\n\nlemma isPrimePow_card : IsPrimePow (Fintype.card K) := by sorry\ntheorem cast_card_eq_zero : (q : K) = 0 := by sorry\ntheorem forall_pow_eq_one_iff (i : ℕ) : (∀ x : Kˣ, x ^ i = 1) ↔ q - 1 ∣ i := by sorry\ntheorem sum_pow_units [DecidableEq K] (i : ℕ) :\n (∑ x : Kˣ, (x ^ i : K)) = if q - 1 ∣ i then -1 else 0 := by sorry\ntheorem sum_pow_lt_card_sub_one (i : ℕ) (h : i < q - 1) : ∑ x : K, x ^ i = 0 := by sorry\nsection frobenius\n\nvariable (R) [CommRing R] [Algebra K R]\n\n/-- If `R` is an algebra over a finite field `K`, the Frobenius `K`-algebra endomorphism of `R` is\n given by raising every element of `R` to its `#K`-th power. -/\n@[simps!] def frobeniusAlgHom : R →ₐ[K] R where\n __ := powMonoidHom q\n map_zero' := zero_pow Fintype.card_pos.ne'\n map_add' _ _ := by sorry\ntheorem coe_frobeniusAlgHom : ⇑(frobeniusAlgHom K R) = (· ^ q) := rfl\n\n/-- If `R` is a perfect ring and an algebra over a finite field `K`, the Frobenius `K`-algebra\n endomorphism of `R` is an automorphism. -/\n@[simps!] noncomputable def frobeniusAlgEquiv (p : ℕ) [ExpChar R p] [PerfectRing R p] : R ≃ₐ[K] R :=\n .ofBijective (frobeniusAlgHom K R) <| by\n obtain ⟨p', _, n, hp, card_eq⟩ := card' K\n rw [coe_frobeniusAlgHom, card_eq]\n have : ExpChar K p' := ExpChar.prime hp\n nontriviality R\n have := ExpChar.eq ‹_› (expChar_of_injective_algebraMap (algebraMap K R).injective p')\n subst this\n apply bijective_iterateFrobenius\n\nvariable (L : Type*) [Field L] [Algebra K L]\n\n/-- If `L/K` is an algebraic extension of a finite field, the Frobenius `K`-algebra endomorphism\n of `L` is an automorphism. -/\n@[simps!] noncomputable def frobeniusAlgEquivOfAlgebraic [Algebra.IsAlgebraic K L] : Gal(L/K) :=\n (Algebra.IsAlgebraic.algEquivEquivAlgHom K L).symm (frobeniusAlgHom K L)\n\ntheorem coe_frobeniusAlgEquivOfAlgebraic [Algebra.IsAlgebraic K L] :\n ⇑(frobeniusAlgEquivOfAlgebraic K L) = (· ^ q) := rfl\n\nlemma coe_frobeniusAlgEquivOfAlgebraic_iterate [Algebra.IsAlgebraic K L] (n : ℕ) :\n (⇑(frobeniusAlgEquivOfAlgebraic K L))^[n] = (· ^ (Fintype.card K ^ n)) :=\n pow_iterate (Fintype.card K) n\n\nvariable [Finite L]\n\nopen Polynomial in\ntheorem orderOf_frobeniusAlgHom : orderOf (frobeniusAlgHom K L) = Module.finrank K L :=\n (orderOf_eq_iff Module.finrank_pos).mpr <| by\n have := Fintype.ofFinite L\n refine ⟨DFunLike.ext _ _ fun x ↦ ?_, fun m lt pos eq ↦ ?_⟩\n · simp_rw [AlgHom.coe_pow, coe_frobeniusAlgHom, pow_iterate, AlgHom.one_apply,\n ← Module.card_eq_pow_finrank, pow_card]\n have := card_le_degree_of_subset_roots (R := L) (p := X ^ q ^ m - X) (Z := univ) fun x _ ↦ by\n simp_rw [mem_roots', IsRoot, eval_sub, eval_pow, eval_X]\n have := DFunLike.congr_fun eq x\n rw [AlgHom.coe_pow, coe_frobeniusAlgHom, pow_iterate, AlgHom.one_apply, ← sub_eq_zero] at this\n refine ⟨fun h ↦ ?_, this⟩\n simpa [if_neg (Nat.one_lt_pow pos.ne' Fintype.one_lt_card).ne] using congr_arg (coeff · 1) h\n refine this.not_gt (((natDegree_sub_le ..).trans_eq ?_).trans_lt <|\n (Nat.pow_lt_pow_right Fintype.one_lt_card lt).trans_eq Module.card_eq_pow_finrank.symm)\n simp [Nat.one_le_pow _ _ Fintype.card_pos]\n\ntheorem orderOf_frobeniusAlgEquivOfAlgebraic :\n orderOf (frobeniusAlgEquivOfAlgebraic K L) = Module.finrank K L := by sorry\ntheorem bijective_frobeniusAlgHom_pow :\n Function.Bijective fun n : Fin (Module.finrank K L) ↦ frobeniusAlgHom K L ^ n.1 :=\n let e := (finCongr <| orderOf_frobeniusAlgHom K L).symm.trans <|\n finEquivPowers (orderOf_pos_iff.mp <| orderOf_frobeniusAlgHom K L ▸ Module.finrank_pos)\n (Subtype.val_injective.comp e.injective).bijective_of_nat_card_le\n ((card_algHom_le_finrank K L L).trans_eq <| by simp)\n\ntheorem bijective_frobeniusAlgEquivOfAlgebraic_pow :\n Function.Bijective fun n : Fin (Module.finrank K L) ↦ frobeniusAlgEquivOfAlgebraic K L ^ n.1 :=\n ((Algebra.IsAlgebraic.algEquivEquivAlgHom K L).bijective.of_comp_iff' _).mp <| by\n simpa only [Function.comp_def, map_pow] using bijective_frobeniusAlgHom_pow K L\n\ninstance (K L) [Finite L] [Field K] [Field L] [Algebra K L] : IsCyclic Gal(L/K) where\n exists_zpow_surjective :=\n have := Finite.of_injective _ (algebraMap K L).injective\n have := Fintype.ofFinite K\n ⟨frobeniusAlgEquivOfAlgebraic K L,\n fun f ↦ have ⟨n, hn⟩ := (bijective_frobeniusAlgEquivOfAlgebraic_pow K L).2 f; ⟨n, hn⟩⟩\n\nopen Polynomial in\ntheorem minpoly_frobeniusAlgHom :\n minpoly K (frobeniusAlgHom K L).toLinearMap = X ^ Module.finrank K L - 1 :=\n minpoly.eq_of_linearIndependent _ _ (leadingCoeff_X_pow_sub_one Module.finrank_pos)\n (LinearMap.ext fun x ↦ by simpa [sub_eq_zero, Module.End.coe_pow, orderOf_frobeniusAlgHom] using\n congr($(pow_orderOf_eq_one (frobeniusAlgHom K L)) x)) _\n (degree_X_pow_sub_C Module.finrank_pos _) <| by\n simpa [← AlgHom.toEnd_apply, ← map_pow] using (linearIndependent_algHom_toLinearMap K L L := by sorry\nend frobenius\n\nopen Polynomial\n\nsection\n\nvariable [Fintype K] (K' : Type*) [Field K'] {p n : ℕ}\n\ntheorem X_pow_card_sub_X_natDegree_eq (hp : 1 < p) : (X ^ p - X : K'[X]).natDegree = p := by sorry\ntheorem X_pow_card_pow_sub_X_natDegree_eq (hn : n ≠ 0) (hp : 1 < p) :\n (X ^ p ^ n - X : K'[X]).natDegree = p ^ n :=\n X_pow_card_sub_X_natDegree_eq K' <| Nat.one_lt_pow hn hp\n\ntheorem X_pow_card_sub_X_ne_zero (hp : 1 < p) : (X ^ p - X : K'[X]) ≠ 0 :=\n ne_zero_of_natDegree_gt <|\n calc\n 1 < _ := hp\n _ = _ := (X_pow_card_sub_X_natDegree_eq K' hp).symm\n\ntheorem X_pow_card_pow_sub_X_ne_zero (hn : n ≠ 0) (hp : 1 < p) : (X ^ p ^ n - X : K'[X]) ≠ 0 :=\n X_pow_card_sub_X_ne_zero K' <| Nat.one_lt_pow hn hp\n\nend\n\ntheorem roots_X_pow_card_sub_X : roots (X ^ q - X : K[X]) = Finset.univ.val := by sorry\nvariable {K}\n\ntheorem frobenius_pow {p : ℕ} [Fact p.Prime] [CharP K p] {n : ℕ} (hcard : q = p ^ n) :\n frobenius K p ^ n = 1 := by sorry\nopen Polynomial\n\ntheorem expand_card (f : K[X]) : expand K q f = f ^ q := by sorry\nend FiniteField\n\nnamespace ZMod\n\nopen FiniteField Polynomial\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem sq_add_sq (p : ℕ) [hp : Fact p.Prime] (x : ZMod p) : ∃ a b : ZMod p, a ^ 2 + b ^ 2 = x := by sorry\nend ZMod\n\n/-- If `p` is a prime natural number and `x` is an integer number, then there exist natural numbers\n`a ≤ p / 2` and `b ≤ p / 2` such that `a ^ 2 + b ^ 2 ≡ x [ZMOD p]`. This is a version of\n`ZMod.sq_add_sq` with estimates on `a` and `b`. -/\ntheorem Nat.sq_add_sq_zmodEq (p : ℕ) [Fact p.Prime] (x : ℤ) :\n ∃ a b : ℕ, a ≤ p / 2 ∧ b ≤ p / 2 ∧ (a : ℤ) ^ 2 + (b : ℤ) ^ 2 ≡ x [ZMOD p] := by sorry\ntheorem Nat.sq_add_sq_modEq (p : ℕ) [Fact p.Prime] (x : ℕ) :\n ∃ a b : ℕ, a ≤ p / 2 ∧ b ≤ p / 2 ∧ a ^ 2 + b ^ 2 ≡ x [MOD p] := by sorry\nnamespace CharP\n\ntheorem sq_add_sq (R : Type*) [Ring R] [IsDomain R] (p : ℕ) [NeZero p] [CharP R p] (x : ℤ) :\n ∃ a b : ℕ, ((a : R) ^ 2 + (b : R) ^ 2) = x := by sorry\nend CharP\n\nopen scoped Nat\n\nopen ZMod\n\n/-- The **Fermat-Euler totient theorem**. `Nat.ModEq.pow_totient` is an alternative statement\n of the same theorem. -/\n@[simp]\ntheorem ZMod.pow_totient {n : ℕ} (x : (ZMod n)ˣ) : x ^ φ n = 1 := by sorry\ntheorem Nat.ModEq.pow_totient {x n : ℕ} (h : Nat.Coprime x n) : x ^ φ n ≡ 1 [MOD n] := by sorry\ninstance instFiniteZModUnits : (n : ℕ) → Finite (ZMod n)ˣ\n| 0 => Finite.of_fintype ℤˣ\n| _ + 1 => inferInstance\n\nopen FiniteField\n\nnamespace ZMod\n\nvariable {p : ℕ} [Fact p.Prime]\n\ninstance : Subsingleton (Subfield (ZMod p)) :=\n subsingleton_of_bot_eq_top <| top_unique (a := ⊥) fun n _ ↦\n have := zsmul_mem (one_mem (⊥ : Subfield (ZMod p))) n.val\n by rwa [natCast_zsmul, Nat.smul_one_eq_cast, ZMod.natCast_zmod_val] at this\n\ntheorem fieldRange_castHom_eq_bot (p : ℕ) [Fact p.Prime] [DivisionRing K] [CharP K p] :\n (ZMod.castHom (m := p) dvd_rfl K).fieldRange = (⊥ : Subfield K) := by sorry\ntheorem pow_card (x : ZMod p) : x ^ p = x := by sorry\ntheorem pow_card_pow {n : ℕ} (x : ZMod p) : x ^ p ^ n = x := by sorry\ntheorem frobenius_zmod (p : ℕ) [Fact p.Prime] : frobenius (ZMod p) p = RingHom.id _ := by sorry\ntheorem card_units (p : ℕ) [Fact p.Prime] : Fintype.card (ZMod p)ˣ = p - 1 := by sorry\ntheorem units_pow_card_sub_one_eq_one (p : ℕ) [Fact p.Prime] (a : (ZMod p)ˣ) : a ^ (p - 1) = 1 := by sorry\ntheorem pow_card_sub_one_eq_one {a : ZMod p} (ha : a ≠ 0) :\n a ^ (p - 1) = 1 := by sorry\nlemma pow_card_sub_one (a : ZMod p) :\n a ^ (p - 1) = if a ≠ 0 then 1 else 0 := by sorry\ntheorem orderOf_units_dvd_card_sub_one (u : (ZMod p)ˣ) : orderOf u ∣ p - 1 :=\n orderOf_dvd_of_pow_eq_one <| units_pow_card_sub_one_eq_one _ _\n\ntheorem orderOf_dvd_card_sub_one {a : ZMod p} (ha : a ≠ 0) :\n orderOf a ∣ p - 1 :=\n orderOf_dvd_of_pow_eq_one <| pow_card_sub_one_eq_one ha\n\nopen Polynomial\n\ntheorem expand_card (f : Polynomial (ZMod p)) :\n expand (ZMod p) p f = f ^ p := by have h := FiniteField.expand_card f; rwa [ZMod.card p] at h\n\nend ZMod\n\n/-- **Fermat's Little Theorem**: for all `a : ℤ` coprime to `p`, we have\n`a ^ (p - 1) ≡ 1 [ZMOD p]`. -/\ntheorem Int.ModEq.pow_card_sub_one_eq_one {p : ℕ} (hp : Nat.Prime p) {n : ℤ} (hpn : IsCoprime n p) :\n n ^ (p - 1) ≡ 1 [ZMOD p] := by sorry\ntheorem Int.prime_dvd_pow_sub_one {p : ℕ} (hp : Nat.Prime p) {n : ℤ} (hpn : IsCoprime n p) :\n (p : ℤ) ∣ n ^ (p - 1) - 1 :=\n (ModEq.pow_card_sub_one_eq_one hp hpn).symm.dvd\n\ntheorem Int.ModEq.pow_prime_eq_self {p : ℕ} (hp : Nat.Prime p) (n : ℤ) : n ^ p ≡ n [ZMOD p] := by sorry\ntheorem Int.prime_dvd_pow_self_sub {p : ℕ} (hp : Nat.Prime p) (n : ℤ) : (p : ℤ) ∣ n ^ p - n :=\n (ModEq.pow_prime_eq_self hp n).symm.dvd\n\ntheorem Int.ModEq.pow_eq_pow {p x y : ℕ} (hp : Nat.Prime p) (h : p - 1 ∣ x - y) (hxy : y ≤ x)\n (hy : 0 < y) (n : ℤ) : n ^ x ≡ n ^ y [ZMOD p] := by sorry\ntheorem Nat.ModEq.pow_card_sub_one_eq_one {p : ℕ} (hp : p.Prime) {n : ℕ} (hpn : n.Coprime p) :\n n ^ (p - 1) ≡ 1 [MOD p] := by sorry\ntheorem Nat.pow_card_sub_one_sub_one_mod_card {p : ℕ} (hp : p.Prime) {n : ℕ} (hpn : n.Coprime p) :\n (n ^ (p - 1) - 1) % p = 0 :=\n Nat.sub_mod_eq_zero_of_mod_eq (Nat.ModEq.pow_card_sub_one_eq_one hp hpn)\n\ntheorem pow_pow_modEq_one (p m a : ℕ) : (1 + p * a) ^ (p ^ m) ≡ 1 [MOD p ^ m] := by sorry\ntheorem ZMod.eq_one_or_isUnit_sub_one {n p k : ℕ} [Fact p.Prime] (hn : n = p ^ k) (a : ZMod n)\n (ha : (orderOf a).Coprime n) : a = 1 ∨ IsUnit (a - 1) := by sorry\nsection prime_subfield\n\nvariable {F : Type*} [Field F]\n\ntheorem mem_bot_iff_intCast (p : ℕ) [Fact p.Prime] (K) [DivisionRing K] [CharP K p] {x : K} :\n x ∈ (⊥ : Subfield K) ↔ ∃ n : ℤ, n = x := by sorry\nvariable (F) (p : ℕ) [Fact p.Prime] [CharP F p]\n\ntheorem Subfield.card_bot : Nat.card (⊥ : Subfield F) = p := by sorry\ndef Subfield.fintypeBot : Fintype (⊥ : Subfield F) :=\n Fintype.subtype (univ.map ⟨_, (ZMod.castHom (m := p) dvd_rfl F).injective⟩)\n fun _ ↦ by simp_rw [Finset.mem_map, mem_univ, true_and, ← fieldRange_castHom_eq_bot p]; rfl\n\nopen Polynomial\n\ntheorem Subfield.roots_X_pow_char_sub_X_bot :\n letI := Subfield.fintypeBot F p\n (X ^ p - X : (⊥ : Subfield F)[X]).roots = Finset.univ.val := by sorry\ntheorem Subfield.splits_bot :\n Splits (X ^ p - X : (⊥ : Subfield F)[X]) := by sorry\ntheorem Subfield.mem_bot_iff_pow_eq_self {x : F} : x ∈ (⊥ : Subfield F) ↔ x ^ p = x := by sorry\nend prime_subfield\n\nnamespace FiniteField\n\nvariable {F : Type*} [Field F]\n\nsection Finite\n\nvariable [Finite F]\n\n/-- In a finite field of characteristic `2`, all elements are squares. -/\ntheorem isSquare_of_char_two (hF : ringChar F = 2) (a : F) : IsSquare a :=\n have : CharP F 2 := ringChar.of_eq hF\n isSquare_of_charTwo' a\n\n/-- In a finite field of odd characteristic, not every element is a square. -/\ntheorem exists_nonsquare (hF : ringChar F ≠ 2) : ∃ a : F, ¬IsSquare a := by sorry\nend Finite\n\nvariable [Fintype F]\n\n/-- The finite field `F` has even cardinality iff it has characteristic `2`. -/\ntheorem even_card_iff_char_two : ringChar F = 2 ↔ Fintype.card F % 2 = 0 := by sorry\ntheorem even_card_of_char_two (hF : ringChar F = 2) : Fintype.card F % 2 = 0 :=\n even_card_iff_char_two.mp hF\n\ntheorem odd_card_of_char_ne_two (hF : ringChar F ≠ 2) : Fintype.card F % 2 = 1 :=\n Nat.mod_two_ne_zero.mp (mt even_card_iff_char_two.mpr hF)\n\n/-- If `F` has odd characteristic, then for nonzero `a : F`, we have that `a ^ (#F / 2) = ±1`. -/\ntheorem pow_dichotomy (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) :\n a ^ (Fintype.card F / 2) = 1 ∨ a ^ (Fintype.card F / 2) = -1 := by sorry\ntheorem unit_isSquare_iff (hF : ringChar F ≠ 2) (a : Fˣ) :\n IsSquare a ↔ a ^ (Fintype.card F / 2) = 1 := by sorry\ntheorem isSquare_iff (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) :\n IsSquare a ↔ a ^ (Fintype.card F / 2) = 1 := by sorry\nend FiniteField\n" }, { "theorem_id": 22, "title": "010_euler_s_generalization_of_fermat_s_little_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From HB Require Import structures.\nFrom mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice.\nFrom mathcomp Require Import div fintype bigop prime finset fingroup morphism.\nFrom mathcomp Require Import perm automorphism quotient gproduct ssralg.\nFrom mathcomp Require Import finalg zmodp poly.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nLocal Open Scope group_scope.\nImport GRing.Theory.\n\nSection Cyclic.\n\nVariable gT : finGroupType.\nImplicit Types (a x y : gT) (A B : {set gT}) (G K H : {group gT}).\n\nDefinition cyclic A := [exists x, A == <[x]>].\n\nLemma cyclicP A : reflect (exists x, A = <[x]>) (cyclic A).\nProof.\nAdmitted.\n\nLemma cycle_cyclic x : cyclic <[x]>.\nProof.\nAdmitted.\n\nLemma cyclic1 : cyclic [1 gT].\nProof.\nAdmitted.\n\nSection Zpm.\n\nVariable a : gT.\n\nDefinition Zpm (i : 'Z_#[a]) := a ^+ i.\n\nLemma ZpmM : {in Zp #[a] &, {morph Zpm : x y / x * y}}.\nProof.\nAdmitted.\n\nCanonical Zpm_morphism := Morphism ZpmM.\n\nLemma im_Zpm : Zpm @* Zp #[a] = <[a]>.\nProof.\nAdmitted.\n\nLemma injm_Zpm : 'injm Zpm.\nProof.\nAdmitted.\n\nLemma eq_expg_mod_order m n : (a ^+ m == a ^+ n) = (m == n %[mod #[a]]).\nProof.\nAdmitted.\n\nLemma eq_expg_ord d (m n : 'I_d) :\n d <= #[a]%g -> (a ^+ m == a ^+ n) = (m == n).\nProof.\nAdmitted.\n\nLemma expgD_Zp d (n m : 'Z_d) : (d > 0)%N ->\n #[a]%g %| d -> a ^+ (n + m)%R = a ^+ n * a ^+ m.\nProof.\nAdmitted.\n\nLemma Zp_isom : isom (Zp #[a]) <[a]> Zpm.\nProof.\nAdmitted.\n\nLemma Zp_isog : isog (Zp #[a]) <[a]>.\nProof.\nAdmitted.\n\nEnd Zpm.\n\nLemma cyclic_abelian A : cyclic A -> abelian A.\nProof.\nAdmitted.\n\nLemma cycleMsub a b :\n commute a b -> coprime #[a] #[b] -> <[a]> \\subset <[a * b]>.\nProof.\nAdmitted.\n\nLemma cycleM a b :\n commute a b -> coprime #[a] #[b] -> <[a * b]> = <[a]> * <[b]>.\nProof.\nAdmitted.\n\nLemma cyclicM A B :\n cyclic A -> cyclic B -> B \\subset 'C(A) -> coprime #|A| #|B| ->\n cyclic (A * B).\nProof.\nAdmitted.\n\nLemma cyclicY K H :\n cyclic K -> cyclic H -> H \\subset 'C(K) -> coprime #|K| #|H| ->\n cyclic (K <*> H).\nProof.\nAdmitted.\n\nLemma order_dvdn a n : (#[a] %| n) = (a ^+ n == 1).\nProof.\nAdmitted.\n\nLemma order_inf a n : a ^+ n.\nProof.\nAdmitted.\n\nLemma order_dvdG G a : a \\in G -> #[a] %| #|G|.\nProof.\nAdmitted.\n\nLemma expg_cardG G a : a \\in G -> a ^+ #|G| = 1.\nProof.\nAdmitted.\n\nLemma expg_znat G x k : x \\in G -> x ^+ (k%:R : 'Z_(#|G|))%R = x ^+ k.\nProof.\nAdmitted.\n\nLemma expg_zneg G x (k : 'Z_(#|G|)) : x \\in G -> x ^+ (- k)%R = x ^- k.\nProof.\nAdmitted.\n\nLemma nt_gen_prime G x : prime #|G| -> x \\in G^# -> G :=: <[x]>.\nProof.\nAdmitted.\n\nLemma nt_prime_order p x : prime p -> x ^+ p = 1 -> x != 1 -> #[x] = p.\nProof.\nAdmitted.\n\nLemma orderXdvd a n : #[a ^+ n] %| #[a].\nProof.\nAdmitted.\n\nLemma orderXgcd a n : #[a ^+ n] = #[a] %/ gcdn #[a] n.\nProof.\nAdmitted.\n\nLemma orderXdiv a n : n %| #[a] -> #[a ^+ n] = #[a] %/ n.\nProof.\nAdmitted.\n\nLemma orderXexp p m n x : #[x] = (p ^ n)%N -> #[x ^+ (p ^ m)] = (p ^ (n - m))%N.\nProof.\nAdmitted.\n\nLemma orderXpfactor p k n x :\n #[x ^+ (p ^ k)] = n -> prime p -> p %| n -> #[x] = (p ^ k * n)%N.\nProof.\nAdmitted.\n\nLemma orderXprime p n x :\n #[x ^+ p] = n -> prime p -> p %| n -> #[x] = (p * n)%N.\nProof.\nAdmitted.\n\nLemma orderXpnat m n x : #[x ^+ m] = n -> \\pi(n).\nProof.\nAdmitted.\n\nLemma orderM a b :\n commute a b -> coprime #[a] #[b] -> #[a * b] = (#[a] * #[b])%N.\nProof.\nAdmitted.\n\nDefinition expg_invn A k := (egcdn k #|A|).1.\n\nLemma expgK G k :\n coprime #|G| k -> {in G, cancel (natexp^~ k) (natexp^~ (expg_invn G k))}.\nProof.\nAdmitted.\n\nLemma cyclic_dprod K H G :\n K \\x H = G -> cyclic K -> cyclic H -> cyclic G = coprime #|K| #|H| .\nProof.\nAdmitted.\n\nDefinition generator (A : {set gT}) a := A == <[a]>.\n\nLemma generator_cycle a : generator <[a]> a.\nProof.\nAdmitted.\n\nLemma cycle_generator a x : generator <[a]> x -> x \\in <[a]>.\nProof.\nAdmitted.\n\nLemma generator_order a b : generator <[a]> b -> #[a] = #[b].\nProof.\nAdmitted.\n\nEnd Cyclic.\n\nArguments cyclic {gT} A%_g.\nArguments generator {gT} A%_g a%_g.\nArguments expg_invn {gT} A%_g k%_N.\nArguments cyclicP {gT A}.\nPrenex Implicits cyclic Zpm.\n\nTheorem Euler_exp_totient a n : coprime a n -> a ^ totient n = 1 %[mod n].\nProof.\nAdmitted.\n\nSection Eltm.\n\nVariables (aT rT : finGroupType) (x : aT) (y : rT).\n\nDefinition eltm & #[y] %| #[x] := fun x_i => y ^+ invm (injm_Zpm x) x_i.\n\nHypothesis dvd_y_x : #[y] %| #[x].\n\nLemma eltmE i : eltm dvd_y_x (x ^+ i) = y ^+ i.\nProof.\nAdmitted.\n\nLemma eltm_id : eltm dvd_y_x x = y.\nProof.\nAdmitted.\n\nLemma eltmM : {in <[x]> &, {morph eltm dvd_y_x : x_i x_j / x_i * x_j}}.\nProof.\nAdmitted.\nCanonical eltm_morphism := Morphism eltmM.\n\nLemma im_eltm : eltm dvd_y_x @* <[x]> = <[y]>.\nProof.\nAdmitted.\n\nLemma ker_eltm : 'ker (eltm dvd_y_x) = <[x ^+ #[y]]>.\nProof.\nAdmitted.\n\nLemma injm_eltm : 'injm (eltm dvd_y_x) = (#[x] %| #[y]).\nProof.\nAdmitted.\n\nEnd Eltm.\n\nSection CycleSubGroup.\n\nVariable gT : finGroupType.\n\nLemma cycle_sub_group (a : gT) m :\n m %| #[a] ->\n [set H : {group gT} | H \\subset <[a]> & #|H| == m]\n = [set <[a ^+ (#[a] %/ m)]>%G].\nProof.\nAdmitted.\n\nLemma cycle_subgroup_char a (H : {group gT}) : H \\subset <[a]> -> H \\char <[a]>.\nProof.\nAdmitted.\n\nEnd CycleSubGroup.\n\nSection MorphicImage.\n\nVariables aT rT : finGroupType.\nVariables (D : {group aT}) (f : {morphism D >-> rT}) (x : aT).\nHypothesis Dx : x \\in D.\n\nLemma morph_order : #[f x] %| #[x].\nProof.\nAdmitted.\n\nLemma morph_generator A : generator A x -> generator (f @* A) (f x).\nProof.\nAdmitted.\n\nEnd MorphicImage.\n\nSection CyclicProps.\n\nVariables gT : finGroupType.\nImplicit Types (aT rT : finGroupType) (G H K : {group gT}).\n\nLemma cyclicS G H : H \\subset G -> cyclic G -> cyclic H.\nProof.\nAdmitted.\n\nLemma cyclicJ G x : cyclic (G :^ x) = cyclic G.\nProof.\nAdmitted.\n\nLemma eq_subG_cyclic G H K :\n cyclic G -> H \\subset G -> K \\subset G -> (H :==: K) = (#|H| == #|K|).\nProof.\nAdmitted.\n\nLemma cardSg_cyclic G H K :\n cyclic G -> H \\subset G -> K \\subset G -> (#|H| %| #|K|) = (H \\subset K).\nProof.\nAdmitted.\n\nLemma sub_cyclic_char G H : cyclic G -> (H \\char G) = (H \\subset G).\nProof.\nAdmitted.\n\nLemma morphim_cyclic rT G H (f : {morphism G >-> rT}) :\n cyclic H -> cyclic (f @* H).\nProof.\nAdmitted.\n\nLemma quotient_cycle x H : x \\in 'N(H) -> <[x]> / H = <[coset H x]>.\nProof.\nAdmitted.\n\nLemma quotient_cyclic G H : cyclic G -> cyclic (G / H).\nProof.\nAdmitted.\n\nLemma quotient_generator x G H :\n x \\in 'N(H) -> generator G x -> generator (G / H) (coset H x).\nProof.\nAdmitted.\n\nLemma prime_cyclic G : prime #|G| -> cyclic G.\nProof.\nAdmitted.\n\nLemma dvdn_prime_cyclic G p : prime p -> #|G| %| p -> cyclic G.\nProof.\nAdmitted.\n\nLemma cyclic_small G : #|G| <= 3 -> cyclic G.\nProof.\nAdmitted.\n\nEnd CyclicProps.\n\nSection IsoCyclic.\n\nVariables gT rT : finGroupType.\nImplicit Types (G H : {group gT}) (M : {group rT}).\n\nLemma injm_cyclic G H (f : {morphism G >-> rT}) :\n 'injm f -> H \\subset G -> cyclic (f @* H) = cyclic H.\nProof.\nAdmitted.\n\nLemma isog_cyclic G M : G \\isog M -> cyclic G = cyclic M.\nProof.\nAdmitted.\n\nLemma isog_cyclic_card G M : cyclic G -> isog G M = cyclic M && (#|M| == #|G|).\nProof.\nAdmitted.\n\nLemma injm_generator G H (f : {morphism G >-> rT}) x :\n 'injm f -> x \\in G -> H \\subset G ->\n generator (f @* H) (f x) = generator H x.\nProof.\nAdmitted.\n\nEnd IsoCyclic.\n\nSection Metacyclic.\n\nVariable gT : finGroupType.\nImplicit Types (A : {set gT}) (G H : {group gT}).\n\nDefinition metacyclic A :=\n [exists H : {group gT}, [&& cyclic H, H <| A & cyclic (A / H)]].\n\nLemma metacyclicP A : \n reflect (exists H : {group gT}, [/\\ cyclic H, H <| A & cyclic (A / H)]) \n (metacyclic A).\nProof.\nAdmitted.\n\nLemma metacyclic1 : metacyclic 1.\nProof.\nAdmitted.\n\nLemma cyclic_metacyclic A : cyclic A -> metacyclic A.\nProof.\nAdmitted.\n\nLemma metacyclicS G H : H \\subset G -> metacyclic G -> metacyclic H.\nProof.\nAdmitted.\n\nEnd Metacyclic.\n\nArguments metacyclic {gT} A%_g.\nArguments metacyclicP {gT A}.\n\nSection CyclicAutomorphism.\n\nVariable gT : finGroupType.\n\nSection CycleAutomorphism.\n\nVariable a : gT.\n\nSection CycleMorphism.\n\nVariable n : nat.\n\nDefinition cyclem & gT := fun x : gT => x ^+ n.\n\nLemma cyclemM : {in <[a]> & , {morph cyclem a : x y / x * y}}.\nProof.\nAdmitted.\n\nCanonical cyclem_morphism := Morphism cyclemM.\n\nEnd CycleMorphism.\n\nSection ZpUnitMorphism.\n\nVariable u : {unit 'Z_#[a]}.\n\nLemma injm_cyclem : 'injm (cyclem (val u) a).\nProof.\nAdmitted.\n\nLemma im_cyclem : cyclem (val u) a @* <[a]> = <[a]>.\nProof.\nAdmitted.\n\nDefinition Zp_unitm := aut injm_cyclem im_cyclem.\n\nEnd ZpUnitMorphism.\n\nLemma Zp_unitmM : {in units_Zp #[a] &, {morph Zp_unitm : u v / u * v}}.\nProof.\nAdmitted.\n\nCanonical Zp_unit_morphism := Morphism Zp_unitmM.\n\nLemma injm_Zp_unitm : 'injm Zp_unitm.\nProof.\nAdmitted.\n\nLemma generator_coprime m : generator <[a]> (a ^+ m) = coprime #[a] m.\nProof.\nAdmitted.\n\nLemma im_Zp_unitm : Zp_unitm @* units_Zp #[a] = Aut <[a]>.\nProof.\nAdmitted.\n\nLemma Zp_unit_isom : isom (units_Zp #[a]) (Aut <[a]>) Zp_unitm.\nProof.\nAdmitted.\n\nLemma Zp_unit_isog : isog (units_Zp #[a]) (Aut <[a]>).\nProof.\nAdmitted.\n\nLemma card_Aut_cycle : #|Aut <[a]>| = totient #[a].\nProof.\nAdmitted.\n\nLemma totient_gen : totient #[a] = #|[set x | generator <[a]> x]|.\nProof.\nAdmitted.\n\nLemma Aut_cycle_abelian : abelian (Aut <[a]>).\nProof.\nAdmitted.\n\nEnd CycleAutomorphism.\n\nVariable G : {group gT}.\n\nLemma Aut_cyclic_abelian : cyclic G -> abelian (Aut G).\nProof.\nAdmitted.\n\nLemma card_Aut_cyclic : cyclic G -> #|Aut G| = totient #|G|.\nProof.\nAdmitted.\n\nLemma sum_ncycle_totient :\n \\sum_(d < #|G|.\nProof.\nAdmitted.\n\nEnd CyclicAutomorphism.\n\nLemma sum_totient_dvd n : \\sum_(d < n.\nProof.\nAdmitted.\n\nSection FieldMulCyclic.\n\nImport GRing.Theory.\n\nVariables (gT : finGroupType) (G : {group gT}).\n\nLemma order_inj_cyclic :\n {in G &, forall x y, #[x] = #[y] -> <[x]> = <[y]>} -> cyclic G.\nProof.\nAdmitted.\n\nLemma div_ring_mul_group_cyclic (R : unitRingType) (f : gT -> R) :\n f 1 = 1%R -> {in G &, {morph f : u v / u * v >-> (u * v)%R}} ->\n {in G^#, forall x, f x - 1 \\in GRing.\nProof.\nAdmitted.\n\nLemma field_mul_group_cyclic (F : fieldType) (f : gT -> F) :\n {in G &, {morph f : u v / u * v >-> (u * v)%R}} ->\n {in G, forall x, f x = 1%R <-> x = 1} ->\n cyclic G.\nProof.\nAdmitted.\n\nEnd FieldMulCyclic.\n\nLemma field_unit_group_cyclic (F : finFieldType) (G : {group {unit F}}) :\n cyclic G.\nProof.\nAdmitted.\n\nLemma units_Zp_cyclic p : prime p -> cyclic (units_Zp p).\nProof.\nAdmitted.\n\nSection PrimitiveRoots.\n\nOpen Scope ring_scope.\nImport GRing.Theory.\n\nLemma has_prim_root_subproof (F : fieldType) (n : nat) (rs : seq F)\n (n_gt0 : n > 0)\n (rsn1 : all n.\nProof.\nAdmitted.\n\nLemma has_prim_root (F : fieldType) (n : nat) (rs : seq F) :\n n > 0 -> all n.\nProof.\nAdmitted.\n\nEnd PrimitiveRoots.\n\nSection AutPrime.\n\nVariable gT : finGroupType.\n\nLemma Aut_prime_cycle_cyclic (a : gT) : prime #[a] -> cyclic (Aut <[a]>).\nProof.\nAdmitted.\n\nLemma Aut_prime_cyclic (G : {group gT}) : prime #|G| -> cyclic (Aut G).\nProof.\nAdmitted.\n\nEnd AutPrime." }, { "theorem_id": 23, "title": "011_the_infinitude_of_primes", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "prioritize_num();;\n\nlet DIVIDES_0 = `!x. x divides 0`;;\n\nlet DIVIDES_ZERO = `!x. 0 divides x <=> x = 0`;;\n\nlet DIVIDES_1 = `!x. 1 divides x`;;\n\nlet DIVIDES_REFL = `!x. x divides x`;;\n\nlet DIVIDES_TRANS = `!a b c. a divides b /\\ b divides c ==> a divides c`;;\n\nlet DIVIDES_ADD = `!d a b. d divides a /\\ d divides b ==> d divides (a + b)`;;\n\nlet DIVIDES_SUB_EQ = `!d a b. d divides (a - b) <=> a < b \\/ (a == b) (mod d)`;;\n\nlet DIVIDES_SUB = `!d a b. d divides a /\\ d divides b ==> d divides (a - b)`;;\n\nlet DIVIDES_SUB_1 = `!d n. d divides n - 1 <=> n = 0 \\/ (n == 1) (mod d)`;;\n\nlet DIVIDES_LMUL = `!d a x. d divides a ==> d divides (x * a)`;;\n\nlet DIVIDES_RMUL = `!d a x. d divides a ==> d divides (a * x)`;;\n\nlet DIVIDES_ADD_REVR = `!d a b. d divides a /\\ d divides (a + b) ==> d divides b`;;\n\nlet DIVIDES_ADD_REVL = `!d a b. d divides b /\\ d divides (a + b) ==> d divides a`;;\n\nlet DIVIDES_MUL_L = `!a b c. a divides b ==> (c * a) divides (c * b)`;;\n\nlet DIVIDES_MUL_R = `!a b c. a divides b ==> (a * c) divides (b * c)`;;\n\nlet DIVIDES_LMUL2 = `!d a x. (x * d) divides a ==> d divides a`;;\n\nlet DIVIDES_RMUL2 = `!d a x. (d * x) divides a ==> d divides a`;;\n\nlet DIVIDES_CMUL2 = `!a b c. (c * a) divides (c * b) /\\ ~(c = 0) ==> a divides b`;;\n\nlet DIVIDES_LMUL2_EQ = `!a b c. ~(c = 0) ==> ((c * a) divides (c * b) <=> a divides b)`;;\n\nlet DIVIDES_RMUL2_EQ = `!a b c. ~(c = 0) ==> ((a * c) divides (b * c) <=> a divides b)`;;\n\nlet DIVIDES_EQ_ZERO = `!p n. n < p ==> (p divides n <=> n = 0)`;;\n\nlet DIVIDES_CASES = `!m n. n divides m ==> m = 0 \\/ m = n \\/ 2 * n <= m`;;\n\nlet DIVIDES_DIV_NOT = `!n x q r. x = q * n + r /\\ 0 < r /\\ r < n ==> ~(n divides x)`;;\n\nlet DIVIDES_MUL2 = `!a b c d. a divides b /\\ c divides d ==> (a * c) divides (b * d)`;;\n\nlet DIVIDES_EXP = `!x y n. x divides y ==> (x EXP n) divides (y EXP n)`;;\n\nlet DIVIDES_EXP2 = `!n x y. ~(n = 0) /\\ (x EXP n) divides y ==> x divides y`;;\n\nlet DIVIDES_EXP_LE_IMP = `!p m n. m <= n ==> (p EXP m) divides (p EXP n)`;;\n\nlet DIVIDES_EXP_LE = `!p m n. 2 <= p ==> ((p EXP m) divides (p EXP n) <=> m <= n)`;;\n\nlet DIVIDES_TRIVIAL_UPPERBOUND = `!p n. ~(n = 0) /\\ 2 <= p ==> ~((p EXP n) divides n)`;;\n\nlet DIVIDES_FACT = `!n p. 1 <= p /\\ p <= n ==> p divides (FACT n)`;;\n\nlet DIVIDES_2 = `!n. 2 divides n <=> EVEN(n)`;;\n\nlet DIVIDES_REXP_SUC = `!x y n. x divides y ==> x divides (y EXP (SUC n))`;;\n\nlet DIVIDES_REXP = `!x y n. x divides y /\\ ~(n = 0) ==> x divides (y EXP n)`;;\n\nlet FINITE_DIVISORS = `!n. ~(n = 0) ==> FINITE {d | d divides n}`;;\n\nlet FINITE_SPECIAL_DIVISORS = `!n. ~(n = 0) ==> FINITE {d | P d /\\ d divides n}`;;\n\nlet DIVISORS_EQ = `!m n. m = n <=> !d. d divides m <=> d divides n`;;\n\nlet MULTIPLES_EQ = `!m n. m = n <=> !d. m divides d <=> n divides d`;;\n\nlet DIVIDES_NSUM = `!n f s. FINITE s /\\ (!i. i IN s ==> n divides (f i))\n ==> n divides nsum s f`;;\n\nlet DIVIDES_GCD = `!a b d. d divides gcd(a,b) <=> d divides a /\\ d divides b`;;\n\nlet GCD_0 = `(!a. gcd(0,a) = a) /\\ (!a. gcd(a,0) = a)`;;\n\nlet GCD_ZERO = `!a b. gcd(a,b) = 0 <=> a = 0 /\\ b = 0`;;\n\nlet GCD_REFL = `!a. gcd(a,a) = a`;;\n\nlet GCD_1 = `(!a. gcd(1,a) = 1) /\\ (!a. gcd(a,1) = 1)`;;\n\nlet GCD_MULTIPLE = `!a b. gcd(b,a * b) = b`;;\n\nlet GCD_ADD = `(!a b. gcd(a + b,b) = gcd(a,b)) /\\\n (!a b. gcd(b + a,b) = gcd(a,b)) /\\\n (!a b. gcd(a,a + b) = gcd(a,b)) /\\\n (!a b. gcd(a,b + a) = gcd(a,b))`;;\n\nlet GCD_SUB = `(!a b. b <= a ==> gcd(a - b,b) = gcd(a,b)) /\\\n (!a b. a <= b ==> gcd(a,b - a) = gcd(a,b))`;;\n\nlet DIVIDES_GCD_LEFT = `!m n:num. m divides n <=> gcd(m,n) = m`;;\n\nlet DIVIDES_GCD_RIGHT = `!m n:num. n divides m <=> gcd(m,n) = n`;;\n\nlet GCD_COPRIME_LMUL = `!a b c. coprime(a,b) ==> gcd(a * b,c) = gcd(a,c) * gcd(b,c)`;;\n\nlet GCD_COPRIME_RMUL = `!a b c. coprime(a,b) ==> gcd(c,a * b) = gcd(c,a) * gcd(c,b)`;;\n\nlet DIVIDES_LMUL_GCD = `(!d a b. d divides gcd(d,a) * b <=> d divides a * b) /\\\n (!d a b. d divides gcd(a,d) * b <=> d divides a * b)`;;\n\nlet DIVIDES_RMUL_GCD = `(!d a b. d divides a * gcd(d,b) <=> d divides a * b) /\\\n (!d a b. d divides a * gcd(b,d) <=> d divides a * b)`;;\n\nlet GCD_MUL_COPRIME = `(!a b c. coprime(a,b) ==> gcd(a,b * c) = gcd(a,c)) /\\\n (!a b c. coprime(a,c) ==> gcd(a,b * c) = gcd(a,b)) /\\\n (!a b c. coprime(b,c) ==> gcd(a,b * c) = gcd(a,b) * gcd(a,c)) /\\\n (!a b c. coprime(a,c) ==> gcd(a * b,c) = gcd(b,c)) /\\\n (!a b c. coprime(b,c) ==> gcd(a * b,c) = gcd(a,c)) /\\\n (!a b c. coprime(a,b) ==> gcd(a * b,c) = gcd(a,c) * gcd(b,c))`;;\n\nlet GCD_SYM = `!a b. gcd(a,b) = gcd(b,a)`;;\n\nlet GCD_ASSOC = `!a b c. gcd(a,gcd(b,c)) = gcd(gcd(a,b),c)`;;\n\nlet GCD_LMUL = `!a b c. gcd(c * a, c * b) = c * gcd(a,b)`;;\n\nlet GCD_RMUL = `!a b c. gcd(a * c, b * c) = c * gcd(a,b)`;;\n\nlet GCD_BEZOUT_SUM = `!a b d x y. a * x + b * y = d ==> gcd(a,b) divides d`;;\n\nlet GCD_COPRIME_DIVIDES_LMUL = `!a b c:num. coprime(a,b) /\\ a divides c ==> gcd(a * b,c) = a * gcd(b,c)`;;\n\nlet GCD_COPRIME_DIVIDES_RMUL = `!a b c:num. coprime(b,c) /\\ b divides a ==> gcd(a,b * c) = b * gcd(a,c)`;;\n\nlet GCD_UNIQUE = `!d a b. (d divides a /\\ d divides b) /\\\n (!e. e divides a /\\ e divides b ==> e divides d) <=>\n d = gcd(a,b)`;;\n\nlet GCD_EQ = `(!d. d divides x /\\ d divides y <=> d divides u /\\ d divides v)\n ==> gcd(x,y) = gcd(u,v)`;;\n\nlet BEZOUT_GCD_STRONG = `!a b. ~(a = 0) ==> ?x y. a * x = b * y + gcd(a,b)`;;\n\nlet BEZOUT_ADD_STRONG = `!a b. ~(a = 0)\n ==> ?d x y. d divides a /\\ d divides b /\\ a * x = b * y + d`;;\n\nlet BEZOUT_GCD = `!a b. ?x y. a * x - b * y = gcd(a,b) \\/ b * x - a * y = gcd(a,b)`;;\n\nlet BEZOUT_ADD = `!a b. ?d x y. (d divides a /\\ d divides b) /\\\n (a * x = b * y + d \\/ b * x = a * y + d)`;;\n\nlet BEZOUT = `!a b. ?d x y. (d divides a /\\ d divides b) /\\\n (a * x - b * y = d \\/ b * x - a * y = d)`;;\n\nlet GCD_BEZOUT = `!a b d. (?x y. a * x - b * y = d \\/ b * x - a * y = d) <=>\n gcd(a,b) divides d`;;\n\nlet GCD_LE = `(!m n. gcd(m,n) <= m <=> (m = 0 ==> n = 0)) /\\\n (!m n. gcd(m,n) <= n <=> (n = 0 ==> m = 0))`;;\n\nlet GCD_LE_MIN_EQ = `!m n. gcd(m,n) <= MIN m n <=> (m = 0 <=> n = 0)`;;\n\nlet GCD_LE_MIN = `!m n. (m = 0 <=> n = 0) ==> gcd(m,n) <= MIN m n`;;\n\nlet GCD_LE_MAX = `!m n. gcd(m,n) <= MAX m n`;;\n\nlet COPRIME = `!a b. coprime(a,b) <=> !d. d divides a /\\ d divides b <=> d = 1`;;\n\nlet COPRIME_GCD = `!a b. coprime(a,b) <=> gcd(a,b) = 1`;;\n\nlet GCD_ONE = `!a b. coprime(a,b) ==> gcd(a,b) = 1`;;\n\nlet COPRIME_SYM = `!a b. coprime(a,b) <=> coprime(b,a)`;;\n\nlet COPRIME_BEZOUT = `!a b. coprime(a,b) <=> ?x y. a * x - b * y = 1 \\/ b * x - a * y = 1`;;\n\nlet COPRIME_DIVPROD = `!d a b. d divides (a * b) /\\ coprime(d,a) ==> d divides b`;;\n\nlet COPRIME_1 = `(!a. coprime(a,1)) /\\ (!a. coprime(1,a))`;;\n\nlet GCD_COPRIME = `!a b a' b'. ~(gcd(a,b) = 0) /\\ a = a' * gcd(a,b) /\\ b = b' * gcd(a,b)\n ==> coprime(a',b')`;;\n\nlet GCD_COPRIME_EXISTS = `!a b. ?a' b'. a = a' * gcd(a,b) /\\ b = b' * gcd(a,b) /\\ coprime(a',b')`;;\n\nlet COPRIME_DIVPROD_IFF = `!d a. ~(d = 0)\n ==> ((!b. d divides a * b ==> d divides b) <=> coprime(d,a))`;;\n\nlet CONG_MULT_LCANCEL_IFF = `!a n. ~(n = 0)\n ==> ((!x y. (a * x == a * y) (mod n) ==> (x == y) (mod n)) <=>\n coprime(a,n))`;;\n\nlet CONG_MULT_RCANCEL_IFF = `!a n. ~(n = 0)\n ==> ((!x y. (x * a == y * a) (mod n) ==> (x == y) (mod n)) <=>\n coprime(a,n))`;;\n\nlet COPRIME_0 = `(!d. coprime(d,0) <=> d = 1) /\\\n (!d. coprime(0,d) <=> d = 1)`;;\n\nlet COPRIME_MUL = `!d a b. coprime(d,a) /\\ coprime(d,b) ==> coprime(d,a * b)`;;\n\nlet COPRIME_LMUL2 = `!d a b. coprime(d,a * b) ==> coprime(d,b)`;;\n\nlet COPRIME_RMUL2 = `!d a b. coprime(d,a * b) ==> coprime(d,a)`;;\n\nlet COPRIME_LMUL = `!d a b. coprime(a * b,d) <=> coprime(a,d) /\\ coprime(b,d)`;;\n\nlet COPRIME_RMUL = `!d a b. coprime(d,a * b) <=> coprime(d,a) /\\ coprime(d,b)`;;\n\nlet COPRIME_EXP = `!n a d. coprime(d,a) ==> coprime(d,a EXP n)`;;\n\nlet COPRIME_EXP_IMP = `!n a b. coprime(a,b) ==> coprime(a EXP n,b EXP n)`;;\n\nlet COPRIME_REXP = `!m n k. coprime(m,n EXP k) <=> coprime(m,n) \\/ k = 0`;;\n\nlet COPRIME_LEXP = `!m n k. coprime(m EXP k,n) <=> coprime(m,n) \\/ k = 0`;;\n\nlet COPRIME_EXP2 = `!m n k. coprime(m EXP k,n EXP k) <=> coprime(m,n) \\/ k = 0`;;\n\nlet COPRIME_EXP2_SUC = `!n a b. coprime(a EXP (SUC n),b EXP (SUC n)) <=> coprime(a,b)`;;\n\nlet COPRIME_NPRODUCT_EQ = `(!(f:A->num) a s.\n FINITE s\n ==> (coprime(a,nproduct s f) <=> !i. i IN s ==> coprime(a,f i))) /\\\n (!(f:A->num) b s.\n FINITE s\n ==> (coprime(nproduct s f,b) <=> !i. i IN s ==> coprime(f i,b)))`;;\n\nlet COPRIME_NPRODUCT = `!s n. FINITE s /\\ (!x. x IN s ==> coprime(n,a x))\n ==> coprime(n,nproduct s a)`;;\n\nlet COPRIME_DIVISORS = `!a b d e. d divides a /\\ e divides b /\\ coprime(a,b) ==> coprime(d,e)`;;\n\nlet COPRIME_REFL = `!n. coprime(n,n) <=> n = 1`;;\n\nlet COPRIME_PLUS1 = `!n. coprime(n + 1,n)`;;\n\nlet COPRIME_MINUS1 = `!n. ~(n = 0) ==> coprime(n - 1,n)`;;\n\nlet GCD_EXP = `!n a b. gcd(a EXP n,b EXP n) = gcd(a,b) EXP n`;;\n\nlet DIVIDES_EXP2_REV = `!n a b. (a EXP n) divides (b EXP n) /\\ ~(n = 0) ==> a divides b`;;\n\nlet DIVIDES_EXP2_EQ = `!n a b. ~(n = 0) ==> ((a EXP n) divides (b EXP n) <=> a divides b)`;;\n\nlet DIVIDES_MUL = `!m n r. m divides r /\\ n divides r /\\ coprime(m,n) ==> (m * n) divides r`;;\n\nlet DIVISION_DECOMP = `!a b c.\n a divides (b * c)\n ==> ?b' c'. a = b' * c' /\\ b' divides b /\\ c' divides c`;;\n\nlet PRIME_0 = `~prime(0)`;;\n\nlet PRIME_1 = `~prime(1)`;;\n\nlet PRIME_ALT = `!p. prime p <=>\n ~(p = 0) /\\ ~(p = 1) /\\ !n. 1 < n /\\ n < p ==> ~(n divides p)`;;\n\nlet PRIME_2 = `prime(2)`;;\n\nlet PRIME_COPRIME_STRONG = `!n p. prime(p) ==> p divides n \\/ coprime(p,n)`;;\n\nlet PRIME_COPRIME = `!n p. prime(p) ==> n = 1 \\/ p divides n \\/ coprime(p,n)`;;\n\nlet PRIME_COPRIME_EQ = `!p n. prime p ==> (coprime(p,n) <=> ~(p divides n))`;;\n\nlet COPRIME_PRIME = `!p a b. coprime(a,b) ==> ~(prime(p) /\\ p divides a /\\ p divides b)`;;\n\nlet PRIME_DIVPROD = `!p a b. prime(p) /\\ p divides (a * b) ==> p divides a \\/ p divides b`;;\n\nlet PRIME_DIVPROD_EQ = `!p a b. prime(p) ==> (p divides (a * b) <=> p divides a \\/ p divides b)`;;\n\nlet PRIME_INT_DIVPROD_EQ = `!p a b:int.\n prime p ==> (&p divides a * b <=> &p divides a \\/ &p divides b)`;;\n\nlet PRIME_GE_2 = `!p. prime(p) ==> 2 <= p`;;\n\nlet PRIME_FACTOR = `!n. ~(n = 1) ==> ?p. prime(p) /\\ p divides n`;;\n\nlet PRIME = `!p. prime p <=>\n ~(p = 0) /\\ ~(p = 1) /\\ !m. 0 < m /\\ m < p ==> coprime(p,m)`;;\n\nlet PRIME_PRIME_FACTOR = `!n. prime n <=> ~(n = 1) /\\ !p. prime p /\\ p divides n ==> p = n`;;\n\nlet PRIME_FACTOR_LT = `!n m p. prime(p) /\\ ~(n = 0) /\\ n = p * m ==> m < n`;;\n\nlet COPRIME_PRIME_EQ = `!a b. coprime(a,b) <=> !p. ~(prime(p) /\\ p divides a /\\ p divides b)`;;\n\nlet GCD_PRIME_CASES = `(!p n. prime p ==> gcd(p,n) = if p divides n then p else 1) /\\\n (!p n. prime p ==> gcd(n,p) = if p divides n then p else 1)`;;\n\nlet GCD_2_CASES = `(!n. gcd(2,n) = if EVEN n then 2 else 1) /\\\n (!n. gcd(n,2) = if EVEN n then 2 else 1)`;;\n\nlet COPRIME_PRIMEPOW = `!p k m. prime p /\\ ~(k = 0) ==> (coprime(m,p EXP k) <=> ~(p divides m))`;;\n\nlet COPRIME_BEZOUT_STRONG = `!a b. coprime(a,b) /\\ ~(b = 1) ==> ?x y. a * x = b * y + 1`;;\n\nlet COPRIME_BEZOUT_ALT = `!a b. coprime(a,b) /\\ ~(a = 0) ==> ?x y. a * x = b * y + 1`;;\n\nlet BEZOUT_PRIME = `!a p. prime p /\\ ~(p divides a) ==> ?x y. a * x = p * y + 1`;;\n\nlet PRIME_DIVEXP = `!n p x. prime(p) /\\ p divides (x EXP n) ==> p divides x`;;\n\nlet PRIME_DIVEXP_N = `!n p x. prime(p) /\\ p divides (x EXP n) ==> (p EXP n) divides (x EXP n)`;;\n\nlet PRIME_DIVEXP_EQ = `!n p x. prime p ==> (p divides x EXP n <=> p divides x /\\ ~(n = 0))`;;\n\nlet COPRIME_SOS = `!x y. coprime(x,y) ==> coprime(x * y,(x EXP 2) + (y EXP 2))`;;\n\nlet PRIME_IMP_NZ = `!p. prime(p) ==> ~(p = 0)`;;\n\nlet DISTINCT_PRIME_COPRIME = `!p q. prime p /\\ prime q /\\ ~(p = q) ==> coprime(p,q)`;;\n\nlet PRIME_COPRIME_LT = `!x p. prime p /\\ 0 < x /\\ x < p ==> coprime(x,p)`;;\n\nlet DIVIDES_PRIME_PRIME = `!p q. prime p /\\ prime q ==> (p divides q <=> p = q)`;;\n\nlet COPRIME_PRIME_PRIME = `!p q. prime p /\\ prime q ==> (coprime(p,q) <=> ~(p = q))`;;\n\nlet DIVIDES_PRIME_EXP_LE = `!p q m n. prime p /\\ prime q\n ==> ((p EXP m) divides (q EXP n) <=> m = 0 \\/ p = q /\\ m <= n)`;;\n\nlet EQ_PRIME_EXP = `!p q m n. prime p /\\ prime q\n ==> (p EXP m = q EXP n <=> m = 0 /\\ n = 0 \\/ p = q /\\ m = n)`;;\n\nlet PRIME_ODD = `!p. prime p ==> p = 2 \\/ ODD p`;;\n\nlet ODD_PRIME = `!p. prime p ==> (ODD p <=> 3 <= p)`;;\n\nlet DIVIDES_FACT_PRIME = `!p. prime p ==> !n. p divides (FACT n) <=> p <= n`;;\n\nlet EQ_PRIMEPOW = `!p m n. prime p ==> (p EXP m = p EXP n <=> m = n)`;;\n\nlet COPRIME_2 = `(!n. coprime(2,n) <=> ODD n) /\\ (!n. coprime(n,2) <=> ODD n)`;;\n\nlet DIVIDES_EXP_PLUS1 = `!n k. ODD k ==> (n + 1) divides (n EXP k + 1)`;;\n\nlet DIVIDES_EXP_MINUS1 = `!k n. (n - 1) divides (n EXP k - 1)`;;\n\nlet PRIME_IRREDUCIBLE = `!p. prime p <=>\n p > 1 /\\ !a b. p divides (a * b) ==> p divides a \\/ p divides b`;;\n\nlet COPRIME_EXP_DIVPROD = `!d n a b.\n (d EXP n) divides (a * b) /\\ coprime(d,a) ==> (d EXP n) divides b`;;\n\nlet PRIME_COPRIME_CASES = `!p a b. prime p /\\ coprime(a,b) ==> coprime(p,a) \\/ coprime(p,b)`;;\n\nlet PRIME_DIVPROD_POW_GEN = `!n p a b.\n prime p /\\ ~(p divides gcd(a,b)) /\\ p EXP n divides a * b\n ==> p EXP n divides a \\/ p EXP n divides b`;;\n\nlet PRIME_DIVPROD_POW_GEN_EQ = `!n p a b.\n prime p /\\ ~(p divides gcd(a,b))\n ==> (p EXP n divides a * b <=>\n p EXP n divides a \\/ p EXP n divides b)`;;\n\nlet PRIME_DIVPROD_POW = `!n p a b. prime(p) /\\ coprime(a,b) /\\ (p EXP n) divides (a * b)\n ==> (p EXP n) divides a \\/ (p EXP n) divides b`;;\n\nlet PRIME_DIVPROD_POW_EQ = `!n p a b.\n prime p /\\ coprime(a,b)\n ==> (p EXP n divides a * b <=>\n p EXP n divides a \\/ p EXP n divides b)`;;\n\nlet PRIME_FACTOR_INDUCT = `!P. P 0 /\\ P 1 /\\\n (!p n. prime p /\\ ~(n = 0) /\\ P n ==> P(p * n))\n ==> !n. P n`;;\n\nlet COMPLETE_FACTOR_INDUCT = `!P. P 0 /\\ P 1 /\\\n (!p. prime p ==> P p) /\\\n (!m n. P m /\\ P n ==> P(m * n))\n ==> !n. P n`;;\n\nlet PRIME_FACTOR_PARTITION = `!Q n. ~(n = 0)\n ==> ?n1 n2. n1 * n2 = n /\\\n (!p. prime p /\\ p divides n1 ==> Q p) /\\\n (!p. prime p /\\ p divides n2 ==> ~Q p)`;;\n\nlet COPRIME_PAIR_DECOMP = `!n1 n2 m.\n coprime(n1,n2) /\\ ~(m = 0)\n ==> ?m1 m2. coprime(m1,n1) /\\ coprime(m2,n2) /\\\n coprime(m1,m2) /\\ m1 * m2 = m`;;\n\nlet EXP_MULT_EXISTS = `!m n p k. ~(m = 0) /\\ m EXP k * n = p EXP k ==> ?q. n = q EXP k`;;\n\nlet COPRIME_POW = `!n a b c. coprime(a,b) /\\ a * b = c EXP n\n ==> ?r s. a = r EXP n /\\ b = s EXP n`;;\n\nlet PRIME_EXP = `!p n. prime(p EXP n) <=> prime(p) /\\ (n = 1)`;;\n\nlet PRIME_POWER_MULT = `!k x y p. prime p /\\ (x * y = p EXP k)\n ==> ?i j. (x = p EXP i) /\\ (y = p EXP j)`;;\n\nlet PRIME_POWER_EXP = `!n x p k. prime p /\\ ~(n = 0) /\\ (x EXP n = p EXP k) ==> ?i. x = p EXP i`;;\n\nlet DIVIDES_PRIMEPOW = `!p. prime p ==> !d. d divides (p EXP k) <=> ?i. i <= k /\\ d = p EXP i`;;\n\nlet PRIMEPOW_DIVIDES_PROD = `!p k m n.\n prime p /\\ (p EXP k) divides (m * n)\n ==> ?i j. (p EXP i) divides m /\\ (p EXP j) divides n /\\ k = i + j`;;\n\nlet EUCLID_BOUND = `!n. ?p. prime(p) /\\ n < p /\\ p <= SUC(FACT n)`;;\n\nlet EUCLID = `!n. ?p. prime(p) /\\ p > n`;;\n\nlet PRIMES_INFINITE = `INFINITE {p | prime p}`;;\n\nlet FACTORIZATION_INDEX = `!n p. ~(n = 0) /\\ 2 <= p\n ==> ?k. (p EXP k) divides n /\\\n !l. k < l ==> ~((p EXP l) divides n)`;;\n\nlet PRIMEPOW_FACTOR = `!n. 2 <= n\n ==> ?p k m. prime p /\\ 1 <= k /\\ coprime(p,m) /\\ n = p EXP k * m`;;\n\nlet PRIMEPOW_DIVISORS_DIVIDES = `!m n. m divides n <=>\n !p k. prime p /\\ p EXP k divides m ==> p EXP k divides n`;;\n\nlet PRIMEPOW_DIVISORS_EQ = `!m n. m = n <=>\n !p k. prime p ==> (p EXP k divides m <=> p EXP k divides n)`;;\n\nlet CHINESE_REMAINDER = `!a b u v. coprime(a,b) /\\ ~(a = 0) /\\ ~(b = 0)\n ==> ?x q1 q2. x = u + q1 * a /\\ x = v + q2 * b`;;\n\nlet FINITE_EXP_LE = `!P p n. 2 <= p ==> FINITE {j | P j /\\ p EXP j <= n}`;;\n\nlet FINITE_INDICES = `!P p n. 2 <= p /\\ ~(n = 0) ==> FINITE {j | P j /\\ p EXP j divides n}`;;\n\nlet index_def = new_definition\n `index p n = if p <= 1 \\/ n = 0 then 0\n else CARD {j | 1 <= j /\\ p EXP j divides n}`;;\n\nlet INDEX_0 = `!p. index p 0 = 0`;;\n\nlet PRIMEPOW_DIVIDES_INDEX = `!n p k. p EXP k divides n <=> n = 0 \\/ p = 1 \\/ k <= index p n`;;\n\nlet LE_INDEX = `!n p k. k <= index p n <=> (n = 0 \\/ p = 1 ==> k = 0) /\\ p EXP k divides n`;;\n\nlet EXP_INDEX_DIVIDES = `!p n. p EXP (index p n) divides n`;;\n\nlet INDEX_LT = `!n p k. (~(n = 0) \\/ ~(k = 0)) /\\ n < p EXP k ==> index p n < k`;;\n\nlet INDEX_1 = `!p. index p 1 = 0`;;\n\nlet INDEX_MUL = `!m n. prime p /\\ ~(m = 0) /\\ ~(n = 0)\n ==> index p (m * n) = index p m + index p n`;;\n\nlet INDEX_EXP = `!p n k. prime p ==> index p (n EXP k) = k * index p n`;;\n\nlet INDEX_FACT = `!p n. prime p ==> index p (FACT n) = nsum(1..n) (\\m. index p m)`;;\n\nlet INDEX_FACT_ALT = `!p n. prime p\n ==> index p (FACT n) =\n nsum {j | 1 <= j /\\ p EXP j <= n} (\\j. n DIV (p EXP j))`;;\n\nlet INDEX_FACT_UNBOUNDED = `!p n. prime p\n ==> index p (FACT n) = nsum {j | 1 <= j} (\\j. n DIV (p EXP j))`;;\n\nlet PRIMEPOW_DIVIDES_FACT = `!p n k. prime p\n ==> (p EXP k divides FACT n <=>\n k <= nsum {j | 1 <= j /\\ p EXP j <= n} (\\j. n DIV (p EXP j)))`;;\n\nlet INDEX_REFL = `!n. index n n = if n <= 1 then 0 else 1`;;\n\nlet INDEX_EQ_0 = `!p n. index p n = 0 <=> n = 0 \\/ p = 1 \\/ ~(p divides n)`;;\n\nlet INDEX_ZERO = `!p n. ~(p divides n) ==> index p n = 0`;;\n\nlet INDEX_POW = `!p n k. index (p EXP k) n = index p n DIV k`;;\n\nlet INDEX_PRIME = `!p a. prime p ==> index a p = if p = a then 1 else 0`;;\n\nlet INDEX_TRIVIAL_BOUND = `!n p. index p n <= n`;;\n\nlet INDEX_DECOMPOSITION = `!n p. ?m. p EXP (index p n) * m = n /\\ (n = 0 \\/ p = 1 \\/ ~(p divides m))`;;\n\nlet INDEX_DECOMPOSITION_PRIME = `!n p. prime p ==> ?m. p EXP (index p n) * m = n /\\ (n = 0 \\/ coprime(p,m))`;;\n\nlet INDEX_DECOMPOSITION_LE = `!p e1 m1 e2 m2.\n p EXP e1 * m1 = p EXP e2 * m2 /\\ ~(p = 0) /\\ ~(p divides m2) ==> e1 <= e2`;;\n\nlet INDEX_DECOMPOSITION_UNIQUE = `!p e1 m1 e2 m2.\n p EXP e1 * m1 = p EXP e2 * m2 /\\\n ~(p = 0) /\\ ~(p divides m1) /\\ ~(p divides m2)\n ==> e1 = e2`;;\n\nlet INDEX_UNIQUE = `!p m n e.\n p EXP e * m = n /\\ (p = 0 ==> e = 0) /\\ ~(p divides m)\n ==> index p n = e`;;\n\nlet INDEX_UNIQUE_EQ = `!n p k. index p n = k <=>\n if p = 1 \\/ n = 0 then k = 0\n else !j. p EXP j divides n <=> j <= k`;;\n\nlet INDEX_UNIQUE_ALT = `!n p k. index p n = k <=>\n if p = 1 \\/ n = 0 then k = 0\n else p EXP k divides n /\\ ~(p EXP (k + 1) divides n)`;;\n\nlet INDEX_ADD_MIN = `!p m n. MIN (index p m) (index p n) <= index p (m + n)`;;\n\nlet INDEX_SUB_MIN = `!p m n. n < m ==> MIN (index p m) (index p n) <= index p (m - n)`;;\n\nlet INDEX_ADD = `!p n m.\n ~(n = 0) /\\ (~(m = 0) ==> index p n < index p m)\n ==> index p (m + n) = index p n`;;\n\nlet INDEX_MULT_BASE = `(!p n. index p (p * n) = if p <= 1 \\/ n = 0 then 0 else index p n + 1) /\\\n (!p n. index p (n * p) = if p <= 1 \\/ n = 0 then 0 else index p n + 1)`;;\n\nlet INDEX_MULT_EXP = `(!p n k. index p (p EXP k * n) =\n if p <= 1 \\/ n = 0 then 0 else k + index p n) /\\\n (!p n k. index p (n * p EXP k) =\n if n = 0 \\/ p <= 1 then 0 else index p n + k)`;;\n\nlet INDEX_MULT_ADD = `(!p m n k.\n ~(n = 0) /\\ index p n < k ==> index p (p EXP k * m + n) = index p n) /\\\n (!p m n k.\n ~(n = 0) /\\ index p n < k ==> index p (m * p EXP k + n) = index p n) /\\\n (!p m n k.\n ~(n = 0) /\\ index p n < k ==> index p (n + m * p EXP k) = index p n) /\\\n (!p m n k.\n ~(n = 0) /\\ index p n < k ==> index p (n + p EXP k * m) = index p n)`;;\n\nlet INDEX_NSUM_LE = `!(f:A->num) p n k.\n FINITE k /\\ ~(k = {}) /\\ (!a. a IN k ==> n <= index p (f a))\n ==> n <= index p (nsum k f)`;;\n\nlet DIVIDES_INDEX = `!m n. m divides n <=>\n n = 0 \\/ ~(m = 0) /\\ !p. prime p ==> index p m <= index p n`;;\n\nlet EQ_INDEX = `!m n. m = n <=> (m = 0 <=> n = 0) /\\ !p. prime p ==> index p m = index p n`;;\n\nlet COPRIME_INDEX = `!m n. coprime(m,n) <=>\n (m = 0 ==> n = 1) /\\ (n = 0 ==> m = 1) /\\\n !p. prime p ==> index p m = 0 \\/ index p n = 0`;;\n\nlet INDEX_GCD = `!m n p.\n prime p\n ==> index p (gcd(m,n)) =\n if m = 0 then index p n\n else if n = 0 then index p m\n else MIN (index p m) (index p n)`;;\n\nlet FORALL_PRIME_INDEX = `(!p. prime p ==> !P. ((!x. P(index p x)) <=> !k. P k)) /\\\n (!p. prime p ==> !P. ((!x. ~(x = 0) ==> P(index p x)) <=> !k. P k))`;;\n\nlet INDEX_FACT_PRIME_MULT = `!p n. prime p ==> index p (FACT(p * n)) = n + index p (FACT n)`;;\n\nlet PRIME_FACTORIZATION_INDEX = `!k. FINITE {p | prime p /\\ ~(k p = 0)}\n ==> ?n. ~(n = 0) /\\ !p. prime p ==> index p n = k p`;;\n\nlet PRIME_POWER_EXISTS = `!n q. prime q\n ==> ((?i. n = q EXP i) <=>\n (!p. prime p /\\ p divides n ==> p = q))`;;\n\nlet PRIME_POWER_EXISTS_ALT = `!n p.\n prime p\n ==> ((?i. n = p EXP i) <=>\n (!d. d divides n ==> d = 1 \\/ p divides d))`;;\n\nlet PRIME_FACTORIZATION_ALT = `!n. ~(n = 0) ==> nproduct {p | prime p} (\\p. p EXP index p n) = n`;;\n\nlet PRIME_FACTORIZATION = `!n. ~(n = 0)\n ==> nproduct {p | prime p /\\ p divides n} (\\p. p EXP index p n) = n`;;\n\nlet lcm = `lcm(m,n) = if m * n = 0 then 0 else (m * n) DIV gcd(m,n)`;;\n\nlet LCM_DIVIDES = `!m n d. lcm(m,n) divides d <=> m divides d /\\ n divides d`;;\n\nlet LCM = `!m n. m divides lcm(m,n) /\\\n n divides lcm(m,n) /\\\n (!d. m divides d /\\ n divides d ==> lcm(m,n) divides d)`;;\n\nlet LCM_DIVIDES_MUL = `!m n. lcm(m,n) divides m * n`;;\n\nlet DIVIDES_LCM = `!m n r. r divides m \\/ r divides n\n ==> r divides lcm(m,n)`;;\n\nlet LCM_0 = `(!n. lcm(0,n) = 0) /\\ (!n. lcm(n,0) = 0)`;;\n\nlet LCM_1 = `(!n. lcm(1,n) = n) /\\ (!n. lcm(n,1) = n)`;;\n\nlet LCM_SYM = `!m n. lcm(m,n) = lcm(n,m)`;;\n\nlet DIVIDES_LCM_GCD = `!m n d. d divides lcm(m,n) <=> d * gcd(m,n) divides m * n`;;\n\nlet PRIMEPOW_DIVIDES_LCM = `!m n p k.\n prime p\n ==> (p EXP k divides lcm(m,n) <=>\n p EXP k divides m \\/ p EXP k divides n)`;;\n\nlet PRIME_DIVIDES_LCM = `!m n p.\n prime p\n ==> (p divides lcm(m,n) <=> p divides m \\/ p divides n)`;;\n\nlet LCM_ZERO = `!m n. lcm(m,n) = 0 <=> m = 0 \\/ n = 0`;;\n\nlet INDEX_LCM = `!m n p.\n prime p\n ==> index p (lcm(m,n)) =\n if m = 0 \\/ n = 0 then 0\n else MAX (index p m) (index p n)`;;\n\nlet LCM_ASSOC = `!m n p. lcm(m,lcm(n,p)) = lcm(lcm(m,n),p)`;;\n\nlet LCM_REFL = `!n. lcm(n,n) = n`;;\n\nlet LCM_MULTIPLE = `!a b. lcm(b,a * b) = a * b`;;\n\nlet LCM_GCD_DISTRIB = `!a b c. lcm(a,gcd(b,c)) = gcd(lcm(a,b),lcm(a,c))`;;\n\nlet GCD_LCM_DISTRIB = `!a b c. gcd(a,lcm(b,c)) = lcm(gcd(a,b),gcd(a,c))`;;\n\nlet LCM_UNIQUE = `!d m n.\n m divides d /\\ n divides d /\\\n (!e. m divides e /\\ n divides e ==> d divides e) <=>\n d = lcm(m,n)`;;\n\nlet LCM_EQ = `!x y u v. (!d. x divides d /\\ y divides d <=> u divides d /\\ v divides d)\n ==> lcm(x,y) = lcm(u,v)`;;\n\nlet LCM_EQ_1 = `!m n. lcm(m,n) = 1 <=> m = 1 /\\ n = 1`;;\n\nlet DIVIDES_LCM_LEFT = `!m n. n divides m <=> lcm(m,n) = m`;;\n\nlet DIVIDES_LCM_RIGHT = `!m n. m divides n <=> lcm(m,n) = n`;;\n\nlet MULT_LCM_GCD = `!m n. lcm(m,n) * gcd(m,n) = m * n`;;\n\nlet MULT_GCD_LCM = `!m n. gcd(m,n) * lcm(m,n) = m * n`;;\n\nlet LCM_LMUL = `!a b c. lcm(c * a,c * b) = c * lcm(a,b)`;;\n\nlet LCM_RMUL = `!a b c. lcm(a * c,b * c) = c * lcm(a,b)`;;\n\nlet LCM_EXP = `!n a b. lcm(a EXP n,b EXP n) = lcm(a,b) EXP n`;;\n\nlet LCM_COPRIME_DECOMP = `!m n:num.\n ?m' n'.\n m' divides m /\\ n' divides n /\\ coprime(m',n') /\\ m' * n' = lcm(m,n)`;;\n\nlet LE_LCM = `(!m n. m <= lcm(m,n) <=> n = 0 ==> m = 0) /\\\n (!m n. n <= lcm(m,n) <=> m = 0 ==> n = 0)`;;\n\nlet LCM_LE_MULT = `!m n. lcm(m,n) <= m * n`;;\n\nlet LCM_EQ_MULT = `!m n. lcm(m,n) = m * n <=> m = 0 \\/ n = 0 \\/ coprime(m,n)`;;\n\nlet MAX_LE_LCM_EQ = `!m n. MAX m n <= lcm(m,n) <=> (m = 0 <=> n = 0)`;;\n\nlet MAX_LE_LCM = `!m n. (m = 0 <=> n = 0) ==> MAX m n <= lcm(m,n)`;;\n\nlet NEUTRAL_GCD = `neutral (\\m n. gcd(m,n)) = 0`;;\n\nlet MONOIDAL_GCD = `monoidal (\\m n:num. gcd(m,n))`;;\n\nlet NEUTRAL_LCM = `neutral (\\m n. lcm(m,n)) = 1`;;\n\nlet MONOIDAL_LCM = `monoidal (\\m n:num. lcm(m,n))`;;\n\nlet ITERATE_GCD_DIVIDES = `!f k i:K.\n FINITE k /\\ i IN k\n ==> iterate (\\m n:num. gcd(m,n)) k f divides f i`;;\n\nlet ITERATE_GCD_DIVIDES_EQ = `!f k i:K.\n i IN k\n ==> (iterate (\\m n:num. gcd(m,n)) k f divides f i <=>\n FINITE {j | j IN k /\\ ~(f j = 0)} \\/ f i = 0)`;;\n\nlet DIVIDES_ITERATE_GCD = `!f (k:K->bool) d.\n FINITE k\n ==> (d divides iterate (\\m n:num. gcd(m,n)) k f <=>\n !i. i IN k ==> d divides f i)`;;\n\nlet DIVIDES_ITERATE_GCD_GEN = `!f (k:K->bool) d.\n d divides iterate (\\m n:num. gcd(m,n)) k f <=>\n FINITE {j | j IN k /\\ ~(f j = 0)} ==> !i. i IN k ==> d divides f i`;;\n\nlet DIVIDES_ITERATE_LCM = `!f k i:K.\n FINITE k /\\ i IN k\n ==> f i divides iterate (\\m n:num. lcm(m,n)) k f`;;\n\nlet DIVIDES_ITERATE_LCM_GEN = `!f k i:K.\n i IN k\n ==> (f i divides iterate (\\m n:num. lcm(m,n)) k f <=>\n FINITE {j | j IN k /\\ ~(f j = 1)} \\/ f i = 1)`;;\n\nlet ITERATE_LCM_DIVIDES = `!f (k:K->bool) n.\n FINITE k\n ==> (iterate (\\m n:num. lcm(m,n)) k f divides n <=>\n !i. i IN k ==> f i divides n)`;;\n\nlet ITERATE_LCM_DIVIDES_GEN = `!f (k:K->bool) n.\n iterate (\\m n:num. lcm(m,n)) k f divides n <=>\n FINITE {j | j IN k /\\ ~(f j = 1)} ==> !i. i IN k ==> f i divides n`;;\n\nlet PRIMEPOW_DIVIDES_ITERATE_LCM = `!f (k:K->bool) p m.\n FINITE k /\\ prime p\n ==> (p EXP m divides iterate (\\m n:num. lcm(m,n)) k f <=>\n m = 0 \\/ ?i. i IN k /\\ p EXP m divides (f i))`;;\n\nlet PRIMEPOW_DIVIDES_ITERATE_LCM_GEN = `!f (k:K->bool) p m.\n prime p\n ==> (p EXP m divides iterate (\\m n:num. lcm(m,n)) k f <=>\n m = 0 \\/\n FINITE {j | j IN k /\\ ~(f j = 1)} /\\\n ?i. i IN k /\\ p EXP m divides (f i))`;;\n\nlet PRIME_DIVIDES_ITERATE_LCM_GEN = `!f (k:K->bool) p.\n prime p\n ==> (p divides iterate (\\m n:num. lcm(m,n)) k f <=>\n FINITE {j | j IN k /\\ ~(f j = 1)} /\\\n ?i. i IN k /\\ p divides (f i))`;;\n\nlet PRIME_DIVIDES_ITERATE_LCM = `!f (k:K->bool) p.\n FINITE k /\\ prime p\n ==> (p divides iterate (\\m n:num. lcm(m,n)) k f <=>\n ?i. i IN k /\\ p divides (f i))`;;\n\nlet ITERATE_LCM_EQ_0_GEN = `!(k:K->bool) f.\n iterate (\\m n. lcm(m,n)) k f = 0 <=>\n FINITE {j | j IN k /\\ ~(f j = 1)} /\\\n ?j. j IN k /\\ f j = 0`;;\n\nlet ITERATE_LCM_EQ_0 = `!(k:K->bool) f.\n FINITE k\n ==> (iterate (\\m n. lcm(m,n)) k f = 0 <=>\n ?j. j IN k /\\ f j = 0)`;;\n\nlet ITERATE_LCM_EQ_1_GEN = `!(k:K->bool) f.\n iterate (\\m n. lcm(m,n)) k f = 1 <=>\n FINITE {j | j IN k /\\ ~(f j = 1)} ==> !j. j IN k ==> f j = 1`;;\n\nlet ITERATE_LCM_EQ_1 = `!(k:K->bool) f.\n FINITE k\n ==> (iterate (\\m n. lcm(m,n)) k f = 1 <=>\n !j. j IN k ==> f j = 1)`;;\n\nlet ITERATE_GCD_EQ_0_GEN = `!(k:K->bool) f.\n iterate (\\m n. gcd(m,n)) k f = 0 <=>\n FINITE {j | j IN k /\\ ~(f j = 0)} ==> !j. j IN k ==> f j = 0`;;\n\nlet ITERATE_GCD_EQ_0 = `!(k:K->bool) f.\n FINITE k\n ==> (iterate (\\m n. gcd(m,n)) k f = 0 <=>\n !j. j IN k ==> f j = 0)`;;\n\nlet INDUCT_COPRIME = `!P. (!a b. 1 < a /\\ 1 < b /\\ coprime(a,b) /\\ P a /\\ P b ==> P(a * b)) /\\\n (!p k. prime p ==> P(p EXP k))\n ==> !n. 1 < n ==> P n`;;\n\nlet INDUCT_COPRIME_STRONG = `!P. (!a b. 1 < a /\\ 1 < b /\\ coprime(a,b) /\\ P a /\\ P b ==> P(a * b)) /\\\n (!p k. prime p /\\ ~(k = 0) ==> P(p EXP k))\n ==> !n. 1 < n ==> P n`;;\n\nlet INDUCT_COPRIME_ALT = `!P. P 0 /\\\n (!a b. 1 < a /\\ 1 < b /\\ coprime(a,b) /\\ P a /\\ P b ==> P(a * b)) /\\\n (!p k. prime p ==> P(p EXP k))\n ==> !n. P n`;;\n\nlet DIVIDES_CONV =\n let pth_0 = SPEC `b:num` DIVIDES_ZERO\n and pth_1 = prove\n (`~(a = 0) ==> (a divides b <=> (b MOD a = 0))`,\n REWRITE_TAC[DIVIDES_MOD])\n and a_tm = `a:num` and b_tm = `b:num` and zero_tm = `0`\n and dest_divides = dest_binop `(divides)` in\n fun tm ->\n let a,b = dest_divides tm in\n if a = zero_tm then\n CONV_RULE (RAND_CONV NUM_EQ_CONV) (INST [b,b_tm] pth_0)\n else\n let th1 = INST [a,a_tm; b,b_tm] pth_1 in\n let th2 = MP th1 (EQF_ELIM(NUM_EQ_CONV(rand(lhand(concl th1))))) in\n CONV_RULE (RAND_CONV (LAND_CONV NUM_MOD_CONV THENC NUM_EQ_CONV)) th2;;\n\nlet COPRIME_CONV =\n let pth_yes_l = `(m * x = n * y + 1) ==> (coprime(m,n) <=> T)`;;\n\nlet GCD_CONV =\n let pth0 = `gcd(0,0) = 0`;;\n\nlet LCM_CONV =\n GEN_REWRITE_CONV I [lcm] THENC\n RATOR_CONV(LAND_CONV(LAND_CONV NUM_MULT_CONV THENC NUM_EQ_CONV)) THENC\n (GEN_REWRITE_CONV I [CONJUNCT1(SPEC_ALL COND_CLAUSES)] ORELSEC\n (GEN_REWRITE_CONV I [CONJUNCT2(SPEC_ALL COND_CLAUSES)] THENC\n COMB2_CONV (RAND_CONV NUM_MULT_CONV) GCD_CONV THENC NUM_DIV_CONV));;" }, { "theorem_id": 23, "title": "011_the_infinitude_of_primes", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Primes\\\n\ntheory Primes\nimports Euclidean_Algorithm\nbegin\n\nsubsection \\Primes on \\<^typ>\\nat\\ and \\<^typ>\\int\\\\\n\nlemma Suc_0_not_prime_nat [simp]: \"\\ prime (Suc 0)\"\n by sorry\n\nlemma prime_ge_2_nat:\n \"p \\ 2\" if \"prime p\" for p :: nat\n by sorry\n\nlemma prime_ge_2_int:\n \"p \\ 2\" if \"prime p\" for p :: int\n by sorry\n\nlemma prime_ge_0_int: \"prime p \\ p \\ (0::int)\"\n by sorry\n\nlemma prime_gt_0_nat: \"prime p \\ p > (0::nat)\"\n by sorry\n\nlemma prime_gt_0_int: \"prime p \\ p > (0::int)\"\n by sorry\n\nlemma prime_ge_1_nat: \"prime p \\ p \\ (1::nat)\"\n by sorry\n\nlemma prime_ge_Suc_0_nat: \"prime p \\ p \\ Suc 0\"\n by sorry\n\nlemma prime_ge_1_int: \"prime p \\ p \\ (1::int)\"\n by sorry\n\nlemma prime_gt_1_nat: \"prime p \\ p > (1::nat)\"\n by sorry\n\nlemma prime_gt_Suc_0_nat: \"prime p \\ p > Suc 0\"\n by sorry\n\nlemma prime_gt_1_int: \"prime p \\ p > (1::int)\"\n by sorry\n\nlemma prime_natI:\n \"prime p\" if \"p \\ 2\" and \"\\m n. p dvd m * n \\ p dvd m \\ p dvd n\" for p :: nat\n by sorry\n\nlemma prime_intI:\n \"prime p\" if \"p \\ 2\" and \"\\m n. p dvd m * n \\ p dvd m \\ p dvd n\" for p :: int\n by sorry\n\nlemma prime_elem_nat_iff [simp]:\n \"prime_elem n \\ prime n\" for n :: nat\n by sorry\n\nlemma prime_elem_iff_prime_abs [simp]:\n \"prime_elem k \\ prime \\k\\\" for k :: int\n by sorry\n\nlemma prime_nat_int_transfer [simp]:\n \"prime (int n) \\ prime n\" (is \"?P \\ ?Q\")\n by sorry\n\nlemma prime_nat_iff_prime [simp]:\n \"prime (nat k) \\ prime k\"\n by sorry\n\nlemma prime_int_nat_transfer:\n \"prime k \\ k \\ 0 \\ prime (nat k)\"\n by sorry\n\nlemma prime_nat_naiveI:\n \"prime p\" if \"p \\ 2\" and dvd: \"\\n. n dvd p \\ n = 1 \\ n = p\" for p :: nat\n by sorry\n\nlemma prime_int_naiveI:\n \"prime p\" if \"p \\ 2\" and dvd: \"\\k. k dvd p \\ \\k\\ = 1 \\ \\k\\ = p\" for p :: int\n by sorry\n\nlemma prime_nat_iff:\n \"prime (n :: nat) \\ (1 < n \\ (\\m. m dvd n \\ m = 1 \\ m = n))\"\n by sorry\n\nlemma prime_nat_iff':\n \"prime (p :: nat) \\ p > 1 \\ (\\n \\ {2.. n dvd p)\"\n by sorry\n\nlemma prime_int_iff:\n \"prime (n::int) \\ (1 < n \\ (\\m. m \\ 0 \\ m dvd n \\ m = 1 \\ m = n))\"\n by sorry\n\nlemma prime_int_iff':\n \"prime (p :: int) \\ p > 1 \\ (\\n \\ {2.. n dvd p)\" (is \"?P \\ ?Q\")\n by sorry\n\nlemma prime_nat_not_dvd:\n assumes \"prime p\" \"p > n\" \"n \\ (1::nat)\"\n shows \"\\n dvd p\"\n by sorry\n\nlemma prime_int_not_dvd:\n assumes \"prime p\" \"p > n\" \"n > (1::int)\"\n shows \"\\n dvd p\"\n by sorry\n\nlemma prime_odd_nat: \"prime p \\ p > (2::nat) \\ odd p\"\n by sorry\n\nlemma prime_odd_int: \"prime p \\ p > (2::int) \\ odd p\"\n by sorry\n\nlemma prime_int_altdef:\n \"prime p = (1 < p \\ (\\m::int. m \\ 0 \\ m dvd p \\\n m = 1 \\ m = p))\"\n by sorry\n\nlemma not_prime_eq_prod_nat:\n assumes \"m > 1\" \"\\ prime (m::nat)\"\n shows \"\\n k. n = m * k \\ 1 < m \\ m < n \\ 1 < k \\ k < n\"\n by sorry\n\nsubsection \\Make prime naively executable\\\n\nlemma prime_int_numeral_eq [simp]:\n \"prime (numeral m :: int) \\ prime (numeral m :: nat)\"\n by sorry\n\nclass check_prime_by_range = normalization_semidom + discrete_linordered_semidom +\n assumes prime_iff: \\prime a \\ 1 < a \\ (\\d\\{2..a div 2}. \\ d dvd a)\\\nbegin\n\nlemma two_is_prime [simp]:\n \\prime 2\\\n by sorry\n\nend\n\nlemma divisor_less_eq_half_nat:\n \\m \\ n div 2\\ if \\m dvd n\\ \\m < n\\ for m n :: nat\n by sorry\n\ninstance nat :: check_prime_by_range\n apply standard\n apply (auto simp add: prime_nat_iff)\n apply (rule ccontr)\n apply (auto simp add: neq_iff)\n apply (metis One_nat_def Suc_1 Suc_leI atLeastAtMost_iff divisor_less_eq_half_nat)\n done\n\nlemma two_is_prime_nat [simp]:\n \\prime (2::nat)\\\n by sorry\n\nlemma divisor_less_eq_half_int:\n \\k \\ l div 2\\ if \\k dvd l\\ \\k < l\\ \\l \\ 0\\ \\k \\ 0\\ for k l :: int\n by sorry\n\ninstance int :: check_prime_by_range\n apply standard\n apply (auto simp add: prime_int_iff)\n apply (smt (verit) int_div_less_self)\n apply (rule ccontr)\n apply (auto simp add: neq_iff zdvd_not_zless)\n apply (metis div_by_0 dvd_div_eq_0_iff less_le_not_le one_dvd order_le_less\n zdvd_not_zless)\n apply (metis atLeastAtMost_iff divisor_less_eq_half_int dvd_div_eq_0_iff\n int_one_le_iff_zero_less nle_le one_add_one pos_imp_zdiv_nonneg_iff zdiv_eq_0_iff\n zless_imp_add1_zle)\n done\n\nlemma prime_nat_numeral_eq [simp]: \\ \\TODO Sieve Of Erathosthenes might speed this up\\\n \"prime (numeral m :: nat) \\\n (1::nat) < numeral m \\\n (\\n::nat \\ set [2.. n dvd numeral m)\"\n by sorry\n\ncontext check_prime_by_range\nbegin\n\ndefinition check_divisors :: \\'a \\ 'a \\ 'a \\ bool\\\n where \\check_divisors l u a \\ (\\d\\{l..u}. \\ d dvd a)\\\n\nlemma check_divisors_rec [code]:\n \\check_divisors l u a \\ u < l \\ (\\ l dvd a \\ check_divisors (l + 1) u a)\\\n by sorry\n done\n\nlemma prime_eq_check_divisors [code]:\n \\prime a \\ a > 1 \\ check_divisors 2 (a div 2) a\\\n by sorry\n\nend\n\nsubsection \\Largest exponent of a prime factor\\\n\nlemma prime_factor_nat:\n \"n \\ (1::nat) \\ \\p. prime p \\ p dvd n\"\n by sorry\n\nlemma prime_factor_int:\n fixes k :: int\n assumes \"\\k\\ \\ 1\"\n obtains p where \"prime p\" \"p dvd k\"\n by sorry\n\ntext\\Possibly duplicates other material, but avoid the complexities of multisets.\\\n \nlemma prime_power_cancel_less:\n assumes \"prime p\" and eq: \"m * (p ^ k) = m' * (p ^ k')\" and less: \"k < k'\" and \"\\ p dvd m\"\n shows False\n by sorry\n\nlemma prime_power_cancel:\n assumes \"prime p\" and eq: \"m * (p ^ k) = m' * (p ^ k')\" and \"\\ p dvd m\" \"\\ p dvd m'\"\n shows \"k = k'\"\n by sorry\n\nlemma prime_power_cancel2:\n assumes \"prime p\" \"m * (p ^ k) = m' * (p ^ k')\" \"\\ p dvd m\" \"\\ p dvd m'\"\n obtains \"m = m'\" \"k = k'\"\n by sorry\n\nlemma prime_power_canonical:\n fixes m :: nat\n assumes \"prime p\" \"m > 0\"\n shows \"\\k n. \\ p dvd n \\ m = n * p ^ k\"\n by sorry\n\nsubsection \\Infinitely many primes\\\n\nlemma next_prime_bound: \"\\p::nat. prime p \\ n < p \\ p \\ fact n + 1\"\n by sorry\n\nlemma bigger_prime: \"\\p. prime p \\ p > (n::nat)\"\n by sorry\n\nlemma primes_infinite: \"\\ (finite {(p::nat). prime p})\"\n by sorry\n\nsubsection \\Powers of Primes\\\n\ntext\\Versions for type nat only\\\n\nlemma prime_product:\n fixes p::nat\n assumes \"prime (p * q)\"\n shows \"p = 1 \\ q = 1\"\n by sorry\n\nlemma prime_power_mult_nat:\n fixes p :: nat\n assumes p: \"prime p\" and xy: \"x * y = p ^ k\"\n shows \"\\i j. x = p ^ i \\ y = p^ j\"\n by sorry\n\nlemma prime_power_exp_nat:\n fixes p::nat\n assumes p: \"prime p\" and n: \"n \\ 0\"\n and xn: \"x^n = p^k\" shows \"\\i. x = p^i\"\n by sorry\n\nlemma divides_primepow_nat:\n fixes p :: nat\n assumes p: \"prime p\"\n shows \"d dvd p ^ k \\ (\\i\\k. d = p ^ i)\"\n by sorry\n\nlemma gcd_prime_int:\n assumes \"prime (p :: int)\"\n shows \"gcd p k = (if p dvd k then p else 1)\"\n by sorry\n\nsubsection \\Chinese Remainder Theorem Variants\\\n\nlemma bezout_gcd_nat:\n fixes a::nat shows \"\\x y. a * x - b * y = gcd a b \\ b * x - a * y = gcd a b\"\n by sorry\nby (metis bezout_nat diff_add_inverse gcd_add_mult gcd.commute\n gcd_nat.right_neutral mult_0)\n\nlemma gcd_bezout_sum_nat:\n fixes a::nat\n assumes \"a * x + b * y = d\"\n shows \"gcd a b dvd d\"\n by sorry\n\ntext \\A binary form of the Chinese Remainder Theorem.\\\n\nlemma chinese_remainder:\n fixes a::nat assumes ab: \"coprime a b\" and a: \"a \\ 0\" and b: \"b \\ 0\"\n shows \"\\x q1 q2. x = u + q1 * a \\ x = v + q2 * b\"\n by sorry\n\ntext \\Primality\\\n\nlemma coprime_bezout_strong:\n fixes a::nat assumes \"coprime a b\" \"b \\ 1\"\n shows \"\\x y. a * x = b * y + 1\"\n by sorry\n\nlemma bezout_prime:\n assumes p: \"prime p\" and pa: \"\\ p dvd a\"\n shows \"\\x y. a*x = Suc (p*y)\"\n by sorry\n\nsubsection \\Multiplicity and primality for natural numbers and integers\\\n\nlemma prime_factors_gt_0_nat:\n \"p \\ prime_factors x \\ p > (0::nat)\"\n by sorry\n\nlemma prime_factors_gt_0_int:\n \"p \\ prime_factors x \\ p > (0::int)\"\n by sorry\n\nlemma prime_factors_ge_0_int [elim]: \n fixes n :: int\n shows \"p \\ prime_factors n \\ p \\ 0\"\n by sorry\n \nlemma prod_mset_prime_factorization_int:\n fixes n :: int\n assumes \"n > 0\"\n shows \"prod_mset (prime_factorization n) = n\"\n by sorry\n\nlemma prime_factorization_exists_nat:\n \"n > 0 \\ (\\M. (\\p::nat \\ set_mset M. prime p) \\ n = (\\i \\# M. i))\"\n by sorry\n\nlemma prod_mset_prime_factorization_nat [simp]: \n \"(n::nat) > 0 \\ prod_mset (prime_factorization n) = n\"\n by sorry\n\nlemma prime_factorization_nat:\n \"n > (0::nat) \\ n = (\\p \\ prime_factors n. p ^ multiplicity p n)\"\n by sorry\n\nlemma prime_factorization_int:\n \"n > (0::int) \\ n = (\\p \\ prime_factors n. p ^ multiplicity p n)\"\n by sorry\n\nlemma prime_factorization_unique_nat:\n fixes f :: \"nat \\ _\"\n assumes S_eq: \"S = {p. 0 < f p}\"\n and \"finite S\"\n and S: \"\\p\\S. prime p\" \"n = (\\p\\S. p ^ f p)\"\n shows \"S = prime_factors n \\ (\\p. prime p \\ f p = multiplicity p n)\"\n by sorry\n\nlemma prime_factorization_unique_int:\n fixes f :: \"int \\ _\"\n assumes S_eq: \"S = {p. 0 < f p}\"\n and \"finite S\"\n and S: \"\\p\\S. prime p\" \"abs n = (\\p\\S. p ^ f p)\"\n shows \"S = prime_factors n \\ (\\p. prime p \\ f p = multiplicity p n)\"\n by sorry\n\nlemma prime_factors_characterization_nat:\n \"S = {p. 0 < f (p::nat)} \\\n finite S \\ \\p\\S. prime p \\ n = (\\p\\S. p ^ f p) \\ prime_factors n = S\"\n by sorry\n\nlemma prime_factors_characterization'_nat:\n \"finite {p. 0 < f (p::nat)} \\\n (\\p. 0 < f p \\ prime p) \\\n prime_factors (\\p | 0 < f p. p ^ f p) = {p. 0 < f p}\"\n by sorry\n\nlemma prime_factors_characterization_int:\n \"S = {p. 0 < f (p::int)} \\ finite S \\\n \\p\\S. prime p \\ abs n = (\\p\\S. p ^ f p) \\ prime_factors n = S\"\n by sorry\n\nlemma abs_prod: \"abs (prod f A :: 'a :: linordered_idom) = prod (\\x. abs (f x)) A\"\n by sorry\n\nlemma primes_characterization'_int [rule_format]:\n \"finite {p. p \\ 0 \\ 0 < f (p::int)} \\ \\p. 0 < f p \\ prime p \\\n prime_factors (\\p | p \\ 0 \\ 0 < f p. p ^ f p) = {p. p \\ 0 \\ 0 < f p}\"\n by sorry\n\nlemma multiplicity_characterization_nat:\n \"S = {p. 0 < f (p::nat)} \\ finite S \\ \\p\\S. prime p \\ prime p \\\n n = (\\p\\S. p ^ f p) \\ multiplicity p n = f p\"\n by sorry\n\nlemma multiplicity_characterization'_nat: \"finite {p. 0 < f (p::nat)} \\\n (\\p. 0 < f p \\ prime p) \\ prime p \\\n multiplicity p (\\p | 0 < f p. p ^ f p) = f p\"\n by sorry\n\nlemma multiplicity_characterization_int: \"S = {p. 0 < f (p::int)} \\\n finite S \\ \\p\\S. prime p \\ prime p \\ n = (\\p\\S. p ^ f p) \\ multiplicity p n = f p\"\n by sorry\n\nlemma multiplicity_characterization'_int [rule_format]:\n \"finite {p. p \\ 0 \\ 0 < f (p::int)} \\\n (\\p. 0 < f p \\ prime p) \\ prime p \\\n multiplicity p (\\p | p \\ 0 \\ 0 < f p. p ^ f p) = f p\"\n by sorry\n\nlemma multiplicity_one_nat [simp]: \"multiplicity p (Suc 0) = 0\"\n by sorry\n\nlemma multiplicity_eq_nat:\n fixes x and y::nat\n assumes \"x > 0\" \"y > 0\" \"\\p. prime p \\ multiplicity p x = multiplicity p y\"\n shows \"x = y\"\n by sorry\n\nlemma multiplicity_eq_int:\n fixes x y :: int\n assumes \"x > 0\" \"y > 0\" \"\\p. prime p \\ multiplicity p x = multiplicity p y\"\n shows \"x = y\"\n by sorry\n\nlemma multiplicity_prod_prime_powers:\n assumes \"finite S\" \"\\x. x \\ S \\ prime x\" \"prime p\"\n shows \"multiplicity p (\\p \\ S. p ^ f p) = (if p \\ S then f p else 0)\"\n by sorry\n\nlemma prime_factorization_prod_mset:\n assumes \"0 \\# A\"\n shows \"prime_factorization (prod_mset A) = \\\\<^sub>#(image_mset prime_factorization A)\"\n by sorry\n\nlemma prime_factors_prod:\n assumes \"finite A\" and \"0 \\ f ` A\"\n shows \"prime_factors (prod f A) = \\((prime_factors \\ f) ` A)\"\n by sorry\n\nlemma prime_factors_fact:\n \"prime_factors (fact n) = {p \\ {2..n}. prime p}\" (is \"?M = ?N\")\n by sorry\n\nlemma prime_dvd_fact_iff:\n assumes \"prime p\"\n shows \"p dvd fact n \\ p \\ n\"\n by sorry\n\nlemma dvd_choose_prime:\n assumes kn: \"k < n\" and k: \"k \\ 0\" and n: \"n \\ 0\" and prime_n: \"prime n\"\n shows \"n dvd (n choose k)\"\n by sorry\n\nlemma (in ring_1) minus_power_prime_CHAR:\n assumes \"p = CHAR('a)\" \"prime p\"\n shows \"(-x :: 'a) ^ p = -(x ^ p)\"\n by sorry\n\nsubsection \\Rings and fields with prime characteristic\\\n\ntext \\\n We introduce some type classes for rings and fields with prime characteristic.\n\\\n\nclass semiring_prime_char = semiring_1 +\n assumes prime_char_aux: \"\\n. prime n \\ of_nat n = (0 :: 'a)\"\nbegin\n\nlemma CHAR_pos [intro, simp]: \"CHAR('a) > 0\"\n by sorry\n\nlemma CHAR_nonzero [simp]: \"CHAR('a) \\ 0\"\n by sorry\n\nlemma CHAR_prime [intro, simp]: \"prime CHAR('a)\"\n by sorry\n\nend\n\nlemma semiring_prime_charI [intro?]:\n \"prime CHAR('a :: semiring_1) \\ OFCLASS('a, semiring_prime_char_class)\"\n by sorry\n\nlemma idom_prime_charI [intro?]:\n assumes \"CHAR('a :: idom) > 0\"\n shows \"OFCLASS('a, semiring_prime_char_class)\"\n by sorry\n\nclass comm_semiring_prime_char = comm_semiring_1 + semiring_prime_char\nclass comm_ring_prime_char = comm_ring_1 + semiring_prime_char\nbegin\nsubclass comm_semiring_prime_char ..\nend\nclass idom_prime_char = idom + semiring_prime_char\nbegin\nsubclass comm_ring_prime_char ..\nend\n\nclass field_prime_char = field +\n assumes pos_char_exists: \"\\n>0. of_nat n = (0 :: 'a)\"\nbegin\nsubclass idom_prime_char\n apply standard\n using pos_char_exists local.CHAR_pos_iff local.of_nat_CHAR local.prime_CHAR_semidom by blast\nend\n\nlemma field_prime_charI [intro?]:\n \"n > 0 \\ of_nat n = (0 :: 'a :: field) \\ OFCLASS('a, field_prime_char_class)\"\n by sorry\n\nlemma field_prime_charI' [intro?]:\n \"CHAR('a :: field) > 0 \\ OFCLASS('a, field_prime_char_class)\"\n by sorry\n\nsubsection \\Finite fields\\\n\nclass finite_field = field_prime_char + finite\n\nlemma finite_fieldI [intro?]:\n assumes \"finite (UNIV :: 'a :: field set)\"\n shows \"OFCLASS('a, finite_field_class)\"\n by sorry\n\ntext \\\n On a finite field with \\n\\ elements, taking the \\n\\-th power of an element\n is the identity. This is an obvious consequence of the fact that the multiplicative group of\n the field is a finite group of order \\n - 1\\, so \\x^n = 1\\ for any non-zero \\x\\.\n\n Note that this result is sharp in the sense that the multiplicative group of a\n finite field is cyclic, i.e.\\ it contains an element of order \\n - 1\\.\n (We don't prove this here.)\n\\\nlemma finite_field_power_card_eq_same:\n fixes x :: \"'a :: finite_field\"\n shows \"x ^ card (UNIV :: 'a set) = x\"\n by sorry\n\nlemma finite_field_power_card_power_eq_same:\n fixes x :: \"'a :: finite_field\"\n assumes \"m = card (UNIV :: 'a set) ^ n\"\n shows \"x ^ m = x\"\n by sorry\n\nclass enum_finite_field = finite_field +\n fixes enum_finite_field :: \"nat \\ 'a\"\n assumes enum_finite_field: \"enum_finite_field ` {..\n To get rid of the pending sort hypotheses, we prove that the field with 2 elements is indeed\n a finite field.\n\\\ntypedef gf2 = \"{0, 1 :: nat}\"\n by auto\n\nsetup_lifting type_definition_gf2\n\ninstantiation gf2 :: field\nbegin\nlift_definition zero_gf2 :: \"gf2\" is \"0\" by auto\nlift_definition one_gf2 :: \"gf2\" is \"1\" by auto\nlift_definition uminus_gf2 :: \"gf2 \\ gf2\" is \"\\x. x\" .\nlift_definition plus_gf2 :: \"gf2 \\ gf2 \\ gf2\" is \"\\x y. if x = y then 0 else 1\" by auto\nlift_definition minus_gf2 :: \"gf2 \\ gf2 \\ gf2\" is \"\\x y. if x = y then 0 else 1\" by auto\nlift_definition times_gf2 :: \"gf2 \\ gf2 \\ gf2\" is \"\\x y. x * y\" by auto\nlift_definition inverse_gf2 :: \"gf2 \\ gf2\" is \"\\x. x\" .\nlift_definition divide_gf2 :: \"gf2 \\ gf2 \\ gf2\" is \"\\x y. x * y\" by auto\n\ninstance\n by standard (transfer; fastforce)+\n\nend\n\ninstance gf2 :: finite_field\nproof\n interpret type_definition Rep_gf2 Abs_gf2 \"{0, 1 :: nat}\"\n by (rule type_definition_gf2)\n show \"finite (UNIV :: gf2 set)\"\n by (metis Abs_image finite.emptyI finite.insertI finite_imageI)\nqed\n\nsubsection \\The Freshman's Dream in rings of prime characteristic\\\n\nlemma (in comm_semiring_1) freshmans_dream:\n fixes x y :: 'a and n :: nat\n assumes \"prime CHAR('a)\"\n assumes n_def: \"n = CHAR('a)\"\n shows \"(x + y) ^ n = x ^ n + y ^ n\"\n by sorry\n\nlemma (in comm_semiring_1) freshmans_dream':\n assumes [simp]: \"prime CHAR('a)\" and \"m = CHAR('a) ^ n\"\n shows \"(x + y :: 'a) ^ m = x ^ m + y ^ m\"\n by sorry\n\nlemma (in comm_semiring_1) freshmans_dream_sum:\n fixes f :: \"'b \\ 'a\"\n assumes \"prime CHAR('a)\" and \"n = CHAR('a)\"\n shows \"sum f A ^ n = sum (\\i. f i ^ n) A\"\n by sorry\n\nlemma (in comm_semiring_1) freshmans_dream_sum':\n fixes f :: \"'b \\ 'a\"\n assumes \"prime CHAR('a)\" \"m = CHAR('a) ^ n\"\n shows \"sum f A ^ m = sum (\\i. f i ^ m) A\"\n by sorry\n\nlemmas prime_imp_coprime_nat = prime_imp_coprime[where ?'a = nat]\nlemmas prime_imp_coprime_int = prime_imp_coprime[where ?'a = int]\nlemmas prime_dvd_mult_nat = prime_dvd_mult_iff[where ?'a = nat]\nlemmas prime_dvd_mult_int = prime_dvd_mult_iff[where ?'a = int]\nlemmas prime_dvd_mult_eq_nat = prime_dvd_mult_iff[where ?'a = nat]\nlemmas prime_dvd_mult_eq_int = prime_dvd_mult_iff[where ?'a = int]\nlemmas prime_dvd_power_nat = prime_dvd_power[where ?'a = nat]\nlemmas prime_dvd_power_int = prime_dvd_power[where ?'a = int]\nlemmas prime_dvd_power_nat_iff = prime_dvd_power_iff[where ?'a = nat]\nlemmas prime_dvd_power_int_iff = prime_dvd_power_iff[where ?'a = int]\nlemmas prime_imp_power_coprime_nat = prime_imp_power_coprime[where ?'a = nat]\nlemmas prime_imp_power_coprime_int = prime_imp_power_coprime[where ?'a = int]\nlemmas primes_coprime_nat = primes_coprime[where ?'a = nat]\nlemmas primes_coprime_int = primes_coprime[where ?'a = nat]\nlemmas prime_divprod_pow_nat = prime_elem_divprod_pow[where ?'a = nat]\nlemmas prime_exp = prime_elem_power_iff[where ?'a = nat]\n\nend" }, { "theorem_id": 23, "title": "011_the_infinitude_of_primes", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Jeremy Avigad, Mario Carneiro\n-/\nmodule\n\npublic import Mathlib.Data.Nat.Factorial.Basic\npublic import Mathlib.Data.Nat.Prime.Defs\npublic import Mathlib.Order.Bounds.Basic\n\n/-!\n## Notable Theorems\n\n- `Nat.exists_infinite_primes`: Euclid's theorem that there exist infinitely many prime numbers.\n This also appears as `Nat.not_bddAbove_setOf_prime` and `Nat.infinite_setOf_prime` (the latter\n in `Data.Nat.PrimeFin`).\n\n-/\n\npublic section\n\nopen Bool Subtype\n\nopen Nat\n\nnamespace Nat\n\nsection Infinite\n\n/-- Euclid's theorem on the **infinitude of primes**.\nHere given in the form: for every `n`, there exists a prime number `p ≥ n`. -/\ntheorem exists_infinite_primes (n : ℕ) : ∃ p, n ≤ p ∧ Prime p :=\n let p := minFac (n ! + 1)\n have f1 : n ! + 1 ≠ 1 := ne_of_gt <| succ_lt_succ <| factorial_pos _\n have pp : Prime p := minFac_prime f1\n have np : n ≤ p :=\n le_of_not_ge fun h =>\n have h₁ : p ∣ n ! := dvd_factorial (minFac_pos _) h\n have h₂ : p ∣ 1 := (Nat.dvd_add_iff_right h₁).2 (minFac_dvd _)\n pp.not_dvd_one h₂\n ⟨p, np, pp⟩\n\n/-- A version of `Nat.exists_infinite_primes` using the `BddAbove` predicate. -/\ntheorem not_bddAbove_setOf_prime : ¬BddAbove { p | Prime p } := by sorry\nend Infinite\n\nend Nat\n" }, { "theorem_id": 23, "title": "011_the_infinitude_of_primes", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq path.\nFrom mathcomp Require Import choice fintype div bigop.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nReserved Notation \"pi ^'\" (format \"pi ^'\").\nReserved Notation \"pi .-nat\" (format \"pi .-nat\").\n\nModule Import PrimeDecompAux.\n\nFixpoint edivn2 q r := if r is r'.+2 then edivn2 q.+1 r' else (q, r).\n\nLemma edivn2P n : edivn_spec n 2 (edivn2 0 n).\nProof.\nAdmitted.\n\nFixpoint elogn2 e q r {struct q} :=\n match q, r with\n | 0, _ | _, 0 => (e, q)\n | q'.+1, 1 => elogn2 e.+1 q' q'\n | q'.+1, r'.+2 => elogn2 e q' r'\n end.\nArguments elogn2 : simpl nomatch.\n\nVariant elogn2_spec n : nat * nat -> Type :=\n Elogn2Spec e m of n = 2 ^ e * m.*2.+1 : elogn2_spec n (e, m).\n\nLemma elogn2P n : elogn2_spec n.\nProof.\nAdmitted.\n\nDefinition ifnz T n (x y : T) := if n is 0 then y else x.\n\nVariant ifnz_spec T n (x y : T) : T -> Type :=\n | IfnzPos of n > 0 : ifnz_spec n x y x\n | IfnzZero of n = 0 : ifnz_spec n x y y.\n\nLemma ifnzP T n (x y : T) : ifnz_spec n x y (ifnz n x y).\nProof.\nAdmitted.\n\nDefinition add_divisors f divs :=\n let: (p, e) := f in\n let add1 divs' := merge leq (map (NatTrec.mul p) divs') divs in\n iter e add1 divs.\n\nImport NatTrec.\n\nDefinition add_totient_factor f m := let: (p, e) := f in p.-1 * p ^ e.-1 * m.\n\nDefinition cons_pfactor (p e : nat) pd := ifnz e ((p, e) :: pd) pd.\n\nNotation \"p ^? e :: pd\" := (cons_pfactor p e pd)\n (at level 30, e at level 30, pd at level 60) : nat_scope.\n\nEnd PrimeDecompAux.\n\nDefinition NumFactor (f : nat * nat) := ([Num of f.1], f.2).\n\nDefinition pfactor p e := p ^ e.\n\nSection prime_decomp.\n\nImport NatTrec.\n\nLocal Fixpoint prime_decomp_rec m k a b c e :=\n let p := k.*2.+1 in\n if a is a'.+1 then\n if b - (ifnz e 1 k - c) is b'.+1 then\n [rec m, k, a', b', ifnz c c.-1 (ifnz e p.-2 1), e] else\n if (b == 0) && (c == 0) then\n let b' := k + a' in [rec b'.*2.+3, k, a', b', k.-1, e.+1] else\n let bc' := ifnz e (ifnz b (k, 0) (edivn2 0 c)) (b, c) in\n p ^? e :: ifnz a' [rec m, k.+1, a'.-1, bc'.1 + a', bc'.2, 0] [:: (m, 1)]\n else if (b == 0) && (c == 0) then [:: (p, e.+2)] else p ^? e :: [:: (m, 1)]\nwhere \"[ 'rec' m , k , a , b , c , e ]\" := (prime_decomp_rec m k a b c e).\n\nDefinition prime_decomp n :=\n let: (e2, m2) := elogn2 0 n.-1 n.-1 in\n if m2 < 2 then 2 ^? e2 :: 3 ^? m2 :: [::] else\n let: (a, bc) := edivn m2.-2 3 in\n let: (b, c) := edivn (2 - bc) 2 in\n 2 ^? e2 :: [rec m2.*2.+1, 1, a, b, c, 0].\n\nEnd prime_decomp.\n\nDefinition primes n := unzip1 (prime_decomp n).\n\nDefinition prime p := if prime_decomp p is [:: (_ , 1)] then true else false.\n\nDefinition nat_pred := simpl_pred nat.\n\nDefinition pi_arg := nat.\nCoercion pi_arg_of_nat (n : nat) : pi_arg := n.\nCoercion pi_arg_of_fin_pred T pT (A : @fin_pred_sort T pT) : pi_arg := #|A|.\nArguments pi_arg_of_nat n /.\nArguments pi_arg_of_fin_pred {T pT} A /.\nDefinition pi_of (n : pi_arg) : nat_pred := [pred p in primes n].\n\nNotation \"\\pi ( n )\" := (pi_of n) (format \"\\pi ( n )\") : nat_scope.\nNotation \"\\p 'i' ( A )\" := \\pi(#|A|) (format \"\\p 'i' ( A )\") : nat_scope.\n\nDefinition pdiv n := head 1 (primes n).\n\nDefinition max_pdiv n := last 1 (primes n).\n\nDefinition divisors n := foldr add_divisors [:: 1] (prime_decomp n).\n\nDefinition totient n := foldr add_totient_factor (n > 0) (prime_decomp n).\n\nLemma prime_decomp_correct :\n let pd_val pd := \\prod_(f <- pd) pfactor f.\nProof.\nAdmitted.\n\nLemma primePn n :\n reflect (n < 2 \\/ exists2 d, 1 < d < n & d %| n) (~~ prime n).\nProof.\nAdmitted.\n\nLemma primeNsig n : ~~ prime n -> 2 <= n -> { d : nat | 1 < d < n & d %| n }.\nProof.\nAdmitted.\n\nLemma primeP p :\n reflect (p > 1 /\\ forall d, d %| p -> xpred2 1 p d) (prime p).\nProof.\nAdmitted.\n\nLemma prime_nt_dvdP d p : prime p -> d != 1 -> reflect (d = p) (d %| p).\nProof.\nAdmitted.\n\nArguments primeP {p}.\nArguments primePn {n}.\n\nLemma prime_gt1 p : prime p -> 1 < p.\nProof.\nAdmitted.\n\nLemma prime_gt0 p : prime p -> 0 < p.\nProof.\nAdmitted.\n\n#[global] Hint Resolve prime_gt1 prime_gt0 : core.\n\nLemma prod_prime_decomp n :\n n > 0 -> n = \\prod_(f <- prime_decomp n) f.\nProof.\nAdmitted.\n\nLemma even_prime p : prime p -> p = 2 \\/ odd p.\nProof.\nAdmitted.\n\nLemma prime_oddPn p : prime p -> reflect (p = 2) (~~ odd p).\nProof.\nAdmitted.\n\nLemma odd_prime_gt2 p : odd p -> prime p -> p > 2.\nProof.\nAdmitted.\n\nLemma mem_prime_decomp n p e :\n (p, e) \\in prime_decomp n -> [/\\ prime p, e > 0 & p ^ e %| n].\nProof.\nAdmitted.\n\nLemma prime_coprime p m : prime p -> coprime p m = ~~ (p %| m).\nProof.\nAdmitted.\n\nLemma dvdn_prime2 p q : prime p -> prime q -> (p %| q) = (p == q).\nProof.\nAdmitted.\n\nLemma Euclid_dvd1 p : prime p -> (p %| 1) = false.\nProof.\nAdmitted.\n\nLemma Euclid_dvdM m n p : prime p -> (p %| m * n) = (p %| m) || (p %| n).\nProof.\nAdmitted.\n\nLemma Euclid_dvd_prod (I : Type) (r : seq I) (P : pred I) (f : I -> nat) p :\n prime p ->\n (p %| \\prod_(i <- r | P i) f i) = \\big[orb/false]_(i <- r | P i) (p %| f i).\nProof.\nAdmitted.\n\nLemma Euclid_dvdX m n p : prime p -> (p %| m ^ n) = (p %| m) && (n > 0).\nProof.\nAdmitted.\n\nLemma mem_primes p n : (p \\in primes n) = [&& prime p, n > 0 & p %| n].\nProof.\nAdmitted.\n\nLemma sorted_primes n : sorted ltn (primes n).\nProof.\nAdmitted.\n\nLemma all_prime_primes n : all prime (primes n).\nProof.\nAdmitted.\n\nLemma eq_primes m n : (primes m =i primes n) <-> (primes m = primes n).\nProof.\nAdmitted.\n\nLemma primes_uniq n : uniq (primes n).\nProof.\nAdmitted.\n\nLemma pi_pdiv n : (pdiv n \\in \\pi(n)) = (n > 1).\nProof.\nAdmitted.\n\nLemma pdiv_prime n : 1 < n -> prime (pdiv n).\nProof.\nAdmitted.\n\nLemma pdiv_dvd n : pdiv n %| n.\nProof.\nAdmitted.\n\nLemma pi_max_pdiv n : (max_pdiv n \\in \\pi(n)) = (n > 1).\nProof.\nAdmitted.\n\nLemma max_pdiv_prime n : n > 1 -> prime (max_pdiv n).\nProof.\nAdmitted.\n\nLemma max_pdiv_dvd n : max_pdiv n %| n.\nProof.\nAdmitted.\n\nLemma pdiv_leq n : 0 < n -> pdiv n <= n.\nProof.\nAdmitted.\n\nLemma max_pdiv_leq n : 0 < n -> max_pdiv n <= n.\nProof.\nAdmitted.\n\nLemma pdiv_gt0 n : 0 < pdiv n.\nProof.\nAdmitted.\n\nLemma max_pdiv_gt0 n : 0 < max_pdiv n.\nProof.\nAdmitted.\n#[global] Hint Resolve pdiv_gt0 max_pdiv_gt0 : core.\n\nLemma pdiv_min_dvd m d : 1 < d -> d %| m -> pdiv m <= d.\nProof.\nAdmitted.\n\nLemma max_pdiv_max n p : p \\in \\pi(n) -> p <= max_pdiv n.\nProof.\nAdmitted.\n\nLemma ltn_pdiv2_prime n : 0 < n -> n < pdiv n ^ 2 -> prime n.\nProof.\nAdmitted.\n\nLemma primePns n :\n reflect (n < 2 \\/ exists p, [/\\ prime p, p ^ 2 <= n & p %| n]) (~~ prime n).\nProof.\nAdmitted.\n\nArguments primePns {n}.\n\nLemma pdivP n : n > 1 -> {p | prime p & p %| n}.\nProof.\nAdmitted.\n \nLemma primes_eq0 n : (primes n == [::]) = (n < 2).\nProof.\nAdmitted.\n\nLemma primesM m n p : m > 0 -> n > 0 ->\n (p \\in primes (m * n)) = (p \\in primes m) || (p \\in primes n).\nProof.\nAdmitted.\n\nLemma primesX m n : n > 0 -> primes (m ^ n) = primes m.\nProof.\nAdmitted.\n\nLemma primes_prime p : prime p -> primes p = [:: p].\nProof.\nAdmitted.\n\nLemma coprime_has_primes m n :\n 0 < m -> 0 < n -> coprime m n = ~~ has [in primes m] (primes n).\nProof.\nAdmitted.\n\nLemma pdiv_id p : prime p -> pdiv p = p.\nProof.\nAdmitted.\n\nLemma pdiv_pfactor p k : prime p -> pdiv (p ^ k.\nProof.\nAdmitted.\n\nLemma prime_above m : {p | m < p & prime p}.\nProof.\nAdmitted.\n\nFixpoint logn_rec d m r :=\n match r, edivn m d with\n | r'.+1, (_.+1 as m', 0) => (logn_rec d m' r').+1\n | _, _ => 0\n end.\n\nDefinition logn p m := if prime p then logn_rec p m m else 0.\n\nLemma lognE p m :\n logn p m = if [&& prime p, 0 < m & p %| m] then (logn p (m %/ p)).\nProof.\nAdmitted.\n\nLemma logn_gt0 p n : (0 < logn p n) = (p \\in primes n).\nProof.\nAdmitted.\n\nLemma ltn_log0 p n : n < p -> logn p n = 0.\nProof.\nAdmitted.\n\nLemma logn0 p : logn p 0 = 0.\nProof.\nAdmitted.\n\nLemma logn1 p : logn p 1 = 0.\nProof.\nAdmitted.\n\nLemma pfactor_gt0 p n : 0 < p ^ logn p n.\nProof.\nAdmitted.\n#[global] Hint Resolve pfactor_gt0 : core.\n\nLemma pfactor_dvdn p n m : prime p -> m > 0 -> (p ^ n %| m) = (n <= logn p m).\nProof.\nAdmitted.\n\nLemma pfactor_dvdnn p n : p ^ logn p n %| n.\nProof.\nAdmitted.\n\nLemma logn_prime p q : prime q -> logn p q = (p == q).\nProof.\nAdmitted.\n\nLemma pfactor_coprime p n :\n prime p -> n > 0 -> {m | coprime p m & n = m * p ^ logn p n}.\nProof.\nAdmitted.\n\nLemma pfactorK p n : prime p -> logn p (p ^ n) = n.\nProof.\nAdmitted.\n\nLemma pfactorKpdiv p n : prime p -> logn (pdiv (p ^ n)) (p ^ n) = n.\nProof.\nAdmitted.\n\nLemma dvdn_leq_log p m n : 0 < n -> m %| n -> logn p m <= logn p n.\nProof.\nAdmitted.\n\nLemma ltn_logl p n : 0 < n -> logn p n < n.\nProof.\nAdmitted.\n\nLemma logn_Gauss p m n : coprime p m -> logn p (m * n) = logn p n.\nProof.\nAdmitted.\n\nLemma logn_coprime p m : coprime p m -> logn p m = 0.\nProof.\nAdmitted.\n\nLemma lognM p m n : 0 < m -> 0 < n -> logn p (m * n) = logn p m + logn p n.\nProof.\nAdmitted.\n\nLemma lognX p m n : logn p (m ^ n) = n * logn p m.\nProof.\nAdmitted.\n\nLemma logn_div p m n : m %| n -> logn p (n %/ m) = logn p n - logn p m.\nProof.\nAdmitted.\n\nLemma dvdn_pfactor p d n : prime p ->\n reflect (exists2 m, m <= n & d = p ^ m) (d %| p ^ n).\nProof.\nAdmitted.\n\nLemma prime_decompE n : prime_decomp n = [seq (p, logn p n) | p <- primes n].\nProof.\nAdmitted.\n\nLemma divn_count_dvd d n : n %/ d = \\sum_(1 <= i < n.\nProof.\nAdmitted.\n\nLemma logn_count_dvd p n : prime p -> logn p n = \\sum_(1 <= k < n) (p ^ k %| n).\nProof.\nAdmitted.\n\nDefinition trunc_log p n :=\n let fix loop n k :=\n if k is k'.+1 then if p <= n then (loop (n %/ p) k').+1 else 0 else 0\n in if p <= 1 then 0 else loop n n.\n\nLemma trunc_log0 p : trunc_log p 0 = 0.\nProof.\nAdmitted.\n\nLemma trunc_log1 p : trunc_log p 1 = 0.\nProof.\nAdmitted.\n\nLemma trunc_log_bounds p n :\n 1 < p -> 0 < n -> let k := trunc_log p n in p ^ k <= n < p ^ k.\nProof.\nAdmitted.\n\nLemma trunc_logP p n : 1 < p -> 0 < n -> p ^ trunc_log p n <= n.\nProof.\nAdmitted.\n\nLemma trunc_log_ltn p n : 1 < p -> n < p ^ (trunc_log p n).\nProof.\nAdmitted.\n\nLemma trunc_log_max p k j : 1 < p -> p ^ j <= k -> j <= trunc_log p k.\nProof.\nAdmitted.\n\nLemma trunc_log_eq0 p n : (trunc_log p n == 0) = (p <= 1) || (n <= p.\nProof.\nAdmitted.\n\nLemma trunc_log_gt0 p n : (0 < trunc_log p n) = (1 < p) && (p.\nProof.\nAdmitted.\n\nLemma trunc_log0n n : trunc_log 0 n = 0.\nProof.\nAdmitted.\n\nLemma trunc_log1n n : trunc_log 1 n = 0.\nProof.\nAdmitted.\n\nLemma leq_trunc_log p m n : m <= n -> trunc_log p m <= trunc_log p n.\nProof.\nAdmitted.\n\nLemma trunc_log_eq p n k : 1 < p -> p ^ n <= k < p ^ n.\nProof.\nAdmitted.\n\nLemma trunc_lognn p : 1 < p -> trunc_log p p = 1.\nProof.\nAdmitted.\n\nLemma trunc_expnK p n : 1 < p -> trunc_log p (p ^ n) = n.\nProof.\nAdmitted.\n\nLemma trunc_logMp p n : 1 < p -> 0 < n ->\n trunc_log p (p * n) = (trunc_log p n).\nProof.\nAdmitted.\n\nLemma trunc_log2_double n : 0 < n -> trunc_log 2 n.\nProof.\nAdmitted.\n\nLemma trunc_log2S n : 1 < n -> trunc_log 2 n = (trunc_log 2 n.\nProof.\nAdmitted.\n\nDefinition up_log p n :=\n if (p <= 1) then 0 else\n let v := trunc_log p n in if n <= p ^ v then v else v.+1.\n\nLemma up_log0 p : up_log p 0 = 0.\nProof.\nAdmitted.\n\nLemma up_log1 p : up_log p 1 = 0.\nProof.\nAdmitted.\n\nLemma up_log_eq0 p n : (up_log p n == 0) = (p <= 1) || (n <= 1).\nProof.\nAdmitted.\n\nLemma up_log_gt0 p n : (0 < up_log p n) = (1 < p) && (1 < n).\nProof.\nAdmitted.\n\nLemma up_log_bounds p n :\n 1 < p -> 1 < n -> let k := up_log p n in p ^ k.\nProof.\nAdmitted.\n\nLemma up_logP p n : 1 < p -> n <= p ^ up_log p n.\nProof.\nAdmitted.\n\nLemma up_log_gtn p n : 1 < p -> 1 < n -> p ^ (up_log p n).\nProof.\nAdmitted.\n\nLemma up_log_min p k j : 1 < p -> k <= p ^ j -> up_log p k <= j.\nProof.\nAdmitted.\n\nLemma leq_up_log p m n : m <= n -> up_log p m <= up_log p n.\nProof.\nAdmitted.\n\nLemma up_log_eq p n k : 1 < p -> p ^ n < k <= p ^ n.\nProof.\nAdmitted.\n\nLemma up_lognn p : 1 < p -> up_log p p = 1.\nProof.\nAdmitted.\n\nLemma up_expnK p n : 1 < p -> up_log p (p ^ n) = n.\nProof.\nAdmitted.\n\nLemma up_logMp p n : 1 < p -> 0 < n -> up_log p (p * n) = (up_log p n).\nProof.\nAdmitted.\n\nLemma up_log2_double n : 0 < n -> up_log 2 n.\nProof.\nAdmitted.\n\nLemma up_log2S n : 0 < n -> up_log 2 n.\nProof.\nAdmitted.\n\nLemma up_log_trunc_log p n :\n 1 < p -> 1 < n -> up_log p n = (trunc_log p n.\nProof.\nAdmitted.\n\nLemma trunc_log_up_log p n :\n 1 < p -> 0 < n -> trunc_log p n = (up_log p n.\nProof.\nAdmitted.\n\nCanonical nat_pred_pred := Eval hnf in [predType of nat_pred].\n\nCoercion nat_pred_of_nat (p : nat) : nat_pred := pred1 p.\n\nSection NatPreds.\n\nVariables (n : nat) (pi : nat_pred).\n\nDefinition negn : nat_pred := [predC pi].\n\nDefinition pnat : pred nat := fun m => (m > 0) && all [in pi] (primes m).\n\nDefinition partn := \\prod_(0 <= p < n.+1 | p \\in pi) p ^ logn p n.\n\nEnd NatPreds.\n\nNotation \"pi ^'\" := (negn pi) : nat_scope.\n\nNotation \"pi .-nat\" := (pnat pi) : nat_scope.\n\nNotation \"n `_ pi\" := (partn n pi) : nat_scope.\n\nSection PnatTheory.\n\nImplicit Types (n p : nat) (pi rho : nat_pred).\n\nLemma negnK pi : pi^'^' =i pi.\nProof.\nAdmitted.\n\nLemma eq_negn pi1 pi2 : pi1 =i pi2 -> pi1^' =i pi2^'.\nProof.\nAdmitted.\n\nLemma eq_piP m n : \\pi(m) =i \\pi(n) <-> \\pi(m) = \\pi(n).\nProof.\nAdmitted.\n\nLemma part_gt0 pi n : 0 < n`_pi.\nProof.\nAdmitted.\nHint Resolve part_gt0 : core.\n\nLemma sub_in_partn pi1 pi2 n :\n {in \\pi(n), {subset pi1 <= pi2}} -> n`_pi1 %| n`_pi2.\nProof.\nAdmitted.\n\nLemma eq_in_partn pi1 pi2 n : {in \\pi(n), pi1 =i pi2} -> n`_pi1 = n`_pi2.\nProof.\nAdmitted.\n\nLemma eq_partn pi1 pi2 n : pi1 =i pi2 -> n`_pi1 = n`_pi2.\nProof.\nAdmitted.\n\nLemma partnNK pi n : n`_pi^'^' = n`_pi.\nProof.\nAdmitted.\n\nLemma widen_partn m pi n :\n n <= m -> n`_pi = \\prod_(0 <= p < m.\nProof.\nAdmitted.\n\nLemma eq_partn_from_log m n (pi : nat_pred) : 0 < m -> 0 < n ->\n {in pi, logn^~ m =1 logn^~ n} -> m`_pi = n`_pi.\nProof.\nAdmitted.\n\nLemma partn0 pi : 0`_pi = 1.\nProof.\nAdmitted.\n\nLemma partn1 pi : 1`_pi = 1.\nProof.\nAdmitted.\n\nLemma partnM pi m n : m > 0 -> n > 0 -> (m * n)`_pi = m`_pi * n`_pi.\nProof.\nAdmitted.\n\nLemma partnX pi m n : (m ^ n)`_pi = m`_pi ^ n.\nProof.\nAdmitted.\n\nLemma partn_dvd pi m n : n > 0 -> m %| n -> m`_pi %| n`_pi.\nProof.\nAdmitted.\n\nLemma p_part p n : n`_p = p ^ logn p n.\nProof.\nAdmitted.\n\nLemma p_part_eq1 p n : (n`_p == 1) = (p \\notin \\pi(n)).\nProof.\nAdmitted.\n\nLemma p_part_gt1 p n : (n`_p > 1) = (p \\in \\pi(n)).\nProof.\nAdmitted.\n\nLemma primes_part pi n : primes n`_pi = filter [in pi] (primes n).\nProof.\nAdmitted.\n\nLemma filter_pi_of n m : n < m -> filter \\pi(n) (index_iota 0 m) = primes n.\nProof.\nAdmitted.\n\nLemma partn_pi n : n > 0 -> n`_\\pi(n) = n.\nProof.\nAdmitted.\n\nLemma partnT n : n > 0 -> n`_predT = n.\nProof.\nAdmitted.\n\nLemma eqn_from_log m n : 0 < m -> 0 < n -> logn^~ m =1 logn^~ n -> m = n.\nProof.\nAdmitted.\n\nLemma partnC pi n : n > 0 -> n`_pi * n`_pi^' = n.\nProof.\nAdmitted.\n\nLemma dvdn_part pi n : n`_pi %| n.\nProof.\nAdmitted.\n\nLemma logn_part p m : logn p m`_p = logn p m.\nProof.\nAdmitted.\n\nLemma partn_lcm pi m n : m > 0 -> n > 0 -> (lcmn m n)`_pi = lcmn m`_pi n`_pi.\nProof.\nAdmitted.\n\nLemma partn_gcd pi m n : m > 0 -> n > 0 -> (gcdn m n)`_pi = gcdn m`_pi n`_pi.\nProof.\nAdmitted.\n\nLemma partn_biglcm (I : finType) (P : pred I) F pi :\n (forall i, P i -> F i > 0) ->\n (\\big[lcmn/1%N]_(i | P i) F i)`_pi = \\big[lcmn/1%N]_(i | P i) (F i)`_pi.\nProof.\nAdmitted.\n\nLemma partn_biggcd (I : finType) (P : pred I) F pi :\n #|SimplPred P| > 0 -> (forall i, P i -> F i > 0) ->\n (\\big[gcdn/0]_(i | P i) F i)`_pi = \\big[gcdn/0]_(i | P i) (F i)`_pi.\nProof.\nAdmitted.\n\nLemma logn_gcd p m n : 0 < m -> 0 < n ->\n logn p (gcdn m n) = minn (logn p m) (logn p n).\nProof.\nAdmitted.\n\nLemma logn_lcm p m n : 0 < m -> 0 < n ->\n logn p (lcmn m n) = maxn (logn p m) (logn p n).\nProof.\nAdmitted.\n\nLemma sub_in_pnat pi rho n :\n {in \\pi(n), {subset pi <= rho}} -> pi.\nProof.\nAdmitted.\n\nLemma eq_in_pnat pi rho n : {in \\pi(n), pi =i rho} -> pi.\nProof.\nAdmitted.\n\nLemma eq_pnat pi rho n : pi =i rho -> pi.\nProof.\nAdmitted.\n\nLemma pnatNK pi n : pi^'^'.\nProof.\nAdmitted.\n\nLemma pnatI pi rho n : [predI pi & rho].\nProof.\nAdmitted.\n\nLemma pnatM pi m n : pi.\nProof.\nAdmitted.\n\nLemma pnatX pi m n : pi.\nProof.\nAdmitted.\n\nLemma part_pnat pi n : pi.\nProof.\nAdmitted.\n\nLemma pnatE pi p : prime p -> pi.\nProof.\nAdmitted.\n\nLemma pnat_id p : prime p -> p.\nProof.\nAdmitted.\n\nLemma coprime_pi' m n : m > 0 -> n > 0 -> coprime m n = \\pi(m)^'.\nProof.\nAdmitted.\n\nLemma pnat_pi n : n > 0 -> \\pi(n).\nProof.\nAdmitted.\n\nLemma pi_of_dvd m n : m %| n -> n > 0 -> {subset \\pi(m) <= \\pi(n)}.\nProof.\nAdmitted.\n\nLemma pi_ofM m n : m > 0 -> n > 0 -> \\pi(m * n) =i [predU \\pi(m) & \\pi(n)].\nProof.\nAdmitted.\n\nLemma pi_of_part pi n : n > 0 -> \\pi(n`_pi) =i [predI \\pi(n) & pi].\nProof.\nAdmitted.\n\nLemma pi_of_exp p n : n > 0 -> \\pi(p ^ n) = \\pi(p).\nProof.\nAdmitted.\n\nLemma pi_of_prime p : prime p -> \\pi(p) =i (p : nat_pred).\nProof.\nAdmitted.\n\nLemma p'natEpi p n : n > 0 -> p^'.\nProof.\nAdmitted.\n\nLemma p'natE p n : prime p -> p^'.\nProof.\nAdmitted.\n\nLemma pnatPpi pi n p : pi.\nProof.\nAdmitted.\n\nLemma pnat_dvd m n pi : m %| n -> pi.\nProof.\nAdmitted.\n\nLemma pnat_div m n pi : m %| n -> pi.\nProof.\nAdmitted.\n\nLemma pnat_coprime pi m n : pi.\nProof.\nAdmitted.\n\nLemma p'nat_coprime pi m n : pi^'.\nProof.\nAdmitted.\n\nLemma sub_pnat_coprime pi rho m n :\n {subset rho <= pi^'} -> pi.\nProof.\nAdmitted.\n\nLemma coprime_partC pi m n : coprime m`_pi n`_pi^'.\nProof.\nAdmitted.\n\nLemma pnat_1 pi n : pi.\nProof.\nAdmitted.\n\nLemma part_pnat_id pi n : pi.\nProof.\nAdmitted.\n\nLemma part_p'nat pi n : pi^'.\nProof.\nAdmitted.\n\nLemma partn_eq1 pi n : n > 0 -> (n`_pi == 1) = pi^'.\nProof.\nAdmitted.\n\nLemma pnatP pi n :\n n > 0 -> reflect (forall p, prime p -> p %| n -> p \\in pi) (pi.\nProof.\nAdmitted.\n\nLemma pi_pnat pi p n : p.\nProof.\nAdmitted.\n\nLemma p_natP p n : p.\nProof.\nAdmitted.\n\nLemma pi'_p'nat pi p n : pi^'.\nProof.\nAdmitted.\n\nLemma pi_p'nat p pi n : pi.\nProof.\nAdmitted.\n\nLemma partn_part pi rho n : {subset pi <= rho} -> n`_rho`_pi = n`_pi.\nProof.\nAdmitted.\n\nLemma partnI pi rho n : n`_[predI pi & rho] = n`_pi`_rho.\nProof.\nAdmitted.\n\nLemma odd_2'nat n : odd n = 2^'.\nProof.\nAdmitted.\n\nEnd PnatTheory.\n#[global] Hint Resolve part_gt0 : core.\n\nLemma divisors_correct n : n > 0 ->\n [/\\ uniq (divisors n), sorted leq (divisors n)\n & forall d, (d \\in divisors n) = (d %| n)].\nProof.\nAdmitted.\n\nLemma sorted_divisors n : sorted leq (divisors n).\nProof.\nAdmitted.\n\nLemma divisors_uniq n : uniq (divisors n).\nProof.\nAdmitted.\n\nLemma sorted_divisors_ltn n : sorted ltn (divisors n).\nProof.\nAdmitted.\n\nLemma dvdn_divisors d m : 0 < m -> (d %| m) = (d \\in divisors m).\nProof.\nAdmitted.\n\nLemma divisor1 n : 1 \\in divisors n.\nProof.\nAdmitted.\n\nLemma divisors_id n : 0 < n -> n \\in divisors n.\nProof.\nAdmitted.\n\nLemma dvdn_sum d I r (K : pred I) F :\n (forall i, K i -> d %| F i) -> d %| \\sum_(i <- r | K i) F i.\nProof.\nAdmitted.\n\nLemma dvdn_partP n m : 0 < n ->\n reflect (forall p, p \\in \\pi(n) -> n`_p %| m) (n %| m).\nProof.\nAdmitted.\n\nLemma modn_partP n a b : 0 < n ->\n reflect (forall p : nat, p \\in \\pi(n) -> a = b %[mod n`_p]) (a == b %[mod n]).\nProof.\nAdmitted.\n\nLemma totientE n :\n n > 0 -> totient n = \\prod_(p <- primes n) (p.\nProof.\nAdmitted.\n\nLemma totient_gt0 n : (0 < totient n) = (0 < n).\nProof.\nAdmitted.\n\nLemma totient_pfactor p e :\n prime p -> e > 0 -> totient (p ^ e) = p.\nProof.\nAdmitted.\n\nLemma totient_prime p : prime p -> totient p = p.\nProof.\nAdmitted.\n\nLemma totient_coprime m n :\n coprime m n -> totient (m * n) = totient m * totient n.\nProof.\nAdmitted.\n\nLemma totient_count_coprime n : totient n = \\sum_(0 <= d < n) coprime n d.\nProof.\nAdmitted.\n\nLemma totient_gt1 n : (totient n > 1) = (n > 2).\nProof.\nAdmitted." }, { "theorem_id": 24, "title": "014_euler_s_summation_of_1_+__1_2_^2_+__1_3_^2_+", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/analysis.ml\";;\nneeds \"Library/transc.ml\";;\nneeds \"Library/floor.ml\";;\nneeds \"Library/poly.ml\";;\nneeds \"Examples/machin.ml\";;\nneeds \"Library/iter.ml\";;\n\nlet REAL_LE_1_POW2 = `!n. &1 <= &2 pow n`;;\n\nlet REAL_LT_1_POW2 = `!n. &1 < &2 pow n <=> ~(n = 0)`;;\n\nlet REAL_POW2_CLAUSES = `(!n. &0 <= &2 pow n) /\\\n (!n. &0 < &2 pow n) /\\\n (!n. &0 <= inv(&2 pow n)) /\\\n (!n. &0 < inv(&2 pow n)) /\\\n (!n. inv(&2 pow n) <= &1) /\\\n (!n. &1 - inv(&2 pow n) <= &1) /\\\n (!n. &1 <= &2 pow n) /\\\n (!n. &1 < &2 pow n <=> ~(n = 0)) /\\\n (!n. &0 <= &1 - inv(&2 pow n)) /\\\n (!n. &0 <= &2 pow n - &1) /\\\n (!n. &0 < &1 - inv(&2 pow n) <=> ~(n = 0))`;;\n\nlet REAL_INTEGER_CLOSURES = `(!n. ?p. abs(&n) = &p) /\\\n (!x y. (?m. abs(x) = &m) /\\ (?n. abs(y) = &n) ==> ?p. abs(x + y) = &p) /\\\n (!x y. (?m. abs(x) = &m) /\\ (?n. abs(y) = &n) ==> ?p. abs(x - y) = &p) /\\\n (!x y. (?m. abs(x) = &m) /\\ (?n. abs(y) = &n) ==> ?p. abs(x * y) = &p) /\\\n (!x r. (?n. abs(x) = &n) ==> ?p. abs(x pow r) = &p) /\\\n (!x. (?n. abs(x) = &n) ==> ?p. abs(--x) = &p) /\\\n (!x. (?n. abs(x) = &n) ==> ?p. abs(abs x) = &p)`;;\n\nlet PI_APPROX_25_BITS = time PI_APPROX_BINARY_RULE 25;;\n\nlet POLYMERIZE_CONV =\n let pth = `a = poly [a] x`;;\n\nlet SUM_PERMUTE_0 = `!n p. (!y. y < n ==> ?!x. x < n /\\ (p(x) = y))\n ==> !f. sum(0,n)(\\n. f(p n)) = sum(0,n) f`;;\n\nlet SUM_REVERSE_0 = `!n f. sum(0,n) f = sum(0,n) (\\k. f((n - 1) - k))`;;\n\nlet SUM_REVERSE = `!n m f. sum(m,n) f = sum(m,n) (\\k. f(((n + 2 * m) - 1) - k))`;;\n\nlet MCLAURIN_SIN = `!x n. abs(sin x -\n sum(0,n) (\\m. (if EVEN m then &0\n else -- &1 pow ((m - 1) DIV 2) / &(FACT m)) *\n x pow m))\n <= inv(&(FACT n)) * abs(x) pow n`;;\n\nlet COT_HALF_TAN = `~(integer x)\n ==> (cot(pi * x) = &1 / &2 * (cot(pi * x / &2) - tan(pi * x / &2)))`;;\n\nlet COT_HALF_POS = `~(integer x)\n ==> (cot(pi * x) = &1 / &2 * (cot(pi * x / &2) + cot(pi * (x + &1) / &2)))`;;\n\nlet COT_HALF_NEG = `~(integer x)\n ==> (cot(pi * x) = &1 / &2 * (cot(pi * x / &2) + cot(pi * (x - &1) / &2)))`;;\n\nlet COT_HALF_MULTIPLE = `~(integer x)\n ==> !n. cot(pi * x) =\n sum(0,2 EXP n)\n (\\k. cot(pi * (x + &k) / &2 pow n) +\n cot(pi * (x - &k) / &2 pow n)) / &2 pow (n + 1)`;;\n\nlet COT_HALF_KNOPP = `~(integer x)\n ==> !n. cot(pi * x) =\n cot(pi * x / &2 pow n) / &2 pow n +\n sum(1,2 EXP n - 1)\n (\\k. cot(pi * (x + &k) / &2 pow (n + 1)) +\n cot(pi * (x - &k) / &2 pow (n + 1))) / &2 pow (n + 1)`;;\n\nlet SIN_SUMDIFF_LEMMA = `!x y. sin(x + y) * sin(x - y) = (sin x + sin y) * (sin x - sin y)`;;\n\nlet SIN_ZERO_LEMMA = `!x. (sin(pi * x) = &0) <=> integer(x)`;;\n\nlet NOT_INTEGER_LEMMA = `~(x = &0) /\\ abs(x) < &1 ==> ~(integer x)`;;\n\nlet NOT_INTEGER_DIV_POW2 = `~(integer x) ==> ~(integer(x / &2 pow n))`;;\n\nlet SIN_ABS_LEMMA = `!x. abs(x) < pi ==> (abs(sin x) = sin(abs x))`;;\n\nlet SIN_EQ_LEMMA = `!x y. &0 <= x /\\ x < pi / &2 /\\ &0 <= y /\\ y < pi / &2\n ==> ((sin x = sin y) <=> (x = y))`;;\n\nlet KNOPP_TERM_EQUIVALENT = `~(integer x) /\\ k < 2 EXP n\n ==> ((cot(pi * (x + &k) / &2 pow (n + 1)) +\n cot(pi * (x - &k) / &2 pow (n + 1))) / &2 pow (n + 1) =\n cot(pi * x / &2 pow (n + 1)) / &2 pow n /\n (&1 - sin(pi * &k / &2 pow (n + 1)) pow 2 /\n sin(pi * x / &2 pow (n + 1)) pow 2))`;;\n\nlet SIN_LINEAR_ABOVE = `!x. abs(x) < &1 ==> abs(sin x) <= &2 * abs(x)`;;\n\nlet SIN_LINEAR_BELOW = `!x. abs(x) < &2 ==> abs(sin x) >= abs(x) / &3`;;\n\nlet KNOPP_TERM_BOUND_LEMMA = `~(integer x) /\\ k < 2 EXP n /\\ &6 * abs(x) < &k\n ==> abs(a / (&1 - sin(pi * &k / &2 pow (n + 1)) pow 2 /\n sin(pi * x / &2 pow (n + 1)) pow 2))\n <= abs(a) / ((&k / (&6 * x)) pow 2 - &1)`;;\n\nlet KNOPP_TERM_BOUND = `~(integer x) /\\ k < 2 EXP n /\\ &6 * abs(x) < &k\n ==> abs((cot(pi * (x + &k) / &2 pow (n + 1)) +\n cot(pi * (x - &k) / &2 pow (n + 1))) / &2 pow (n + 1))\n <= abs(cot(pi * x / &2 pow (n + 1)) / &2 pow n) *\n (&36 * x pow 2) / (&k pow 2 - &36 * x pow 2)`;;\n\nlet SUMMABLE_INVERSE_SQUARES_LEMMA = `(\\n. inv(&(n + 1) * &(n + 2))) sums &1`;;\n\nlet SUMMABLE_INVERSE_SQUARES = `summable (\\n. inv(&n pow 2))`;;\n\nlet SUMMABLE_INVERSE_POWERS = `!m. 2 <= m ==> summable (\\n. inv(&(n + 1) pow m))`;;\n\nlet COT_TYPE_SERIES_CONVERGES = `!x. ~(integer x) ==> summable (\\n. inv(&n pow 2 - x))`;;\n\nlet SIN_X_RANGE = `!x. abs(sin(x) - x) <= abs(x) pow 2 / &2`;;\n\nlet SIN_X_X_RANGE = `!x. ~(x = &0) ==> abs(sin(x) / x - &1) <= abs(x) / &2`;;\n\nlet SIN_X_LIMIT = `((\\x. sin(x) / x) tends_real_real &1)(&0)`;;\n\nlet COT_X_LIMIT = `((\\x. x * cot(x)) tends_real_real &1)(&0)`;;\n\nlet COT_LIMIT_LEMMA = `!x. ~(x = &0)\n ==> (\\n. (x / &2 pow n) * cot(x / &2 pow n)) tends_num_real &1`;;\n\nlet COT_LIMIT_LEMMA1 = `~(x = &0)\n ==> (\\n. (pi / &2 pow (n + 1)) * cot(pi * x / &2 pow (n + 1)))\n tends_num_real (inv(x))`;;\n\nlet COT_X_BOUND_LEMMA_POS = `?M. !x. &0 < x /\\ abs(x) <= &1 ==> abs(x * cot(x)) <= M`;;\n\nlet COT_X_BOUND_LEMMA = `?M. !x. ~(x = &0) /\\ abs(x) <= &1 ==> abs(x * cot(x)) <= M`;;\n\nlet COT_PARTIAL_FRACTIONS = `~(integer x)\n ==> (\\n. (&2 * x pow 2) / (x pow 2 - &n pow 2)) sums\n ((pi * x) * cot(pi * x) + &1)`;;\n\nlet COT_PARTIAL_FRACTIONS_SUBTERM = `abs(x) < &n\n ==> (\\k. --(&2) * (x pow 2 / &n pow 2) pow (k + 1))\n sums ((&2 * x pow 2) / (x pow 2 - &n pow 2))`;;\n\nlet SEQ_LE_CONST = `!a x l N. (!n. n >= N ==> x(n) <= a) /\\ x tends_num_real l ==> l <= a`;;\n\nlet SEQ_GE_CONST = `!a x l N. (!n. n >= N ==> a <= x(n)) /\\ x tends_num_real l ==> a <= l`;;\n\nlet SUM_SWAP_0 = `!m n. sum(0,m) (\\i. sum(0,n) (\\j. a i j)) =\n sum(0,n) (\\j. sum(0,m) (\\i. a i j))`;;\n\nlet SUM_SWAP = `!m1 m2 n1 n2.\n sum(m1,m2) (\\i. sum(n1,n2) (\\j. a i j)) =\n sum(n1,n2) (\\j. sum(m1,m2) (\\i. a i j))`;;\n\nlet SER_SWAPDOUBLE_POS = `!z a l. (!m n. &0 <= a m n) /\\ (!m. (a m) sums (z m)) /\\ z sums l\n ==> ?s. (!n. (\\m. a m n) sums (s n)) /\\ s sums l`;;\n\nlet COT_PARTIAL_FRACTIONS_FROM1 = `~integer x\n ==> (\\n. (&2 * x pow 2) / (x pow 2 - &(n + 1) pow 2)) sums\n (pi * x) * cot (pi * x) - &1`;;\n\nlet COT_ALT_POWSER = `!x. &0 < abs(x) /\\ abs(x) < &1\n ==> ?s. (!n. (\\m. &2 * (x pow 2 / &(m + 1) pow 2) pow (n + 1))\n sums s n) /\\\n s sums --((pi * x) * cot(pi * x) - &1)`;;\n\nlet SER_INSERTZEROS = `(\\n. c(2 * n)) sums l\n ==> (\\n. if ODD n then &0 else c(n)) sums l`;;\n\nlet COT_POWSER_SQUARED_FORM = `!x. &0 < abs(x) /\\ abs(x) < pi\n ==> (\\n. &2 * (x / pi) pow (2 * (n + 1)) *\n suminf (\\m. inv (&(m + 1) pow (2 * (n + 1)))))\n sums --(x * cot x - &1)`;;\n\nlet COT_POWSER_SQUAREDAGAIN = `!x. &0 < abs(x) /\\ abs(x) < pi\n ==> (\\n. (if n = 0 then &1\n else --(&2) *\n suminf (\\m. inv (&(m + 1) pow (2 * n))) /\n pi pow (2 * n)) *\n x pow (2 * n))\n sums (x * cot(x))`;;\n\nlet COT_X_POWSER = `!x. &0 < abs(x) /\\ abs(x) < pi\n ==> (\\n. (if n = 0 then &1 else if ODD n then &0 else\n --(&2) * suminf (\\m. inv (&(m + 1) pow n)) / pi pow n) *\n x pow n)\n sums (x * cot(x))`;;\n\nlet TAN_COT_DOUBLE = `!x. &0 < abs(x) /\\ abs(x) < pi / &2\n ==> (tan(x) = cot(x) - &2 * cot(&2 * x))`;;\n\nlet TAN_POWSER_WEAK = `!x. &0 < abs(x) /\\ abs(x) < pi / &2\n ==> (\\n. (if EVEN n then &0 else\n &2 * (&2 pow (n + 1) - &1) *\n suminf (\\m. inv (&(m + 1) pow (n + 1))) / pi pow (n + 1)) *\n x pow n)\n sums (tan x)`;;\n\nlet TAN_POWSER = `!x. abs(x) < pi / &2\n ==> (\\n. (if EVEN n then &0 else\n &2 * (&2 pow (n + 1) - &1) *\n suminf (\\m. inv (&(m + 1) pow (n + 1))) / pi pow (n + 1)) *\n x pow n)\n sums (tan x)`;;\n\nlet th = `(f diffl l)(x) ==>\n ((\\x. poly p (f x)) diffl (l * poly (poly_diff p) (f x)))(x)`;;\n\nlet tanpoly = new_recursive_definition num_RECURSION\n `(tanpoly 0 = [&0; &1]) /\\\n (!n. tanpoly (SUC n) = [&1; &0; &1] ** poly_diff(tanpoly n))`;;\n\nlet TANPOLYS_RULE =\n let pth1,pth2 = CONJ_PAIR tanpoly in\n let base = [pth1]\n and rule = GEN_REWRITE_RULE LAND_CONV [GSYM pth2] in\n let poly_diff_tm = `poly_diff`\n and poly_mul_tm = `( ** ) [&1; &0; &1]` in\n let rec tanpolys n =\n if n < 0 then []\n else if n = 0 then base else\n let thl = tanpolys (n - 1) in\n let th1 = AP_TERM poly_diff_tm (hd thl) in\n let th2 = TRANS th1 (POLY_DIFF_CONV (rand(concl th1))) in\n let th3 = AP_TERM poly_mul_tm th2 in\n let th4 = TRANS th3 (POLY_MUL_CONV (rand(concl th3))) in\n let th5 = rule th4 in\n let th6 = CONV_RULE (LAND_CONV(RAND_CONV NUM_SUC_CONV)) th5 in\n th6::thl in\n rev o tanpolys;;\n\nlet TANPOLY_CONV =\n let tanpoly_tm = `tanpoly` in\n fun tm ->\n let l,r = dest_comb tm in\n if l <> tanpoly_tm then failwith \"TANPOLY_CONV\"\n else last(TANPOLYS_RULE(dest_small_numeral r));;\n\nlet tannumber = new_definition\n `tannumber n = poly (tanpoly n) (&0)`;;\n\nlet TANNUMBERS_RULE,TANNUMBER_CONV =\n let POLY_0_THM = `(poly [] (&0) = &0) /\\\n (poly (CONS h t) (&0) = h)`;;\n\nlet th = `(f diffl l)(x) /\\ ~(cos(f x) = &0)\n ==> ((\\x. poly (tanpoly n) (tan(f x))) diffl\n (l * poly (tanpoly(SUC n)) (tan(f x))))(x)`;;\n\nlet TAN_DERIV_POWSER = `!n x. abs(x) < pi / &2\n ==> (\\m. ITER n diffs\n (\\i. if EVEN i\n then &0\n else &2 *\n (&2 pow (i + 1) - &1) *\n suminf (\\m. inv (&(m + 1) pow (i + 1))) /\n pi pow (i + 1)) m *\n x pow m)\n sums (poly (tanpoly n) (tan x))`;;\n\nlet ITER_DIFFS_LEMMA = `!n c. ITER n diffs c 0 = &(FACT n) * c(n)`;;\n\nlet TANNUMBER_HARMONICSUMS = `!n. ODD n\n ==> (&2 * (&2 pow (n + 1) - &1) * &(FACT n) *\n suminf (\\m. inv (&(m + 1) pow (n + 1))) / pi pow (n + 1) =\n tannumber n)`;;\n\nlet HARMONICSUMS_TANNUMBER = `!n. EVEN n /\\ ~(n = 0)\n ==> (suminf (\\m. inv (&(m + 1) pow n)) / pi pow n =\n tannumber(n - 1) / (&2 * &(FACT(n - 1)) * (&2 pow n - &1)))`;;\n\nlet ODD_POLY_DIFF = `(!x. poly p (--x) = poly p x)\n ==> (!x. poly (poly_diff p) (--x) = --(poly(poly_diff p) x))`;;\n\nlet EVEN_POLY_DIFF = `(!x. poly p (--x) = --(poly p x))\n ==> (!x. poly (poly_diff p) (--x) = poly(poly_diff p) x)`;;\n\nlet TANPOLY_ODD_EVEN = `!n x. (poly (tanpoly n) (--x) =\n if EVEN n then --(poly (tanpoly n) x) else poly (tanpoly n) x)`;;\n\nlet TANNUMBER_EVEN = `!n. EVEN n ==> (tannumber n = &0)`;;\n\nlet TAYLOR_TAN_CONVERGES = `!x. abs(x) < pi / &2\n ==> (\\n. tannumber n / &(FACT n) * x pow n) sums (tan x)`;;\n\nlet TAYLOR_X_COT_CONVERGES = `!x. &0 < abs(x) /\\ abs(x) < pi\n ==> (\\n. (if n = 0 then &1 else\n tannumber (n - 1) / ((&1 - &2 pow n) * &(FACT(n - 1)))) *\n x pow n)\n sums (x * cot(x))`;;\n\nlet TANNUMBER_BOUND = `!n. abs(tannumber n) <= &4 * &(FACT n) * (&2 / pi) pow (n + 1)`;;\n\nlet HARMONIC_SUMS = `!n. (\\m. inv (&(m + 1) pow (2 * (n + 1))))\n sums (pi pow (2 * (n + 1)) *\n tannumber(2 * n + 1) /\n (&2 * (&2 pow (2 * (n + 1)) - &1) * &(FACT(2 * n + 1))))`;;\n\nlet mk_harmonic =\n let pth = `x * &1 / n = x / n`;;\n\nlet EULER_HARMONIC_SUM = mk_harmonic 2;;\n\nlet TAYLOR_TAN_BOUND_GENERAL = `!x n. abs(x) <= &1\n ==> abs(tan x - sum (0,n) (\\m. tannumber m / &(FACT m) * x pow m))\n <= &12 * (&2 / &3) pow (n + 1) * abs(x) pow n`;;\n\nlet TAYLOR_TAN_BOUND = `!x n k. abs(x) <= inv(&2 pow k)\n ==> abs(tan x -\n sum (0,n) (\\m. tannumber(m) / &(FACT(m)) * x pow m))\n <= &12 * (&2 / &3) pow (n + 1) * inv(&2 pow (k * n))`;;\n\nlet TAYLOR_TANX_BOUND = `!x n k. abs(x) <= inv(&2 pow k) /\\ ~(x = &0)\n ==> abs(tan x / x -\n sum (0,n) (\\m. tannumber(m+1) / &(FACT(m+1)) * x pow m))\n <= &12 * (&2 / &3) pow (n + 2) * inv(&2 pow (k * n))`;;\n\nlet TAYLOR_TANX_SQRT_BOUND = `!x n k. abs(x) <= inv(&2 pow k) /\\ &0 < x\n ==> abs(tan (sqrt x) / sqrt(x) -\n sum(0,n) (\\m. tannumber(2 * m + 1) / &(FACT(2 * m + 1)) *\n x pow m))\n <= &12 * (&2 / &3) pow (2 * n + 2) *\n inv(&2 pow (k DIV 2 * 2 * n))`;;\n\nlet TAYLOR_COT_BOUND_GENERAL = `!x n. abs(x) <= &1 /\\ ~(x = &0)\n ==> abs((&1 / x - cot x) -\n sum (0,n) (\\m. (tannumber m /\n ((&2 pow (m+1) - &1) * &(FACT(m)))) *\n x pow m))\n <= &4 * (abs(x) / &3) pow n`;;\n\nlet TAYLOR_COT_BOUND = `!x n k. abs(x) <= inv(&2 pow k) /\\ ~(x = &0)\n ==> abs((&1 / x - cot x) -\n sum (0,n) (\\m. (tannumber m /\n ((&2 pow (m+1) - &1) * &(FACT(m)))) *\n x pow m))\n <= &4 / &3 pow n * inv(&2 pow (k * n))`;;\n\nlet TAYLOR_COTX_BOUND = `!x n k. abs(x) <= inv(&2 pow k) /\\ ~(x = &0)\n ==> abs((&1 / x - cot x) / x -\n sum (0,n) (\\m. (tannumber(m+1) /\n ((&2 pow (m+2) - &1) * &(FACT(m+1)))) *\n x pow m))\n <= (&4 / &3) / &3 pow n * inv(&2 pow (k * n))`;;\n\nlet TAYLOR_COTXX_BOUND = `!x n k. abs(x) <= inv(&2 pow k) /\\ ~(x = &0)\n ==> abs((&1 - x * cot(x)) -\n sum(0,n) (\\m. (tannumber (m-1) /\n ((&2 pow m - &1) * &(FACT(m-1)))) *\n x pow m))\n <= &12 / &3 pow n * inv(&2 pow (k * n))`;;\n\nlet TAYLOR_COTXX_SQRT_BOUND = `!x n k. abs(x) <= inv(&2 pow k) /\\ &0 < x\n ==> abs((&1 - sqrt(x) * cot(sqrt(x))) -\n sum(0,n) (\\m. (tannumber (2*m-1) /\n ((&2 pow (2*m) - &1) * &(FACT(2*m-1)))) *\n x pow m))\n <= &12 / &3 pow (2 * n) * inv(&2 pow (k DIV 2 * 2 * n))`;;" }, { "theorem_id": 24, "title": "014_euler_s_summation_of_1_+__1_2_^2_+__1_3_^2_+", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Bernoulli numbers and the zeta function at positive integers\\\ntheory Bernoulli_Zeta\nimports \n \"HOL-Complex_Analysis.Complex_Analysis\"\n Bernoulli_FPS\nbegin\n\nlemma joinpaths_cong: \"f = f' \\ g = g' \\ f +++ g = f' +++ g'\"\n by sorry\n\nlemma linepath_cong: \"a = a' \\ b = b' \\ linepath a b = linepath a' b'\"\n by sorry\n\ntext \\\n The analytic continuation of the exponential generating function of the Bernoulli numbers\n is $\\frac{z}{e^z - 1}$, which has simple poles at all $2ki\\pi$ for $k\\in\\mathbb{Z}\\setminus\\{0\\}$.\n We will need the residue at these poles:\n\\\nlemma residue_bernoulli:\n assumes \"n \\ 0\"\n shows \"residue (\\z. 1 / (z ^ m * (exp z - 1))) (2 * pi * real_of_int n * \\) = \n 1 / (2 * pi * real_of_int n * \\) ^ m\"\n by sorry\n\ntext \\\n At positive integers greater than 1, the Riemann zeta function is simply the infinite\n sum $\\zeta(n) = \\sum_{k=1}^\\infty k^{-n}$. For even $n$, this quantity can also be\n expressed in terms of Bernoulli numbers.\n\n To show this, we employ a similar strategy as in the meromorphic asymptotics approach:\n We apply the Residue Theorem to the exponential generating function of the Bernoulli numbers:\n \\[\\sum_{n=0}^\\infty \\frac{B_n}{n!} z^n = \\frac{z}{e^z - 1}\\]\n Recall that this function has poles at $2ki\\pi$ for $k\\in\\mathbb{Z}\\setminus\\{0\\}$.\n In the meromorphic asymptotics case, we integrated along a circle of radius $3i\\pi$ in order\n to get the dominant singularities $2i\\pi$ and $-2i\\pi$. Now, however, we will not use a \n fixed integration path, but we let the integration path become bigger and bigger. \n Because the integrand decays relatively quickly if $n > 1$, the integral vanishes in the limit \n and we obtain not just an asymptotic formula, but an exact representation of $B_n$ as an \n infinite sum.\n\n For odd $n$, we have $B_n = 0$, but for even $n$, the residues at $2ki\\pi$ and $-2ki\\pi$ \n combine nicely to $2\\cdot(-2k\\pi)^{-n}$, and after some simplification we get the formula\n for $B_n$.\n\n Another difference to the meromorphic asymptotics is that we now use a rectangle instead\n of a circle as the integration path. For the asymptotics, only a big-oh bound was needed\n for the integral over one fixed integration path, and the circular path was very convenient.\n However, now we need to explicitly bound the integral for a whole sequence of integration paths\n that grow in size, and bounding $e^z - 1$ for $z$ on a circle is very tedious. On a rectangle,\n this term can be bounded much more easily. Still, we have to do this separately for all four\n edges of the rectangle, which will be a bit tedious.\n\\\ntheorem nat_even_power_sums_complex:\n assumes n': \"n' > 0\"\n shows \"(\\k. 1 / of_nat (Suc k) ^ (2*n') :: complex) sums\n of_real ((-1) ^ Suc n' * bernoulli (2*n') * (2 * pi) ^ (2 * n') / (2 * fact (2*n')))\"\n by sorry\n\ncorollary nat_even_power_sums_real:\n assumes n': \"n' > 0\"\n shows \"(\\k. 1 / real (Suc k) ^ (2*n')) sums\n ((-1) ^ Suc n' * bernoulli (2*n') * (2 * pi) ^ (2 * n') / (2 * fact (2*n')))\"\n (is \"?f sums ?L\")\n by sorry\n\nlemma sgn_of_int: \"sgn (of_int n) = (of_int (sgn n) :: 'a :: linordered_idom)\"\n by sorry\n\ntext \\\n We can now also easily determine the signs of Bernoulli numbers: the above formula \n clearly shows that the signs of $B_{2n}$ alternate as $n$ increases, and we already know\n that $B_{2n+1} = 0$ for any positive $n$. A lot of other facts about the signs of\n Bernoulli numbers follow.\n\\\ncorollary sgn_bernoulli_num_even:\n assumes \"n > 0\"\n shows \"sgn (bernoulli_num (2 * n)) = (-1) ^ Suc n\"\n by sorry\n\nlemma sgn_bernoulli_even:\n assumes \"n > 0\"\n shows \"sgn (bernoulli (2 * n)) = ((-1) ^ Suc n :: 'a :: linordered_field)\"\n by sorry\n\ncorollary bernoulli_even_nonzero:\n assumes \"even n\"\n shows \"bernoulli n \\ (0 :: 'a :: field_char_0)\"\n by sorry\n\ncorollary sgn_bernoulli: \n \"sgn (bernoulli n :: 'a :: linordered_field) = \n (if n = 0 then 1 else if n = 1 then -1 else if odd n then 0 else (-1) ^ Suc (n div 2))\"\n by sorry\n\ncorollary bernoulli_zero_iff: \"bernoulli n = 0 \\ odd n \\ n \\ 1\"\n by sorry\n\ncorollary bernoulli'_zero_iff: \"(bernoulli' n = 0) \\ (n \\ 1 \\ odd n)\"\n by sorry\n\nlemma bernoulli_num_eq_0_iff: \"bernoulli_num n = 0 \\ odd n \\ n \\ 1\"\n by sorry\n\ncorollary bernoulli_pos_iff: \"bernoulli n > (0 :: 'a :: linordered_field) \\ n = 0 \\ n mod 4 = 2\"\n by sorry\n\ncorollary bernoulli_neg_iff: \"(bernoulli n :: 'a :: linordered_field) < 0 \\ n = 1 \\ n > 0 \\ 4 dvd n\"\n by sorry\n\ntext \\\n We also get the solution of the Basel problem (the sum over all squares of positive\n integers) and any `Basel-like' problem with even exponent. The case of odd exponents\n is much more complicated and no similarly nice closed form is known for these.\n\\\n\ncorollary nat_squares_sums: \"(\\n. 1 / (n+1) ^ 2) sums (pi ^ 2 / 6)\"\n by sorry\n\ncorollary nat_power4_sums: \"(\\n. 1 / (n+1) ^ 4) sums (pi ^ 4 / 90)\"\n by sorry\n\ncorollary nat_power6_sums: \"(\\n. 1 / (n+1) ^ 6) sums (pi ^ 6 / 945)\"\n by sorry\n\ncorollary nat_power8_sums: \"(\\n. 1 / (n+1) ^ 8) sums (pi ^ 8 / 9450)\"\n by sorry\n\nend" }, { "theorem_id": 24, "title": "014_euler_s_summation_of_1_+__1_2_^2_+__1_3_^2_+", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2022 David Loeffler. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Loeffler\n-/\nmodule\n\npublic import Mathlib.NumberTheory.BernoulliPolynomials\npublic import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic\npublic import Mathlib.Analysis.Calculus.ContDiff.Polynomial\npublic import Mathlib.Analysis.Calculus.Deriv.Polynomial\npublic import Mathlib.Analysis.Fourier.AddCircle\npublic import Mathlib.Analysis.PSeries\n\n/-!\n# Critical values of the Riemann zeta function\n\nIn this file we prove formulae for the critical values of `ζ(s)`, and more generally of Hurwitz\nzeta functions, in terms of Bernoulli polynomials.\n\n## Main results:\n\n* `hasSum_zeta_nat`: the final formula for zeta values,\n $$\\zeta(2k) = \\frac{(-1)^{(k + 1)} 2 ^ {2k - 1} \\pi^{2k} B_{2 k}}{(2 k)!}.$$\n* `hasSum_zeta_two` and `hasSum_zeta_four`: special cases given explicitly.\n* `hasSum_one_div_nat_pow_mul_cos`: a formula for the sum `∑ (n : ℕ), cos (2 π i n x) / n ^ k` as\n an explicit multiple of `Bₖ(x)`, for any `x ∈ [0, 1]` and `k ≥ 2` even.\n* `hasSum_one_div_nat_pow_mul_sin`: a formula for the sum `∑ (n : ℕ), sin (2 π i n x) / n ^ k` as\n an explicit multiple of `Bₖ(x)`, for any `x ∈ [0, 1]` and `k ≥ 3` odd.\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen scoped Nat Real Interval\n\nopen Complex MeasureTheory Set intervalIntegral\n\nlocal notation \"𝕌\" => UnitAddCircle\n\nsection BernoulliFunProps\n\n/-! Simple properties of the Bernoulli polynomial, as a function `ℝ → ℝ`. -/\n\n\n/-- The function `x ↦ Bₖ(x) : ℝ → ℝ`. -/\ndef bernoulliFun (k : ℕ) (x : ℝ) : ℝ :=\n (Polynomial.map (algebraMap ℚ ℝ) (Polynomial.bernoulli k)).eval x\n\nsection Evaluation\n\n@[simp]\ntheorem bernoulliFun_zero (x : ℝ) : bernoulliFun 0 x = 1 := by sorry\ntheorem bernoulliFun_one (x : ℝ) : bernoulliFun 1 x = x - 1 / 2 := by sorry\ntheorem bernoulliFun_two (x : ℝ) : bernoulliFun 2 x = x ^ 2 - x + 6⁻¹ := by sorry\ntheorem bernoulliFun_eval_zero (k : ℕ) : bernoulliFun k 0 = bernoulli k := by sorry\ntheorem bernoulliFun_endpoints_eq_of_ne_one {k : ℕ} (hk : k ≠ 1) :\n bernoulliFun k 1 = bernoulliFun k 0 := by sorry\ntheorem bernoulliFun_eval_one (k : ℕ) : bernoulliFun k 1 = bernoulliFun k 0 + ite (k = 1) 1 0 := by sorry\nend Evaluation\n\nsection Calculus\n\ntheorem hasDerivAt_bernoulliFun (k : ℕ) (x : ℝ) :\n HasDerivAt (bernoulliFun k) (k * bernoulliFun (k - 1) x) x := by sorry\nvariable (k : ℕ)\n\ntheorem contDiff_bernoulliFun : ContDiff ℝ ⊤ (bernoulliFun k) := by sorry\ntheorem continuous_bernoulliFun : Continuous (bernoulliFun k) := Polynomial.continuous_aeval _\n\ntheorem intervalIntegrable_bernoulliFun (a b : ℝ) :\n IntervalIntegrable (bernoulliFun k) volume a b :=\n (continuous_bernoulliFun k).intervalIntegrable a b\n\n@[simp]\ntheorem deriv_bernoulliFun :\n deriv (bernoulliFun k) = fun x ↦ k * bernoulliFun (k - 1) x := by sorry\ntheorem antideriv_bernoulliFun (k : ℕ) (x : ℝ) :\n HasDerivAt (fun x => bernoulliFun (k + 1) x / (k + 1)) (bernoulliFun k x) x := by sorry\ntheorem integral_bernoulliFun : ∫ x : ℝ in 0..1, bernoulliFun k x = if k = 0 then 1 else 0 := by sorry\nvariable {k} in\ntheorem integral_bernoulliFun_eq_zero (hk : k ≠ 0) :\n ∫ x : ℝ in 0..1, bernoulliFun k x = 0 := by sorry\ntheorem bernoulliFun_eq_integral (k : ℕ) (x y : ℝ) :\n bernoulliFun (k + 1) y =\n bernoulliFun (k + 1) x + ∫ t in x..y, (k + 1 : ℕ) * bernoulliFun k t := by sorry\nend Calculus\n\n/-- Reflection principle: `B_s(1 - x) = (-1)^s B_s(x)` -/\ntheorem bernoulliFun_eval_one_sub {k : ℕ} {x : ℝ} :\n bernoulliFun k (1 - x) = (-1) ^ k * bernoulliFun k x := by sorry\ntheorem bernoulliFun_mul (k : ℕ) {m : ℕ} (m0 : m ≠ 0) (x : ℝ) :\n bernoulliFun k (m * x) =\n m ^ k / m * ∑ i ∈ Finset.range m, bernoulliFun k (x + i / m) := by sorry\ntheorem bernoulliFun_eval_half_eq_zero (k : ℕ) : bernoulliFun (2 * k + 1) 2⁻¹ = 0 := by sorry\ntheorem bernoulliFun_eval_half (k : ℕ) : bernoulliFun k 2⁻¹ = (2 / 2 ^ k - 1) * bernoulli k := by sorry\nend BernoulliFunProps\n\nsection BernoulliFourierCoeffs\n\n/-! Compute the Fourier coefficients of the Bernoulli functions via integration by parts. -/\n\n\n/-- The `n`-th Fourier coefficient of the `k`-th Bernoulli function on the interval `[0, 1]`. -/\ndef bernoulliFourierCoeff (k : ℕ) (n : ℤ) : ℂ :=\n fourierCoeffOn zero_lt_one (fun x => bernoulliFun k x) n\n\n/-- Recurrence relation (in `k`) for the `n`-th Fourier coefficient of `Bₖ`. -/\ntheorem bernoulliFourierCoeff_recurrence (k : ℕ) {n : ℤ} (hn : n ≠ 0) :\n bernoulliFourierCoeff k n =\n 1 / (-2 * π * I * n) * (ite (k = 1) 1 0 - k * bernoulliFourierCoeff (k - 1) n) := by sorry\ntheorem bernoulli_zero_fourier_coeff {n : ℤ} (hn : n ≠ 0) : bernoulliFourierCoeff 0 n = 0 := by sorry\ntheorem bernoulliFourierCoeff_zero {k : ℕ} (hk : k ≠ 0) : bernoulliFourierCoeff k 0 = 0 := by sorry\ntheorem bernoulliFourierCoeff_eq {k : ℕ} (hk : k ≠ 0) (n : ℤ) :\n bernoulliFourierCoeff k n = -k ! / (2 * π * I * n) ^ k := by sorry\nend BernoulliFourierCoeffs\n\nsection BernoulliPeriodized\n\n/-! In this section we use the above evaluations of the Fourier coefficients of Bernoulli\npolynomials, together with the theorem `has_pointwise_sum_fourier_series_of_summable` from Fourier\ntheory, to obtain an explicit formula for `∑ (n:ℤ), 1 / n ^ k * fourier n x`. -/\n\n\n/-- The Bernoulli polynomial, extended from `[0, 1)` to the unit circle. -/\ndef periodizedBernoulli (k : ℕ) : 𝕌 → ℝ :=\n AddCircle.liftIco 1 0 (bernoulliFun k)\n\ntheorem periodizedBernoulli.continuous {k : ℕ} (hk : k ≠ 1) : Continuous (periodizedBernoulli k) :=\n AddCircle.liftIco_zero_continuous\n (mod_cast (bernoulliFun_endpoints_eq_of_ne_one hk).symm)\n (Polynomial.continuous _).continuousOn\n\ntheorem fourierCoeff_bernoulli_eq {k : ℕ} (hk : k ≠ 0) (n : ℤ) :\n fourierCoeff ((↑) ∘ periodizedBernoulli k : 𝕌 → ℂ) n = -k ! / (2 * π * I * n) ^ k := by sorry\ntheorem summable_bernoulli_fourier {k : ℕ} (hk : 2 ≤ k) :\n Summable (fun n => -k ! / (2 * π * I * n) ^ k : ℤ → ℂ) := by sorry\ntheorem hasSum_one_div_pow_mul_fourier_mul_bernoulliFun {k : ℕ} (hk : 2 ≤ k) {x : ℝ}\n (hx : x ∈ Icc (0 : ℝ) 1) :\n HasSum (fun n : ℤ => 1 / (n : ℂ) ^ k * fourier n (x : 𝕌))\n (-(2 * π * I) ^ k / k ! * bernoulliFun k x) := by sorry\nend BernoulliPeriodized\n\nsection Cleanup\n\n-- This section is just reformulating the results in a nicer form.\ntheorem hasSum_one_div_nat_pow_mul_fourier {k : ℕ} (hk : 2 ≤ k) {x : ℝ} (hx : x ∈ Icc (0 : ℝ) 1) :\n HasSum\n (fun n : ℕ =>\n (1 : ℂ) / (n : ℂ) ^ k * (fourier n (x : 𝕌) + (-1 : ℂ) ^ k * fourier (-n) (x : 𝕌)))\n (-(2 * π * I) ^ k / k ! * bernoulliFun k x) := by sorry\ntheorem hasSum_one_div_nat_pow_mul_cos {k : ℕ} (hk : k ≠ 0) {x : ℝ} (hx : x ∈ Icc (0 : ℝ) 1) :\n HasSum (fun n : ℕ => 1 / (n : ℝ) ^ (2 * k) * Real.cos (2 * π * n * x))\n ((-1 : ℝ) ^ (k + 1) * (2 * π) ^ (2 * k) / 2 / (2 * k)! *\n (Polynomial.map (algebraMap ℚ ℝ) (Polynomial.bernoulli (2 * k))).eval x) := by sorry\ntheorem hasSum_one_div_nat_pow_mul_sin {k : ℕ} (hk : k ≠ 0) {x : ℝ} (hx : x ∈ Icc (0 : ℝ) 1) :\n HasSum (fun n : ℕ => 1 / (n : ℝ) ^ (2 * k + 1) * Real.sin (2 * π * n * x))\n ((-1 : ℝ) ^ (k + 1) * (2 * π) ^ (2 * k + 1) / 2 / (2 * k + 1)! *\n (Polynomial.map (algebraMap ℚ ℝ) (Polynomial.bernoulli (2 * k + 1))).eval x) := by sorry\ntheorem hasSum_zeta_nat {k : ℕ} (hk : k ≠ 0) :\n HasSum (fun n : ℕ => 1 / (n : ℝ) ^ (2 * k))\n ((-1 : ℝ) ^ (k + 1) * (2 : ℝ) ^ (2 * k - 1) * π ^ (2 * k) *\n bernoulli (2 * k) / (2 * k)!) := by sorry\nend Cleanup\n\nsection Examples\n\ntheorem hasSum_zeta_two : HasSum (fun n : ℕ => (1 : ℝ) / (n : ℝ) ^ 2) (π ^ 2 / 6) := by sorry\ntheorem hasSum_zeta_four : HasSum (fun n : ℕ => (1 : ℝ) / (n : ℝ) ^ 4) (π ^ 4 / 90) := by sorry\ntheorem hasSum_L_function_mod_four_eval_three :\n HasSum (fun n : ℕ => (1 : ℝ) / (n : ℝ) ^ 3 * Real.sin (π * n / 2)) (π ^ 3 / 32) := by sorry\nend Examples\n" }, { "theorem_id": 24, "title": "014_euler_s_summation_of_1_+__1_2_^2_+__1_3_^2_+", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Lra.\nRequire Import Rsequence_facts.\nRequire Export Rseries.\nRequire Import Rsequence_subsequence.\nRequire Import Rtactic.\nRequire Import Lia.\n\nOpen Scope R_scope.\n\nLtac solve_with_eq a b := let H := fresh in \n assert (H : a = b); [ | rewrite H; try reflexivity].\n\nLtac inject := match goal with |- ?a = ?b => recinject (a = b) end\nwith recinject t := match t with\n | ?a = ?a => idtac\n | ?a ?b = ?a ?c => recinject (b = c)\n | ?b ?a = ?c ?a => recinject (b = c)\n | ?b = ?c => solve_with_eq b c\nend.\n\nLemma plus_1_S : forall a, INR (S a) = 1 + (INR a).\nProof.\nAdmitted.\n\nDefinition Rseq_square_inv n := / (INR n) ^ 2.\nDefinition Rseq_square_inv_s n := / (INR (S n)) ^ 2.\n\nDefinition odds Un : Rseq := fun n => Un (S (2 * n)).\nDefinition evens Un : Rseq := fun n => Un (mult 2 n).\n\nLemma Rser_cv_pair_compat : forall Un l, Rser_cv Un l -> Rser_cv (fun n => Un (mult 2 n) + Un (S (mult 2 n))) l.\nProof.\nAdmitted.\n\nLemma sum_odd_even_split : forall an n, sum_f_R0 (odds an) n =\n sum_f_R0 an (S (2 * n)) - sum_f_R0 (evens an) n.\nProof.\nAdmitted.\n\nLemma remove_odds : forall Un l, {lu | Rser_cv Un lu} ->\n Rser_cv (evens Un) l -> Rser_cv (Un - (odds Un)) l.\nProof.\nAdmitted.\n\nLemma remove_evens : forall Un l, {lu | Rser_cv Un lu} ->\n Rser_cv (odds Un) l -> Rser_cv (Un - evens Un) l.\nProof.\nAdmitted.\n\nDefinition antg : nat -> R := fun n => (- 1)^n / (2 * (INR n) + 1).\nDefinition antg_neg : nat -> R := fun n => (- 1)^n / (- 2 * (INR n) + 1).\n\nLemma PI_tg_PI : Rseq_cv (sum_f_R0 (tg_alt PI_tg)) (PI / 4).\nProof.\nAdmitted.\n\nLemma Sum_antg : Rser_cv antg (PI / 4).\nProof.\nAdmitted.\n\nLemma antg_shift_neg_compat : Rseq_shift antg_neg == antg.\nProof.\nAdmitted.\n\nLemma Sum_antg_neg : Rser_cv antg_neg (PI / 4 + 1).\nProof.\nAdmitted.\n\nDefinition bntg n := / (2 * (INR n) + 1) ^ 2.\nDefinition bntg_neg n := / (- 2 * (INR n) + 1) ^ 2.\n\nLemma bntg_pos : forall n, 0 < bntg n.\nProof.\nAdmitted.\n\nLemma odd_not_zero : forall n, 2 * (INR n) + 1 <> 0.\nProof.\nAdmitted.\n\nLemma neg_odd_not_zero : forall n, 2 * (INR n) - 1 <> 0.\nProof.\nAdmitted.\n\nLemma bntg_neg_simpl : forall n, \n 1 / (- 2 * (INR n) + 1) ^ 2 = 1 / (2 * (INR n) - 1) ^ 2.\nProof.\nAdmitted.\n\nDefinition pi_tg2 (n : nat) := 2 / ((4 * (INR n) + 1) * (4 * (INR n) + 3)).\n\nLemma pi_tg2_corresp : forall n, \n pi_tg2 n = tg_alt PI_tg (2 * n) + tg_alt PI_tg (S (2 * n)).\nProof.\nAdmitted.\n\nLemma pi_tg2_cv : { l | Rser_cv pi_tg2 l }.\nProof.\nAdmitted.\n\nLemma Rser_cv_bntg : {l | Rser_cv bntg l}.\nProof.\nAdmitted.\n\nRequire Import ZArith.\n\nFixpoint bisum (f : Z -> R) (N : nat) := match N with\n | O => f Z0\n | S n => (bisum f n) + f (Z_of_nat N) + f (- Z_of_nat N)%Z\nend.\n\nDefinition pow1_P p := match p with xO _ => 1 | _ => -1 end.\n\nDefinition pow1 z := match z with\n | Z0 => 1\n | Zpos n | Zneg n => pow1_P n\nend.\n\nLemma pow1_P_ind : forall p, pow1_P (Pos.\nProof.\nAdmitted.\n\nLemma nat_ind2 : forall (P : nat -> Prop), \n P O -> P (S O) -> (forall m, P m -> P (S (S m))) -> forall n, P n.\nProof.\nAdmitted.\n\nLemma pow1_nat : forall n, pow1 (Z_of_nat n) = (- 1) ^ n.\nProof.\nAdmitted.\n\nLemma pow1_nat_neg : forall n, pow1 (- Z_of_nat n) = (- 1) ^ n.\nProof.\nAdmitted.\n\nLemma pow1_squared : forall z, (pow1 z) ^ 2 = 1.\nProof.\nAdmitted.\n\nLemma pow1_Rabs : forall z, Rabs (pow1 z) = 1.\nProof.\nAdmitted.\n\nLemma pow1_P_plus : forall a b, pow1_P (a + b) = pow1_P a * pow1_P b.\nProof.\nAdmitted.\n\nLemma pow1_succ : forall z, pow1 (Z.\nProof.\nAdmitted.\n\nLemma pow1_plus_nat : forall a b, pow1 (a + Z_of_nat b) = (pow1 a) * (-1) ^ b.\nProof.\nAdmitted.\n\nDefinition zr (op : R -> R) (f : Z -> R) z := op (f z).\nDefinition zr2 (op : R -> R -> R) (f g : Z -> R) z := op (f z) (g z).\nDefinition zr22 (op : R -> R -> R) (f g : Z -> Z -> R) x y := op (f x y) (g x y).\n\nLemma bisum_eq_compat : forall f g n, (forall z, f z = g z) -> bisum f n = bisum g n.\nProof.\nAdmitted.\n\nLemma bisum_plus : forall f g n, bisum (zr2 Rplus f g) n = bisum f n + bisum g n.\nProof.\nAdmitted.\n\nLemma bisum_minus : forall f g n, bisum (zr2 Rminus f g) n = bisum f n - bisum g n.\nProof.\nAdmitted.\n\nLemma bisum_scal_mult : forall f a n, bisum (zr (Rmult a) f) n = a * (bisum f n).\nProof.\nAdmitted.\n\nLemma bisum_mult : forall f g n m, (bisum f n) * (bisum g m) = \n bisum (fun i => bisum (fun j => f i * g j) m) n.\nProof.\nAdmitted.\n\nLemma bisum_reverse : forall f n, bisum f n = bisum (fun i => f (- i)%Z) n.\nProof.\nAdmitted.\n\nLemma sum_bisum : forall n f, bisum f (S n) =\n sum_f_R0 (fun i => f (Z_of_nat i)) (S n) + sum_f_R0 (fun i => f (- Z_of_nat (S i))%Z) n.\nProof.\nAdmitted.\n\nDefinition anz z := (pow1 z) / (2 * (IZR z) + 1).\nDefinition bnz z := / (2 * (IZR z) + 1) ^ 2.\nDefinition An := bisum anz.\nDefinition Bn := bisum bnz.\n\nLemma anz_antg : forall n, antg n = anz (Z_of_nat n).\nProof.\nAdmitted.\n\nLemma anz_antg_neg : forall n, antg_neg n = anz (- Z_of_nat n).\nProof.\nAdmitted.\n\nLemma bisum_anz_antg : (sum_f_R0 antg + (sum_f_R0 antg_neg - 1))%Rseq == bisum anz.\nProof.\nAdmitted.\n\nLemma An_cv : Rseq_cv An (PI / 2).\nProof.\nAdmitted.\n\nLemma An_squared_cv : Rseq_cv (An * An) (PI ^ 2 / 4).\nProof.\nAdmitted.\n\nDefinition bisumsum f N := bisum (fun i => (bisum (f i) N)) N.\n\nDefinition bisum_strip f j N := bisum f N - (f j).\nDefinition bisumsum_strip_diag f N := bisumsum f N - bisum (fun i => (f i i)) N.\n\nDefinition bisum_strip' f j N := bisum (fun i => if Z.eq_dec i j then 0 else f i) N.\nDefinition bisumsum_strip_diag' f N := bisumsum (fun i j => if Z.eq_dec i j then 0 else f i j) N.\n\nLemma bisumsum_eq_compat : forall f g n, (forall x y, f x y = g x y) ->\n bisumsum f n = bisumsum g n.\nProof.\nAdmitted.\n\nLemma bisum_eq_compat_bounded : forall f g n, (forall z, ((-Z_of_nat n) <= z <= Z_of_nat n)%Z -> f z = g z) ->\n bisum f n = bisum g n.\nProof.\nAdmitted.\n\nLemma bisumsum_square : forall f n, bisumsum (fun i j => f i * f j) n = bisum f n * bisum f n.\nProof.\nAdmitted.\n\nLemma Psucc_lt : forall p, (Zpos p < Zpos (Pos.\nProof.\nAdmitted.\n\nLemma Psucc_lt_neg : forall p, (Zneg (Pos.\nProof.\nAdmitted.\n\nLemma bisum_not_in : forall f g j n, (j < (- Z_of_nat n) \\/ Z_of_nat n < j)%Z -> \n bisum (fun i : Z => if Z.\nProof.\nAdmitted.\n\nLemma bisum_in : forall f g j n, (- Z_of_nat n <= j <= Z_of_nat n)%Z -> \n bisum (fun i : Z => if Z.\nProof.\nAdmitted.\n\nDefinition Zzero : Z -> R := fun _ => 0.\n\nLemma bisum_strip_equiv : forall f n j, ((- Z_of_nat n) <= j <= Z_of_nat n)%Z -> \n bisum_strip f j n = bisum_strip' f j n.\nProof.\nAdmitted.\n\nLemma bisum_strip_nothing : forall f n j, ((- Z_of_nat (S n)) = j \\/ j = Z_of_nat (S n))%Z -> \n bisum_strip' f j n = bisum f n.\nProof.\nAdmitted.\n\nLemma bisum_one_step : forall f n, bisum f (S n) = bisum f n + f (Z_of_nat (S n)) + f (- Z_of_nat (S n))%Z.\nProof.\nAdmitted.\n\nLemma bisumsum_one_step : forall f n m, \n bisum (fun i => bisum (f i) (S n)) m =\n bisum (fun i => bisum (f i) n) m + \n bisum (fun i => f i (Z_of_nat (S n)) ) m +\n bisum (fun i => f i (- Z_of_nat (S n))%Z ) m.\nProof.\nAdmitted.\n\nLemma bisum_eq_sym : forall f z n,\n bisum (fun i : Z => if Z.\nProof.\nAdmitted.\n\nLemma strip_diag : forall f n, bisumsum_strip_diag' f n = bisumsum_strip_diag f n.\nProof.\nAdmitted.\n\nLemma bisumsum_switch_index : forall f n, bisumsum (fun i j => f j i) n = bisumsum f n.\nProof.\nAdmitted.\n\nLemma bisumsum_strip_diag'_switch_index : forall f n,\n bisumsum_strip_diag' (fun i j => f j i) n =\n bisumsum_strip_diag' f n.\nProof.\nAdmitted.\n\nLemma bisumsum_strip_diag'_plus : forall f g n,\n bisumsum_strip_diag' (fun i j => f i j + g i j) n =\n bisumsum_strip_diag' f n +\n bisumsum_strip_diag' g n.\nProof.\nAdmitted.\n\nLemma bisumsum_plus_switch : forall f g n,\n bisumsum_strip_diag' (fun i j => f i j + g i j) n =\n bisumsum_strip_diag' (fun i j => f i j + g j i) n.\nProof.\nAdmitted.\n\nLemma bisumsum_strip_diag'_eq_but_diag_compat : forall f g n,\n (forall i j, i <> j -> f i j = g i j) ->\n bisumsum_strip_diag' f n = bisumsum_strip_diag' g n.\nProof.\nAdmitted.\n\nFixpoint sum1 u n := match n with\n | O => 0\n | S n' => (sum1 u n') + u (Z_of_nat n)\nend.\n\nLemma sum_f_R0_sum1 : forall u n, sum1 u (S n) = \n sum_f_R0 (fun i => u (Z_of_nat (S i))) n.\nProof.\nAdmitted.\n\nDefinition shiftp (u:Z->R) (p:nat) (i:Z) := u (i + (Z_of_nat p))%Z.\n\nLemma bisum_shifting_S : forall u a b, \n bisum (shiftp u (S b)) (S a) = \n bisum (shiftp u b) a +\n u (Z_of_nat (S (a + b))) +\n u (Z_of_nat (S (S (a + b))))\n.\nProof.\nAdmitted.\n\nLemma bisum_shifting : forall u n p, \n bisum (shiftp u p) (n + p) = \n bisum u n + sum1 (shiftp u n) (2 * p)\n.\nProof.\nAdmitted.\n\nDefinition d x := 2 * x + 1.\nDefinition d' z := d (IZR z).\n\nLemma splitmn : forall n m, d n <> 0 -> d m <> 0 -> m <> n -> \n / ((d n) * (d m)) = / (2 * (m - n)) * (/ (d n) - / (d m)).\nProof.\nAdmitted.\n\nLemma d_not_null : forall z, d' z <> 0.\nProof.\nAdmitted.\n\nLemma calc1 : forall N, (An N) * (An N) - Bn N =\n bisumsum_strip_diag' (fun n m =>\n (pow1 m * pow1 n) * / (2 * (IZR (m - n))) * (/ (d' n) - / (d' m))\n ) N.\nProof.\nAdmitted.\n\nLemma calc2 : forall N, (An N) * (An N) - Bn N = bisumsum_strip_diag' (fun n m =>\n (pow1 m * pow1 n) * / ((IZR (m - n)) * (d' n))\n ) N.\nProof.\nAdmitted.\n\nDefinition cn n N := bisum (fun m => if Z.eq_dec n m then 0 else pow1 m / (IZR (m - n))) N.\n\nLemma calc3 : forall N, (An N) * (An N) - Bn N = bisum (fun n => pow1 n / (d' n) * (cn n N)) N.\nProof.\nAdmitted.\n\nLemma cn_odd : forall n N, cn (- n)%Z N = - (cn n N).\nProof.\nAdmitted.\n\nLemma cn_zero_zero : forall N, cn 0 N = 0.\nProof.\nAdmitted.\n\nLemma cn_pos : forall n N, (S n <= N)%nat ->\n cn (Zpos (P_of_succ_nat n)) N = \n (pow (-1) (S (S n))) * \n (sum_f_R0 (fun j => pow (-1) (j + N - n) * / (INR (j + N - n)))) (S (2 * n))\n.\nProof.\nAdmitted.\n\nLemma alt_bounding : \n forall u : nat -> R,\n Un_decreasing u ->\n (forall n, 0 <= u n) ->\n forall n, 0 <= sum_f_R0 (tg_alt u) n <= u O.\nProof.\nAdmitted.\n\nLemma cn_maj : forall n N, (n <= N)%nat -> Rabs (cn (Z_of_nat n) N) <= / (INR (N - n + 1)).\nProof.\nAdmitted.\n\nLemma abound_eq : forall n N, (O <= n)%nat -> (S n <= N)%nat ->\n / (INR (N - n)) * (/ (INR (2 * n + 1)) + / (INR (2 * n + 3))) =\n / (INR (2 * N + 1)) * (2 / (INR (2 * n + 1)) + / (INR (N - n))) +\n / (INR (2 * N + 3)) * (2 / (INR (2 * n + 3)) + / (INR (N - n))).\nProof.\nAdmitted.\n\nDefinition abound N := sum_f_R0 (fun n => / (INR (N - (S n) + 1)) * \n (/ (INR (2 * n + 1)) + / (INR (2 * n + 3)))\n ) (pred N).\n\nDefinition bound1 N := / (INR (2 * N + 1)) * \n sum_f_R0 (fun n => \n 2 / (INR (2 * n + 1)) + / (INR (N - (S n) + 1))\n ) (pred N).\n\nDefinition bound2 N := / (INR (2 * N + 3)) * \n sum_f_R0 (fun n => \n 2 / (INR (2 * n + 3)) + / (INR (N - (S n) + 1))\n ) (pred N).\n\nDefinition bound1' N := / INR (2 * N + 1) * sum_f_R0 (fun n => 2 / INR (2 * n + 1)) (pred N).\nDefinition bound2' N := / INR (2 * N + 3) * sum_f_R0 (fun n => 2 / INR (2 * n + 3)) (pred N).\nDefinition bound1c N := / INR (2 * N + 1) * sum_f_R0 (fun n => / INR (N - (S n) + 1)) (pred N).\nDefinition bound2c N := / INR (2 * N + 3) * sum_f_R0 (fun n => / INR (N - (S n) + 1)) (pred N).\n\nLemma An_squared_Bn_maj : forall N, (1 <= N)%nat -> Rabs (An N * An N - Bn N) <= abound N.\nProof.\nAdmitted.\n\nLemma bound_eq : forall N, abound (S N) = bound1 (S N) + bound2 (S N).\nProof.\nAdmitted.\n\nDefinition inverse_mean n := sum_f_R0 (fun i => / INR (S i)) n / INR (S n).\n\nLemma inverse_cv_0 : Rseq_cv (fun i => / INR (S i)) 0.\nProof.\nAdmitted.\n\nLemma inverse_mean_cv_0 : Rseq_cv inverse_mean 0.\nProof.\nAdmitted.\n\nLemma Rseq_cv_0_pos_maj_compat : forall Un Vn, (forall n, 0 <= Un n) -> (forall n, Un n <= Vn n) ->\n Rseq_cv Vn 0 -> Rseq_cv Un 0.\nProof.\nAdmitted.\n\nLemma half_mean_0 : forall Un k m, 0 <= k -> (1 <= m)%nat -> (forall n, 0 <= Un n) -> (forall n, Un n <= k / INR (S n)) ->\n Rseq_cv (fun N => / INR (2 * N + m) * sum_f_R0 Un (pred N)) 0.\nProof.\nAdmitted.\n\nLemma bound1'_cv : Rseq_cv bound1' 0.\nProof.\nAdmitted.\n\nLemma bound2'_cv : Rseq_cv bound2' 0.\nProof.\nAdmitted.\n\nLemma Rsum_switch_index : forall Un N, sum_f_R0 (fun n => Un (N - n)%nat) N = sum_f_R0 Un N.\nProof.\nAdmitted.\n\nLemma bound1c_cv : Rseq_cv bound1c 0.\nProof.\nAdmitted.\n\nLemma bound2c_cv : Rseq_cv bound2c 0.\nProof.\nAdmitted.\n\nLemma bound1_cv : Rseq_cv bound1 0.\nProof.\nAdmitted.\n\nLemma bound2_cv : Rseq_cv bound2 0.\nProof.\nAdmitted.\n\nLemma abound_cv : Rseq_cv abound 0.\nProof.\nAdmitted.\n\nLemma An_squared_Bn_cv : Rseq_cv (An * An - Bn) 0.\nProof.\nAdmitted.\n\nLemma Bn_cv : Rseq_cv Bn (PI ^ 2 / 4).\nProof.\nAdmitted.\n\nLemma bnz_bntg : forall n, bntg n = bnz (Z_of_nat n).\nProof.\nAdmitted.\n\nLemma bnz_bntg_neg : forall n, bntg_neg n = bnz (- Z_of_nat n).\nProof.\nAdmitted.\n\nLemma bisum_bnz_bntg : (sum_f_R0 bntg + (sum_f_R0 bntg_neg - 1))%Rseq == bisum bnz.\nProof.\nAdmitted.\n\nDefinition sumbntg := let (l, _) := Rser_cv_bntg in l.\n\nLemma Sum_bntg : Rser_cv bntg sumbntg.\nProof.\nAdmitted.\n\nLemma bntg_shift_neg_compat : Rseq_shift bntg_neg == bntg.\nProof.\nAdmitted.\n\nLemma Sum_bntg_neg : Rser_cv bntg_neg (sumbntg + 1).\nProof.\nAdmitted.\n\nLemma Sum_bnz : Rseq_cv Bn (2 * sumbntg).\nProof.\nAdmitted.\n\nLemma sumbntg_val : sumbntg = PI ^ 2 / 8.\nProof.\nAdmitted.\n\nLemma odd_zeta : Rser_cv bntg (PI ^ 2 / 8).\nProof.\nAdmitted.\n\nLemma odd_zeta_evens : Rser_cv (evens (Rseq_shift Rseq_square_inv)) (PI ^ 2 / 8).\nProof.\nAdmitted.\n\nDefinition zeta2 := let (l, _) := Rser_cv_square_inv in l.\n\nLemma zeta2_half : Rser_cv (odds (Rseq_shift (Rseq_square_inv))) (zeta2 / 4).\nProof.\nAdmitted.\n\nLemma zeta2_val : zeta2 = PI ^ 2 / 6.\nProof.\nAdmitted.\n\nCoercion INR : nat >-> R.\n\nTheorem zeta2_pi_2_6 : Rser_cv (fun n => 1 / (n + 1) ^ 2) (PI ^ 2 / 6).\nProof.\nAdmitted." }, { "theorem_id": 25, "title": "015_the_fundamental_theorem_of_integral_calculus", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/analysis.ml\";;\n\nlet POWDIFF_LEMMA = `!n x y. sum(0,SUC n)(\\p. (x pow p) * y pow ((SUC n) - p)) =\n y * sum(0,SUC n)(\\p. (x pow p) * (y pow (n - p)))`;;\n\nlet POWDIFF = `!n x y. (x pow (SUC n)) - (y pow (SUC n)) =\n (x - y) * sum(0,SUC n)(\\p. (x pow p) * (y pow (n - p)))`;;\n\nlet POWREV = `!n x y. sum(0,SUC n)(\\p. (x pow p) * (y pow (n - p))) =\n sum(0,SUC n)(\\p. (x pow (n - p)) * (y pow p))`;;\n\nlet POWSER_INSIDEA = `!f x z. summable (\\n. f(n) * (x pow n)) /\\ abs(z) < abs(x)\n ==> summable (\\n. abs(f(n)) * (z pow n))`;;\n\nlet POWSER_INSIDE = `!f x z. summable (\\n. f(n) * (x pow n)) /\\ abs(z) < abs(x)\n ==> summable (\\n. f(n) * (z pow n))`;;\n\nlet diffs = new_definition\n `diffs c = (\\n. &(SUC n) * c(SUC n))`;;\n\nlet DIFFS_NEG = `!c. diffs(\\n. --(c n)) = \\n. --((diffs c) n)`;;\n\nlet DIFFS_LEMMA = `!n c x. sum(0,n) (\\n. (diffs c)(n) * (x pow n)) =\n sum(0,n) (\\n. &n * c(n) * (x pow (n - 1))) +\n (&n * c(n) * x pow (n - 1))`;;\n\nlet DIFFS_LEMMA2 = `!n c x. sum(0,n) (\\n. &n * c(n) * (x pow (n - 1))) =\n sum(0,n) (\\n. (diffs c)(n) * (x pow n)) -\n (&n * c(n) * x pow (n - 1))`;;\n\nlet DIFFS_EQUIV = `!c x. summable(\\n. (diffs c)(n) * (x pow n)) ==>\n (\\n. &n * c(n) * (x pow (n - 1))) sums\n (suminf(\\n. (diffs c)(n) * (x pow n)))`;;\n\nlet TERMDIFF_LEMMA1 = `!m z h.\n sum(0,m)(\\p. (((z + h) pow (m - p)) * (z pow p)) - (z pow m)) =\n sum(0,m)(\\p. (z pow p) *\n (((z + h) pow (m - p)) - (z pow (m - p))))`;;\n\nlet TERMDIFF_LEMMA2 = `!z h. ~(h = &0) ==>\n (((((z + h) pow n) - (z pow n)) / h) - (&n * (z pow (n - 1))) =\n h * sum(0,n - 1)(\\p. (z pow p) *\n sum(0,(n - 1) - p)\n (\\q. ((z + h) pow q) *\n (z pow (((n - 2) - p) - q)))))`;;\n\nlet TERMDIFF_LEMMA3 = `!z h n K. ~(h = &0) /\\ abs(z) <= K /\\ abs(z + h) <= K ==>\n abs(((((z + h) pow n) - (z pow n)) / h) - (&n * (z pow (n - 1))))\n <= &n * &(n - 1) * (K pow (n - 2)) * abs(h)`;;\n\nlet TERMDIFF_LEMMA4 = `!f K k. &0 < k /\\\n (!h. &0 < abs(h) /\\ abs(h) < k ==> abs(f h) <= K * abs(h))\n ==> (f tends_real_real &0)(&0)`;;\n\nlet TERMDIFF_LEMMA5 = `!f g k. &0 < k /\\\n summable(f) /\\\n (!h. &0 < abs(h) /\\ abs(h) < k ==> !n. abs(g(h) n) <= (f(n) * abs(h)))\n ==> ((\\h. suminf(g h)) tends_real_real &0)(&0)`;;\n\nlet TERMDIFF = `!c K. summable(\\n. c(n) * (K pow n)) /\\\n summable(\\n. (diffs c)(n) * (K pow n)) /\\\n summable(\\n. (diffs(diffs c))(n) * (K pow n)) /\\\n abs(x) < abs(K)\n ==> ((\\x. suminf (\\n. c(n) * (x pow n))) diffl\n (suminf (\\n. (diffs c)(n) * (x pow n))))(x)`;;\n\nlet SEQ_NPOW = `!x. abs(x) < &1 ==> (\\n. &n * x pow n) tends_num_real &0`;;\n\nlet TERMDIFF_CONVERGES = `!K. (!x. abs(x) < K ==> summable(\\n. c(n) * x pow n))\n ==> !x. abs(x) < K ==> summable (\\n. diffs c n * x pow n)`;;\n\nlet TERMDIFF_STRONG = `!c K x.\n summable(\\n. c(n) * (K pow n)) /\\ abs(x) < abs(K)\n ==> ((\\x. suminf (\\n. c(n) * (x pow n))) diffl\n (suminf (\\n. (diffs c)(n) * (x pow n))))(x)`;;\n\nlet POWSER_0 = `!a. (\\n. a n * (&0) pow n) sums a(0)`;;\n\nlet POWSER_LIMIT_0 = `!f a s. &0 < s /\\\n (!x. abs(x) < s ==> (\\n. a n * x pow n) sums (f x))\n ==> (f tends_real_real a(0))(&0)`;;\n\nlet POWSER_LIMIT_0_STRONG = `!f a s.\n &0 < s /\\\n (!x. &0 < abs(x) /\\ abs(x) < s ==> (\\n. a n * x pow n) sums (f x))\n ==> (f tends_real_real a(0))(&0)`;;\n\nlet POWSER_EQUAL_0 = `!f a b P.\n (!e. &0 < e ==> ?x. P x /\\ &0 < abs x /\\ abs(x) < e) /\\\n (!x. &0 < abs(x) /\\ P x\n ==> (\\n. a n * x pow n) sums (f x) /\\\n (\\n. b n * x pow n) sums (f x))\n ==> (a(0) = b(0))`;;\n\nlet POWSER_EQUAL = `!f a b P.\n (!e. &0 < e ==> ?x. P x /\\ &0 < abs x /\\ abs(x) < e) /\\\n (!x. P x ==> (\\n. a n * x pow n) sums (f x) /\\\n (\\n. b n * x pow n) sums (f x))\n ==> (a = b)`;;\n\nprioritize_num();;\n\nset_basic_rewrites (subtract' equals_thm (basic_rewrites())\n [SPEC_ALL BETA_THM]);;\n\nlet MULT_DIV_2 = `!n. (2 * n) DIV 2 = n`;;\n\nlet EVEN_DIV2 = `!n. ~(EVEN n) ==> ((SUC n) DIV 2 = SUC((n - 1) DIV 2))`;;\n\nprioritize_real();;\n\nlet POW_ZERO = `!n x. (x pow n = &0) ==> (x = &0)`;;\n\nlet POW_ZERO_EQ = `!n x. (x pow (SUC n) = &0) <=> (x = &0)`;;\n\nlet POW_LT = `!n x y. &0 <= x /\\ x < y ==> (x pow (SUC n)) < (y pow (SUC n))`;;\n\nlet POW_EQ = `!n x y. &0 <= x /\\ &0 <= y /\\ (x pow (SUC n) = y pow (SUC n))\n ==> (x = y)`;;\n\nlet diff_net = ref empty_net;;\n\nlet add_to_diff_net th =\n let t = lhand(rator(rand(concl th))) in\n let net = !diff_net in\n let net' = enter [] (t,PART_MATCH (lhand o rator o rand) th) net in\n diff_net := net';;\n\nlet exp = new_definition\n `exp(x) = suminf(\\n. ((\\n. inv(&(FACT n)))) n * (x pow n))`;;\n\nlet sin = new_definition\n `sin(x) = suminf(\\n. ((\\n. if EVEN n then &0 else\n ((--(&1)) pow ((n - 1) DIV 2)) / &(FACT n))) n * (x pow n))`;;\n\nlet cos = new_definition\n `cos(x) = suminf(\\n. ((\\n. if EVEN n then ((--(&1)) pow (n DIV 2)) / &(FACT n)\n else &0)) n * (x pow n))`;;\n\nlet REAL_EXP_CONVERGES = `!x. (\\n. ((\\n. inv(&(FACT n)))) n * (x pow n)) sums exp(x)`;;\n\nlet SIN_CONVERGES = `!x. (\\n. ((\\n. if EVEN n then &0 else\n ((--(&1)) pow ((n - 1) DIV 2)) / &(FACT n))) n * (x pow n)) sums\n sin(x)`;;\n\nlet COS_CONVERGES = `!x. (\\n. ((\\n. if EVEN n then ((--(&1)) pow (n DIV 2)) / &(FACT n) else &0)) n\n * (x pow n)) sums cos(x)`;;\n\nlet REAL_EXP_FDIFF = `diffs (\\n. inv(&(FACT n))) = (\\n. inv(&(FACT n)))`;;\n\nlet SIN_FDIFF = `diffs (\\n. if EVEN n then &0 else ((--(&1)) pow ((n - 1) DIV 2)) / &(FACT n))\n = (\\n. if EVEN n then ((--(&1)) pow (n DIV 2)) / &(FACT n) else &0)`;;\n\nlet COS_FDIFF = `diffs (\\n. if EVEN n then ((--(&1)) pow (n DIV 2)) / &(FACT n) else &0) =\n (\\n. --(((\\n. if EVEN n then &0 else ((--(&1)) pow ((n - 1) DIV 2)) /\n &(FACT n))) n))`;;\n\nlet SIN_NEGLEMMA = `!x. --(sin x) = suminf (\\n. --(((\\n. if EVEN n then &0 else ((--(&1))\n pow ((n - 1) DIV 2)) / &(FACT n))) n * (x pow n)))`;;\n\nlet DIFF_EXP = `!x. (exp diffl exp(x))(x)`;;\n\nlet DIFF_SIN = `!x. (sin diffl cos(x))(x)`;;\n\nlet DIFF_COS = `!x. (cos diffl --(sin(x)))(x)`;;\n\nlet DIFF_CONV =\n let lookup_expr tm =\n tryfind (fun f -> f tm) (lookup tm (!diff_net)) in\n let v = `x:real` and k = `k:real` and diffl_tm = `(diffl)` in\n let DIFF_var = SPEC v DIFF_X\n and DIFF_const = SPECL [k;v] DIFF_CONST in\n let uneta_CONV = REWR_CONV (GSYM ETA_AX) in\n let rec DIFF_CONV tm =\n if not (is_abs tm) then\n let th0 = uneta_CONV tm in\n let th1 = DIFF_CONV (rand(concl th0)) in\n CONV_RULE (RATOR_CONV(LAND_CONV(K(SYM th0)))) th1 else\n let x,bod = dest_abs tm in\n if bod = x then INST [x,v] DIFF_var\n else if not(free_in x bod) then INST [bod,k; x,v] DIFF_const else\n let th = lookup_expr tm in\n let hyp = fst(dest_imp(concl th)) in\n let hyps = conjuncts hyp in\n let dhyps,sides = partition\n (fun t -> try funpow 3 rator t = diffl_tm\n with Failure _ -> false) hyps in\n let tha = CONJ_ACI_RULE(mk_eq(hyp,list_mk_conj(dhyps@sides))) in\n let thb = CONV_RULE (LAND_CONV (K tha)) th in\n let dths = map (DIFF_CONV o lhand o rator) dhyps in\n MATCH_MP thb (end_itlist CONJ (dths @ map ASSUME sides)) in\n fun tm ->\n let xv = try bndvar tm with Failure _ -> v in\n GEN xv (DISCH_ALL(DIFF_CONV tm));;\n\nlet DIFF_COMPOSITE = `((f diffl l)(x) /\\ ~(f(x) = &0) ==>\n ((\\x. inv(f x)) diffl --(l / (f(x) pow 2)))(x)) /\\\n ((f diffl l)(x) /\\ (g diffl m)(x) /\\ ~(g(x) = &0) ==>\n ((\\x. f(x) / g(x)) diffl (((l * g(x)) - (m * f(x))) / (g(x) pow 2)))(x)) /\\\n ((f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) + g(x)) diffl (l + m))(x)) /\\\n ((f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) * g(x)) diffl ((l * g(x)) + (m * f(x))))(x)) /\\\n ((f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) - g(x)) diffl (l - m))(x)) /\\\n ((f diffl l)(x) ==> ((\\x. --(f x)) diffl --l)(x)) /\\\n ((g diffl m)(x) ==>\n ((\\x. (g x) pow n) diffl ((&n * (g x) pow (n - 1)) * m))(x)) /\\\n ((g diffl m)(x) ==> ((\\x. exp(g x)) diffl (exp(g x) * m))(x)) /\\\n ((g diffl m)(x) ==> ((\\x. sin(g x)) diffl (cos(g x) * m))(x)) /\\\n ((g diffl m)(x) ==> ((\\x. cos(g x)) diffl (--(sin(g x)) * m))(x))`;;\n\ndo_list add_to_diff_net (CONJUNCTS DIFF_COMPOSITE);;\n\nlet DIFF_TAC =\n W(fun (asl,w) -> MP_TAC(SPEC(rand w) (DIFF_CONV(lhand(rator w)))) THEN\n MATCH_MP_TAC EQ_IMP THEN AP_THM_TAC THEN AP_TERM_TAC);;\n\nlet DIFFERENTIABLE_RULE =\n let pth = `(f diffl l) x ==> f differentiable x`;;\n\nlet DIFFERENTIABLE_CONV = EQT_INTRO o DIFFERENTIABLE_RULE;;\n\nlet CONTINUOUS_RULE =\n let pth = `!f x. f differentiable x ==> f contl x`;;\n\nlet CONTINUOUS_CONV = EQT_INTRO o CONTINUOUS_RULE;;\n\nlet REAL_EXP_0 = `exp(&0) = &1`;;\n\nlet REAL_EXP_LE_X = `!x. &0 <= x ==> (&1 + x) <= exp(x)`;;\n\nlet REAL_EXP_LT_1 = `!x. &0 < x ==> &1 < exp(x)`;;\n\nlet REAL_EXP_ADD_MUL = `!x y. exp(x + y) * exp(--x) = exp(y)`;;\n\nlet REAL_EXP_NEG_MUL = `!x. exp(x) * exp(--x) = &1`;;\n\nlet REAL_EXP_NEG_MUL2 = `!x. exp(--x) * exp(x) = &1`;;\n\nlet REAL_EXP_NEG = `!x. exp(--x) = inv(exp(x))`;;\n\nlet REAL_EXP_ADD = `!x y. exp(x + y) = exp(x) * exp(y)`;;\n\nlet REAL_EXP_POS_LE = `!x. &0 <= exp(x)`;;\n\nlet REAL_EXP_NZ = `!x. ~(exp(x) = &0)`;;\n\nlet REAL_EXP_POS_LT = `!x. &0 < exp(x)`;;\n\nlet REAL_EXP_N = `!n x. exp(&n * x) = exp(x) pow n`;;\n\nlet REAL_EXP_SUB = `!x y. exp(x - y) = exp(x) / exp(y)`;;\n\nlet REAL_EXP_MONO_IMP = `!x y. x < y ==> exp(x) < exp(y)`;;\n\nlet REAL_EXP_MONO_LT = `!x y. exp(x) < exp(y) <=> x < y`;;\n\nlet REAL_EXP_MONO_LE = `!x y. exp(x) <= exp(y) <=> x <= y`;;\n\nlet REAL_EXP_INJ = `!x y. (exp(x) = exp(y)) <=> (x = y)`;;\n\nlet REAL_EXP_TOTAL_LEMMA = `!y. &1 <= y ==> ?x. &0 <= x /\\ x <= y - &1 /\\ (exp(x) = y)`;;\n\nlet REAL_EXP_TOTAL = `!y. &0 < y ==> ?x. exp(x) = y`;;\n\nlet REAL_EXP_BOUND_LEMMA = `!x. &0 <= x /\\ x <= inv(&2) ==> exp(x) <= &1 + &2 * x`;;\n\nlet ln = new_definition\n `ln x = @u. exp(u) = x`;;\n\nlet LN_EXP = `!x. ln(exp x) = x`;;\n\nlet REAL_EXP_LN = `!x. (exp(ln x) = x) <=> &0 < x`;;\n\nlet EXP_LN = `!x. &0 < x ==> exp(ln x) = x`;;\n\nlet LN_MUL = `!x y. &0 < x /\\ &0 < y ==> (ln(x * y) = ln(x) + ln(y))`;;\n\nlet LN_INJ = `!x y. &0 < x /\\ &0 < y ==> ((ln(x) = ln(y)) <=> (x = y))`;;\n\nlet LN_1 = `ln(&1) = &0`;;\n\nlet LN_INV = `!x. &0 < x ==> (ln(inv x) = --(ln x))`;;\n\nlet LN_DIV = `!x. &0 < x /\\ &0 < y ==> (ln(x / y) = ln(x) - ln(y))`;;\n\nlet LN_MONO_LT = `!x y. &0 < x /\\ &0 < y ==> (ln(x) < ln(y) <=> x < y)`;;\n\nlet LN_MONO_LE = `!x y. &0 < x /\\ &0 < y ==> (ln(x) <= ln(y) <=> x <= y)`;;\n\nlet LN_POW = `!n x. &0 < x ==> (ln(x pow n) = &n * ln(x))`;;\n\nlet LN_LE = `!x. &0 <= x ==> ln(&1 + x) <= x`;;\n\nlet LN_LT_X = `!x. &0 < x ==> ln(x) < x`;;\n\nlet LN_POS = `!x. &1 <= x ==> &0 <= ln(x)`;;\n\nlet LN_POS_LT = `!x. &1 < x ==> &0 < ln(x)`;;\n\nlet DIFF_LN = `!x. &0 < x ==> (ln diffl (inv x))(x)`;;\n\nlet root = new_definition\n `root(n) x = @u. (&0 < x ==> &0 < u) /\\ (u pow n = x)`;;\n\nlet ROOT_LT_LEMMA = `!n x. &0 < x ==> (exp(ln(x) / &(SUC n)) pow (SUC n) = x)`;;\n\nlet ROOT_LN = `!x. &0 < x ==> !n. root(SUC n) x = exp(ln(x) / &(SUC n))`;;\n\nlet ROOT_0 = `!n. root(SUC n) (&0) = &0`;;\n\nlet ROOT_1 = `!n. root(SUC n) (&1) = &1`;;\n\nlet ROOT_POW_POS = `!n x. &0 <= x ==> ((root(SUC n) x) pow (SUC n) = x)`;;\n\nlet POW_ROOT_POS = `!n x. &0 <= x ==> (root(SUC n)(x pow (SUC n)) = x)`;;\n\nlet ROOT_POS_POSITIVE = `!x n. &0 <= x ==> &0 <= root(SUC n) x`;;\n\nlet ROOT_POS_UNIQ = `!n x y. &0 <= x /\\ &0 <= y /\\ (y pow (SUC n) = x)\n ==> (root (SUC n) x = y)`;;\n\nlet ROOT_MUL = `!n x y. &0 <= x /\\ &0 <= y\n ==> (root(SUC n) (x * y) = root(SUC n) x * root(SUC n) y)`;;\n\nlet ROOT_INV = `!n x. &0 <= x ==> (root(SUC n) (inv x) = inv(root(SUC n) x))`;;\n\nlet ROOT_DIV = `!n x y. &0 <= x /\\ &0 <= y\n ==> (root(SUC n) (x / y) = root(SUC n) x / root(SUC n) y)`;;\n\nlet ROOT_MONO_LT = `!x y. &0 <= x /\\ x < y ==> root(SUC n) x < root(SUC n) y`;;\n\nlet ROOT_MONO_LE = `!x y. &0 <= x /\\ x <= y ==> root(SUC n) x <= root(SUC n) y`;;\n\nlet ROOT_MONO_LT_EQ = `!x y. &0 <= x /\\ &0 <= y ==> (root(SUC n) x < root(SUC n) y <=> x < y)`;;\n\nlet ROOT_MONO_LE_EQ = `!x y. &0 <= x /\\ &0 <= y ==> (root(SUC n) x <= root(SUC n) y <=> x <= y)`;;\n\nlet ROOT_INJ = `!x y. &0 <= x /\\ &0 <= y ==> ((root(SUC n) x = root(SUC n) y) <=> (x = y))`;;\n\nlet SQRT_EVEN_POW2 = `!n. EVEN n ==> (sqrt(&2 pow n) = &2 pow (n DIV 2))`;;\n\nlet REAL_DIV_SQRT = `!x. &0 <= x ==> x / sqrt(x) = sqrt(x)`;;\n\nlet DIFF_SQRT = `!x. &0 < x ==> (sqrt diffl inv(&2 * sqrt(x))) x`;;\n\nlet DIFF_SQRT_COMPOSITE = `!g m x. (g diffl m)(x) /\\ &0 < g x\n ==> ((\\x. sqrt(g x)) diffl (inv(&2 * sqrt(g x)) * m))(x)`;;\n\nlet SIN_0 = `sin(&0) = &0`;;\n\nlet COS_0 = `cos(&0) = &1`;;\n\nlet SIN_CIRCLE = `!x. (sin(x) pow 2) + (cos(x) pow 2) = &1`;;\n\nlet SIN_BOUND = `!x. abs(sin x) <= &1`;;\n\nlet SIN_BOUNDS = `!x. --(&1) <= sin(x) /\\ sin(x) <= &1`;;\n\nlet COS_BOUND = `!x. abs(cos x) <= &1`;;\n\nlet COS_BOUNDS = `!x. --(&1) <= cos(x) /\\ cos(x) <= &1`;;\n\nlet SIN_COS_ADD = `!x y. ((sin(x + y) - ((sin(x) * cos(y)) + (cos(x) * sin(y)))) pow 2) +\n ((cos(x + y) - ((cos(x) * cos(y)) - (sin(x) * sin(y)))) pow 2) = &0`;;\n\nlet SIN_COS_NEG = `!x. ((sin(--x) + (sin x)) pow 2) +\n ((cos(--x) - (cos x)) pow 2) = &0`;;\n\nlet SIN_ADD = `!x y. sin(x + y) = (sin(x) * cos(y)) + (cos(x) * sin(y))`;;\n\nlet COS_ADD = `!x y. cos(x + y) = (cos(x) * cos(y)) - (sin(x) * sin(y))`;;\n\nlet SIN_NEG = `!x. sin(--x) = --(sin(x))`;;\n\nlet COS_NEG = `!x. cos(--x) = cos(x)`;;\n\nlet SIN_DOUBLE = `!x. sin(&2 * x) = &2 * sin(x) * cos(x)`;;\n\nlet COS_DOUBLE = `!x. cos(&2 * x) = (cos(x) pow 2) - (sin(x) pow 2)`;;\n\nlet COS_ABS = `!x. cos(abs x) = cos(x)`;;\n\nlet SIN_PAIRED = `!x. (\\n. (((--(&1)) pow n) / &(FACT((2 * n) + 1)))\n * (x pow ((2 * n) + 1))) sums (sin x)`;;\n\nlet SIN_POS = `!x. &0 < x /\\ x < &2 ==> &0 < sin(x)`;;\n\nlet COS_PAIRED = `!x. (\\n. (((--(&1)) pow n) / &(FACT(2 * n)))\n * (x pow (2 * n))) sums (cos x)`;;\n\nlet COS_2 = `cos(&2) < &0`;;\n\nlet COS_ISZERO = `?!x. &0 <= x /\\ x <= &2 /\\ (cos x = &0)`;;\n\nlet pi = new_definition\n `pi = &2 * @x. &0 <= x /\\ x <= &2 /\\ (cos x = &0)`;;\n\nlet PI2 = `pi / &2 = @x. &0 <= x /\\ x <= &2 /\\ (cos(x) = &0)`;;\n\nlet COS_PI2 = `cos(pi / &2) = &0`;;\n\nlet PI2_BOUNDS = `&0 < (pi / &2) /\\ (pi / &2) < &2`;;\n\nlet PI_POS = `&0 < pi`;;\n\nlet SIN_PI2 = `sin(pi / &2) = &1`;;\n\nlet COS_PI = `cos(pi) = --(&1)`;;\n\nlet SIN_PI = `sin(pi) = &0`;;\n\nlet SIN_COS = `!x. sin(x) = cos((pi / &2) - x)`;;\n\nlet COS_SIN = `!x. cos(x) = sin((pi / &2) - x)`;;\n\nlet SIN_PERIODIC_PI = `!x. sin(x + pi) = --(sin(x))`;;\n\nlet COS_PERIODIC_PI = `!x. cos(x + pi) = --(cos(x))`;;\n\nlet SIN_PERIODIC = `!x. sin(x + (&2 * pi)) = sin(x)`;;\n\nlet COS_PERIODIC = `!x. cos(x + (&2 * pi)) = cos(x)`;;\n\nlet COS_NPI = `!n. cos(&n * pi) = --(&1) pow n`;;\n\nlet SIN_NPI = `!n. sin(&n * pi) = &0`;;\n\nlet SIN_POS_PI2 = `!x. &0 < x /\\ x < pi / &2 ==> &0 < sin(x)`;;\n\nlet COS_POS_PI2 = `!x. &0 < x /\\ x < pi / &2 ==> &0 < cos(x)`;;\n\nlet COS_POS_PI = `!x. --(pi / &2) < x /\\ x < pi / &2 ==> &0 < cos(x)`;;\n\nlet SIN_POS_PI = `!x. &0 < x /\\ x < pi ==> &0 < sin(x)`;;\n\nlet SIN_POS_PI_LE = `!x. &0 <= x /\\ x <= pi ==> &0 <= sin(x)`;;\n\nlet COS_TOTAL = `!y. --(&1) <= y /\\ y <= &1 ==> ?!x. &0 <= x /\\ x <= pi /\\ (cos(x) = y)`;;\n\nlet SIN_TOTAL = `!y. --(&1) <= y /\\ y <= &1 ==>\n ?!x. --(pi / &2) <= x /\\ x <= pi / &2 /\\ (sin(x) = y)`;;\n\nlet COS_ZERO_LEMMA = `!x. &0 <= x /\\ (cos(x) = &0) ==>\n ?n. ~EVEN n /\\ (x = &n * (pi / &2))`;;\n\nlet SIN_ZERO_LEMMA = `!x. &0 <= x /\\ (sin(x) = &0) ==>\n ?n. EVEN n /\\ (x = &n * (pi / &2))`;;\n\nlet COS_ZERO = `!x. (cos(x) = &0) <=> (?n. ~EVEN n /\\ (x = &n * (pi / &2))) \\/\n (?n. ~EVEN n /\\ (x = --(&n * (pi / &2))))`;;\n\nlet SIN_ZERO = `!x. (sin(x) = &0) <=> (?n. EVEN n /\\ (x = &n * (pi / &2))) \\/\n (?n. EVEN n /\\ (x = --(&n * (pi / &2))))`;;\n\nlet SIN_ZERO_PI = `!x. (sin(x) = &0) <=> (?n. x = &n * pi) \\/ (?n. x = --(&n * pi))`;;\n\nlet COS_ONE_2PI = `!x. (cos(x) = &1) <=> (?n. x = &n * &2 * pi) \\/ (?n. x = --(&n * &2 * pi))`;;\n\nlet tan = new_definition\n `tan(x) = sin(x) / cos(x)`;;\n\nlet TAN_0 = `tan(&0) = &0`;;\n\nlet TAN_PI = `tan(pi) = &0`;;\n\nlet TAN_NPI = `!n. tan(&n * pi) = &0`;;\n\nlet TAN_NEG = `!x. tan(--x) = --(tan x)`;;\n\nlet TAN_PERIODIC = `!x. tan(x + &2 * pi) = tan(x)`;;\n\nlet TAN_PERIODIC_PI = `!x. tan(x + pi) = tan(x)`;;\n\nlet TAN_PERIODIC_NPI = `!x n. tan(x + &n * pi) = tan(x)`;;\n\nlet TAN_ADD = `!x y. ~(cos(x) = &0) /\\ ~(cos(y) = &0) /\\ ~(cos(x + y) = &0) ==>\n (tan(x + y) = (tan(x) + tan(y)) / (&1 - tan(x) * tan(y)))`;;\n\nlet TAN_DOUBLE = `!x. ~(cos(x) = &0) /\\ ~(cos(&2 * x) = &0) ==>\n (tan(&2 * x) = (&2 * tan(x)) / (&1 - (tan(x) pow 2)))`;;\n\nlet TAN_POS_PI2 = `!x. &0 < x /\\ x < pi / &2 ==> &0 < tan(x)`;;\n\nlet DIFF_TAN = `!x. ~(cos(x) = &0) ==> (tan diffl inv(cos(x) pow 2))(x)`;;\n\nlet DIFF_TAN_COMPOSITE = `(g diffl m)(x) /\\ ~(cos(g x) = &0)\n ==> ((\\x. tan(g x)) diffl (inv(cos(g x) pow 2) * m))(x)`;;\n\nlet TAN_TOTAL_POS = `!y. &0 <= y ==> ?x. &0 <= x /\\ x < pi / &2 /\\ (tan(x) = y)`;;\n\nlet TAN_TOTAL = `!y. ?!x. --(pi / &2) < x /\\ x < (pi / &2) /\\ (tan(x) = y)`;;\n\nlet PI2_PI4 = `pi / &2 = &2 * pi / &4`;;\n\nlet TAN_PI4 = `tan(pi / &4) = &1`;;\n\nlet TAN_COT = `!x. tan(pi / &2 - x) = inv(tan x)`;;\n\nlet TAN_BOUND_PI2 = `!x. abs(x) < pi / &4 ==> abs(tan x) < &1`;;\n\nlet TAN_ABS_GE_X = `!x. abs(x) < pi / &2 ==> abs(x) <= abs(tan x)`;;\n\nlet asn = new_definition\n `asn(y) = @x. --(pi / &2) <= x /\\ x <= pi / &2 /\\ (sin x = y)`;;\n\nlet acs = new_definition\n `acs(y) = @x. &0 <= x /\\ x <= pi /\\ (cos x = y)`;;\n\nlet atn = new_definition\n `atn(y) = @x. --(pi / &2) < x /\\ x < pi / &2 /\\ (tan x = y)`;;\n\nlet ASN = `!y. --(&1) <= y /\\ y <= &1 ==>\n --(pi / &2) <= asn(y) /\\ asn(y) <= pi / &2 /\\ (sin(asn y) = y)`;;\n\nlet ASN_SIN = `!y. --(&1) <= y /\\ y <= &1 ==> (sin(asn(y)) = y)`;;\n\nlet ASN_BOUNDS = `!y. --(&1) <= y /\\ y <= &1 ==> --(pi / &2) <= asn(y) /\\ asn(y) <= pi / &2`;;\n\nlet ASN_BOUNDS_LT = `!y. --(&1) < y /\\ y < &1 ==> --(pi / &2) < asn(y) /\\ asn(y) < pi / &2`;;\n\nlet SIN_ASN = `!x. --(pi / &2) <= x /\\ x <= pi / &2 ==> (asn(sin(x)) = x)`;;\n\nlet ACS = `!y. --(&1) <= y /\\ y <= &1 ==>\n &0 <= acs(y) /\\ acs(y) <= pi /\\ (cos(acs y) = y)`;;\n\nlet ACS_COS = `!y. --(&1) <= y /\\ y <= &1 ==> (cos(acs(y)) = y)`;;\n\nlet ACS_BOUNDS = `!y. --(&1) <= y /\\ y <= &1 ==> &0 <= acs(y) /\\ acs(y) <= pi`;;\n\nlet ACS_BOUNDS_LT = `!y. --(&1) < y /\\ y < &1 ==> &0 < acs(y) /\\ acs(y) < pi`;;\n\nlet COS_ACS = `!x. &0 <= x /\\ x <= pi ==> (acs(cos(x)) = x)`;;\n\nlet ATN = `!y. --(pi / &2) < atn(y) /\\ atn(y) < (pi / &2) /\\ (tan(atn y) = y)`;;\n\nlet ATN_TAN = `!y. tan(atn y) = y`;;\n\nlet ATN_BOUNDS = `!y. --(pi / &2) < atn(y) /\\ atn(y) < (pi / &2)`;;\n\nlet TAN_ATN = `!x. --(pi / &2) < x /\\ x < (pi / &2) ==> (atn(tan(x)) = x)`;;\n\nlet ATN_0 = `atn(&0) = &0`;;\n\nlet ATN_1 = `atn(&1) = pi / &4`;;\n\nlet ATN_NEG = `!x. atn(--x) = --(atn x)`;;\n\nlet COS_ATN_NZ = `!x. ~(cos(atn(x)) = &0)`;;\n\nlet TAN_SEC = `!x. ~(cos(x) = &0) ==> (&1 + (tan(x) pow 2) = inv(cos x) pow 2)`;;\n\nlet DIFF_ATN = `!x. (atn diffl (inv(&1 + (x pow 2))))(x)`;;\n\nlet DIFF_ATN_COMPOSITE = `(g diffl m)(x) ==> ((\\x. atn(g x)) diffl (inv(&1 + (g x) pow 2) * m))(x)`;;\n\nlet ATN_MONO_LT_EQ = `!x y. atn(x) < atn(y) <=> x < y`;;\n\nlet ATN_MONO_LE_EQ = `!x y. atn(x) <= atn(y) <=> x <= y`;;\n\nlet ATN_INJ = `!x y. (atn x = atn y) <=> (x = y)`;;\n\nlet ATN_POS_LT = `&0 < atn(x) <=> &0 < x`;;\n\nlet ATN_POS_LE = `&0 <= atn(x) <=> &0 <= x`;;\n\nlet ATN_LT_PI4_POS = `!x. x < &1 ==> atn(x) < pi / &4`;;\n\nlet ATN_LT_PI4_NEG = `!x. --(&1) < x ==> --(pi / &4) < atn(x)`;;\n\nlet ATN_LT_PI4 = `!x. abs(x) < &1 ==> abs(atn x) < pi / &4`;;\n\nlet ATN_LE_PI4 = `!x. abs(x) <= &1 ==> abs(atn x) <= pi / &4`;;\n\nlet COS_SIN_SQRT = `!x. &0 <= cos(x) ==> (cos(x) = sqrt(&1 - (sin(x) pow 2)))`;;\n\nlet COS_ASN_NZ = `!x. --(&1) < x /\\ x < &1 ==> ~(cos(asn(x)) = &0)`;;\n\nlet DIFF_ASN_COS = `!x. --(&1) < x /\\ x < &1 ==> (asn diffl (inv(cos(asn x))))(x)`;;\n\nlet DIFF_ASN = `!x. --(&1) < x /\\ x < &1 ==> (asn diffl (inv(sqrt(&1 - (x pow 2)))))(x)`;;\n\nlet DIFF_ASN_COMPOSITE = `(g diffl m)(x) /\\ -- &1 < g(x) /\\ g(x) < &1\n ==> ((\\x. asn(g x)) diffl (inv(sqrt (&1 - g(x) pow 2)) * m))(x)`;;\n\nlet SIN_ACS_NZ = `!x. --(&1) < x /\\ x < &1 ==> ~(sin(acs(x)) = &0)`;;\n\nlet DIFF_ACS_SIN = `!x. --(&1) < x /\\ x < &1 ==> (acs diffl (inv(--(sin(acs x)))))(x)`;;\n\nlet DIFF_ACS = `!x. --(&1) < x /\\ x < &1 ==> (acs diffl --(inv(sqrt(&1 - (x pow 2)))))(x)`;;\n\nlet DIFF_ACS_COMPOSITE = `(g diffl m)(x) /\\ -- &1 < g(x) /\\ g(x) < &1\n ==> ((\\x. acs(g x)) diffl (--inv(sqrt(&1 - g(x) pow 2)) * m))(x)`;;\n\nlet ACS_MONO_LT = `!x y. --(&1) < x /\\ x < y /\\ y < &1 ==> acs(y) < acs(x)`;;\n\nlet LE_MATCH_TAC th (asl,w) =\n let thi = PART_MATCH (rand o rator) th (rand(rator w)) in\n let tm = rand(concl thi) in\n (MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC tm THEN CONJ_TAC THENL\n [MATCH_ACCEPT_TAC th; ALL_TAC]) (asl,w);;\n\nlet LESS_SUC_EQ = `!m n. m < SUC n <=> m <= n`;;\n\nlet LESS_1 = `!n. n < 1 <=> (n = 0)`;;\n\nlet division = new_definition\n `division(a,b) D <=>\n (D 0 = a) /\\\n (?N. (!n. n < N ==> D(n) < D(SUC n)) /\\\n (!n. n >= N ==> (D(n) = b)))`;;\n\nlet dsize = new_definition\n `dsize D =\n @N. (!n. n < N ==> D(n) < D(SUC n)) /\\\n (!n. n >= N ==> (D(n) = D(N)))`;;\n\nlet tdiv = new_definition\n `tdiv(a,b) (D,p) <=>\n division(a,b) D /\\\n (!n. D(n) <= p(n) /\\ p(n) <= D(SUC n))`;;\n\nlet gauge = new_definition\n `gauge(E) (g:real->real) <=> !x. E x ==> &0 < g(x)`;;\n\nlet fine = new_definition\n `fine(g:real->real) (D,p) <=>\n !n. n < (dsize D) ==> (D(SUC n) - D(n)) < g(p(n))`;;\n\nlet rsum = new_definition\n `rsum (D,(p:num->real)) f =\n sum(0,dsize(D))(\\n. f(p n) * (D(SUC n) - D(n)))`;;\n\nlet defint = new_definition\n `defint(a,b) f k <=>\n !e. &0 < e ==>\n ?g. gauge(\\x. a <= x /\\ x <= b) g /\\\n !D p. tdiv(a,b) (D,p) /\\ fine(g)(D,p) ==>\n abs(rsum(D,p) f - k) < e`;;\n\nlet DIVISION_0 = `!a b. (a = b) ==> (dsize(\\n. if (n = 0) then a else b) = 0)`;;\n\nlet DIVISION_1 = `!a b. a < b ==> (dsize(\\n. if (n = 0) then a else b) = 1)`;;\n\nlet DIVISION_SINGLE = `!a b. a <= b ==> division(a,b)(\\n. if (n = 0) then a else b)`;;\n\nlet DIVISION_LHS = `!D a b. division(a,b) D ==> (D(0) = a)`;;\n\nlet DIVISION_THM = `!D a b. division(a,b) D <=>\n (D(0) = a) /\\\n (!n. n < (dsize D) ==> D(n) < D(SUC n)) /\\\n (!n. n >= (dsize D) ==> (D(n) = b))`;;\n\nlet DIVISION_RHS = `!D a b. division(a,b) D ==> (D(dsize D) = b)`;;\n\nlet DIVISION_LT_GEN = `!D a b m n. division(a,b) D /\\\n m < n /\\\n n <= (dsize D) ==> D(m) < D(n)`;;\n\nlet DIVISION_LT = `!D a b. division(a,b) D ==> !n. n < (dsize D) ==> D(0) < D(SUC n)`;;\n\nlet DIVISION_LE = `!D a b. division(a,b) D ==> a <= b`;;\n\nlet DIVISION_GT = `!D a b. division(a,b) D ==> !n. n < (dsize D) ==> D(n) < D(dsize D)`;;\n\nlet DIVISION_EQ = `!D a b. division(a,b) D ==> ((a = b) <=> (dsize D = 0))`;;\n\nlet DIVISION_LBOUND = `!D a b r. division(a,b) D ==> a <= D(r)`;;\n\nlet DIVISION_LBOUND_LT = `!D a b n. division(a,b) D /\\ ~(dsize D = 0) ==> a < D(SUC n)`;;\n\nlet DIVISION_UBOUND = `!D a b r. division(a,b) D ==> D(r) <= b`;;\n\nlet DIVISION_UBOUND_LT = `!D a b n. division(a,b) D /\\\n n < dsize D ==> D(n) < b`;;\n\nlet DIVISION_APPEND_LEMMA1 = `!a b c D1 D2. division(a,b) D1 /\\ division(b,c) D2 ==>\n (!n. n < ((dsize D1) + (dsize D2)) ==>\n (\\n. if (n < (dsize D1)) then D1(n) else\n D2(n - (dsize D1)))(n) <\n (\\n. if (n < (dsize D1)) then D1(n) else D2(n - (dsize D1)))(SUC n)) /\\\n (!n. n >= ((dsize D1) + (dsize D2)) ==>\n ((\\n. if (n < (dsize D1)) then D1(n) else\n D2(n - (dsize D1)))(n) = (\\n. if (n < (dsize D1)) then D1(n) else\n D2(n - (dsize D1)))((dsize D1) + (dsize D2))))`;;\n\nlet DIVISION_APPEND_LEMMA2 = `!a b c D1 D2. division(a,b) D1 /\\ division(b,c) D2 ==>\n (dsize(\\n. if (n < (dsize D1)) then D1(n) else\n D2(n - (dsize D1))) = dsize(D1) + dsize(D2))`;;\n\nlet DIVISION_APPEND_EXPLICIT = `!a b c g d1 p1 d2 p2.\n tdiv(a,b) (d1,p1) /\\\n fine g (d1,p1) /\\\n tdiv(b,c) (d2,p2) /\\\n fine g (d2,p2)\n ==> tdiv(a,c)\n ((\\n. if n < dsize d1 then d1(n) else d2(n - (dsize d1))),\n (\\n. if n < dsize d1\n then p1(n) else p2(n - (dsize d1)))) /\\\n fine g ((\\n. if n < dsize d1 then d1(n) else d2(n - (dsize d1))),\n (\\n. if n < dsize d1\n then p1(n) else p2(n - (dsize d1)))) /\\\n !f. rsum((\\n. if n < dsize d1 then d1(n) else d2(n - (dsize d1))),\n (\\n. if n < dsize d1\n then p1(n) else p2(n - (dsize d1)))) f =\n rsum(d1,p1) f + rsum(d2,p2) f`;;\n\nlet DIVISION_APPEND_STRONG = `!a b c D1 p1 D2 p2.\n tdiv(a,b) (D1,p1) /\\ fine(g) (D1,p1) /\\\n tdiv(b,c) (D2,p2) /\\ fine(g) (D2,p2)\n ==> ?D p. tdiv(a,c) (D,p) /\\ fine(g) (D,p) /\\\n !f. rsum(D,p) f = rsum(D1,p1) f + rsum(D2,p2) f`;;\n\nlet DIVISION_APPEND = `!a b c.\n (?D1 p1. tdiv(a,b) (D1,p1) /\\ fine(g) (D1,p1)) /\\\n (?D2 p2. tdiv(b,c) (D2,p2) /\\ fine(g) (D2,p2)) ==>\n ?D p. tdiv(a,c) (D,p) /\\ fine(g) (D,p)`;;\n\nlet DIVISION_EXISTS = `!a b g. a <= b /\\ gauge(\\x. a <= x /\\ x <= b) g ==>\n ?D p. tdiv(a,b) (D,p) /\\ fine(g) (D,p)`;;\n\nlet GAUGE_MIN = `!E g1 g2. gauge(E) g1 /\\ gauge(E) g2 ==>\n gauge(E) (\\x. if g1(x) < g2(x) then g1(x) else g2(x))`;;\n\nlet FINE_MIN = `!g1 g2 D p. fine (\\x. if g1(x) < g2(x) then g1(x) else g2(x)) (D,p) ==>\n fine(g1) (D,p) /\\ fine(g2) (D,p)`;;\n\nlet DINT_UNIQ = `!a b f k1 k2. a <= b /\\ defint(a,b) f k1 /\\ defint(a,b) f k2 ==> (k1 = k2)`;;\n\nlet INTEGRAL_NULL = `!f a. defint(a,a) f (&0)`;;\n\nlet STRADDLE_LEMMA = `!f f' a b e. (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\ &0 < e\n ==> ?g. gauge(\\x. a <= x /\\ x <= b) g /\\\n !x u v. a <= u /\\ u <= x /\\ x <= v /\\ v <= b /\\ (v - u) < g(x)\n ==> abs((f(v) - f(u)) - (f'(x) * (v - u))) <= e * (v - u)`;;\n\nlet FTC1 = `!f f' a b. a <= b /\\ (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x))\n ==> defint(a,b) f' (f(b) - f(a))`;;\n\nlet integrable = new_definition\n `integrable(a,b) f = ?i. defint(a,b) f i`;;\n\nlet integral = new_definition\n `integral(a,b) f = @i. defint(a,b) f i`;;\n\nlet INTEGRABLE_DEFINT = `!f a b. integrable(a,b) f ==> defint(a,b) f (integral(a,b) f)`;;\n\nlet DIVISION_BOUNDS = `!d a b. division(a,b) d ==> !n. a <= d(n) /\\ d(n) <= b`;;\n\nlet TDIV_BOUNDS = `!d p a b. tdiv(a,b) (d,p)\n ==> !n. a <= d(n) /\\ d(n) <= b /\\ a <= p(n) /\\ p(n) <= b`;;\n\nlet TDIV_LE = `!d p a b. tdiv(a,b) (d,p) ==> a <= b`;;\n\nlet DEFINT_WRONG = `!a b f i. b < a ==> defint(a,b) f i`;;\n\nlet DEFINT_INTEGRAL = `!f a b i. a <= b /\\ defint(a,b) f i ==> integral(a,b) f = i`;;\n\nlet DEFINT_CONST = `!a b c. defint(a,b) (\\x. c) (c * (b - a))`;;\n\nlet DEFINT_0 = `!a b. defint(a,b) (\\x. &0) (&0)`;;\n\nlet DEFINT_NEG = `!f a b i. defint(a,b) f i ==> defint(a,b) (\\x. --f x) (--i)`;;\n\nlet DEFINT_CMUL = `!f a b c i. defint(a,b) f i ==> defint(a,b) (\\x. c * f x) (c * i)`;;\n\nlet DEFINT_ADD = `!f g a b i j.\n defint(a,b) f i /\\ defint(a,b) g j\n ==> defint(a,b) (\\x. f x + g x) (i + j)`;;\n\nlet DEFINT_SUB = `!f g a b i j.\n defint(a,b) f i /\\ defint(a,b) g j\n ==> defint(a,b) (\\x. f x - g x) (i - j)`;;\n\nlet INTEGRAL_LE = `!f g a b i j.\n a <= b /\\ integrable(a,b) f /\\ integrable(a,b) g /\\\n (!x. a <= x /\\ x <= b ==> f(x) <= g(x))\n ==> integral(a,b) f <= integral(a,b) g`;;\n\nlet DEFINT_LE = `!f g a b i j. a <= b /\\ defint(a,b) f i /\\ defint(a,b) g j /\\\n (!x. a <= x /\\ x <= b ==> f(x) <= g(x))\n ==> i <= j`;;\n\nlet DEFINT_TRIANGLE = `!f a b i j. a <= b /\\ defint(a,b) f i /\\ defint(a,b) (\\x. abs(f x)) j\n ==> abs(i) <= j`;;\n\nlet DEFINT_EQ = `!f g a b i j. a <= b /\\ defint(a,b) f i /\\ defint(a,b) g j /\\\n (!x. a <= x /\\ x <= b ==> f(x) = g(x))\n ==> i = j`;;\n\nlet INTEGRAL_EQ = `!f g a b i. defint(a,b) f i /\\\n (!x. a <= x /\\ x <= b ==> f(x) = g(x))\n ==> defint(a,b) g i`;;\n\nlet INTEGRATION_BY_PARTS = `!f g f' g' a b.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n (!x. a <= x /\\ x <= b ==> (g diffl g'(x))(x))\n ==> defint(a,b) (\\x. f'(x) * g(x) + f(x) * g'(x))\n (f(b) * g(b) - f(a) * g(a))`;;\n\nlet DIVISION_LE_SUC = `!d a b. division(a,b) d ==> !n. d(n) <= d(SUC n)`;;\n\nlet DIVISION_MONO_LE = `!d a b. division(a,b) d ==> !m n. m <= n ==> d(m) <= d(n)`;;\n\nlet DIVISION_MONO_LE_SUC = `!d a b. division(a,b) d ==> !n. d(n) <= d(SUC n)`;;\n\nlet DIVISION_INTERMEDIATE = `!d a b c. division(a,b) d /\\ a <= c /\\ c <= b\n ==> ?n. n <= dsize d /\\ d(n) <= c /\\ c <= d(SUC n)`;;\n\nlet DIVISION_DSIZE_LE = `!a b d n. division(a,b) d /\\ d(SUC n) = d(n) ==> dsize d <= n`;;\n\nlet DIVISION_DSIZE_GE = `!a b d n. division(a,b) d /\\ d(n) < d(SUC n) ==> SUC n <= dsize d`;;\n\nlet DIVISION_DSIZE_EQ = `!a b d n. division(a,b) d /\\ d(n) < d(SUC n) /\\ d(SUC(SUC n)) = d(SUC n)\n ==> dsize d = SUC n`;;\n\nlet DIVISION_DSIZE_EQ_ALT = `!a b d n. division(a,b) d /\\ d(SUC n) = d(n) /\\\n (!i. i < n ==> d(i) < d(SUC i))\n ==> dsize d = n`;;\n\nlet DEFINT_COMBINE = `!f a b c i j. a <= b /\\ b <= c /\\ defint(a,b) f i /\\ defint(b,c) f j\n ==> defint(a,c) f (i + j)`;;\n\nlet DEFINT_DELTA_LEFT = `!a b. defint(a,b) (\\x. if x = a then &1 else &0) (&0)`;;\n\nlet DEFINT_DELTA_RIGHT = `!a b. defint(a,b) (\\x. if x = b then &1 else &0) (&0)`;;\n\nlet DEFINT_DELTA = `!a b c. defint(a,b) (\\x. if x = c then &1 else &0) (&0)`;;\n\nlet DEFINT_POINT_SPIKE = `!f g a b c i.\n (!x. a <= x /\\ x <= b /\\ ~(x = c) ==> (f x = g x)) /\\ defint(a,b) f i\n ==> defint(a,b) g i`;;\n\nlet DEFINT_FINITE_SPIKE = `!f g a b s i.\n FINITE s /\\\n (!x. a <= x /\\ x <= b /\\ ~(x IN s) ==> (f x = g x)) /\\\n defint(a,b) f i\n ==> defint(a,b) g i`;;\n\nlet GAUGE_MIN_FINITE = `!s gs n. (!m:num. m <= n ==> gauge s (gs m))\n ==> ?g. gauge s g /\\\n !d p. fine g (d,p) ==> !m. m <= n ==> fine (gs m) (d,p)`;;\n\nlet INTEGRABLE_CAUCHY = `!f a b. integrable(a,b) f <=>\n !e. &0 < e\n ==> ?g. gauge (\\x. a <= x /\\ x <= b) g /\\\n !d1 p1 d2 p2.\n tdiv (a,b) (d1,p1) /\\ fine g (d1,p1) /\\\n tdiv (a,b) (d2,p2) /\\ fine g (d2,p2)\n ==> abs (rsum(d1,p1) f - rsum(d2,p2) f) < e`;;\n\nlet SUM_DIFFS = `!m n. sum(m,n) (\\i. d(SUC i) - d(i)) = d(m + n) - d m`;;\n\nlet RSUM_BOUND = `!a b d p e f.\n tdiv(a,b) (d,p) /\\\n (!x. a <= x /\\ x <= b ==> abs(f x) <= e)\n ==> abs(rsum(d,p) f) <= e * (b - a)`;;\n\nlet RSUM_DIFF_BOUND = `!a b d p e f g.\n tdiv(a,b) (d,p) /\\\n (!x. a <= x /\\ x <= b ==> abs(f x - g x) <= e)\n ==> abs(rsum (d,p) f - rsum (d,p) g) <= e * (b - a)`;;\n\nlet INTEGRABLE_LIMIT = `!f a b. (!e. &0 < e\n ==> ?g. (!x. a <= x /\\ x <= b ==> abs(f x - g x) <= e) /\\\n integrable(a,b) g)\n ==> integrable(a,b) f`;;\n\nlet INTEGRABLE_CONST = `!a b c. integrable(a,b) (\\x. c)`;;\n\nlet INTEGRABLE_COMBINE = `!f a b c. a <= b /\\ b <= c /\\ integrable(a,b) f /\\ integrable(b,c) f\n ==> integrable(a,c) f`;;\n\nlet INTEGRABLE_POINT_SPIKE = `!f g a b c.\n (!x. a <= x /\\ x <= b /\\ ~(x = c) ==> f x = g x) /\\ integrable(a,b) f\n ==> integrable(a,b) g`;;\n\nlet INTEGRABLE_CONTINUOUS = `!f a b. (!x. a <= x /\\ x <= b ==> f contl x) ==> integrable(a,b) f`;;\n\nlet INTEGRABLE_SPLIT_SIDES = `!f a b c.\n a <= c /\\ c <= b /\\ integrable(a,b) f\n ==> ?i. !e. &0 < e\n ==> ?g. gauge(\\x. a <= x /\\ x <= b) g /\\\n !d1 p1 d2 p2. tdiv(a,c) (d1,p1) /\\\n fine g (d1,p1) /\\\n tdiv(c,b) (d2,p2) /\\\n fine g (d2,p2)\n ==> abs((rsum(d1,p1) f +\n rsum(d2,p2) f) - i) < e`;;\n\nlet INTEGRABLE_SUBINTERVAL_LEFT = `!f a b c. a <= c /\\ c <= b /\\ integrable(a,b) f ==> integrable(a,c) f`;;\n\nlet INTEGRABLE_SUBINTERVAL_RIGHT = `!f a b c. a <= c /\\ c <= b /\\ integrable(a,b) f ==> integrable(c,b) f`;;\n\nlet INTEGRABLE_SUBINTERVAL = `!f a b c d. a <= c /\\ c <= d /\\ d <= b /\\ integrable(a,b) f\n ==> integrable(c,d) f`;;\n\nlet INTEGRABLE_RULE =\n let pth = `(!x. f contl x) ==> integrable(a,b) f`;;\n\nlet INTEGRAL_CMUL = `!f c a b. a <= b /\\ integrable(a,b) f\n ==> integral(a,b) (\\x. c * f(x)) = c * integral(a,b) f`;;\n\nlet INTEGRAL_ADD = `!f g a b. a <= b /\\ integrable(a,b) f /\\ integrable(a,b) g\n ==> integral(a,b) (\\x. f(x) + g(x)) =\n integral(a,b) f + integral(a,b) g`;;\n\nlet INTEGRAL_SUB = `!f g a b. a <= b /\\ integrable(a,b) f /\\ integrable(a,b) g\n ==> integral(a,b) (\\x. f(x) - g(x)) =\n integral(a,b) f - integral(a,b) g`;;\n\nlet INTEGRAL_BY_PARTS = `!f g f' g' a b.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f' x) x) /\\\n (!x. a <= x /\\ x <= b ==> (g diffl g' x) x) /\\\n integrable(a,b) (\\x. f' x * g x) /\\\n integrable(a,b) (\\x. f x * g' x)\n ==> integral(a,b) (\\x. f x * g' x) =\n (f b * g b - f a * g a) - integral(a,b) (\\x. f' x * g x)`;;\n\nlet SYM_CANON_CONV sym fn =\n REWR_CONV sym o check\n (not o fn o ((snd o dest_comb) F_F I) o dest_comb);;\n\nlet EXT_CONV = SYM o uncurry X_FUN_EQ_CONV o\n (I F_F (mk_eq o (rator F_F rator) o dest_eq)) o dest_forall;;\n\nlet MCLAURIN = `!f diff h n.\n &0 < h /\\\n 0 < n /\\\n (diff(0) = f) /\\\n (!m t. m < n /\\ &0 <= t /\\ t <= h ==>\n (diff(m) diffl diff(SUC m)(t))(t)) ==>\n (?t. &0 < t /\\ t < h /\\\n (f(h) = sum(0,n)(\\m. (diff(m)(&0) / &(FACT m)) * (h pow m)) +\n ((diff(n)(t) / &(FACT n)) * (h pow n))))`;;\n\nlet MCLAURIN_NEG = `!f diff h n.\n h < &0 /\\\n 0 < n /\\\n (diff(0) = f) /\\\n (!m t. m < n /\\ h <= t /\\ t <= &0 ==>\n (diff(m) diffl diff(SUC m)(t))(t)) ==>\n (?t. h < t /\\ t < &0 /\\\n (f(h) = sum(0,n)(\\m. (diff(m)(&0) / &(FACT m)) * (h pow m)) +\n ((diff(n)(t) / &(FACT n)) * (h pow n))))`;;\n\nlet MCLAURIN_BI_LE = `!f diff x n.\n (diff 0 = f) /\\\n (!m t. m < n /\\ abs(t) <= abs(x) ==> (diff m diffl diff (SUC m) t) t)\n ==> ?t. abs(t) <= abs(x) /\\\n (f x = sum (0,n) (\\m. diff m (&0) / &(FACT m) * x pow m) +\n diff n t / &(FACT n) * x pow n)`;;\n\nlet MCLAURIN_ALL_LT = `!f diff.\n (diff 0 = f) /\\\n (!m x. ((diff m) diffl (diff(SUC m) x)) x)\n ==> !x n. ~(x = &0) /\\ 0 < n\n ==> ?t. &0 < abs(t) /\\ abs(t) < abs(x) /\\\n (f(x) = sum(0,n)(\\m. (diff m (&0) / &(FACT m)) * x pow m) +\n (diff n t / &(FACT n)) * x pow n)`;;\n\nlet MCLAURIN_ZERO = `!diff n x. (x = &0) /\\ 0 < n ==>\n (sum(0,n)(\\m. (diff m (&0) / &(FACT m)) * x pow m) = diff 0 (&0))`;;\n\nlet MCLAURIN_ALL_LE = `!f diff.\n (diff 0 = f) /\\\n (!m x. ((diff m) diffl (diff(SUC m) x)) x)\n ==> !x n. ?t. abs(t) <= abs(x) /\\\n (f(x) = sum(0,n)(\\m. (diff m (&0) / &(FACT m)) * x pow m) +\n (diff n t / &(FACT n)) * x pow n)`;;\n\nlet MCLAURIN_EXP_LEMMA = `((\\n:num. exp) 0 = exp) /\\\n (!m x. (((\\n:num. exp) m) diffl ((\\n:num. exp) (SUC m) x)) x)`;;\n\nlet MCLAURIN_EXP_LT = `!x n. ~(x = &0) /\\ 0 < n\n ==> ?t. &0 < abs(t) /\\\n abs(t) < abs(x) /\\\n (exp(x) = sum(0,n)(\\m. x pow m / &(FACT m)) +\n (exp(t) / &(FACT n)) * x pow n)`;;\n\nlet MCLAURIN_EXP_LE = `!x n. ?t. abs(t) <= abs(x) /\\\n (exp(x) = sum(0,n)(\\m. x pow m / &(FACT m)) +\n (exp(t) / &(FACT n)) * x pow n)`;;\n\nlet DIFF_LN_COMPOSITE = `!g m x. (g diffl m)(x) /\\ &0 < g x\n ==> ((\\x. ln(g x)) diffl (inv(g x) * m))(x)`;;\n\nlet MCLAURIN_LN_POS = `!x n.\n &0 < x /\\ 0 < n\n ==> ?t. &0 < t /\\\n t < x /\\\n (ln(&1 + x) = sum(0,n)\n (\\m. --(&1) pow (SUC m) * (x pow m) / &m) +\n --(&1) pow (SUC n) * x pow n / (&n * (&1 + t) pow n))`;;\n\nlet MCLAURIN_LN_NEG = `!x n. &0 < x /\\ x < &1 /\\ 0 < n\n ==> ?t. &0 < t /\\\n t < x /\\\n (--(ln(&1 - x)) = sum(0,n) (\\m. (x pow m) / &m) +\n x pow n / (&n * (&1 - t) pow n))`;;\n\nlet MCLAURIN_SIN = `!x n. abs(sin x -\n sum(0,n) (\\m. (if EVEN m then &0\n else -- &1 pow ((m - 1) DIV 2) / &(FACT m)) *\n x pow m))\n <= inv(&(FACT n)) * abs(x) pow n`;;\n\nlet MCLAURIN_COS = `!x n. abs(cos x -\n sum(0,n) (\\m. (if EVEN m\n then -- &1 pow (m DIV 2) / &(FACT m)\n else &0) * x pow m))\n <= inv(&(FACT n)) * abs(x) pow n`;;\n\nlet REAL_ATN_POWSER_SUMMABLE = `!x. abs(x) < &1\n ==> summable (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n) * x pow n)`;;\n\nlet REAL_ATN_POWSER_DIFFS_SUMMABLE = `!x. abs(x) < &1\n ==> summable (\\n. diffs (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n)) n *\n x pow n)`;;\n\nlet REAL_ATN_POWSER_DIFFS_SUM = `!x. abs(x) < &1\n ==> (\\n. diffs (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n)) n * x pow n)\n sums (inv(&1 + x pow 2))`;;\n\nlet REAL_ATN_POWSER_DIFFS_DIFFS_SUMMABLE = `!x. abs(x) < &1\n ==> summable\n (\\n. diffs (diffs\n (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n))) n * x pow n)`;;\n\nlet REAL_ATN_POWSER_DIFFL = `!x. abs(x) < &1\n ==> ((\\x. suminf (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n) * x pow n))\n diffl (inv(&1 + x pow 2))) x`;;\n\nlet REAL_ATN_POWSER = `!x. abs(x) < &1\n ==> (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n) * x pow n)\n sums (atn x)`;;\n\nlet MCLAURIN_ATN = `!x n. abs(x) < &1\n ==> abs(atn x -\n sum(0,n) (\\m. (if EVEN m then &0\n else --(&1) pow ((m - 1) DIV 2) / &m) *\n x pow m))\n <= abs(x) pow n / (&1 - abs x)`;;" }, { "theorem_id": 25, "title": "015_the_fundamental_theorem_of_integral_calculus", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Henstock-Kurzweil Gauge Integration in Many Dimensions\\\n\ntheory Henstock_Kurzweil_Integration\nimports\n Lebesgue_Measure Tagged_Division \"HOL-Real_Asymp.Real_Asymp\"\n\nbegin\n\nlemma norm_diff2: \"\\y = y1 + y2; x = x1 + x2; e = e1 + e2; norm(y1 - x1) \\ e1; norm(y2 - x2) \\ e2\\\n \\ norm(y-x) \\ e\"\n by sorry\n\nlemma setcomp_dot1: \"{z. P (z \\ (i,0))} = {(x,y). P(x \\ i)}\"\n by sorry\n\nlemma setcomp_dot2: \"{z. P (z \\ (0,i))} = {(x,y). P(y \\ i)}\"\n by sorry\n\nlemma Sigma_Int_Paircomp1: \"(Sigma A B) \\ {(x, y). P x} = Sigma (A \\ {x. P x}) B\"\n by sorry\n\nlemma Sigma_Int_Paircomp2: \"(Sigma A B) \\ {(x, y). P y} = Sigma A (\\z. B z \\ {y. P y})\"\n by sorry\n\nsubsection \\Content (length, area, volume, etc.) of an interval\\\n\nabbreviation content :: \"'a::euclidean_space set \\ real\"\n where \"content s \\ measure lborel s\"\n\nlemma content_cbox_cases:\n \"content (cbox a b) = (if \\i\\Basis. a\\i \\ b\\i then prod (\\i. b\\i - a\\i) Basis else 0)\"\n by sorry\n\nlemma content_cbox: \"\\i\\Basis. a\\i \\ b\\i \\ content (cbox a b) = (\\i\\Basis. b\\i - a\\i)\"\n by sorry\n\nlemma content_cbox': \"cbox a b \\ {} \\ content (cbox a b) = (\\i\\Basis. b\\i - a\\i)\"\n by sorry\n\nlemma content_cbox_if: \"content (cbox a b) = (if cbox a b = {} then 0 else \\i\\Basis. b\\i - a\\i)\"\n by sorry\n\nlemma content_cbox_cart:\n \"cbox a b \\ {} \\ content(cbox a b) = prod (\\i. b$i - a$i) UNIV\"\n by sorry\n\nlemma content_cbox_if_cart:\n \"content(cbox a b) = (if cbox a b = {} then 0 else prod (\\i. b$i - a$i) UNIV)\"\n by sorry\n\nlemma content_division_of:\n assumes \"K \\ \\\" \"\\ division_of S\"\n shows \"content K = (\\i \\ Basis. interval_upperbound K \\ i - interval_lowerbound K \\ i)\"\n by sorry\n\nlemma content_real: \"a \\ b \\ content {a..b} = b - a\"\n by sorry\n\nlemma abs_eq_content: \"\\y - x\\ = (if x\\y then content {x..y} else content {y..x})\"\n by sorry\n\nlemma content_singleton: \"content {a} = 0\"\n by sorry\n\nlemma content_unit[iff]: \"content (cbox 0 (One::'a::euclidean_space)) = 1\"\n by sorry\n\nlemma content_pos_le [iff]: \"0 \\ content X\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ content_nonneg [simp]: \"\\ content (cbox a b) < 0\"\n by sorry\n\nlemma content_pos_lt: \"\\i\\Basis. a\\i < b\\i \\ 0 < content (cbox a b)\"\n by sorry\n\nlemma content_eq_0: \"content (cbox a b) = 0 \\ (\\i\\Basis. b\\i \\ a\\i)\"\n by sorry\n\nlemma content_eq_0_interior: \"content (cbox a b) = 0 \\ interior(cbox a b) = {}\"\n by sorry\n\nlemma content_pos_lt_eq: \"0 < content (cbox a (b::'a::euclidean_space)) \\ (\\i\\Basis. a\\i < b\\i)\"\n by sorry\n\nlemma content_empty [simp]: \"content {} = 0\"\n by sorry\n\nlemma content_real_if [simp]: \"content {a..b} = (if a \\ b then b - a else 0)\"\n by sorry\n\nlemma content_subset: \"cbox a b \\ cbox c d \\ content (cbox a b) \\ content (cbox c d)\"\n by sorry\n\nlemma content_lt_nz: \"0 < content (cbox a b) \\ content (cbox a b) \\ 0\"\n by sorry\n\nlemma content_Pair: \"content (cbox (a,c) (b,d)) = content (cbox a b) * content (cbox c d)\"\n by sorry\n\nlemma content_cbox_pair_eq0_D:\n \"content (cbox (a,c) (b,d)) = 0 \\ content (cbox a b) = 0 \\ content (cbox c d) = 0\"\n by sorry\n\nlemma content_cbox_plus:\n fixes x :: \"'a::euclidean_space\"\n shows \"content(cbox x (x + h *\\<^sub>R One)) = (if h \\ 0 then h ^ DIM('a) else 0)\"\n by sorry\n\nlemma content_0_subset: \"content(cbox a b) = 0 \\ s \\ cbox a b \\ content s = 0\"\n by sorry\n\nlemma content_ball_pos:\n assumes \"r > 0\"\n shows \"content (ball c r) > 0\"\n by sorry\n\nlemma content_cball_pos:\n assumes \"r > 0\"\n shows \"content (cball c r) > 0\"\n by sorry\n\nlemma content_split:\n fixes a :: \"'a::euclidean_space\"\n assumes \"k \\ Basis\"\n shows \"content (cbox a b) = content(cbox a b \\ {x. x\\k \\ c}) + content(cbox a b \\ {x. x\\k \\ c})\"\n \\ \\Prove using measure theory\\\n by sorry\n\nlemma division_of_content_0:\n assumes \"content (cbox a b) = 0\" \"d division_of (cbox a b)\" \"K \\ d\"\n shows \"content K = 0\"\n by sorry\n\nlemma sum_content_null:\n assumes \"content (cbox a b) = 0\"\n and \"p tagged_division_of (cbox a b)\"\n shows \"(\\(x,K)\\p. content K *\\<^sub>R f x) = (0::'a::real_normed_vector)\"\n by sorry\n\nglobal_interpretation sum_content: operative plus 0 content\n rewrites \"comm_monoid_set.F plus 0 = sum\"\nproof -\n interpret operative plus 0 content\n by standard (auto simp: content_split [symmetric] content_eq_0_interior)\n show \"operative plus 0 content\"\n by standard\n show \"comm_monoid_set.F plus 0 = sum\"\n by (simp add: sum_def)\nqed\n\nlemma additive_content_division: \"d division_of (cbox a b) \\ sum content d = content (cbox a b)\"\n by sorry\n\nlemma additive_content_tagged_division:\n \"d tagged_division_of (cbox a b) \\ sum (\\(x,l). content l) d = content (cbox a b)\"\n by sorry\n\nlemma subadditive_content_division:\n assumes \"\\ division_of S\" \"S \\ cbox a b\"\n shows \"sum content \\ \\ content(cbox a b)\"\n by sorry\n\nlemma content_real_eq_0: \"content {a..b::real} = 0 \\ a \\ b\"\n by sorry\n\nlemma property_empty_interval: \"\\a b. content (cbox a b) = 0 \\ P (cbox a b) \\ P {}\"\n by sorry\n\nlemma interval_bounds_nz_content [simp]:\n assumes \"content (cbox a b) \\ 0\"\n shows \"interval_upperbound (cbox a b) = b\"\n and \"interval_lowerbound (cbox a b) = a\"\n by sorry\n\nsubsection \\Gauge integral\\\n\ntext \\Case distinction to define it first on compact intervals first, then use a limit. This is only\nmuch later unified. In Fremlin: Measure Theory, Volume 4I this is generalized using residual sets.\\\n\ndefinition has_integral :: \"('n::euclidean_space \\ 'b::real_normed_vector) \\ 'b \\ 'n set \\ bool\"\n (infixr \\has'_integral\\ 46)\n where \"(f has_integral I) s \\\n (if \\a b. s = cbox a b\n then ((\\p. \\(x,k)\\p. content k *\\<^sub>R f x) \\ I) (division_filter s)\n else (\\e>0. \\B>0. \\a b. ball 0 B \\ cbox a b \\\n (\\z. ((\\p. \\(x,k)\\p. content k *\\<^sub>R (if x \\ s then f x else 0)) \\ z) (division_filter (cbox a b)) \\\n norm (z - I) < e)))\"\n\nlemma has_integral_cbox:\n \"(f has_integral I) (cbox a b) \\ ((\\p. \\(x,k)\\p. content k *\\<^sub>R f x) \\ I) (division_filter (cbox a b))\"\n by sorry\n\nlemma has_integral:\n \"(f has_integral y) (cbox a b) \\\n (\\e>0. \\\\. gauge \\ \\\n (\\\\. \\ tagged_division_of (cbox a b) \\ \\ fine \\ \\\n norm ((\\(x, k)\\\\. content k *\\<^sub>R f x) - y) < e))\"\n by sorry\n\nlemma has_integral_real:\n \"(f has_integral y) {a..b::real} \\\n (\\e>0. \\\\. gauge \\ \\\n (\\\\. \\ tagged_division_of {a..b} \\ \\ fine \\ \\\n norm (sum (\\(x,k). content(k) *\\<^sub>R f x) \\ - y) < e))\"\n by sorry\n\nlemma has_integralD[dest]:\n assumes \"(f has_integral y) (cbox a b)\"\n and \"e > 0\"\n obtains \\\n where \"gauge \\\"\n and \"\\\\. \\ tagged_division_of (cbox a b) \\ \\ fine \\ \\\n norm ((\\(x,k)\\\\. content k *\\<^sub>R f x) - y) < e\"\n by sorry\n\nlemma has_integral_alt:\n \"(f has_integral y) i \\\n (if \\a b. i = cbox a b\n then (f has_integral y) i\n else (\\e>0. \\B>0. \\a b. ball 0 B \\ cbox a b \\\n (\\z. ((\\x. if x \\ i then f x else 0) has_integral z) (cbox a b) \\ norm (z - y) < e)))\"\n by sorry\n\nlemma has_integral_altD:\n assumes \"(f has_integral y) i\"\n and \"\\ (\\a b. i = cbox a b)\"\n and \"e>0\"\n obtains B where \"B > 0\"\n and \"\\a b. ball 0 B \\ cbox a b \\\n (\\z. ((\\x. if x \\ i then f(x) else 0) has_integral z) (cbox a b) \\ norm(z - y) < e)\"\n by sorry\n\ndefinition integrable_on (infixr \\integrable'_on\\ 46)\n where \"f integrable_on i \\ (\\y. (f has_integral y) i)\"\n\ndefinition \"integral i f = (SOME y. (f has_integral y) i \\ \\ f integrable_on i \\ y=0)\"\n\nlemma integrable_integral[intro]: \"f integrable_on i \\ (f has_integral (integral i f)) i\"\n by sorry\n\nlemma not_integrable_integral: \"\\ f integrable_on i \\ integral i f = 0\"\n by sorry\n\nlemma has_integral_integrable[dest]: \"(f has_integral i) s \\ f integrable_on s\"\n by sorry\n\nlemma has_integral_integral: \"f integrable_on s \\ (f has_integral (integral s f)) s\"\n by sorry\n\nsubsection \\Basic theorems about integrals\\\n\nlemma has_integral_eq_rhs: \"(f has_integral j) S \\ i = j \\ (f has_integral i) S\"\n by sorry\n\nlemma has_integral_unique_cbox:\n fixes f :: \"'n::euclidean_space \\ 'a::real_normed_vector\"\n shows \"(f has_integral k1) (cbox a b) \\ (f has_integral k2) (cbox a b) \\ k1 = k2\"\n by sorry\n\nlemma has_integral_unique:\n fixes f :: \"'n::euclidean_space \\ 'a::real_normed_vector\"\n assumes \"(f has_integral k1) i\" \"(f has_integral k2) i\"\n shows \"k1 = k2\"\n by sorry\n\nlemma integral_unique [intro]: \"(f has_integral y) k \\ integral k f = y\"\n by sorry\n\nlemma has_integral_iff: \"(f has_integral i) S \\ (f integrable_on S \\ integral S f = i)\"\n by sorry\n\nlemma eq_integralD: \"integral k f = y \\ (f has_integral y) k \\ \\ f integrable_on k \\ y=0\"\n by sorry\n\nlemma has_integral_const [intro]:\n fixes a b :: \"'a::euclidean_space\"\n shows \"((\\x. c) has_integral (content (cbox a b) *\\<^sub>R c)) (cbox a b)\"\n by sorry\n\nlemma has_integral_const_real [intro]:\n fixes a b :: real\n shows \"((\\x. c) has_integral (content {a..b} *\\<^sub>R c)) {a..b}\"\n by sorry\n\nlemma has_integral_integrable_integral: \"(f has_integral i) s \\ f integrable_on s \\ integral s f = i\"\n by sorry\n\nlemma integral_const [simp]:\n fixes a b :: \"'a::euclidean_space\"\n shows \"integral (cbox a b) (\\x. c) = content (cbox a b) *\\<^sub>R c\"\n by sorry\n\nlemma integral_const_real [simp]:\n fixes a b :: real\n shows \"integral {a..b} (\\x. c) = content {a..b} *\\<^sub>R c\"\n by sorry\n\nlemma has_integral_is_0_cbox:\n fixes f :: \"'n::euclidean_space \\ 'a::real_normed_vector\"\n assumes \"\\x. x \\ cbox a b \\ f x = 0\"\n shows \"(f has_integral 0) (cbox a b)\"\n by sorry\n\nlemma has_integral_is_0:\n fixes f :: \"'n::euclidean_space \\ 'a::real_normed_vector\"\n assumes \"\\x. x \\ S \\ f x = 0\"\n shows \"(f has_integral 0) S\"\n by sorry\n\nlemma has_integral_0[simp]: \"((\\x::'n::euclidean_space. 0) has_integral 0) S\"\n by sorry\n\nlemma has_integral_0_eq[simp]: \"((\\x. 0) has_integral i) S \\ i = 0\"\n by sorry\n\nlemma has_integral_linear_cbox:\n fixes f :: \"'n::euclidean_space \\ 'a::real_normed_vector\"\n assumes f: \"(f has_integral y) (cbox a b)\"\n and h: \"bounded_linear h\"\n shows \"((h \\ f) has_integral (h y)) (cbox a b)\"\n by sorry\n\nlemma has_integral_linear:\n fixes f :: \"'n::euclidean_space \\ 'a::real_normed_vector\"\n assumes f: \"(f has_integral y) S\"\n and h: \"bounded_linear h\"\n shows \"((h \\ f) has_integral (h y)) S\"\n by sorry\n\nlemma has_integral_of_real:\n \"(f has_integral I) A \\\n ((\\x::'a::euclidean_space. of_real (f x) :: 'b :: {real_normed_vector,real_normed_algebra_1}) \n has_integral of_real I) A\"\n by sorry\n\nlemma has_integral_scaleR_left:\n \"(f has_integral y) S \\ ((\\x. f x *\\<^sub>R c) has_integral (y *\\<^sub>R c)) S\"\n by sorry\n\nlemma integrable_on_scaleR_left:\n assumes \"f integrable_on A\"\n shows \"(\\x. f x *\\<^sub>R y) integrable_on A\"\n by sorry\n\nlemma has_integral_mult_left:\n fixes c :: \"_ :: real_normed_algebra\"\n shows \"(f has_integral y) S \\ ((\\x. f x * c) has_integral (y * c)) S\"\n by sorry\n\nlemma integrable_on_mult_left:\n fixes c :: \"'a :: real_normed_algebra\"\n assumes \"f integrable_on A\"\n shows \"(\\x. f x * c) integrable_on A\"\n by sorry\n\nlemma has_integral_divide:\n fixes c :: \"_ :: real_normed_div_algebra\"\n shows \"(f has_integral y) S \\ ((\\x. f x / c) has_integral (y / c)) S\"\n by sorry\n\nlemma integrable_on_divide:\n fixes c :: \"'a :: real_normed_div_algebra\"\n assumes \"f integrable_on A\"\n shows \"(\\x. f x / c) integrable_on A\"\n by sorry\n\ntext\\The case analysis eliminates the condition \\<^term>\\f integrable_on S\\ at the cost\n of the type class constraint \\division_ring\\\\\ncorollary integral_mult_left [simp]:\n fixes c:: \"'a::{real_normed_algebra,division_ring}\"\n shows \"integral S (\\x. f x * c) = integral S f * c\"\n by sorry\n\ncorollary integral_mult_right [simp]:\n fixes c:: \"'a::{real_normed_field}\"\n shows \"integral S (\\x. c * f x) = c * integral S f\"\n by sorry\n\ncorollary integral_divide [simp]:\n fixes z :: \"'a::real_normed_field\"\n shows \"integral S (\\x. f x / z) = integral S (\\x. f x) / z\"\n by sorry\n\nlemma has_integral_mult_right:\n fixes c :: \"'a :: real_normed_algebra\"\n shows \"(f has_integral y) A \\ ((\\x. c * f x) has_integral (c * y)) A\"\n by sorry\n\nlemma integrable_on_mult_right:\n fixes c :: \"'a :: real_normed_algebra\"\n assumes \"f integrable_on A\"\n shows \"(\\x. c * f x) integrable_on A\"\n by sorry\n\nlemma has_integral_mult_right_iff:\n fixes c :: \"'a :: real_normed_field\"\n assumes \"c \\ 0\"\n shows \"((\\x. c * f x) has_integral y) A \\ (f has_integral (y / c)) A\"\n by sorry\n\nlemma integrable_on_mult_right_iff [simp]:\n fixes c :: \"'a :: real_normed_field\"\n assumes \"c \\ 0\"\n shows \"(\\x. c * f x) integrable_on A \\ f integrable_on A\"\n by sorry\n\nlemma integrable_on_mult_left_iff [simp]:\n fixes c :: \"'a :: real_normed_field\"\n assumes \"c \\ 0\"\n shows \"(\\x. f x * c) integrable_on A \\ f integrable_on A\"\n by sorry\n\nlemma integrable_on_div_iff [simp]:\n fixes c :: \"'a :: real_normed_field\"\n assumes \"c \\ 0\"\n shows \"(\\x. f x / c) integrable_on A \\ f integrable_on A\"\n by sorry\n\nlemma has_integral_cmul: \"(f has_integral k) S \\ ((\\x. c *\\<^sub>R f x) has_integral (c *\\<^sub>R k)) S\"\n by sorry\n\nlemma has_integral_cmult_real:\n fixes c :: real\n assumes \"c \\ 0 \\ (f has_integral x) A\"\n shows \"((\\x. c * f x) has_integral c * x) A\"\n by sorry\n\nlemma has_integral_neg: \"(f has_integral k) S \\ ((\\x. -(f x)) has_integral -k) S\"\n by sorry\n\nlemma has_integral_neg_iff: \"((\\x. - f x) has_integral k) S \\ (f has_integral - k) S\"\n by sorry\n\nlemma has_integral_add_cbox:\n fixes f :: \"'n::euclidean_space \\ 'a::real_normed_vector\"\n assumes \"(f has_integral k) (cbox a b)\" \"(g has_integral l) (cbox a b)\"\n shows \"((\\x. f x + g x) has_integral (k + l)) (cbox a b)\"\n by sorry\n\nlemma has_integral_add:\n fixes f :: \"'n::euclidean_space \\ 'a::real_normed_vector\"\n assumes f: \"(f has_integral k) S\" and g: \"(g has_integral l) S\"\n shows \"((\\x. f x + g x) has_integral (k + l)) S\"\n by sorry\n\nlemma has_integral_diff:\n \"(f has_integral k) S \\ (g has_integral l) S \\\n ((\\x. f x - g x) has_integral (k - l)) S\"\n by sorry\n\nlemma integral_0 [simp]:\n \"integral S (\\x::'n::euclidean_space. 0::'m::real_normed_vector) = 0\"\n by sorry\n\nlemma integral_add: \"f integrable_on S \\ g integrable_on S \\\n integral S (\\x. f x + g x) = integral S f + integral S g\"\n by sorry\n\nlemma integral_cmul [simp]: \"integral S (\\x. c *\\<^sub>R f x) = c *\\<^sub>R integral S f\"\n by sorry\n\nlemma integral_mult:\n fixes K::real\n shows \"f integrable_on X \\ K * integral X f = integral X (\\x. K * f x)\"\n by sorry\n\nlemma integral_neg [simp]: \"integral S (\\x. - f x) = - integral S f\"\n by sorry\n\nlemma integral_diff: \"f integrable_on S \\ g integrable_on S \\\n integral S (\\x. f x - g x) = integral S f - integral S g\"\n by sorry\n\nlemma integrable_0: \"(\\x. 0) integrable_on S\"\n by sorry\n\nlemma integrable_add: \"f integrable_on S \\ g integrable_on S \\ (\\x. f x + g x) integrable_on S\"\n by sorry\n\nlemma integrable_cmul: \"f integrable_on S \\ (\\x. c *\\<^sub>R f(x)) integrable_on S\"\n by sorry\n\nlemma integrable_on_scaleR_iff [simp]:\n fixes c :: real\n assumes \"c \\ 0\"\n shows \"(\\x. c *\\<^sub>R f x) integrable_on S \\ f integrable_on S\"\n by sorry\n\nlemma integrable_on_cmult_iff [simp]:\n fixes c :: real\n assumes \"c \\ 0\"\n shows \"(\\x. c * f x) integrable_on S \\ f integrable_on S\"\n by sorry\n\nlemma integrable_on_cmult_left:\n assumes \"f integrable_on S\"\n shows \"(\\x. of_real c * f x) integrable_on S\"\n by sorry\n\nlemma integrable_neg: \"f integrable_on S \\ (\\x. -f(x)) integrable_on S\"\n by sorry\n\nlemma integrable_neg_iff: \"(\\x. -f(x)) integrable_on S \\ f integrable_on S\"\n by sorry\n\nlemma integrable_diff:\n \"f integrable_on S \\ g integrable_on S \\ (\\x. f x - g x) integrable_on S\"\n by sorry\n\nlemma integrable_linear:\n \"f integrable_on S \\ bounded_linear h \\ (h \\ f) integrable_on S\"\n by sorry\n\nlemma integral_linear:\n \"f integrable_on S \\ bounded_linear h \\ integral S (h \\ f) = h (integral S f)\"\n by sorry\n\nlemma integrable_on_cnj_iff:\n \"(\\x. cnj (f x)) integrable_on A \\ f integrable_on A\"\n by sorry\n\nlemma integral_cnj: \"cnj (integral A f) = integral A (\\x. cnj (f x))\"\n by sorry\n\nlemma has_integral_cnj: \"(cnj \\ f has_integral (cnj I)) A = (f has_integral I) A\"\n by sorry\n\nlemma integral_component_eq[simp]:\n fixes f :: \"'n::euclidean_space \\ 'm::euclidean_space\"\n assumes \"f integrable_on S\"\n shows \"integral S (\\x. f x \\ k) = integral S f \\ k\"\n by sorry\n\nlemma integral_eq_iff_componentwise:\n fixes f :: \"'a :: euclidean_space \\ 'b :: euclidean_space\"\n assumes \"f integrable_on A\"\n shows \"integral A f = I \\ (\\b\\Basis. integral A (\\x. f x \\ b) = I \\ b)\"\n by sorry\n\nlemma has_integral_sum:\n assumes \"finite T\"\n and \"\\a. a \\ T \\ ((f a) has_integral (i a)) S\"\n shows \"((\\x. sum (\\a. f a x) T) has_integral (sum i T)) S\"\n by sorry\n\nlemma integral_sum:\n \"\\finite I; \\a. a \\ I \\ f a integrable_on S\\ \\\n integral S (\\x. \\a\\I. f a x) = (\\a\\I. integral S (f a))\"\n by sorry\n\nlemma integrable_sum:\n \"\\finite I; \\a. a \\ I \\ f a integrable_on S\\ \\ (\\x. \\a\\I. f a x) integrable_on S\"\n by sorry\n\nlemma has_integral_eq:\n assumes \"\\x. x \\ s \\ f x = g x\"\n and f: \"(f has_integral k) s\"\n shows \"(g has_integral k) s\"\n by sorry\n\nlemma integrable_eq: \"\\f integrable_on s; \\x. x \\ s \\ f x = g x\\ \\ g integrable_on s\"\n by sorry\n\nlemma has_integral_cong:\n assumes \"\\x. x \\ s \\ f x = g x\"\n shows \"(f has_integral i) s = (g has_integral i) s\"\n by sorry\n\nlemma integrable_cong:\n assumes \"\\x. x \\ A \\ f x = g x\"\n shows \"f integrable_on A \\ g integrable_on A\"\n by sorry\n\nlemma integral_cong:\n assumes \"\\x. x \\ s \\ f x = g x\"\n shows \"integral s f = integral s g\"\n by sorry\nby (metis (full_types, opaque_lifting) assms has_integral_cong integrable_eq)\n\nlemma integrable_on_cmult_left_iff [simp]:\n assumes \"c \\ 0\"\n shows \"(\\x. of_real c * f x) integrable_on s \\ f integrable_on s\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma integrable_on_cmult_right:\n fixes f :: \"_ \\ 'b :: {comm_ring,real_algebra_1,real_normed_vector}\"\n assumes \"f integrable_on s\"\n shows \"(\\x. f x * of_real c) integrable_on s\"\n by sorry\n\nlemma integrable_on_cmult_right_iff [simp]:\n fixes f :: \"_ \\ 'b :: {comm_ring,real_algebra_1,real_normed_vector}\"\n assumes \"c \\ 0\"\n shows \"(\\x. f x * of_real c) integrable_on s \\ f integrable_on s\"\n by sorry\n\nlemma integrable_on_cdivide_iff [simp]:\n fixes f :: \"_ \\ 'b :: real_normed_field\"\n assumes \"c \\ 0\"\n shows \"(\\x. f x / of_real c) integrable_on s \\ f integrable_on s\"\n by sorry\n\nlemma has_integral_null [intro]: \"content(cbox a b) = 0 \\ (f has_integral 0) (cbox a b)\"\n by sorry\n\nlemma has_integral_null_real [intro]: \"content {a..b::real} = 0 \\ (f has_integral 0) {a..b}\"\n by sorry\n\nlemma has_integral_null_eq[simp]: \"content (cbox a b) = 0 \\ (f has_integral i) (cbox a b) \\ i = 0\"\n by sorry\n\nlemma integral_null [simp]: \"content (cbox a b) = 0 \\ integral (cbox a b) f = 0\"\n by sorry\n\nlemma integrable_on_null [intro]: \"content (cbox a b) = 0 \\ f integrable_on (cbox a b)\"\n by sorry\n\nlemma has_integral_empty[intro]: \"(f has_integral 0) {}\"\n by sorry\n\nlemma has_integral_empty_eq[simp]: \"(f has_integral i) {} \\ i = 0\"\n by sorry\n\nlemma integrable_on_empty[intro]: \"f integrable_on {}\"\n by sorry\n\nlemma integral_empty[simp]: \"integral {} f = 0\"\n by sorry\n\nlemma has_integral_refl[intro]:\n fixes a :: \"'a::euclidean_space\"\n shows \"(f has_integral 0) (cbox a a)\"\n and \"(f has_integral 0) {a}\"\n by sorry\n\nlemma integrable_on_refl[intro]: \"f integrable_on cbox a a\"\n by sorry\n\nlemma integral_refl [simp]: \"integral (cbox a a) f = 0\"\n by sorry\n\nlemma integral_singleton [simp]: \"integral {a} f = 0\"\n by sorry\n\nlemma integral_blinfun_apply:\n assumes \"f integrable_on s\"\n shows \"integral s (\\x. blinfun_apply h (f x)) = blinfun_apply h (integral s f)\"\n by sorry\n\nlemma blinfun_apply_integral:\n assumes \"f integrable_on s\"\n shows \"blinfun_apply (integral s f) x = integral s (\\y. blinfun_apply (f y) x)\"\n by sorry\n\nlemma has_integral_componentwise_iff:\n fixes f :: \"'a :: euclidean_space \\ 'b :: euclidean_space\"\n shows \"(f has_integral y) A \\ (\\b\\Basis. ((\\x. f x \\ b) has_integral (y \\ b)) A)\"\n by sorry\n\nlemma has_integral_componentwise:\n fixes f :: \"'a :: euclidean_space \\ 'b :: euclidean_space\"\n shows \"(\\b. b \\ Basis \\ ((\\x. f x \\ b) has_integral (y \\ b)) A) \\ (f has_integral y) A\"\n by sorry\n\nlemma integrable_componentwise_iff:\n fixes f :: \"'a :: euclidean_space \\ 'b :: euclidean_space\"\n shows \"f integrable_on A \\ (\\b\\Basis. (\\x. f x \\ b) integrable_on A)\"\n by sorry\n\nlemma integrable_componentwise:\n fixes f :: \"'a :: euclidean_space \\ 'b :: euclidean_space\"\n shows \"(\\b. b \\ Basis \\ (\\x. f x \\ b) integrable_on A) \\ f integrable_on A\"\n by sorry\n\nlemma integral_componentwise:\n fixes f :: \"'a :: euclidean_space \\ 'b :: euclidean_space\"\n assumes \"f integrable_on A\"\n shows \"integral A f = (\\b\\Basis. integral A (\\x. (f x \\ b) *\\<^sub>R b))\"\n by sorry\n\nlemma integrable_component:\n \"f integrable_on A \\ (\\x. f x \\ (y :: 'b :: euclidean_space)) integrable_on A\"\n by sorry\n\nlemma\n assumes \"(f has_integral I) A \"\n shows has_integral_Re: \"((\\x. Re (f x)) has_integral (Re I)) A\"\n and has_integral_Im: \"((\\x. Im (f x)) has_integral (Im I)) A\"\n by sorry\n\nsubsection \\Cauchy-type criterion for integrability\\\n\nproposition integrable_Cauchy:\n fixes f :: \"'n::euclidean_space \\ 'a::{real_normed_vector,complete_space}\"\n shows \"f integrable_on cbox a b \\\n (\\e>0. \\\\. gauge \\ \\\n (\\\\1 \\2. \\1 tagged_division_of (cbox a b) \\ \\ fine \\1 \\\n \\2 tagged_division_of (cbox a b) \\ \\ fine \\2 \\\n norm ((\\(x,K)\\\\1. content K *\\<^sub>R f x) - (\\(x,K)\\\\2. content K *\\<^sub>R f x)) < e))\"\n (is \"?l = (\\e>0. \\\\. ?P e \\)\")\n by sorry\n\nsubsection \\Additivity of integral on abutting intervals\\\n\nlemma tagged_division_split_left_inj_content:\n assumes \\: \"\\ tagged_division_of S\"\n and \"(x1, K1) \\ \\\" \"(x2, K2) \\ \\\" \"K1 \\ K2\" \"K1 \\ {x. x\\k \\ c} = K2 \\ {x. x\\k \\ c}\" \"k \\ Basis\"\n shows \"content (K1 \\ {x. x\\k \\ c}) = 0\"\n by sorry\n\nlemma tagged_division_split_right_inj_content:\n assumes \\: \"\\ tagged_division_of S\"\n and \"(x1, K1) \\ \\\" \"(x2, K2) \\ \\\" \"K1 \\ K2\" \"K1 \\ {x. x\\k \\ c} = K2 \\ {x. x\\k \\ c}\" \"k \\ Basis\"\n shows \"content (K1 \\ {x. x\\k \\ c}) = 0\"\n by sorry\n\nproposition has_integral_split:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n assumes fi: \"(f has_integral i) (cbox a b \\ {x. x\\k \\ c})\"\n and fj: \"(f has_integral j) (cbox a b \\ {x. x\\k \\ c})\"\n and k: \"k \\ Basis\"\nshows \"(f has_integral (i + j)) (cbox a b)\"\n by sorry\n\nsubsection \\A sort of converse, integrability on subintervals\\\n\nlemma has_integral_separate_sides:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n assumes f: \"(f has_integral i) (cbox a b)\"\n and \"e > 0\"\n and k: \"k \\ Basis\"\n obtains d where \"gauge d\"\n \"\\p1 p2. p1 tagged_division_of (cbox a b \\ {x. x\\k \\ c}) \\ d fine p1 \\\n p2 tagged_division_of (cbox a b \\ {x. x\\k \\ c}) \\ d fine p2 \\\n norm ((sum (\\(x,k). content k *\\<^sub>R f x) p1 + sum (\\(x,k). content k *\\<^sub>R f x) p2) - i) < e\"\n by sorry\n\nlemma integrable_split [intro]:\n fixes f :: \"'a::euclidean_space \\ 'b::{real_normed_vector,complete_space}\"\n assumes f: \"f integrable_on cbox a b\"\n and k: \"k \\ Basis\"\n shows \"f integrable_on (cbox a b \\ {x. x\\k \\ c})\" (is ?thesis1)\n and \"f integrable_on (cbox a b \\ {x. x\\k \\ c})\" (is ?thesis2)\n by sorry\n\nlemma operative_integralI:\n fixes f :: \"'a::euclidean_space \\ 'b::banach\"\n shows \"operative (lift_option (+)) (Some 0)\n (\\i. if f integrable_on i then Some (integral i f) else None)\"\n by sorry\n\nsubsection \\Bounds on the norm of Riemann sums and the integral itself\\\n\nlemma dsum_bound:\n assumes p: \"p division_of (cbox a b)\"\n and \"norm c \\ e\"\n shows \"norm (\\l\\p. content l *\\<^sub>R c) \\ e * content(cbox a b)\"\n by sorry\n\nlemma rsum_bound:\n assumes p: \"p tagged_division_of (cbox a b)\"\n and \"\\x\\cbox a b. norm (f x) \\ e\"\n shows \"norm (\\(x, k)\\p. content k *\\<^sub>R f x) \\ e * content (cbox a b)\"\n by sorry\n\nlemma rsum_diff_bound:\n assumes \"p tagged_division_of (cbox a b)\"\n and \"\\x\\cbox a b. norm (f x - g x) \\ e\"\n shows \"norm (sum (\\(x,k). content k *\\<^sub>R f x) p - sum (\\(x,k). content k *\\<^sub>R g x) p) \\\n e * content (cbox a b)\"\n by sorry\n\nlemma has_integral_bound:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n assumes \"0 \\ B\"\n and f: \"(f has_integral i) (cbox a b)\"\n and \"\\x. x\\cbox a b \\ norm (f x) \\ B\"\n shows \"norm i \\ B * content (cbox a b)\"\n by sorry\n\ncorollary integrable_bound:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n assumes \"0 \\ B\"\n and \"f integrable_on (cbox a b)\"\n and \"\\x. x\\cbox a b \\ norm (f x) \\ B\"\n shows \"norm (integral (cbox a b) f) \\ B * content (cbox a b)\"\n by sorry\n\nsubsection \\Similar theorems about relationship among components\\\n\nlemma rsum_component_le:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes p: \"p tagged_division_of (cbox a b)\"\n and \"\\x. x \\ cbox a b \\ (f x)\\i \\ (g x)\\i\"\n shows \"(\\(x, K)\\p. content K *\\<^sub>R f x) \\ i \\ (\\(x, K)\\p. content K *\\<^sub>R g x) \\ i\"\n by sorry\n\nlemma has_integral_component_le:\n fixes f g :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes k: \"k \\ Basis\"\n assumes \"(f has_integral i) S\" \"(g has_integral j) S\"\n and f_le_g: \"\\x. x \\ S \\ (f x)\\k \\ (g x)\\k\"\n shows \"i\\k \\ j\\k\"\n by sorry\n\nlemma integral_component_le:\n fixes g f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"k \\ Basis\"\n and \"f integrable_on S\" \"g integrable_on S\"\n and \"\\x. x \\ S \\ (f x)\\k \\ (g x)\\k\"\n shows \"(integral S f)\\k \\ (integral S g)\\k\"\n by sorry\n\nlemma has_integral_component_nonneg:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"k \\ Basis\"\n and \"(f has_integral i) S\"\n and \"\\x. x \\ S \\ 0 \\ (f x)\\k\"\n shows \"0 \\ i\\k\"\n by sorry\n\nlemma integral_component_nonneg:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"k \\ Basis\"\n and \"\\x. x \\ S \\ 0 \\ (f x)\\k\"\n shows \"0 \\ (integral S f)\\k\"\n by sorry\n\nlemma has_integral_component_neg:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"k \\ Basis\"\n and \"(f has_integral i) S\"\n and \"\\x. x \\ S \\ (f x)\\k \\ 0\"\n shows \"i\\k \\ 0\"\n by sorry\n\nlemma has_integral_component_lbound:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"(f has_integral i) (cbox a b)\"\n and \"\\x\\cbox a b. B \\ f(x)\\k\"\n and \"k \\ Basis\"\n shows \"B * content (cbox a b) \\ i\\k\"\n by sorry\n\nlemma has_integral_component_ubound:\n fixes f::\"'a::euclidean_space => 'b::euclidean_space\"\n assumes \"(f has_integral i) (cbox a b)\"\n and \"\\x\\cbox a b. f x\\k \\ B\"\n and \"k \\ Basis\"\n shows \"i\\k \\ B * content (cbox a b)\"\n by sorry\n\nlemma integral_component_lbound:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"f integrable_on cbox a b\"\n and \"\\x\\cbox a b. B \\ f(x)\\k\"\n and \"k \\ Basis\"\n shows \"B * content (cbox a b) \\ (integral(cbox a b) f)\\k\"\n by sorry\n\nlemma integral_component_lbound_real:\n assumes \"f integrable_on {a ::real..b}\"\n and \"\\x\\{a..b}. B \\ f(x)\\k\"\n and \"k \\ Basis\"\n shows \"B * content {a..b} \\ (integral {a..b} f)\\k\"\n by sorry\n\nlemma integral_component_ubound:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"f integrable_on cbox a b\"\n and \"\\x\\cbox a b. f x\\k \\ B\"\n and \"k \\ Basis\"\n shows \"(integral (cbox a b) f)\\k \\ B * content (cbox a b)\"\n by sorry\n\nlemma integral_component_ubound_real:\n fixes f :: \"real \\ 'a::euclidean_space\"\n assumes \"f integrable_on {a..b}\"\n and \"\\x\\{a..b}. f x\\k \\ B\"\n and \"k \\ Basis\"\n shows \"(integral {a..b} f)\\k \\ B * content {a..b}\"\n by sorry\n\nsubsection \\Uniform limit of integrable functions is integrable\\\n\nlemma real_arch_invD:\n \"0 < (e::real) \\ (\\n::nat. n \\ 0 \\ 0 < inverse (real n) \\ inverse (real n) < e)\"\n by sorry\n\nlemma integrable_uniform_limit:\n fixes f :: \"'a::euclidean_space \\ 'b::banach\"\n assumes \"\\e. e > 0 \\ \\g. (\\x\\cbox a b. norm (f x - g x) \\ e) \\ g integrable_on cbox a b\"\n shows \"f integrable_on cbox a b\"\n by sorry\n\nlemmas integrable_uniform_limit_real = integrable_uniform_limit [where 'a=real, simplified]\n\nsubsection \\Negligible sets\\\n\ndefinition \"negligible (s:: 'a::euclidean_space set) \\\n (\\a b. ((indicator s :: 'a\\real) has_integral 0) (cbox a b))\"\n\nsubsubsection \\Negligibility of hyperplane\\\n\nlemma content_doublesplit:\n fixes a :: \"'a::euclidean_space\"\n assumes \"0 < e\"\n and k: \"k \\ Basis\"\n obtains d where \"0 < d\" and \"content (cbox a b \\ {x. \\x\\k - c\\ \\ d}) < e\"\n by sorry\n\nproposition negligible_standard_hyperplane[intro]:\n fixes k :: \"'a::euclidean_space\"\n assumes k: \"k \\ Basis\"\n shows \"negligible {x. x\\k = c}\"\n by sorry\n\ncorollary negligible_standard_hyperplane_cart:\n fixes k :: \"'a::finite\"\n shows \"negligible {x. x$k = (0::real)}\"\n by sorry\n\nsubsubsection \\Hence the main theorem about negligible sets\\\n\nlemma has_integral_negligible_cbox:\n fixes f :: \"'b::euclidean_space \\ 'a::real_normed_vector\"\n assumes negs: \"negligible S\"\n and 0: \"\\x. x \\ S \\ f x = 0\"\n shows \"(f has_integral 0) (cbox a b)\"\n by sorry\n\nproposition has_integral_negligible:\n fixes f :: \"'b::euclidean_space \\ 'a::real_normed_vector\"\n assumes negs: \"negligible S\"\n and \"\\x. x \\ (T - S) \\ f x = 0\"\n shows \"(f has_integral 0) T\"\n by sorry\n\nlemma\n assumes \"negligible S\"\n shows integrable_negligible: \"f integrable_on S\" and integral_negligible: \"integral S f = 0\"\n by sorry\n\nlemma has_integral_spike:\n fixes f :: \"'b::euclidean_space \\ 'a::real_normed_vector\"\n assumes \"negligible S\"\n and gf: \"\\x. x \\ T - S \\ g x = f x\"\n and fint: \"(f has_integral y) T\"\n shows \"(g has_integral y) T\"\n by sorry\n\nlemma has_integral_spike_eq:\n assumes \"negligible S\" and \"\\x. x \\ T - S \\ g x = f x\"\n shows \"(f has_integral y) T \\ (g has_integral y) T\"\n by sorry\n\nlemma integrable_spike:\n assumes \"f integrable_on T\" \"negligible S\" \"\\x. x \\ T - S \\ g x = f x\"\n shows \"g integrable_on T\"\n by sorry\n\nlemma integral_spike:\n assumes \"negligible S\" and \"\\x. x \\ T - S \\ g x = f x\"\n shows \"integral T f = integral T g\"\n by sorry\n\nsubsection \\Some other trivialities about negligible sets\\\n\nlemma negligible_subset:\n assumes \"negligible S\" \"T \\ S\"\n shows \"negligible T\"\n by sorry\n\nlemma negligible_diff[intro?]:\n assumes \"negligible S\"\n shows \"negligible (S - T)\"\n by sorry\n\nlemma negligible_Int:\n assumes \"negligible S \\ negligible T\"\n shows \"negligible (S \\ T)\"\n by sorry\n\nlemma negligible_Un:\n assumes \"negligible S\" and T: \"negligible T\"\n shows \"negligible (S \\ T)\"\n by sorry\n\nlemma negligible_Un_eq[simp]: \"negligible (S \\ T) \\ negligible S \\ negligible T\"\n by sorry\n\nlemma negligible_sing[intro]: \"negligible {a::'a::euclidean_space}\"\n by sorry\n\nlemma negligible_insert[simp]: \"negligible (insert a S) \\ negligible S\"\n by sorry\n\nlemma negligible_empty[iff]: \"negligible {}\"\n by sorry\n\ntext\\Useful in this form for backchaining\\\nlemma empty_imp_negligible: \"S = {} \\ negligible S\"\n by sorry\n\nlemma negligible_finite[intro]:\n assumes \"finite S\"\n shows \"negligible S\"\n by sorry\n\nlemma negligible_Union[intro]:\n assumes \"finite \\\"\n and \"\\T. T \\ \\ \\ negligible T\"\n shows \"negligible(\\\\)\"\n by sorry\n\nlemma negligible: \"negligible S \\ (\\T. (indicat_real S has_integral 0) T)\"\n by sorry\n\nsubsection \\Finite case of the spike theorem is quite commonly needed\\\n\nlemma has_integral_spike_finite:\n assumes \"finite S\"\n and \"\\x. x \\ T - S \\ g x = f x\"\n and \"(f has_integral y) T\"\n shows \"(g has_integral y) T\"\n by sorry\n\nlemma has_integral_spike_finite_eq:\n assumes \"finite S\"\n and \"\\x. x \\ T - S \\ g x = f x\"\n shows \"((f has_integral y) T \\ (g has_integral y) T)\"\n by sorry\n\nlemma integrable_spike_finite:\n assumes \"finite S\"\n and \"\\x. x \\ T - S \\ g x = f x\"\n and \"f integrable_on T\"\n shows \"g integrable_on T\"\n by sorry\n\nlemma integrable_spike_finite_eq:\n assumes \"finite S\"\n and \"\\x. x \\ T - S \\ f x = g x\"\n shows \"f integrable_on T \\ g integrable_on T\"\n by sorry\n\nlemma has_integral_bound_spike_finite:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n assumes \"0 \\ B\" \"finite S\"\n and f: \"(f has_integral i) (cbox a b)\"\n and leB: \"\\x. x \\ cbox a b - S \\ norm (f x) \\ B\"\n shows \"norm i \\ B * content (cbox a b)\"\n by sorry\n\ncorollary has_integral_bound_real:\n fixes f :: \"real \\ 'b::real_normed_vector\"\n assumes \"0 \\ B\" \"finite S\"\n and \"(f has_integral i) {a..b}\"\n and \"\\x. x \\ {a..b} - S \\ norm (f x) \\ B\"\n shows \"norm i \\ B * content {a..b}\"\n by sorry\n\nsubsection \\In particular, the boundary of an interval is negligible\\\n\nlemma negligible_frontier_interval: \"negligible(cbox a b - box a b)\"\n by sorry\n\nlemma has_integral_spike_interior:\n assumes f: \"(f has_integral y) (cbox a b)\" and gf: \"\\x. x \\ box a b \\ g x = f x\"\n shows \"(g has_integral y) (cbox a b)\"\n by sorry\n \nlemma has_integral_spike_interior_eq:\n assumes \"\\x. x \\ box a b \\ g x = f x\"\n shows \"(f has_integral y) (cbox a b) \\ (g has_integral y) (cbox a b)\"\n by sorry\n\nlemma integrable_spike_interior:\n assumes \"\\x. x \\ box a b \\ g x = f x\"\n and \"f integrable_on cbox a b\"\n shows \"g integrable_on cbox a b\"\n by sorry\n\nsubsection \\Integrability of continuous functions\\\n\nlemma operative_approximableI:\n fixes f :: \"'b::euclidean_space \\ 'a::banach\"\n assumes \"0 \\ e\"\n shows \"operative conj True (\\i. \\g. (\\x\\i. norm (f x - g (x::'b)) \\ e) \\ g integrable_on i)\"\n by sorry\n\nlemma comm_monoid_set_F_and: \"comm_monoid_set.F (\\) True f s \\ (finite s \\ (\\x\\s. f x))\"\n by sorry\n\nlemma approximable_on_division:\n fixes f :: \"'b::euclidean_space \\ 'a::banach\"\n assumes \"0 \\ e\"\n and d: \"d division_of (cbox a b)\"\n and f: \"\\i\\d. \\g. (\\x\\i. norm (f x - g x) \\ e) \\ g integrable_on i\"\n obtains g where \"\\x\\cbox a b. norm (f x - g x) \\ e\" \"g integrable_on cbox a b\"\n by sorry\n\nlemma integrable_continuous:\n fixes f :: \"'b::euclidean_space \\ 'a::banach\"\n assumes \"continuous_on (cbox a b) f\"\n shows \"f integrable_on cbox a b\"\n by sorry\n\nlemma integrable_continuous_interval:\n fixes f :: \"'b::ordered_euclidean_space \\ 'a::banach\"\n assumes \"continuous_on {a..b} f\"\n shows \"f integrable_on {a..b}\"\n by sorry\n\nlemmas integrable_continuous_real = integrable_continuous_interval[where 'b=real]\n\nlemma integrable_continuous_closed_segment:\n fixes f :: \"real \\ 'a::banach\"\n assumes \"continuous_on (closed_segment a b) f\"\n shows \"f integrable_on (closed_segment a b)\"\n by sorry\n\nsubsection \\Specialization of additivity to one dimension\\\n\nsubsection \\A useful lemma allowing us to factor out the content size\\\n\nlemma has_integral_factor_content:\n \"(f has_integral i) (cbox a b) \\\n (\\e>0. \\d. gauge d \\ (\\p. p tagged_division_of (cbox a b) \\ d fine p \\\n norm (sum (\\(x,k). content k *\\<^sub>R f x) p - i) \\ e * content (cbox a b)))\"\n by sorry\n\nlemma has_integral_factor_content_real:\n \"(f has_integral i) {a..b::real} \\\n (\\e>0. \\d. gauge d \\ (\\p. p tagged_division_of {a..b} \\ d fine p \\\n norm (sum (\\(x,k). content k *\\<^sub>R f x) p - i) \\ e * content {a..b} ))\"\n by sorry\n\nsubsection \\Fundamental theorem of calculus\\\n\nlemma interval_bounds_real:\n fixes q b :: real\n assumes \"a \\ b\"\n shows \"Sup {a..b} = b\"\n and \"Inf {a..b} = a\"\n by sorry\n\ntheorem fundamental_theorem_of_calculus:\n fixes f :: \"real \\ 'a::banach\"\n assumes \"a \\ b\" \n and vecd: \"\\x. x \\ {a..b} \\ (f has_vector_derivative f' x) (at x within {a..b})\"\n shows \"(f' has_integral (f b - f a)) {a..b}\"\n by sorry\n\nlemma has_complex_derivative_imp_has_vector_derivative:\n fixes f :: \"complex \\ complex\"\n assumes \"(f has_field_derivative f') (at (of_real a) within (cbox (of_real x) (of_real y)))\"\n shows \"((f o of_real) has_vector_derivative f') (at a within {x..y})\"\n by sorry\n\nlemma ident_has_integral:\n fixes a::real\n assumes \"a \\ b\"\n shows \"((\\x. x) has_integral (b\\<^sup>2 - a\\<^sup>2)/2) {a..b}\"\n by sorry\n\nlemma integral_ident [simp]:\n fixes a::real\n assumes \"a \\ b\"\n shows \"integral {a..b} (\\x. x) = (if a \\ b then (b\\<^sup>2 - a\\<^sup>2)/2 else 0)\"\n by sorry\n\nlemma ident_integrable_on:\n fixes a::real\n shows \"(\\x. x) integrable_on {a..b}\"\n by sorry\n\nlemma integral_sin [simp]:\n fixes a::real\n assumes \"a \\ b\" shows \"integral {a..b} sin = cos a - cos b\"\n by sorry\n\nlemma integral_cos [simp]:\n fixes a::real\n assumes \"a \\ b\" shows \"integral {a..b} cos = sin b - sin a\"\n by sorry\n\nlemma integral_exp [simp]:\n fixes a::real\n assumes \"a \\ b\" shows \"integral {a..b} exp = exp b - exp a\"\n by sorry\n\nlemma has_integral_sin_nx: \"((\\x. sin(real_of_int n * x)) has_integral 0) {-pi..pi}\"\n by sorry\n\nlemma integral_sin_nx:\n \"integral {-pi..pi} (\\x. sin(x * real_of_int n)) = 0\"\n by sorry\n\nlemma has_integral_cos_nx:\n \"((\\x. cos(real_of_int n * x)) has_integral (if n = 0 then 2 * pi else 0)) {-pi..pi}\"\n by sorry\n\nlemma integral_cos_nx:\n \"integral {-pi..pi} (\\x. cos(x * real_of_int n)) = (if n = 0 then 2 * pi else 0)\"\n by sorry\n\nsubsection \\Taylor series expansion\\\n\nlemma mvt_integral:\n fixes f::\"'a::real_normed_vector\\'b::banach\"\n assumes f'[derivative_intros]:\n \"\\x. x \\ S \\ (f has_derivative f' x) (at x within S)\"\n assumes line_in: \"\\t. t \\ {0..1} \\ x + t *\\<^sub>R y \\ S\"\n shows \"f (x + y) - f x = integral {0..1} (\\t. f' (x + t *\\<^sub>R y) y)\"\n by sorry\n\nlemma (in bounded_bilinear) sum_prod_derivatives_has_vector_derivative:\n assumes \"p>0\"\n and f0: \"Df 0 = f\"\n and Df: \"\\m t. m < p \\ a \\ t \\ t \\ b \\\n (Df m has_vector_derivative Df (Suc m) t) (at t within {a..b})\"\n and g0: \"Dg 0 = g\"\n and Dg: \"\\m t. m < p \\ a \\ t \\ t \\ b \\\n (Dg m has_vector_derivative Dg (Suc m) t) (at t within {a..b})\"\n and ivl: \"a \\ t\" \"t \\ b\"\n shows \"((\\t. \\iR prod (Df i t) (Dg (p - Suc i) t))\n has_vector_derivative\n prod (f t) (Dg p t) - (-1)^p *\\<^sub>R prod (Df p t) (g t))\n (at t within {a..b})\"\n by sorry\n\nlemma\n fixes f::\"real\\'a::banach\"\n assumes \"p>0\"\n and f0: \"Df 0 = f\"\n and Df: \"\\m t. m < p \\ a \\ t \\ t \\ b \\\n (Df m has_vector_derivative Df (Suc m) t) (at t within {a..b})\"\n and ivl: \"a \\ b\"\n defines \"i \\ \\x. ((b - x) ^ (p - 1) / fact (p - 1)) *\\<^sub>R Df p x\"\n shows Taylor_has_integral:\n \"(i has_integral f b - (\\iR Df i a)) {a..b}\"\n and Taylor_integral:\n \"f b = (\\iR Df i a) + integral {a..b} i\"\n and Taylor_integrable:\n \"i integrable_on {a..b}\"\n by sorry\n\nsubsection \\Only need trivial subintervals if the interval itself is trivial\\\n\nproposition division_of_nontrivial:\n fixes \\ :: \"'a::euclidean_space set set\"\n assumes sdiv: \"\\ division_of (cbox a b)\"\n and cont0: \"content (cbox a b) \\ 0\"\n shows \"{k. k \\ \\ \\ content k \\ 0} division_of (cbox a b)\"\n by sorry\n\nsubsection \\Integrability on subintervals\\\n\nlemma operative_integrableI:\n fixes f :: \"'b::euclidean_space \\ 'a::banach\"\n assumes \"0 \\ e\"\n shows \"operative conj True (\\i. f integrable_on i)\"\n by sorry" }, { "theorem_id": 25, "title": "015_the_fundamental_theorem_of_integral_calculus", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Patrick Massot, Sébastien Gouëzel\n-/\nmodule\n\npublic import Mathlib.Analysis.Calculus.Deriv.Add\npublic import Mathlib.Analysis.Calculus.Deriv.Comp\npublic import Mathlib.Analysis.Calculus.FDeriv.Measurable\npublic import Mathlib.Analysis.Normed.Module.Dual\npublic import Mathlib.MeasureTheory.Integral.Bochner.FundThmCalculus\npublic import Mathlib.MeasureTheory.Integral.Bochner.VitaliCaratheodory\npublic import Mathlib.MeasureTheory.Integral.DominatedConvergence\npublic import Mathlib.Analysis.Calculus.TangentCone.Prod\n\n/-!\n# Fundamental Theorem of Calculus\n\nWe prove various versions of the\n[fundamental theorem of calculus](https://en.wikipedia.org/wiki/Fundamental_theorem_of_calculus)\nfor interval integrals in `ℝ`.\n\nRecall that its first version states that the function `(u, v) ↦ ∫ x in u..v, f x` has derivative\n`(δu, δv) ↦ δv • f b - δu • f a` at `(a, b)` provided that `f` is continuous at `a` and `b`,\nand its second version states that, if `f` has an integrable derivative on `[a, b]`, then\n`∫ x in a..b, f' x = f b - f a`.\n\n## Main statements\n\n### FTC-1 for Lebesgue measure\n\nWe prove several versions of FTC-1, all in the `intervalIntegral` namespace. Many of them follow\nthe naming scheme `integral_has(Strict?)(F?)Deriv(Within?)At(_of_tendsto_ae?)(_right|_left?)`.\nThey formulate FTC in terms of `Has(Strict?)(F?)Deriv(Within?)At`.\nLet us explain the meaning of each part of the name:\n\n* `Strict` means that the theorem is about strict differentiability, see `HasStrictDerivAt` and\n `HasStrictFDerivAt`;\n* `F` means that the theorem is about differentiability in both endpoints; incompatible with\n `_right|_left`;\n* `Within` means that the theorem is about one-sided derivatives, see below for details;\n* `_of_tendsto_ae` means that instead of continuity the theorem assumes that `f` has a finite limit\n almost surely as `x` tends to `a` and/or `b`;\n* `_right` or `_left` mean that the theorem is about differentiability in the right (resp., left)\n endpoint.\n\nWe also reformulate these theorems in terms of `(f?)deriv(Within?)`. These theorems are named\n`(f?)deriv(Within?)_integral(_of_tendsto_ae?)(_right|_left?)` with the same meaning of parts of the\nname.\n\n### One-sided derivatives\n\nTheorem `intervalIntegral.integral_hasFDerivWithinAt_of_tendsto_ae` states that\n`(u, v) ↦ ∫ x in u..v, f x` has a derivative `(δu, δv) ↦ δv • cb - δu • ca` within the set `s × t`\nat `(a, b)` provided that `f` tends to `ca` (resp., `cb`) almost surely at `la` (resp., `lb`), where\npossible values of `s`, `t`, and corresponding filters `la`, `lb` are given in the following table.\n\n| `s` | `la` | `t` | `lb` |\n| ------- | ---- | --- | ---- |\n| `Iic a` | `𝓝[≤] a` | `Iic b` | `𝓝[≤] b` |\n| `Ici a` | `𝓝[>] a` | `Ici b` | `𝓝[>] b` |\n| `{a}` | `⊥` | `{b}` | `⊥` |\n| `univ` | `𝓝 a` | `univ` | `𝓝 b` |\n\nWe use a typeclass `intervalIntegral.FTCFilter` to make Lean automatically find `la`/`lb` based on\n`s`/`t`. This way we can formulate one theorem instead of `16` (or `8` if we leave only non-trivial\nones not covered by `integral_hasDerivWithinAt_of_tendsto_ae_(left|right)` and\n`integral_hasFDerivAt_of_tendsto_ae`). Similarly, `integral_hasDerivWithinAt_of_tendsto_ae_right`\nworks for both one-sided derivatives using the same typeclass to find an appropriate filter.\n\n### FTC for a locally finite measure\n\nBefore proving FTC for the Lebesgue measure, we prove a few statements that can be seen as FTC for\nany measure. The most general of them,\n`measure_integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae`, states the following.\nLet `(la, la')` be an `intervalIntegral.FTCFilter` pair of filters around `a` (i.e.,\n`intervalIntegral.FTCFilter a la la'`) and let `(lb, lb')` be an `intervalIntegral.FTCFilter` pair\nof filters around `b`. If `f` has finite limits `ca` and `cb` almost surely at `la'` and `lb'`,\nrespectively, then\n$$\n \\int_{va}^{vb} f ∂μ - \\int_{ua}^{ub} f ∂μ =\n \\int_{ub}^{vb} cb ∂μ - \\int_{ua}^{va} ca ∂μ + o(‖∫_{ua}^{va} 1 ∂μ‖ + ‖∫_{ub}^{vb} (1:ℝ) ∂μ‖)\n$$\nas `ua` and `va` tend to `la` while `ub` and `vb` tend to `lb`.\n\n### FTC-2 and corollaries\n\nWe use FTC-1 to prove several versions of FTC-2 for the Lebesgue measure, using a similar naming\nscheme as for the versions of FTC-1. They include:\n* `intervalIntegral.integral_eq_sub_of_hasDeriv_right_of_le` - most general version, for functions\n with a right derivative\n* `intervalIntegral.integral_eq_sub_of_hasDerivAt` - version for functions with a derivative on\n an open set\n* `intervalIntegral.integral_deriv_eq_sub'` - version that is easiest to use when computing the\n integral of a specific function\n\nMany applications of these theorems can be found in the directory\n`Mathlib/Analysis/SpecialFunctions/Integrals/`.\n\nNote that the assumptions of FTC-2 are formulated in the form that `f'` is integrable. To use it in\na context with the stronger assumption that `f'` is continuous, one can use\n`ContinuousOn.intervalIntegrable` or `ContinuousOn.integrableOn_Icc` or\n`ContinuousOn.integrableOn_uIcc`.\n\nVersions of FTC-2 under the simpler assumption that the function is `C^1` are given in the\nfile `Mathlib/MeasureTheory/Integral/IntervalIntegral/ContDiff.lean`.\n\nApplications to integration by parts are in the file\n`Mathlib.MeasureTheory.Integral.IntegrationByParts`.\n\n### `intervalIntegral.FTCFilter` class\n\nAs explained above, many theorems in this file rely on the typeclass\n`intervalIntegral.FTCFilter (a : ℝ) (l l' : Filter ℝ)` to avoid code duplication. This typeclass\ncombines four assumptions:\n\n- `pure a ≤ l`;\n- `l' ≤ 𝓝 a`;\n- `l'` has a basis of measurable sets;\n- if `u n` and `v n` tend to `l`, then for any `s ∈ l'`, `Ioc (u n) (v n)` is eventually included\n in `s`.\n\nThis typeclass has the following “real” instances: `(a, pure a, ⊥)`, `(a, 𝓝[≥] a, 𝓝[>] a)`,\n`(a, 𝓝[≤] a, 𝓝[≤] a)`, `(a, 𝓝 a, 𝓝 a)`.\nFurthermore, we have the following instances that are equal to the previously mentioned instances:\n`(a, 𝓝[{a}] a, ⊥)` and `(a, 𝓝[univ] a, 𝓝[univ] a)`.\nWhile the difference between `Ici a` and `Ioi a` doesn't matter for theorems about Lebesgue measure,\nit becomes important in the versions of FTC about any locally finite measure if this measure has an\natom at one of the endpoints.\n\n### Combining one-sided and two-sided derivatives\n\nThere are some `intervalIntegral.FTCFilter` instances where the fact that it is one-sided or\ntwo-sided depends on the point, namely `(x, 𝓝[Set.Icc a b] x, 𝓝[Set.Icc a b] x)` (resp.\n`(x, 𝓝[Set.uIcc a b] x, 𝓝[Set.uIcc a b] x)`), with `x ∈ Icc a b` (resp. `x ∈ uIcc a b`). This\nresults in a two-sided derivatives for `x ∈ Set.Ioo a b` and one-sided derivatives for `x ∈ {a, b}`.\nOther instances could be added when needed (in that case, one also needs to add instances for\n`Filter.IsMeasurablyGenerated` and `Filter.TendstoIxxClass`).\n\n## Tags\n\nintegral, fundamental theorem of calculus, FTC-1, FTC-2\n-/\n\n@[expose] public section\n\nassert_not_exists HasDerivAt.mul -- guard against import creep\n\nnoncomputable section\n\nopen MeasureTheory Set Filter Function Asymptotics\n\nopen scoped Topology ENNReal Interval NNReal\n\nvariable {ι 𝕜 E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]\n\nnamespace intervalIntegral\n\nsection FTC1\n\n/-!\n### Fundamental theorem of calculus, part 1, for any measure\n\nIn this section we prove a few lemmas that can be seen as versions of FTC-1 for interval integrals\nw.r.t. any measure. Many theorems are formulated for one or two pairs of filters related by\n`intervalIntegral.FTCFilter a l l'`. This typeclass has exactly four “real” instances:\n`(a, pure a, ⊥)`, `(a, 𝓝[≥] a, 𝓝[>] a)`, `(a, 𝓝[≤] a, 𝓝[≤] a)`, `(a, 𝓝 a, 𝓝 a)`, and two instances\nthat are equal to the first and last “real” instances: `(a, 𝓝[{a}] a, ⊥)` and\n`(a, 𝓝[univ] a, 𝓝[univ] a)`. We use this approach to avoid repeating arguments in many very similar\ncases. Lean can automatically find both `a` and `l'` based on `l`.\n\nThe most general theorem `measure_integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae` can be\nseen as a generalization of lemma `integral_hasStrictFDerivAt` below which states strict\ndifferentiability of `∫ x in u..v, f x` in `(u, v)` at `(a, b)` for a measurable function `f` that\nis integrable on `a..b` and is continuous at `a` and `b`. The lemma is generalized in three\ndirections: first, `measure_integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae` deals with any\nlocally finite measure `μ`; second, it works for one-sided limits/derivatives; third, it assumes\nonly that `f` has finite limits almost surely at `a` and `b`.\n\nNamely, let `f` be a measurable function integrable on `a..b`. Let `(la, la')` be a pair of\n`intervalIntegral.FTCFilter`s around `a`; let `(lb, lb')` be a pair of `intervalIntegral.FTCFilter`s\naround `b`. Suppose that `f` has finite limits `ca` and `cb` at `la' ⊓ ae μ` and `lb' ⊓ ae μ`,\nrespectively. Then\n`∫ x in va..vb, f x ∂μ - ∫ x in ua..ub, f x ∂μ = ∫ x in ub..vb, cb ∂μ - ∫ x in ua..va, ca ∂μ +\n o(‖∫ x in ua..va, (1:ℝ) ∂μ‖ + ‖∫ x in ub..vb, (1:ℝ) ∂μ‖)`\nas `ua` and `va` tend to `la` while `ub` and `vb` tend to `lb`.\n\nThis theorem is formulated with integral of constants instead of measures in the right-hand sides\nfor two reasons: first, this way we avoid `min`/`max` in the statements; second, often it is\npossible to write better `simp` lemmas for these integrals, see `integral_const` and\n`integral_const_of_cdf`.\n\nIn the next subsection we apply this theorem to prove various theorems about differentiability\nof the integral w.r.t. Lebesgue measure. -/\n\n/-- An auxiliary typeclass for the Fundamental theorem of calculus, part 1. It is used to formulate\ntheorems that work simultaneously for left and right one-sided derivatives of `∫ x in u..v, f x`. -/\nclass FTCFilter (a : outParam ℝ) (outer : Filter ℝ) (inner : outParam <| Filter ℝ) : Prop\n extends TendstoIxxClass Ioc outer inner where\n pure_le : pure a ≤ outer\n le_nhds : inner ≤ 𝓝 a\n [meas_gen : IsMeasurablyGenerated inner]\n\nnamespace FTCFilter\n\n\ninstance pure (a : ℝ) : FTCFilter a (pure a) ⊥ where\n pure_le := le_rfl\n le_nhds := bot_le\n\ninstance nhdsWithinSingleton (a : ℝ) : FTCFilter a (𝓝[{a}] a) ⊥ := by sorry\ntheorem finiteAt_inner {a : ℝ} (l : Filter ℝ) {l'} [h : FTCFilter a l l'] {μ : Measure ℝ}\n [IsLocallyFiniteMeasure μ] : μ.FiniteAtFilter l' :=\n (μ.finiteAt_nhds a).filter_mono h.le_nhds\n\ninstance nhds (a : ℝ) : FTCFilter a (𝓝 a) (𝓝 a) where\n pure_le := pure_le_nhds a\n le_nhds := le_rfl\n\ninstance nhdsUniv (a : ℝ) : FTCFilter a (𝓝[univ] a) (𝓝 a) := by rw [nhdsWithin_univ]; infer_instance\n\ninstance nhdsLeft (a : ℝ) : FTCFilter a (𝓝[≤] a) (𝓝[≤] a) where\n pure_le := pure_le_nhdsWithin self_mem_Iic\n le_nhds := inf_le_left\n\ninstance nhdsRight (a : ℝ) : FTCFilter a (𝓝[≥] a) (𝓝[>] a) where\n pure_le := pure_le_nhdsWithin self_mem_Ici\n le_nhds := inf_le_left\n\ninstance nhdsIcc {x a b : ℝ} [h : Fact (x ∈ Icc a b)] :\n FTCFilter x (𝓝[Icc a b] x) (𝓝[Icc a b] x) where\n pure_le := pure_le_nhdsWithin h.out\n le_nhds := inf_le_left\n\ninstance nhdsUIcc {x a b : ℝ} [h : Fact (x ∈ [[a, b]])] :\n FTCFilter x (𝓝[[[a, b]]] x) (𝓝[[[a, b]]] x) :=\n .nhdsIcc (h := h)\n\nend FTCFilter\n\nsection\n\nvariable {f : ℝ → E} {a b : ℝ} {c ca cb : E} {l l' la la' lb lb' : Filter ℝ} {lt : Filter ι}\n {μ : Measure ℝ} {u v ua va ub vb : ι → ℝ}\n\n/-- **Fundamental theorem of calculus-1**, local version for any measure.\nLet filters `l` and `l'` be related by `TendstoIxxClass Ioc`.\nIf `f` has a finite limit `c` at `l' ⊓ ae μ`, where `μ` is a measure\nfinite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both\n`u` and `v` tend to `l`.\n\nSee also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming\n`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one\nof `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version. The primed version\nalso works, e.g., for `l = l' = atTop`.\n\nWe use integrals of constants instead of measures because this way it is easier to formulate\na statement that works in both cases `u ≤ v` and `v ≤ u`. -/\ntheorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']\n [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)\n (hf : Tendsto f (l' ⊓ ae μ) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)\n (hv : Tendsto v lt l) :\n (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>\n ∫ _ in u t..v t, (1 : ℝ) ∂μ := by sorry\ntheorem measure_integral_sub_linear_isLittleO_of_tendsto_ae_of_le'\n [CompleteSpace E] [IsMeasurablyGenerated l']\n [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)\n (hf : Tendsto f (l' ⊓ ae μ) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)\n (hv : Tendsto v lt l) (huv : u ≤ᶠ[lt] v) :\n (fun t => (∫ x in u t..v t, f x ∂μ) - μ.real (Ioc (u t) (v t)) • c) =o[lt] fun t =>\n μ.real (Ioc (u t) (v t)) :=\n (measure_integral_sub_linear_isLittleO_of_tendsto_ae' hfm hf hl hu hv).congr'\n (huv.mono fun x hx => by simp [integral_const', hx])\n (huv.mono fun x hx => by simp [integral_const', hx])\n\n/-- **Fundamental theorem of calculus-1**, local version for any measure.\nLet filters `l` and `l'` be related by `TendstoIxxClass Ioc`.\nIf `f` has a finite limit `c` at `l ⊓ ae μ`, where `μ` is a measure\nfinite at `l`, then `∫ x in u..v, f x ∂μ = -μ (Ioc v u) • c + o(μ(Ioc v u))` as both\n`u` and `v` tend to `l` so that `v ≤ u`.\n\nSee also `measure_integral_sub_linear_is_o_of_tendsto_ae_of_ge` for a version assuming\n`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one\nof `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version. The primed version\nalso works, e.g., for `l = l' = Filter.atTop`. -/\ntheorem measure_integral_sub_linear_isLittleO_of_tendsto_ae_of_ge'\n [CompleteSpace E] [IsMeasurablyGenerated l']\n [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)\n (hf : Tendsto f (l' ⊓ ae μ) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)\n (hv : Tendsto v lt l) (huv : v ≤ᶠ[lt] u) :\n (fun t => (∫ x in u t..v t, f x ∂μ) + μ.real (Ioc (v t) (u t)) • c) =o[lt] fun t =>\n μ.real (Ioc (v t) (u t)) :=\n (measure_integral_sub_linear_isLittleO_of_tendsto_ae_of_le' hfm hf hl hv hu\n huv).neg_left.congr_left\n fun t => by simp [integral_symm (u t), add_comm]\n\nsection IsLocallyFiniteMeasure\n\nvariable [IsLocallyFiniteMeasure μ]\n\nvariable [FTCFilter a la la'] [FTCFilter b lb lb']\n\n/-- **Fundamental theorem of calculus-1**, local version for any measure.\n\nLet filters `l` and `l'` be related by `[intervalIntegral.FTCFilter a l l']`; let `μ` be a locally\nfinite measure. If `f` has a finite limit `c` at `l' ⊓ ae μ`, then\n`∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both `u` and `v` tend to `l`.\n\nSee also `measure_integral_sub_linear_isLittleO_of_tendsto_ae'` for a version that also works, e.g.,\nfor `l = l' = Filter.atTop`.\n\nWe use integrals of constants instead of measures because this way it is easier to formulate\na statement that works in both cases `u ≤ v` and `v ≤ u`. -/\ntheorem measure_integral_sub_linear_isLittleO_of_tendsto_ae [FTCFilter a l l']\n (hfm : StronglyMeasurableAtFilter f l' μ) (hf : Tendsto f (l' ⊓ ae μ) (𝓝 c))\n (hu : Tendsto u lt l) (hv : Tendsto v lt l) :\n (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>\n ∫ _ in u t..v t, (1 : ℝ) ∂μ :=\n haveI := FTCFilter.meas_gen l\n measure_integral_sub_linear_isLittleO_of_tendsto_ae' hfm hf (FTCFilter.finiteAt_inner l) hu hv\n\n/-- **Fundamental theorem of calculus-1**, local version for any measure.\n\nLet filters `l` and `l'` be related by `[intervalIntegral.FTCFilter a l l']`; let `μ` be a locally\nfinite measure. If `f` has a finite limit `c` at `l' ⊓ ae μ`, then\n`∫ x in u..v, f x ∂μ = μ (Ioc u v) • c + o(μ(Ioc u v))` as both `u` and `v` tend to `l`.\n\nSee also `measure_integral_sub_linear_isLittleO_of_tendsto_ae_of_le'` for a version that also works,\ne.g., for `l = l' = Filter.atTop`. -/\ntheorem measure_integral_sub_linear_isLittleO_of_tendsto_ae_of_le\n [CompleteSpace E] [FTCFilter a l l']\n (hfm : StronglyMeasurableAtFilter f l' μ) (hf : Tendsto f (l' ⊓ ae μ) (𝓝 c))\n (hu : Tendsto u lt l) (hv : Tendsto v lt l) (huv : u ≤ᶠ[lt] v) :\n (fun t => (∫ x in u t..v t, f x ∂μ) - μ.real (Ioc (u t) (v t)) • c) =o[lt] fun t =>\n μ.real (Ioc (u t) (v t)) :=\n haveI := FTCFilter.meas_gen l\n measure_integral_sub_linear_isLittleO_of_tendsto_ae_of_le' hfm hf (FTCFilter.finiteAt_inner l) hu\n hv huv\n\n/-- **Fundamental theorem of calculus-1**, local version for any measure.\n\nLet filters `l` and `l'` be related by `[intervalIntegral.FTCFilter a l l']`; let `μ` be a locally\nfinite measure. If `f` has a finite limit `c` at `l' ⊓ ae μ`, then\n`∫ x in u..v, f x ∂μ = -μ (Set.Ioc v u) • c + o(μ(Set.Ioc v u))` as both `u` and `v` tend to `l`.\n\nSee also `measure_integral_sub_linear_isLittleO_of_tendsto_ae_of_ge'` for a version that also works,\ne.g., for `l = l' = Filter.atTop`. -/\ntheorem measure_integral_sub_linear_isLittleO_of_tendsto_ae_of_ge\n [CompleteSpace E] [FTCFilter a l l']\n (hfm : StronglyMeasurableAtFilter f l' μ) (hf : Tendsto f (l' ⊓ ae μ) (𝓝 c))\n (hu : Tendsto u lt l) (hv : Tendsto v lt l) (huv : v ≤ᶠ[lt] u) :\n (fun t => (∫ x in u t..v t, f x ∂μ) + μ.real (Ioc (v t) (u t)) • c) =o[lt] fun t =>\n μ.real (Ioc (v t) (u t)) :=\n haveI := FTCFilter.meas_gen l\n measure_integral_sub_linear_isLittleO_of_tendsto_ae_of_ge' hfm hf (FTCFilter.finiteAt_inner l) hu\n hv huv\n\n/-- **Fundamental theorem of calculus-1**, strict derivative in both limits for a locally finite\nmeasure.\n\nLet `f` be a measurable function integrable on `a..b`. Let `(la, la')` be a pair of\n`intervalIntegral.FTCFilter`s around `a`; let `(lb, lb')` be a pair of `intervalIntegral.FTCFilter`s\naround `b`. Suppose that `f` has finite limits `ca` and `cb` at `la' ⊓ ae μ` and `lb' ⊓ ae μ`,\nrespectively.\nThen `∫ x in va..vb, f x ∂μ - ∫ x in ua..ub, f x ∂μ =\n ∫ x in ub..vb, cb ∂μ - ∫ x in ua..va, ca ∂μ +\n o(‖∫ x in ua..va, (1:ℝ) ∂μ‖ + ‖∫ x in ub..vb, (1:ℝ) ∂μ‖)`\nas `ua` and `va` tend to `la` while `ub` and `vb` tend to `lb`.\n-/\ntheorem measure_integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae\n (hab : IntervalIntegrable f μ a b) (hmeas_a : StronglyMeasurableAtFilter f la' μ)\n (hmeas_b : StronglyMeasurableAtFilter f lb' μ) (ha_lim : Tendsto f (la' ⊓ ae μ) (𝓝 ca))\n (hb_lim : Tendsto f (lb' ⊓ ae μ) (𝓝 cb)) (hua : Tendsto ua lt la) (hva : Tendsto va lt la)\n (hub : Tendsto ub lt lb) (hvb : Tendsto vb lt lb) :\n (fun t =>\n ((∫ x in va t..vb t, f x ∂μ) - ∫ x in ua t..ub t, f x ∂μ) -\n ((∫ _ in ub t..vb t, cb ∂μ) - ∫ _ in ua t..va t, ca ∂μ)) =o[lt]\n fun t => ‖∫ _ in ua t..va t, (1 : ℝ) ∂μ‖ + ‖∫ _ in ub t..vb t, (1 : ℝ) ∂μ‖ := by sorry\ntheorem measure_integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae_right\n (hab : IntervalIntegrable f μ a b) (hmeas : StronglyMeasurableAtFilter f lb' μ)\n (hf : Tendsto f (lb' ⊓ ae μ) (𝓝 c)) (hu : Tendsto u lt lb) (hv : Tendsto v lt lb) :\n (fun t => ((∫ x in a..v t, f x ∂μ) - ∫ x in a..u t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt]\n fun t => ∫ _ in u t..v t, (1 : ℝ) ∂μ := by sorry\ntheorem measure_integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae_left\n (hab : IntervalIntegrable f μ a b) (hmeas : StronglyMeasurableAtFilter f la' μ)\n (hf : Tendsto f (la' ⊓ ae μ) (𝓝 c)) (hu : Tendsto u lt la) (hv : Tendsto v lt la) :\n (fun t => ((∫ x in v t..b, f x ∂μ) - ∫ x in u t..b, f x ∂μ) + ∫ _ in u t..v t, c ∂μ) =o[lt]\n fun t => ∫ _ in u t..v t, (1 : ℝ) ∂μ := by sorry\nend IsLocallyFiniteMeasure\n\nend\n\n/-!\n### Fundamental theorem of calculus-1 for Lebesgue measure\n\nIn this section we restate theorems from the previous section for Lebesgue measure.\nIn particular, we prove that `∫ x in u..v, f x` is strictly differentiable in `(u, v)`\nat `(a, b)` provided that `f` is integrable on `a..b` and is continuous at `a` and `b`.\n-/\n\n\nvariable [CompleteSpace E]\n {f : ℝ → E} {c ca cb : E} {l l' la la' lb lb' : Filter ℝ} {lt : Filter ι} {a b : ℝ}\n {u v ua ub va vb : ι → ℝ} [FTCFilter a la la'] [FTCFilter b lb lb']\n\n/-!\n#### Auxiliary `Asymptotics.IsLittleO` statements\n\nIn this section we prove several lemmas that can be interpreted as strict differentiability of\n`(u, v) ↦ ∫ x in u..v, f x ∂μ` in `u` and/or `v` at a filter. The statements use\n`Asymptotics.isLittleO` because we have no definition of `HasStrict(F)DerivAtFilter` in the library.\n-/\n\n\n/-- **Fundamental theorem of calculus-1**, local version.\n\nIf `f` has a finite limit `c` almost surely at `l'`, where `(l, l')` is an\n`intervalIntegral.FTCFilter` pair around `a`, then `∫ x in u..v, f x ∂μ = (v - u) • c + o (v - u)`\nas both `u` and `v` tend to `l`. -/\ntheorem integral_sub_linear_isLittleO_of_tendsto_ae [FTCFilter a l l']\n (hfm : StronglyMeasurableAtFilter f l') (hf : Tendsto f (l' ⊓ ae volume) (𝓝 c)) {u v : ι → ℝ}\n (hu : Tendsto u lt l) (hv : Tendsto v lt l) :\n (fun t => (∫ x in u t..v t, f x) - (v t - u t) • c) =o[lt] (v - u) := by sorry\ntheorem integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae\n (hab : IntervalIntegrable f volume a b) (hmeas_a : StronglyMeasurableAtFilter f la')\n (hmeas_b : StronglyMeasurableAtFilter f lb') (ha_lim : Tendsto f (la' ⊓ ae volume) (𝓝 ca))\n (hb_lim : Tendsto f (lb' ⊓ ae volume) (𝓝 cb)) (hua : Tendsto ua lt la) (hva : Tendsto va lt la)\n (hub : Tendsto ub lt lb) (hvb : Tendsto vb lt lb) :\n (fun t =>\n ((∫ x in va t..vb t, f x) - ∫ x in ua t..ub t, f x) -\n ((vb t - ub t) • cb - (va t - ua t) • ca)) =o[lt]\n fun t => ‖va t - ua t‖ + ‖vb t - ub t‖ := by sorry\ntheorem integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae_right\n (hab : IntervalIntegrable f volume a b) (hmeas : StronglyMeasurableAtFilter f lb')\n (hf : Tendsto f (lb' ⊓ ae volume) (𝓝 c)) (hu : Tendsto u lt lb) (hv : Tendsto v lt lb) :\n (fun t => ((∫ x in a..v t, f x) - ∫ x in a..u t, f x) - (v t - u t) • c) =o[lt] (v - u) := by sorry\ntheorem integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae_left\n (hab : IntervalIntegrable f volume a b) (hmeas : StronglyMeasurableAtFilter f la')\n (hf : Tendsto f (la' ⊓ ae volume) (𝓝 c)) (hu : Tendsto u lt la) (hv : Tendsto v lt la) :\n (fun t => ((∫ x in v t..b, f x) - ∫ x in u t..b, f x) + (v t - u t) • c) =o[lt] (v - u) := by sorry\nopen ContinuousLinearMap (fst snd smulRight sub_apply smulRight_apply coe_fst' coe_snd' map_sub)\n\n/-!\n#### Strict differentiability\n\nIn this section we prove that for a measurable function `f` integrable on `a..b`,\n\n* `integral_hasStrictFDerivAt_of_tendsto_ae`: the function `(u, v) ↦ ∫ x in u..v, f x` has\n derivative `(u, v) ↦ v • cb - u • ca` at `(a, b)` in the sense of strict differentiability\n provided that `f` tends to `ca` and `cb` almost surely as `x` tends to `a` and `b`,\n respectively;\n\n* `integral_hasStrictFDerivAt`: the function `(u, v) ↦ ∫ x in u..v, f x` has\n derivative `(u, v) ↦ v • f b - u • f a` at `(a, b)` in the sense of strict differentiability\n provided that `f` is continuous at `a` and `b`;\n\n* `integral_hasStrictDerivAt_of_tendsto_ae_right`: the function `u ↦ ∫ x in a..u, f x` has\n derivative `c` at `b` in the sense of strict differentiability provided that `f` tends to `c`\n almost surely as `x` tends to `b`;\n\n* `integral_hasStrictDerivAt_right`: the function `u ↦ ∫ x in a..u, f x` has derivative `f b` at\n `b` in the sense of strict differentiability provided that `f` is continuous at `b`;\n\n* `integral_hasStrictDerivAt_of_tendsto_ae_left`: the function `u ↦ ∫ x in u..b, f x` has\n derivative `-c` at `a` in the sense of strict differentiability provided that `f` tends to `c`\n almost surely as `x` tends to `a`;\n\n* `integral_hasStrictDerivAt_left`: the function `u ↦ ∫ x in u..b, f x` has derivative `-f a` at\n `a` in the sense of strict differentiability provided that `f` is continuous at `a`.\n-/\n\n\n/-- **Fundamental theorem of calculus-1**, strict differentiability in both endpoints.\n\nIf `f : ℝ → E` is integrable on `a..b` and `f x` has finite limits `ca` and `cb` almost surely as\n`x` tends to `a` and `b`, respectively, then\n`(u, v) ↦ ∫ x in u..v, f x` has derivative `(u, v) ↦ v • cb - u • ca` at `(a, b)`\nin the sense of strict differentiability. -/\ntheorem integral_hasStrictFDerivAt_of_tendsto_ae (hf : IntervalIntegrable f volume a b)\n (hmeas_a : StronglyMeasurableAtFilter f (𝓝 a)) (hmeas_b : StronglyMeasurableAtFilter f (𝓝 b))\n (ha : Tendsto f (𝓝 a ⊓ ae volume) (𝓝 ca)) (hb : Tendsto f (𝓝 b ⊓ ae volume) (𝓝 cb)) :\n HasStrictFDerivAt (fun p : ℝ × ℝ => ∫ x in p.1..p.2, f x)\n ((snd ℝ ℝ ℝ).smulRight cb - (fst ℝ ℝ ℝ).smulRight ca) (a, b) := by sorry\ntheorem integral_hasStrictFDerivAt (hf : IntervalIntegrable f volume a b)\n (hmeas_a : StronglyMeasurableAtFilter f (𝓝 a)) (hmeas_b : StronglyMeasurableAtFilter f (𝓝 b))\n (ha : ContinuousAt f a) (hb : ContinuousAt f b) :\n HasStrictFDerivAt (fun p : ℝ × ℝ => ∫ x in p.1..p.2, f x)\n ((snd ℝ ℝ ℝ).smulRight (f b) - (fst ℝ ℝ ℝ).smulRight (f a)) (a, b) :=\n integral_hasStrictFDerivAt_of_tendsto_ae hf hmeas_a hmeas_b (ha.mono_left inf_le_left)\n (hb.mono_left inf_le_left)\n\n/-- **Fundamental theorem of calculus-1**, strict differentiability in the right endpoint.\n\nIf `f : ℝ → E` is integrable on `a..b` and `f x` has a finite limit `c` almost surely at `b`, then\n`u ↦ ∫ x in a..u, f x` has derivative `c` at `b` in the sense of strict differentiability. -/\ntheorem integral_hasStrictDerivAt_of_tendsto_ae_right (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 b)) (hb : Tendsto f (𝓝 b ⊓ ae volume) (𝓝 c)) :\n HasStrictDerivAt (fun u => ∫ x in a..u, f x) c b :=\n .of_isLittleO <|\n integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae_right hf hmeas hb continuousAt_snd\n continuousAt_fst\n\n/-- **Fundamental theorem of calculus-1**, strict differentiability in the right endpoint.\n\nIf `f : ℝ → E` is integrable on `a..b` and `f` is continuous at `b`, then `u ↦ ∫ x in a..u, f x` has\nderivative `f b` at `b` in the sense of strict differentiability. -/\ntheorem integral_hasStrictDerivAt_right (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 b)) (hb : ContinuousAt f b) :\n HasStrictDerivAt (fun u => ∫ x in a..u, f x) (f b) b :=\n integral_hasStrictDerivAt_of_tendsto_ae_right hf hmeas (hb.mono_left inf_le_left)\n\n/-- **Fundamental theorem of calculus-1**, strict differentiability in the left endpoint.\n\nIf `f : ℝ → E` is integrable on `a..b` and `f x` has a finite limit `c` almost surely at `a`, then\n`u ↦ ∫ x in u..b, f x` has derivative `-c` at `a` in the sense of strict differentiability. -/\ntheorem integral_hasStrictDerivAt_of_tendsto_ae_left (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 a)) (ha : Tendsto f (𝓝 a ⊓ ae volume) (𝓝 c)) :\n HasStrictDerivAt (fun u => ∫ x in u..b, f x) (-c) a := by sorry\ntheorem integral_hasStrictDerivAt_left (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 a)) (ha : ContinuousAt f a) :\n HasStrictDerivAt (fun u => ∫ x in u..b, f x) (-f a) a := by sorry\ntheorem _root_.Continuous.integral_hasStrictDerivAt {f : ℝ → E} (hf : Continuous f) (a b : ℝ) :\n HasStrictDerivAt (fun u => ∫ x : ℝ in a..u, f x) (f b) b :=\n integral_hasStrictDerivAt_right (hf.intervalIntegrable _ _) (hf.stronglyMeasurableAtFilter _ _)\n hf.continuousAt\n\n/-- **Fundamental theorem of calculus-1**, derivative in the right endpoint.\n\nIf `f : ℝ → E` is continuous, then the derivative of `u ↦ ∫ x in a..u, f x` at `b` is `f b`. -/\ntheorem _root_.Continuous.deriv_integral (f : ℝ → E) (hf : Continuous f) (a b : ℝ) :\n deriv (fun u => ∫ x : ℝ in a..u, f x) b = f b :=\n (hf.integral_hasStrictDerivAt a b).hasDerivAt.deriv\n\n/-!\n#### Fréchet differentiability\n\nIn this subsection we restate results from the previous subsection in terms of `HasFDerivAt`,\n`HasDerivAt`, `fderiv`, and `deriv`.\n-/\n\n\n/-- **Fundamental theorem of calculus-1**: if `f : ℝ → E` is integrable on `a..b` and `f x` has\nfinite limits `ca` and `cb` almost surely as `x` tends to `a` and `b`, respectively, then\n`(u, v) ↦ ∫ x in u..v, f x` has derivative `(u, v) ↦ v • cb - u • ca` at `(a, b)`. -/\ntheorem integral_hasFDerivAt_of_tendsto_ae (hf : IntervalIntegrable f volume a b)\n (hmeas_a : StronglyMeasurableAtFilter f (𝓝 a)) (hmeas_b : StronglyMeasurableAtFilter f (𝓝 b))\n (ha : Tendsto f (𝓝 a ⊓ ae volume) (𝓝 ca)) (hb : Tendsto f (𝓝 b ⊓ ae volume) (𝓝 cb)) :\n HasFDerivAt (fun p : ℝ × ℝ => ∫ x in p.1..p.2, f x)\n ((snd ℝ ℝ ℝ).smulRight cb - (fst ℝ ℝ ℝ).smulRight ca) (a, b) :=\n (integral_hasStrictFDerivAt_of_tendsto_ae hf hmeas_a hmeas_b ha hb).hasFDerivAt\n\n/-- **Fundamental theorem of calculus-1**: if `f : ℝ → E` is integrable on `a..b` and `f` is\ncontinuous at `a` and `b`, then `(u, v) ↦ ∫ x in u..v, f x` has derivative `(u, v) ↦ v • cb - u •\nca` at `(a, b)`. -/\ntheorem integral_hasFDerivAt (hf : IntervalIntegrable f volume a b)\n (hmeas_a : StronglyMeasurableAtFilter f (𝓝 a)) (hmeas_b : StronglyMeasurableAtFilter f (𝓝 b))\n (ha : ContinuousAt f a) (hb : ContinuousAt f b) :\n HasFDerivAt (fun p : ℝ × ℝ => ∫ x in p.1..p.2, f x)\n ((snd ℝ ℝ ℝ).smulRight (f b) - (fst ℝ ℝ ℝ).smulRight (f a)) (a, b) :=\n (integral_hasStrictFDerivAt hf hmeas_a hmeas_b ha hb).hasFDerivAt\n\n/-- **Fundamental theorem of calculus-1**: if `f : ℝ → E` is integrable on `a..b` and `f x` has\nfinite limits `ca` and `cb` almost surely as `x` tends to `a` and `b`, respectively, then `fderiv`\nderivative of `(u, v) ↦ ∫ x in u..v, f x` at `(a, b)` equals `(u, v) ↦ v • cb - u • ca`. -/\ntheorem fderiv_integral_of_tendsto_ae (hf : IntervalIntegrable f volume a b)\n (hmeas_a : StronglyMeasurableAtFilter f (𝓝 a)) (hmeas_b : StronglyMeasurableAtFilter f (𝓝 b))\n (ha : Tendsto f (𝓝 a ⊓ ae volume) (𝓝 ca)) (hb : Tendsto f (𝓝 b ⊓ ae volume) (𝓝 cb)) :\n fderiv ℝ (fun p : ℝ × ℝ => ∫ x in p.1..p.2, f x) (a, b) =\n (snd ℝ ℝ ℝ).smulRight cb - (fst ℝ ℝ ℝ).smulRight ca :=\n (integral_hasFDerivAt_of_tendsto_ae hf hmeas_a hmeas_b ha hb).fderiv\n\n/-- **Fundamental theorem of calculus-1**: if `f : ℝ → E` is integrable on `a..b` and `f` is\ncontinuous at `a` and `b`, then `fderiv` derivative of `(u, v) ↦ ∫ x in u..v, f x` at `(a, b)`\nequals `(u, v) ↦ v • cb - u • ca`. -/\ntheorem fderiv_integral (hf : IntervalIntegrable f volume a b)\n (hmeas_a : StronglyMeasurableAtFilter f (𝓝 a)) (hmeas_b : StronglyMeasurableAtFilter f (𝓝 b))\n (ha : ContinuousAt f a) (hb : ContinuousAt f b) :\n fderiv ℝ (fun p : ℝ × ℝ => ∫ x in p.1..p.2, f x) (a, b) =\n (snd ℝ ℝ ℝ).smulRight (f b) - (fst ℝ ℝ ℝ).smulRight (f a) :=\n (integral_hasFDerivAt hf hmeas_a hmeas_b ha hb).fderiv\n\n/-- **Fundamental theorem of calculus-1**: if `f : ℝ → E` is integrable on `a..b` and `f x` has a\nfinite limit `c` almost surely at `b`, then `u ↦ ∫ x in a..u, f x` has derivative `c` at `b`. -/\ntheorem integral_hasDerivAt_of_tendsto_ae_right (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 b)) (hb : Tendsto f (𝓝 b ⊓ ae volume) (𝓝 c)) :\n HasDerivAt (fun u => ∫ x in a..u, f x) c b :=\n (integral_hasStrictDerivAt_of_tendsto_ae_right hf hmeas hb).hasDerivAt\n\n/-- **Fundamental theorem of calculus-1**: if `f : ℝ → E` is integrable on `a..b` and `f` is\ncontinuous at `b`, then `u ↦ ∫ x in a..u, f x` has derivative `f b` at `b`. -/\ntheorem integral_hasDerivAt_right (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 b)) (hb : ContinuousAt f b) :\n HasDerivAt (fun u => ∫ x in a..u, f x) (f b) b :=\n (integral_hasStrictDerivAt_right hf hmeas hb).hasDerivAt\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f` has a finite\nlimit `c` almost surely at `b`, then the derivative of `u ↦ ∫ x in a..u, f x` at `b` equals `c`. -/\ntheorem deriv_integral_of_tendsto_ae_right (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 b)) (hb : Tendsto f (𝓝 b ⊓ ae volume) (𝓝 c)) :\n deriv (fun u => ∫ x in a..u, f x) b = c :=\n (integral_hasDerivAt_of_tendsto_ae_right hf hmeas hb).deriv\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f` is continuous\nat `b`, then the derivative of `u ↦ ∫ x in a..u, f x` at `b` equals `f b`. -/\ntheorem deriv_integral_right (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 b)) (hb : ContinuousAt f b) :\n deriv (fun u => ∫ x in a..u, f x) b = f b :=\n (integral_hasDerivAt_right hf hmeas hb).deriv\n\n/-- **Fundamental theorem of calculus-1**: if `f : ℝ → E` is integrable on `a..b` and `f x` has a\nfinite limit `c` almost surely at `a`, then `u ↦ ∫ x in u..b, f x` has derivative `-c` at `a`. -/\ntheorem integral_hasDerivAt_of_tendsto_ae_left (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 a)) (ha : Tendsto f (𝓝 a ⊓ ae volume) (𝓝 c)) :\n HasDerivAt (fun u => ∫ x in u..b, f x) (-c) a :=\n (integral_hasStrictDerivAt_of_tendsto_ae_left hf hmeas ha).hasDerivAt\n\n/-- **Fundamental theorem of calculus-1**: if `f : ℝ → E` is integrable on `a..b` and `f` is\ncontinuous at `a`, then `u ↦ ∫ x in u..b, f x` has derivative `-f a` at `a`. -/\ntheorem integral_hasDerivAt_left (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 a)) (ha : ContinuousAt f a) :\n HasDerivAt (fun u => ∫ x in u..b, f x) (-f a) a :=\n (integral_hasStrictDerivAt_left hf hmeas ha).hasDerivAt\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f` has a finite\nlimit `c` almost surely at `a`, then the derivative of `u ↦ ∫ x in u..b, f x` at `a` equals `-c`. -/\ntheorem deriv_integral_of_tendsto_ae_left (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 a)) (hb : Tendsto f (𝓝 a ⊓ ae volume) (𝓝 c)) :\n deriv (fun u => ∫ x in u..b, f x) a = -c :=\n (integral_hasDerivAt_of_tendsto_ae_left hf hmeas hb).deriv\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f` is continuous\nat `a`, then the derivative of `u ↦ ∫ x in u..b, f x` at `a` equals `-f a`. -/\ntheorem deriv_integral_left (hf : IntervalIntegrable f volume a b)\n (hmeas : StronglyMeasurableAtFilter f (𝓝 a)) (hb : ContinuousAt f a) :\n deriv (fun u => ∫ x in u..b, f x) a = -f a :=\n (integral_hasDerivAt_left hf hmeas hb).deriv\n\n/-!\n#### One-sided derivatives\n-/\n\n\n/-- Let `f` be a measurable function integrable on `a..b`. The function `(u, v) ↦ ∫ x in u..v, f x`\nhas derivative `(u, v) ↦ v • cb - u • ca` within `s × t` at `(a, b)`, where\n`s ∈ {Iic a, {a}, Ici a, univ}` and `t ∈ {Iic b, {b}, Ici b, univ}` provided that `f` tends to `ca`\nand `cb` almost surely at the filters `la` and `lb` from the following table.\n := by sorry\ntheorem integral_hasFDerivWithinAt_of_tendsto_ae (hf : IntervalIntegrable f volume a b)\n {s t : Set ℝ} [FTCFilter a (𝓝[s] a) la] [FTCFilter b (𝓝[t] b) lb]\n (hmeas_a : StronglyMeasurableAtFilter f la) (hmeas_b : StronglyMeasurableAtFilter f lb)\n (ha : Tendsto f (la ⊓ ae volume) (𝓝 ca)) (hb : Tendsto f (lb ⊓ ae volume) (𝓝 cb)) :\n HasFDerivWithinAt (fun p : ℝ × ℝ => ∫ x in p.1..p.2, f x)\n ((snd ℝ ℝ ℝ).smulRight cb - (fst ℝ ℝ ℝ).smulRight ca) (s ×ˢ t) (a, b) := by sorry\ntheorem integral_hasFDerivWithinAt (hf : IntervalIntegrable f volume a b)\n (hmeas_a : StronglyMeasurableAtFilter f la) (hmeas_b : StronglyMeasurableAtFilter f lb)\n {s t : Set ℝ} [FTCFilter a (𝓝[s] a) la] [FTCFilter b (𝓝[t] b) lb] (ha : Tendsto f la (𝓝 <| f a))\n (hb : Tendsto f lb (𝓝 <| f b)) :\n HasFDerivWithinAt (fun p : ℝ × ℝ => ∫ x in p.1..p.2, f x)\n ((snd ℝ ℝ ℝ).smulRight (f b) - (fst ℝ ℝ ℝ).smulRight (f a)) (s ×ˢ t) (a, b) :=\n integral_hasFDerivWithinAt_of_tendsto_ae hf hmeas_a hmeas_b (ha.mono_left inf_le_left)\n (hb.mono_left inf_le_left)\n\n/-- An auxiliary tactic closing goals `UniqueDiffWithinAt ℝ s a` where\n`s ∈ {Iic a, Ici a, univ}`. -/\nmacro \"uniqueDiffWithinAt_Ici_Iic_univ\" : tactic =>\n `(tactic| (first | exact uniqueDiffOn_Ici _ _ self_mem_Ici |\n exact uniqueDiffOn_Iic _ _ self_mem_Iic | exact uniqueDiffWithinAt_univ (𝕜 := ℝ) (E := ℝ)))\n\n/-- Let `f` be a measurable function integrable on `a..b`. Choose `s ∈ {Iic a, Ici a, univ}`\nand `t ∈ {Iic b, Ici b, univ}`. Suppose that `f` tends to `ca` and `cb` almost surely at the filters\n`la` and `lb` from the table below. Then `fderivWithin ℝ (fun p ↦ ∫ x in p.1..p.2, f x) (s ×ˢ t)`\nis equal to `(u, v) ↦ u • cb - v • ca`.\n := by sorry\ntheorem fderivWithin_integral_of_tendsto_ae (hf : IntervalIntegrable f volume a b)\n (hmeas_a : StronglyMeasurableAtFilter f la) (hmeas_b : StronglyMeasurableAtFilter f lb)\n {s t : Set ℝ} [FTCFilter a (𝓝[s] a) la] [FTCFilter b (𝓝[t] b) lb]\n (ha : Tendsto f (la ⊓ ae volume) (𝓝 ca)) (hb : Tendsto f (lb ⊓ ae volume) (𝓝 cb))\n (hs : UniqueDiffWithinAt ℝ s a := by uniqueDiffWithinAt_Ici_Iic_univ)\n (ht : UniqueDiffWithinAt ℝ t b := by uniqueDiffWithinAt_Ici_Iic_univ) :\n fderivWithin ℝ (fun p : ℝ × ℝ => ∫ x in p.1..p.2, f x) (s ×ˢ t) (a, b) =\n (snd ℝ ℝ ℝ).smulRight cb - (fst ℝ ℝ ℝ).smulRight ca :=\n (integral_hasFDerivWithinAt_of_tendsto_ae hf hmeas_a hmeas_b ha hb).fderivWithin <| hs.prod ht\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f x` has a finite\nlimit `c` almost surely as `x` tends to `b` from the right or from the left,\nthen `u ↦ ∫ x in a..u, f x` has right (resp., left) derivative `c` at `b`. -/\ntheorem integral_hasDerivWithinAt_of_tendsto_ae_right (hf : IntervalIntegrable f volume a b)\n {s t : Set ℝ} [FTCFilter b (𝓝[s] b) (𝓝[t] b)] (hmeas : StronglyMeasurableAtFilter f (𝓝[t] b))\n (hb : Tendsto f (𝓝[t] b ⊓ ae volume) (𝓝 c)) :\n HasDerivWithinAt (fun u => ∫ x in a..u, f x) c s b :=\n .of_isLittleO <| integral_sub_integral_sub_linear_isLittleO_of_tendsto_ae_right hf hmeas hb\n (tendsto_const_pure.mono_right FTCFilter.pure_le) tendsto_id\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f x` is continuous\nfrom the left or from the right at `b`, then `u ↦ ∫ x in a..u, f x` has left (resp., right)\nderivative `f b` at `b`. -/\ntheorem integral_hasDerivWithinAt_right (hf : IntervalIntegrable f volume a b) {s t : Set ℝ}\n [FTCFilter b (𝓝[s] b) (𝓝[t] b)] (hmeas : StronglyMeasurableAtFilter f (𝓝[t] b))\n (hb : ContinuousWithinAt f t b) : HasDerivWithinAt (fun u => ∫ x in a..u, f x) (f b) s b :=\n integral_hasDerivWithinAt_of_tendsto_ae_right hf hmeas (hb.mono_left inf_le_left)\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f x` has a finite\nlimit `c` almost surely as `x` tends to `b` from the right or from the left, then the right\n(resp., left) derivative of `u ↦ ∫ x in a..u, f x` at `b` equals `c`. -/\ntheorem derivWithin_integral_of_tendsto_ae_right (hf : IntervalIntegrable f volume a b)\n {s t : Set ℝ} [FTCFilter b (𝓝[s] b) (𝓝[t] b)] (hmeas : StronglyMeasurableAtFilter f (𝓝[t] b))\n (hb : Tendsto f (𝓝[t] b ⊓ ae volume) (𝓝 c))\n (hs : UniqueDiffWithinAt ℝ s b := by uniqueDiffWithinAt_Ici_Iic_univ) :\n derivWithin (fun u => ∫ x in a..u, f x) s b = c :=\n (integral_hasDerivWithinAt_of_tendsto_ae_right hf hmeas hb).derivWithin hs\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f x` is continuous\non the right or on the left at `b`, then the right (resp., left) derivative of\n`u ↦ ∫ x in a..u, f x` at `b` equals `f b`. -/\ntheorem derivWithin_integral_right (hf : IntervalIntegrable f volume a b) {s t : Set ℝ}\n [FTCFilter b (𝓝[s] b) (𝓝[t] b)] (hmeas : StronglyMeasurableAtFilter f (𝓝[t] b))\n (hb : ContinuousWithinAt f t b)\n (hs : UniqueDiffWithinAt ℝ s b := by uniqueDiffWithinAt_Ici_Iic_univ) :\n derivWithin (fun u => ∫ x in a..u, f x) s b = f b :=\n (integral_hasDerivWithinAt_right hf hmeas hb).derivWithin hs\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f x` has a finite\nlimit `c` almost surely as `x` tends to `a` from the right or from the left,\nthen `u ↦ ∫ x in u..b, f x` has right (resp., left) derivative `-c` at `a`. -/\ntheorem integral_hasDerivWithinAt_of_tendsto_ae_left (hf : IntervalIntegrable f volume a b)\n {s t : Set ℝ} [FTCFilter a (𝓝[s] a) (𝓝[t] a)] (hmeas : StronglyMeasurableAtFilter f (𝓝[t] a))\n (ha : Tendsto f (𝓝[t] a ⊓ ae volume) (𝓝 c)) :\n HasDerivWithinAt (fun u => ∫ x in u..b, f x) (-c) s a := by sorry\ntheorem integral_hasDerivWithinAt_left (hf : IntervalIntegrable f volume a b) {s t : Set ℝ}\n [FTCFilter a (𝓝[s] a) (𝓝[t] a)] (hmeas : StronglyMeasurableAtFilter f (𝓝[t] a))\n (ha : ContinuousWithinAt f t a) : HasDerivWithinAt (fun u => ∫ x in u..b, f x) (-f a) s a :=\n integral_hasDerivWithinAt_of_tendsto_ae_left hf hmeas (ha.mono_left inf_le_left)\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f x` has a finite\nlimit `c` almost surely as `x` tends to `a` from the right or from the left, then the right\n(resp., left) derivative of `u ↦ ∫ x in u..b, f x` at `a` equals `-c`. -/\ntheorem derivWithin_integral_of_tendsto_ae_left (hf : IntervalIntegrable f volume a b) {s t : Set ℝ}\n [FTCFilter a (𝓝[s] a) (𝓝[t] a)] (hmeas : StronglyMeasurableAtFilter f (𝓝[t] a))\n (ha : Tendsto f (𝓝[t] a ⊓ ae volume) (𝓝 c))\n (hs : UniqueDiffWithinAt ℝ s a := by uniqueDiffWithinAt_Ici_Iic_univ) :\n derivWithin (fun u => ∫ x in u..b, f x) s a = -c :=\n (integral_hasDerivWithinAt_of_tendsto_ae_left hf hmeas ha).derivWithin hs\n\n/-- Fundamental theorem of calculus: if `f : ℝ → E` is integrable on `a..b` and `f x` is continuous\non the right or on the left at `a`, then the right (resp., left) derivative of\n`u ↦ ∫ x in u..b, f x` at `a` equals `-f a`. -/\ntheorem derivWithin_integral_left (hf : IntervalIntegrable f volume a b) {s t : Set ℝ}\n [FTCFilter a (𝓝[s] a) (𝓝[t] a)] (hmeas : StronglyMeasurableAtFilter f (𝓝[t] a))\n (ha : ContinuousWithinAt f t a)\n (hs : UniqueDiffWithinAt ℝ s a := by uniqueDiffWithinAt_Ici_Iic_univ) :\n derivWithin (fun u => ∫ x in u..b, f x) s a = -f a :=\n (integral_hasDerivWithinAt_left hf hmeas ha).derivWithin hs\n\n/-- The integral of a continuous function is differentiable on a real set `s`. -/\ntheorem differentiable_integral_of_continuous (hcont : Continuous f) :\n Differentiable ℝ (fun u => ∫ x in a..u, f x) := fun _ ↦\n (integral_hasDerivAt_right (hcont.intervalIntegrable _ _)\n hcont.aestronglyMeasurable.stronglyMeasurableAtFilter hcont.continuousAt).differentiableAt\n\n/-- The integral of a continuous function is differentiable on a real set `s`. -/\ntheorem differentiableOn_integral_of_continuous {s : Set ℝ} (hcont : Continuous f) :\n DifferentiableOn ℝ (fun u => ∫ x in a..u, f x) s :=\n (differentiable_integral_of_continuous hcont).differentiableOn\n\nend FTC1\n\n/-!\n### Fundamental theorem of calculus, part 2\n\nThis section contains theorems pertaining to FTC-2 for interval integrals, i.e., the assertion\nthat `∫ x in a..b, f' x = f b - f a` under suitable assumptions.\n\nThe most classical version of this theorem assumes that `f'` is continuous. However, this is\nunnecessarily strong: the result holds if `f'` is just integrable. We prove the strong version,\nfollowing [Rudin, *Real and Complex Analysis* (Theorem 7.21)][rudin2006real]. The proof is first\ngiven for real-valued functions, and then deduced for functions with a general target space. For\na real-valued function `g`, it suffices to show that `g b - g a ≤ (∫ x in a..b, g' x) + ε` for all\npositive `ε`. To prove this, choose a lower-semicontinuous function `G'` with `g' < G'` and with\nintegral close to that of `g'` (its existence is guaranteed by the Vitali-Carathéodory theorem).\nIt satisfies `g t - g a ≤ ∫ x in a..t, G' x` for all `t ∈ [a, b]`: this inequality holds at `a`,\nand if it holds at `t` then it holds for `u` close to `t` on its right, as the left-hand side\nincreases by `g u - g t ∼ (u -t) g' t`, while the right-hand side increases by\n`∫ x in t..u, G' x` which is roughly at least `∫ x in t..u, G' t = (u - t) G' t`, by lower\nsemicontinuity. As `g' t < G' t`, this gives the conclusion. One can therefore push progressively\nthis inequality to the right until the point `b`, where it gives the desired conclusion.\n-/\n\nsection FTC2\n\nvariable {g' g φ : ℝ → ℝ} {a b : ℝ}\n\n/-- Hard part of FTC-2 for integrable derivatives, real-valued functions: one has\n`g b - g a ≤ ∫ y in a..b, g' y` when `g'` is integrable.\nAuxiliary lemma in the proof of `integral_eq_sub_of_hasDeriv_right_of_le`.\nWe give the slightly more general version that `g b - g a ≤ ∫ y in a..b, φ y` when `g' ≤ φ` and\n`φ` is integrable (even if `g'` is not known to be integrable).\nVersion assuming that `g` is differentiable on `[a, b)`. -/\ntheorem sub_le_integral_of_hasDeriv_right_of_le_Ico (hab : a ≤ b)\n (hcont : ContinuousOn g (Icc a b)) (hderiv : ∀ x ∈ Ico a b, HasDerivWithinAt g (g' x) (Ioi x) x)\n (φint : IntegrableOn φ (Icc a b)) (hφg : ∀ x ∈ Ico a b, g' x ≤ φ x) :\n g b - g a ≤ ∫ y in a..b, φ y := by sorry\ntheorem sub_le_integral_of_hasDeriv_right_of_le (hab : a ≤ b) (hcont : ContinuousOn g (Icc a b))\n (hderiv : ∀ x ∈ Ioo a b, HasDerivWithinAt g (g' x) (Ioi x) x) (φint : IntegrableOn φ (Icc a b))\n (hφg : ∀ x ∈ Ioo a b, g' x ≤ φ x) : g b - g a ≤ ∫ y in a..b, φ y := by sorry\ntheorem integral_le_sub_of_hasDeriv_right_of_le (hab : a ≤ b) (hcont : ContinuousOn g (Icc a b))\n (hderiv : ∀ x ∈ Ioo a b, HasDerivWithinAt g (g' x) (Ioi x) x) (φint : IntegrableOn φ (Icc a b))\n (hφg : ∀ x ∈ Ioo a b, φ x ≤ g' x) : (∫ y in a..b, φ y) ≤ g b - g a := by sorry\ntheorem integral_eq_sub_of_hasDeriv_right_of_le_real (hab : a ≤ b)\n (hcont : ContinuousOn g (Icc a b)) (hderiv : ∀ x ∈ Ioo a b, HasDerivWithinAt g (g' x) (Ioi x) x)\n (g'int : IntegrableOn g' (Icc a b)) : ∫ y in a..b, g' y = g b - g a :=\n le_antisymm (integral_le_sub_of_hasDeriv_right_of_le hab hcont hderiv g'int fun _ _ => le_rfl)\n (sub_le_integral_of_hasDeriv_right_of_le hab hcont hderiv g'int fun _ _ => le_rfl)\n\nvariable [CompleteSpace E] {f f' : ℝ → E}\n\n/-- **Fundamental theorem of calculus-2**: If `f : ℝ → E` is continuous on `[a, b]` (where `a ≤ b`)\n and has a right derivative at `f' x` for all `x` in `(a, b)`, and `f'` is integrable on `[a, b]`,\n then `∫ y in a..b, f' y` equals `f b - f a`. -/\ntheorem integral_eq_sub_of_hasDeriv_right_of_le (hab : a ≤ b) (hcont : ContinuousOn f (Icc a b))\n (hderiv : ∀ x ∈ Ioo a b, HasDerivWithinAt f (f' x) (Ioi x) x)\n (f'int : IntervalIntegrable f' volume a b) : ∫ y in a..b, f' y = f b - f a := by sorry\ntheorem integral_eq_sub_of_hasDeriv_right (hcont : ContinuousOn f (uIcc a b))\n (hderiv : ∀ x ∈ Ioo (min a b) (max a b), HasDerivWithinAt f (f' x) (Ioi x) x)\n (hint : IntervalIntegrable f' volume a b) : ∫ y in a..b, f' y = f b - f a := by sorry\ntheorem integral_eq_sub_of_hasDerivAt_of_le (hab : a ≤ b) (hcont : ContinuousOn f (Icc a b))\n (hderiv : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x) (hint : IntervalIntegrable f' volume a b) :\n ∫ y in a..b, f' y = f b - f a :=\n integral_eq_sub_of_hasDeriv_right_of_le hab hcont (fun x hx => (hderiv x hx).hasDerivWithinAt)\n hint\n\n/-- Fundamental theorem of calculus-2: If `f : ℝ → E` has a derivative at `f' x` for all `x` in\n `[a, b]` and `f'` is integrable on `[a, b]`, then `∫ y in a..b, f' y` equals `f b - f a`. -/\ntheorem integral_eq_sub_of_hasDerivAt (hderiv : ∀ x ∈ uIcc a b, HasDerivAt f (f' x) x)\n (hint : IntervalIntegrable f' volume a b) : ∫ y in a..b, f' y = f b - f a :=\n integral_eq_sub_of_hasDeriv_right (HasDerivAt.continuousOn hderiv)\n (fun _x hx => (hderiv _ (mem_Icc_of_Ioo hx)).hasDerivWithinAt) hint\n\ntheorem integral_eq_sub_of_hasDerivAt_of_tendsto (hab : a < b) {fa fb}\n (hderiv : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x) (hint : IntervalIntegrable f' volume a b)\n (ha : Tendsto f (𝓝[>] a) (𝓝 fa)) (hb : Tendsto f (𝓝[<] b) (𝓝 fb)) :\n ∫ y in a..b, f' y = fb - fa := by sorry\ntheorem integral_deriv_eq_sub (hderiv : ∀ x ∈ [[a, b]], DifferentiableAt ℝ f x)\n (hint : IntervalIntegrable (deriv f) volume a b) : ∫ y in a..b, deriv f y = f b - f a :=\n integral_eq_sub_of_hasDerivAt (fun x hx => (hderiv x hx).hasDerivAt) hint\n\ntheorem integral_deriv_eq_sub' (f) (hderiv : deriv f = f')\n (hdiff : ∀ x ∈ uIcc a b, DifferentiableAt ℝ f x) (hcont : ContinuousOn f' (uIcc a b)) :\n ∫ y in a..b, f' y = f b - f a := by sorry\ntheorem integral_deriv_eq_sub_uIoo\n (hcont : ContinuousOn f [[a, b]]) (hderiv : ∀ x ∈ uIoo a b, DifferentiableAt ℝ f x)\n (hint : IntervalIntegrable (deriv f) volume a b) : ∫ y in a..b, deriv f y = f b - f a := by sorry\nlemma integral_unitInterval_deriv_eq_sub [RCLike 𝕜] [NormedSpace 𝕜 E] [IsScalarTower ℝ 𝕜 E]\n {f f' : 𝕜 → E} {z₀ z₁ : 𝕜}\n (hcont : ContinuousOn (fun t : ℝ ↦ f' (z₀ + t • z₁)) (Set.Icc 0 1))\n (hderiv : ∀ t ∈ Set.Icc (0 : ℝ) 1, HasDerivAt f (f' (z₀ + t • z₁)) (z₀ + t • z₁)) :\n z₁ • ∫ t in (0 : ℝ)..1, f' (z₀ + t • z₁) = f (z₀ + z₁) - f z₀ := by sorry\ntheorem integrableOn_deriv_right_of_nonneg (hcont : ContinuousOn g (Icc a b))\n (hderiv : ∀ x ∈ Ioo a b, HasDerivWithinAt g (g' x) (Ioi x) x)\n (g'pos : ∀ x ∈ Ioo a b, 0 ≤ g' x) : IntegrableOn g' (Ioc a b) := by sorry\ntheorem integrableOn_deriv_of_nonneg (hcont : ContinuousOn g (Icc a b))\n (hderiv : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x) (g'pos : ∀ x ∈ Ioo a b, 0 ≤ g' x) :\n IntegrableOn g' (Ioc a b) :=\n integrableOn_deriv_right_of_nonneg hcont (fun x hx => (hderiv x hx).hasDerivWithinAt) g'pos\n\n/-- When the derivative of a function is nonnegative, then it is automatically integrable,\ninterval version. -/\ntheorem intervalIntegrable_deriv_of_nonneg (hcont : ContinuousOn g (uIcc a b))\n (hderiv : ∀ x ∈ Ioo (min a b) (max a b), HasDerivAt g (g' x) x)\n (hpos : ∀ x ∈ Ioo (min a b) (max a b), 0 ≤ g' x) : IntervalIntegrable g' volume a b := by sorry\nend FTC2\n\nend intervalIntegral\n" }, { "theorem_id": 25, "title": "015_the_fundamental_theorem_of_integral_calculus", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Export CoRN.ftc.MoreIntegrals.\nRequire Export CoRN.ftc.CalculusTheorems.\n\nOpaque Min.\n\nSection Indefinite_Integral." }, { "theorem_id": 26, "title": "017_de_moivre_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/measure.ml\";;\nneeds \"Multivariate/canal.ml\";;\n\nprioritize_complex();;\n\nlet cexp = new_definition\n `cexp z = infsum (from 0) (\\n. z pow n / Cx(&(FACT n)))`;;\n\nlet CEXP_0 = `cexp(Cx(&0)) = Cx(&1)`;;\n\nlet CEXP_CONVERGES_UNIFORMLY_CAUCHY = `!R e. &0 < e /\\ &0 < R\n ==> ?N. !m n z. m >= N /\\ norm(z) <= R\n ==> norm(vsum(m..n) (\\i. z pow i / Cx(&(FACT i))))\n < e`;;\n\nlet CEXP_CONVERGES = `!z. ((\\n. z pow n / Cx(&(FACT n))) sums cexp(z)) (from 0)`;;\n\nlet CEXP_CONVERGES_UNIQUE = `!w z. ((\\n. z pow n / Cx(&(FACT n))) sums w) (from 0) <=> w = cexp(z)`;;\n\nlet CEXP_CONVERGES_UNIFORMLY = `!R e. &0 < R /\\ &0 < e\n ==> ?N. !n z. n >= N /\\ norm(z) < R\n ==> norm(vsum(0..n) (\\i. z pow i / Cx(&(FACT i))) -\n cexp(z)) <= e`;;\n\nlet HAS_COMPLEX_DERIVATIVE_CEXP = `!z. (cexp has_complex_derivative cexp(z)) (at z)`;;\n\nlet COMPLEX_DIFFERENTIABLE_AT_CEXP = `!z. cexp complex_differentiable at z`;;\n\nlet COMPLEX_DIFFERENTIABLE_WITHIN_CEXP = `!s z. cexp complex_differentiable (at z within s)`;;\n\nlet CONTINUOUS_AT_CEXP = `!z. cexp continuous at z`;;\n\nlet CONTINUOUS_WITHIN_CEXP = `!s z. cexp continuous (at z within s)`;;\n\nlet CONTINUOUS_ON_CEXP = `!s. cexp continuous_on s`;;\n\nlet HOLOMORPHIC_ON_CEXP = `!s. cexp holomorphic_on s`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN_UNIV\n HAS_COMPLEX_DERIVATIVE_CEXP)));;\n\nlet CEXP_ADD_MUL = `!w z. cexp(w + z) * cexp(--z) = cexp(w)`;;\n\nlet CEXP_NEG_RMUL = `!z. cexp(z) * cexp(--z) = Cx(&1)`;;\n\nlet CEXP_NEG_LMUL = `!z. cexp(--z) * cexp(z) = Cx(&1)`;;\n\nlet CEXP_NEG = `!z. cexp(--z) = inv(cexp z)`;;\n\nlet CEXP_ADD = `!w z. cexp(w + z) = cexp(w) * cexp(z)`;;\n\nlet CEXP_SUB = `!w z. cexp(w - z) = cexp(w) / cexp(z)`;;\n\nlet CEXP_NZ = `!z. ~(cexp(z) = Cx(&0))`;;\n\nlet CEXP_N = `!n x. cexp(Cx(&n) * x) = cexp(x) pow n`;;\n\nlet CEXP_VSUM = `!f s. FINITE s ==> cexp(vsum s f) = cproduct s (\\x. cexp(f x))`;;\n\nlet LIM_CEXP_MINUS_1 = `((\\z. (cexp(z) - Cx(&1)) / z) --> Cx(&1)) (at (Cx(&0)))`;;\n\nlet CEXP_BOUND_BLEMMA = `!B. (!z. norm(z) <= &1 / &2 ==> norm(cexp z) <= B)\n ==> !z. norm(z) <= &1 / &2 ==> norm(cexp z) <= &1 + B / &2`;;\n\nlet CEXP_BOUND_HALF = `!z. norm(z) <= &1 / &2 ==> norm(cexp z) <= &2`;;\n\nlet CEXP_BOUND_LEMMA = `!z. norm(z) <= &1 / &2 ==> norm(cexp z) <= &1 + &2 * norm(z)`;;\n\nlet ccos = new_definition\n `ccos z = (cexp(ii * z) + cexp(--ii * z)) / Cx(&2)`;;\n\nlet csin = new_definition\n `csin z = (cexp(ii * z) - cexp(--ii * z)) / (Cx(&2) * ii)`;;\n\nlet CSIN_0 = `csin(Cx(&0)) = Cx(&0)`;;\n\nlet CCOS_0 = `ccos(Cx(&0)) = Cx(&1)`;;\n\nlet CSIN_CIRCLE = `!z. csin(z) pow 2 + ccos(z) pow 2 = Cx(&1)`;;\n\nlet CSIN_ADD = `!w z. csin(w + z) = csin(w) * ccos(z) + ccos(w) * csin(z)`;;\n\nlet CCOS_ADD = `!w z. ccos(w + z) = ccos(w) * ccos(z) - csin(w) * csin(z)`;;\n\nlet CSIN_NEG = `!z. csin(--z) = --(csin(z))`;;\n\nlet CCOS_NEG = `!z. ccos(--z) = ccos(z)`;;\n\nlet CSIN_DOUBLE = `!z. csin(Cx(&2) * z) = Cx(&2) * csin(z) * ccos(z)`;;\n\nlet CCOS_DOUBLE = `!z. ccos(Cx(&2) * z) = (ccos(z) pow 2) - (csin(z) pow 2)`;;\n\nlet CSIN_SUB = `!w z. csin(w - z) = csin(w) * ccos(z) - ccos(w) * csin(z)`;;\n\nlet CCOS_SUB = `!w z. ccos(w - z) = ccos(w) * ccos(z) + csin(w) * csin(z)`;;\n\nlet COMPLEX_MUL_CSIN_CSIN = `!w z. csin(w) * csin(z) = (ccos(w - z) - ccos(w + z)) / Cx(&2)`;;\n\nlet COMPLEX_MUL_CSIN_CCOS = `!w z. csin(w) * ccos(z) = (csin(w + z) + csin(w - z)) / Cx(&2)`;;\n\nlet COMPLEX_MUL_CCOS_CSIN = `!w z. ccos(w) * csin(z) = (csin(w + z) - csin(w - z)) / Cx(&2)`;;\n\nlet COMPLEX_MUL_CCOS_CCOS = `!w z. ccos(w) * ccos(z) = (ccos(w - z) + ccos(w + z)) / Cx(&2)`;;\n\nlet COMPLEX_ADD_CSIN = `!w z. csin(w) + csin(z) =\n Cx(&2) * csin((w + z) / Cx(&2)) * ccos((w - z) / Cx(&2))`;;\n\nlet COMPLEX_SUB_CSIN = `!w z. csin(w) - csin(z) =\n Cx(&2) * csin((w - z) / Cx(&2)) * ccos((w + z) / Cx(&2))`;;\n\nlet COMPLEX_ADD_CCOS = `!w z. ccos(w) + ccos(z) =\n Cx(&2) * ccos((w + z) / Cx(&2)) * ccos((w - z) / Cx(&2))`;;\n\nlet COMPLEX_SUB_CCOS = `!w z. ccos(w) - ccos(z) =\n Cx(&2) * csin((w + z) / Cx(&2)) * csin((z - w) / Cx(&2))`;;\n\nlet CCOS_DOUBLE_CCOS = `!z. ccos(Cx(&2) * z) = Cx(&2) * ccos z pow 2 - Cx(&1)`;;\n\nlet CCOS_DOUBLE_CSIN = `!z. ccos(Cx(&2) * z) = Cx(&1) - Cx(&2) * csin z pow 2`;;\n\nlet CEXP_EULER = `!z. cexp(ii * z) = ccos(z) + ii * csin(z)`;;\n\nlet DEMOIVRE = `!z n. (ccos z + ii * csin z) pow n =\n ccos(Cx(&n) * z) + ii * csin(Cx(&n) * z)`;;\n\nlet exp = new_definition `exp(x) = Re(cexp(Cx x))`;;\n\nlet CNJ_CEXP = `!z. cnj(cexp z) = cexp(cnj z)`;;\n\nlet REAL_EXP = `!z. real z ==> real(cexp z)`;;\n\nlet CX_EXP = `!x. Cx(exp x) = cexp(Cx x)`;;\n\nlet REAL_EXP_ADD = `!x y. exp(x + y) = exp(x) * exp(y)`;;\n\nlet REAL_EXP_0 = `exp(&0) = &1`;;\n\nlet REAL_EXP_ADD_MUL = `!x y. exp(x + y) * exp(--x) = exp(y)`;;\n\nlet REAL_EXP_NEG_MUL = `!x. exp(x) * exp(--x) = &1`;;\n\nlet REAL_EXP_NEG_MUL2 = `!x. exp(--x) * exp(x) = &1`;;\n\nlet REAL_EXP_NEG = `!x. exp(--x) = inv(exp(x))`;;\n\nlet REAL_EXP_N = `!n x. exp(&n * x) = exp(x) pow n`;;\n\nlet REAL_EXP_SUB = `!x y. exp(x - y) = exp(x) / exp(y)`;;\n\nlet REAL_EXP_NZ = `!x. ~(exp(x) = &0)`;;\n\nlet REAL_EXP_POS_LE = `!x. &0 <= exp(x)`;;\n\nlet REAL_EXP_POS_LT = `!x. &0 < exp(x)`;;\n\nlet REAL_EXP_LE_X = `!x. &1 + x <= exp(x)`;;\n\nlet REAL_EXP_LT_1 = `!x. &0 < x ==> &1 < exp(x)`;;\n\nlet REAL_EXP_MONO_IMP = `!x y. x < y ==> exp(x) < exp(y)`;;\n\nlet REAL_EXP_MONO_LT = `!x y. exp(x) < exp(y) <=> x < y`;;\n\nlet REAL_EXP_MONO_LE = `!x y. exp(x) <= exp(y) <=> x <= y`;;\n\nlet REAL_EXP_INJ = `!x y. (exp(x) = exp(y)) <=> (x = y)`;;\n\nlet REAL_EXP_EQ_1 = `!x. exp(x) = &1 <=> x = &0`;;\n\nlet REAL_ABS_EXP = `!x. abs(exp x) = exp x`;;\n\nlet REAL_EXP_SUM = `!f s. FINITE s ==> exp(sum s f) = product s (\\x. exp(f x))`;;\n\nlet REAL_EXP_BOUND_LEMMA = `!x. &0 <= x /\\ x <= inv(&2) ==> exp(x) <= &1 + &2 * x`;;\n\nlet sin = new_definition `sin(x) = Re(csin(Cx x))`;;\n\nlet cos = new_definition `cos(x) = Re(ccos(Cx x))`;;\n\nlet CNJ_CSIN = `!z. cnj(csin z) = csin(cnj z)`;;\n\nlet CNJ_CCOS = `!z. cnj(ccos z) = ccos(cnj z)`;;\n\nlet REAL_SIN = `!z. real z ==> real(csin z)`;;\n\nlet REAL_COS = `!z. real z ==> real(ccos z)`;;\n\nlet CX_SIN = `!x. Cx(sin x) = csin(Cx x)`;;\n\nlet CX_COS = `!x. Cx(cos x) = ccos(Cx x)`;;\n\nlet HAS_COMPLEX_DERIVATIVE_CSIN = `!z. (csin has_complex_derivative ccos z) (at z)`;;\n\nlet COMPLEX_DIFFERENTIABLE_AT_CSIN = `!z. csin complex_differentiable at z`;;\n\nlet COMPLEX_DIFFERENTIABLE_WITHIN_CSIN = `!s z. csin complex_differentiable (at z within s)`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN_UNIV\n HAS_COMPLEX_DERIVATIVE_CSIN)));;\n\nlet HAS_COMPLEX_DERIVATIVE_CCOS = `!z. (ccos has_complex_derivative --csin z) (at z)`;;\n\nlet COMPLEX_DIFFERENTIABLE_AT_CCOS = `!z. ccos complex_differentiable at z`;;\n\nlet COMPLEX_DIFFERENTIABLE_WITHIN_CCOS = `!s z. ccos complex_differentiable (at z within s)`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN_UNIV\n HAS_COMPLEX_DERIVATIVE_CCOS)));;\n\nlet CONTINUOUS_AT_CSIN = `!z. csin continuous at z`;;\n\nlet CONTINUOUS_WITHIN_CSIN = `!s z. csin continuous (at z within s)`;;\n\nlet CONTINUOUS_ON_CSIN = `!s. csin continuous_on s`;;\n\nlet HOLOMORPHIC_ON_CSIN = `!s. csin holomorphic_on s`;;\n\nlet CONTINUOUS_AT_CCOS = `!z. ccos continuous at z`;;\n\nlet CONTINUOUS_WITHIN_CCOS = `!s z. ccos continuous (at z within s)`;;\n\nlet CONTINUOUS_ON_CCOS = `!s. ccos continuous_on s`;;\n\nlet HOLOMORPHIC_ON_CCOS = `!s. ccos holomorphic_on s`;;\n\nlet SIN_0 = `sin(&0) = &0`;;\n\nlet COS_0 = `cos(&0) = &1`;;\n\nlet SIN_CIRCLE = `!x. (sin(x) pow 2) + (cos(x) pow 2) = &1`;;\n\nlet SIN_ADD = `!x y. sin(x + y) = sin(x) * cos(y) + cos(x) * sin(y)`;;\n\nlet COS_ADD = `!x y. cos(x + y) = cos(x) * cos(y) - sin(x) * sin(y)`;;\n\nlet SIN_NEG = `!x. sin(--x) = --(sin(x))`;;\n\nlet COS_NEG = `!x. cos(--x) = cos(x)`;;\n\nlet SIN_DOUBLE = `!x. sin(&2 * x) = &2 * sin(x) * cos(x)`;;\n\nlet COS_DOUBLE = `!x. cos(&2 * x) = (cos(x) pow 2) - (sin(x) pow 2)`;;\n\nlet COS_DOUBLE_COS = `!x. cos(&2 * x) = &2 * cos(x) pow 2 - &1`;;\n\nlet (SIN_BOUND,COS_BOUND) = (CONJ_PAIR o prove)\n (`(!x. abs(sin x) <= &1) /\\ (!x. abs(cos x) <= &1)`,\n CONJ_TAC THEN GEN_TAC THEN ONCE_REWRITE_TAC[GSYM REAL_ABS_NUM] THEN\n ONCE_REWRITE_TAC[REAL_LE_SQUARE_ABS] THEN\n MP_TAC(SPEC `x:real` SIN_CIRCLE) THEN\n MAP_EVERY (MP_TAC o C SPEC REAL_LE_SQUARE) [`sin x`; `cos x`] THEN\n REAL_ARITH_TAC);;\n\nlet SIN_BOUNDS = `!x. --(&1) <= sin(x) /\\ sin(x) <= &1`;;\n\nlet COS_BOUNDS = `!x. --(&1) <= cos(x) /\\ cos(x) <= &1`;;\n\nlet COS_ABS = `!x. cos(abs x) = cos(x)`;;\n\nlet SIN_SUB = `!w z. sin(w - z) = sin(w) * cos(z) - cos(w) * sin(z)`;;\n\nlet COS_SUB = `!w z. cos(w - z) = cos(w) * cos(z) + sin(w) * sin(z)`;;\n\nlet REAL_MUL_SIN_SIN = `!x y. sin(x) * sin(y) = (cos(x - y) - cos(x + y)) / &2`;;\n\nlet REAL_MUL_SIN_COS = `!x y. sin(x) * cos(y) = (sin(x + y) + sin(x - y)) / &2`;;\n\nlet REAL_MUL_COS_SIN = `!x y. cos(x) * sin(y) = (sin(x + y) - sin(x - y)) / &2`;;\n\nlet REAL_MUL_COS_COS = `!x y. cos(x) * cos(y) = (cos(x - y) + cos(x + y)) / &2`;;\n\nlet REAL_ADD_SIN = `!x y. sin(x) + sin(y) = &2 * sin((x + y) / &2) * cos((x - y) / &2)`;;\n\nlet REAL_SUB_SIN = `!x y. sin(x) - sin(y) = &2 * sin((x - y) / &2) * cos((x + y) / &2)`;;\n\nlet REAL_ADD_COS = `!x y. cos(x) + cos(y) = &2 * cos((x + y) / &2) * cos((x - y) / &2)`;;\n\nlet REAL_SUB_COS = `!x y. cos(x) - cos(y) = &2 * sin((x + y) / &2) * sin((y - x) / &2)`;;\n\nlet COS_DOUBLE_SIN = `!x. cos(&2 * x) = &1 - &2 * sin x pow 2`;;\n\nlet EULER = `!z. cexp(z) = Cx(exp(Re z)) * (Cx(cos(Im z)) + ii * Cx(sin(Im z)))`;;\n\nlet RE_CEXP = `!z. Re(cexp z) = exp(Re z) * cos(Im z)`;;\n\nlet IM_CEXP = `!z. Im(cexp z) = exp(Re z) * sin(Im z)`;;\n\nlet RE_CSIN = `!z. Re(csin z) = (exp(Im z) + exp(--(Im z))) / &2 * sin(Re z)`;;\n\nlet IM_CSIN = `!z. Im(csin z) = (exp(Im z) - exp(--(Im z))) / &2 * cos(Re z)`;;\n\nlet RE_CCOS = `!z. Re(ccos z) = (exp(Im z) + exp(--(Im z))) / &2 * cos(Re z)`;;\n\nlet IM_CCOS = `!z. Im(ccos z) = (exp(--(Im z)) - exp(Im z)) / &2 * sin(Re z)`;;\n\nlet IVT_INCREASING_RE = `!f a b y.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> f continuous at (Cx x)) /\\\n Re(f(Cx a)) <= y /\\ y <= Re(f(Cx b))\n ==> ?x. a <= x /\\ x <= b /\\ Re(f(Cx x)) = y`;;\n\nlet IVT_DECREASING_RE = `!f a b y.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> f continuous at (Cx x)) /\\\n Re(f(Cx b)) <= y /\\ y <= Re(f(Cx a))\n ==> ?x. a <= x /\\ x <= b /\\ Re(f(Cx x)) = y`;;\n\nlet IVT_INCREASING_IM = `!f a b y.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> f continuous at (Cx x)) /\\\n Im(f(Cx a)) <= y /\\ y <= Im(f(Cx b))\n ==> ?x. a <= x /\\ x <= b /\\ Im(f(Cx x)) = y`;;\n\nlet IVT_DECREASING_IM = `!f a b y.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> f continuous at (Cx x)) /\\\n Im(f(Cx b)) <= y /\\ y <= Im(f(Cx a))\n ==> ?x. a <= x /\\ x <= b /\\ Im(f(Cx x)) = y`;;\n\nlet log_def = new_definition\n `log y = @x. exp(x) = y`;;\n\nlet EXP_LOG = `!x. &0 < x ==> exp(log x) = x`;;\n\nlet LOG_EXP = `!x. log(exp x) = x`;;\n\nlet REAL_EXP_LOG = `!x. (exp(log x) = x) <=> &0 < x`;;\n\nlet LOG_MUL = `!x y. &0 < x /\\ &0 < y ==> (log(x * y) = log(x) + log(y))`;;\n\nlet LOG_INJ = `!x y. &0 < x /\\ &0 < y ==> (log(x) = log(y) <=> x = y)`;;\n\nlet LOG_1 = `log(&1) = &0`;;\n\nlet LOG_INV = `!x. &0 < x ==> (log(inv x) = --(log x))`;;\n\nlet LOG_DIV = `!x y. &0 < x /\\ &0 < y ==> log(x / y) = log(x) - log(y)`;;\n\nlet LOG_MONO_LT = `!x y. &0 < x /\\ &0 < y ==> (log(x) < log(y) <=> x < y)`;;\n\nlet LOG_MONO_LT_IMP = `!x y. &0 < x /\\ x < y ==> log(x) < log(y)`;;\n\nlet LOG_MONO_LT_REV = `!x y. &0 < x /\\ &0 < y /\\ log x < log y ==> x < y`;;\n\nlet LOG_MONO_LE = `!x y. &0 < x /\\ &0 < y ==> (log(x) <= log(y) <=> x <= y)`;;\n\nlet LOG_MONO_LE_IMP = `!x y. &0 < x /\\ x <= y ==> log(x) <= log(y)`;;\n\nlet LOG_MONO_LE_REV = `!x y. &0 < x /\\ &0 < y /\\ log x <= log y ==> x <= y`;;\n\nlet LOG_POW = `!n x. &0 < x ==> (log(x pow n) = &n * log(x))`;;\n\nlet LOG_LE_STRONG = `!x. &0 < &1 + x ==> log(&1 + x) <= x`;;\n\nlet LOG_LE = `!x. &0 <= x ==> log(&1 + x) <= x`;;\n\nlet LOG_LT_X = `!x. &0 < x ==> log(x) < x`;;\n\nlet LOG_POS = `!x. &1 <= x ==> &0 <= log(x)`;;\n\nlet LOG_POS_LT = `!x. &1 < x ==> &0 < log(x)`;;\n\nlet LOG_PRODUCT = `!f:A->real s.\n FINITE s /\\ (!x. x IN s ==> &0 < f x)\n ==> log(product s f) = sum s (\\x. log(f x))`;;\n\nlet SIN_NEARZERO = `?x. &0 < x /\\ !y. &0 < y /\\ y <= x ==> &0 < sin(y)`;;\n\nlet SIN_NONTRIVIAL = `?x. &0 < x /\\ ~(sin x = &0)`;;\n\nlet COS_NONTRIVIAL = `?x. &0 < x /\\ ~(cos x = &1)`;;\n\nlet COS_DOUBLE_BOUND = `!x. &0 <= cos x ==> &2 * (&1 - cos x) <= &1 - cos(&2 * x)`;;\n\nlet COS_GOESNEGATIVE_LEMMA = `!x. cos(x) < &1 ==> ?n. cos(&2 pow n * x) < &0`;;\n\nlet COS_GOESNEGATIVE = `?x. &0 < x /\\ cos(x) < &0`;;\n\nlet COS_HASZERO = `?x. &0 < x /\\ cos(x) = &0`;;\n\nlet SIN_HASZERO = `?x. &0 < x /\\ sin(x) = &0`;;\n\nlet SIN_HASZERO_MINIMAL = `?p. &0 < p /\\ sin p = &0 /\\ !x. &0 < x /\\ x < p ==> ~(sin x = &0)`;;\n\nlet pi = new_definition\n `pi = @p. &0 < p /\\ sin(p) = &0 /\\ !x. &0 < x /\\ x < p ==> ~(sin(x) = &0)`;;\n\nlet PI_WORKS = `&0 < pi /\\ sin(pi) = &0 /\\ !x. &0 < x /\\ x < pi ==> ~(sin x = &0)`;;\n\nlet PI_POS = `&0 < pi`;;\n\nlet PI_POS_LE = `&0 <= pi`;;\n\nlet PI_NZ = `~(pi = &0)`;;\n\nlet REAL_ABS_PI = `abs pi = pi`;;\n\nlet SIN_PI = `sin(pi) = &0`;;\n\nlet SIN_POS_PI = `!x. &0 < x /\\ x < pi ==> &0 < sin(x)`;;\n\nlet COS_PI2 = `cos(pi / &2) = &0`;;\n\nlet COS_PI = `cos(pi) = -- &1`;;\n\nlet SIN_PI2 = `sin(pi / &2) = &1`;;\n\nlet SIN_COS = `!x. sin(x) = cos(pi / &2 - x)`;;\n\nlet COS_SIN = `!x. cos(x) = sin(pi / &2 - x)`;;\n\nlet SIN_PERIODIC_PI = `!x. sin(x + pi) = --(sin(x))`;;\n\nlet COS_PERIODIC_PI = `!x. cos(x + pi) = --(cos(x))`;;\n\nlet SIN_PERIODIC = `!x. sin(x + &2 * pi) = sin(x)`;;\n\nlet COS_PERIODIC = `!x. cos(x + &2 * pi) = cos(x)`;;\n\nlet SIN_NPI = `!n. sin(&n * pi) = &0`;;\n\nlet COS_NPI = `!n. cos(&n * pi) = --(&1) pow n`;;\n\nlet COS_POS_PI2 = `!x. &0 < x /\\ x < pi / &2 ==> &0 < cos(x)`;;\n\nlet SIN_POS_PI2 = `!x. &0 < x /\\ x < pi / &2 ==> &0 < sin(x)`;;\n\nlet COS_POS_PI = `!x. --(pi / &2) < x /\\ x < pi / &2 ==> &0 < cos(x)`;;\n\nlet COS_POS_PI_LE = `!x. --(pi / &2) <= x /\\ x <= pi / &2 ==> &0 <= cos(x)`;;\n\nlet SIN_POS_PI_LE = `!x. &0 <= x /\\ x <= pi ==> &0 <= sin(x)`;;\n\nlet SIN_PIMUL_EQ_0 = `!n. sin(n * pi) = &0 <=> integer(n)`;;\n\nlet SIN_EQ_0 = `!x. sin(x) = &0 <=> ?n. integer n /\\ x = n * pi`;;\n\nlet COS_EQ_0 = `!x. cos(x) = &0 <=> ?n. integer n /\\ x = (n + &1 / &2) * pi`;;\n\nlet SIN_ZERO_PI = `!x. sin(x) = &0 <=> (?n. x = &n * pi) \\/ (?n. x = --(&n * pi))`;;\n\nlet COS_ZERO_PI = `!x. cos(x) = &0 <=>\n (?n. x = (&n + &1 / &2) * pi) \\/ (?n. x = --((&n + &1 / &2) * pi))`;;\n\nlet SIN_ZERO = `!x. (sin(x) = &0) <=> (?n. EVEN n /\\ x = &n * (pi / &2)) \\/\n (?n. EVEN n /\\ x = --(&n * (pi / &2)))`;;\n\nlet COS_ZERO = `!x. cos(x) = &0 <=> (?n. ~EVEN n /\\ (x = &n * (pi / &2))) \\/\n (?n. ~EVEN n /\\ (x = --(&n * (pi / &2))))`;;\n\nlet COS_ONE_2PI = `!x. (cos(x) = &1) <=> (?n. x = &n * &2 * pi) \\/ (?n. x = --(&n * &2 * pi))`;;\n\nlet SIN_COS_SQRT = `!x. &0 <= sin(x) ==> (sin(x) = sqrt(&1 - (cos(x) pow 2)))`;;\n\nlet SIN_EQ_0_PI = `!x. --pi < x /\\ x < pi /\\ sin(x) = &0 ==> x = &0`;;\n\nlet COS_TREBLE_COS = `!x. cos(&3 * x) = &4 * cos(x) pow 3 - &3 * cos x`;;\n\nlet COS_PI6 = `cos(pi / &6) = sqrt(&3) / &2`;;\n\nlet SIN_PI6 = `sin(pi / &6) = &1 / &2`;;\n\nlet SIN_POS_PI_REV = `!x. &0 <= x /\\ x <= &2 * pi /\\ &0 < sin x ==> &0 < x /\\ x < pi`;;\n\nlet SIN_PI3 = `sin(pi / &3) = sqrt(&3) / &2`;;\n\nlet COS_PI3 = `cos(pi / &3) = &1 / &2`;;\n\nlet CEXP_II_PI = `cexp(ii * Cx pi) = --Cx(&1)`;;\n\nlet SIN_TOTAL_POS = `!y. &0 <= y /\\ y <= &1\n ==> ?x. &0 <= x /\\ x <= pi / &2 /\\ sin(x) = y`;;\n\nlet SINCOS_TOTAL_PI2 = `!x y. &0 <= x /\\ &0 <= y /\\ x pow 2 + y pow 2 = &1\n ==> ?t. &0 <= t /\\ t <= pi / &2 /\\ x = cos t /\\ y = sin t`;;\n\nlet SINCOS_TOTAL_PI = `!x y. &0 <= y /\\ x pow 2 + y pow 2 = &1\n ==> ?t. &0 <= t /\\ t <= pi /\\ x = cos t /\\ y = sin t`;;\n\nlet SINCOS_TOTAL_2PI = `!x y. x pow 2 + y pow 2 = &1\n ==> ?t. &0 <= t /\\ t < &2 * pi /\\ x = cos t /\\ y = sin t`;;\n\nlet CIRCLE_SINCOS = `!x y. x pow 2 + y pow 2 = &1 ==> ?t. x = cos(t) /\\ y = sin(t)`;;\n\nlet CX_PI_NZ = `~(Cx pi = Cx(&0))`;;\n\nlet COMPLEX_UNIMODULAR_POLAR = `!z. (norm z = &1) ==> ?x. z = complex(cos(x),sin(x))`;;\n\nlet SIN_INTEGER_2PI = `!n. integer n ==> sin((&2 * pi) * n) = &0`;;\n\nlet SIN_INTEGER_PI = `!n. integer n ==> sin (n * pi) = &0`;;\n\nlet COS_INTEGER_2PI = `!n. integer n ==> cos((&2 * pi) * n) = &1`;;\n\nlet SINCOS_PRINCIPAL_VALUE = `!x. ?y. (--pi < y /\\ y <= pi) /\\ (sin(y) = sin(x) /\\ cos(y) = cos(x))`;;\n\nlet CEXP_COMPLEX = `!r t. cexp(complex(r,t)) = Cx(exp r) * complex(cos t,sin t)`;;\n\nlet NORM_COSSIN = `!t. norm(complex(cos t,sin t)) = &1`;;\n\nlet NORM_CEXP = `!z. norm(cexp z) = exp(Re z)`;;\n\nlet NORM_CEXP_II = `!t. norm (cexp (ii * Cx t)) = &1`;;\n\nlet NORM_CEXP_IMAGINARY = `!z. norm(cexp z) = &1 ==> Re(z) = &0`;;\n\nlet CEXP_EQ_1 = `!z. cexp z = Cx(&1) <=> Re(z) = &0 /\\ ?n. integer n /\\ Im(z) = &2 * n * pi`;;\n\nlet CEXP_EQ = `!w z. cexp w = cexp z <=> ?n. integer n /\\ w = z + Cx(&2 * n * pi) * ii`;;\n\nlet COMPLEX_EQ_CEXP = `!w z. abs(Im w - Im z) < &2 * pi /\\ cexp w = cexp z ==> w = z`;;\n\nlet CEXP_INTEGER_2PI = `!n. integer n ==> cexp(Cx(&2 * n * pi) * ii) = Cx(&1)`;;\n\nlet CEXP_LIPSCHITZ_BOUNDED = `!M a b. norm(a) <= M /\\ norm(b) <= M\n ==> norm(cexp a - cexp b) <= exp(M) * norm(a - b)`;;\n\nlet SIN_COS_EQ = `!x y. sin y = sin x /\\ cos y = cos x <=>\n ?n. integer n /\\ y = x + &2 * n * pi`;;\n\nlet SIN_COS_INJ = `!x y. sin x = sin y /\\ cos x = cos y /\\ abs(x - y) < &2 * pi ==> x = y`;;\n\nlet CEXP_II_NE_1 = `!x. &0 < x /\\ x < &2 * pi ==> ~(cexp(ii * Cx x) = Cx(&1))`;;\n\nlet CSIN_EQ_0 = `!z. csin z = Cx(&0) <=> ?n. integer n /\\ z = Cx(n * pi)`;;\n\nlet CCOS_EQ_0 = `!z. ccos z = Cx(&0) <=> ?n. integer n /\\ z = Cx((n + &1 / &2) * pi)`;;\n\nlet CCOS_EQ_1 = `!z. ccos z = Cx(&1) <=> ?n. integer n /\\ z = Cx(&2 * n * pi)`;;\n\nlet CSIN_EQ_1 = `!z. csin z = Cx(&1) <=> ?n. integer n /\\ z = Cx((&2 * n + &1 / &2) * pi)`;;\n\nlet CSIN_EQ_MINUS1 = `!z. csin z = --Cx(&1) <=>\n ?n. integer n /\\ z = Cx((&2 * n + &3 / &2) * pi)`;;\n\nlet CCOS_EQ_MINUS1 = `!z. ccos z = --Cx(&1) <=>\n ?n. integer n /\\ z = Cx((&2 * n + &1) * pi)`;;\n\nlet COS_EQ_1 = `!x. cos x = &1 <=> ?n. integer n /\\ x = &2 * n * pi`;;\n\nlet SIN_EQ_1 = `!x. sin x = &1 <=> ?n. integer n /\\ x = (&2 * n + &1 / &2) * pi`;;\n\nlet SIN_EQ_MINUS1 = `!x. sin x = --(&1) <=> ?n. integer n /\\ x = (&2 * n + &3 / &2) * pi`;;\n\nlet COS_EQ_MINUS1 = `!x. cos x = --(&1) <=>\n ?n. integer n /\\ x = (&2 * n + &1) * pi`;;\n\nlet DIST_CEXP_II_1 = `!t. norm(cexp(ii * Cx t) - Cx(&1)) = &2 * abs(sin(t / &2))`;;\n\nlet CX_SINH = `Cx((exp x - inv(exp x)) / &2) = --ii * csin(ii * Cx x)`;;\n\nlet CX_COSH = `Cx((exp x + inv(exp x)) / &2) = ccos(ii * Cx x)`;;\n\nlet NORM_CCOS_POW_2 = `!z. norm(ccos z) pow 2 =\n cos(Re z) pow 2 + (exp(Im z) - inv(exp(Im z))) pow 2 / &4`;;\n\nlet NORM_CSIN_POW_2 = `!z. norm(csin z) pow 2 =\n (exp(&2 * Im z) + inv(exp(&2 * Im z)) - &2 * cos(&2 * Re z)) / &4`;;\n\nlet CSIN_EQ = `!w z. csin w = csin z <=>\n ?n. integer n /\\\n (w = z + Cx(&2 * n * pi) \\/ w = --z + Cx((&2 * n + &1) * pi))`;;\n\nlet CCOS_EQ = `!w z. ccos(w) = ccos(z) <=>\n ?n. integer n /\\\n (w = z + Cx(&2 * n * pi) \\/ w = --z + Cx(&2 * n * pi))`;;\n\nlet SIN_EQ = `!x y. sin x = sin y <=>\n ?n. integer n /\\\n (x = y + &2 * n * pi \\/ x = --y + (&2 * n + &1) * pi)`;;\n\nlet COS_EQ = `!x y. cos x = cos y <=>\n ?n. integer n /\\\n (x = y + &2 * n * pi \\/ x = --y + &2 * n * pi)`;;\n\nlet NORM_CCOS_LE = `!z. norm(ccos z) <= exp(norm z)`;;\n\nlet NORM_CCOS_PLUS1_LE = `!z. norm(Cx(&1) + ccos z) <= &2 * exp(norm z)`;;\n\nlet TAYLOR_CEXP = `!n z. norm(cexp z - vsum(0..n) (\\k. z pow k / Cx(&(FACT k))))\n <= exp(abs(Re z)) * (norm z) pow (n + 1) / &(FACT n)`;;\n\nlet E_APPROX_32 = `abs(exp(&1) - &5837465777 / &2147483648) <= inv(&2 pow 32)`;;\n\nlet TAYLOR_CSIN_RAW = `!n z. norm(csin z -\n vsum(0..n) (\\k. if ODD k\n then --ii * (ii * z) pow k / Cx(&(FACT k))\n else Cx(&0)))\n <= exp(abs(Im z)) * (norm z) pow (n + 1) / &(FACT n)`;;\n\nlet TAYLOR_CSIN = `!n z. norm(csin z -\n vsum(0..n) (\\k. --Cx(&1) pow k *\n z pow (2 * k + 1) / Cx(&(FACT(2 * k + 1)))))\n <= exp(abs(Im z)) * norm(z) pow (2 * n + 3) / &(FACT(2 * n + 2))`;;\n\nlet CSIN_CONVERGES = `!z. ((\\n. --Cx(&1) pow n * z pow (2 * n + 1) / Cx(&(FACT(2 * n + 1))))\n sums csin(z)) (from 0)`;;\n\nlet TAYLOR_CCOS_RAW = `!n z. norm(ccos z -\n vsum(0..n) (\\k. if EVEN k\n then (ii * z) pow k / Cx(&(FACT k))\n else Cx(&0)))\n <= exp(abs(Im z)) * (norm z) pow (n + 1) / &(FACT n)`;;\n\nlet TAYLOR_CCOS = `!n z. norm(ccos z -\n vsum(0..n) (\\k. --Cx(&1) pow k *\n z pow (2 * k) / Cx(&(FACT(2 * k)))))\n <= exp(abs(Im z)) * norm(z) pow (2 * n + 2) / &(FACT(2 * n + 1))`;;\n\nlet CCOS_CONVERGES = `!z. ((\\n. --Cx(&1) pow n * z pow (2 * n) / Cx(&(FACT(2 * n))))\n sums ccos(z)) (from 0)`;;\n\nlet Arg_DEF = new_definition\n `Arg z = if z = Cx(&0) then &0\n else @t. &0 <= t /\\ t < &2 * pi /\\\n z = Cx(norm(z)) * cexp(ii * Cx t)`;;\n\nlet ARG_0 = `Arg(Cx(&0)) = &0`;;\n\nlet ARG = `!z. &0 <= Arg(z) /\\ Arg(z) < &2 * pi /\\\n z = Cx(norm z) * cexp(ii * Cx(Arg z))`;;\n\nlet COMPLEX_NORM_EQ_1_CEXP = `!z. norm z = &1 <=> (?t. z = cexp(ii * Cx t))`;;\n\nlet ARG_UNIQUE = `!a r z. &0 < r /\\ Cx r * cexp(ii * Cx a) = z /\\ &0 <= a /\\ a < &2 * pi\n ==> Arg z = a`;;\n\nlet ARG_MUL_CX = `!r z. &0 < r ==> Arg(Cx r * z) = Arg(z)`;;\n\nlet ARG_DIV_CX = `!r z. &0 < r ==> Arg(z / Cx r) = Arg(z)`;;\n\nlet ARG_LT_NZ = `!z. &0 < Arg z <=> ~(Arg z = &0)`;;\n\nlet ARG_LE_PI = `!z. Arg z <= pi <=> &0 <= Im z`;;\n\nlet ARG_LT_PI = `!z. &0 < Arg z /\\ Arg z < pi <=> &0 < Im z`;;\n\nlet ARG_EQ_0 = `!z. Arg z = &0 <=> real z /\\ &0 <= Re z`;;\n\nlet ARG_NUM = `!n. Arg(Cx(&n)) = &0`;;\n\nlet ARG_EQ_PI = `!z. Arg z = pi <=> real z /\\ Re z < &0`;;\n\nlet ARG_EQ_0_PI = `!z. Arg z = &0 \\/ Arg z = pi <=> real z`;;\n\nlet ARG_INV = `!z. ~(real z /\\ &0 <= Re z) ==> Arg(inv z) = &2 * pi - Arg z`;;\n\nlet ARG_EQ = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0))\n ==> (Arg w = Arg z <=> ?x. &0 < x /\\ w = Cx(x) * z)`;;\n\nlet ARG_INV_EQ_0 = `!z. Arg(inv z) = &0 <=> Arg z = &0`;;\n\nlet ARG_LE_DIV_SUM = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0)) /\\ Arg(w) <= Arg(z)\n ==> Arg(z) = Arg(w) + Arg(z / w)`;;\n\nlet ARG_LE_DIV_SUM_EQ = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0))\n ==> (Arg(w) <= Arg(z) <=> Arg(z) = Arg(w) + Arg(z / w))`;;\n\nlet REAL_SUB_ARG = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0))\n ==> Arg w - Arg z = if Arg(z) <= Arg(w) then Arg(w / z)\n else Arg(w / z) - &2 * pi`;;\n\nlet REAL_ADD_ARG = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0))\n ==> Arg(w) + Arg(z) =\n if Arg w + Arg z < &2 * pi\n then Arg(w * z)\n else Arg(w * z) + &2 * pi`;;\n\nlet ARG_MUL = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0))\n ==> Arg(w * z) = if Arg w + Arg z < &2 * pi\n then Arg w + Arg z\n else (Arg w + Arg z) - &2 * pi`;;\n\nlet ARG_CNJ = `!z. Arg(cnj z) = if real z /\\ &0 <= Re z then Arg z else &2 * pi - Arg z`;;\n\nlet ARG_REAL = `!z. real z ==> Arg z = if &0 <= Re z then &0 else pi`;;\n\nlet ARG_CEXP = `!z. &0 <= Im z /\\ Im z < &2 * pi ==> Arg(cexp(z)) = Im z`;;\n\nlet rotate2d = new_definition\n `(rotate2d:real->real^2->real^2) t x =\n vector[x$1 * cos(t) - x$2 * sin(t);\n x$1 * sin(t) + x$2 * cos(t)]`;;\n\nlet LINEAR_ROTATE2D = `!t. linear(rotate2d t)`;;\n\nlet ROTATE2D_ADD_VECTORS = `!t w z. rotate2d t (w + z) = rotate2d t w + rotate2d t z`;;\n\nlet ROTATE2D_SUB = `!t w z. rotate2d t (w - z) = rotate2d t w - rotate2d t z`;;\n\nlet NORM_ROTATE2D = `!t z. norm(rotate2d t z) = norm z`;;\n\nlet ROTATE2D_0 = `!t. rotate2d t (Cx(&0)) = Cx(&0)`;;\n\nlet ROTATE2D_EQ_0 = `!t z. rotate2d t z = Cx(&0) <=> z = Cx(&0)`;;\n\nlet ROTATE2D_ZERO = `!z. rotate2d (&0) z = z`;;\n\nlet ORTHOGONAL_TRANSFORMATION_ROTATE2D = `!t. orthogonal_transformation(rotate2d t)`;;\n\nlet ROTATE2D_POLAR = `!r t s. rotate2d t (vector[r * cos(s); r * sin(s)]) =\n vector[r * cos(t + s); r * sin(t + s)]`;;\n\nlet MATRIX_ROTATE2D = `!t. matrix(rotate2d t) = vector[vector[cos t;--(sin t)];\n vector[sin t; cos t]]`;;\n\nlet DET_MATRIX_ROTATE2D = `!t. det(matrix(rotate2d t)) = &1`;;\n\nlet ROTATION_ROTATE2D = `!f. orthogonal_transformation f /\\ det(matrix f) = &1\n ==> ?t. &0 <= t /\\ t < &2 * pi /\\ f = rotate2d t`;;\n\nlet ROTATE2D_ADD = `!s t x. rotate2d (s + t) x = rotate2d s (rotate2d t x)`;;\n\nlet ROTATE2D_COMPLEX = `!t z. rotate2d t z = cexp(ii * Cx t) * z`;;\n\nlet ROTATE2D_PI2 = `!z. rotate2d (pi / &2) z = ii * z`;;\n\nlet ROTATE2D_PI = `!z. rotate2d pi z = --z`;;\n\nlet ROTATE2D_NPI = `!n z. rotate2d (&n * pi) z = --Cx(&1) pow n * z`;;\n\nlet ROTATE2D_2PI = `!z. rotate2d (&2 * pi) z = z`;;\n\nlet ARG_ROTATE2D = `!t z. ~(z = Cx(&0)) /\\ &0 <= t + Arg z /\\ t + Arg z < &2 * pi\n ==> Arg(rotate2d t z) = t + Arg z`;;\n\nlet ARG_ROTATE2D_UNIQUE = `!t a z. ~(z = Cx(&0)) /\\ Arg(rotate2d t z) = a\n ==> ?n. integer n /\\ t = &2 * n * pi + (a - Arg z)`;;\n\nlet ARG_ROTATE2D_UNIQUE_2PI = `!s t z. ~(z = Cx(&0)) /\\\n &0 <= s /\\ s < &2 * pi /\\ &0 <= t /\\ t < &2 * pi /\\\n Arg(rotate2d s z) = Arg(rotate2d t z)\n ==> s = t`;;\n\nlet COMPLEX_DIV_ROTATION = `!f w z. orthogonal_transformation f /\\ det(matrix f) = &1\n ==> f w / f z = w / z`;;\n\nlet th = `!f w z. linear f /\\ (!x. norm(f x) = norm x) /\\\n (2 <= dimindex(:2) ==> det(matrix f) = &1)\n ==> f w / f z = w / z`;;\n\nlet ROTATION_ROTATE2D_EXISTS = `!x y. norm x = norm y ==> ?t. &0 <= t /\\ t < &2 * pi /\\ rotate2d t x = y`;;\n\nlet ROTATION_ROTATE2D_EXISTS_ORTHOGONAL = `!e1 e2. norm(e1) = &1 /\\ norm(e2) = &1 /\\ orthogonal e1 e2\n ==> e1 = rotate2d (pi / &2) e2 \\/ e2 = rotate2d (pi / &2) e1`;;\n\nlet ROTATION_ROTATE2D_EXISTS_ORTHOGONAL_ORIENTED = `!e1 e2. norm(e1) = &1 /\\ norm(e2) = &1 /\\ orthogonal e1 e2 /\\\n &0 < e1$1 * e2$2 - e1$2 * e2$1\n ==> e2 = rotate2d (pi / &2) e1`;;\n\nlet ROTATE2D_EQ = `!t x y. rotate2d t x = rotate2d t y <=> x = y`;;\n\nlet ROTATE2D_SUB_ARG = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0))\n ==> rotate2d(Arg w - Arg z) = rotate2d(Arg(w / z))`;;\n\nlet ROTATION_MATRIX_ROTATE2D = `!t. rotation_matrix(matrix(rotate2d t))`;;\n\nlet ROTATION_MATRIX_ROTATE2D_EQ = `!A:real^2^2. rotation_matrix A <=> ?t. A = matrix(rotate2d t)`;;\n\nlet NULLHOMOTOPIC_ORTHOGONAL_TRANSFORMATION = `!f:real^N->real^N.\n orthogonal_transformation f /\\ det(matrix f) = &1\n ==> homotopic_with orthogonal_transformation\n (subtopology euclidean (:real^N),subtopology euclidean (:real^N))\n f I`;;\n\nlet HOMOTOPIC_SPECIAL_ORTHOGONAL_TRANSFORMATIONS,\n HOMOTOPIC_WITH_ORTHOGONAL_TRANSFORMATIONS_UNIV = (CONJ_PAIR o prove)\n (`(!f g. homotopic_with\n (\\h. orthogonal_transformation h /\\ det(matrix h) = det(matrix f))\n (subtopology euclidean (:real^N),subtopology euclidean (:real^N))\n f g <=>\n homotopic_with\n orthogonal_transformation\n (subtopology euclidean (:real^N),\n subtopology euclidean (:real^N)) f g) /\\\n !f g. homotopic_with orthogonal_transformation\n (subtopology euclidean (:real^N),\n subtopology euclidean (:real^N)) f g <=>\n orthogonal_transformation f /\\ orthogonal_transformation g /\\\n det(matrix f) = det(matrix g)`,\n REWRITE_TAC[AND_FORALL_THM] THEN REPEAT GEN_TAC THEN MATCH_MP_TAC(TAUT\n `(u ==> s) /\\ (s ==> t) /\\ (t ==> u)\n ==> (u <=> t) /\\ (t <=> s)`) THEN\n REPEAT CONJ_TAC THENL\n [DISCH_THEN(MP_TAC o MATCH_MP HOMOTOPIC_WITH_IMP_PROPERTY) THEN MESON_TAC[];\n STRIP_TAC THEN\n MP_TAC(ISPEC `g:real^N->real^N` ORTHOGONAL_TRANSFORMATION_INVERSE_o) THEN\n ASM_REWRITE_TAC[] THEN\n DISCH_THEN(X_CHOOSE_THEN `h:real^N->real^N` STRIP_ASSUME_TAC) THEN\n SUBGOAL_THEN\n `(f:real^N->real^N) = g o (h:real^N->real^N) o f /\\ g = g o I`\n (fun th -> ONCE_REWRITE_TAC[th])\n THENL [ASM_REWRITE_TAC[o_ASSOC; I_O_ID]; ALL_TAC] THEN\n MATCH_MP_TAC HOMOTOPIC_WITH_COMPOSE_CONTINUOUS_LEFT THEN\n EXISTS_TAC `(:real^N)` THEN REWRITE_TAC[SUBSET_UNIV] THEN\n ASM_SIMP_TAC[ORTHOGONAL_TRANSFORMATION_LINEAR; LINEAR_CONTINUOUS_ON] THEN\n SUBGOAL_THEN\n `!k:real^N->real^N.\n orthogonal_transformation (g o k) <=> orthogonal_transformation k`\n (fun th -> REWRITE_TAC[th; ETA_AX])\n THENL\n [GEN_TAC THEN EQ_TAC THEN\n ASM_SIMP_TAC[ORTHOGONAL_TRANSFORMATION_COMPOSE] THEN DISCH_THEN\n (MP_TAC o SPEC `h:real^N->real^N` o MATCH_MP (ONCE_REWRITE_RULE\n [IMP_CONJ_ALT] ORTHOGONAL_TRANSFORMATION_COMPOSE)) THEN\n ASM_SIMP_TAC[o_ASSOC; I_O_ID];\n MATCH_MP_TAC NULLHOMOTOPIC_ORTHOGONAL_TRANSFORMATION THEN\n REPEAT(FIRST_X_ASSUM(MP_TAC o AP_TERM\n `\\f:real^N->real^N. det(matrix f)`)) THEN\n ASM_SIMP_TAC[MATRIX_COMPOSE; ORTHOGONAL_TRANSFORMATION_LINEAR;\n ORTHOGONAL_TRANSFORMATION_COMPOSE; DET_MUL;\n MATRIX_I; DET_I]];\n REWRITE_TAC[HOMOTOPIC_WITH_EUCLIDEAN] THEN MATCH_MP_TAC MONO_EXISTS THEN\n X_GEN_TAC `k:real^(1,N)finite_sum->real^N` THEN\n STRIP_TAC THEN ASM_SIMP_TAC[] THEN MP_TAC(ISPECL\n [`\\t. lift(\n det(matrix((k:real^(1,N)finite_sum->real^N) o pastecart t)))`;\n `interval[vec 0:real^1,vec 1]`]\n CONTINUOUS_DISCRETE_RANGE_CONSTANT) THEN\n REWRITE_TAC[CONNECTED_INTERVAL] THEN ANTS_TAC THENL\n [CONJ_TAC THENL\n [MATCH_MP_TAC CONTINUOUS_ON_LIFT_DET THEN\n SIMP_TAC[matrix; LAMBDA_BETA; o_DEF] THEN\n MAP_EVERY X_GEN_TAC [`i:num`; `j:num`] THEN STRIP_TAC THEN\n MATCH_MP_TAC CONTINUOUS_ON_LIFT_COMPONENT_COMPOSE THEN\n ASM_REWRITE_TAC[] THEN GEN_REWRITE_TAC LAND_CONV [GSYM o_DEF] THEN\n MATCH_MP_TAC CONTINUOUS_ON_COMPOSE THEN\n SIMP_TAC[CONTINUOUS_ON_PASTECART; CONTINUOUS_ON_CONST;\n CONTINUOUS_ON_ID] THEN\n FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP (REWRITE_RULE[IMP_CONJ]\n CONTINUOUS_ON_SUBSET)) THEN\n SIMP_TAC[SUBSET; FORALL_IN_IMAGE; PASTECART_IN_PCROSS; IN_UNIV];\n X_GEN_TAC `t:real^1` THEN DISCH_TAC THEN EXISTS_TAC `&1` THEN\n REWRITE_TAC[REAL_LT_01] THEN X_GEN_TAC `u:real^1` THEN\n DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC MP_TAC) THEN\n REWRITE_TAC[GSYM LIFT_SUB; NORM_LIFT; LIFT_EQ] THEN\n SUBGOAL_THEN\n `orthogonal_transformation\n ((k:real^(1,N)finite_sum->real^N) o pastecart t) /\\\n orthogonal_transformation (k o pastecart u)`\n MP_TAC THENL [ASM_SIMP_TAC[o_DEF]; ALL_TAC] THEN\n DISCH_THEN(CONJUNCTS_THEN\n (STRIP_ASSUME_TAC o MATCH_MP DET_ORTHOGONAL_MATRIX o\n MATCH_MP ORTHOGONAL_MATRIX_MATRIX)) THEN\n ASM_REWRITE_TAC[] THEN CONV_TAC REAL_RAT_REDUCE_CONV];\n REWRITE_TAC[o_DEF; LEFT_IMP_EXISTS_THM] THEN\n X_GEN_TAC `a:real^1` THEN DISCH_TAC THEN\n REPEAT(FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [GSYM FUN_EQ_THM])) THEN\n REPEAT(DISCH_THEN(SUBST1_TAC o SYM)) THEN\n ASM_SIMP_TAC[ENDS_IN_UNIT_INTERVAL; GSYM LIFT_EQ]]]);;\n\nlet HOMOTOPIC_ORTHOGONAL_TRANSFORMATIONS_SPHERE = `!f g r.\n &0 < r\n ==> (homotopic_with orthogonal_transformation\n (subtopology euclidean (sphere(vec 0,r)),\n subtopology euclidean (sphere(vec 0,r))) f g <=>\n homotopic_with orthogonal_transformation\n (subtopology euclidean (:real^N),\n subtopology euclidean (:real^N)) f g)`;;\n\nlet HOMOTOPIC_LINEAR_MAPS = `!f g. homotopic_with linear\n (subtopology euclidean (:real^M),subtopology euclidean (:real^N))\n f g <=>\n linear f /\\ linear g`;;\n\nlet HOMOTOPIC_LINEAR_POSITIVE_SEMIDEFINITE_MAPS = `!f g. homotopic_with (\\f. linear f /\\ positive_semidefinite(matrix f))\n (subtopology euclidean (:real^N),\n subtopology euclidean (:real^N)) f g <=>\n linear f /\\ linear g /\\\n positive_semidefinite(matrix f) /\\\n positive_semidefinite(matrix g)`;;\n\nlet HOMOTOPIC_LINEAR_POSITIVE_DEFINITE_MAPS = `!f g. homotopic_with (\\f. linear f /\\ positive_definite(matrix f))\n (subtopology euclidean (:real^N),\n subtopology euclidean (:real^N)) f g <=>\n linear f /\\ linear g /\\\n positive_definite(matrix f) /\\\n positive_definite(matrix g)`;;\n\nlet HOMOTOPIC_RESTRICTED_LINEAR_MAPS = `!f g b. homotopic_with (\\f. linear f /\\ real_sgn(det(matrix f)) = b)\n (subtopology euclidean (:real^N),\n subtopology euclidean (:real^N)) f g <=>\n linear f /\\ linear g /\\\n real_sgn(det(matrix f)) = b /\\\n real_sgn(det(matrix g)) = b`;;\n\nlet HOMOTOPIC_INVERTIBLE_LINEAR_MAPS_ALT = `!f g. homotopic_with (\\h. linear h /\\ invertible(matrix h))\n (subtopology euclidean (:real^N),\n subtopology euclidean (:real^N)) f g <=>\n linear f /\\ linear g /\\\n &0 < real_sgn(det(matrix f)) * real_sgn(det(matrix g))`;;\n\nlet HOMOTOPIC_INVERTIBLE_LINEAR_MAPS = `!f g. homotopic_with (\\h. linear h /\\ invertible(matrix h))\n (subtopology euclidean (:real^N),\n subtopology euclidean (:real^N)) f g <=>\n linear f /\\ linear g /\\ &0 < det(matrix f) * det(matrix g)`;;\n\nlet HOMOTOPIC_LINEAR_MAPS_EQ = `!f g:real^N->real^N.\n linear f /\\ linear g\n ==> (homotopic_with (\\x. T)\n (subtopology euclidean ((:real^N) DELETE vec 0),\n subtopology euclidean ((:real^N) DELETE vec 0)) f g <=>\n &0 < det(matrix f) * det(matrix g))`;;\n\nlet HOMOTOPIC_ORTHOGONAL_TRANSFORMATIONS_EQ = `!f g:real^N->real^N.\n orthogonal_transformation f /\\ orthogonal_transformation g\n ==> (homotopic_with (\\x. T)\n (subtopology euclidean (sphere (vec 0,&1)),\n subtopology euclidean (sphere (vec 0,&1))) f g <=>\n det(matrix f) = det(matrix g))`;;\n\nlet HOMOTOPIC_ANTIPODAL_IDENTITY_MAP = `homotopic_with (\\x. T)\n (subtopology euclidean (sphere(vec 0,&1)),\n subtopology euclidean (sphere(vec 0,&1)))\n (\\x:real^N. --x) (\\x. x) <=>\n EVEN(dimindex(:N))`;;\n\nlet ctan = new_definition\n `ctan z = csin z / ccos z`;;\n\nlet CTAN_0 = `ctan(Cx(&0)) = Cx(&0)`;;\n\nlet CTAN_NEG = `!z. ctan(--z) = --(ctan z)`;;\n\nlet CTAN_ADD = `!w z. ~(ccos(w) = Cx(&0)) /\\\n ~(ccos(z) = Cx(&0)) /\\\n ~(ccos(w + z) = Cx(&0))\n ==> ctan(w + z) = (ctan w + ctan z) / (Cx(&1) - ctan(w) * ctan(z))`;;\n\nlet CTAN_DOUBLE = `!z. ctan(Cx(&2) * z) = (Cx(&2) * ctan z) / (Cx(&1) - ctan z pow 2)`;;\n\nlet CCOT_DOUBLE = `!z. inv(ctan(Cx(&2) * z)) = (inv(ctan z) - ctan z) / Cx(&2)`;;\n\nlet CTAN_CCOT_DOUBLE = `!z. ctan z = Cx(&1) / ctan z - Cx(&2) / ctan(Cx(&2) * z)`;;\n\nlet CTAN_SUB = `!w z. ~(ccos(w) = Cx(&0)) /\\\n ~(ccos(z) = Cx(&0)) /\\\n ~(ccos(w - z) = Cx(&0))\n ==> ctan(w - z) = (ctan w - ctan z) / (Cx(&1) + ctan(w) * ctan(z))`;;\n\nlet COMPLEX_ADD_CTAN = `!w z. ~(ccos(w) = Cx(&0)) /\\\n ~(ccos(z) = Cx(&0))\n ==> ctan(w) + ctan(z) = csin(w + z) / (ccos(w) * ccos(z))`;;\n\nlet COMPLEX_SUB_CTAN = `!w z. ~(ccos(w) = Cx(&0)) /\\\n ~(ccos(z) = Cx(&0))\n ==> ctan(w) - ctan(z) = csin(w - z) / (ccos(w) * ccos(z))`;;\n\nlet CTAN_CEXP = `!z. ctan z =\n --ii * (cexp(Cx(&2) * ii * z) - Cx(&1)) /\n (cexp(Cx(&2) * ii * z) + Cx(&1))`;;\n\nlet HAS_COMPLEX_DERIVATIVE_CTAN = `!z. ~(ccos z = Cx(&0))\n ==> (ctan has_complex_derivative (inv(ccos(z) pow 2))) (at z)`;;\n\nlet COMPLEX_DIFFERENTIABLE_AT_CTAN = `!z. ~(ccos z = Cx(&0)) ==> ctan complex_differentiable at z`;;\n\nlet COMPLEX_DIFFERENTIABLE_WITHIN_CTAN = `!s z. ~(ccos z = Cx(&0))\n ==> ctan complex_differentiable (at z within s)`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN\n HAS_COMPLEX_DERIVATIVE_CTAN)));;\n\nlet CONTINUOUS_AT_CTAN = `!z. ~(ccos z = Cx(&0)) ==> ctan continuous at z`;;\n\nlet CONTINUOUS_WITHIN_CTAN = `!s z. ~(ccos z = Cx(&0)) ==> ctan continuous (at z within s)`;;\n\nlet CONTINUOUS_ON_CTAN = `!s. (!z. z IN s ==> ~(ccos z = Cx(&0))) ==> ctan continuous_on s`;;\n\nlet HOLOMORPHIC_ON_CTAN = `!s. (!z. z IN s ==> ~(ccos z = Cx(&0))) ==> ctan holomorphic_on s`;;\n\nlet tan_def = new_definition\n `tan(x) = Re(ctan(Cx x))`;;\n\nlet CNJ_CTAN = `!z. cnj(ctan z) = ctan(cnj z)`;;\n\nlet REAL_TAN = `!z. real z ==> real(ctan z)`;;\n\nlet CX_TAN = `!x. Cx(tan x) = ctan(Cx x)`;;\n\nlet tan = `!x. tan x = sin x / cos x`;;\n\nlet TAN_0 = `tan(&0) = &0`;;\n\nlet TAN_PI = `tan(pi) = &0`;;\n\nlet TAN_NPI = `!n. tan(&n * pi) = &0`;;\n\nlet TAN_NEG = `!x. tan(--x) = --(tan x)`;;\n\nlet TAN_PERIODIC_PI = `!x. tan(x + pi) = tan(x)`;;\n\nlet TAN_PERIODIC_NPI = `!x n. tan(x + &n * pi) = tan(x)`;;\n\nlet TAN_ADD = `!x y. ~(cos(x) = &0) /\\ ~(cos(y) = &0) /\\ ~(cos(x + y) = &0)\n ==> tan(x + y) = (tan(x) + tan(y)) / (&1 - tan(x) * tan(y))`;;\n\nlet TAN_SUB = `!x y. ~(cos(x) = &0) /\\ ~(cos(y) = &0) /\\ ~(cos(x - y) = &0)\n ==> tan(x - y) = (tan(x) - tan(y)) / (&1 + tan(x) * tan(y))`;;\n\nlet TAN_DOUBLE = `!x. tan(&2 * x) = (&2 * tan x) / (&1 - tan x pow 2)`;;\n\nlet COT_DOUBLE = `!z. inv(tan(&2 * z)) = (inv(tan z) - tan z) / &2`;;\n\nlet TAN_COT_DOUBLE = `!z. tan z = &1 / tan z - &2 / tan(&2 * z)`;;\n\nlet REAL_ADD_TAN = `!x y. ~(cos(x) = &0) /\\ ~(cos(y) = &0)\n ==> tan(x) + tan(y) = sin(x + y) / (cos(x) * cos(y))`;;\n\nlet REAL_SUB_TAN = `!x y. ~(cos(x) = &0) /\\ ~(cos(y) = &0)\n ==> tan(x) - tan(y) = sin(x - y) / (cos(x) * cos(y))`;;\n\nlet TAN_PI4 = `tan(pi / &4) = &1`;;\n\nlet TAN_POS_PI2 = `!x. &0 < x /\\ x < pi / &2 ==> &0 < tan x`;;\n\nlet TAN_POS_PI2_LE = `!x. &0 <= x /\\ x < pi / &2 ==> &0 <= tan x`;;\n\nlet COS_TAN = `!x. abs(x) < pi / &2 ==> cos(x) = &1 / sqrt(&1 + tan(x) pow 2)`;;\n\nlet SIN_TAN = `!x. abs(x) < pi / &2 ==> sin(x) = tan(x) / sqrt(&1 + tan(x) pow 2)`;;\n\nlet SIN_MONO_LT = `!x y. --(pi / &2) <= x /\\ x < y /\\ y <= pi / &2 ==> sin(x) < sin(y)`;;\n\nlet SIN_MONO_LE = `!x y. --(pi / &2) <= x /\\ x <= y /\\ y <= pi / &2 ==> sin(x) <= sin(y)`;;\n\nlet SIN_MONO_LT_EQ = `!x y. --(pi / &2) <= x /\\ x <= pi / &2 /\\ --(pi / &2) <= y /\\ y <= pi / &2\n ==> (sin(x) < sin(y) <=> x < y)`;;\n\nlet SIN_MONO_LE_EQ = `!x y. --(pi / &2) <= x /\\ x <= pi / &2 /\\ --(pi / &2) <= y /\\ y <= pi / &2\n ==> (sin(x) <= sin(y) <=> x <= y)`;;\n\nlet SIN_INJ_PI = `!x y. --(pi / &2) <= x /\\ x <= pi / &2 /\\\n --(pi / &2) <= y /\\ y <= pi / &2 /\\\n sin(x) = sin(y)\n ==> x = y`;;\n\nlet COS_MONO_LT = `!x y. &0 <= x /\\ x < y /\\ y <= pi ==> cos(y) < cos(x)`;;\n\nlet COS_MONO_LE = `!x y. &0 <= x /\\ x <= y /\\ y <= pi ==> cos(y) <= cos(x)`;;\n\nlet COS_MONO_LT_EQ = `!x y. &0 <= x /\\ x <= pi /\\ &0 <= y /\\ y <= pi\n ==> (cos(x) < cos(y) <=> y < x)`;;\n\nlet COS_MONO_LE_EQ = `!x y. &0 <= x /\\ x <= pi /\\ &0 <= y /\\ y <= pi\n ==> (cos(x) <= cos(y) <=> y <= x)`;;\n\nlet COS_INJ_PI = `!x y. &0 <= x /\\ x <= pi /\\ &0 <= y /\\ y <= pi /\\ cos(x) = cos(y)\n ==> x = y`;;\n\nlet REAL_ABS_COS_MONO_LE_EQ = `!x y. abs(x) <= pi / &2 /\\ abs(y) <= pi / &2\n ==> (abs(cos x) <= abs(cos y) <=> abs y <= abs x)`;;\n\nlet TAN_MONO_LT = `!x y. --(pi / &2) < x /\\ x < y /\\ y < pi / &2 ==> tan(x) < tan(y)`;;\n\nlet TAN_MONO_LE = `!x y. --(pi / &2) < x /\\ x <= y /\\ y < pi / &2 ==> tan(x) <= tan(y)`;;\n\nlet TAN_MONO_LT_EQ = `!x y. --(pi / &2) < x /\\ x < pi / &2 /\\ --(pi / &2) < y /\\ y < pi / &2\n ==> (tan(x) < tan(y) <=> x < y)`;;\n\nlet TAN_MONO_LE_EQ = `!x y. --(pi / &2) < x /\\ x < pi / &2 /\\ --(pi / &2) < y /\\ y < pi / &2\n ==> (tan(x) <= tan(y) <=> x <= y)`;;\n\nlet TAN_BOUND_PI2 = `!x. abs(x) < pi / &4 ==> abs(tan x) < &1`;;\n\nlet TAN_COT = `!x. tan(pi / &2 - x) = inv(tan x)`;;\n\nlet REAL_ABS_SIN_BOUND_LT = `!x. ~(x = &0) ==> abs(sin x) < abs x`;;\n\nlet REAL_ABS_SIN_BOUND_LE = `!x. abs(sin x) <= abs x`;;\n\nlet SIN_PI6_STRADDLE = `!a b. &0 <= a /\\ a <= b /\\ b <= &4 /\\\n sin(a / &6) <= &1 / &2 /\\ &1 / &2 <= sin(b / &6)\n ==> a <= pi /\\ pi <= b`;;\n\nlet PI_APPROX_32 = `abs(pi - &13493037705 / &4294967296) <= inv(&2 pow 32)`;;\n\nlet PI2_BOUNDS = `&0 < pi / &2 /\\ pi / &2 < &2`;;\n\nlet clog = new_definition\n `clog z = @w. cexp(w) = z /\\ --pi < Im(w) /\\ Im(w) <= pi`;;\n\nlet EXISTS_COMPLEX' = `!P. (?z. P (Re z) (Im z)) <=> ?x y. P x y`;;\n\nlet CLOG_WORKS = `!z. ~(z = Cx(&0))\n ==> cexp(clog z) = z /\\ --pi < Im(clog z) /\\ Im(clog z) <= pi`;;\n\nlet CEXP_CLOG = `!z. ~(z = Cx(&0)) ==> cexp(clog z) = z`;;\n\nlet CLOG_CEXP = `!z. --pi < Im(z) /\\ Im(z) <= pi ==> clog(cexp z) = z`;;\n\nlet CLOG_EQ = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0)) ==> (clog w = clog z <=> w = z)`;;\n\nlet CLOG_UNIQUE = `!w z. --pi < Im(z) /\\ Im(z) <= pi /\\ cexp(z) = w ==> clog w = z`;;\n\nlet RE_CLOG = `!z. ~(z = Cx(&0)) ==> Re(clog z) = log(norm z)`;;\n\nlet EXISTS_COMPLEX_ROOT = `!a n. ~(n = 0) ==> ?z. z pow n = a`;;\n\nlet HAS_COMPLEX_DERIVATIVE_CLOG = `!z. (Im(z) = &0 ==> &0 < Re(z))\n ==> (clog has_complex_derivative inv(z)) (at z)`;;\n\nlet COMPLEX_DIFFERENTIABLE_AT_CLOG = `!z. (Im(z) = &0 ==> &0 < Re(z)) ==> clog complex_differentiable at z`;;\n\nlet COMPLEX_DIFFERENTIABLE_WITHIN_CLOG = `!s z. (Im(z) = &0 ==> &0 < Re(z))\n ==> clog complex_differentiable (at z within s)`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN\n HAS_COMPLEX_DERIVATIVE_CLOG)));;\n\nlet CONTINUOUS_AT_CLOG = `!z. (Im(z) = &0 ==> &0 < Re(z)) ==> clog continuous at z`;;\n\nlet CONTINUOUS_WITHIN_CLOG = `!s z. (Im(z) = &0 ==> &0 < Re(z)) ==> clog continuous (at z within s)`;;\n\nlet CONTINUOUS_ON_CLOG = `!s. (!z. z IN s /\\ Im(z) = &0 ==> &0 < Re(z)) ==> clog continuous_on s`;;\n\nlet HOLOMORPHIC_ON_CLOG = `!s. (!z. z IN s /\\ Im(z) = &0 ==> &0 < Re(z)) ==> clog holomorphic_on s`;;\n\nlet CX_LOG = `!z. &0 < z ==> Cx(log z) = clog(Cx z)`;;\n\nlet RE_CLOG_POS_LT = `!z. ~(z = Cx(&0)) ==> (abs(Im(clog z)) < pi / &2 <=> &0 < Re(z))`;;\n\nlet RE_CLOG_POS_LE = `!z. ~(z = Cx(&0)) ==> (abs(Im(clog z)) <= pi / &2 <=> &0 <= Re(z))`;;\n\nlet IM_CLOG_POS_LT = `!z. ~(z = Cx(&0)) ==> (&0 < Im(clog z) /\\ Im(clog z) < pi <=> &0 < Im(z))`;;\n\nlet IM_CLOG_POS_LE = `!z. ~(z = Cx(&0)) ==> (&0 <= Im(clog z) <=> &0 <= Im(z))`;;\n\nlet RE_CLOG_POS_LT_IMP = `!z. &0 < Re(z) ==> abs(Im(clog z)) < pi / &2`;;\n\nlet IM_CLOG_POS_LT_IMP = `!z. &0 < Im(z) ==> &0 < Im(clog z) /\\ Im(clog z) < pi`;;\n\nlet IM_CLOG_EQ_0 = `!z. ~(z = Cx(&0)) ==> (Im(clog z) = &0 <=> &0 < Re(z) /\\ Im(z) = &0)`;;\n\nlet IM_CLOG_EQ_PI = `!z. ~(z = Cx(&0)) ==> (Im(clog z) = pi <=> Re(z) < &0 /\\ Im(z) = &0)`;;\n\nlet CNJ_CLOG = `!z. (Im z = &0 ==> &0 < Re z) ==> cnj(clog z) = clog(cnj z)`;;\n\nlet CLOG_INV = `!z. (Im(z) = &0 ==> &0 < Re z) ==> clog(inv z) = --(clog z)`;;\n\nlet CLOG_1 = `clog(Cx(&1)) = Cx(&0)`;;\n\nlet CLOG_NEG_1 = `clog(--Cx(&1)) = ii * Cx pi`;;\n\nlet CLOG_II = `clog ii = ii * Cx(pi / &2)`;;\n\nlet CLOG_NEG_II = `clog(--ii) = --ii * Cx(pi / &2)`;;\n\nlet CSQRT_CEXP_CLOG = `!z. ~(z = Cx(&0)) ==> csqrt z = cexp(clog(z) / Cx(&2))`;;\n\nlet CNJ_CSQRT = `!z. (Im z = &0 ==> &0 <= Re(z)) ==> cnj(csqrt z) = csqrt(cnj z)`;;\n\nlet HAS_COMPLEX_DERIVATIVE_CSQRT = `!z. (Im z = &0 ==> &0 < Re(z))\n ==> (csqrt has_complex_derivative inv(Cx(&2) * csqrt z)) (at z)`;;\n\nlet COMPLEX_DIFFERENTIABLE_AT_CSQRT = `!z. (Im z = &0 ==> &0 < Re(z)) ==> csqrt complex_differentiable at z`;;\n\nlet COMPLEX_DIFFERENTIABLE_WITHIN_CSQRT = `!s z. (Im z = &0 ==> &0 < Re(z))\n ==> csqrt complex_differentiable (at z within s)`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN\n HAS_COMPLEX_DERIVATIVE_CSQRT)));;\n\nlet CONTINUOUS_AT_CSQRT = `!z. (Im z = &0 ==> &0 < Re(z)) ==> csqrt continuous at z`;;\n\nlet CONTINUOUS_WITHIN_CSQRT = `!s z. (Im z = &0 ==> &0 < Re(z)) ==> csqrt continuous (at z within s)`;;\n\nlet CONTINUOUS_ON_CSQRT = `!s. (!z. z IN s /\\ Im z = &0 ==> &0 < Re(z)) ==> csqrt continuous_on s`;;\n\nlet HOLOMORPHIC_ON_CSQRT = `!s. (!z. z IN s /\\ Im(z) = &0 ==> &0 < Re(z)) ==> csqrt holomorphic_on s`;;\n\nlet CONTINUOUS_WITHIN_CSQRT_POSREAL = `!z. csqrt continuous (at z within {w | real w /\\ &0 <= Re(w)})`;;\n\nparse_as_infix(\"cpow\",(24,\"left\"));;\n\nlet cpow = new_definition\n `w cpow z = if w = Cx(&0) then Cx(&0)\n else cexp(z * clog w)`;;\n\nlet CPOW_0 = `!z. Cx(&0) cpow z = Cx(&0)`;;\n\nlet CPOW_N = `!z. z cpow (Cx(&n)) = if z = Cx(&0) then Cx(&0) else z pow n`;;\n\nlet CPOW_1 = `!z. Cx(&1) cpow z = Cx(&1)`;;\n\nlet CPOW_ADD = `!w z1 z2. w cpow (z1 + z2) = w cpow z1 * w cpow z2`;;\n\nlet CPOW_SUC = `!w z. w cpow (z + Cx(&1)) = w * w cpow z`;;\n\nlet CPOW_NEG = `!w z. w cpow (--z) = inv(w cpow z)`;;\n\nlet CPOW_SUB = `!w z1 z2. w cpow (z1 - z2) = w cpow z1 / w cpow z2`;;\n\nlet CEXP_MUL_CPOW = `!w z. --pi < Im w /\\ Im w <= pi ==> cexp(w * z) = cexp(w) cpow z`;;\n\nlet CPOW_EQ_0 = `!w z. w cpow z = Cx(&0) <=> w = Cx(&0)`;;\n\nlet NORM_CPOW_REAL = `!w z. real w /\\ &0 < Re w ==> norm(w cpow z) = exp(Re z * log(Re w))`;;\n\nlet CPOW_REAL_REAL = `!w z. real w /\\ real z /\\ &0 < Re w\n ==> w cpow z = Cx(exp(Re z * log(Re w)))`;;\n\nlet NORM_CPOW_REAL_MONO = `!w z1 z2. real w /\\ &1 < Re w\n ==> (norm(w cpow z1) <= norm(w cpow z2) <=> Re(z1) <= Re(z2))`;;\n\nlet CPOW_MUL_REAL = `!x y z. real x /\\ real y /\\ &0 <= Re x /\\ &0 <= Re y\n ==> (x * y) cpow z = x cpow z * y cpow z`;;\n\nlet HAS_COMPLEX_DERIVATIVE_CPOW = `!s z. (Im z = &0 ==> &0 < Re z)\n ==> ((\\z. z cpow s) has_complex_derivative\n (s * z cpow (s - Cx(&1)))) (at z)`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (GEN `s:complex`\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN\n (SPEC `s:complex` HAS_COMPLEX_DERIVATIVE_CPOW)))));;\n\nlet HAS_COMPLEX_DERIVATIVE_CPOW_RIGHT = `!w z. ~(w = Cx(&0))\n ==> ((\\z. w cpow z) has_complex_derivative clog(w) * w cpow z) (at z)`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (GEN `s:complex`\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN\n (SPEC `s:complex` HAS_COMPLEX_DERIVATIVE_CPOW_RIGHT)))));;\n\nlet COMPLEX_DIFFERENTIABLE_CPOW_RIGHT = `!w z. (\\z. w cpow z) complex_differentiable (at z)`;;\n\nlet HOLOMORPHIC_ON_CPOW_RIGHT = `!w f s. f holomorphic_on s\n ==> (\\z. w cpow (f z)) holomorphic_on s`;;\n\nlet CONTINUOUS_ON_CPOW_RIGHT = `!w f s. f continuous_on s\n ==> (\\z. w cpow (f z)) continuous_on s`;;\n\nlet CLOG_MUL = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0))\n ==> clog(w * z) =\n if Im(clog w + clog z) <= --pi then\n (clog(w) + clog(z)) + ii * Cx(&2 * pi)\n else if Im(clog w + clog z) > pi then\n (clog(w) + clog(z)) - ii * Cx(&2 * pi)\n else clog(w) + clog(z)`;;\n\nlet CLOG_MUL_SIMPLE = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0)) /\\\n --pi < Im(clog(w)) + Im(clog(z)) /\\\n Im(clog(w)) + Im(clog(z)) <= pi\n ==> clog(w * z) = clog(w) + clog(z)`;;\n\nlet CLOG_MUL_CX = `(!x z. &0 < x /\\ ~(z = Cx(&0)) ==> clog(Cx x * z) = Cx(log x) + clog z) /\\\n (!x z. &0 < x /\\ ~(z = Cx(&0)) ==> clog(z * Cx x) = clog z + Cx(log x))`;;\n\nlet CLOG_MUL_POS = `!w z. &0 < Re w /\\ &0 < Re z ==> clog(w * z) = clog w + clog z`;;\n\nlet CLOG_DIV_POS = `!w z. &0 < Re w /\\ &0 < Re z ==> clog(w / z) = clog w - clog z`;;\n\nlet CLOG_NEG = `!z. ~(z = Cx(&0))\n ==> clog(--z) = if Im(z) <= &0 /\\ ~(Re(z) < &0 /\\ Im(z) = &0)\n then clog(z) + ii * Cx(pi)\n else clog(z) - ii * Cx(pi)`;;\n\nlet CLOG_MUL_II = `!z. ~(z = Cx(&0))\n ==> clog(ii * z) = if &0 <= Re(z) \\/ Im(z) < &0\n then clog(z) + ii * Cx(pi / &2)\n else clog(z) - ii * Cx(&3 * pi / &2)`;;\n\nlet unwinding = new_definition\n `unwinding(z) = (z - clog(cexp z)) / (Cx(&2 * pi) * ii)`;;\n\nlet UNWINDING_2PI = `Cx(&2 * pi) * ii * unwinding(z) = z - clog(cexp z)`;;\n\nlet CLOG_MUL_UNWINDING = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0))\n ==> clog(w * z) =\n clog(w) + clog(z) -\n Cx(&2 * pi) * ii * unwinding(clog w + clog z)`;;\n\nlet catn = new_definition\n `catn z = (ii / Cx(&2)) * clog((Cx(&1) - ii * z) / (Cx(&1) + ii * z))`;;\n\nlet CATN_0 = `catn(Cx(&0)) = Cx(&0)`;;\n\nlet IM_COMPLEX_DIV_LEMMA = `!z. Im((Cx(&1) - ii * z) / (Cx(&1) + ii * z)) = &0 <=> Re z = &0`;;\n\nlet RE_COMPLEX_DIV_LEMMA = `!z. &0 < Re((Cx(&1) - ii * z) / (Cx(&1) + ii * z)) <=> norm(z) < &1`;;\n\nlet CTAN_CATN = `!z. ~(z pow 2 = --Cx(&1)) ==> ctan(catn z) = z`;;\n\nlet CATN_CTAN = `!z. abs(Re z) < pi / &2 ==> catn(ctan z) = z`;;\n\nlet RE_CATN_BOUNDS = `!z. (Re z = &0 ==> abs(Im z) < &1) ==> abs(Re(catn z)) < pi / &2`;;\n\nlet HAS_COMPLEX_DERIVATIVE_CATN = `!z. (Re z = &0 ==> abs(Im z) < &1)\n ==> (catn has_complex_derivative inv(Cx(&1) + z pow 2)) (at z)`;;\n\nlet COMPLEX_DIFFERENTIABLE_AT_CATN = `!z. (Re z = &0 ==> abs(Im z) < &1) ==> catn complex_differentiable at z`;;\n\nlet COMPLEX_DIFFERENTIABLE_WITHIN_CATN = `!s z. (Re z = &0 ==> abs(Im z) < &1)\n ==> catn complex_differentiable (at z within s)`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN\n HAS_COMPLEX_DERIVATIVE_CATN)));;\n\nlet CONTINUOUS_AT_CATN = `!z. (Re z = &0 ==> abs(Im z) < &1) ==> catn continuous at z`;;\n\nlet CONTINUOUS_WITHIN_CATN = `!s z. (Re z = &0 ==> abs(Im z) < &1) ==> catn continuous (at z within s)`;;\n\nlet CONTINUOUS_ON_CATN = `!s. (!z. z IN s /\\ Re z = &0 ==> abs(Im z) < &1) ==> catn continuous_on s`;;\n\nlet HOLOMORPHIC_ON_CATN = `!s. (!z. z IN s /\\ Re z = &0 ==> abs(Im z) < &1) ==> catn holomorphic_on s`;;\n\nlet atn = new_definition\n `atn(x) = Re(catn(Cx x))`;;\n\nlet CX_ATN = `!x. Cx(atn x) = catn(Cx x)`;;\n\nlet ATN_TAN = `!y. tan(atn y) = y`;;\n\nlet ATN_BOUND = `!y. abs(atn y) < pi / &2`;;\n\nlet ATN_BOUNDS = `!y. --(pi / &2) < atn(y) /\\ atn(y) < (pi / &2)`;;\n\nlet TAN_ATN = `!x. --(pi / &2) < x /\\ x < pi / &2 ==> atn(tan(x)) = x`;;\n\nlet ATN_0 = `atn(&0) = &0`;;\n\nlet ATN_1 = `atn(&1) = pi / &4`;;\n\nlet ATN_NEG = `!x. atn(--x) = --(atn x)`;;\n\nlet ATN_MONO_LT = `!x y. x < y ==> atn(x) < atn(y)`;;\n\nlet ATN_MONO_LT_EQ = `!x y. atn(x) < atn(y) <=> x < y`;;\n\nlet ATN_MONO_LE_EQ = `!x y. atn(x) <= atn(y) <=> x <= y`;;\n\nlet ATN_INJ = `!x y. (atn x = atn y) <=> (x = y)`;;\n\nlet ATN_POS_LT = `&0 < atn(x) <=> &0 < x`;;\n\nlet ATN_POS_LE = `&0 <= atn(x) <=> &0 <= x`;;\n\nlet ATN_LT_PI4_POS = `!x. x < &1 ==> atn(x) < pi / &4`;;\n\nlet ATN_LT_PI4_NEG = `!x. --(&1) < x ==> --(pi / &4) < atn(x)`;;\n\nlet ATN_LT_PI4 = `!x. abs(x) < &1 ==> abs(atn x) < pi / &4`;;\n\nlet ATN_LE_PI4 = `!x. abs(x) <= &1 ==> abs(atn x) <= pi / &4`;;\n\nlet COS_ATN_NZ = `!x. ~(cos(atn(x)) = &0)`;;\n\nlet TAN_SEC = `!x. ~(cos(x) = &0) ==> (&1 + (tan(x) pow 2) = inv(cos x) pow 2)`;;\n\nlet COS_ATN = `!x. cos(atn x) = &1 / sqrt(&1 + x pow 2)`;;\n\nlet SIN_ATN = `!x. sin(atn x) = x / sqrt(&1 + x pow 2)`;;\n\nlet ATN_ABS = `!x. atn(abs x) = abs(atn x)`;;\n\nlet ATN_ADD = `!x y. abs(atn x + atn y) < pi / &2\n ==> atn(x) + atn(y) = atn((x + y) / (&1 - x * y))`;;\n\nlet ATN_INV = `!x. &0 < x ==> atn(inv x) = pi / &2 - atn x`;;\n\nlet ATN_ADD_SMALL = `!x y. abs(x * y) < &1\n ==> (atn(x) + atn(y) = atn((x + y) / (&1 - x * y)))`;;\n\nlet [MACHIN; MACHIN_EULER; MACHIN_GAUSS] = (CONJUNCTS o prove)\n (`(&4 * atn(&1 / &5) - atn(&1 / &239) = pi / &4) /\\\n (&5 * atn(&1 / &7) + &2 * atn(&3 / &79) = pi / &4) /\\\n (&12 * atn(&1 / &18) + &8 * atn(&1 / &57) - &5 * atn(&1 / &239) = pi / &4)`,\n REPEAT CONJ_TAC THEN CONV_TAC(ONCE_DEPTH_CONV(fun tm ->\n if is_binop `( * ):real->real->real` tm\n then LAND_CONV(RAND_CONV(TOP_DEPTH_CONV num_CONV)) tm\n else failwith \"\")) THEN\n REWRITE_TAC[real_sub; GSYM REAL_MUL_RNEG; GSYM ATN_NEG] THEN\n REWRITE_TAC[GSYM REAL_OF_NUM_SUC; REAL_ADD_RDISTRIB] THEN\n REWRITE_TAC[REAL_MUL_LZERO; REAL_MUL_LID; REAL_ADD_LID] THEN\n CONV_TAC(DEPTH_CONV (fun tm ->\n let th1 = PART_MATCH (lhand o rand) ATN_ADD_SMALL tm in\n let th2 = MP th1 (EQT_ELIM(REAL_RAT_REDUCE_CONV(lhand(concl th1)))) in\n CONV_RULE(RAND_CONV(RAND_CONV REAL_RAT_REDUCE_CONV)) th2)) THEN\n REWRITE_TAC[ATN_1]);;\n\nlet ATN_ABS_LE_X = `!x. abs(atn x) <= abs x`;;\n\nlet ATN_LE_X = `!x. &0 <= x ==> atn(x) <= x`;;\n\nlet TAN_ABS_GE_X = `!x. abs(x) < pi / &2 ==> abs(x) <= abs(tan x)`;;\n\nlet TAN_TOTAL = `!y. ?!x. --(pi / &2) < x /\\ x < (pi / &2) /\\ tan(x) = y`;;\n\nlet TAN_TOTAL_POS = `!y. &0 <= y ==> ?x. &0 <= x /\\ x < pi / &2 /\\ tan(x) = y`;;\n\nlet TAN_TOTAL_LEMMA = `!y. &0 < y ==> ?x. &0 < x /\\ x < pi / &2 /\\ y < tan(x)`;;\n\nlet RE_POW_2 = `Re(z pow 2) = Re(z) pow 2 - Im(z) pow 2`;;\n\nlet IM_POW_2 = `Im(z pow 2) = &2 * Re(z) * Im(z)`;;\n\nlet casn = new_definition\n `casn z = --ii * clog(ii * z + csqrt(Cx(&1) - z pow 2))`;;\n\nlet CASN_BODY_LEMMA = `!z. ~(ii * z + csqrt(Cx(&1) - z pow 2) = Cx(&0))`;;\n\nlet CSIN_CASN = `!z. csin(casn z) = z`;;\n\nlet CASN_CSIN = `!z. abs(Re z) < pi / &2 \\/ (abs(Re z) = pi / &2 /\\ Im z = &0)\n ==> casn(csin z) = z`;;\n\nlet CASN_UNIQUE = `!w z. csin(z) = w /\\\n (abs(Re z) < pi / &2 \\/ (abs(Re z) = pi / &2 /\\ Im z = &0))\n ==> casn w = z`;;\n\nlet CASN_0 = `casn(Cx(&0)) = Cx(&0)`;;\n\nlet CASN_1 = `casn(Cx(&1)) = Cx(pi / &2)`;;\n\nlet CASN_NEG_1 = `casn(--Cx(&1)) = --Cx(pi / &2)`;;\n\nlet HAS_COMPLEX_DERIVATIVE_CASN = `!z. (Im z = &0 ==> abs(Re z) < &1)\n ==> (casn has_complex_derivative inv(ccos(casn z))) (at z)`;;\n\nlet COMPLEX_DIFFERENTIABLE_AT_CASN = `!z. (Im z = &0 ==> abs(Re z) < &1) ==> casn complex_differentiable at z`;;\n\nlet COMPLEX_DIFFERENTIABLE_WITHIN_CASN = `!s z. (Im z = &0 ==> abs(Re z) < &1)\n ==> casn complex_differentiable (at z within s)`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN\n HAS_COMPLEX_DERIVATIVE_CASN)));;\n\nlet CONTINUOUS_AT_CASN = `!z. (Im z = &0 ==> abs(Re z) < &1) ==> casn continuous at z`;;\n\nlet CONTINUOUS_WITHIN_CASN = `!s z. (Im z = &0 ==> abs(Re z) < &1) ==> casn continuous (at z within s)`;;\n\nlet CONTINUOUS_ON_CASN = `!s. (!z. z IN s /\\ Im z = &0 ==> abs(Re z) < &1) ==> casn continuous_on s`;;\n\nlet HOLOMORPHIC_ON_CASN = `!s. (!z. z IN s /\\ Im z = &0 ==> abs(Re z) < &1) ==> casn holomorphic_on s`;;\n\nlet cacs = new_definition\n `cacs z = --ii * clog(z + ii * csqrt(Cx(&1) - z pow 2))`;;\n\nlet CACS_BODY_LEMMA = `!z. ~(z + ii * csqrt(Cx(&1) - z pow 2) = Cx(&0))`;;\n\nlet CCOS_CACS = `!z. ccos(cacs z) = z`;;\n\nlet CACS_CCOS = `!z. &0 < Re z /\\ Re z < pi \\/\n Re(z) = &0 /\\ &0 <= Im(z) \\/\n Re(z) = pi /\\ Im(z) <= &0\n ==> cacs(ccos z) = z`;;\n\nlet CACS_UNIQUE = `!w z.\n ccos z = w /\\\n (&0 < Re z /\\ Re z < pi \\/\n Re(z) = &0 /\\ &0 <= Im(z) \\/\n Re(z) = pi /\\ Im(z) <= &0)\n ==> cacs(w) = z`;;\n\nlet CACS_0 = `cacs(Cx(&0)) = Cx(pi / &2)`;;\n\nlet CACS_1 = `cacs(Cx(&1)) = Cx(&0)`;;\n\nlet CACS_NEG_1 = `cacs(--Cx(&1)) = Cx pi`;;\n\nlet HAS_COMPLEX_DERIVATIVE_CACS = `!z. (Im z = &0 ==> abs(Re z) < &1)\n ==> (cacs has_complex_derivative --inv(csin(cacs z))) (at z)`;;\n\nlet COMPLEX_DIFFERENTIABLE_AT_CACS = `!z. (Im z = &0 ==> abs(Re z) < &1) ==> cacs complex_differentiable at z`;;\n\nlet COMPLEX_DIFFERENTIABLE_WITHIN_CACS = `!s z. (Im z = &0 ==> abs(Re z) < &1)\n ==> cacs complex_differentiable (at z within s)`;;\n\nadd_complex_differentiation_theorems\n (CONJUNCTS(REWRITE_RULE[FORALL_AND_THM]\n (MATCH_MP HAS_COMPLEX_DERIVATIVE_CHAIN\n HAS_COMPLEX_DERIVATIVE_CACS)));;\n\nlet CONTINUOUS_AT_CACS = `!z. (Im z = &0 ==> abs(Re z) < &1) ==> cacs continuous at z`;;\n\nlet CONTINUOUS_WITHIN_CACS = `!s z. (Im z = &0 ==> abs(Re z) < &1) ==> cacs continuous (at z within s)`;;\n\nlet CONTINUOUS_ON_CACS = `!s. (!z. z IN s /\\ Im z = &0 ==> abs(Re z) < &1) ==> cacs continuous_on s`;;\n\nlet HOLOMORPHIC_ON_CACS = `!s. (!z. z IN s /\\ Im z = &0 ==> abs(Re z) < &1) ==> cacs holomorphic_on s`;;\n\nlet CASN_RANGE_LEMMA = `!z. abs (Re z) < &1 ==> &0 < Re(ii * z + csqrt(Cx(&1) - z pow 2))`;;\n\nlet CACS_RANGE_LEMMA = `!z. abs(Re z) < &1 ==> &0 < Im(z + ii * csqrt(Cx(&1) - z pow 2))`;;\n\nlet RE_CASN = `!z. Re(casn z) = Im(clog(ii * z + csqrt(Cx(&1) - z pow 2)))`;;\n\nlet RE_CACS = `!z. Re(cacs z) = Im(clog(z + ii * csqrt(Cx(&1) - z pow 2)))`;;\n\nlet CASN_BOUNDS = `!z. abs(Re z) < &1 ==> abs(Re(casn z)) < pi / &2`;;\n\nlet CACS_BOUNDS = `!z. abs(Re z) < &1 ==> &0 < Re(cacs z) /\\ Re(cacs z) < pi`;;\n\nlet RE_CACS_BOUNDS = `!z. --pi < Re(cacs z) /\\ Re(cacs z) <= pi`;;\n\nlet RE_CACS_BOUND = `!z. abs(Re(cacs z)) <= pi`;;\n\nlet RE_CASN_BOUNDS = `!z. --pi < Re(casn z) /\\ Re(casn z) <= pi`;;\n\nlet RE_CASN_BOUND = `!z. abs(Re(casn z)) <= pi`;;\n\nlet CCOS_CASN_NZ = `!z. ~(z pow 2 = Cx(&1)) ==> ~(ccos(casn z) = Cx(&0))`;;\n\nlet CSIN_CACS_NZ = `!z. ~(z pow 2 = Cx(&1)) ==> ~(csin(cacs z) = Cx(&0))`;;\n\nlet CCOS_CSIN_CSQRT = `!z. &0 < cos(Re z) \\/ cos(Re z) = &0 /\\ Im(z) * sin(Re z) <= &0\n ==> ccos(z) = csqrt(Cx(&1) - csin(z) pow 2)`;;\n\nlet CSIN_CCOS_CSQRT = `!z. &0 < sin(Re z) \\/ sin(Re z) = &0 /\\ &0 <= Im(z) * cos(Re z)\n ==> csin(z) = csqrt(Cx(&1) - ccos(z) pow 2)`;;\n\nlet CASN_CACS_SQRT_POS = `!z. (&0 < Re z \\/ Re z = &0 /\\ &0 <= Im z)\n ==> casn(z) = cacs(csqrt(Cx(&1) - z pow 2))`;;\n\nlet CACS_CASN_SQRT_POS = `!z. (&0 < Re z \\/ Re z = &0 /\\ &0 <= Im z)\n ==> cacs(z) = casn(csqrt(Cx(&1) - z pow 2))`;;\n\nlet CSIN_CACS = `!z. &0 < Re z \\/ Re(z) = &0 /\\ &0 <= Im z\n ==> csin(cacs z) = csqrt(Cx(&1) - z pow 2)`;;\n\nlet CCOS_CASN = `!z. &0 < Re z \\/ Re(z) = &0 /\\ &0 <= Im z\n ==> ccos(casn z) = csqrt(Cx(&1) - z pow 2)`;;\n\nlet asn = new_definition `asn(x) = Re(casn(Cx x))`;;\n\nlet REAL_ASN = `!z. real z /\\ abs(Re z) <= &1 ==> real(casn z)`;;\n\nlet CX_ASN = `!x. abs(x) <= &1 ==> Cx(asn x) = casn(Cx x)`;;\n\nlet SIN_ASN = `!y. --(&1) <= y /\\ y <= &1 ==> sin(asn(y)) = y`;;\n\nlet ASN_SIN = `!x. --(pi / &2) <= x /\\ x <= pi / &2 ==> asn(sin(x)) = x`;;\n\nlet ASN_BOUNDS_LT = `!y. --(&1) < y /\\ y < &1 ==> --(pi / &2) < asn(y) /\\ asn(y) < pi / &2`;;\n\nlet ASN_0 = `asn(&0) = &0`;;\n\nlet ASN_1 = `asn(&1) = pi / &2`;;\n\nlet ASN_NEG_1 = `asn(-- &1) = --(pi / &2)`;;\n\nlet ASN_BOUNDS = `!y. --(&1) <= y /\\ y <= &1 ==> --(pi / &2) <= asn(y) /\\ asn(y) <= pi / &2`;;\n\nlet ASN_BOUNDS_PI2 = `!x. &0 <= x /\\ x <= &1 ==> &0 <= asn x /\\ asn x <= pi / &2`;;\n\nlet ASN_NEG = `!x. -- &1 <= x /\\ x <= &1 ==> asn(--x) = --asn(x)`;;\n\nlet COS_ASN_NZ = `!x. --(&1) < x /\\ x < &1 ==> ~(cos(asn(x)) = &0)`;;\n\nlet ASN_MONO_LT_EQ = `!x y. abs(x) <= &1 /\\ abs(y) <= &1 ==> (asn(x) < asn(y) <=> x < y)`;;\n\nlet ASN_MONO_LE_EQ = `!x y. abs(x) <= &1 /\\ abs(y) <= &1 ==> (asn(x) <= asn(y) <=> x <= y)`;;\n\nlet ASN_MONO_LT = `!x y. --(&1) <= x /\\ x < y /\\ y <= &1 ==> asn(x) < asn(y)`;;\n\nlet ASN_MONO_LE = `!x y. --(&1) <= x /\\ x <= y /\\ y <= &1 ==> asn(x) <= asn(y)`;;\n\nlet COS_ASN = `!x. --(&1) <= x /\\ x <= &1 ==> cos(asn x) = sqrt(&1 - x pow 2)`;;\n\nlet acs = new_definition `acs(x) = Re(cacs(Cx x))`;;\n\nlet REAL_ACS = `!z. real z /\\ abs(Re z) <= &1 ==> real(cacs z)`;;\n\nlet CX_ACS = `!x. abs(x) <= &1 ==> Cx(acs x) = cacs(Cx x)`;;\n\nlet COS_ACS = `!y. --(&1) <= y /\\ y <= &1 ==> cos(acs(y)) = y`;;\n\nlet ACS_COS = `!x. &0 <= x /\\ x <= pi ==> acs(cos(x)) = x`;;\n\nlet ACS_BOUNDS_LT = `!y. --(&1) < y /\\ y < &1 ==> &0 < acs(y) /\\ acs(y) < pi`;;\n\nlet ACS_0 = `acs(&0) = pi / &2`;;\n\nlet ACS_1 = `acs(&1) = &0`;;\n\nlet ACS_NEG_1 = `acs(-- &1) = pi`;;\n\nlet ACS_BOUNDS = `!y. --(&1) <= y /\\ y <= &1 ==> &0 <= acs(y) /\\ acs(y) <= pi`;;\n\nlet ACS_NEG = `!x. -- &1 <= x /\\ x <= &1 ==> acs(--x) = pi - acs(x)`;;\n\nlet SIN_ACS_NZ = `!x. --(&1) < x /\\ x < &1 ==> ~(sin(acs(x)) = &0)`;;\n\nlet ACS_MONO_LT_EQ = `!x y. abs(x) <= &1 /\\ abs(y) <= &1 ==> (acs(x) < acs(y) <=> y < x)`;;\n\nlet ACS_MONO_LE_EQ = `!x y. abs(x) <= &1 /\\ abs(y) <= &1 ==> (acs(x) <= acs(y) <=> y <= x)`;;\n\nlet ACS_MONO_LT = `!x y. --(&1) <= x /\\ x < y /\\ y <= &1 ==> acs(y) < acs(x)`;;\n\nlet ACS_MONO_LE = `!x y. --(&1) <= x /\\ x <= y /\\ y <= &1 ==> acs(y) <= acs(x)`;;\n\nlet SIN_ACS = `!x. --(&1) <= x /\\ x <= &1 ==> sin(acs x) = sqrt(&1 - x pow 2)`;;\n\nlet ACS_INJ = `!x y. abs(x) <= &1 /\\ abs(y) <= &1 ==> (acs x = acs y <=> x = y)`;;\n\nlet ACS_ATN = `!x. -- &1 < x /\\ x < &1 ==> acs(x) = pi / &2 - atn(x / sqrt(&1 - x pow 2))`;;\n\nlet ASN_PLUS_ACS = `!x. -- &1 <= x /\\ x <= &1 ==> asn(x) + acs(x) = pi / &2`;;\n\nlet ASN_ACS = `!x. -- &1 <= x /\\ x <= &1 ==> asn(x) = pi / &2 - acs(x)`;;\n\nlet ACS_ASN = `!x. -- &1 <= x /\\ x <= &1 ==> acs(x) = pi / &2 - asn(x)`;;\n\nlet ASN_ATN = `!x. -- &1 < x /\\ x < &1 ==> asn(x) = atn(x / sqrt(&1 - x pow 2))`;;\n\nlet ASN_ACS_SQRT_POS = `!x. &0 <= x /\\ x <= &1 ==> asn(x) = acs(sqrt(&1 - x pow 2))`;;\n\nlet ASN_ACS_SQRT_NEG = `!x. -- &1 <= x /\\ x <= &0 ==> asn(x) = --acs(sqrt(&1 - x pow 2))`;;\n\nlet ACS_ASN_SQRT_POS = `!x. &0 <= x /\\ x <= &1 ==> acs(x) = asn(sqrt(&1 - x pow 2))`;;\n\nlet ACS_ASN_SQRT_NEG = `!x. -- &1 <= x /\\ x <= &0 ==> acs(x) = pi - asn(sqrt(&1 - x pow 2))`;;\n\nlet CONTINUOUS_ON_CASN_REAL = `casn continuous_on {w | real w /\\ abs(Re w) <= &1}`;;\n\nlet CONTINUOUS_WITHIN_CASN_REAL = `!z. casn continuous (at z within {w | real w /\\ abs(Re w) <= &1})`;;\n\nlet CONTINUOUS_ON_CACS_REAL = `cacs continuous_on {w | real w /\\ abs(Re w) <= &1}`;;\n\nlet CONTINUOUS_WITHIN_CACS_REAL = `!z. cacs continuous (at z within {w | real w /\\ abs(Re w) <= &1})`;;\n\nlet LIM_CX_OVER_CEXP = `((\\x. Cx x / cexp(Cx x)) --> Cx(&0)) at_posinfinity`;;\n\nlet LIM_Z_TIMES_CLOG = `((\\z. z * clog z) --> Cx(&0)) (at (Cx(&0)))`;;\n\nlet LIM_LOG_OVER_Z = `((\\z. clog z / z) --> Cx(&0)) at_infinity`;;\n\nlet LIM_LOG_OVER_POWER = `!s. &0 < Re s\n ==> ((\\x. clog(Cx x) / (Cx x) cpow s) --> Cx(&0)) at_posinfinity`;;\n\nlet LIM_LOG_OVER_X = `((\\x. clog(Cx x) / Cx x) --> Cx(&0)) at_posinfinity`;;\n\nlet LIM_LOG_OVER_POWER_N = `!s. &0 < Re s\n ==> ((\\n. clog(Cx(&n)) / Cx(&n) cpow s) --> Cx(&0)) sequentially`;;\n\nlet LIM_LOG_OVER_N = `((\\n. clog(Cx(&n)) / Cx(&n)) --> Cx(&0)) sequentially`;;\n\nlet LIM_1_OVER_POWER = `!s. &0 < Re s\n ==> ((\\n. Cx(&1) / Cx(&n) cpow s) --> Cx(&0)) sequentially`;;\n\nlet LIM_INV_Z_OFFSET = `!z. ((\\w. inv(w + z)) --> Cx(&0)) at_infinity`;;\n\nlet LIM_INV_Z = `((\\z. inv(z)) --> Cx(&0)) at_infinity`;;\n\nlet LIM_INV_X_OFFSET = `!z. ((\\x. inv(Cx x + z)) --> Cx(&0)) at_posinfinity`;;\n\nlet LIM_INV_X = `((\\x. inv(Cx x)) --> Cx(&0)) at_posinfinity`;;\n\nlet LIM_INV_N_OFFSET = `!z. ((\\n. inv(Cx(&n) + z)) --> Cx(&0)) sequentially`;;\n\nlet LIM_1_OVER_N = `((\\n. Cx(&1) / Cx(&n)) --> Cx(&0)) sequentially`;;\n\nlet LIM_INV_N = `((\\n. inv(Cx(&n))) --> Cx(&0)) sequentially`;;\n\nlet LIM_INV_Z_POW_OFFSET = `!z n. 1 <= n ==> ((\\w. inv(w + z) pow n) --> Cx(&0)) at_infinity`;;\n\nlet LIM_INV_Z_POW = `!n. 1 <= n ==> ((\\z. inv(z) pow n) --> Cx(&0)) at_infinity`;;\n\nlet LIM_INV_X_POW_OFFSET = `!z n. 1 <= n ==> ((\\x. inv(Cx x + z) pow n) --> Cx(&0)) at_posinfinity`;;\n\nlet LIM_INV_X_POW = `!n. 1 <= n ==> ((\\x. inv(Cx x) pow n) --> Cx(&0)) at_posinfinity`;;\n\nlet LIM_INV_N_POW_OFFSET = `!z m. 1 <= m ==> ((\\n. inv(Cx(&n) + z) pow m) --> Cx(&0)) sequentially`;;\n\nlet LIM_INV_N_POW = `!m. 1 <= m ==> ((\\n. inv(Cx(&n)) pow m) --> Cx(&0)) sequentially`;;\n\nlet LIM_1_OVER_LOG = `((\\n. Cx(&1) / clog(Cx(&n))) --> Cx(&0)) sequentially`;;\n\nlet LIM_N_TIMES_POWN = `!z. norm(z) < &1 ==> ((\\n. Cx(&n) * z pow n) --> Cx(&0)) sequentially`;;\n\nlet LIM_N_OVER_POWN = `!z. &1 < norm(z) ==> ((\\n. Cx(&n) / z pow n) --> Cx(&0)) sequentially`;;\n\nlet LIM_POWN = `!z. norm(z) < &1 ==> ((\\n. z pow n) --> Cx(&0)) sequentially`;;\n\nlet LIM_CSIN_OVER_X = `((\\z. csin z / z) --> Cx(&1)) (at (Cx(&0)))`;;\n\nlet COMPLEX_ROOT_POLYFUN = `!n z a.\n 1 <= n\n ==> (z pow n = a <=>\n vsum(0..n) (\\i. (if i = 0 then --a else if i = n then Cx(&1)\n else Cx(&0)) * z pow i) = Cx(&0))`;;\n\nlet COMPLEX_ROOT_UNITY = `!n j. ~(n = 0)\n ==> cexp(Cx(&2) * Cx pi * ii * Cx(&j / &n)) pow n = Cx(&1)`;;\n\nlet COMPLEX_ROOT_UNITY_EQ = `!n j k. ~(n = 0)\n ==> (cexp(Cx(&2) * Cx pi * ii * Cx(&j / &n)) =\n cexp(Cx(&2) * Cx pi * ii * Cx(&k / &n)) <=> (j == k) (mod n))`;;\n\nlet COMPLEX_ROOT_UNITY_EQ_1 = `!n j. ~(n = 0)\n ==> (cexp(Cx(&2) * Cx pi * ii * Cx(&j / &n)) = Cx(&1) <=>\n n divides j)`;;\n\nlet FINITE_CARD_COMPLEX_ROOTS_UNITY = `!n. 1 <= n\n ==> FINITE {z | z pow n = Cx(&1)} /\\ CARD {z | z pow n = Cx(&1)} <= n`;;\n\nlet FINITE_COMPLEX_ROOTS_UNITY = `!n. ~(n = 0) ==> FINITE {z | z pow n = Cx(&1)}`;;\n\nlet FINITE_CARD_COMPLEX_ROOTS_UNITY_EXPLICIT = `!n. 1 <= n\n ==> FINITE {cexp(Cx(&2) * Cx pi * ii * Cx(&j / &n)) | j | j < n} /\\\n CARD {cexp(Cx(&2) * Cx pi * ii * Cx(&j / &n)) | j | j < n} = n`;;\n\nlet COMPLEX_ROOTS_UNITY = `!n. 1 <= n\n ==> {z | z pow n = Cx(&1)} =\n {cexp(Cx(&2) * Cx pi * ii * Cx(&j / &n)) | j | j < n}`;;\n\nlet CARD_COMPLEX_ROOTS_UNITY = `!n. 1 <= n ==> CARD {z | z pow n = Cx(&1)} = n`;;\n\nlet HAS_SIZE_COMPLEX_ROOTS_UNITY = `!n. 1 <= n ==> {z | z pow n = Cx(&1)} HAS_SIZE n`;;\n\nlet COMPLEX_NOT_ROOT_UNITY = `!n. 1 <= n ==> ?u. norm u = &1 /\\ ~(u pow n = Cx(&1))`;;\n\nlet ARG_CLOG = `!z. &0 < Arg z ==> Arg z = Im(clog(--z)) + pi`;;\n\nlet CONTINUOUS_AT_ARG = `!z. ~(real z /\\ &0 <= Re z) ==> (Cx o Arg) continuous (at z)`;;\n\nlet CONTINUOUS_ON_ARG = `!s. (!z. z IN s /\\ real z ==> Re z < &0) ==> (Cx o Arg) continuous_on s`;;\n\nlet CONTINUOUS_WITHIN_UPPERHALF_ARG = `!z. ~(z = Cx(&0))\n ==> (Cx o Arg) continuous (at z) within {z | &0 <= Im z}`;;\n\nlet CONTINUOUS_ON_UPPERHALF_ARG = `(Cx o Arg) continuous_on ({z | &0 <= Im z} DIFF {Cx(&0)})`;;\n\nlet CONTINUOUS_ON_COMPOSE_ARG = `!s p:real->real^N.\n (p o drop) continuous_on interval[vec 0,lift(&2 * pi)] /\\\n p(&2 * pi) = p(&0) /\\ ~(Cx(&0) IN s)\n ==> (\\z. p(Arg z)) continuous_on s`;;\n\nlet OPEN_ARG_LTT = `!s t. &0 <= s /\\ t <= &2 * pi ==> open {z | s < Arg z /\\ Arg z < t}`;;\n\nlet OPEN_ARG_GT = `!t. open {z | t < Arg z}`;;\n\nlet CLOSED_ARG_LE = `!t. closed {z | Arg z <= t}`;;\n\nlet ARG_ATAN_UPPERHALF = `!z. &0 < Im z ==> Arg(z) = pi / &2 - atn(Re z / Im z)`;;\n\nlet root = new_definition\n `root(n) x = real_sgn(x) * exp(log(abs x) / &n)`;;\n\nlet ROOT_0 = `!n. root n (&0) = &0`;;\n\nlet ROOT_1 = `!n. root n (&1) = &1`;;\n\nlet ROOT_2 = `!x. root 2 x = sqrt x`;;\n\nlet ROOT_NEG = `!n x. root n (--x) = --(root n x)`;;\n\nlet ROOT_WORKS = `!n x. real_sgn(root n x) = real_sgn x /\\\n (root n x) pow n = if n = 0 then &1\n else real_sgn(x) pow n * abs x`;;\n\nlet REAL_POW_ROOT = `!n x. ODD n \\/ ~(n = 0) /\\ &0 <= x ==> (root n x) pow n = x`;;\n\nlet ROOT_POS_LT = `!n x. &0 < x ==> &0 < root n x`;;\n\nlet ROOT_POS_LE = `!n x. &0 <= x ==> &0 <= root n x`;;\n\nlet ROOT_LT_0 = `!n x. &0 < root n x <=> &0 < x`;;\n\nlet ROOT_LE_0 = `!n x. &0 <= root n x <=> &0 <= x`;;\n\nlet ROOT_EQ_0 = `!n x. root n x = &0 <=> x = &0`;;\n\nlet REAL_ROOT_MUL = `!n x y. root n (x * y) = root n x * root n y`;;\n\nlet REAL_ROOT_POW_GEN = `!m n x. root n (x pow m) = (root n x) pow m`;;\n\nlet REAL_ROOT_POW = `!n x. ODD n \\/ ~(n = 0) /\\ &0 <= x ==> root n (x pow n) = x`;;\n\nlet ROOT_UNIQUE = `!n x y. y pow n = x /\\ (ODD n \\/ ~(n = 0) /\\ &0 <= y) ==> root n x = y`;;\n\nlet REAL_ROOT_INV = `!n x. root n (inv x) = inv(root n x)`;;\n\nlet REAL_ROOT_DIV = `!n x y. root n (x / y) = root n x / root n y`;;\n\nlet ROOT_MONO_LT = `!n x y. ~(n = 0) /\\ x < y ==> root n x < root n y`;;\n\nlet ROOT_MONO_LE = `!n x y. x <= y ==> root n x <= root n y`;;\n\nlet ROOT_MONO_LT_EQ = `!n x y. ~(n = 0) ==> (root n x < root n y <=> x < y)`;;\n\nlet ROOT_MONO_LE_EQ = `!n x y. ~(n = 0) ==> (root n x <= root n y <=> x <= y)`;;\n\nlet ROOT_INJ = `!n x y. ~(n = 0) ==> (root n x = root n y <=> x = y)`;;\n\nlet REAL_ROOT_LE = `!n x y. ~(n = 0) /\\ &0 <= y\n ==> (root n x <= y <=> x <= y pow n)`;;\n\nlet REAL_LE_ROOT = `!n x y. ~(n = 0) /\\ &0 <= x\n ==> (x <= root n y <=> x pow n <= y)`;;\n\nlet LOG_ROOT = `!n x. ~(n = 0) /\\ &0 < x ==> log(root n x) = log x / &n`;;\n\nlet ROOT_EXP_LOG = `!n x. ~(n = 0) /\\ &0 < x ==> root n x = exp(log x / &n)`;;\n\nlet ROOT_PRODUCT = `!n f s. FINITE s ==> root n (product s f) = product s (\\i. root n (f i))`;;\n\nlet SQRT_PRODUCT = `!f s. FINITE s ==> sqrt(product s f) = product s (\\i. sqrt(f i))`;;\n\nparse_as_infix(\"rpow\",(24,\"left\"));;\n\nlet rpow = new_definition\n `x rpow y = if &0 < x then exp(y * log x)\n else if x = &0 then if y = &0 then &1 else &0\n else if ?m n. ODD(m) /\\ ODD(n) /\\ (abs y = &m / &n)\n then --(exp(y * log(--x)))\n else exp(y * log(--x))`;;\n\nlet RPOW_POW = `!x n. x rpow &n = x pow n`;;\n\nlet RPOW_0 = `!x. x rpow &0 = &1`;;\n\nlet RPOW_NEG = `!x y. x rpow (--y) = inv(x rpow y)`;;\n\nlet RPOW_ZERO = `!y. &0 rpow y = if y = &0 then &1 else &0`;;\n\nlet RPOW_POS_LT = `!x y. &0 < x ==> &0 < x rpow y`;;\n\nlet RPOW_POS_LE = `!x y. &0 <= x ==> &0 <= x rpow y`;;\n\nlet RPOW_LT2 = `!x y z. &0 <= x /\\ x < y /\\ &0 < z ==> x rpow z < y rpow z`;;\n\nlet RPOW_LE2 = `!x y z. &0 <= x /\\ x <= y /\\ &0 <= z ==> x rpow z <= y rpow z`;;\n\nlet REAL_ABS_RPOW = `!x y. abs(x rpow y) = abs(x) rpow y`;;\n\nlet RPOW_ONE = `!z. &1 rpow z = &1`;;\n\nlet RPOW_RPOW = `!x y z. &0 <= x ==> x rpow y rpow z = x rpow (y * z)`;;\n\nlet RPOW_LNEG = `!x y. --x rpow y =\n if ?m n. ODD m /\\ ODD n /\\ abs y = &m / &n\n then --(x rpow y) else x rpow y`;;\n\nlet RPOW_EQ_0 = `!x y. x rpow y = &0 <=> x = &0 /\\ ~(y = &0)`;;\n\nlet RPOW_MUL = `!x y z. (x * y) rpow z = x rpow z * y rpow z`;;\n\nlet RPOW_INV = `!x y. inv(x) rpow y = inv(x rpow y)`;;\n\nlet REAL_INV_RPOW = `!x y. inv(x rpow y) = inv(x) rpow y`;;\n\nlet RPOW_DIV = `!x y z. (x / y) rpow z = x rpow z / y rpow z`;;\n\nlet RPOW_PRODUCT = `!s:A->bool x y.\n FINITE s ==> (product s x) rpow y = product s (\\i. x i rpow y)`;;\n\nlet RPOW_ADD = `!x y z. &0 < x ==> x rpow (y + z) = x rpow y * x rpow z`;;\n\nlet RPOW_SUB = `!x y z. &0 < x ==> x rpow (y - z) = x rpow y / x rpow z`;;\n\nlet RPOW_ADD_ALT = `!x y z. &0 <= x /\\ (x = &0 /\\ y + z = &0 ==> y = &0 \\/ z = &0)\n ==> x rpow (y + z) = x rpow y * x rpow z`;;\n\nlet RPOW_SUB_ALT = `!x y z. &0 <= x /\\ (x = &0 /\\ y = z ==> y = &0 \\/ z = &0)\n ==> x rpow (y - z) = x rpow y / x rpow z`;;\n\nlet RPOW_SQRT = `!x. &0 <= x ==> x rpow (&1 / &2) = sqrt x`;;\n\nlet RPOW_MONO_LE = `!a b x. &1 <= x /\\ a <= b ==> x rpow a <= x rpow b`;;\n\nlet RPOW_MONO_LT = `!a b x. &1 < x /\\ a < b ==> x rpow a < x rpow b`;;\n\nlet RPOW_MONO_LE_EQ = `!a b x. &1 < x ==> (x rpow a <= x rpow b <=> a <= b)`;;\n\nlet RPOW_MONO_LT_EQ = `!a b x. &1 < x ==> (x rpow a < x rpow b <=> a < b)`;;\n\nlet RPOW_INJ = `!x y z. &0 < x ==> (x rpow y = x rpow z <=> x = &1 \\/ y = z)`;;\n\nlet RPOW_LE_1 = `!x y. &1 <= x /\\ &0 <= y ==> &1 <= x rpow y`;;\n\nlet RPOW_LT_1 = `!x y. &1 < x /\\ &0 < y ==> &1 < x rpow y`;;\n\nlet RPOW_MONO_INV = `!a b x. &0 < x /\\ x <= &1 /\\ b <= a ==> x rpow a <= x rpow b`;;\n\nlet RPOW_1_LE = `!a x. &0 <= x /\\ x <= &1 /\\ &0 <= a ==> x rpow a <= &1`;;\n\nlet REAL_ROOT_RPOW = `!n x. ~(n = 0) /\\ (&0 <= x \\/ ODD n) ==> root n x = x rpow (inv(&n))`;;\n\nlet LOG_RPOW = `!x y. &0 < x ==> log(x rpow y) = y * log x`;;\n\nlet LOG_SQRT = `!x. &0 < x ==> log(sqrt x) = log x / &2`;;\n\nlet RPOW_ADD_INTEGER = `!x m n. integer m /\\ integer n /\\ ~(x = &0 /\\ m + n = &0 /\\ ~(n = &0))\n ==> x rpow (m + n) = x rpow m * x rpow n`;;\n\nlet NORM_CPOW = `!w z. real w /\\ &0 < Re w ==> norm(w cpow z) = norm(w) rpow (Re z)`;;\n\nlet REAL_MAX_RPOW = `!x y z. &0 <= x /\\ &0 <= y /\\ &0 <= z\n ==> max (x rpow z) (y rpow z) = (max x y) rpow z`;;\n\nlet REAL_MIN_RPOW = `!x y z. &0 <= x /\\ &0 <= y /\\ &0 <= z\n ==> min (x rpow z) (y rpow z) = (min x y) rpow z`;;\n\nlet SUMMABLE_ZETA = `!n z. &1 < Re z ==> summable (from n) (\\k. inv(Cx(&k) cpow z))`;;\n\nlet SUMMABLE_ZETA_INTEGER = `!n m. 2 <= m ==> summable (from n) (\\k. inv(Cx(&k) pow m))`;;\n\nlet HOMOTOPIC_CIRCLEMAPS_IMP_HOMOTOPIC_LOOPS = `!f:complex->real^N g s.\n homotopic_with (\\h. T)\n (subtopology euclidean (sphere(vec 0,&1)),subtopology euclidean s)\n f g\n ==> homotopic_loops s (f o cexp o (\\t. Cx(&2 * pi * drop t) * ii))\n (g o cexp o (\\t. Cx(&2 * pi * drop t) * ii))`;;\n\nlet HOMOTOPIC_LOOPS_IMP_HOMOTOPIC_CIRCLEMAPS = `!p q s:real^N->bool.\n homotopic_loops s p q\n ==> homotopic_with (\\h. T)\n (subtopology euclidean (sphere(vec 0,&1)),subtopology euclidean s)\n (p o (\\z. lift(Arg z / (&2 * pi))))\n (q o (\\z. lift(Arg z / (&2 * pi))))`;;\n\nlet SIMPLY_CONNECTED_EQ_HOMOTOPIC_CIRCLEMAPS,\n SIMPLY_CONNECTED_EQ_CONTRACTIBLE_CIRCLEMAP =\n (CONJ_PAIR o prove)\n (`(!s:real^N->bool.\n simply_connected s <=>\n !f g:complex->real^N.\n f continuous_on sphere(vec 0,&1) /\\\n IMAGE f (sphere(vec 0,&1)) SUBSET s /\\\n g continuous_on sphere(vec 0,&1) /\\\n IMAGE g (sphere(vec 0,&1)) SUBSET s\n ==> homotopic_with (\\h. T)\n (subtopology euclidean (sphere(vec 0,&1)),\n subtopology euclidean s) f g) /\\\n (!s:real^N->bool.\n simply_connected s <=>\n path_connected s /\\\n !f:real^2->real^N.\n f continuous_on sphere(vec 0,&1) /\\\n IMAGE f (sphere(vec 0,&1)) SUBSET s\n ==> ?a. homotopic_with (\\h. T)\n (subtopology euclidean (sphere(vec 0,&1)),\n subtopology euclidean s) f (\\x. a))`,\n REWRITE_TAC[AND_FORALL_THM] THEN GEN_TAC THEN MATCH_MP_TAC(TAUT\n `(p ==> q) /\\ (q ==> r) /\\ (r ==> p) ==> (p <=> q) /\\ (p <=> r)`) THEN\n REPEAT CONJ_TAC THENL\n [REWRITE_TAC[simply_connected] THEN DISCH_TAC THEN\n MAP_EVERY X_GEN_TAC [`f:complex->real^N`; `g:complex->real^N`] THEN\n STRIP_TAC THEN FIRST_X_ASSUM(MP_TAC o SPECL\n [`(f:complex->real^N) o cexp o (\\t. Cx(&2 * pi * drop t) * ii)`;\n `(g:complex->real^N) o cexp o (\\t. Cx(&2 * pi * drop t) * ii)`]) THEN\n ONCE_REWRITE_TAC[TAUT `p1 /\\ q1 /\\ r1 /\\ p2 /\\ q2 /\\ r2 <=>\n (p1 /\\ r1 /\\ q1) /\\ (p2 /\\ r2 /\\ q2)`] THEN\n REWRITE_TAC[GSYM HOMOTOPIC_LOOPS_REFL] THEN\n ASM_SIMP_TAC[HOMOTOPIC_CIRCLEMAPS_IMP_HOMOTOPIC_LOOPS;\n HOMOTOPIC_WITH_REFL; CONTINUOUS_MAP_EUCLIDEAN2] THEN\n DISCH_THEN(MP_TAC o MATCH_MP HOMOTOPIC_LOOPS_IMP_HOMOTOPIC_CIRCLEMAPS) THEN\n MATCH_MP_TAC(ONCE_REWRITE_RULE[IMP_CONJ_ALT] HOMOTOPIC_WITH_EQ) THEN\n REWRITE_TAC[TOPSPACE_EUCLIDEAN_SUBTOPOLOGY] THEN\n REWRITE_TAC[IN_SPHERE_0; LIFT_DROP; o_DEF] THEN X_GEN_TAC `z:complex` THEN\n REPEAT STRIP_TAC THEN AP_TERM_TAC THEN MP_TAC(SPEC `z:complex` ARG) THEN\n ASM_REWRITE_TAC[COMPLEX_MUL_LID] THEN\n DISCH_THEN(STRIP_ASSUME_TAC o GSYM) THEN SIMP_TAC[PI_POS;\n REAL_FIELD `&0 < pi ==> &2 * pi * x / (&2 * pi) = x`] THEN\n ASM_MESON_TAC[COMPLEX_MUL_SYM];\n DISCH_TAC THEN CONJ_TAC THENL\n [REWRITE_TAC[PATH_CONNECTED_EQ_HOMOTOPIC_POINTS] THEN\n MAP_EVERY X_GEN_TAC [`a:real^N`; `b:real^N`] THEN STRIP_TAC THEN\n FIRST_X_ASSUM(MP_TAC o SPECL\n [`(\\x. a):complex->real^N`; `(\\x. b):complex->real^N`]) THEN\n REWRITE_TAC[CONTINUOUS_ON_CONST] THEN\n ANTS_TAC THENL [ASM SET_TAC[]; ALL_TAC] THEN DISCH_THEN\n (MP_TAC o MATCH_MP HOMOTOPIC_CIRCLEMAPS_IMP_HOMOTOPIC_LOOPS) THEN\n REWRITE_TAC[o_DEF; LINEPATH_REFL];\n X_GEN_TAC `f:complex->real^N` THEN STRIP_TAC THEN\n EXISTS_TAC `f(Cx(&1)):real^N` THEN FIRST_X_ASSUM MATCH_MP_TAC THEN\n ASM_REWRITE_TAC[CONTINUOUS_ON_CONST] THEN\n RULE_ASSUM_TAC(REWRITE_RULE[SUBSET; FORALL_IN_IMAGE; IN_SPHERE_0]) THEN\n REWRITE_TAC[SUBSET; FORALL_IN_IMAGE; IN_SPHERE_0] THEN\n REPEAT STRIP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN\n REWRITE_TAC[COMPLEX_NORM_CX] THEN REAL_ARITH_TAC];\n STRIP_TAC THEN\n ASM_REWRITE_TAC[SIMPLY_CONNECTED_EQ_CONTRACTIBLE_LOOP_SOME] THEN\n X_GEN_TAC `p:real^1->real^N` THEN STRIP_TAC THEN\n FIRST_X_ASSUM(MP_TAC o SPEC\n `(p:real^1->real^N) o (\\z. lift(Arg z / (&2 * pi)))`) THEN\n ANTS_TAC THENL\n [MP_TAC(ISPECL [`s:real^N->bool`; `p:real^1->real^N`]\n HOMOTOPIC_LOOPS_REFL) THEN\n ASM_REWRITE_TAC[] THEN DISCH_THEN(MP_TAC o MATCH_MP\n HOMOTOPIC_LOOPS_IMP_HOMOTOPIC_CIRCLEMAPS) THEN\n SIMP_TAC[HOMOTOPIC_WITH_REFL; CONTINUOUS_MAP_EUCLIDEAN2];\n MATCH_MP_TAC MONO_EXISTS THEN X_GEN_TAC `a:real^N` THEN\n STRIP_TAC THEN FIRST_ASSUM\n (MP_TAC o MATCH_MP HOMOTOPIC_CIRCLEMAPS_IMP_HOMOTOPIC_LOOPS) THEN\n FIRST_ASSUM(MP_TAC o MATCH_MP HOMOTOPIC_WITH_IMP_SUBSET) THEN\n REWRITE_TAC[SUBSET; FORALL_IN_IMAGE; IN_SPHERE_0; o_DEF] THEN\n DISCH_THEN(MP_TAC o SPEC `Cx(&1)` o CONJUNCT2) THEN\n REWRITE_TAC[COMPLEX_NORM_CX; REAL_ABS_NUM] THEN\n STRIP_TAC THEN ASM_REWRITE_TAC[LINEPATH_REFL] THEN\n MATCH_MP_TAC(REWRITE_RULE[IMP_CONJ] HOMOTOPIC_LOOPS_TRANS) THEN\n MATCH_MP_TAC HOMOTOPIC_LOOPS_EQ THEN ASM_REWRITE_TAC[] THEN\n REWRITE_TAC[IN_INTERVAL_1; FORALL_LIFT; LIFT_DROP; DROP_VEC] THEN\n X_GEN_TAC `t:real` THEN STRIP_TAC THEN ASM_CASES_TAC `t = &1` THENL\n [ASM_REWRITE_TAC[REAL_ARITH `&2 * pi * &1 = &2 * &1 * pi`] THEN\n SIMP_TAC[CEXP_INTEGER_2PI; INTEGER_CLOSED; ARG_NUM] THEN\n REWRITE_TAC[real_div; REAL_MUL_LZERO; LIFT_NUM] THEN\n ASM_MESON_TAC[pathstart; pathfinish];\n AP_TERM_TAC THEN AP_TERM_TAC THEN SIMP_TAC[PI_POS; REAL_FIELD\n `&0 < pi ==> (t = x / (&2 * pi) <=> x = &2 * pi * t)`] THEN\n MATCH_MP_TAC EQ_TRANS THEN EXISTS_TAC `Im(Cx (&2 * pi * t) * ii)` THEN\n CONJ_TAC THENL [MATCH_MP_TAC ARG_CEXP; ALL_TAC] THEN\n SIMP_TAC[IM_MUL_II; RE_CX; REAL_ARITH\n `a < &2 * pi <=> a < &2 * pi * &1`] THEN\n ASM_SIMP_TAC[REAL_LE_MUL; REAL_LT_LMUL_EQ; REAL_OF_NUM_LT; ARITH;\n PI_POS; REAL_LT_IMP_LE; REAL_POS; REAL_LE_MUL] THEN\n ASM_REWRITE_TAC[REAL_LT_LE]]]]);;\n\nlet HOMOTOPY_EQUIVALENT_SIMPLE_CONNECTEDNESS = `!s:real^M->bool t:real^N->bool.\n s homotopy_equivalent t\n ==> (simply_connected s <=> simply_connected t)`;;\n\nlet HAS_DERIVATIVE_POLAR = `!z. ((\\w. Cx(Re w) * cexp(ii * Cx(Im w))) has_derivative\n (\\h. vector[vector[cos(Im z); --Re(z) * sin(Im z)];\n vector[sin(Im z); Re z * cos(Im z)]] ** h))\n (at z)`;;\n\nlet HAS_ABSOLUTE_INTEGRAL_CHANGE_OF_VARIABLES_POLAR = `!f:complex->real^N b.\n f absolutely_integrable_on (:complex) /\\ integral (:complex) f = b <=>\n (\\z. Re z % f(Cx(Re z) * cexp(ii * Cx(Im z))))\n absolutely_integrable_on\n {z | &0 <= Re z /\\ &0 <= Im z /\\ Im z <= &2 * pi} /\\\n integral {z | &0 <= Re z /\\ &0 <= Im z /\\ Im z <= &2 * pi}\n (\\z. Re z % f(Cx(Re z) * cexp(ii * Cx(Im z)))) = b`;;\n\nlet ABSOLUTELY_INTEGRABLE_CHANGE_OF_VARIABLES_POLAR = `!f:complex->real^N.\n f absolutely_integrable_on (:complex) <=>\n (\\z. Re z % f(Cx(Re z) * cexp(ii * Cx(Im z))))\n absolutely_integrable_on\n {z | &0 <= Re z /\\ &0 <= Im z /\\ Im z <= &2 * pi}`;;\n\nlet FUBINI_POLAR = `!f:complex->real^N.\n f absolutely_integrable_on (:complex)\n ==> negligible\n {r | &0 <= drop r /\\\n ~((\\t. drop r % f(Cx(drop r) * cexp(ii * Cx(drop t))))\n absolutely_integrable_on interval[vec 0,lift(&2 * pi)])} /\\\n (\\r. integral (interval[vec 0,lift(&2 * pi)])\n (\\t. drop r % f(Cx(drop r) * cexp(ii * Cx(drop t)))))\n absolutely_integrable_on {r | &0 <= drop r} /\\\n integral {r | &0 <= drop r}\n (\\r. integral (interval[vec 0,lift(&2 * pi)])\n (\\t. drop r % f(Cx(drop r) * cexp(ii * Cx(drop t))))) =\n integral (:complex) f`;;\n\nlet FUBINI_TONELLI_POLAR = `!f:complex->real^N.\n f measurable_on (:complex)\n ==> (f absolutely_integrable_on (:complex) <=>\n negligible\n {r | &0 <= drop r /\\\n ~((\\t. drop r % f(Cx(drop r) * cexp(ii * Cx(drop t))))\n absolutely_integrable_on interval[vec 0,lift(&2 * pi)])} /\\\n (\\r. integral (interval[vec 0,lift(&2 * pi)])\n (\\t. drop r %\n lift(norm(f(Cx(drop r) * cexp(ii * Cx(drop t)))))))\n integrable_on {r | &0 <= drop r})`;;" }, { "theorem_id": 26, "title": "017_de_moivre_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Complex Analysis Basics\\\ntext \\Definitions of analytic and holomorphic functions, limit theorems, complex differentiation\\\n\ntheory Complex_Analysis_Basics\n imports Derivative \"HOL-Library.Nonpos_Ints\" Uncountable_Sets\nbegin\n\nsubsection\\<^marker>\\tag unimportant\\\\General lemmas\\\n\nlemma nonneg_Reals_cmod_eq_Re: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ norm z = Re z\"\n by sorry\n\nlemma fact_cancel:\n fixes c :: \"'a::real_field\"\n shows \"of_nat (Suc n) * c / (fact (Suc n)) = c / (fact n)\"\n by sorry\n\nlemma vector_derivative_cnj_within:\n assumes \"at x within A \\ bot\" and \"f differentiable at x within A\"\n shows \"vector_derivative (\\z. cnj (f z)) (at x within A) = \n cnj (vector_derivative f (at x within A))\" (is \"_ = cnj ?D\")\n by sorry\n\nlemma vector_derivative_cnj:\n assumes \"f differentiable at x\"\n shows \"vector_derivative (\\z. cnj (f z)) (at x) = cnj (vector_derivative f (at x))\"\n by sorry\n\nlemma\n shows open_halfspace_Re_lt: \"open {z. Re(z) < b}\"\n and open_halfspace_Re_gt: \"open {z. Re(z) > b}\"\n and closed_halfspace_Re_ge: \"closed {z. Re(z) \\ b}\"\n and closed_halfspace_Re_le: \"closed {z. Re(z) \\ b}\"\n and closed_halfspace_Re_eq: \"closed {z. Re(z) = b}\"\n and open_halfspace_Im_lt: \"open {z. Im(z) < b}\"\n and open_halfspace_Im_gt: \"open {z. Im(z) > b}\"\n and closed_halfspace_Im_ge: \"closed {z. Im(z) \\ b}\"\n and closed_halfspace_Im_le: \"closed {z. Im(z) \\ b}\"\n and closed_halfspace_Im_eq: \"closed {z. Im(z) = b}\"\n by sorry\n\nlemma uncountable_halfspace_Im_gt: \"uncountable {z. Im z > c}\"\n by sorry\n\nlemma uncountable_halfspace_Im_lt: \"uncountable {z. Im z < c}\"\n by sorry\n\nlemma uncountable_halfspace_Re_gt: \"uncountable {z. Re z > c}\"\n by sorry\n\nlemma uncountable_halfspace_Re_lt: \"uncountable {z. Re z < c}\"\n by sorry\n\nlemma connected_halfspace_Im_gt [intro]: \"connected {z. c < Im z}\"\n by sorry\n\nlemma connected_halfspace_Im_lt [intro]: \"connected {z. c > Im z}\"\n by sorry\n\nlemma connected_halfspace_Re_gt [intro]: \"connected {z. c < Re z}\"\n by sorry\n\nlemma connected_halfspace_Re_lt [intro]: \"connected {z. c > Re z}\"\n by sorry\n \nlemma closed_complex_Reals: \"closed (\\ :: complex set)\"\n by sorry\n\nlemma closed_Real_halfspace_Re_le: \"closed (\\ \\ {w. Re w \\ x})\"\n by sorry\n\nlemma closed_nonpos_Reals_complex [simp]: \"closed (\\\\<^sub>\\\\<^sub>0 :: complex set)\"\n by sorry\n\nlemma closed_Real_halfspace_Re_ge: \"closed (\\ \\ {w. x \\ Re(w)})\"\n by sorry\n\nlemma closed_nonneg_Reals_complex [simp]: \"closed (\\\\<^sub>\\\\<^sub>0 :: complex set)\"\n by sorry\n\nlemma closed_real_abs_le: \"closed {w \\ \\. \\Re w\\ \\ r}\"\n by sorry\n\nlemma real_lim:\n fixes l::complex\n assumes \"(f \\ l) F\" and \"\\ trivial_limit F\" and \"eventually P F\" and \"\\a. P a \\ f a \\ \\\"\n shows \"l \\ \\\"\n by sorry\n\nlemma real_lim_sequentially:\n fixes l::complex\n shows \"(f \\ l) sequentially \\ (\\N. \\n\\N. f n \\ \\) \\ l \\ \\\"\n by sorry\n\nlemma real_series:\n fixes l::complex\n shows \"f sums l \\ (\\n. f n \\ \\) \\ l \\ \\\"\n by sorry\n\nlemma Lim_null_comparison_Re:\n assumes \"eventually (\\x. norm(f x) \\ Re(g x)) F\" \"(g \\ 0) F\" shows \"(f \\ 0) F\"\n by sorry\n\nsubsection\\Holomorphic functions\\\n\ndefinition\\<^marker>\\tag important\\ holomorphic_on :: \"[complex \\ complex, complex set] \\ bool\"\n (infixl \\(holomorphic'_on)\\ 50)\n where \"f holomorphic_on s \\ \\x\\s. f field_differentiable (at x within s)\"\n\nnamed_theorems\\<^marker>\\tag important\\ holomorphic_intros \"structural introduction rules for holomorphic_on\"\n\nlemma holomorphic_onI [intro?]: \"(\\x. x \\ s \\ f field_differentiable (at x within s)) \\ f holomorphic_on s\"\n by sorry\n\nlemma holomorphic_onD [dest?]: \"\\f holomorphic_on s; x \\ s\\ \\ f field_differentiable (at x within s)\"\n by sorry\n\nlemma holomorphic_on_imp_differentiable_on:\n \"f holomorphic_on s \\ f differentiable_on s\"\n by sorry\n\nlemma holomorphic_on_imp_differentiable_at:\n \"\\f holomorphic_on s; open s; x \\ s\\ \\ f field_differentiable (at x)\"\n by sorry\n\nlemma holomorphic_on_empty [holomorphic_intros]: \"f holomorphic_on {}\"\n by sorry\n\nlemma holomorphic_on_open:\n \"open s \\ f holomorphic_on s \\ (\\x \\ s. \\f'. DERIV f x :> f')\"\n by sorry\n\nlemma holomorphic_on_UN_open:\n assumes \"\\n. n \\ I \\ f holomorphic_on A n\" \"\\n. n \\ I \\ open (A n)\"\n shows \"f holomorphic_on (\\n\\I. A n)\"\n by sorry\n\nlemma holomorphic_on_imp_continuous_on:\n \"f holomorphic_on s \\ continuous_on s f\"\n by sorry\n\nlemma holomorphic_closedin_preimage_constant:\n assumes \"f holomorphic_on D\" \n shows \"closedin (top_of_set D) {z\\D. f z = a}\"\n by sorry\n\nlemma holomorphic_closed_preimage_constant:\n assumes \"f holomorphic_on UNIV\" \n shows \"closed {z. f z = a}\"\n by sorry\n\nlemma holomorphic_on_subset [elim]:\n \"f holomorphic_on s \\ t \\ s \\ f holomorphic_on t\"\n by sorry\n\nlemma holomorphic_transform: \"\\f holomorphic_on s; \\x. x \\ s \\ f x = g x\\ \\ g holomorphic_on s\"\n by sorry\n\nlemma holomorphic_cong: \"s = t ==> (\\x. x \\ s \\ f x = g x) \\ f holomorphic_on s \\ g holomorphic_on t\"\n by sorry\n\nlemma holomorphic_on_linear [simp, holomorphic_intros]: \"(" }, { "theorem_id": 26, "title": "017_de_moivre_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Abhimanyu Pallavi Sudhir\n-/\nmodule\n\npublic import Mathlib.Analysis.Complex.Exponential\nimport Mathlib.Tactic.NormNum.NatFactorial\n\n/-!\n# Trigonometric and hyperbolic trigonometric functions\n\nThis file contains the definitions of the sine, cosine, tangent,\nhyperbolic sine, hyperbolic cosine, and hyperbolic tangent functions.\n\n-/\n\n@[expose] public section\n\nopen CauSeq Finset IsAbsoluteValue\nopen scoped ComplexConjugate\n\nnamespace Complex\n\nnoncomputable section\n\n/-- The complex sine function, defined via `exp` -/\n@[pp_nodot]\ndef sin (z : ℂ) : ℂ :=\n (exp (-z * I) - exp (z * I)) * I / 2\n\n/-- The complex cosine function, defined via `exp` -/\n@[pp_nodot]\ndef cos (z : ℂ) : ℂ :=\n (exp (z * I) + exp (-z * I)) / 2\n\n/-- The complex tangent function, defined as `sin z / cos z` -/\n@[pp_nodot]\ndef tan (z : ℂ) : ℂ :=\n sin z / cos z\n\n/-- The complex cotangent function, defined as `cos z / sin z` -/\ndef cot (z : ℂ) : ℂ :=\n cos z / sin z\n\n/-- The complex hyperbolic sine function, defined via `exp` -/\n@[pp_nodot]\ndef sinh (z : ℂ) : ℂ :=\n (exp z - exp (-z)) / 2\n\n/-- The complex hyperbolic cosine function, defined via `exp` -/\n@[pp_nodot]\ndef cosh (z : ℂ) : ℂ :=\n (exp z + exp (-z)) / 2\n\n/-- The complex hyperbolic tangent function, defined as `sinh z / cosh z` -/\n@[pp_nodot]\ndef tanh (z : ℂ) : ℂ :=\n sinh z / cosh z\n\nend\n\nend Complex\n\nnamespace Real\n\nopen Complex\n\nnoncomputable section\n\n/-- The real sine function, defined as the real part of the complex sine -/\n@[pp_nodot]\nnonrec def sin (x : ℝ) : ℝ :=\n (sin x).re\n\n/-- The real cosine function, defined as the real part of the complex cosine -/\n@[pp_nodot]\nnonrec def cos (x : ℝ) : ℝ :=\n (cos x).re\n\n/-- The real tangent function, defined as the real part of the complex tangent -/\n@[pp_nodot]\nnonrec def tan (x : ℝ) : ℝ :=\n (tan x).re\n\n/-- The real cotangent function, defined as the real part of the complex cotangent -/\nnonrec def cot (x : ℝ) : ℝ :=\n (cot x).re\n\n/-- The real hyperbolic sine function, defined as the real part of the complex hyperbolic sine -/\n@[pp_nodot]\nnonrec def sinh (x : ℝ) : ℝ :=\n (sinh x).re\n\n/-- The real hyperbolic cosine function, defined as the real part of the complex hyperbolic cosine\n-/\n@[pp_nodot]\nnonrec def cosh (x : ℝ) : ℝ :=\n (cosh x).re\n\n/-- The real hyperbolic tangent function, defined as the real part of\nthe complex hyperbolic tangent -/\n@[pp_nodot]\nnonrec def tanh (x : ℝ) : ℝ :=\n (tanh x).re\n\nend\n\nend Real\n\nnamespace Complex\n\nvariable (x y : ℂ)\n\ntheorem two_sinh : 2 * sinh x = exp x - exp (-x) :=\n mul_div_cancel₀ _ two_ne_zero\n\ntheorem two_cosh : 2 * cosh x = exp x + exp (-x) :=\n mul_div_cancel₀ _ two_ne_zero\n\n@[simp]\ntheorem sinh_zero : sinh 0 = 0 := by simp [sinh]\n\n@[simp]\ntheorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh, exp_neg, (neg_div _ _).symm]\n\nprivate theorem sinh_add_aux {a b c d : ℂ} :\n (a - b) * (c + d) + (a + b) * (c - d) = 2 * (a * c - b * d) := by ring\n\ntheorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y := by sorry\ntheorem cosh_zero : cosh 0 = 1 := by simp [cosh]\n\n@[simp]\ntheorem cosh_neg : cosh (-x) = cosh x := by simp [add_comm, cosh, exp_neg]\n\nprivate theorem cosh_add_aux {a b c d : ℂ} :\n (a + b) * (c + d) + (a - b) * (c - d) = 2 * (a * c + b * d) := by ring\n\ntheorem cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y := by sorry\ntheorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by sorry\ntheorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by sorry\ntheorem sinh_conj : sinh (conj x) = conj (sinh x) := by sorry\ntheorem ofReal_sinh_ofReal_re (x : ℝ) : ((sinh x).re : ℂ) = sinh x :=\n conj_eq_iff_re.1 <| by rw [← sinh_conj, conj_ofReal]\n\n@[simp, norm_cast]\ntheorem ofReal_sinh (x : ℝ) : (Real.sinh x : ℂ) = sinh x :=\n ofReal_sinh_ofReal_re _\n\n@[simp]\ntheorem sinh_ofReal_im (x : ℝ) : (sinh x).im = 0 := by rw [← ofReal_sinh_ofReal_re, ofReal_im]\n\ntheorem sinh_ofReal_re (x : ℝ) : (sinh x).re = Real.sinh x :=\n rfl\n\ntheorem cosh_conj : cosh (conj x) = conj (cosh x) := by sorry\ntheorem ofReal_cosh_ofReal_re (x : ℝ) : ((cosh x).re : ℂ) = cosh x :=\n conj_eq_iff_re.1 <| by rw [← cosh_conj, conj_ofReal]\n\n@[simp, norm_cast]\ntheorem ofReal_cosh (x : ℝ) : (Real.cosh x : ℂ) = cosh x :=\n ofReal_cosh_ofReal_re _\n\n@[simp]\ntheorem cosh_ofReal_im (x : ℝ) : (cosh x).im = 0 := by rw [← ofReal_cosh_ofReal_re, ofReal_im]\n\n@[simp]\ntheorem cosh_ofReal_re (x : ℝ) : (cosh x).re = Real.cosh x :=\n rfl\n\ntheorem tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x :=\n rfl\n\n@[simp]\ntheorem tanh_zero : tanh 0 = 0 := by simp [tanh]\n\n@[simp]\ntheorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div]\n\ntheorem tanh_conj : tanh (conj x) = conj (tanh x) := by sorry\ntheorem ofReal_tanh_ofReal_re (x : ℝ) : ((tanh x).re : ℂ) = tanh x :=\n conj_eq_iff_re.1 <| by rw [← tanh_conj, conj_ofReal]\n\n@[simp, norm_cast]\ntheorem ofReal_tanh (x : ℝ) : (Real.tanh x : ℂ) = tanh x :=\n ofReal_tanh_ofReal_re _\n\n@[simp]\ntheorem tanh_ofReal_im (x : ℝ) : (tanh x).im = 0 := by rw [← ofReal_tanh_ofReal_re, ofReal_im]\n\ntheorem tanh_ofReal_re (x : ℝ) : (tanh x).re = Real.tanh x :=\n rfl\n\n@[simp]\ntheorem cosh_add_sinh : cosh x + sinh x = exp x := by sorry\ntheorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh]\n\n@[simp]\ntheorem exp_sub_cosh : exp x - cosh x = sinh x :=\n sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm\n\n@[simp]\ntheorem exp_sub_sinh : exp x - sinh x = cosh x :=\n sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm\n\n@[simp]\ntheorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by sorry\ntheorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh]\n\n@[simp]\ntheorem cosh_sq_sub_sinh_sq : cosh x ^ 2 - sinh x ^ 2 = 1 := by sorry\ntheorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by sorry\ntheorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by sorry\ntheorem cosh_two_mul : cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2 := by rw [two_mul, cosh_add, sq, sq]\n\ntheorem sinh_two_mul : sinh (2 * x) = 2 * sinh x * cosh x := by sorry\ntheorem cosh_three_mul : cosh (3 * x) = 4 * cosh x ^ 3 - 3 * cosh x := by sorry\ntheorem sinh_three_mul : sinh (3 * x) = 4 * sinh x ^ 3 + 3 * sinh x := by sorry\ntheorem sin_zero : sin 0 = 0 := by simp [sin]\n\n@[simp]\ntheorem sin_neg : sin (-x) = -sin x := by sorry\ntheorem two_sin : 2 * sin x = (exp (-x * I) - exp (x * I)) * I :=\n mul_div_cancel₀ _ two_ne_zero\n\ntheorem two_cos : 2 * cos x = exp (x * I) + exp (-x * I) :=\n mul_div_cancel₀ _ two_ne_zero\n\ntheorem sinh_mul_I : sinh (x * I) = sin x * I := by sorry\ntheorem cosh_mul_I : cosh (x * I) = cos x := by sorry\ntheorem tanh_mul_I : tanh (x * I) = tan x * I := by sorry\ntheorem cos_mul_I : cos (x * I) = cosh x := by rw [← cosh_mul_I]; ring_nf; simp\n\ntheorem sin_mul_I : sin (x * I) = sinh x * I := by sorry\ntheorem tan_mul_I : tan (x * I) = tanh x * I := by sorry\ntheorem sin_add : sin (x + y) = sin x * cos y + cos x * sin y := by sorry\ntheorem cos_zero : cos 0 = 1 := by simp [cos]\n\n@[simp]\ntheorem cos_neg : cos (-x) = cos x := by simp [cos, exp_neg, add_comm]\n\ntheorem cos_add : cos (x + y) = cos x * cos y - sin x * sin y := by sorry\ntheorem sin_sub : sin (x - y) = sin x * cos y - cos x * sin y := by sorry\ntheorem cos_sub : cos (x - y) = cos x * cos y + sin x * sin y := by sorry\ntheorem sin_add_mul_I (x y : ℂ) : sin (x + y * I) = sin x * cosh y + cos x * sinh y * I := by sorry\ntheorem sin_eq (z : ℂ) : sin z = sin z.re * cosh z.im + cos z.re * sinh z.im * I := by sorry\ntheorem cos_add_mul_I (x y : ℂ) : cos (x + y * I) = cos x * cosh y - sin x * sinh y * I := by sorry\ntheorem cos_eq (z : ℂ) : cos z = cos z.re * cosh z.im - sin z.re * sinh z.im * I := by sorry\ntheorem sin_sub_sin : sin x - sin y = 2 * sin ((x - y) / 2) * cos ((x + y) / 2) := by sorry\ntheorem cos_sub_cos : cos x - cos y = -2 * sin ((x + y) / 2) * sin ((x - y) / 2) := by sorry\ntheorem sin_add_sin : sin x + sin y = 2 * sin ((x + y) / 2) * cos ((x - y) / 2) := by sorry\ntheorem cos_add_cos : cos x + cos y = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) := by sorry\ntheorem sin_conj : sin (conj x) = conj (sin x) := by sorry\ntheorem ofReal_sin_ofReal_re (x : ℝ) : ((sin x).re : ℂ) = sin x :=\n conj_eq_iff_re.1 <| by rw [← sin_conj, conj_ofReal]\n\n@[simp, norm_cast]\ntheorem ofReal_sin (x : ℝ) : (Real.sin x : ℂ) = sin x :=\n ofReal_sin_ofReal_re _\n\n@[simp]\ntheorem sin_ofReal_im (x : ℝ) : (sin x).im = 0 := by rw [← ofReal_sin_ofReal_re, ofReal_im]\n\ntheorem sin_ofReal_re (x : ℝ) : (sin x).re = Real.sin x :=\n rfl\n\ntheorem cos_conj : cos (conj x) = conj (cos x) := by sorry\ntheorem ofReal_cos_ofReal_re (x : ℝ) : ((cos x).re : ℂ) = cos x :=\n conj_eq_iff_re.1 <| by rw [← cos_conj, conj_ofReal]\n\n@[simp, norm_cast]\ntheorem ofReal_cos (x : ℝ) : (Real.cos x : ℂ) = cos x :=\n ofReal_cos_ofReal_re _\n\n@[simp]\ntheorem cos_ofReal_im (x : ℝ) : (cos x).im = 0 := by rw [← ofReal_cos_ofReal_re, ofReal_im]\n\ntheorem cos_ofReal_re (x : ℝ) : (cos x).re = Real.cos x :=\n rfl\n\n@[simp]\ntheorem tan_zero : tan 0 = 0 := by simp [tan]\n\ntheorem tan_eq_sin_div_cos : tan x = sin x / cos x :=\n rfl\n\ntheorem cot_eq_cos_div_sin : cot x = cos x / sin x :=\n rfl\n\ntheorem tan_mul_cos {x : ℂ} (hx : cos x ≠ 0) : tan x * cos x = sin x := by sorry\ntheorem tan_inv_eq_cot : (tan x)⁻¹ = cot x :=\n inv_div ..\n\n@[simp]\ntheorem cot_inv_eq_tan : (cot x)⁻¹ = tan x :=\n inv_div ..\n\n@[simp]\ntheorem tan_neg : tan (-x) = -tan x := by simp [tan, neg_div]\n\ntheorem tan_conj : tan (conj x) = conj (tan x) := by rw [tan, sin_conj, cos_conj, ← map_div₀, tan]\n\ntheorem cot_conj : cot (conj x) = conj (cot x) := by rw [cot, sin_conj, cos_conj, ← map_div₀, cot]\n\n@[simp]\ntheorem ofReal_tan_ofReal_re (x : ℝ) : ((tan x).re : ℂ) = tan x :=\n conj_eq_iff_re.1 <| by rw [← tan_conj, conj_ofReal]\n\n@[simp]\ntheorem ofReal_cot_ofReal_re (x : ℝ) : ((cot x).re : ℂ) = cot x :=\n conj_eq_iff_re.1 <| by rw [← cot_conj, conj_ofReal]\n\n@[simp, norm_cast]\ntheorem ofReal_tan (x : ℝ) : (Real.tan x : ℂ) = tan x :=\n ofReal_tan_ofReal_re _\n\n@[simp, norm_cast]\ntheorem ofReal_cot (x : ℝ) : (Real.cot x : ℂ) = cot x :=\n ofReal_cot_ofReal_re _\n\n@[simp]\ntheorem tan_ofReal_im (x : ℝ) : (tan x).im = 0 := by rw [← ofReal_tan_ofReal_re, ofReal_im]\n\ntheorem tan_ofReal_re (x : ℝ) : (tan x).re = Real.tan x :=\n rfl\n\ntheorem cos_add_sin_I : cos x + sin x * I = exp (x * I) := by sorry\ntheorem cos_sub_sin_I : cos x - sin x * I = exp (-x * I) := by sorry\ntheorem sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 :=\n Eq.trans (by rw [cosh_mul_I, sinh_mul_I, mul_pow, I_sq, mul_neg_one, sub_neg_eq_add, add_comm])\n (cosh_sq_sub_sinh_sq (x * I))\n\n@[simp]\ntheorem cos_sq_add_sin_sq : cos x ^ 2 + sin x ^ 2 = 1 := by rw [add_comm, sin_sq_add_cos_sq]\n\ntheorem cos_two_mul' : cos (2 * x) = cos x ^ 2 - sin x ^ 2 := by rw [two_mul, cos_add, ← sq, ← sq]\n\ntheorem cos_two_mul : cos (2 * x) = 2 * cos x ^ 2 - 1 := by sorry\ntheorem cos_two_mul_eq_one_sub : cos (2 * x) = 1 - 2 * sin x ^ 2 := by sorry\ntheorem sin_two_mul : sin (2 * x) = 2 * sin x * cos x := by sorry\ntheorem cos_sq : cos x ^ 2 = 1 / 2 + cos (2 * x) / 2 := by sorry\ntheorem cos_sq' : cos x ^ 2 = 1 - sin x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel_left]\n\ntheorem sin_sq : sin x ^ 2 = 1 - cos x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel_right]\n\ntheorem one_add_tan_sq_mul_cos_sq_eq_one {x : ℂ} (h : cos x ≠ 0) :\n (1 + tan x ^ 2) * cos x ^ 2 = 1 := by sorry\ntheorem inv_one_add_tan_sq {x : ℂ} (hx : cos x ≠ 0) : (1 + tan x ^ 2)⁻¹ = cos x ^ 2 := by sorry\ntheorem tan_sq_div_one_add_tan_sq {x : ℂ} (hx : cos x ≠ 0) :\n tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by sorry\ntheorem cos_three_mul : cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x := by sorry\ntheorem sin_three_mul : sin (3 * x) = 3 * sin x - 4 * sin x ^ 3 := by sorry\ntheorem exp_mul_I : exp (x * I) = cos x + sin x * I :=\n (cos_add_sin_I _).symm\n\ntheorem exp_add_mul_I : exp (x + y * I) = exp x * (cos y + sin y * I) := by rw [exp_add, exp_mul_I]\n\ntheorem exp_eq_exp_re_mul_sin_add_cos : exp x = exp x.re * (cos x.im + sin x.im * I) := by sorry\ntheorem exp_re : (exp x).re = Real.exp x.re * Real.cos x.im := by sorry\ntheorem exp_im : (exp x).im = Real.exp x.re * Real.sin x.im := by sorry\ntheorem exp_ofReal_mul_I_re (x : ℝ) : (exp (x * I)).re = Real.cos x := by sorry\ntheorem exp_ofReal_mul_I_im (x : ℝ) : (exp (x * I)).im = Real.sin x := by sorry\ntheorem exp_ofReal_mul_I (x : ℝ) : exp (x * I) = Real.cos x + (Real.sin x) * I := by sorry\ntheorem cos_add_sin_mul_I_pow (n : ℕ) (z : ℂ) :\n (cos z + sin z * I) ^ n = cos (↑n * z) + sin (↑n * z) * I := by sorry\nopen Finset\n\ntheorem cos_bound {x : ℂ} (hx : ‖x‖ ≤ 1) : ‖cos x - (1 - x ^ 2 / 2)‖ ≤ ‖x‖ ^ 4 * (5 / 96) :=\n calc\n ‖cos x - (1 - x ^ 2 / 2)‖ =\n ‖(exp (-x * I) - ∑ m ∈ range 4, (-x * I) ^ m / m.factorial) / 2 +\n (exp (x * I) - ∑ m ∈ range 4, (x * I) ^ m / m.factorial) / 2‖ := by sorry\ntheorem sin_bound {x : ℂ} (hx : ‖x‖ ≤ 1) : ‖sin x - (x - x ^ 3 / 6)‖ ≤ ‖x‖ ^ 4 * (5 / 96) :=\n calc\n ‖sin x - (x - x ^ 3 / 6)‖ =\n ‖(exp (-x * I) - ∑ m ∈ range 4, (-x * I) ^ m / m.factorial) * I / 2 -\n (exp (x * I) - ∑ m ∈ range 4, (x * I) ^ m / m.factorial) * I / 2‖ := by sorry\nend Complex\n\nnamespace Real\n\nopen Complex\n\nvariable (x y : ℝ)\n\n@[simp]\ntheorem sin_zero : sin 0 = 0 := by simp [sin]\n\n@[simp]\ntheorem sin_neg : sin (-x) = -sin x := by simp [sin]\n\nnonrec theorem sin_add : sin (x + y) = sin x * cos y + cos x * sin y :=\n ofReal_injective <| by simp [sin_add]\n\n@[simp]\ntheorem cos_zero : cos 0 = 1 := by simp [cos]\n\n@[simp]\ntheorem cos_neg : cos (-x) = cos x := by simp [cos]\n\n@[simp]\ntheorem cos_abs : cos |x| = cos x := by sorry\ntheorem sin_sub : sin (x - y) = sin x * cos y - cos x * sin y := by sorry\ntheorem cos_sub : cos (x - y) = cos x * cos y + sin x * sin y := by sorry\ntheorem two_mul_sin_mul_sin (x y : ℝ) : 2 * sin x * sin y = cos (x - y) - cos (x + y) := by sorry\ntheorem two_mul_cos_mul_cos (x y : ℝ) : 2 * cos x * cos y = cos (x - y) + cos (x + y) := by sorry\ntheorem two_mul_sin_mul_cos (x y : ℝ) : 2 * sin x * cos y = sin (x - y) + sin (x + y) := by sorry\ntheorem tan_mul_cos {x : ℝ} (hx : cos x ≠ 0) : tan x * cos x = sin x := by sorry\ntheorem tan_inv_eq_cot : (tan x)⁻¹ = cot x :=\n ofReal_injective <| by simp\n\n@[simp]\ntheorem cot_inv_eq_tan : (cot x)⁻¹ = tan x :=\n ofReal_injective <| by simp\n\n@[simp]\ntheorem tan_zero : tan 0 = 0 := by simp [tan]\n\n@[simp]\ntheorem tan_neg : tan (-x) = -tan x := by simp [tan]\n\n@[simp]\nnonrec theorem sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 :=\n ofReal_injective (by simp [sin_sq_add_cos_sq])\n\n@[simp]\ntheorem cos_sq_add_sin_sq : cos x ^ 2 + sin x ^ 2 = 1 := by rw [add_comm, sin_sq_add_cos_sq]\n\ntheorem sin_sq_le_one : sin x ^ 2 ≤ 1 := by sorry\ntheorem cos_sq_le_one : cos x ^ 2 ≤ 1 := by sorry\ntheorem abs_sin_le_one : |sin x| ≤ 1 :=\n abs_le_one_iff_mul_self_le_one.2 <| by simp only [← sq, sin_sq_le_one]\n\ntheorem abs_cos_le_one : |cos x| ≤ 1 :=\n abs_le_one_iff_mul_self_le_one.2 <| by simp only [← sq, cos_sq_le_one]\n\ntheorem sin_le_one : sin x ≤ 1 :=\n (abs_le.1 (abs_sin_le_one _)).2\n\ntheorem cos_le_one : cos x ≤ 1 :=\n (abs_le.1 (abs_cos_le_one _)).2\n\ntheorem neg_one_le_sin : -1 ≤ sin x :=\n (abs_le.1 (abs_sin_le_one _)).1\n\ntheorem neg_one_le_cos : -1 ≤ cos x :=\n (abs_le.1 (abs_cos_le_one _)).1\n\nnonrec theorem cos_two_mul : cos (2 * x) = 2 * cos x ^ 2 - 1 :=\n ofReal_injective <| by simp [cos_two_mul]\n\nnonrec theorem cos_two_mul' : cos (2 * x) = cos x ^ 2 - sin x ^ 2 :=\n ofReal_injective <| by simp [cos_two_mul']\n\nnonrec theorem cos_two_mul_eq_one_sub : cos (2 * x) = 1 - 2 * sin x ^ 2 :=\n ofReal_injective <| by simp [cos_two_mul_eq_one_sub]\n\nnonrec theorem sin_two_mul : sin (2 * x) = 2 * sin x * cos x :=\n ofReal_injective <| by simp [sin_two_mul]\n\nnonrec theorem cos_sq : cos x ^ 2 = 1 / 2 + cos (2 * x) / 2 :=\n ofReal_injective <| by simp [cos_sq]\n\ntheorem cos_sq' : cos x ^ 2 = 1 - sin x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel_left]\n\ntheorem sin_sq : sin x ^ 2 = 1 - cos x ^ 2 :=\n eq_sub_iff_add_eq.2 <| sin_sq_add_cos_sq _\n\nlemma sin_sq_eq_half_sub : sin x ^ 2 = 1 / 2 - cos (2 * x) / 2 := by sorry\ntheorem abs_sin_eq_sqrt_one_sub_cos_sq (x : ℝ) : |sin x| = √(1 - cos x ^ 2) := by sorry\ntheorem abs_cos_eq_sqrt_one_sub_sin_sq (x : ℝ) : |cos x| = √(1 - sin x ^ 2) := by sorry\ntheorem one_add_tan_sq_mul_cos_sq_eq_one {x : ℝ} (h : cos x ≠ 0) :\n (1 + tan x ^ 2) * cos x ^ 2 = 1 :=\n mod_cast @Complex.one_add_tan_sq_mul_cos_sq_eq_one x (mod_cast h)\n\ntheorem inv_one_add_tan_sq {x : ℝ} (hx : cos x ≠ 0) : (1 + tan x ^ 2)⁻¹ = cos x ^ 2 :=\n have : Complex.cos x ≠ 0 := mt (congr_arg re) hx\n ofReal_inj.1 <| by simpa using Complex.inv_one_add_tan_sq this\n\ntheorem tan_sq_div_one_add_tan_sq {x : ℝ} (hx : cos x ≠ 0) :\n tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by sorry\ntheorem inv_sqrt_one_add_tan_sq {x : ℝ} (hx : 0 < cos x) : (√(1 + tan x ^ 2))⁻¹ = cos x := by sorry\ntheorem tan_div_sqrt_one_add_tan_sq {x : ℝ} (hx : 0 < cos x) :\n tan x / √(1 + tan x ^ 2) = sin x := by sorry\ntheorem sinh_zero : sinh 0 = 0 := by simp [sinh]\n\n@[simp]\ntheorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh]\n\nnonrec theorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y := by sorry\ntheorem cosh_eq (x : ℝ) : cosh x = (exp x + exp (-x)) / 2 :=\n eq_div_of_mul_eq two_ne_zero <| by\n rw [cosh, exp, exp, Complex.ofReal_neg, Complex.cosh, mul_two, ← Complex.add_re, ← mul_two,\n div_mul_cancel₀ _ (two_ne_zero' ℂ), Complex.add_re]\n\n@[simp]\ntheorem cosh_zero : cosh 0 = 1 := by simp [cosh]\n\n@[simp]\ntheorem cosh_neg : cosh (-x) = cosh x :=\n ofReal_inj.1 <| by simp\n\n@[simp]\ntheorem cosh_abs : cosh |x| = cosh x := by sorry\ntheorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by sorry\ntheorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by sorry\ntheorem tanh_eq (x : ℝ) : tanh x = (exp x - exp (-x)) / (exp x + exp (-x)) := by sorry\ntheorem tanh_zero : tanh 0 = 0 := by simp [tanh]\n\n@[simp]\ntheorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh]\n\n@[simp]\ntheorem cosh_add_sinh : cosh x + sinh x = exp x := by rw [← ofReal_inj]; simp\n\n@[simp]\ntheorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh]\n\n@[simp]\ntheorem exp_sub_cosh : exp x - cosh x = sinh x :=\n sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm\n\n@[simp]\ntheorem exp_sub_sinh : exp x - sinh x = cosh x :=\n sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm\n\n@[simp]\ntheorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by sorry\ntheorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh]\n\n@[simp]\ntheorem cosh_sq_sub_sinh_sq (x : ℝ) : cosh x ^ 2 - sinh x ^ 2 = 1 := by rw [← ofReal_inj]; simp\n\nnonrec theorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by rw [← ofReal_inj]; simp [cosh_sq]\n\ntheorem cosh_sq' : cosh x ^ 2 = 1 + sinh x ^ 2 :=\n (cosh_sq x).trans (add_comm _ _)\n\nnonrec theorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by rw [← ofReal_inj]; simp [sinh_sq]\n\nnonrec theorem cosh_two_mul : cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2 := by sorry\nopen IsAbsoluteValue Nat\n\n/-- `Real.cosh` is always positive -/\ntheorem cosh_pos (x : ℝ) : 0 < Real.cosh x :=\n (cosh_eq x).symm ▸ half_pos (add_pos (exp_pos x) (exp_pos (-x)))\n\ntheorem sinh_lt_cosh : sinh x < cosh x :=\n lt_of_pow_lt_pow_left₀ 2 (cosh_pos _).le <| (cosh_sq x).symm ▸ lt_add_one _\n\ntheorem tanh_lt_one (x : ℝ) : tanh x < 1 := by sorry\ntheorem neg_one_lt_tanh (x : ℝ) : -1 < tanh x := by sorry\ntheorem abs_tanh_lt_one (x : ℝ) : |tanh x| < 1 :=\n abs_lt.mpr ⟨neg_one_lt_tanh x, tanh_lt_one x⟩\n\ntheorem tanh_sq_lt_one (x : ℝ) : (tanh x) ^ 2 < 1 :=\n (sq_lt_one_iff_abs_lt_one (tanh x)).mpr (abs_tanh_lt_one x)\n\nend Real\n\nnamespace Real\n\nopen Complex\n\ntheorem cos_bound {x : ℝ} (hx : |x| ≤ 1) : |cos x - (1 - x ^ 2 / 2)| ≤ |x| ^ 4 * (5 / 96) := by sorry\ntheorem sin_bound {x : ℝ} (hx : |x| ≤ 1) : |sin x - (x - x ^ 3 / 6)| ≤ |x| ^ 4 * (5 / 96) := by sorry\ntheorem cos_pos_of_le_one {x : ℝ} (hx : |x| ≤ 1) : 0 < cos x :=\n calc 0 < 1 - x ^ 2 / 2 - |x| ^ 4 * (5 / 96) :=\n sub_pos.2 <|\n lt_sub_iff_add_lt.2\n (calc\n |x| ^ 4 * (5 / 96) + x ^ 2 / 2 ≤ 1 * (5 / 96) + 1 / 2 := by sorry\ntheorem sin_pos_of_pos_of_le_one {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 1) : 0 < sin x :=\n calc 0 < x - x ^ 3 / 6 - |x| ^ 4 * (5 / 96) :=\n sub_pos.2 <| lt_sub_iff_add_lt.2\n (calc\n |x| ^ 4 * (5 / 96) + x ^ 3 / 6 ≤ x * (5 / 96) + x / 6 := by sorry\ntheorem sin_pos_of_pos_of_le_two {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 2) : 0 < sin x :=\n have : x / 2 ≤ 1 := (div_le_iff₀ (by simp)).mpr (by simpa)\n calc\n 0 < 2 * sin (x / 2) * cos (x / 2) :=\n mul_pos (mul_pos (by simp) (sin_pos_of_pos_of_le_one (half_pos hx0) this))\n (cos_pos_of_le_one (by rwa [abs_of_nonneg (le_of_lt (half_pos hx0))]))\n _ = sin x := by rw [← sin_two_mul, two_mul, add_halves]\n\ntheorem cos_one_le : cos 1 ≤ 5 / 9 :=\n calc\n cos 1 ≤ |(1 : ℝ)| ^ 4 * (5 / 96) + (1 - 1 ^ 2 / 2) :=\n sub_le_iff_le_add.1 (abs_sub_le_iff.1 (cos_bound (by simp))).1\n _ ≤ 5 / 9 := by norm_num\n\ntheorem cos_one_pos : 0 < cos 1 :=\n cos_pos_of_le_one (le_of_eq abs_one)\n\ntheorem cos_two_neg : cos 2 < 0 :=\n calc cos 2 = cos (2 * 1) := congr_arg cos (mul_one _).symm\n _ = _ := Real.cos_two_mul 1\n _ ≤ 2 * (5 / 9) ^ 2 - 1 := by sorry\nend Real\n\nnamespace Mathlib.Meta.Positivity\nopen Lean.Meta Qq\n\n/-- Extension for the `positivity` tactic: `Real.cosh` is always positive. -/\n@[positivity Real.cosh _]\nmeta def evalCosh : PositivityExt where eval {u α} _ _ e := do\n match u, α, e with\n | 0, ~q(ℝ), ~q(Real.cosh $a) =>\n assertInstancesCommute\n return .positive q(Real.cosh_pos $a)\n | _, _, _ => throwError \"not Real.cosh\"\n\nexample (x : ℝ) : 0 < x.cosh := by positivity\n\nend Mathlib.Meta.Positivity\n\nnamespace Complex\n\n@[simp]\ntheorem norm_cos_add_sin_mul_I (x : ℝ) : ‖cos x + sin x * I‖ = 1 := by sorry\ntheorem norm_exp_ofReal_mul_I (x : ℝ) : ‖exp (x * I)‖ = 1 := by sorry\ntheorem norm_exp_I_mul_ofReal (x : ℝ) : ‖exp (I * x)‖ = 1 := by sorry\ntheorem nnnorm_exp_ofReal_mul_I (x : ℝ) : ‖exp (x * I)‖₊ = 1 := by sorry\ntheorem nnnorm_exp_I_mul_ofReal (x : ℝ) : ‖exp (I * x)‖₊ = 1 := by sorry\ntheorem enorm_exp_ofReal_mul_I (x : ℝ) : ‖exp (x * I)‖ₑ = 1 := by sorry\ntheorem enorm_exp_I_mul_ofReal (x : ℝ) : ‖exp (I * x)‖ₑ = 1 := by sorry\ntheorem norm_exp_I_mul_ofReal_sub_one (x : ℝ) : ‖exp (I * x) - 1‖ = ‖2 * Real.sin (x / 2)‖ := by sorry\ntheorem norm_exp (z : ℂ) : ‖exp z‖ = Real.exp z.re := by sorry\ntheorem norm_exp_eq_iff_re_eq {x y : ℂ} : ‖exp x‖ = ‖exp y‖ ↔ x.re = y.re := by sorry\nend Complex\n" }, { "theorem_id": 26, "title": "017_de_moivre_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Lia.\nRequire Import Rsequence_def.\nRequire Import Rsequence_facts.\nRequire Import Rsequence_cv_facts.\nRequire Import Rsequence_usual_facts.\nRequire Import Rtactic.\nRequire Import MyRIneq.\n\nRequire Import Cprop_base.\nRequire Import Csequence.\nRequire Import Csequence_facts.\nRequire Import Cpser_def Cpser_base_facts Cpser_facts.\nRequire Import Cseries.\nRequire Import Cseries_facts.\nRequire Import Cdefinitions.\nRequire Import Canalysis_def.\n\nOpen Scope C_scope.\n\nDefinition exp_seq (n : nat) := / INC (fact n).\n\nLemma exp_seq_neq : forall n : nat, exp_seq n <> 0.\nProof.\nAdmitted.\n\nLemma Cdiv_exp_seq_simpl : forall n, (exp_seq (S n)) / (exp_seq n) = / INC (S n).\nProof.\nAdmitted.\n\nLemma Deriv_exp_seq_simpl : forall n, An_deriv exp_seq n = exp_seq n.\nProof.\nAdmitted.\n\nLemma exp_infinite_cv_radius : infinite_cv_radius exp_seq.\nProof.\nAdmitted.\n\nDefinition Cexp (z : C) := sum _ exp_infinite_cv_radius z.\n\nDefinition Deriv_Cexp (z : C) := sum_derive _ exp_infinite_cv_radius z.\n\nLemma Cexp_eq_Deriv_Cexp : forall z, Cexp z = Deriv_Cexp z.\nProof.\nAdmitted.\n\nLemma derivable_pt_lim_Cexp : forall z, derivable_pt_lim Cexp z (Cexp z).\nProof.\nAdmitted.\n\nLemma Cexp_exp_compat : forall a : R, Cexp a = exp a.\nProof.\nAdmitted.\n\nLemma Cre_Cpow_2 : forall (a : R) (n : nat), Cre ((0 +i a) ^ (2 * n)) = ((-1) ^ n * a ^ (2*n))%R.\nProof.\nAdmitted.\n\nLemma Cim_Cpow_2 : forall (a : R) (n : nat), Cim ((0 +i a) ^ (2 * n)) = R0.\nProof.\nAdmitted.\n\nLemma Cre_Cpow_S2 : forall (a : R) (p : nat), Cre ((0 +i a) ^ S (2 * p)) = R0.\nProof.\nAdmitted.\n\nLemma Cim_Cpow_S2 : forall (a : R) (n : nat), Cim ((0 +i a) ^ (S (2 * n))) = ((-1) ^ n * a ^ S (2*n))%R.\nProof.\nAdmitted.\n\nLemma Cexp_trigo_compat : forall a, Cexp (0 +i a) = cos a +i sin a.\nProof.\nAdmitted.\n\nLemma Cexp_abs_cv : forall z, {l | Cser_abs_cv (gt_pser exp_seq z) l}.\nProof.\nAdmitted.\n\nLemma binomial_diag : forall n, Binomial.\nProof.\nAdmitted.\n\nLemma binomial_zero : forall n, Binomial.\nProof.\nAdmitted.\n\nOpen Scope C_scope.\n\nLemma binomial_sum : forall (x y:C) n,\n (x + y) ^ n = sum_f_C0 (fun p => IRC (Binomial.\nProof.\nAdmitted.\n\nLemma Cexp_add : forall a b, Cexp (a + b) = (Cexp a * Cexp b)%C.\nProof.\nAdmitted.\n\nLemma Cexp_0 : Cexp C0 = C1.\nProof.\nAdmitted.\n\nLemma Cexp_mult : forall a n, Cexp (INC n * a) = (Cexp a) ^ n.\nProof.\nAdmitted." }, { "theorem_id": 27, "title": "018_liouville_s_theorem_and_the_construction_of_transcendental_n", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/floor.ml\";;\nneeds \"Library/poly.ml\";;\n\nlet algebraic = new_definition\n `algebraic(x) <=> ?p. ALL integer p /\\ ~(poly p = poly []) /\\ poly p x = &0`;;\n\nlet transcendental = new_definition\n `transcendental(x) <=> ~(algebraic x)`;;\n\nlet REAL_INTEGER_EQ_0 = `!x. integer x /\\ abs(x) < &1 ==> x = &0`;;\n\nlet FACT_LE_REFL = `!n. n <= FACT n`;;\n\nlet EXP_LE_REFL = `!a. 1 < a ==> !n. n <= a EXP n`;;\n\nlet MVT_INEQ = `!f f' a d M.\n &0 < M /\\ &0 < d /\\\n (!x. abs(x - a) <= d ==> (f diffl f'(x)) x /\\ abs(f' x) < M)\n ==> !x. abs(x - a) <= d ==> abs(f x - f a) < M * d`;;\n\nlet POLY_MULTIPLE_INTEGER = `!p q l. ALL integer l ==> integer(&q pow (LENGTH l) * poly l (&p / &q))`;;\n\nlet SEPARATE_FINITE_SET = `!a s. FINITE s\n ==> ~(a IN s) ==> ?d. &0 < d /\\ !x. x IN s ==> d <= abs(x - a)`;;\n\nlet POLY_ROOT_SEPARATE_LE = `!p x. poly p x = &0 /\\ ~(poly p = poly [])\n ==> ?d. &0 < d /\\\n !x'. &0 < abs(x' - x) /\\ abs(x' - x) < d\n ==> ~(poly p x' = &0)`;;\n\nlet POLY_ROOT_SEPARATE_LT = `!p x. poly p x = &0 /\\ ~(poly p = poly [])\n ==> ?d. &0 < d /\\\n !x'. &0 < abs(x' - x) /\\ abs(x' - x) <= d\n ==> ~(poly p x' = &0)`;;\n\nlet POLY_BOUND_INTERVAL = `!p d x. ?M. &0 < M /\\ !x'. abs(x' - x) <= d ==> abs(poly p x') < M`;;\n\nlet LIOUVILLE_INTERVAL = `!p x. poly p x = &0 /\\ ~(poly p = poly [])\n ==> ?c. &0 < c /\\\n (!x'. abs(x' - x) <= c\n ==> abs(poly(poly_diff p) x') < &1 / c) /\\\n (!x'. &0 < abs(x' - x) /\\ abs(x' - x) <= c\n ==> ~(poly p x' = &0))`;;\n\nlet LIOUVILLE = `!x. algebraic x\n ==> ?n c. c > &0 /\\\n !p q. ~(q = 0) ==> &p / &q = x \\/\n abs(x - &p / &q) > c / &q pow n`;;\n\nlet LIOUVILLE_IRRATIONAL = `!x. algebraic x /\\ ~rational x\n ==> ?n c. c > &0 /\\ !p q. ~(q = 0) ==> abs(x - &p / &q) > c / &q pow n`;;\n\nlet liouville = new_definition\n `liouville = suminf (\\n. &1 / &10 pow (FACT n))`;;\n\nlet LIOUVILLE_SUM_BOUND = `!d n. ~(n = 0)\n ==> sum(n..n+d) (\\k. &1 / &10 pow FACT k) <= &2 / &10 pow (FACT n)`;;\n\nlet LIOUVILLE_PSUM_BOUND = `!n d. ~(n = 0)\n ==> sum(n,d) (\\k. &1 / &10 pow FACT k) <= &2 / &10 pow (FACT n)`;;\n\nlet LIOUVILLE_SUMS = `(\\k. &1 / &10 pow FACT k) sums liouville`;;\n\nlet LIOUVILLE_PSUM_LE = `!n. sum(0,n) (\\k. &1 / &10 pow FACT k) <= liouville`;;\n\nlet LIOUVILLE_PSUM_LT = `!n. sum(0,n) (\\k. &1 / &10 pow FACT k) < liouville`;;\n\nlet LIOVILLE_PSUM_DIFF = `!n. ~(n = 0)\n ==> liouville\n <= sum(0,n) (\\k. &1 / &10 pow FACT k) + &2 / &10 pow (FACT n)`;;\n\nlet TRANSCENDENTAL_LIOUVILLE = `transcendental(liouville)`;;" }, { "theorem_id": 27, "title": "018_liouville_s_theorem_and_the_construction_of_transcendental_n", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory Liouville_Numbers\nimports \n Complex_Main\n \"HOL-Computational_Algebra.Polynomial\"\n Liouville_Numbers_Misc\nbegin\n\ntext \\\nA Liouville number is a real number that can be approximated well -- but not perfectly -- \nby a sequence of rational numbers. ``Well``, in this context, means that the error of the\n $n$-th rational in the sequence is bounded by the $n$-th power of its denominator.\n\nOur approach will be the following:\n\\begin{itemize}\n\\item Liouville numbers cannot be rational.\n\\item Any irrational algebraic number cannot be approximated in the Liouville sense\n\\item Therefore, all Liouville numbers are transcendental.\n\\item The standard construction fulfils all the properties of Liouville numbers.\n\\end{itemize}\n\\\n\nsubsection \\Definition of Liouville numbers\\\n\ntext \\\n The following definitions and proofs are largely adapted from those in the Wikipedia\n article on Liouville numbers.~\\<^cite>\\\"wikipedia\"\\\n\\\n\ntext \\\n A Liouville number is a real number that can be approximated well -- but not perfectly --\n by a sequence of rational numbers. The error of the $n$-th term $\\frac{p_n}{q_n}$ is at most\n $q_n^{-n}$, where $p_n\\in\\isasymint$ and $q_n \\in\\isasymint_{\\geq 2}$.\n\n We will say that such a number can be approximated in the Liouville sense.\n\\\nlocale liouville =\n fixes x :: real and p q :: \"nat \\ int\"\n assumes approx_int_pos: \"abs (x - p n / q n) > 0\" \n and denom_gt_1: \"q n > 1\"\n and approx_int: \"abs (x - p n / q n) < 1 / of_int (q n) ^ n\"\n\ntext \\\n First, we show that any Liouville number is irrational.\n\\\nlemma (in liouville) irrational: \"x \\ \\\"\n by sorry\n\ntext \\\n Next, any irrational algebraic number cannot be approximated with rational \n numbers in the Liouville sense.\n\\\nlemma liouville_irrational_algebraic:\n fixes x :: real\n assumes irrationsl: \"x \\ \\\" and \"algebraic x\"\n obtains c :: real and n :: nat\n where \"c > 0\" and \"\\(p::int) (q::int). q > 0 \\ abs (x - p / q) > c / of_int q ^ n\"\n by sorry\n\ntext \\\n Since Liouville numbers are irrational, but can be approximated well by rational \n numbers in the Liouville sense, they must be transcendental.\n\\\nlemma (in liouville) transcendental: \"\\algebraic x\"\n by sorry\n\nsubsection \\Standard construction for Liouville numbers\\\n\ntext \\\n We now define the standard construction for Liouville numbers.\n\\\ndefinition standard_liouville :: \"(nat \\ int) \\ int \\ real\" where\n \"standard_liouville p q = (\\k. p k / of_int q ^ fact (Suc k))\"\n\nlemma standard_liouville_summable:\n fixes p :: \"nat \\ int\" and q :: int\n assumes \"q > 1\" \"range p \\ {0..k. p k / of_int q ^ fact (Suc k))\"\n by sorry\n\nlemma standard_liouville_sums:\n assumes \"q > 1\" \"range p \\ {0..k. p k / of_int q ^ fact (Suc k)) sums standard_liouville p q\"\n by sorry\n\ntext \\\n Now we prove that the standard construction indeed yields Liouville numbers.\n\\\nlemma standard_liouville_is_liouville:\n assumes \"q > 1\" \"range p \\ {0..n. p n \\ 0) sequentially\"\n defines \"b \\ \\n. q ^ fact (Suc n)\"\n defines \"a \\ \\n. (\\k\\n. p k * q ^ (fact (Suc n) - fact (Suc k)))\"\n shows \"liouville (standard_liouville p q) a b\"\n by sorry\n\ntext \\\n We can now show our main result: any standard Liouville number is transcendental.\n\\\ntheorem transcendental_standard_liouville:\n assumes \"q > 1\" \"range p \\ {0..k. p k \\ 0) sequentially\"\n shows \"\\algebraic (standard_liouville p q)\"\n by sorry\n\ntext \\\n In particular: The the standard construction for constant sequences, such as the\n ``classic'' Liouville constant $\\sum_{n=1}^\\infty 10^{-n!} = 0.11000100\\ldots$,\n are transcendental. \n\n This shows that Liouville numbers exists and therefore gives a concrete and \n elementary proof that transcendental numbers exist.\n\\\ncorollary transcendental_standard_standard_liouville:\n \"a \\ {0<.. \\algebraic (standard_liouville (\\_. int a) (int b))\"\n by sorry\n\ncorollary transcendental_liouville_constant:\n \"\\algebraic (standard_liouville (\\_. 1) 10)\"\n by sorry\n\nend" }, { "theorem_id": 27, "title": "018_liouville_s_theorem_and_the_construction_of_transcendental_n", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Damiano Testa, Jujian Zhang\n-/\nmodule\n\npublic import Mathlib.Algebra.Polynomial.DenomsClearable\npublic import Mathlib.Analysis.Calculus.MeanValue\npublic import Mathlib.Analysis.Calculus.Deriv.Polynomial\npublic import Mathlib.NumberTheory.Real.Irrational\npublic import Mathlib.Topology.Algebra.Polynomial\nimport Mathlib.Algebra.Order.Interval.Set.Group\n\n/-!\n\n# Liouville's theorem\n\nThis file contains a proof of Liouville's theorem stating that all Liouville numbers are\ntranscendental.\n\nTo obtain this result, there is first a proof that Liouville numbers are irrational and two\ntechnical lemmas. These lemmas exploit the fact that a polynomial with integer coefficients\ntakes integer values at integers. When evaluating at a rational number, we can clear denominators\nand obtain precise inequalities that ultimately allow us to prove transcendence of\nLiouville numbers.\n-/\n\n@[expose] public section\n\n\n/-- A Liouville number is a real number `x` such that for every natural number `n`, there exist\n`a, b ∈ ℤ` with `1 < b` such that `0 < |x - a/b| < 1/bⁿ`.\nIn the implementation, the condition `x ≠ a/b` replaces the traditional equivalent `0 < |x - a/b|`.\n-/\ndef Liouville (x : ℝ) :=\n ∀ n : ℕ, ∃ a b : ℤ, 1 < b ∧ x ≠ a / b ∧ |x - a / b| < 1 / (b : ℝ) ^ n\n\nnamespace Liouville\n\nprotected theorem irrational {x : ℝ} (h : Liouville x) : Irrational x := by sorry\nopen Polynomial Metric Set Real RingHom\n\nopen scoped Polynomial\n\n/-- Let `Z, N` be types, let `R` be a metric space, let `α : R` be a point and let\n`j : Z → N → R` be a function. We aim to estimate how close we can get to `α`, while staying\nin the image of `j`. The points `j z a` of `R` in the image of `j` come with a \"cost\" equal to\n`d a`. As we get closer to `α` while staying in the image of `j`, we are interested in bounding\nthe quantity `d a * dist α (j z a)` from below by a strictly positive amount `1 / A`: the intuition\nis that approximating well `α` with the points in the image of `j` should come at a high cost. The\nhypotheses on the function `f : R → R` provide us with sufficient conditions to ensure our goal.\nThe first hypothesis is that `f` is Lipschitz at `α`: this yields a bound on the distance.\nThe second hypothesis is specific to the Liouville argument and provides the missing bound\ninvolving the cost function `d`.\n\nThis lemma collects the properties used in the proof of `exists_pos_real_of_irrational_root`.\nIt is stated in more general form than needed: in the intended application, `Z = ℤ`, `N = ℕ`,\n`R = ℝ`, `d a = (a + 1) ^ f.nat_degree`, `j z a = z / (a + 1)`, `f ∈ ℤ[x]`, `α` is an irrational\nroot of `f`, `ε` is small, `M` is a bound on the Lipschitz constant of `f` near `α`, `n` is\nthe degree of the polynomial `f`.\n-/\ntheorem exists_one_le_pow_mul_dist {Z N R : Type*} [PseudoMetricSpace R] {d : N → ℝ}\n {j : Z → N → R} {f : R → R} {α : R} {ε M : ℝ}\n -- denominators are positive\n (d0 : ∀ a : N, 1 ≤ d a)\n (e0 : 0 < ε)\n -- function is Lipschitz at α\n (B : ∀ ⦃y : R⦄, y ∈ closedBall α ε → dist (f α) (f y) ≤ dist α y * M)\n -- clear denominators\n (L : ∀ ⦃z : Z⦄, ∀ ⦃a : N⦄, j z a ∈ closedBall α ε → 1 ≤ d a * dist (f α) (f (j z a))) :\n ∃ A : ℝ, 0 < A ∧ ∀ z : Z, ∀ a : N, 1 ≤ d a * (dist α (j z a) * A) := by sorry\ntheorem exists_pos_real_of_irrational_root {α : ℝ} (ha : Irrational α) {f : ℤ[X]} (f0 : f ≠ 0)\n (fa : eval α (map (algebraMap ℤ ℝ) f) = 0) :\n ∃ A : ℝ, 0 < A ∧ ∀ a : ℤ, ∀ b : ℕ,\n (1 : ℝ) ≤ ((b : ℝ) + 1) ^ f.natDegree * (|α - a / (b + 1)| * A) := by sorry\nend Liouville\n" }, { "theorem_id": 27, "title": "018_liouville_s_theorem_and_the_construction_of_transcendental_n", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import CRing_Homomorphisms.\nRequire Import CPoly_NthCoeff.\nRequire Import MoreFunctions.\nRequire Import Rolle.\n\nRequire Import Zlcm Q_can RX_deg QX_ZX QX_root_loc QX_extract_roots.\n\nSection CPoly_bounded.\n\nVariable I : interval.\nHypothesis I_fin : finite I.\n\nFixpoint AbsPoly (P : cpoly_cring IR) : cpoly_cring IR :=\n match P with\n | cpoly_zero _ => cpoly_zero IR\n | cpoly_linear _ c P => cpoly_linear IR (AbsIR c) (AbsPoly P)\n end.\n\nLemma AbsPoly_zero : AbsPoly [0] = [0].\nProof.\nAdmitted.\nLemma AbsPoly_linear : forall c P, AbsPoly (c[+X*]P) = AbsIR c[+X*]AbsPoly P.\nProof.\nAdmitted.\n\nLemma Abs_poly_nth_coeff : forall P i, nth_coeff i (AbsPoly P) [=] AbsIR (nth_coeff i P).\nProof.\nAdmitted.\n\nDefinition CPoly_bound (P : cpoly_cring IR) : IR :=\n (AbsPoly P) ! (Max (AbsIR (left_end I I_fin)) (AbsIR (right_end I I_fin))).\n\nLemma AbsIR_leEq : forall a b, a [<=] b -> [--]a [<=] b -> AbsIR a [<=] b.\nProof.\nAdmitted.\n\nLemma abs_max : forall a b x, a [<=] x -> x [<=] b -> AbsIR x [<=] Max (AbsIR a) (AbsIR b).\nProof.\nAdmitted.\n\nLemma Abs_min_max : forall x, I x ->\n AbsIR x [<=] Max (AbsIR (left_end I I_fin)) (AbsIR (right_end I I_fin)).\nProof.\nAdmitted.\n\nLemma CPoly_bound_spec : forall x P, I x -> AbsIR (P ! x) [<=] CPoly_bound P.\nProof.\nAdmitted.\n\nEnd CPoly_bounded.\n\nSection poly_law_of_mean.\n\nVariable I : interval.\nHypothesis I_fin : finite I.\nHypothesis I_proper : proper I.\nVariable P : cpoly_cring IR.\n\nLet C := CPoly_bound I I_fin (_D_ P).\nLet Hderiv := Derivative_poly I I_proper P.\n\nLemma poly_law_of_mean : forall a b, I a -> I b ->\n AbsIR (P ! b [-] P ! a) [<=] C [*] (AbsIR (b [-] a)).\nProof.\nAdmitted.\n\nEnd poly_law_of_mean.\n\nSection liouville_lemmas.\n\nVariable a : IR.\nDefinition Ia : interval := clcr (a[-]Two) (a[+]Two).\nLemma Ia_fin : finite Ia.\nProof.\nAdmitted.\nLemma Ia_proper : proper Ia.\nProof.\nAdmitted.\nLemma a_in_Ia : Ia a.\nProof.\nAdmitted.\n\nLemma Liouville_lemma1 : forall x : IR, AbsIR (x[-]a) [<=] Two -> Ia x.\nProof.\nAdmitted.\n\nVariable P : cpoly_cring IR.\nLet C := CPoly_bound Ia Ia_fin (_D_ P).\n\nLemma Liouville_lemma2 : forall x : IR, AbsIR (x[-]a) [<=] Two ->\n AbsIR (P ! x [-] P ! a) [<=] C [*] AbsIR (x [-] a).\nProof.\nAdmitted.\n\nLemma Liouville_lemma3 : forall x : IR, [1] [<] x or x [<] Two.\nProof.\nAdmitted.\n\nEnd liouville_lemmas.\n\nSection liouville_lemmas2.\n\nLet ZX_deg := RX_deg Z_as_CRing Z_dec.\nVariable P : cpoly_cring Z_as_CRing.\n\nLemma Liouville_lemma4 : forall p : Z_as_CRing,\n p [#] [0] -> [1] [<=] AbsIR (inj_Q_rh p).\nProof.\nAdmitted.\n\nLemma Liouville_lemma5 : forall (p : Z_as_CRing) (q : positive), (zx2qx P) ! (p#q)%Q [#] [0] ->\n [1] [<=] (inj_Q_rh q)[^](ZX_deg P) [*] AbsIR (inj_Q_rh ((zx2qx P) ! (p#q)%Q)).\nProof.\nAdmitted.\n\nEnd liouville_lemmas2.\n\nSection liouville_lemmas3.\n\nLet ZX_deg := RX_deg Z_as_CRing Z_dec.\nLet QX_deg := RX_deg Q_as_CRing Q_dec.\nVariable P : cpoly_cring Q_as_CRing.\n\nLemma Liouville_lemma6 : forall (p : Z_as_CRing) (q : positive), P ! (p#q)%Q [#] [0] ->\n [1] [<=] (inj_Q_rh q)[^](QX_deg P) [*] AbsIR (inj_Q_rh ((Zlcm_den_poly P:Q_as_CRing)[*]P ! (p#q)%Q)).\nProof.\nAdmitted.\n\nLemma Liouville_lemma7 : forall (p : Z_as_CRing) (q : positive), P ! (p#q)%Q [#] [0] ->\n [1] [<=] (inj_Q_rh q)[^](QX_deg P) [*] AbsIR (inj_Q_rh (Zlcm_den_poly P:Q_as_CRing)) [*] AbsIR (inj_Q_rh (P ! (p#q)%Q)).\nProof.\nAdmitted.\n\nVariable a : IR.\nLet C := AbsIR (inj_Q_rh (Zlcm_den_poly P:Q_as_CRing)) [*] CPoly_bound (Ia a) (Ia_fin a) (_D_ (inj_QX_rh P)).\nHypothesis Ha : (inj_QX_rh P) ! a [=] [0].\n\nLemma Liouville_lemma8 : forall (n : nat) (q : positive), [1] [<=] (inj_Q_rh q)[^]n.\nProof.\nAdmitted.\n\nLemma Liouville_lemma9 : forall (p : Z_as_CRing) (q : positive),\n P ! (p#q)%Q [#] [0] -> AbsIR ((inj_Q_rh (p#q)%Q) [-] a) [<=] Two ->\n [1] [<=] (inj_Q_rh q)[^](QX_deg P) [*] C [*] AbsIR ((inj_Q_rh (p#q)%Q) [-] a).\nProof.\nAdmitted.\n\nLet C' := Max [1] C.\n\nLemma Liouville_lemma10 : forall (p : Z_as_CRing) (q : positive),\n P ! (p#q)%Q [#] [0] ->\n [1] [<=] (inj_Q_rh q)[^](QX_deg P) [*] C' [*] AbsIR ((inj_Q_rh (p#q)%Q) [-] a).\nProof.\nAdmitted.\n\nEnd liouville_lemmas3.\n\nSection liouville_theorem.\n\nVariable a : IR.\nHypothesis a_irrat : forall x : Q, a [~=] inj_Q _ x.\nVariable P : cpoly_cring Q_as_CRing.\nHypothesis P_nz : P [#] [0].\nHypothesis a_alg : (inj_QX_rh P) ! a [=] [0].\n\nLet C : IR := Max [1] (AbsIR (inj_Q_rh (Zlcm_den_poly (QX_extract_roots P):Q_as_CRing)) [*] CPoly_bound (Ia a) (Ia_fin a) (_D_ (inj_QX_rh (QX_extract_roots P)))).\nLemma constant_pos : [0] [<] C.\nProof.\nAdmitted.\n\nLemma constant_nz : C [#] [0].\nProof.\nAdmitted.\n\nDefinition Liouville_constant : IR := [1] [/] C [//] constant_nz.\n\nDefinition Liouville_degree := RX_deg _ Q_dec (QX_extract_roots P).\n\nTheorem Liouville_theorem : forall (x : Q),\n (Liouville_constant[*]inj_Q IR (1#Qden x)%Q[^]Liouville_degree)\n [<=] AbsIR (inj_Q _ x [-] a).\nProof.\nAdmitted.\n\nTheorem Liouville_theorem2 :\n {n : nat | {C : IR | [0] [<] C | forall (x : Q),\n (C[*]inj_Q IR (1#Qden x)%Q[^]n) [<=] AbsIR (inj_Q _ x [-] a)}}.\nProof.\nAdmitted.\n\nEnd liouville_theorem." }, { "theorem_id": 28, "title": "019_four_squares_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";;\nneeds \"Library/analysis.ml\";; \n\nprioritize_num();;\n\nlet involution = new_definition\n `involution f s = !x. x IN s ==> f(x) IN s /\\ (f(f(x)) = x)`;;\n\nlet INVOLUTION_IMAGE = `!f s. involution f s ==> (IMAGE f s = s)`;;\n\nlet INVOLUTION_DELETE = `involution f s /\\ a IN s /\\ (f a = a) ==> involution f (s DELETE a)`;;\n\nlet INVOLUTION_STEPDOWN = `involution f s /\\ a IN s ==> involution f (s DIFF {a, (f a)})`;;\n\nlet INVOLUTION_NOFIXES = `involution f s ==> involution f {x | x IN s /\\ ~(f x = x)}`;;\n\nlet INVOLUTION_SUBSET = `!f s t. involution f s /\\ (!x. x IN t ==> f(x) IN t) /\\ t SUBSET s\n ==> involution f t`;;\n\nlet INVOLUTION_EVEN = `!s. FINITE(s) /\\ involution f s /\\ (!x:A. x IN s ==> ~(f x = x))\n ==> EVEN(CARD s)`;;\n\nlet INVOLUTION_FIX_ODD = `FINITE(s) /\\ involution f s /\\ (?!a:A. a IN s /\\ (f a = a))\n ==> ODD(CARD s)`;;\n\nlet INVOLUTION_ODD = `!n s. FINITE(s) /\\ involution f s /\\ ODD(CARD s)\n ==> ?a. a IN s /\\ (f a = a)`;;\n\nlet INVOLUTION_FIX_FIX = `!f g s. FINITE(s) /\\ involution f s /\\ involution g s /\\\n (?!x. x IN s /\\ (f x = x)) ==> ?x. x IN s /\\ (g x = x)`;;\n\nlet zset = new_definition\n `zset(a) = {(x,y,z) | x EXP 2 + 4 * y * z = a}`;;\n\nlet zag = new_definition\n `zag(x,y,z) =\n if x + z < y then (x + 2 * z,z,y - (x + z))\n else if x < 2 * y then (2 * y - x, y, (x + z) - y)\n else (x - 2 * y,(x + z) - y, y)`;;\n\nlet tag = new_definition\n `tag((x,y,z):num#num#num) = (x,z,y)`;;\n\nlet ZAG_INVOLUTION_GENERAL = `0 < x /\\ 0 < y /\\ 0 < z ==> (zag(zag(x,y,z)) = (x,y,z))`;;\n\nlet IN_TRIPLE = `(a,b,c) IN {(x,y,z) | P x y z} <=> P a b c`;;\n\nlet PRIME_SQUARE = `!n. ~prime(n * n)`;;\n\nlet PRIME_4X = `!n. ~prime(4 * n)`;;\n\nlet PRIME_XYZ_NONZERO = `prime(x EXP 2 + 4 * y * z) ==> 0 < x /\\ 0 < y /\\ 0 < z`;;\n\nlet ZAG_INVOLUTION = `!p. prime(p) ==> involution zag (zset(p))`;;\n\nlet TAG_INVOLUTION = `!a. involution tag (zset a)`;;\n\nlet ZAG_LEMMA = `(zag(x,y,z) = (x,y,z)) ==> (y = x)`;;\n\nlet ZSET_BOUND = `0 < y /\\ 0 < z /\\ (x EXP 2 + 4 * y * z = p)\n ==> x <= p /\\ y <= p /\\ z <= p`;;\n\nlet ZSET_FINITE = `!p. prime(p) ==> FINITE(zset p)`;;\n\nlet SUM_OF_TWO_SQUARES = `!p k. prime(p) /\\ (p = 4 * k + 1) ==> ?x y. p = x EXP 2 + y EXP 2`;;\n\nlet PIGEONHOLE_LEMMA = `!f:A->B g s t.\n FINITE(s) /\\ FINITE(t) /\\\n (!x. x IN s ==> f(x) IN t) /\\\n (!x y. x IN s /\\ y IN s /\\ (f x = f y) ==> (x = y)) /\\\n (!x. x IN s ==> g(x) IN t) /\\\n (!x y. x IN s /\\ y IN s /\\ (g x = g y) ==> (x = y)) /\\\n CARD(t) < 2 * CARD(s)\n ==> ?x y. x IN s /\\ y IN s /\\ (f x = g y)`;;\n\nlet PIGEONHOLE_LEMMA_P12 = `!f g p.\n ODD(p) /\\\n (!x. 2 * x < p ==> f(x) < p) /\\\n (!x y. 2 * x < p /\\ 2 * y < p /\\ (f x = f y) ==> (x = y)) /\\\n (!x. 2 * x < p ==> g(x) < p) /\\\n (!x y. 2 * x < p /\\ 2 * y < p /\\ (g x = g y) ==> (x = y))\n ==> ?x y. 2 * x < p /\\ 2 * y < p /\\ (f x = g y)`;;\n\nlet SQUAREMOD_INJ_LEMMA = `!p x d. prime(p) /\\ 2 * (x + d) < p /\\\n ((x + d) * (x + d) + m * p = x * x + n * p)\n ==> (d = 0)`;;\n\nlet SQUAREMOD_INJ = `!p. prime(p)\n ==> (!x. 2 * x < p ==> (x EXP 2 + a) MOD p < p) /\\\n (!x y. 2 * x < p /\\ 2 * y < p /\\\n ((x EXP 2 + a) MOD p = (y EXP 2 + a) MOD p)\n ==> (x = y))`;;\n\nlet REFLECT_INJ = `(!x. 2 * x < p ==> f(x) < p) /\\\n (!x y. 2 * x < p /\\ 2 * y < p /\\ (f x = f y) ==> (x = y))\n ==> (!x. 2 * x < p ==> p - 1 - f(x) < p) /\\\n (!x y. 2 * x < p /\\ 2 * y < p /\\ (p - 1 - f(x) = p - 1 - f(y))\n ==> (x = y))`;;\n\nlet LAGRANGE_LEMMA_ODD = `!a p. prime(p) /\\ ODD(p)\n ==> ?n x y. 2 * x < p /\\ 2 * y < p /\\\n (n * p = x EXP 2 + y EXP 2 + a + 1)`;;\n\nlet LAGRANGE_LEMMA = `!a p. prime(p)\n ==> ?n x y. 2 * x <= p /\\ 2 * y <= p /\\\n (n * p = x EXP 2 + y EXP 2 + a)`;;\n\nprioritize_real();;\n\nlet REAL_INTEGER_CLOSURES = `(!n. ?p. abs(&n) = &p) /\\\n (!x y. (?m. abs(x) = &m) /\\ (?n. abs(y) = &n) ==> ?p. abs(x + y) = &p) /\\\n (!x y. (?m. abs(x) = &m) /\\ (?n. abs(y) = &n) ==> ?p. abs(x - y) = &p) /\\\n (!x y. (?m. abs(x) = &m) /\\ (?n. abs(y) = &n) ==> ?p. abs(x * y) = &p) /\\\n (!x r. (?n. abs(x) = &n) ==> ?p. abs(x pow r) = &p) /\\\n (!x. (?n. abs(x) = &n) ==> ?p. abs(--x) = &p) /\\\n (!x. (?n. abs(x) = &n) ==> ?p. abs(abs x) = &p)`;;\n\nlet REAL_NUM_ROUND = `!x. &0 <= x ==> ?n. abs(x - &n) <= &1 / &2`;;\n\nlet REAL_POS_ABS_MIDDLE = `!x n. &0 <= x /\\ (abs(x - &n) = &1 / &2)\n ==> (x = &(n - 1) + &1 / &2) \\/ (x = &n + &1 / &2)`;;\n\nlet REAL_RAT_ABS_MIDDLE = `!m n p. (abs(&m / &p - &n) = &1 / &2)\n ==> (&m / &p = &(n - 1) + &1 / &2) \\/ (&m / &p = &n + &1 / &2)`;;\n\nlet AUBREY_LEMMA_4 = `!m n p q r.\n ~(m = 0) /\\ ~(m = 1) /\\\n ((&n / &m) pow 2 + (&p / &m) pow 2 +\n (&q / &m) pow 2 + (&r / &m) pow 2 = &N)\n ==> ?m' n' p' q' r'.\n ~(m' = 0) /\\ m' < m /\\\n ((&n' / &m') pow 2 + (&p' / &m') pow 2 +\n (&q' / &m') pow 2 + (&r' / &m') pow 2 = &N)`;;\n\nlet AUBREY_THM_4 = `(?q. ~(q = 0) /\\\n ?a b c d.\n (&a / &q) pow 2 + (&b / &q) pow 2 +\n (&c / &q) pow 2 + (&d / &q) pow 2 = &N)\n ==> ?a b c d. &a pow 2 + &b pow 2 + &c pow 2 + &d pow 2 = &N`;;\n\nlet LAGRANGE_IDENTITY = REAL_ARITH\n `(w1 pow 2 + x1 pow 2 + y1 pow 2 + z1 pow 2) *\n (w2 pow 2 + x2 pow 2 + y2 pow 2 + z2 pow 2) =\n (w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2) pow 2 +\n (w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2) pow 2 +\n (w1 * y2 - x1 * z2 + y1 * w2 + z1 * x2) pow 2 +\n (w1 * z2 + x1 * y2 - y1 * x2 + z1 * w2) pow 2`;;\n\nlet LAGRANGE_REAL_NUM = `!n. ?w x y z. &n = &w pow 2 + &x pow 2 + &y pow 2 + &z pow 2`;;\n\nlet LAGRANGE_NUM = `!n. ?w x y z. n = w EXP 2 + x EXP 2 + y EXP 2 + z EXP 2`;;\n\nprioritize_int();;\n\nlet LAGRANGE_INT = `!a. &0 <= a <=> ?w x y z. a = w pow 2 + x pow 2 + y pow 2 + z pow 2`;;\n\nprioritize_num();;" }, { "theorem_id": 28, "title": "019_four_squares_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Lagrange's four-square theorem\\\n\ntheory FourSquares\n imports \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ncontext\n\n fixes sum4sq_nat :: \"nat \\ nat \\ nat \\ nat \\ nat\"\n defines \"sum4sq_nat a b c d \\ a^2+b^2+c^2+d^2\"\n \n fixes is_sum4sq_nat :: \"nat \\ bool\"\n defines \"is_sum4sq_nat n \\ (\\ a b c d. n = sum4sq_nat a b c d)\"\n \nbegin\n\nprivate lemma best_division_abs: \"(n::int) > 0 \\ \\ k. 2 * \\a - k*n\\ \\ n\"\nproof -\n assume a: \"n > 0\"\n define k where \"k = a div n\"\n have h: \"a - k * n = a mod n\" by (simp add: div_mult_mod_eq algebra_simps k_def)\n thus ?thesis\n proof (cases \"2 * (a mod n) \\ n\")\n case True\n hence \"2 * \\a - k*n\\ \\ n\" using h pos_mod_sign a by auto\n thus ?thesis by blast\n next\n case False\n hence \"2 * (n - a mod n) \\ n\" by auto\n have \"a - (k+1)*n = a mod n - n\" using h by (simp add: algebra_simps)\n hence \"2 * \\a - (k+1)*n\\ \\ n\" using h pos_mod_bound[of n a] a False by fastforce\n thus ?thesis by blast\n qed\nqed\n\ntext \\Shows that all nonnegative integers can be written as the sum of four squares. The proof consists of the following steps:\n\\begin{itemize}\\item For every prime $p=2n+1$ the two sets of residue classes $$\\{x^2 \\bmod p\\mid 0\\le x\\le n\\} ~{\\rm and}~ \\{-1-y^2 \\bmod p \\mid 0 \\le y \\le n\\}$$ both contain $n+1$ different elements and therefore they must have at least one element in common.\n\\item Hence there exist $x,y$ such that $x^2+y^2+1^2+0^2$ is a multiple of $p$.\n\\item The next step is to show, by an infinite descent, that $p$ itself can be written as the sum of four squares.\n\\item Finally, using the multiplicity of this form, the same holds for all positive numbers.\n\\end{itemize}\\\n\nprivate definition\n sum4sq_int :: \"int \\ int \\ int \\ int \\ int\" where\n \"sum4sq_int = (\\(a,b,c,d). a^2+b^2+c^2+d^2)\"\n\nprivate definition\n is_sum4sq_int :: \"int \\ bool\" where\n \"is_sum4sq_int n \\ (\\ a b c d. n = sum4sq_int(a,b,c,d))\"\n\nprivate lemma mult_sum4sq_int: \"sum4sq_int(a,b,c,d) * sum4sq_int(p,q,r,s) =\n sum4sq_int(a*p+b*q+c*r+d*s, a*q-b*p-c*s+d*r,\n a*r+b*s-c*p-d*q, a*s-b*r+c*q-d*p)\"\n by (unfold sum4sq_int_def, simp add: eval_nat_numeral field_simps)\n\nprivate lemma sum4sq_int_nat_eq: \"sum4sq_nat a b c d = sum4sq_int (a, b, c, d)\"\n unfolding sum4sq_nat_def sum4sq_int_def by simp\n\nprivate lemma is_sum4sq_int_nat_eq: \"is_sum4sq_nat n = is_sum4sq_int (int n)\"\n unfolding is_sum4sq_nat_def is_sum4sq_int_def\nproof\n assume \"\\a b c d. n = sum4sq_nat a b c d\"\n thus \"\\a b c d. int n = sum4sq_int (a, b, c, d)\" using sum4sq_int_nat_eq by force\nnext\n assume \"\\a b c d. int n = sum4sq_int (a, b, c, d)\"\n then obtain a b c d where \"int n = sum4sq_int (a, b, c, d)\" by blast\n hence \"int n = sum4sq_int (int (nat \\a\\), int (nat \\b\\), int (nat \\c\\), int (nat \\d\\))\"\n unfolding sum4sq_int_def by simp\n hence \"int n = int (sum4sq_nat (nat \\a\\) (nat \\b\\) (nat \\c\\) (nat \\d\\))\"\n using sum4sq_int_nat_eq by presburger\n thus \"\\a b c d. n = sum4sq_nat a b c d\" by auto\nqed\n\nprivate lemma is_mult_sum4sq_int: \"is_sum4sq_int x \\ is_sum4sq_int y \\ is_sum4sq_int (x*y)\"\n by (unfold is_sum4sq_int_def, auto simp only: mult_sum4sq_int, blast)\n\nprivate lemma is_mult_sum4sq_nat: \"is_sum4sq_nat x \\ is_sum4sq_nat y \\ is_sum4sq_nat (x*y)\"\n using is_mult_sum4sq_int is_sum4sq_int_nat_eq by simp\n\nprivate lemma mult_oddprime_is_sum4sq: \"\\ prime (nat p); odd p \\ \\\n \\ t. 0 t

is_sum4sq_int (p*t)\"\nproof -\n assume p1: \"prime (nat p)\"\n then have p0: \"p > 1\" and \"prime p\"\n by (simp_all add: prime_int_nat_transfer prime_nat_iff)\n assume p2: \"odd p\"\n then obtain n where n: \"p = 2*n+1\" using oddE by blast\n with p1 have n0: \"n > 0\" by (auto simp add: prime_nat_iff)\n let ?C = \"{0 ..< p}\"\n let ?D = \"{0 .. n}\"\n let ?f = \"%x. x^2 mod p\"\n let ?g = \"%x. (-1-x^2) mod p\"\n let ?A = \"?f ` ?D\"\n let ?B = \"?g ` ?D\"\n have finC: \"finite ?C\" by simp\n have finD: \"finite ?D\" by simp\n from p0 have AsubC: \"?A \\ ?C\" and BsubC: \"?B \\ ?C\"\n by auto\n with finC have finA: \"finite ?A\" and finB: \"finite ?B\"\n by (auto simp add: finite_subset)\n from AsubC BsubC have AunBsubC: \"?A \\ ?B \\ ?C\" by (rule Un_least)\n from p0 have cardC: \"card ?C = nat p\" using card_atLeastZeroLessThan_int by blast\n from n0 have cardD: \"card ?D = 1+ nat n\" by simp\n have cardA: \"card ?A = card ?D\"\n proof -\n have \"inj_on ?f ?D\"\n proof (unfold inj_on_def, auto)\n fix x fix y\n assume x0: \"0 \\ x\" and xn: \"x \\ n\" and y0: \"0 \\ y\" and yn: \" y \\ n\"\n and xyp: \"x^2 mod p = y^2 mod p\"\n with p0 have \"[x^2 = y^2] (mod p)\" using cong_def by blast\n hence \"p dvd x^2-y^2\" using cong_iff_dvd_diff by blast\n hence \"p dvd (x+y)*(x-y)\" by (simp add: power2_eq_square algebra_simps)\n hence \"p dvd x+y \\ p dvd x-y\" using \\prime p\\ p0 \n by (auto dest: prime_dvd_multD)\n moreover\n { assume \"p dvd x+y\"\n moreover from xn yn n have \"x+y < p\" by auto\n ultimately have \"\\ x+y > 0\" by (auto simp add: zdvd_not_zless)\n with x0 y0 have \"x = y\" by auto } \\ \\both are zero\\\n moreover\n { assume ass: \"p dvd x-y\"\n have \"x = y\"\n proof (rule ccontr, case_tac \"x-y \\ 0\")\n assume \"x-y \\ 0\" and \"x \\ y\" hence \"x-y > 0\" by auto\n with ass have \"\\ x-y < p\" by (auto simp add: zdvd_not_zless)\n with xn y0 n p0 show \"False\" by auto\n next\n assume \"\\ 0 \\ x-y\" hence \"y-x > 0\" by auto\n moreover from x0 yn n p0 have \"y-x < p\" by auto\n ultimately have \"\\ p dvd y-x\" by (auto simp add: zdvd_not_zless)\n moreover from ass have \"p dvd -(x-y)\" by (simp only: dvd_minus_iff)\n ultimately show \"False\" by auto\n qed }\n ultimately show \"x=y\" by auto\n qed\n with finD show ?thesis by (simp only: inj_on_iff_eq_card)\n qed\n have cardB: \"card ?B = card ?D\"\n proof -\n have \"inj_on ?g ?D\"\n proof (unfold inj_on_def, auto)\n fix x fix y\n assume x0: \"0 \\ x\" and xn: \"x \\ n\" and y0: \"0 \\ y\" and yn: \" y \\ n\"\n and xyp: \"(-1-x^2) mod p = (-1-y^2) mod p\"\n with p0 have \"[-1-y^2 = -1-x^2] (mod p)\" by (simp only: cong_def)\n hence \"p dvd (-1-y^2) - (-1-x^2)\" by (simp only: cong_iff_dvd_diff)\n moreover have \"-1-y^2 - (-1-x^2) = x^2 - y^2\" by arith\n ultimately have \"p dvd x^2-y^2\" by simp\n hence \"p dvd (x+y)*(x-y)\" by (simp add: power2_eq_square algebra_simps)\n with p1 have \"p dvd x+y \\ p dvd x-y\" using \\prime p\\ p0 \n by (auto dest: prime_dvd_multD)\n moreover\n { assume \"p dvd x+y\"\n moreover from xn yn n have \"x+y < p\" by auto\n ultimately have \"\\ x+y > 0\" by (auto simp add: zdvd_not_zless)\n with x0 y0 have \"x = y\" by auto } \\ \\both are zero\\\n moreover\n { assume ass: \"p dvd x-y\"\n have \"x = y\"\n proof (rule ccontr, case_tac \"x-y \\ 0\")\n assume \"x-y \\ 0\" and \"x \\ y\" hence \"x-y > 0\" by auto\n with ass have \"\\ x-y < p\" by (auto simp add: zdvd_not_zless)\n with xn y0 n p0 show \"False\" by auto\n next\n assume \"\\ 0 \\ x-y\" hence \"y-x > 0\" by auto\n moreover from x0 yn n p0 have \"y-x < p\" by auto\n ultimately have \"\\ p dvd y-x\" by (auto simp add: zdvd_not_zless)\n moreover from ass have \"p dvd -(x-y)\" by (simp only: dvd_minus_iff)\n ultimately show \"False\" by auto\n qed }\n ultimately show \"x=y\" by auto\n qed\n with finD show ?thesis by (simp only: inj_on_iff_eq_card)\n qed\n have \"?A \\ ?B \\ {}\"\n proof (rule ccontr, auto)\n assume ABdisj: \"?A \\ ?B = {}\"\n from cardA cardB cardD have \"2 + 2*(nat n) = card ?A + card ?B\" by auto\n also with finA finB ABdisj have \"\\ = card (?A \\ ?B)\"\n by (simp only: card_Un_disjoint)\n also with finC AunBsubC have \"\\ \\ card ?C\" by (simp only: card_mono)\n also with cardC have \"\\ = nat p\" by simp\n finally have \"2 + 2*(nat n) \\ nat p\" by simp\n with n show \"False\" by arith\n qed\n then obtain z where \"z \\ ?A \\ z \\ ?B\" by auto\n then obtain x y where xy: \"x \\ ?D \\ y \\ ?D \\ z = x^2 mod p \\ z = (-1-y^2) mod p\" by blast\n with p0 have \"[x^2=-1-y^2](mod p)\" by (simp add: cong_def)\n hence \"p dvd x^2-(-1-y^2)\" by (simp only: cong_iff_dvd_diff)\n moreover have \"x^2-(-1-y^2)=x^2+y^2+1\" by arith\n ultimately have \"p dvd sum4sq_int(x,y,1,0)\" by (auto simp add: sum4sq_int_def)\n then obtain t where t: \"p * t = sum4sq_int(x,y,1,0)\" by (auto simp only: dvd_def eq_refl)\n hence \"is_sum4sq_int (p*t)\" by (unfold is_sum4sq_int_def, auto)\n moreover have \"t > 0 \\ t < p\"\n proof\n have \"x^2 \\ 0 \\ y^2 \\ 0\" by simp\n hence \"x^2+y^2+1 > 0\" by arith\n with t have \"p*t > 0\" by (unfold sum4sq_int_def, auto)\n moreover\n { assume \"t < 0\" with p0 have \"p*t < p*0\" by (simp only: zmult_zless_mono2)\n hence \"p*t < 0\" by simp }\n moreover\n { assume \"t = 0\" hence \"p*t = 0\" by simp }\n ultimately have \"\\ t < 0 \\ t \\ 0\" by auto\n thus \"t > 0\" by simp\n from xy have \"x^2 \\ n^2 \\ y^2 \\ n^2\" by (auto simp add: power_mono)\n hence \"x^2+y^2+1 \\ 2*n^2 + 1\" by auto\n with t have contr: \"p*t \\ 2*n^2+1\" by (simp add: sum4sq_int_def)\n moreover\n { assume \"t > n+1\"\n with p0 have \"p*(n+1) < p*t\" by (simp only: zmult_zless_mono2)\n with n have \"p*t > (2*n+1)*n + (2*n+1)*1\" by (simp only: distrib_left)\n hence \"p*t > 2*n*n + n + 2*n + 1\" by (simp only: distrib_right mult_1_left)\n with n0 have \"p*t > 2*n^2 + 1\" by (simp add: power2_eq_square) }\n ultimately have \"\\ t > n+1\" by auto\n with n0 n show \"t < p\" by auto\n qed\n ultimately show ?thesis by blast\nqed\n\nprivate lemma zprime_is_sum4sq: \"prime (nat p) \\ is_sum4sq_int p\"\nproof (cases)\n assume p2: \"p=2\"\n hence \"p = sum4sq_int(1,1,0,0)\" by (auto simp add: sum4sq_int_def)\n thus ?thesis by (auto simp add: is_sum4sq_int_def)\nnext\n assume \"\\ p =2\" and prp: \"prime (nat p)\"\n hence \"\\ nat p = 2\" by simp\n with prp have \"2 < nat p\" using prime_nat_iff by force\n moreover with prp have \"odd (nat p)\" using prime_odd_nat[of \"nat p\"] by blast\n ultimately have \"odd p\" by (simp add: even_nat_iff)\n with prp have \"\\ t. 0 t

is_sum4sq_int (p*t)\" by (rule mult_oddprime_is_sum4sq)\n then obtain a b c d t where pt_sol: \"0 t

p*t = sum4sq_int(a,b,c,d)\"\n by (unfold is_sum4sq_int_def, blast)\n hence Qt: \"0 t

(\\ a1 a2 a3 a4. p*t = sum4sq_int(a1,a2,a3,a4))\"\n (is \"?Q t\") by blast\n have \"?Q 1\"\n proof (rule ccontr)\n assume nQ1: \"\\ ?Q 1\"\n have \"\\ ?Q t\"\n proof (induct t rule: infinite_descent0_measure[where V=\"\\x. (nat x)- 1\"], clarify)\n fix x a b c d\n assume \"nat x - 1 = 0\" and \"x > 0\" and s: \"p*x=sum4sq_int(a,b,c,d)\" and \"x < p\"\n moreover hence \"x = 1\" by arith\n ultimately have \"?Q 1\" by auto\n with nQ1 show False by auto\n next\n fix x\n assume \"0 < nat x - 1\" and \"\\ \\ ?Q x\"\n then obtain a1 a2 a3 a4 where ass: \"1 x

p*x = sum4sq_int(a1,a2,a3,a4)\"\n by auto\n have \"\\ y. nat y - 1 < nat x - 1 \\ ?Q y\"\n proof (cases)\n assume evx: \"even x\"\n hence \"even (x*p)\" by simp\n with ass have ev1234: \"even (a1^2+a2^2 + a3^2+a4^2)\"\n by (auto simp add: sum4sq_int_def ac_simps)\n have \"\\ b1 b2 b3 b4. p*x=sum4sq_int(b1,b2,b3,b4) \\ even (b1+b2) \\ even (b3+b4)\"\n proof (cases)\n assume ev12: \"even (a1^2+a2^2)\"\n with ev1234 ass show ?thesis by auto\n next\n assume \"\\ even (a1^2+a2^2)\"\n hence odd12: \"odd (a1^2+a2^2)\" by simp\n with ev1234 have odd34: \"odd (a3^2+a4^2)\" by auto\n show ?thesis\n proof (cases)\n assume ev1: \"even (a1^2)\"\n with odd12 have odd2: \"odd (a2^2)\" by simp\n show ?thesis\n proof (cases)\n assume \"even (a3^2)\"\n moreover from ass have \"p*x = sum4sq_int(a1,a3,a2,a4)\" by (auto simp add: sum4sq_int_def)\n ultimately show ?thesis using odd2 odd34 ev1 by auto\n next\n assume \"\\ even (a3^2)\"\n moreover from ass have \"p*x = sum4sq_int(a1,a4,a2,a3)\" by (auto simp add: sum4sq_int_def)\n ultimately show ?thesis using odd34 odd2 ev1 by auto\n qed\n next\n assume odd1: \"\\ even (a1^2)\"\n with odd12 have ev2: \"even (a2^2)\" by simp\n show ?thesis\n proof (cases)\n assume \"even (a3^2)\"\n moreover from ass have \"sum4sq_int(a1,a4,a2,a3)=p*x\" by (auto simp add: sum4sq_int_def)\n ultimately show ?thesis using odd34 odd1 ev2 by force\n next\n assume \"\\ even (a3^2)\"\n moreover from ass have \"sum4sq_int(a1,a3,a2,a4)=p*x\" by (auto simp add: sum4sq_int_def)\n ultimately show ?thesis using odd34 odd1 ev2 by force\n qed\n qed\n qed\n then obtain b1 b2 b3 b4\n where b: \"p*x = sum4sq_int(b1,b2,b3,b4) \\ even (b1+b2) \\ even (b3+b4)\" by auto\n then obtain c1 c3 where c13: \"b1+b2 = 2*c1 \\ b3+b4 = 2*c3\"\n using evenE[of \"b1+b2\"] evenE[of \"b3+b4\"] by meson\n from b have \"even (b1-b2) \\ even (b3-b4)\" by simp\n then obtain c2 c4 where c24: \"b1-b2 = 2*c2 \\ b3-b4 = 2*c4\"\n using evenE[of \"b1-b2\"] evenE[of \"b3-b4\"] by meson\n from evx obtain y where y: \"x = 2*y\" using evenE by blast\n hence \"4*(p*y) = 2*(p*x)\" by (simp add: ac_simps)\n also from b have \"\\ = 2*b1^2 + 2*b2^2 + 2*b3^2 + 2*b4^2\"\n by (auto simp: sum4sq_int_def)\n also have \"\\ = (b1 + b2)^2 + (b1 - b2)^2 + (b3 + b4)^2 + (b3 - b4)^2\"\n by (auto simp add: power2_eq_square algebra_simps)\n also with c13 c24 have \"\\ = 4*(c1^2 + c2^2 + c3^2 + c4^2)\"\n by (auto simp add: power_mult_distrib)\n finally have \"p * y = sum4sq_int(c1,c2,c3,c4)\" by (auto simp add: sum4sq_int_def)\n moreover from y ass have \"0 < y \\ y < p \\ (nat y) - 1 < (nat x) - 1\" by arith\n ultimately show ?thesis by blast\n next\n assume xodd: \"\\ even x\"\n with ass have \"\\ c1 c2 c3 c4. 2*\\a1-c1*x\\\\x \\ 2*\\a2-c2*x\\\\x \\ 2*\\a3-c3*x\\\\x \\ 2*\\a4-c4*x\\\\x\"\n by (simp add: best_division_abs)\n then obtain b1 c1 b2 c2 b3 c3 b4 c4 where\n bc_def: \"b1 = a1-c1*x \\ b2 = a2-c2*x \\ b3 = a3-c3*x \\ b4 = a4-c4*x\"\n and \"2*\\b1\\\\x \\ 2*\\b2\\\\x \\ 2*\\b3\\\\x \\ 2*\\b4\\\\x\"\n by blast\n moreover have \"2*\\b1\\\\x \\ 2*\\b2\\\\x \\ 2*\\b3\\\\x \\ 2*\\b4\\\\x\" using xodd by fastforce\n ultimately have bc_abs: \"2*\\b1\\ 2*\\b2\\ 2*\\b3\\ 2*\\b4\\ x dvd ?A2 \\ x dvd ?A3 \\ x dvd ?A4\"\n proof (safe)\n from bc_def have\n \"?A1 = (b1+c1*x)*b1 + (b2+c2*x)*b2 + (b3+c3*x)*b3 + (b4+c4*x)*b4\"\n by simp\n also with y have \"\\ = x*(y + c1*b1 + c2*b2 + c3*b3 + c4*b4)\"\n by (auto simp add: distrib_left power2_eq_square ac_simps)\n finally show \"x dvd ?A1\" by auto\n from bc_def have\n \"?A2 = (b1+c1*x)*b2 - (b2+c2*x)*b1 - (b3+c3*x)*b4 + (b4+c4*x)*b3\"\n by simp\n also have \"\\ = x*(c1*b2 - c2*b1 - c3*b4 + c4*b3)\"\n by (auto simp add: distrib_left right_diff_distrib ac_simps)\n finally show \"x dvd ?A2\" by auto\n from bc_def have\n \"?A3 = (b1+c1*x)*b3 + (b2+c2*x)*b4 - (b3+c3*x)*b1 - (b4+c4*x)*b2\"\n by simp\n also have \"\\ = x*(c1*b3 + c2*b4 - c3*b1 - c4*b2)\"\n by (auto simp add: distrib_left right_diff_distrib ac_simps)\n finally show \"x dvd ?A3\" by auto\n from bc_def have\n \"?A4 = (b1+c1*x)*b4 - (b2+c2*x)*b3 + (b3+c3*x)*b2 - (b4+c4*x)*b1\"\n by simp\n also have \"\\ = x*(c1*b4 - c2*b3 + c3*b2 - c4*b1)\"\n by (auto simp add: distrib_left right_diff_distrib ac_simps)\n finally show \"x dvd ?A4\" by auto\n qed\n then obtain d1 d2 d3 d4 where d:\n \"?A1=x*d1 \\ ?A2=x*d2 \\ ?A3=x*d3 \\ ?A4=x*d4\"\n by (auto simp add: dvd_def)\n let ?D = \"sum4sq_int(d1,d2,d3,d4)\"\n from d have \"x^2*?D = ?A\"\n by (auto simp only: sum4sq_int_def power_mult_distrib distrib_left)\n also have \"\\ = sum4sq_int(a1,a2,a3,a4)*sum4sq_int(b1,b2,b3,b4)\"\n by (simp only: mult_sum4sq_int)\n also with y ass have \"\\ = (p*x)*(x*y)\" by (auto simp add: sum4sq_int_def)\n also have \"\\ = x^2*(p*y)\" by (simp only: power2_eq_square ac_simps)\n finally have \"x^2*(?D - p*y) = 0\" by (auto simp add: right_diff_distrib)\n with ass have \"p*y = ?D\" by auto\n moreover have y_l_x: \"y < x\"\n proof -\n have \"4*b1^2 = (2*\\b1\\)^2 \\ 4*b2^2 = (2*\\b2\\)^2 \\\n 4*b3^2 = (2*\\b3\\)^2 \\ 4*b4^2 = (2*\\b4\\)^2\" by simp\n with bc_abs have \"4*b1^2 4*b2^2 4*b3^2 4*b4^2b\\\" x 2 for b]\n by auto\n hence \"?B < x^2\" by auto\n with y have \"x*(x-y) > 0\"\n by (auto simp add: power2_eq_square right_diff_distrib)\n moreover from ass have \"x > 0\" by simp\n ultimately show ?thesis using zero_less_mult_pos by fastforce\n qed\n moreover have \"y > 0\"\n proof -\n have b2pos: \"b1^2 \\ 0 \\ b2^2 \\ 0 \\ b3^2 \\ 0 \\ b4^2 \\ 0\" by simp\n hence \"?B = 0 \\ ?B > 0\" by arith\n moreover\n { assume \"?B = 0\"\n moreover from b2pos have\n \"?B-b1^2 \\ 0 \\ ?B-b2^2 \\ 0 \\ ?B-b3^2 \\ 0 \\ ?B-b4^2 \\ 0\" by arith\n ultimately have \"b1^2 \\ 0 \\ b2^2 \\ 0 \\ b3^2 \\ 0 \\ b4^2 \\ 0\" by auto\n with b2pos have \"b1^2 = 0 \\ b2^2 = 0 \\ b3^2 = 0 \\ b4^2 = 0\" by arith\n hence \"b1 = 0 \\ b2 = 0 \\ b3 = 0 \\ b4 = 0\" by auto\n with bc_def have \"x dvd a1 \\ x dvd a2 \\ x dvd a3 \\ x dvd a4\"\n by auto\n hence \"x^2 dvd a1^2 \\ x^2 dvd a2^2 \\ x^2 dvd a3^2 \\ x^2 dvd a4^2\" by simp\n hence \"x^2 dvd a1^2+a2^2+a3^2+a4^2\" by (simp only: dvd_add)\n with ass have \"x^2 dvd p*x\" by (auto simp only: sum4sq_int_def)\n hence \"x*x dvd x*p\" by (simp only: power2_eq_square ac_simps)\n with ass have \"nat x dvd nat p\"\n by (simp add: nat_dvd_iff)\n moreover from ass prp have \"x \\ 0 \\ x \\ 1 \\ x \\ p \\ prime (nat p)\" by simp\n ultimately have \"False\" unfolding prime_nat_iff by auto }\n moreover\n { assume \"?B > 0\"\n with y have \"x*y > 0\" by simp\n moreover from ass have \"x > 0\" by simp\n ultimately have ?thesis using zero_less_mult_pos by blast }\n ultimately show ?thesis by auto\n qed\n moreover with y_l_x have \"(nat y) - 1 < (nat x) - 1\" by arith\n moreover from y_l_x ass have \"y < p\" by auto\n ultimately show ?thesis by blast\n qed\n thus \"\\ y. nat y - 1 < nat x - 1 \\ \\ \\ ?Q y\" by blast\n qed\n with Qt show \"False\" by simp\n qed\n thus \"is_sum4sq_int p\" by (auto simp add: is_sum4sq_int_def)\nqed\n\nprivate lemma prime_is_sum4sq: \"prime p \\ is_sum4sq_nat p\"\n using zprime_is_sum4sq is_sum4sq_int_nat_eq by simp\n\ntheorem sum_of_four_squares: \"is_sum4sq_nat n\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 28, "title": "019_four_squares_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2019 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nmodule\n\npublic import Mathlib.FieldTheory.Finite.Basic\n\n/-!\n# Lagrange's four square theorem\n\nThe main result in this file is `sum_four_squares`,\na proof that every natural number is the sum of four square numbers.\n\n## Implementation Notes\n\nThe proof used is close to Lagrange's original proof.\n-/\n\npublic section\n\n\nopen Finset Polynomial FiniteField Equiv\n\n/-- **Euler's four-square identity**. -/\ntheorem euler_four_squares {R : Type*} [CommRing R] (a b c d x y z w : R) :\n (a * x - b * y - c * z - d * w) ^ 2 + (a * y + b * x + c * w - d * z) ^ 2 +\n (a * z - b * w + c * x + d * y) ^ 2 + (a * w + b * z - c * y + d * x) ^ 2 =\n (a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2) * (x ^ 2 + y ^ 2 + z ^ 2 + w ^ 2) := by ring\n\n/-- **Euler's four-square identity**, a version for natural numbers. -/\ntheorem Nat.euler_four_squares (a b c d x y z w : ℕ) :\n ((a : ℤ) * x - b * y - c * z - d * w).natAbs ^ 2 +\n ((a : ℤ) * y + b * x + c * w - d * z).natAbs ^ 2 +\n ((a : ℤ) * z - b * w + c * x + d * y).natAbs ^ 2 +\n ((a : ℤ) * w + b * z - c * y + d * x).natAbs ^ 2 =\n (a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2) * (x ^ 2 + y ^ 2 + z ^ 2 + w ^ 2) := by sorry\nnamespace Int\n\ntheorem sq_add_sq_of_two_mul_sq_add_sq {m x y : ℤ} (h : 2 * m = x ^ 2 + y ^ 2) :\n m = ((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2 :=\n have : Even (x ^ 2 + y ^ 2) := by simp [← h]\n mul_right_injective₀ (show (2 * 2 : ℤ) ≠ 0 by decide) <|\n calc\n 2 * 2 * m = (x - y) ^ 2 + (x + y) ^ 2 := by rw [mul_assoc, h]; ring\n _ = (2 * ((x - y) / 2)) ^ 2 + (2 * ((x + y) / 2)) ^ 2 := by sorry\ntheorem lt_of_sum_four_squares_eq_mul {a b c d k m : ℕ}\n (h : a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = k * m)\n (ha : 2 * a < m) (hb : 2 * b < m) (hc : 2 * c < m) (hd : 2 * d < m) :\n k < m := by nlinarith\n\ntheorem exists_sq_add_sq_add_one_eq_mul (p : ℕ) [hp : Fact p.Prime] :\n ∃ (a b k : ℕ), 0 < k ∧ k < p ∧ a ^ 2 + b ^ 2 + 1 = k * p := by sorry\nend Int\n\nnamespace Nat\n\nopen Int\n\nprivate theorem sum_four_squares_of_two_mul_sum_four_squares {m a b c d : ℤ}\n (h : a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = 2 * m) :\n ∃ w x y z : ℤ, w ^ 2 + x ^ 2 + y ^ 2 + z ^ 2 = m := by sorry\ntheorem sum_four_squares (n : ℕ) : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n := by sorry\nend Nat\n" }, { "theorem_id": 28, "title": "019_four_squares_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import ZArith Lia Znumtheory.\nRequire Import Natsets MyNat Ztools Zeqm Znumfacts.\n\nDefinition foursquare (n : Z) : Type :=\n {a : _ & { b: _ & { c : _ & { d |\n n = a * a + b * b + c * c + d * d\n }}}}.\n\nLemma euler's_identity : forall a b c d w x y z : Z,\n let s z := z * z in\n (a * a + b * b + c * c + d * d) * (w * w + x * x + y * y + z * z) =\n s (a*w + b*x + c*y + d*z) +\n s (a*x - b*w - c*z + d*y) +\n s (a*y + b*z - c*w - d*x) +\n s (a*z - b*y + c*x - d*w).\nProof.\nAdmitted.\n\nLemma mult_foursquare_compat : forall n m : Z,\n foursquare n -> foursquare m -> foursquare (n * m)%Z.\nProof.\nAdmitted.\n\nLemma Zmod_sqrt_eq_compat : forall p i j, prime p ->\n (0 <= i -> 0 <= j -> 2 * i < p -> 2 * j < p ->\n i * i ≡ j * j [p] -> i = j)%Z.\nProof.\nAdmitted.\n\nLemma prime_odd : forall p, 2 <> p -> prime p -> p mod 2 = 1.\nProof.\nAdmitted.\n\nLemma odd_bound_1 : forall p i, p mod 2 = 1 -> i < Z.\nProof.\nAdmitted.\n\nDefinition modsym x m := (x + m / 2) mod m - m / 2.\n\nLemma modsym_bounds : forall x m, 0 < m -> - m <= 2 * modsym x m < m.\nProof.\nAdmitted.\n\nLemma modsym_mod_compat : forall x m, (modsym x m) mod m = x mod m.\nProof.\nAdmitted.\n\nLemma mod_modsym_compat : forall x m, modsym (x mod m) m = modsym x m.\nProof.\nAdmitted.\n\nLemma modsym_mod_diff : forall x m, 0 < m -> { k | modsym x m = x mod m + m * k }.\nProof.\nAdmitted.\n\nLemma modsym_eqm : forall x m, modsym x m ≡ x [ m ].\nProof.\nAdmitted.\n\nLemma prime_div_false : forall a p, prime p -> (a | p) -> 1 < a < p -> False.\nProof.\nAdmitted.\n\nLemma Zbounding_square : forall x m, 0 < m -> -m <= x <= m -> x ^ 2 <= m ^ 2.\nProof.\nAdmitted.\n\nLemma prime_dividing_sum_of_two_squares_plus_one : forall p,\n prime p -> 3 <= p ->\t\n {l : _ & {m : _ & { k |\n p * k = 1 + l * l + m * m /\\\n 2 * m < p /\\ 2 * l < p /\\ 0 < k /\\ 0 <= l /\\ 0 <= m /\\ (0 < l \\/ 0 < m)}}}.\nProof.\nAdmitted.\n\nLemma egality_case_sum_of_four : forall a b c d M,\n a <= M -> b <= M -> c <= M -> d <= M ->\n a + b + c + d = 4 * M -> ((a = M) /\\ (b = M)) /\\ ((c = M) /\\ (d = M)).\nProof.\nAdmitted.\n\nLemma square_bound_equality_case : forall a M,\n -M <= a < M -> M * M <= a * a -> a = - M.\nProof.\nAdmitted.\n\nLemma square_bound : forall x m, -m <= x <= m -> x * x <= m * m.\nProof.\nAdmitted.\n\nLemma square_bound_opp : forall x m, m <= x <= -m -> x * x <= m * m.\nProof.\nAdmitted.\n\nLemma egality_case_sum_of_four_squares : forall a b c d M,\n -M <= a < M -> -M <= b < M -> -M <= c < M -> -M <= d < M ->\n a * a + b * b + c * c + d * d = 4 * (M * M) ->\n ((a = -M) /\\ (b = -M)) /\\ ((c = -M) /\\ (d = -M)).\nProof.\nAdmitted.\n\nLemma foursquare_prime_factor_decreasing :\n forall p, prime p -> forall m, (1 < m /\\ m < p)%Z ->\n foursquare (m * p) ->\n sigT (fun n => ((0 < n /\\ n < m)%Z * foursquare (n * p))%type).\nProof.\nAdmitted.\n\nDefinition lt_wf_rect :=\n fun p (P : nat -> Type) F =>\n well_founded_induction_type\n (well_founded_ltof nat (fun m => m)) P F p.\n\nLemma foursquare_prime : forall p, prime p -> foursquare p.\nProof.\nAdmitted.\n\nTheorem lagrange_4_square_theorem : forall n, 0 <= n -> foursquare n.\nProof.\nAdmitted.\n\nDefinition lagrange_fun (n : Z) : (Z * Z) * (Z * Z) :=\n let (a, ha) := lagrange_4_square_theorem (Z.abs n) (Zabs_pos n) in\n let (b, hb) := ha in\n let (c, hc) := hb in\n let (d, _ ) := hc in\n ((a, b), (c, d)).\n\nLemma lagrange_fun_spec (n : Z) :\n (let (ab, cd) := lagrange_fun n in let (a, b) := ab in let (c, d) := cd in\n Z.\nProof.\nAdmitted." }, { "theorem_id": 29, "title": "022_the_non-denumerability_of_the_continuum", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/card.ml\";;\n\nprioritize_real();;\n\nlet countable = new_definition\n `countable s <=> s <=_c (UNIV:num->bool)`;;\n\nlet repeating = new_definition\n `repeating = {s:num->bool | ?n. !m. m >= n ==> s m}`;;\n\nlet BINARY_BOUND = `!n. nsum(0..n) (\\i. if b(i) then 2 EXP i else 0) < 2 EXP (n + 1)`;;\n\nlet BINARY_DIV_POW2 = `!n. (nsum(0..n) (\\i. if b(i) then 2 EXP i else 0)) DIV (2 EXP (SUC n)) = 0`;;\n\nlet PLUS_MOD_REFL = `!a b. ~(b = 0) ==> (a + b) MOD b = a MOD b`;;\n\nlet BINARY_PLUS_DIV_POW2 = `!n. (nsum(0..n) (\\i. if b(i) then 2 EXP i else 0) + 2 EXP (SUC n))\n DIV (2 EXP (SUC n)) = 1`;;\n\nlet BINARY_UNIQUE_LEMMA = `!n. nsum(0..n) (\\i. if b(i) then 2 EXP i else 0) =\n nsum(0..n) (\\i. if c(i) then 2 EXP i else 0)\n ==> !i. i <= n ==> (b(i) <=> c(i))`;;\n\nlet COUNTABLE_REPEATING = `countable repeating`;;\n\nlet canonical = new_definition\n `canonical = {s:num->bool | !n. ?m. m >= n /\\ ~(s m)}`;;\n\nlet UNCOUNTABLE_CANONICAL = `~countable canonical`;;\n\nneeds \"Library/analysis.ml\";;\n\nprioritize_real();;\n\nlet SUM_BINSEQUENCE_LBOUND = `!m n. &0 <= sum(m,n) (\\i. if s(i) then inv(&2 pow i) else &0)`;;\n\nlet SUM_BINSEQUENCE_UBOUND_SHARP = `!s m n. sum(m,n) (\\i. if s(i) then inv(&2 pow i) else &0)\n <= &2 / &2 pow m - &2 / &2 pow (m + n)`;;\n\nlet SUMMABLE_BINSEQUENCE = `!s. summable (\\i. if s(i) then inv(&2 pow i) else &0)`;;\n\nlet SUMS_BINSEQUENCE = `!s. (\\i. if s(i) then inv(&2 pow i) else &0) sums\n (suminf (\\i. if s(i) then inv(&2 pow i) else &0))`;;\n\nlet SUM_BINSEQUENCE_UBOUND_LE = `!s m n. sum(m,n) (\\i. if s(i) then inv(&2 pow i) else &0) <= &2 / &2 pow m`;;\n\nlet SUMINF_INJ_LEMMA = `!s t n. ~(s n) /\\ t n /\\\n (!m. m < n ==> (s(m) <=> t(m))) /\\\n (!n. ?m. m >= n /\\ ~(s m))\n ==> suminf(\\n. if s n then inv (&2 pow n) else &0)\n < suminf(\\n. if t n then inv (&2 pow n) else &0)`;;\n\nlet UNCOUNTABLE_REALS = `~countable(UNIV:real->bool)`;;" }, { "theorem_id": 29, "title": "022_the_non-denumerability_of_the_continuum", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Non-Denumerability of the Continuum\\\n\ntheory Continuum_Not_Denumerable\nimports\n Complex_Main \n \"HOL-Library.Countable_Set\"\nbegin\n\nsubsection\\<^marker>\\tag unimportant\\ \\Abstract\\\n\ntext \\\n The following document presents a proof that the Continuum is uncountable.\n It is formalised in the Isabelle/Isar theorem proving system.\n\n \\<^bold>\\Theorem:\\ The Continuum \\\\\\ is not denumerable. In other words, there does\n not exist a function \\f: \\ \\ \\\\ such that \\f\\ is surjective.\n\n \\<^bold>\\Outline:\\ An elegant informal proof of this result uses Cantor's\n Diagonalisation argument. The proof presented here is not this one.\n\n First we formalise some properties of closed intervals, then we prove the\n Nested Interval Property. This property relies on the completeness of the\n Real numbers and is the foundation for our argument. Informally it states\n that an intersection of countable closed intervals (where each successive\n interval is a subset of the last) is non-empty. We then assume a surjective\n function \\f: \\ \\ \\\\ exists and find a real \\x\\ such that \\x\\ is not in the\n range of \\f\\ by generating a sequence of closed intervals then using the\n Nested Interval Property.\n\\\ntext\\<^marker>\\tag important\\ \\%whitespace\\\ntheorem real_non_denum: \"\\f :: nat \\ real. surj f\"\n by sorry\n\nlemma uncountable_UNIV_real: \"uncountable (UNIV :: real set)\"\n by sorry\n\ncorollary complex_non_denum: \"\\f :: nat \\ complex. surj f\"\n by sorry\n\nlemma uncountable_UNIV_complex: \"uncountable (UNIV :: complex set)\"\n by sorry\n\nlemma bij_betw_open_intervals:\n fixes a b c d :: real\n assumes \"a < b\" \"c < d\"\n shows \"\\f. bij_betw f {a<.. a < b\" for a b :: real\n by sorry\n\nlemma uncountable_half_open_interval_1: \"uncountable {a.. a < b\" for a b :: real\n by sorry\n\nlemma uncountable_half_open_interval_2: \"uncountable {a<..b} \\ a < b\" for a b :: real\n by sorry\n\nlemma real_interval_avoid_countable_set:\n fixes a b :: real and A :: \"real set\"\n assumes \"a < b\" and \"countable A\"\n shows \"\\x\\{a<.. A\"\n by sorry\n\nlemma uncountable_closed_interval: \"uncountable {a..b} \\ a < b\" for a b :: real\n by sorry\n\nlemma open_minus_countable:\n fixes S A :: \"real set\"\n assumes \"countable A\" \"S \\ {}\" \"open S\"\n shows \"\\x\\S. x \\ A\"\n by sorry\n\nend" }, { "theorem_id": 29, "title": "022_the_non-denumerability_of_the_continuum", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2019 Floris van Doorn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Floris van Doorn\n-/\nmodule\n\npublic import Mathlib.Algebra.Order.Group.Pointwise.Interval\npublic import Mathlib.Analysis.SpecificLimits.Basic\npublic import Mathlib.Data.Rat.Cardinal\npublic import Mathlib.SetTheory.Cardinal.Continuum\n\n/-!\n# The cardinality of the reals\n\nThis file shows that the real numbers have cardinality continuum, i.e. `#ℝ = 𝔠`.\n\nWe show that `#ℝ ≤ 𝔠` by noting that every real number is determined by a Cauchy-sequence of the\nform `ℕ → ℚ`, which has cardinality `𝔠`. To show that `#ℝ ≥ 𝔠` we define an injection from\n`{0, 1} ^ ℕ` to `ℝ` with `f ↦ Σ n, f n * (1 / 3) ^ n`.\n\nWe conclude that all intervals with distinct endpoints have cardinality continuum.\n\n## Main definitions\n\n* `Cardinal.cantorFunction` is the function that sends `f` in `{0, 1} ^ ℕ` to `ℝ` by\n `f ↦ Σ' n, f n * (1 / 3) ^ n`\n\n## Main statements\n\n* `Cardinal.mk_real : #ℝ = 𝔠`: the reals have cardinality continuum.\n* `Cardinal.not_countable_real`: the universal set of real numbers is not countable.\n We can use this same proof to show that all the other sets in this file are not countable.\n* 8 lemmas of the form `mk_Ixy_real` for `x,y ∈ {i,o,c}` state that intervals on the reals\n have cardinality continuum.\n\n## Notation\n\n* `𝔠` : notation for `Cardinal.continuum` in scope `Cardinal`, defined in `SetTheory.Continuum`.\n\n## Tags\ncontinuum, cardinality, reals, cardinality of the reals\n-/\n\n@[expose] public section\n\n\nopen Nat Set\n\nopen Cardinal\n\nnoncomputable section\n\nnamespace Cardinal\n\nvariable {c : ℝ} {f g : ℕ → Bool} {n : ℕ}\n\n/-- The body of the sum in `cantorFunction`.\n`cantorFunctionAux c f n = c ^ n` if `f n = true`;\n`cantorFunctionAux c f n = 0` if `f n = false`. -/\ndef cantorFunctionAux (c : ℝ) (f : ℕ → Bool) (n : ℕ) : ℝ :=\n cond (f n) (c ^ n) 0\n\n@[simp]\ntheorem cantorFunctionAux_true (h : f n = true) : cantorFunctionAux c f n = c ^ n := by sorry\ntheorem cantorFunctionAux_false (h : f n = false) : cantorFunctionAux c f n = 0 := by sorry\ntheorem cantorFunctionAux_nonneg (h : 0 ≤ c) : 0 ≤ cantorFunctionAux c f n := by sorry\ntheorem cantorFunctionAux_eq (h : f n = g n) :\n cantorFunctionAux c f n = cantorFunctionAux c g n := by simp [cantorFunctionAux, h]\n\ntheorem cantorFunctionAux_zero (f : ℕ → Bool) : cantorFunctionAux c f 0 = cond (f 0) 1 0 := by sorry\ntheorem cantorFunctionAux_succ (f : ℕ → Bool) :\n (fun n => cantorFunctionAux c f (n + 1)) = fun n =>\n c * cantorFunctionAux c (fun n => f (n + 1)) n := by sorry\ntheorem summable_cantor_function (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) :\n Summable (cantorFunctionAux c f) := by sorry\ndef cantorFunction (c : ℝ) (f : ℕ → Bool) : ℝ :=\n ∑' n, cantorFunctionAux c f n\n\ntheorem cantorFunction_le (h1 : 0 ≤ c) (h2 : c < 1) (h3 : ∀ n, f n → g n) :\n cantorFunction c f ≤ cantorFunction c g := by sorry\ntheorem cantorFunction_succ (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) :\n cantorFunction c f = cond (f 0) 1 0 + c * cantorFunction c fun n => f (n + 1) := by sorry\ntheorem increasing_cantorFunction (h1 : 0 < c) (h2 : c < 1 / 2) {n : ℕ} {f g : ℕ → Bool}\n (hn : ∀ k < n, f k = g k) (fn : f n = false) (gn : g n = true) :\n cantorFunction c f < cantorFunction c g := by sorry\ntheorem cantorFunction_injective (h1 : 0 < c) (h2 : c < 1 / 2) :\n Function.Injective (cantorFunction c) := by sorry\ntheorem mk_real : #ℝ = 𝔠 := by sorry\ntheorem mk_univ_real : #(Set.univ : Set ℝ) = 𝔠 := by rw [mk_univ, mk_real]\n\n/-- **Non-Denumerability of the Continuum**: The reals are not countable. -/\ninstance : Uncountable ℝ := by sorry\ntheorem not_countable_real : ¬(Set.univ : Set ℝ).Countable :=\n not_countable_univ\n\n/-- The cardinality of the interval $(a, ∞)$. -/\ntheorem mk_Ioi_real (a : ℝ) : #(Ioi a) = 𝔠 := by sorry\ntheorem mk_Ici_real (a : ℝ) : #(Ici a) = 𝔠 :=\n le_antisymm (mk_real ▸ mk_set_le _) (mk_Ioi_real a ▸ mk_le_mk_of_subset Ioi_subset_Ici_self)\n\n/-- The cardinality of the interval $(-∞, a)$. -/\ntheorem mk_Iio_real (a : ℝ) : #(Iio a) = 𝔠 := by sorry\ntheorem mk_Iic_real (a : ℝ) : #(Iic a) = 𝔠 :=\n le_antisymm (mk_real ▸ mk_set_le _) (mk_Iio_real a ▸ mk_le_mk_of_subset Iio_subset_Iic_self)\n\n/-- The cardinality of the interval $(a, b)$. -/\ntheorem mk_Ioo_real {a b : ℝ} (h : a < b) : #(Ioo a b) = 𝔠 := by sorry\ntheorem mk_Ico_real {a b : ℝ} (h : a < b) : #(Ico a b) = 𝔠 :=\n le_antisymm (mk_real ▸ mk_set_le _) (mk_Ioo_real h ▸ mk_le_mk_of_subset Ioo_subset_Ico_self)\n\n/-- The cardinality of the interval $[a, b]$. -/\ntheorem mk_Icc_real {a b : ℝ} (h : a < b) : #(Icc a b) = 𝔠 :=\n le_antisymm (mk_real ▸ mk_set_le _) (mk_Ioo_real h ▸ mk_le_mk_of_subset Ioo_subset_Icc_self)\n\n/-- The cardinality of the interval $(a, b]$. -/\ntheorem mk_Ioc_real {a b : ℝ} (h : a < b) : #(Ioc a b) = 𝔠 :=\n le_antisymm (mk_real ▸ mk_set_le _) (mk_Ioo_real h ▸ mk_le_mk_of_subset Ioo_subset_Ioc_self)\n\n@[simp]\nlemma Real.Ioo_countable_iff {x y : ℝ} :\n (Ioo x y).Countable ↔ y ≤ x := by sorry\nlemma Real.Ico_countable_iff {x y : ℝ} :\n (Ico x y).Countable ↔ y ≤ x := by sorry\nlemma Real.Ioc_countable_iff {x y : ℝ} :\n (Ioc x y).Countable ↔ y ≤ x := by sorry\nlemma Real.Icc_countable_iff {x y : ℝ} :\n (Icc x y).Countable ↔ y ≤ x := by sorry\nend Cardinal\n" }, { "theorem_id": 29, "title": "022_the_non-denumerability_of_the_continuum", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Lra.\n\nOpen Scope R_scope.\n\nLemma epsilon_2 : forall x, 0 < x -> x / 2 < x.\nProof.\nAdmitted.\n\nLemma Rabs_include :\n forall x y u v, x <= u <= y -> x <= v <= y -> Rabs (u - v) <= Rabs (x - y).\nProof.\nAdmitted.\n\nLemma Rabs_max : forall x y d, Rabs (x - y) <= d -> x <= y + d.\nProof.\nAdmitted.\n\nLemma Rabs_min : forall x y d, Rabs (x - y) <= d -> x - d <= y.\nProof.\nAdmitted.\n\nSection middle_facts.\n\nDefinition middle (x y : R) := (x + y) / 2.\n\nVariables x y x' y': R.\n\nLemma Rlt_middle_r : x < y -> (middle x y) < y.\nProof.\nAdmitted.\n\nLemma Rlt_middle_l : x < y -> x < middle x y.\nProof.\nAdmitted.\n\nLemma middle_sym : middle x y = middle y x.\nProof.\nAdmitted.\n\nLemma middle_minus : x - (middle x y) = (x - y) / 2.\nProof.\nAdmitted.\n\nLemma middle_dist : R_dist x (middle x y) = (R_dist x y) / 2.\nProof.\nAdmitted.\n\nEnd middle_facts.\n\nSection succ_facts.\n\nDefinition succ x y k :=\n let m := middle x y in\n let loc := total_order_T m k in\n match loc with\n | inleft (left _) => (x, m)\n | inleft (right _) => (x, middle x m)\n | inright _ => (m, y)\n end\n.\n\nVariable x y k : R.\nHypothesis H : x < y.\n\nLemma succ_compat : fst (succ x y k) < snd (succ x y k).\nProof.\nAdmitted.\n\nLemma succ_not_in : ~ (fst (succ x y k) <= k <= snd (succ x y k)).\nProof.\nAdmitted.\n\nLemma succ_included_l : x <= fst (succ x y k).\nProof.\nAdmitted.\n\nLemma succ_included_r : snd (succ x y k) <= y.\nProof.\nAdmitted.\n\nLemma succ_dist : R_dist (fst (succ x y k)) (snd (succ x y k)) <= (R_dist x y) / 2.\nProof.\nAdmitted.\n\nEnd succ_facts.\n\nSection CantorDiagonal.\n\nVariable lb ub : R.\nHypothesis not_empty : lb < ub. \nVariable f : nat -> R.\n\nDefinition Rn n := f n.\n\nFixpoint Dn n {struct n} :=\n match n with\n | O => succ lb ub (Rn O)\n | S m =>\n succ (fst (Dn m)) (snd (Dn m)) (Rn n)\n end\n.\n\nLemma non_zero_dist : R_dist lb ub > 0.\nProof.\nAdmitted.\n\nLemma diagonal_compat : forall n, fst (Dn n) < snd (Dn n).\nProof.\nAdmitted.\n\nLemma diagonal_included_l : forall n p, (n <= p)%nat -> fst (Dn n) <= fst (Dn p).\nProof.\nAdmitted.\n\nLemma diagonal_included_r : forall n p, (n <= p)%nat -> snd (Dn p) <= snd (Dn n).\nProof.\nAdmitted.\n\nLemma diagonal_dist : forall n, R_dist (fst (Dn n)) (snd (Dn n)) <= (R_dist lb ub) * ((/2) ^ (S n)).\nProof.\nAdmitted.\n\nLemma diagonal_not_in : forall n p, (n <= p)%nat -> ~ (fst (Dn p) <= Rn n <= snd (Dn p)).\nProof.\nAdmitted.\n\nDefinition Ln n := middle (fst (Dn n)) (snd (Dn n)).\n\nLemma sequence_bound : forall n p, (n <= p)%nat -> (fst (Dn n)) <= Ln p <= (snd (Dn n)).\nProof.\nAdmitted.\n\nLemma sequence_cauchy : forall n p q, (p >= n)%nat -> (q >= n)%nat -> R_dist (Ln p) (Ln q) < (R_dist lb ub) * (/2) ^ n.\nProof.\nAdmitted.\n\nLemma sequence_cauchy_crit : Cauchy_crit Ln.\nProof.\nAdmitted.\n\nLemma sequence_cv : { l : R | Un_cv Ln l }.\nProof.\nAdmitted.\n\nDefinition l := proj1_sig sequence_cv.\nDefinition l_is_limit := proj2_sig sequence_cv.\n\nLemma l_in_Dn : forall n, fst (Dn n) <= l <= snd (Dn n).\nProof.\nAdmitted.\n\nLemma l_not_in_Rn : forall n, ~(Rn n = l).\nProof.\nAdmitted.\n\nLemma l_in_segment : lb <= l <= ub.\nProof.\nAdmitted.\n\nLemma segment_uncountable : { l | forall n, l <> Rn n }.\nProof.\nAdmitted.\n\nEnd CantorDiagonal.\n\nTheorem R_uncountable_strong :\n forall (f : nat -> R) (x y : R), x < y -> {l : R | forall n, l <> f n & x <= l <= y}.\nProof.\nAdmitted.\n\nTheorem R_uncountable : forall (f : nat -> R), {l : R | forall n, l <> f n}.\nProof.\nAdmitted." }, { "theorem_id": 30, "title": "025_schroeder-bernstein_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "let CANTOR_THM_INJ = `~(?f:(A->bool)->A. (!x y. f(x) = f(y) ==> x = y))`;;\n\nlet CANTOR_THM_SURJ = `~(?f:A->(A->bool). !s. ?x. f x = s)`;;\n\nlet CANTOR = `!s:A->bool. s <_c {t | t SUBSET s}`;;\n\nlet CANTOR_THM_INJ' = `~(?f:(A->bool)->A. (!x y. f(x) = f(y) ==> x = y))`;;\n\nlet CANTOR_LAWVERE = `!h:A->(A->B).\n (!f:A->B. ?x:A. h(x) = f) ==> !n:B->B. ?x. n(x) = x`;;\n\nlet CANTOR = `!f:A->(A->bool). ~(!s. ?x. f x = s)`;;\n\nlet CANTOR_TAYLOR = `!f:(A->bool)->A. ~(!x y. f(x) = f(y) ==> x = y)`;;\n\nlet SURJECTIVE_COMPOSE = `(!y. ?x. f(x) = y) /\\ (!z. ?y. g(y) = z)\n ==> (!z. ?x. (g o f) x = z)`;;\n\nlet INJECTIVE_SURJECTIVE_PREIMAGE = `!f:A->B. (!x y. f(x) = f(y) ==> x = y) ==> !t. ?s. {x | f(x) IN s} = t`;;\n\nlet CANTOR_JOHNSTONE = `!i:B->S f:B->S->bool.\n ~((!x y. i(x) = i(y) ==> x = y) /\\ (!s. ?z. f(z) = s))`;;" }, { "theorem_id": 30, "title": "025_schroeder-bernstein_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Cardinality of Equivalence Relations\\\n\ntheory Card_Equiv_Relations\nimports\n Card_Partitions.Card_Partitions\n Bell_Numbers_Spivey.Bell_Numbers\nbegin\n\nsubsection \\Bijection between Equivalence Relations and Set Partitions\\\n\nsubsubsection \\Possibly Interesting Theorem for @{theory HOL.Equiv_Relations}\\\n\ntext \\This theorem was historically useful in this theory, but\nis now after some proof refactoring not needed here anymore.\nPossibly it is an interesting fact about equivalence relations, though.\n\\\n\nlemma equiv_quotient_eq_quotient_on_UNIV:\n assumes \"equiv A R\"\n shows \"A // R = (UNIV // R) - {{}}\"\n by sorry\n\nsubsubsection \\Dedicated Facts for Bijection Proof\\\n\nlemma equiv_relation_of_partition_of:\n assumes \"equiv A R\"\n shows \"{(x, y). \\X\\A // R. x \\ X \\ y \\ X} = R\"\n by sorry\n\nsubsubsection \\Bijection Proof\\\n\nlemma bij_betw_partition_of:\n \"bij_betw (\\R. A // R) {R. equiv A R} {P. partition_on A P}\"\n by sorry\n\nlemma bij_betw_partition_of_equiv_with_k_classes:\n \"bij_betw (\\R. A // R) {R. equiv A R \\ card (A // R) = k} {P. partition_on A P \\ card P = k}\"\n by sorry\n\nsubsection \\Finiteness of Equivalence Relations\\\n\nlemma finite_equiv:\n assumes \"finite A\"\n shows \"finite {R. equiv A R}\"\n by sorry\n\nsubsection \\Cardinality of Equivalence Relations\\\n\ntheorem card_equiv_rel_eq_card_partitions:\n \"card {R. equiv A R} = card {P. partition_on A P}\"\n by sorry\n\ncorollary card_equiv_rel_eq_Bell:\n assumes \"finite A\"\n shows \"card {R. equiv A R} = Bell (card A)\"\n by sorry\n\ncorollary card_equiv_rel_eq_sum_Stirling:\n assumes \"finite A\"\n shows \"card {R. equiv A R} = sum (Stirling (card A)) {..card A}\"\n by sorry\n\ntheorem card_equiv_k_classes_eq_card_partitions_k_parts:\n \"card {R. equiv A R \\ card (A // R) = k} = card {P. partition_on A P \\ card P = k}\"\n by sorry\n\ncorollary\n assumes \"finite A\"\n shows \"card {R. equiv A R \\ card (A // R) = k} = Stirling (card A) k\"\n by sorry\n\nend" }, { "theorem_id": 30, "title": "025_schroeder-bernstein_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nmodule\n\npublic import Mathlib.Data.Set.Piecewise\npublic import Mathlib.Order.FixedPoints\npublic import Mathlib.Order.Zorn\n\n/-!\n# Schröder-Bernstein theorem, well-ordering of cardinals\n\nThis file proves the Schröder-Bernstein theorem (see `schroeder_bernstein`), the well-ordering of\ncardinals (see `min_injective`) and the totality of their order (see `total`).\n\n## Notes\n\nCardinals are naturally ordered by `α ≤ β ↔ ∃ f : a → β, Injective f`:\n* `schroeder_bernstein` states that, given injections `α → β` and `β → α`, one can get a\n bijection `α → β`. This corresponds to the antisymmetry of the order.\n* The order is also well-founded: any nonempty set of cardinals has a minimal element.\n `min_injective` states that by saying that there exists an element of the set that injects into\n all others.\n\nCardinals are defined and further developed in the folder `SetTheory.Cardinal`.\n-/\n\npublic section\n\n\nopen Set Function\n\nuniverse u v\n\nnamespace Function\n\nnamespace Embedding\n\nsection antisymm\n\nvariable {α : Type u} {β : Type v}\n\n/-- **The Schröder-Bernstein Theorem**:\nGiven injections `α → β` and `β → α` that satisfy a pointwise property `R`, we can get a bijection\n`α → β` that satisfies that same pointwise property. -/\ntheorem schroeder_bernstein_of_rel {f : α → β} {g : β → α} (hf : Function.Injective f)\n (hg : Function.Injective g) (R : α → β → Prop) (hp₁ : ∀ a : α, R a (f a))\n (hp₂ : ∀ b : β, R (g b) b) :\n ∃ h : α → β, Bijective h ∧ ∀ a : α, R a (h a) := by sorry\ntheorem schroeder_bernstein {f : α → β} {g : β → α} (hf : Function.Injective f)\n (hg : Function.Injective g) : ∃ h : α → β, Bijective h := by sorry\ntheorem antisymm : (α ↪ β) → (β ↪ α) → Nonempty (α ≃ β) := by sorry\nend antisymm\n\nsection Wo\n\nvariable {ι : Type u} (β : ι → Type v)\n\n/-- `sets β` -/\nprivate abbrev sets :=\n { s : Set (∀ i, β i) | ∀ i : ι, s.InjOn fun x => x i }\n\n/-- The cardinals are well-ordered. We express it here by the fact that in any set of cardinals\nthere is an element that injects into the others.\nSee `Cardinal.conditionallyCompleteLinearOrderBot` for (one of) the lattice instances. -/\ntheorem min_injective [I : Nonempty ι] : ∃ i, Nonempty (∀ j, β i ↪ β j) :=\n let ⟨s, hs⟩ := show ∃ s, Maximal (· ∈ sets β) s by\n refine zorn_subset _ fun c hc hcc ↦\n ⟨⋃₀ c, fun i x ⟨p, hpc, hxp⟩ y ⟨q, hqc, hyq⟩ hi ↦ ?_, fun _ ↦ subset_sUnion_of_mem⟩\n exact (hcc.total hpc hqc).elim (fun h ↦ hc hqc i (h hxp) hyq hi)\n fun h ↦ hc hpc i hxp (h hyq) hi\n let ⟨i, e⟩ :=\n show ∃ i, Surjective fun x : s => x.val i from\n Classical.by_contradiction fun h =>\n have h : ∀ i, ∃ y, ∀ x ∈ s, (x : ∀ i, β i) i ≠ y := by sorry\nend Wo\n\n/-- The cardinals are totally ordered. See\n`Cardinal.conditionallyCompleteLinearOrderBot` for (one of) the lattice\ninstance. -/\ntheorem total (α : Type u) (β : Type v) : Nonempty (α ↪ β) ∨ Nonempty (β ↪ α) :=\n match @min_injective Bool (fun b => cond b (ULift α) (ULift.{max u v, v} β)) ⟨true⟩\n with := by sorry\nend Embedding\n\nend Function\n" }, { "theorem_id": 30, "title": "025_schroeder-bernstein_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Ensembles. \nRequire Import Relations_1. \nRequire Import Powerset. \nRequire Import Classical_Prop. \n\nRequire Import Setminus_fact.\nRequire Import Sums.\nRequire Import Functions.\nRequire Import Equipollence.\n\nSection Schroeder_Bernstein.\n\nDefinition in_or_not_in (U : Type) (x : U) (A : Ensemble U) :=\n classic (In U A x).\n\nVariable U : Type.\n\nLet SU := Ensemble U.\n\nVariable A B : SU. \n\n Section Bijection.\n\n Variable f g : Relation U. \n\n Hypothesis f_inj : injection U A B f. \n Hypothesis g_inj : injection U B A g.\n\n Let Imf : Ensemble U -> Ensemble U := Im U f.\n Let Img : Ensemble U -> Ensemble U := Im U g.\n\n Let F (C : SU) := Setminus U A (Img (Setminus U B (Imf C))).\n\n Let D (C : SU) := Included U C (F C).\n\n Let J := Set_Sum U D.\n\n Lemma F_growing :\n forall C C' : SU, Included U C C' -> Included U (F C) (F C').\nProof.\nAdmitted.\n\n End Bijection.\n\nTheorem Schroeder : A <=_card B -> B <=_card A -> A =_card B.\nProof.\nAdmitted.\n\nEnd Schroeder_Bernstein." }, { "theorem_id": 31, "title": "026_leibniz_s_series_for_pi", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/transc.ml\";;\n\nprioritize_real();;\n\nlet ALTERNATING_SUM_BOUNDS = `!a. (!n. a(2 * n + 1) <= &0 /\\ &0 <= a(2 * n)) /\\\n (!n. abs(a(n + 1)) <= abs(a(n)))\n ==> !m n. (EVEN m ==> &0 <= sum(m,n) a /\\ sum(m,n) a <= a(m)) /\\\n (ODD m ==> a(m) <= sum(m,n) a /\\ sum(m,n) a <= &0)`;;\n\nlet ALTERNATING_SUM_BOUND = `!a. (!n. a(2 * n + 1) <= &0 /\\ &0 <= a(2 * n)) /\\\n (!n. abs(a(n + 1)) <= abs(a(n)))\n ==> !m n. abs(sum(m,n) a) <= abs(a m)`;;\n\nlet SUMMABLE_ALTERNATING = `!v. (!n. a(2 * n + 1) <= &0 /\\ &0 <= a(2 * n)) /\\\n (!n. abs(a(n + 1)) <= abs(a(n))) /\\ a tends_num_real &0\n ==> summable a`;;\n\nlet REAL_ATN_POWSER_ALT = `!x. abs(x) < &1\n ==> (\\n. (-- &1) pow n / &(2 * n + 1) * x pow (2 * n + 1))\n sums (atn x)`;;\n\nlet SUMMABLE_LEIBNIZ = `summable (\\n. (-- &1) pow n / &(2 * n + 1))`;;\n\nlet SUM_DIFFERENCES = `!a m n. m <= n + 1 ==> sum(m..n) (\\i. a(i) - a(i+1)) = a(m) - a(n + 1)`;;\n\nlet SUM_REARRANGE_LEMMA = `!a v m n.\n m <= n + 1\n ==> sum(m..n+1) (\\i. a i * v i) =\n sum(m..n) (\\k. sum(m..k) a * (v(k) - v(k+1))) +\n sum(m..n+1) a * v(n+1)`;;\n\nlet SUM_BOUNDS_LEMMA = `!a v l u m n.\n m <= n /\\\n (!i. m <= i /\\ i <= n ==> &0 <= v(i) /\\ v(i+1) <= v(i)) /\\\n (!k. m <= k /\\ k <= n ==> l <= sum(m..k) a /\\ sum(m..k) a <= u)\n ==> l * v(m) <= sum(m..n) (\\i. a(i) * v(i)) /\\\n sum(m..n) (\\i. a(i) * v(i)) <= u * v(m)`;;\n\nlet SUM_BOUND_LEMMA = `!a v b m n.\n m <= n /\\\n (!i. m <= i /\\ i <= n ==> &0 <= v(i) /\\ v(i+1) <= v(i)) /\\\n (!k. m <= k /\\ k <= n ==> abs(sum(m..k) a) <= b)\n ==> abs(sum(m..n) (\\i. a(i) * v(i))) <= b * abs(v m)`;;\n\nlet LEIBNIZ_PI = `(\\n. (-- &1) pow n / &(2 * n + 1)) sums (pi / &4)`;;" }, { "theorem_id": 31, "title": "026_leibniz_s_series_for_pi", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Complex Transcendental Functions\\\n\ntext\\By John Harrison et al. Ported from HOL Light by L C Paulson (2015)\\\n\ntheory Complex_Transcendental\nimports\n Complex_Analysis_Basics Summation_Tests \"HOL-Library.Periodic_Fun\"\nbegin\n\nsubsection\\Möbius transformations\\\n\ndefinition\\<^marker>\\tag important\\ \"moebius a b c d \\ (\\z. (a*z+b) / (c*z+d :: 'a :: field))\"\n\ntheorem moebius_inverse:\n assumes \"a * d \\ b * c\" \"c * z + d \\ 0\"\n shows \"moebius d (-b) (-c) a (moebius a b c d z) = z\"\n by sorry\n\nlemma moebius_inverse':\n assumes \"a * d \\ b * c\" \"c * z - a \\ 0\"\n shows \"moebius a b c d (moebius d (-b) (-c) a z) = z\"\n by sorry\n\nlemma cmod_add_real_less:\n assumes \"Im z \\ 0\" \"r\\0\"\n shows \"cmod (z + r) < cmod z + \\r\\\"\n by sorry\n\nlemma cmod_diff_real_less: \"Im z \\ 0 \\ x\\0 \\ cmod (z - x) < cmod z + \\x\\\"\n by sorry\n\nlemma cmod_square_less_1_plus:\n assumes \"Im z = 0 \\ \\Re z\\ < 1\"\n shows \"(cmod z)\\<^sup>2 < 1 + cmod (1 - z\\<^sup>2)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\The Exponential Function\\\n\nlemma exp_npi_numeral: \"exp (\\ * pi * Num.numeral n) = (-1) ^ Num.numeral n\"\n by sorry\n\nlemma norm_exp_i_times [simp]: \"norm (exp(\\ * of_real y)) = 1\"\n by sorry\n\nlemma norm_exp_imaginary: \"norm(exp z) = 1 \\ Re z = 0\"\n by sorry\n\nlemma field_differentiable_within_exp: \"exp field_differentiable (at z within s)\"\n by sorry\n\nlemma continuous_within_exp:\n fixes z::\"'a::{real_normed_field,banach}\"\n shows \"continuous (at z within s) exp\"\n by sorry\n\nlemma holomorphic_on_exp [holomorphic_intros]: \"exp holomorphic_on s\"\n by sorry\n\nlemma holomorphic_on_exp' [holomorphic_intros]:\n \"f holomorphic_on s \\ (\\x. exp (f x)) holomorphic_on s\"\n by sorry\n\nlemma exp_analytic_on [analytic_intros]:\n assumes \"f analytic_on A\"\n shows \"(\\z. exp (f z)) analytic_on A\"\n by sorry\n\nlemma\n assumes \"\\w. w \\ A \\ exp (f w) = w\"\n assumes \"f holomorphic_on A\" \"z \\ A\" \"open A\"\n shows deriv_complex_logarithm: \"deriv f z = 1 / z\"\n and has_field_derivative_complex_logarithm: \"(f has_field_derivative 1 / z) (at z)\"\n by sorry\n \nsubsection\\Euler and de Moivre formulas\\\n\ntext\\The sine series times \\<^term>\\i\\\\\nlemma sin_i_eq: \"(\\n. (\\ * sin_coeff n) * z^n) sums (\\ * sin z)\"\n by sorry\n\ntheorem exp_Euler: \"exp(\\ * z) = cos(z) + \\ * sin(z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ exp_minus_Euler: \"exp(-(\\ * z)) = cos(z) - \\ * sin(z)\"\n by sorry\n\nlemma sin_exp_eq: \"sin z = (exp(\\ * z) - exp(-(\\ * z))) / (2*\\)\"\n by sorry\n\nlemma sin_exp_eq': \"sin z = \\ * (exp(-(\\ * z)) - exp(\\ * z)) / 2\"\n by sorry\n\nlemma cos_exp_eq: \"cos z = (exp(\\ * z) + exp(-(\\ * z))) / 2\"\n by sorry\n\ntheorem Euler: \"exp(z) = of_real(exp(Re z)) *\n (of_real(cos(Im z)) + \\ * of_real(sin(Im z)))\"\n by sorry\n\nlemma Re_sin: \"Re(sin z) = sin(Re z) * (exp(Im z) + exp(-(Im z))) / 2\"\n by sorry\n\nlemma Im_sin: \"Im(sin z) = cos(Re z) * (exp(Im z) - exp(-(Im z))) / 2\"\n by sorry\n\nlemma Re_cos: \"Re(cos z) = cos(Re z) * (exp(Im z) + exp(-(Im z))) / 2\"\n by sorry\n\nlemma Im_cos: \"Im(cos z) = sin(Re z) * (exp(-(Im z)) - exp(Im z)) / 2\"\n by sorry\n\nlemma Re_sin_pos: \"0 < Re z \\ Re z < pi \\ Re (sin z) > 0\"\n by sorry\n\nlemma Im_sin_nonneg: \"Re z = 0 \\ 0 \\ Im z \\ 0 \\ Im (sin z)\"\n by sorry\n\nlemma Im_sin_nonneg2: \"Re z = pi \\ Im z \\ 0 \\ 0 \\ Im (sin z)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relationships between real and complex trigonometric and hyperbolic functions\\\n\nlemma real_sin_eq [simp]: \"Re(sin(of_real x)) = sin x\"\n by sorry\n\nlemma real_cos_eq [simp]: \"Re(cos(of_real x)) = cos x\"\n by sorry\n\nlemma DeMoivre: \"(cos z + \\ * sin z) ^ n = cos(n * z) + \\ * sin(n * z)\"\n by sorry\n\nlemma exp_cnj: \"cnj (exp z) = exp (cnj z)\"\n by sorry\n\nlemma cnj_sin: \"cnj(sin z) = sin(cnj z)\"\n by sorry\n\nlemma cnj_cos: \"cnj(cos z) = cos(cnj z)\"\n by sorry\n\nlemma field_differentiable_at_sin: \"sin field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_sin: \"sin field_differentiable (at z within S)\"\n by sorry\n\nlemma field_differentiable_at_cos: \"cos field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_cos: \"cos field_differentiable (at z within S)\"\n by sorry\n\nlemma holomorphic_on_sin: \"sin holomorphic_on S\"\n by sorry\n\nlemma holomorphic_on_cos: \"cos holomorphic_on S\"\n by sorry\n\nlemma holomorphic_on_sin' [holomorphic_intros]:\n assumes \"f holomorphic_on A\"\n shows \"(\\x. sin (f x)) holomorphic_on A\"\n by sorry\n\nlemma holomorphic_on_cos' [holomorphic_intros]:\n assumes \"f holomorphic_on A\"\n shows \"(\\x. cos (f x)) holomorphic_on A\"\n by sorry\n\nlemma analytic_on_sin [analytic_intros]: \"f analytic_on A \\ (\\w. sin (f w)) analytic_on A\"\n and analytic_on_cos [analytic_intros]: \"f analytic_on A \\ (\\w. cos (f w)) analytic_on A\"\n and analytic_on_sinh [analytic_intros]: \"f analytic_on A \\ (\\w. sinh (f w)) analytic_on A\"\n and analytic_on_cosh [analytic_intros]: \"f analytic_on A \\ (\\w. cosh (f w)) analytic_on A\"\n by sorry\n\nlemma analytic_on_tan [analytic_intros]:\n \"f analytic_on A \\ (\\z. z \\ A \\ cos (f z) \\ 0) \\ (\\w. tan (f w)) analytic_on A\"\n and analytic_on_cot [analytic_intros]:\n \"f analytic_on A \\ (\\z. z \\ A \\ sin (f z) \\ 0) \\ (\\w. cot (f w)) analytic_on A\"\n and analytic_on_tanh [analytic_intros]:\n \"f analytic_on A \\ (\\z. z \\ A \\ cosh (f z) \\ 0) \\ (\\w. tanh (f w)) analytic_on A\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\More on the Polar Representation of Complex Numbers\\\n\nlemma exp_Complex: \"exp(Complex r t) = of_real(exp r) * Complex (cos t) (sin t)\"\n by sorry\n\nlemma exp_eq_1: \"exp z = 1 \\ Re(z) = 0 \\ (\\n::int. Im(z) = of_int (2 * n) * pi)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma exp_eq: \"exp w = exp z \\ (\\n::int. w = z + (of_int (2 * n) * pi) * \\)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma exp_complex_eqI: \"\\Im w - Im z\\ < 2*pi \\ exp w = exp z \\ w = z\"\n by sorry\n\nlemma exp_integer_2pi:\n assumes \"n \\ \\\"\n shows \"exp((2 * n * pi) * \\) = 1\"\n by sorry\n\nlemma exp_plus_2pin [simp]: \"exp (z + \\ * (of_int n * (of_real pi * 2))) = exp z\"\n by sorry\n\nlemma exp_2pi_1_int [simp]: \"exp (\\ * (of_int j * (of_real pi * 2))) = 1\"\n by sorry\n\nlemma exp_2pi_1_nat [simp]: \"exp (\\ * (of_nat j * (of_real pi * 2))) = 1\"\n by sorry\n\nlemma exp_integer_2pi_plus1:\n assumes \"n \\ \\\"\n shows \"exp(((2 * n + 1) * pi) * \\) = - 1\"\n by sorry\n\nlemma inj_on_exp_pi:\n fixes z::complex shows \"inj_on exp (ball z pi)\"\n by sorry\n\nlemma cmod_add_squared:\n fixes r1 r2::real\n shows \"(cmod (r1 * exp (\\ * \\1) + r2 * exp (\\ * \\2)))\\<^sup>2 = r1\\<^sup>2 + r2\\<^sup>2 + 2 * r1 * r2 * cos (\\1 - \\2)\" (is \"(cmod (?z1 + ?z2))\\<^sup>2 = ?rhs\")\n by sorry\n\nlemma cmod_diff_squared:\n fixes r1 r2::real\n shows \"(cmod (r1 * exp (\\ * \\1) - r2 * exp (\\ * \\2)))\\<^sup>2 = r1\\<^sup>2 + r2\\<^sup>2 - 2*r1*r2*cos (\\1 - \\2)\" \n by sorry\n\nlemma polar_convergence:\n fixes R::real\n assumes \"\\j. r j > 0\" \"R > 0\"\n shows \"((\\j. r j * exp (\\ * \\ j)) \\ (R * exp (\\ * \\))) \\\n (r \\ R) \\ (\\k. (\\j. \\ j - of_int (k j) * (2 * pi)) \\ \\)\" (is \"(?z \\ ?Z) = ?rhs\")\n by sorry\n\nlemma exp_i_ne_1:\n assumes \"0 < x\" \"x < 2*pi\"\n shows \"exp(\\ * of_real x) \\ 1\"\n by sorry\n\nlemma sin_eq_0:\n fixes z::complex\n shows \"sin z = 0 \\ (\\n::int. z = of_real(n * pi))\"\n by sorry\n\nlemma cos_eq_0:\n fixes z::complex\n shows \"cos z = 0 \\ (\\n::int. z = complex_of_real(n * pi) + of_real pi/2)\"\n by sorry\n\nlemma cos_eq_1:\n fixes z::complex\n shows \"cos z = 1 \\ (\\n::int. z = complex_of_real(2 * n * pi))\"\n by sorry\n\nlemma csin_eq_1:\n fixes z::complex\n shows \"sin z = 1 \\ (\\n::int. z = of_real(2 * n * pi) + of_real pi/2)\"\n by sorry\n\nlemma csin_eq_minus1:\n fixes z::complex\n shows \"sin z = -1 \\ (\\n::int. z = complex_of_real(2 * n * pi) + 3/2*pi)\"\n (is \"_ = ?rhs\")\n by sorry\n\nlemma ccos_eq_minus1:\n fixes z::complex\n shows \"cos z = -1 \\ (\\n::int. z = complex_of_real(2 * n * pi) + pi)\"\n by sorry\n\nlemma sin_eq_1: \"sin x = 1 \\ (\\n::int. x = (2 * n + 1 / 2) * pi)\"\n (is \"_ = ?rhs\")\n by sorry\n\nlemma sin_eq_minus1: \"sin x = -1 \\ (\\n::int. x = (2*n + 3/2) * pi)\" (is \"_ = ?rhs\")\n by sorry\n\nlemma cos_eq_minus1: \"cos x = -1 \\ (\\n::int. x = (2*n + 1) * pi)\"\n (is \"_ = ?rhs\")\n by sorry\n\nlemma cos_gt_neg1:\n assumes \"(t::real) \\ {-pi<.. -1\"\n by sorry\n\nlemma dist_exp_i_1: \"norm(exp(\\ * of_real t) - 1) = 2 * \\sin(t / 2)\\\"\n by sorry\n\nlemma sin_cx_2pi [simp]: \"\\z = of_int m; even m\\ \\ sin (z * complex_of_real pi) = 0\"\n by sorry\n\nlemma cos_cx_2pi [simp]: \"\\z = of_int m; even m\\ \\ cos (z * complex_of_real pi) = 1\"\n by sorry\n\nlemma complex_sin_eq:\n fixes w :: complex\n shows \"sin w = sin z \\ (\\n \\ \\. w = z + of_real(2*n*pi) \\ w = -z + of_real((2*n + 1)*pi))\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma complex_cos_eq:\n fixes w :: complex\n shows \"cos w = cos z \\ (\\n \\ \\. w = z + of_real(2*n*pi) \\ w = -z + of_real(2*n*pi))\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma sin_eq:\n \"sin x = sin y \\ (\\n \\ \\. x = y + 2*n*pi \\ x = -y + (2*n + 1)*pi)\"\n by sorry\n\nlemma cos_eq:\n \"cos x = cos y \\ (\\n \\ \\. x = y + 2*n*pi \\ x = -y + 2*n*pi)\"\n by sorry\n\nlemma sinh_complex:\n fixes z :: complex\n shows \"(exp z - inverse (exp z)) / 2 = -\\ * sin(\\ * z)\"\n by sorry\n\nlemma sin_i_times:\n fixes z :: complex\n shows \"sin(\\ * z) = \\ * ((exp z - inverse (exp z)) / 2)\"\n by sorry\n\nlemma sinh_real:\n fixes x :: real\n shows \"of_real((exp x - inverse (exp x)) / 2) = -\\ * sin(\\ * of_real x)\"\n by sorry\n\nlemma cosh_complex:\n fixes z :: complex\n shows \"(exp z + inverse (exp z)) / 2 = cos(\\ * z)\"\n by sorry\n\nlemma cosh_real:\n fixes x :: real\n shows \"of_real((exp x + inverse (exp x)) / 2) = cos(\\ * of_real x)\"\n by sorry\n\nlemmas cos_i_times = cosh_complex [symmetric]\n\nlemma norm_cos_squared:\n \"norm(cos z) ^ 2 = cos(Re z) ^ 2 + (exp(Im z) - inverse(exp(Im z))) ^ 2 / 4\"\n by sorry\n\nlemma norm_sin_squared:\n \"norm(sin z) ^ 2 = (exp(2 * Im z) + inverse(exp(2 * Im z)) - 2 * cos(2 * Re z)) / 4\"\n by sorry\n\nlemma exp_uminus_Im: \"exp (- Im z) \\ exp (cmod z)\"\n by sorry\n\nlemma norm_cos_le:\n fixes z::complex\n shows \"norm(cos z) \\ exp(norm z)\"\n by sorry\n\nlemma norm_cos_plus1_le:\n fixes z::complex\n shows \"norm(1 + cos z) \\ 2 * exp(norm z)\"\n by sorry\n\nlemma sinh_conv_sin: \"sinh z = -\\ * sin (\\*z)\"\n by sorry\n\nlemma cosh_conv_cos: \"cosh z = cos (\\*z)\"\n by sorry\n\nlemma tanh_conv_tan: \"tanh z = -\\ * tan (\\*z)\"\n by sorry\n\nlemma sin_conv_sinh: \"sin z = -\\ * sinh (\\*z)\"\n by sorry\n\nlemma cos_conv_cosh: \"cos z = cosh (\\*z)\"\n by sorry\n\nlemma tan_conv_tanh: \"tan z = -\\ * tanh (\\*z)\"\n by sorry\n\nlemma sinh_complex_eq_iff:\n \"sinh (z :: complex) = sinh w \\\n (\\n\\\\. z = w - 2 * \\ * of_real n * of_real pi \\\n z = -(2 * complex_of_real n + 1) * \\ * complex_of_real pi - w)\" (is \"_ = ?rhs\")\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Taylor series for complex exponential, sine and cosine\\\n\ndeclare power_Suc [simp del]\n\nlemma Taylor_exp_field:\n fixes z::\"'a::{banach,real_normed_field}\"\n shows \"norm (exp z - (\\i\\n. z ^ i / fact i)) \\ exp (norm z) * (norm z ^ Suc n) / fact n\"\n by sorry\n\ntext \\For complex @{term z}, a tighter bound than in the previous result\\\nlemma Taylor_exp:\n \"norm(exp z - (\\k\\n. z ^ k / (fact k))) \\ exp\\Re z\\ * (norm z) ^ (Suc n) / (fact n)\"\n by sorry\n\nlemma\n assumes \"0 \\ u\" \"u \\ 1\"\n shows cmod_sin_le_exp: \"cmod (sin (u *\\<^sub>R z)) \\ exp \\Im z\\\"\n and cmod_cos_le_exp: \"cmod (cos (u *\\<^sub>R z)) \\ exp \\Im z\\\"\n by sorry\n\nlemma Taylor_sin:\n \"norm(sin z - (\\k\\n. complex_of_real (sin_coeff k) * z ^ k))\n \\ exp\\Im z\\ * (norm z) ^ (Suc n) / (fact n)\"\n by sorry\n\nlemma Taylor_cos:\n \"norm(cos z - (\\k\\n. complex_of_real (cos_coeff k) * z ^ k))\n \\ exp\\Im z\\ * (norm z) ^ Suc n / (fact n)\"\n by sorry\n\ndeclare power_Suc [simp]\n\ntext\\32-bit Approximation to e\\\nlemma e_approx_32: \"\\exp(1) - 5837465777 / 2147483648\\ \\ (inverse(2 ^ 32)::real)\"\n by sorry\n\nlemma e_less_272: \"exp 1 < (272/100::real)\"\n by sorry\n\nlemma ln_272_gt_1: \"ln (272/100) > (1::real)\"\n by sorry\n\ntext\\Apparently redundant. But many arguments involve integers.\\\nlemma ln3_gt_1: \"ln 3 > (1::real)\"\n by sorry\n\nsubsection\\The argument of a complex number (HOL Light version)\\\n\ndefinition\\<^marker>\\tag important\\ is_Arg :: \"[complex,real] \\ bool\"\n where \"is_Arg z r \\ z = of_real(norm z) * exp(\\ * of_real r)\"\n\ndefinition\\<^marker>\\tag important\\ Arg2pi :: \"complex \\ real\"\n where \"Arg2pi z \\ if z = 0 then 0 else THE t. 0 \\ t \\ t < 2*pi \\ is_Arg z t\"\n\nlemma is_Arg_2pi_iff: \"is_Arg z (r + of_int k * (2 * pi)) \\ is_Arg z r\"\n by sorry\n\nlemma is_Arg_eqI:\n assumes \"is_Arg z r\" and \"is_Arg z s\" and \"abs (r-s) < 2*pi\" and \"z \\ 0\"\n shows \"r = s\"\n by sorry\n\ntext\\This function returns the angle of a complex number from its representation in polar coordinates.\nDue to periodicity, its range is arbitrary. \\<^term>\\Arg2pi\\ follows HOL Light in adopting the interval \\[0,2\\)\\.\nBut we have the same periodicity issue with logarithms, and it is usual to adopt the same interval\nfor the complex logarithm and argument functions. Further on down, we shall define both functions for the interval \\(-\\,\\]\\.\nThe present version is provided for compatibility.\\\n\nlemma Arg2pi_0 [simp]: \"Arg2pi(0) = 0\"\n by sorry\n\nlemma Arg2pi_unique_lemma:\n assumes \"is_Arg z t\"\n and \"is_Arg z t'\"\n and \"0 \\ t\" \"t < 2*pi\"\n and \"0 \\ t'\" \"t' < 2*pi\"\n and \"z \\ 0\"\n shows \"t' = t\"\n by sorry\n\nlemma Arg2pi: \"0 \\ Arg2pi z \\ Arg2pi z < 2*pi \\ is_Arg z (Arg2pi z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\\n shows Arg2pi_ge_0: \"0 \\ Arg2pi z\"\n and Arg2pi_lt_2pi: \"Arg2pi z < 2*pi\"\n and Arg2pi_eq: \"z = of_real(norm z) * exp(\\ * of_real(Arg2pi z))\"\n by sorry\n\nlemma complex_norm_eq_1_exp: \"norm z = 1 \\ exp(\\ * of_real (Arg2pi z)) = z\"\n by sorry\n\nlemma Arg2pi_unique: \"\\of_real r * exp(\\ * of_real a) = z; 0 < r; 0 \\ a; a < 2*pi\\ \\ Arg2pi z = a\"\n by sorry\n\nlemma cos_Arg2pi: \"cmod z * cos (Arg2pi z) = Re z\" and sin_Arg2pi: \"cmod z * sin (Arg2pi z) = Im z\"\n by sorry\n\nlemma Arg2pi_minus:\n assumes \"z \\ 0\" shows \"Arg2pi (-z) = (if Arg2pi z < pi then Arg2pi z + pi else Arg2pi z - pi)\"\n by sorry\n\nlemma Arg2pi_times_of_real [simp]:\n assumes \"0 < r\" shows \"Arg2pi (of_real r * z) = Arg2pi z\"\n by sorry\n\nlemma Arg2pi_times_of_real2 [simp]: \"0 < r \\ Arg2pi (z * of_real r) = Arg2pi z\"\n by sorry\n\nlemma Arg2pi_divide_of_real [simp]: \"0 < r \\ Arg2pi (z / of_real r) = Arg2pi z\"\n by sorry\n\nlemma Arg2pi_le_pi: \"Arg2pi z \\ pi \\ 0 \\ Im z\"\n by sorry\n\nlemma Arg2pi_lt_pi: \"0 < Arg2pi z \\ Arg2pi z < pi \\ 0 < Im z\"\n by sorry\n\nlemma Arg2pi_eq_0: \"Arg2pi z = 0 \\ z \\ \\ \\ 0 \\ Re z\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Arg2pi_gt_0:\n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"Arg2pi z > 0\"\n by sorry\n\nlemma Arg2pi_eq_pi: \"Arg2pi z = pi \\ z \\ \\ \\ Re z < 0\"\n by sorry\n\nlemma Arg2pi_eq_0_pi: \"Arg2pi z = 0 \\ Arg2pi z = pi \\ z \\ \\\"\n by sorry\n\nlemma Arg2pi_of_real: \"Arg2pi (of_real r) = (if r<0 then pi else 0)\"\n by sorry\n\nlemma Arg2pi_real: \"z \\ \\ \\ Arg2pi z = (if 0 \\ Re z then 0 else pi)\"\n by sorry\n\nlemma Arg2pi_inverse: \"Arg2pi(inverse z) = (if z \\ \\ then Arg2pi z else 2*pi - Arg2pi z)\"\n by sorry\n\nlemma Arg2pi_eq_iff:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg2pi w = Arg2pi z \\ (\\x. 0 < x \\ w = of_real x * z)\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma Arg2pi_inverse_eq_0: \"Arg2pi(inverse z) = 0 \\ Arg2pi z = 0\"\n by sorry\n\nlemma Arg2pi_divide:\n assumes \"w \\ 0\" \"z \\ 0\" \"Arg2pi w \\ Arg2pi z\"\n shows \"Arg2pi(z / w) = Arg2pi z - Arg2pi w\"\n by sorry\n\nlemma Arg2pi_le_div_sum:\n assumes \"w \\ 0\" \"z \\ 0\" \"Arg2pi w \\ Arg2pi z\"\n shows \"Arg2pi z = Arg2pi w + Arg2pi(z / w)\"\n by sorry\n\nlemma Arg2pi_le_div_sum_eq:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg2pi w \\ Arg2pi z \\ Arg2pi z = Arg2pi w + Arg2pi(z / w)\"\n by sorry\n\nlemma Arg2pi_diff:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg2pi w - Arg2pi z = (if Arg2pi z \\ Arg2pi w then Arg2pi(w / z) else Arg2pi(w/z) - 2*pi)\"\n by sorry\n\nlemma Arg2pi_add:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg2pi w + Arg2pi z = (if Arg2pi w + Arg2pi z < 2*pi then Arg2pi(w * z) else Arg2pi(w * z) + 2*pi)\"\n by sorry\n\nlemma Arg2pi_times:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg2pi (w * z) = (if Arg2pi w + Arg2pi z < 2*pi then Arg2pi w + Arg2pi z\n else (Arg2pi w + Arg2pi z) - 2*pi)\"\n by sorry\n\nlemma Arg2pi_cnj_eq_inverse:\n assumes \"z \\ 0\" shows \"Arg2pi (cnj z) = Arg2pi (inverse z)\"\n by sorry\n\nlemma Arg2pi_cnj: \"Arg2pi(cnj z) = (if z \\ \\ then Arg2pi z else 2*pi - Arg2pi z)\"\n by sorry\n\nlemma Arg2pi_exp: \"0 \\ Im z \\ Im z < 2*pi \\ Arg2pi(exp z) = Im z\"\n by sorry\n\nlemma complex_split_polar:\n obtains r a::real where \"z = complex_of_real r * (cos a + \\ * sin a)\" \"0 \\ r\" \"0 \\ a\" \"a < 2*pi\"\n by sorry\n\nlemma Re_Im_le_cmod: \"Im w * sin \\ + Re w * cos \\ \\ cmod w\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Analytic properties of tangent function\\\n\nlemma cnj_tan: \"cnj(tan z) = tan(cnj z)\"\n by sorry\n\nlemma field_differentiable_at_tan: \"cos z \\ 0 \\ tan field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_tan: \"cos z \\ 0\n \\ tan field_differentiable (at z within s)\"\n by sorry\n\nlemma continuous_within_tan: \"cos z \\ 0 \\ continuous (at z within s) tan\"\n by sorry\n\nlemma continuous_on_tan [continuous_intros]: \"(\\z. z \\ s \\ cos z \\ 0) \\ continuous_on s tan\"\n by sorry\n\nlemma holomorphic_on_tan: \"(\\z. z \\ s \\ cos z \\ 0) \\ tan holomorphic_on s\"\n by sorry\n\nsubsection\\The principal branch of the Complex logarithm\\\n\ninstantiation complex :: ln\nbegin\n\ndefinition\\<^marker>\\tag important\\ ln_complex :: \"complex \\ complex\"\n where \"ln_complex \\ \\z. THE w. exp w = z & -pi < Im(w) & Im(w) \\ pi\"\n\ntext\\NOTE: within this scope, the constant Ln is not yet available!\\\nlemma\n assumes \"z \\ 0\"\n shows exp_Ln [simp]: \"exp(ln z) = z\"\n and mpi_less_Im_Ln: \"-pi < Im(ln z)\"\n and Im_Ln_le_pi: \"Im(ln z) \\ pi\"\n by sorry\n\nlemma Ln_exp [simp]:\n assumes \"-pi < Im(z)\" \"Im(z) \\ pi\"\n shows \"ln(exp z) = z\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relation to Real Logarithm\\\n\nlemma Ln_of_real:\n assumes \"0 < z\"\n shows \"ln(of_real z::complex) = of_real(ln z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_in_Reals [simp]: \"z \\ \\ \\ Re z > 0 \\ ln z \\ \\\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Im_Ln_of_real [simp]: \"r > 0 \\ Im (ln (of_real r)) = 0\"\n by sorry\n\nlemma cmod_Ln_Reals [simp]: \"z \\ \\ \\ 0 < Re z \\ cmod (ln z) = norm (ln (Re z))\"\n by sorry\n\nlemma Ln_Reals_eq: \"\\x \\ \\; Re x > 0\\ \\ ln x = of_real (ln (Re x))\"\n by sorry\n\nlemma Ln_1 [simp]: \"ln 1 = (0::complex)\"\n by sorry\n\nlemma Ln_eq_zero_iff [simp]: \"x \\ \\\\<^sub>\\\\<^sub>0 \\ ln x = 0 \\ x = 1\" for x::complex\n by sorry\n\ninstance\n by intro_classes (rule ln_complex_def Ln_1)\n\nend\n\nabbreviation Ln :: \"complex \\ complex\"\n where \"Ln \\ ln\"\n\nlemma Ln_eq_iff: \"w \\ 0 \\ z \\ 0 \\ (Ln w = Ln z \\ w = z)\"\n by sorry\n\nlemma Ln_unique: \"exp(z) = w \\ -pi < Im(z) \\ Im(z) \\ pi \\ Ln w = z\"\n by sorry\n\nlemma Re_Ln [simp]: \"z \\ 0 \\ Re(Ln z) = ln(norm z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ ln_cmod_le:\n assumes z: \"z \\ 0\"\n shows \"ln (cmod z) \\ cmod (Ln z)\"\n by sorry\n\nproposition\\<^marker>\\tag unimportant\\ exists_complex_root:\n fixes z :: complex\n assumes \"n \\ 0\" obtains w where \"z = w ^ n\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ exists_complex_root_nonzero:\n fixes z::complex\n assumes \"z \\ 0\" \"n \\ 0\"\n obtains w where \"w \\ 0\" \"z = w ^ n\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Derivative of Ln away from the branch cut\\\n\nlemma Im_Ln_less_pi: \n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"shows \"Im (Ln z) < pi\"\n by sorry\n\nlemma has_field_derivative_Ln: \n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"(Ln has_field_derivative inverse(z)) (at z)\"\n by sorry\n\ndeclare has_field_derivative_Ln [derivative_intros]\ndeclare has_field_derivative_Ln [THEN DERIV_chain2, derivative_intros]\n\nlemma field_differentiable_at_Ln: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ Ln field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_Ln: \"z \\ \\\\<^sub>\\\\<^sub>0\n \\ Ln field_differentiable (at z within S)\"\n by sorry\n\nlemma continuous_at_Ln: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ continuous (at z) Ln\"\n by sorry\n\nlemma isCont_Ln' [simp,continuous_intros]:\n \"\\isCont f z; f z \\ \\\\<^sub>\\\\<^sub>0\\ \\ isCont (\\x. Ln (f x)) z\"\n by sorry\n\nlemma continuous_within_Ln [continuous_intros]: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ continuous (at z within S) Ln\"\n by sorry\n\nlemma continuous_on_Ln [continuous_intros]: \"(\\z. z \\ S \\ z \\ \\\\<^sub>\\\\<^sub>0) \\ continuous_on S Ln\"\n by sorry\n\nlemma continuous_on_Ln' [continuous_intros]:\n \"continuous_on S f \\ (\\z. z \\ S \\ f z \\ \\\\<^sub>\\\\<^sub>0) \\ continuous_on S (\\x. Ln (f x))\"\n by sorry\n\nlemma holomorphic_on_Ln [holomorphic_intros]: \"S \\ \\\\<^sub>\\\\<^sub>0 = {} \\ Ln holomorphic_on S\"\n by sorry\n\nlemma holomorphic_on_Ln' [holomorphic_intros]:\n \"(\\z. z \\ A \\ f z \\ \\\\<^sub>\\\\<^sub>0) \\ f holomorphic_on A \\ (\\z. Ln (f z)) holomorphic_on A\"\n by sorry\n\nlemma analytic_on_ln [analytic_intros]:\n assumes \"f analytic_on A\" \"f ` A \\ \\\\<^sub>\\\\<^sub>0 = {}\"\n shows \"(\\w. ln (f w)) analytic_on A\"\n by sorry\n\nlemma tendsto_Ln [tendsto_intros]:\n assumes \"(f \\ L) F\" \"L \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"((\\x. Ln (f x)) \\ Ln L) F\"\n by sorry\n\nlemma divide_ln_mono:\n fixes x y::real\n assumes \"3 \\ x\" \"x \\ y\"\n shows \"x / ln x \\ y / ln y\"\n by sorry\n\ntheorem Ln_series:\n fixes z :: complex\n assumes \"norm z < 1\"\n shows \"(\\n. (-1)^Suc n / of_nat n * z^n) sums ln (1 + z)\" (is \"(\\n. ?f n * z^n) sums _\")\n by sorry\n\nlemma Ln_series': \"cmod z < 1 \\ (\\n. - ((-z)^n) / of_nat n) sums ln (1 + z)\"\n by sorry\n\nlemma ln_series':\n fixes x::real\n assumes \"\\x\\ < 1\"\n shows \"(\\n. - ((-x)^n) / of_nat n) sums ln (1 + x)\"\n by sorry\n\nlemma Ln_approx_linear:\n fixes z :: complex\n assumes \"norm z < 1\"\n shows \"norm (ln (1 + z) - z) \\ norm z^2 / (1 - norm z)\"\n by sorry\n\nlemma norm_Ln_le:\n fixes z :: complex\n assumes \"norm z < 1/2\"\n shows \"norm (Ln(1+z)) \\ 2 * norm z\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Quadrant-type results for Ln\\\n\nlemma cos_lt_zero_pi: \"pi/2 < x \\ x < 3*pi/2 \\ cos x < 0\"\n by sorry\n\nlemma Re_Ln_pos_le:\n assumes \"z \\ 0\"\n shows \"\\Im(Ln z)\\ \\ pi/2 \\ 0 \\ Re(z)\"\n by sorry\n\nlemma Re_Ln_pos_lt:\n assumes \"z \\ 0\"\n shows \"\\Im(Ln z)\\ < pi/2 \\ 0 < Re(z)\"\n by sorry\n\nlemma Im_Ln_pos_le:\n assumes \"z \\ 0\"\n shows \"0 \\ Im(Ln z) \\ Im(Ln z) \\ pi \\ 0 \\ Im(z)\"\n by sorry\n\nlemma Im_Ln_pos_lt:\n assumes \"z \\ 0\"\n shows \"0 < Im(Ln z) \\ Im(Ln z) < pi \\ 0 < Im(z)\"\n by sorry\n\nlemma Re_Ln_pos_lt_imp: \"0 < Re(z) \\ \\Im(Ln z)\\ < pi/2\"\n by sorry\n\nlemma Im_Ln_pos_lt_imp: \"0 < Im(z) \\ 0 < Im(Ln z) \\ Im(Ln z) < pi\"\n by sorry\n\ntext\\A reference to the set of positive real numbers\\\nlemma Im_Ln_eq_0: \"z \\ 0 \\ (Im(Ln z) = 0 \\ 0 < Re(z) \\ Im(z) = 0)\"\n by sorry\n\nlemma Im_Ln_eq_pi: \"z \\ 0 \\ (Im(Ln z) = pi \\ Re(z) < 0 \\ Im(z) = 0)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\More Properties of Ln\\\n\nlemma cnj_Ln: assumes \"z \\ \\\\<^sub>\\\\<^sub>0\" shows \"cnj(Ln z) = Ln(cnj z)\"\n by sorry\n\nlemma Ln_inverse: assumes \"z \\ \\\\<^sub>\\\\<^sub>0\" shows \"Ln(inverse z) = -(Ln z)\"\n by sorry\n\nlemma Ln_minus1 [simp]: \"Ln(-1) = \\ * pi\"\n by sorry\n\nlemma Ln_ii [simp]: \"Ln \\ = \\ * of_real pi/2\"\n by sorry\n\nlemma Ln_minus_ii [simp]: \"Ln(-\\) = - (\\ * pi/2)\"\n by sorry\n\nlemma Ln_times:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Ln(w * z) =\n (if Im(Ln w + Ln z) \\ -pi then (Ln(w) + Ln(z)) + \\ * of_real(2*pi)\n else if Im(Ln w + Ln z) > pi then (Ln(w) + Ln(z)) - \\ * of_real(2*pi)\n else Ln(w) + Ln(z))\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_times_simple:\n \"\\w \\ 0; z \\ 0; -pi < Im(Ln w) + Im(Ln z); Im(Ln w) + Im(Ln z) \\ pi\\\n \\ Ln(w * z) = Ln(w) + Ln(z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_times_of_real:\n \"\\r > 0; z \\ 0\\ \\ Ln(of_real r * z) = ln r + Ln(z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_times_of_nat:\n \"\\r > 0; z \\ 0\\ \\ Ln(of_nat r * z :: complex) = ln (of_nat r) + Ln(z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_times_Reals:\n \"\\r \\ Reals; Re r > 0; z \\ 0\\ \\ Ln(r * z) = ln (Re r) + Ln(z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_divide_of_real:\n \"\\r > 0; z \\ 0\\ \\ Ln(z / of_real r) = Ln(z) - ln r\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_prod:\n fixes f :: \"'a \\ complex\"\n assumes \"finite A\" \"\\x. x \\ A \\ f x \\ 0\"\n shows \"\\n. Ln (prod f A) = (\\x \\ A. Ln (f x) + (of_int (n x) * (2 * pi)) * \\)\"\n by sorry\n\nlemma Ln_minus:\n assumes \"z \\ 0\"\n shows \"Ln(-z) = (if Im(z) \\ 0 \\ \\(Re(z) < 0 \\ Im(z) = 0)\n then Ln(z) + \\ * pi\n else Ln(z) - \\ * pi)\" \n by sorry\n\nlemma Ln_inverse_if:\n assumes \"z \\ 0\"\n shows \"Ln (inverse z) = (if z \\ \\\\<^sub>\\\\<^sub>0 then -(Ln z) + \\ * 2 * complex_of_real pi else -(Ln z))\"\n by sorry\n\nlemma Ln_times_ii:\n assumes \"z \\ 0\"\n shows \"Ln(\\ * z) = (if 0 \\ Re(z) | Im(z) < 0\n then Ln(z) + \\ * of_real pi/2\n else Ln(z) - \\ * of_real(3 * pi/2))\"\n by sorry\n\nlemma Ln_of_nat [simp]: \"0 < n \\ Ln (of_nat n) = of_real (ln (of_nat n))\"\n by sorry\n\nlemma Ln_of_nat_over_of_nat:\n assumes \"m > 0\" \"n > 0\"\n shows \"Ln (of_nat m / of_nat n) = of_real (ln (of_nat m) - ln (of_nat n))\"\n by sorry\n\nlemma norm_Ln_times_le:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"cmod (Ln(w * z)) \\ cmod (Ln(w) + Ln(z))\"\n by sorry\n\ncorollary norm_Ln_prod_le:\n fixes f :: \"'a \\ complex\"\n assumes \"\\x. x \\ A \\ f x \\ 0\"\n shows \"cmod (Ln (prod f A)) \\ (\\x \\ A. cmod (Ln (f x)))\"\n by sorry\n\nlemma norm_Ln_exp_le: \"norm (Ln (exp z)) \\ norm z\"\n by sorry\n\nlemma Ln_cis: \"x \\ {-pi<..pi} \\ Ln (cis x) = x * \\\"\n by sorry\n\nlemma Ln_rcis:\n assumes \"r > 0\" \"x \\ {-pi<..pi}\"\n shows \"Ln (rcis r x) = Complex (ln r) x\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Uniform convergence and products\\\n\nlemma uniformly_convergent_on_prod_aux:\n fixes f :: \"nat \\ complex \\ complex\"\n assumes norm_f: \"\\n x. x \\ A \\ norm (f n x) < 1\"\n assumes cont: \"\\n. continuous_on A (f n)\"\n assumes conv: \"uniformly_convergent_on A (\\N x. \\nN x. \\nTheorem 17.6 by Bak and Newman, Complex Analysis [roughly]\\\nlemma uniformly_convergent_on_prod:\n fixes f :: \"nat \\ complex \\ complex\"\n assumes cont: \"\\n. continuous_on A (f n)\"\n assumes A: \"compact A\"\n assumes conv_sum: \"uniformly_convergent_on A (\\N x. \\nN x. \\n complex \\ complex\"\n assumes cont: \"\\n. continuous_on A (f n)\"\n assumes A: \"compact A\"\n assumes conv_sum: \"uniformly_convergent_on A (\\N x. \\nN x. \\nProp 17.6 of Bak and Newman, Complex Analysis, p. 243. \n Only this version is for the reals. Can the two proofs be consolidated?\\\nlemma uniformly_convergent_on_prod_real:\n fixes u :: \"nat \\ real \\ real\"\n assumes contu: \"\\k. continuous_on K (u k)\" \n and uconv: \"uniformly_convergent_on K (\\n x. \\ku k x\\)\"\n and K: \"compact K\"\n shows \"uniformly_convergent_on K (\\n x. \\kThe Argument of a Complex Number\\\n\ntext\\Unlike in HOL Light, it's defined for the same interval as the complex logarithm: \\(-\\,\\]\\.\\\n\nlemma Arg_eq_Im_Ln:\n assumes \"z \\ 0\" shows \"Arg z = Im (Ln z)\"\n by sorry\n\ntext \\The 1990s definition of argument coincides with the more recent one\\\nlemma\\<^marker>\\tag important\\ Arg_def:\n shows \"Arg z = (if z = 0 then 0 else Im (Ln z))\"\n by sorry\n\nlemma Arg_of_real [simp]: \"Arg (of_real r) = (if r<0 then pi else 0)\"\n by sorry\n\nlemma mpi_less_Arg: \"-pi < Arg z\" and Arg_le_pi: \"Arg z \\ pi\"\n by sorry\n\nlemma Arg_eq: \n assumes \"z \\ 0\"\n shows \"z = of_real(norm z) * exp(\\ * Arg z)\"\n by sorry\n\nlemma is_Arg_Arg: \"z \\ 0 \\ is_Arg z (Arg z)\"\n by sorry\n\nlemma Argument_exists:\n assumes \"z \\ 0\" and R: \"R = {r-pi<..r+pi}\"\n obtains s where \"is_Arg z s\" \"s\\R\"\n by sorry\n\nlemma Argument_exists_unique:\n assumes \"z \\ 0\" and R: \"R = {r-pi<..r+pi}\"\n obtains s where \"is_Arg z s\" \"s\\R\" \"\\t. \\is_Arg z t; t\\R\\ \\ s=t\"\n by sorry\n\nlemma Argument_Ex1:\n assumes \"z \\ 0\" and R: \"R = {r-pi<..r+pi}\"\n shows \"\\!s. is_Arg z s \\ s \\ R\"\n by sorry\n\nlemma Arg_divide:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"is_Arg (z / w) (Arg z - Arg w)\"\n by sorry\n\nlemma Arg_unique_lemma:\n assumes \"is_Arg z t\" \"is_Arg z t'\"\n and \"- pi < t\" \"t \\ pi\"\n and \"- pi < t'\" \"t' \\ pi\"\n and \"z \\ 0\"\n shows \"t' = t\"\n by sorry\n\nlemma complex_norm_eq_1_exp_eq: \"norm z = 1 \\ exp(\\ * (Arg z)) = z\"\n by sorry\n\nlemma Arg_unique: \"\\of_real r * exp(\\ * a) = z; 0 < r; -pi < a; a \\ pi\\ \\ Arg z = a\"\n by sorry\n\nlemma Arg_minus:\n assumes \"z \\ 0\"\n shows \"Arg (-z) = (if Arg z \\ 0 then Arg z + pi else Arg z - pi)\"\n by sorry\n\nlemma Arg_1 [simp]: \"Arg 1 = 0\"\n by sorry\n\nlemma Arg_numeral [simp]: \"Arg (numeral n) = 0\"\n by sorry\n \nlemma Arg_times_of_real [simp]:\n assumes \"0 < r\" shows \"Arg (of_real r * z) = Arg z\"\n by sorry\n\nlemma Arg_times_of_real2 [simp]: \"0 < r \\ Arg (z * of_real r) = Arg z\"\n by sorry\n\nlemma Arg_divide_of_real [simp]: \"0 < r \\ Arg (z / of_real r) = Arg z\"\n by sorry\n\nlemma Arg_less_0: \"0 \\ Arg z \\ 0 \\ Im z\"\n by sorry\n\ntext \\converse fails because the argument can equal $\\pi$.\\ \nlemma Arg_uminus: \"Arg z < 0 \\ Arg (-z) > 0\"\n by sorry\n\nlemma Arg_eq_pi: \"Arg z = pi \\ Re z < 0 \\ Im z = 0\"\n by sorry\n\nlemma Arg_lt_pi: \"0 < Arg z \\ Arg z < pi \\ 0 < Im z\"\n by sorry\n\nlemma Arg_eq_0: \"Arg z = 0 \\ z \\ \\ \\ 0 \\ Re z\"\n by sorry\n\nlemma Arg_neg_iff: \"Arg x < 0 \\ Im x < 0\"\n by sorry\n\nlemma Arg_pos_iff: \"Arg x > 0 \\ Im x > 0 \\ (Im x = 0 \\ Re x < 0)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Arg_ne_0: assumes \"z \\ \\\\<^sub>\\\\<^sub>0\" shows \"Arg z \\ 0\"\n by sorry\n\nlemma Arg_eq_pi_iff: \"Arg z = pi \\ z \\ \\ \\ Re z < 0\"\n by sorry\n\nlemma Arg_eq_0_iff: \"Arg z = 0 \\ z \\ \\ \\ Re z \\ 0\"\n by sorry\n\nlemma Arg_eq_0_pi: \"Arg z = 0 \\ Arg z = pi \\ z \\ \\\"\n by sorry\n\nlemma Arg_real: \"z \\ \\ \\ Arg z = (if 0 \\ Re z then 0 else pi)\"\n by sorry\n\nlemma Arg_inverse: \"Arg(inverse z) = (if z \\ \\ then Arg z else - Arg z)\"\n by sorry\n\nlemma Arg_eq_iff:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg w = Arg z \\ (\\x. 0 < x \\ w = of_real x * z)\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma Arg_inverse_eq_0: \"Arg(inverse z) = 0 \\ Arg z = 0\"\n by sorry\n\nlemma Arg_cnj_eq_inverse: \"z\\0 \\ Arg (cnj z) = Arg (inverse z)\"\n by sorry\n\nlemma Arg_cnj: \"Arg(cnj z) = (if z \\ \\ then Arg z else - Arg z)\"\n by sorry\n\nlemma Arg_exp: \"-pi < Im z \\ Im z \\ pi \\ Arg(exp z) = Im z\"\n by sorry\n\nlemma Arg_cis: \"x \\ {-pi<..pi} \\ Arg (cis x) = x\"\n by sorry\n\nlemma Arg_rcis: \"x \\ {-pi<..pi} \\ r > 0 \\ Arg (rcis r x) = x\"\n by sorry\n\nlemma Ln_Arg: \"z\\0 \\ Ln(z) = ln(norm z) + \\ * Arg(z)\"\n by sorry\n\nlemma Ln_of_real':\n assumes \"x \\ 0\"\n shows \"Ln (of_real x) = of_real (ln \\x\\) + (if x < 0 then pi else 0) * \\\"\n by sorry\n\nlemma continuous_at_Arg:\n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"continuous (at z) Arg\"\n by sorry\n\nlemma continuous_within_Arg: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ continuous (at z within S) Arg\"\n by sorry\n\nlemma continuous_on_Arg: \"continuous_on (-\\\\<^sub>\\\\<^sub>0) Arg\"\n by sorry\n\nlemma continuous_on_Arg' [continuous_intros]:\n assumes \"continuous_on A f\" \"\\z. z \\ A \\ f z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"continuous_on A (\\x. Arg (f x))\"\n by sorry\n\nlemma tendsto_Arg [tendsto_intros]:\n assumes \"(f \\ z) F\" \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"((\\x. Arg (f x)) \\ Arg z) F\"\n by sorry\n\nlemma Arg_Re_pos: \"\\Arg z\\ < pi / 2 \\ Re z > 0 \\ z = 0\"\n by sorry\n\nlemma Arg_Re_nonneg: \"\\Arg z\\ \\ pi / 2 \\ Re z \\ 0\"\n by sorry\n\nlemma Arg_times:\n assumes \"Arg z + Arg w \\ {-pi<..pi}\" \"z \\ 0\" \"w \\ 0\"\n shows \"Arg (z * w) = Arg z + Arg w\"\n by sorry\n\nlemma Arg_unique': \"r > 0 \\ \\ \\ {-pi<..pi} \\ x = rcis r \\ \\ Arg x = \\\"\n by sorry\n\nlemma Arg_times':\n assumes \"w \\ 0\" \"z \\ 0\"\n defines \"x \\ Arg w + Arg z\"\n shows \"Arg (w * z) = x + (if x \\ {-pi<..pi} then 0 else if x > pi then -2*pi else 2*pi)\"\n by sorry\n\nlemma Arg_divide':\n assumes [simp]: \"z \\ 0\" \"w \\ 0\"\n shows \"Arg (z / w) = Arg z - Arg w +\n (if Arg z - Arg w > pi then -2 * pi else if Arg z - Arg w \\ -pi then 2 * pi else 0)\"\n (is \"_ = ?rhs\")\n by sorry\n \nsubsection\\The Unwinding Number and the Ln product Formula\\\n\ntext\\Note that in this special case the unwinding number is -1, 0 or 1. But it's always an integer.\\\n\nlemma is_Arg_exp_Im: \"is_Arg (exp z) (Im z)\"\n by sorry\n\nlemma is_Arg_exp_diff_2pi:\n assumes \"is_Arg (exp z) \\\"\n shows \"\\k. Im z - of_int k * (2 * pi) = \\\"\n by sorry\n\nlemma Arg_exp_diff_2pi: \"\\k. Im z - of_int k * (2 * pi) = Arg (exp z)\"\n by sorry\n\nlemma unwinding_in_Ints: \"(z - Ln(exp z)) / (of_real(2*pi) * \\) \\ \\\"\n by sorry\n\ndefinition\\<^marker>\\tag important\\ unwinding :: \"complex \\ int\" where\n \"unwinding z \\ THE k. of_int k = (z - Ln(exp z)) / (of_real(2*pi) * \\)\"\n\nlemma unwinding: \"of_int (unwinding z) = (z - Ln(exp z)) / (of_real(2*pi) * \\)\"\n by sorry\n\nlemma unwinding_2pi: \"(2*pi) * \\ * unwinding(z) = z - Ln(exp z)\"\n by sorry\n\nlemma Ln_times_unwinding:\n \"w \\ 0 \\ z \\ 0 \\ Ln(w * z) = Ln(w) + Ln(z) - (2*pi) * \\ * unwinding(Ln w + Ln z)\"\n by sorry\n\nlemma arg_conv_arctan:\n assumes \"Re z > 0\"\n shows \"Arg z = arctan (Im z / Re z)\"\n by sorry\n\nsubsection \\Characterisation of @{term \"Im (Ln z)\"} (Wenda Li)\\\n\nlemma Im_Ln_eq_pi_half:\n \"z \\ 0 \\ (Im(Ln z) = pi/2 \\ 0 < Im(z) \\ Re(z) = 0)\"\n \"z \\ 0 \\ (Im(Ln z) = -pi/2 \\ Im(z) < 0 \\ Re(z) = 0)\"\n by sorry\n\nlemma Im_Ln_eq:\n assumes \"z\\0\"\n shows \"Im (Ln z) = (if Re z\\0 then\n if Re z>0 then\n arctan (Im z/Re z)\n else if Im z\\0 then\n arctan (Im z/Re z) + pi\n else\n arctan (Im z/Re z) - pi\n else\n if Im z>0 then pi/2 else -pi/2)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relation between Ln and Arg2pi, and hence continuity of Arg2pi\\\n\nlemma Arg2pi_Ln: \"0 < Arg2pi z \\ Arg2pi z = Im(Ln(-z)) + pi\"\n by sorry\n\nlemma continuous_at_Arg2pi:\n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"continuous (at z) Arg2pi\"\n by sorry\n\ntext\\Relation between Arg2pi and arctangent in upper halfplane\\\nlemma Arg2pi_arctan_upperhalf:\n assumes \"0 < Im z\"\n shows \"Arg2pi z = pi/2 - arctan(Re z / Im z)\"\n by sorry\n\nlemma Arg2pi_eq_Im_Ln:\n assumes \"0 \\ Im z\" \"0 < Re z\"\n shows \"Arg2pi z = Im (Ln z)\"\n by sorry\n\nlemma continuous_within_upperhalf_Arg2pi:\n assumes \"z \\ 0\"\n shows \"continuous (at z within {z. 0 \\ Im z}) Arg2pi\"\n by sorry\n\nlemma continuous_on_upperhalf_Arg2pi: \"continuous_on ({z. 0 \\ Im z} - {0}) Arg2pi\"\n by sorry\n\nlemma open_Arg2pi2pi_less_Int:\n assumes \"0 \\ s\" \"t \\ 2*pi\"\n shows \"open ({y. s < Arg2pi y} \\ {y. Arg2pi y < t})\"\n by sorry\n\nlemma open_Arg2pi2pi_gt: \"open {z. t < Arg2pi z}\"\n by sorry\n\nlemma closed_Arg2pi2pi_le: \"closed {z. Arg2pi z \\ t}\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Complex Powers\\\n\nlemma powr_to_1 [simp]: \"z powr 1 = (z::complex)\"\n by sorry\n\nlemma powr_nat:\n fixes n::nat and z::complex shows \"z powr n = (if z = 0 then 0 else z^n)\"\n by sorry\n\nlemma powr_nat': \"(z :: complex) \\ 0 \\ n \\ 0 \\ z powr of_nat n = z ^ n\"\n by sorry\n\nlemma norm_powr_complex: \"norm (x powr y) = norm x powr Re y * exp (-Im y * Arg x)\"\n by sorry\n\nlemma norm_powr_real: \"w \\ \\ \\ 0 < Re w \\ norm(w powr z) = exp(Re z * ln(Re w))\"\n by sorry\n\nlemma norm_powr_real_powr:\n \"w \\ \\ \\ 0 \\ Re w \\ cmod (w powr z) = Re w powr Re z\"\n by sorry\n\nlemma norm_powr_real_powr': \"w \\ \\ \\ norm (z powr w) = norm z powr Re w\"\n by sorry\n\nlemma powr_complexpow [simp]:\n fixes x::complex shows \"x \\ 0 \\ x powr (of_nat n) = x^n\"\n by sorry\n\nlemma powr_complexnumeral [simp]:\n fixes x::complex shows \"x powr (numeral n) = x ^ (numeral n)\"\n by sorry\n\nlemma powr_times_real_left:\n assumes \"x \\ \\\" \"Re x \\ 0\"\n shows \"(x * y) powr z = x powr z * y powr z\"\n by sorry\n\nlemma cnj_powr:\n assumes \"Im a = 0 \\ Re a \\ 0\"\n shows \"cnj (a powr b) = cnj a powr cnj b\"\n by sorry\n\nlemma powr_real_real:\n assumes \"w \\ \\\" \"z \\ \\\" \"0 < Re w\"\n shows \"w powr z = exp(Re z * ln(Re w))\"\n by sorry\n\nlemma powr_of_real:\n fixes x::real and y::real\n shows \"0 \\ x \\ of_real x powr (of_real y::complex) = of_real (x powr y)\"\n by sorry\n\nlemma powr_of_int:\n fixes z::complex and n::int\n assumes \"z\\(0::complex)\"\n shows \"z powr of_int n = (if n\\0 then z^nat n else inverse (z^nat (-n)))\"\n by sorry\n\nlemma complex_powr_of_int: \"z \\ 0 \\ n \\ 0 \\ z powr of_int n = (z :: complex) powi n\"\n by sorry\n\nlemma powr_of_neg_real:\n fixes x::real and y::real\n assumes \"x<0\"\n shows \"(complex_of_real x) powr (complex_of_real y) = of_real (\\x\\ powr y) * exp (\\ * pi * y)\"\n by sorry\n\nlemma powr_of_real_if:\n fixes x::real and y::real\n shows \"complex_of_real x powr (complex_of_real y) = \n (if x<0 then of_real (\\x\\ powr y) * exp (\\ * pi * y) else of_real (x powr y))\"\n by sorry\n\nlemma powr_Reals_eq: \"\\x \\ \\; y \\ \\; Re x \\ 0\\ \\ x powr y = of_real (Re x powr Re y)\"\n by sorry\n\nlemma norm_powr_real_mono:\n \"\\w \\ \\; 1 < Re w\\ \\ cmod(w powr z1) \\ cmod(w powr z2) \\ Re z1 \\ Re z2\"\n by sorry\n\nlemma powr_times_real:\n \"\\x \\ \\; y \\ \\; 0 \\ Re x; 0 \\ Re y\\ \\ (x * y) powr z = x powr z * y powr z\"\n by sorry\n\nlemma Re_powr_le: \"r \\ \\\\<^sub>\\\\<^sub>0 \\ Re (r powr z) \\ Re r powr Re z\"\n by sorry\n\nlemma\n fixes w::complex\n assumes \"w \\ \\\\<^sub>\\\\<^sub>0\" \"z \\ \\\"\n shows Reals_powr [simp]: \"w powr z \\ \\\" and nonneg_Reals_powr [simp]: \"w powr z \\ \\\\<^sub>\\\\<^sub>0\"\n by sorry\n\nlemma exp_powr_complex:\n fixes x::complex \n assumes \"-pi < Im(x)\" \"Im(x) \\ pi\"\n shows \"exp x powr y = exp (x*y)\"\n by sorry\n\nlemma powr_neg_real_complex:\n fixes w::complex\n shows \"(- of_real x) powr w = (-1) powr (of_real (sgn x) * w) * of_real x powr w\"\n by sorry\n\nlemma has_field_derivative_powr:\n fixes z :: complex\n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"((\\z. z powr s) has_field_derivative (s * z powr (s - 1))) (at z)\"\n by sorry\n\ndeclare has_field_derivative_powr[THEN DERIV_chain2, derivative_intros]\n\nlemma has_field_derivative_powr_of_int:\n fixes z :: complex\n assumes gderiv: \"(g has_field_derivative gd) (at z within S)\" and \"g z \\ 0\"\n shows \"((\\z. g z powr of_int n) has_field_derivative (n * g z powr (of_int n - 1) * gd)) (at z within S)\"\n by sorry\n\nlemma field_differentiable_powr_of_int:\n fixes z :: complex\n assumes \"g field_differentiable (at z within S)\" and \"g z \\ 0\"\n shows \"(\\z. g z powr of_int n) field_differentiable (at z within S)\"\n by sorry\n\nlemma holomorphic_on_powr_of_int [holomorphic_intros]:\n assumes \"f holomorphic_on S\" and \"\\z. z\\S \\ f z \\ 0\"\n shows \"(\\z. (f z) powr of_int n) holomorphic_on S\"\n by sorry\n\nlemma has_field_derivative_powr_right [derivative_intros]:\n \"w \\ 0 \\ ((\\z. w powr z) has_field_derivative Ln w * w powr z) (at z)\"\n by sorry\n\nlemma field_differentiable_powr_right [derivative_intros]:\n fixes w::complex\n shows \"w \\ 0 \\ (\\z. w powr z) field_differentiable (at z)\"\n by sorry\n\nlemma holomorphic_on_powr_right [holomorphic_intros]:\n assumes \"f holomorphic_on S\"\n shows \"(\\z. w powr (f z)) holomorphic_on S\"\n by sorry\n\nlemma holomorphic_on_divide_gen [holomorphic_intros]:\n assumes \"f holomorphic_on S\" \"g holomorphic_on S\" and \"\\z z'. \\z \\ S; z' \\ S\\ \\ g z = 0 \\ g z' = 0\"\n shows \"(\\z. f z / g z) holomorphic_on S\"\n by sorry\n\nlemma tendsto_powr_complex:\n fixes f g :: \"_ \\ complex\"\n assumes a: \"a \\ \\\\<^sub>\\\\<^sub>0\"\n assumes f: \"(f \\ a) F\" and g: \"(g \\ b) F\"\n shows \"((\\z. f z powr g z) \\ a powr b) F\"\n by sorry\n\nlemma tendsto_powr_complex_0:\n fixes f g :: \"'a \\ complex\"\n assumes f: \"(f \\ 0) F\" and g: \"(g \\ b) F\" and b: \"Re b > 0\"\n shows \"((\\z. f z powr g z) \\ 0) F\"\n by sorry\n\nlemma tendsto_powr_complex' [tendsto_intros]:\n fixes f g :: \"_ \\ complex\"\n assumes \"a \\ \\\\<^sub>\\\\<^sub>0 \\ (a = 0 \\ Re b > 0)\" and \"(f \\ a) F\" \"(g \\ b) F\"\n shows \"((\\z. f z powr g z) \\ a powr b) F\"\n by sorry\n\nlemma tendsto_neg_powr_complex_of_real:\n assumes \"filterlim f at_top F\" and \"Re s < 0\"\n shows \"((\\x. complex_of_real (f x) powr s) \\ 0) F\"\n by sorry\n\nlemma tendsto_neg_powr_complex_of_nat:\n assumes \"filterlim f at_top F\" and \"Re s < 0\"\n shows \"((\\x. of_nat (f x) powr s) \\ 0) F\"\n by sorry\n\nlemma continuous_powr_complex [continuous_intros]: \n assumes \"continuous F f\" \"continuous F g\"\n assumes \"Re (f (netlimit F)) \\ 0 \\ Im (f (netlimit F)) \\ 0\"\n assumes \"f (netlimit F) = 0 \\ Re (g (netlimit F)) > 0\"\n shows \"continuous F (\\z. f z powr g z :: complex)\"\n by sorry\n\nlemma continuous_powr_real [continuous_intros]: \n assumes \"continuous F f\" \"continuous F g\"\n assumes \"f (netlimit F) = 0 \\ g (netlimit F) > 0 \\ (\\\\<^sub>F z in F. 0 \\ f z)\"\n shows \"continuous F (\\z. f z powr g z :: real)\"\n by sorry\n\nlemma isCont_powr_complex [continuous_intros]:\n assumes \"f z \\ \\\\<^sub>\\\\<^sub>0\" \"isCont f z\" \"isCont g z\"\n shows \"isCont (\\z. f z powr g z :: complex) z\"\n by sorry\n\nlemma continuous_on_powr_complex [continuous_intros]:\n assumes \"A \\ {z. Re (f z) \\ 0 \\ Im (f z) \\ 0}\"\n assumes \"\\z. z \\ A \\ f z = 0 \\ Re (g z) > 0\"\n assumes \"continuous_on A f\" \"continuous_on A g\"\n shows \"continuous_on A (\\z. f z powr g z)\"\n by sorry\n\nlemma analytic_on_powr [analytic_intros]:\n assumes \"f analytic_on X\" \"g analytic_on X\" \"\\x. x \\ X \\ f x \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"(\\x. f x powr g x) analytic_on X\"\n by sorry\n\nlemma holomorphic_on_powr [holomorphic_intros]:\n assumes \"f holomorphic_on X\" \"g holomorphic_on X\" \"\\x. x \\ X \\ f x \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"(\\x. f x powr g x) holomorphic_on X\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Some Limits involving Logarithms\\\n\nlemma lim_Ln_over_power:\n fixes s::complex\n assumes \"0 < Re s\"\n shows \"(\\n. Ln (of_nat n) / of_nat n powr s) \\ 0\"\n by sorry\n\nlemma lim_Ln_over_n: \"((\\n. Ln(of_nat n) / of_nat n) \\ 0) sequentially\"\n by sorry\n\nlemma lim_ln_over_power:\n fixes s :: real\n assumes \"0 < s\"\n shows \"(\\n. ln (real n) / real n powr s) \\ 0\"\n by sorry\n\nlemma lim_ln_over_n [tendsto_intros]: \"((\\n. ln(real_of_nat n) / of_nat n) \\ 0) sequentially\"\n by sorry\n\nlemma lim_log_over_n [tendsto_intros]:\n \"(\\n. log k n/n) \\ 0\"\n by sorry\n\nlemma lim_1_over_complex_power:\n assumes \"0 < Re s\"\n shows \"(\\n. 1 / of_nat n powr s) \\ 0\"\n by sorry\n\nlemma lim_1_over_real_power:\n fixes s :: real\n assumes \"0 < s\"\n shows \"((\\n. 1 / (of_nat n powr s)) \\ 0) sequentially\"\n by sorry\n\nlemma lim_1_over_Ln: \"(\\n. 1 / Ln (complex_of_nat n)) \\ 0\"\n by sorry\n\nlemma lim_1_over_ln: \"(\\n. 1 / ln (real n)) \\ 0\"\n by sorry\n\nlemma lim_ln1_over_ln: \"(\\n. ln(Suc n) / ln n) \\ 1\"\n by sorry\n\nlemma lim_ln_over_ln1: \"(\\n. ln n / ln(Suc n)) \\ 1\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relation between Square Root and exp/ln, hence its derivative\\\n\nlemma csqrt_exp_Ln:\n assumes \"z \\ 0\"\n shows \"csqrt z = exp(Ln z / 2)\"\n by sorry\n\nlemma csqrt_in_nonpos_Reals_iff [simp]: \"csqrt z \\ \\\\<^sub>\\\\<^sub>0 \\ z = 0\"\n by sorry\n\nlemma Im_csqrt_eq_0_iff: \"Im (csqrt z) = 0 \\ z \\ \\\\<^sub>\\\\<^sub>0\"\n by sorry\n\nlemma csqrt_conv_powr: \"csqrt z = z powr (1/2)\"\n by sorry\n\nlemma csqrt_mult:\n assumes \"Arg z + Arg w \\ {-pi<..pi}\"\n shows \"csqrt (z * w) = csqrt z * csqrt w\"\n by sorry\n\nlemma Arg_csqrt [simp]: \"Arg (csqrt z) = Arg z / 2\"\n by sorry\n\nlemma csqrt_inverse:\n \"z \\ \\\\<^sub>\\\\<^sub>0 \\ csqrt (inverse z) = inverse (csqrt z)\"\n by sorry\n\nlemma cnj_csqrt: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ cnj(csqrt z) = csqrt(cnj z)\"\n by sorry\n\nlemma has_field_derivative_csqrt:\n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"(csqrt has_field_derivative inverse(2 * csqrt z)) (at z)\"\n by sorry\n\nlemma has_field_derivative_csqrt' [derivative_intros]:\n assumes \"(f has_field_derivative f') (at x within A)\" \"f x \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"((\\x. csqrt (f x)) has_field_derivative (f' / (2 * csqrt (f x)))) (at x within A)\"\n by sorry\n\nlemma field_differentiable_at_csqrt:\n \"z \\ \\\\<^sub>\\\\<^sub>0 \\ csqrt field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_csqrt:\n \"z \\ \\\\<^sub>\\\\<^sub>0 \\ csqrt field_differentiable (at z within s)\"\n by sorry\n\nlemma continuous_at_csqrt:\n \"z \\ \\\\<^sub>\\\\<^sub>0 \\ continuous (at z) csqrt\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ isCont_csqrt' [simp]:\n \"\\isCont f z; f z \\ \\\\<^sub>\\\\<^sub>0\\ \\ isCont (\\x. csqrt (f x)) z\"\n by sorry\n\nlemma continuous_within_csqrt:\n \"z \\ \\\\<^sub>\\\\<^sub>0 \\ continuous (at z within s) csqrt\"\n by sorry\n\nlemma continuous_on_csqrt [continuous_intros]:\n \"continuous_on (-\\\\<^sub>\\\\<^sub>0) csqrt\"\n by sorry\n\nlemma holomorphic_on_csqrt [holomorphic_intros]: \"csqrt holomorphic_on -\\\\<^sub>\\\\<^sub>0\"\n by sorry\n\nlemma holomorphic_on_csqrt' [holomorphic_intros]:\n \"f holomorphic_on A \\ (\\z. z \\ A \\ f z \\ \\\\<^sub>\\\\<^sub>0) \\ (\\z. csqrt (f z)) holomorphic_on A\"\n by sorry\n\nlemma analytic_on_csqrt [analytic_intros]: \"csqrt analytic_on -\\\\<^sub>\\\\<^sub>0\"\n by sorry\n\nlemma analytic_on_csqrt' [analytic_intros]:\n \"f analytic_on A \\ (\\z. z \\ A \\ f z \\ \\\\<^sub>\\\\<^sub>0) \\ (\\z. csqrt (f z)) analytic_on A\"\n by sorry\n\nlemma continuous_within_closed_nontrivial:\n \"closed s \\ a \\ s ==> continuous (at a within s) f\"\n by sorry\n\nlemma continuous_within_csqrt_posreal:\n \"continuous (at z within (\\ \\ {w. 0 \\ Re(w)})) csqrt\"\n by sorry\n\nsubsection\\Complex arctangent\\\n\ntext\\The branch cut gives standard bounds in the real case.\\\n\ndefinition\\<^marker>\\tag important\\ Arctan :: \"complex \\ complex\" where\n \"Arctan \\ \\z. (\\/2) * Ln((1 - \\*z) / (1 + \\*z))\"\n\nlemma Arctan_def_moebius: \"Arctan z = \\/2 * Ln (moebius (-\\) 1 \\ 1 z)\"\n by sorry\n\nlemma Ln_conv_Arctan:\n assumes \"z \\ -1\"\n shows \"Ln z = -2*\\ * Arctan (moebius 1 (- 1) (- \\) (- \\) z)\"\n by sorry\n\nlemma Arctan_0 [simp]: \"Arctan 0 = 0\"\n by sorry\n\nlemma Im_complex_div_lemma: \"Im((1 - \\*z) / (1 + \\*z)) = 0 \\ Re z = 0\"\n by sorry\n\nlemma Re_complex_div_lemma: \"0 < Re((1 - \\*z) / (1 + \\*z)) \\ norm z < 1\"\n by sorry\n\nlemma tan_Arctan:\n assumes \"z\\<^sup>2 \\ -1\"\n shows [simp]: \"tan(Arctan z) = z\"\n by sorry\n\nlemma Arctan_tan [simp]:\n assumes \"\\Re z\\ < pi/2\"\n shows \"Arctan(tan z) = z\"\n by sorry\n\nlemma\n assumes \"Re z = 0 \\ \\Im z\\ < 1\"\n shows Re_Arctan_bounds: \"\\Re(Arctan z)\\ < pi/2\"\n and has_field_derivative_Arctan: \"(Arctan has_field_derivative inverse(1 + z\\<^sup>2)) (at z)\"\n by sorry\n\nlemma field_differentiable_at_Arctan: \"(Re z = 0 \\ \\Im z\\ < 1) \\ Arctan field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_Arctan:\n \"(Re z = 0 \\ \\Im z\\ < 1) \\ Arctan field_differentiable (at z within s)\"\n by sorry\n\ndeclare has_field_derivative_Arctan [derivative_intros]\ndeclare has_field_derivative_Arctan [THEN DERIV_chain2, derivative_intros]\n\nlemma continuous_at_Arctan:\n \"(Re z = 0 \\ \\Im z\\ < 1) \\ continuous (at z) Arctan\"\n by sorry\n\nlemma continuous_within_Arctan:\n \"(Re z = 0 \\ \\Im z\\ < 1) \\ continuous (at z within s) Arctan\"\n by sorry\n\nlemma continuous_on_Arctan [continuous_intros]:\n \"(\\z. z \\ s \\ Re z = 0 \\ \\Im z\\ < 1) \\ continuous_on s Arctan\"\n by sorry\n\nlemma holomorphic_on_Arctan:\n \"(\\z. z \\ s \\ Re z = 0 \\ \\Im z\\ < 1) \\ Arctan holomorphic_on s\"\n by sorry\n\ntheorem Arctan_series:\n assumes z: \"norm (z :: complex) < 1\"\n defines \"g \\ \\n. if odd n then -\\*\\^n / n else 0\"\n defines \"h \\ \\z n. (-1)^n / of_nat (2*n+1) * (z::complex)^(2*n+1)\"\n shows \"(\\n. g n * z^n) sums Arctan z\"\n and \"h z sums Arctan z\"\n by sorry\n\ntext \\A quickly-converging series for the logarithm, based on the arctangent.\\\ntheorem ln_series_quadratic:\n assumes x: \"x > (0::real)\"\n shows \"(\\n. (2*((x - 1) / (x + 1)) ^ (2*n+1) / of_nat (2*n+1))) sums ln x\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Real arctangent\\\n\nlemma Im_Arctan_of_real [simp]: \"Im (Arctan (of_real x)) = 0\"\n by sorry\n\nlemma arctan_eq_Re_Arctan: \"arctan x = Re (Arctan (of_real x))\"\n by sorry\n\nlemma Arctan_of_real: \"Arctan (of_real x) = of_real (arctan x)\"\n by sorry\n\nlemma Arctan_in_Reals [simp]: \"z \\ \\ \\ Arctan z \\ \\\"\n by sorry\n\ndeclare arctan_one [simp]\n\nlemma arctan_less_pi4_pos: \"x < 1 \\ arctan x < pi/4\"\n by sorry\n\nlemma arctan_less_pi4_neg: \"-1 < x \\ -(pi/4) < arctan x\"\n by sorry\n\nlemma arctan_less_pi4: \"\\x\\ < 1 \\ \\arctan x\\ < pi/4\"\n by sorry\n\nlemma arctan_le_pi4: \"\\x\\ \\ 1 \\ \\arctan x\\ \\ pi/4\"\n by sorry\n\nlemma abs_arctan: \"\\arctan x\\ = arctan \\x\\\"\n by sorry\n\nlemma arctan_add_raw:\n assumes \"\\arctan x + arctan y\\ < pi/2\"\n shows \"arctan x + arctan y = arctan((x + y) / (1 - x * y))\"\n by sorry\n\nlemma arctan_inverse:\n \"0 < x \\arctan(inverse x) = pi/2 - arctan x\"\n by sorry\n\nlemma arctan_add_small:\n assumes \"\\x * y\\ < 1\"\n shows \"(arctan x + arctan y = arctan((x + y) / (1 - x * y)))\"\n by sorry\n\nlemma abs_arctan_le:\n fixes x::real shows \"\\arctan x\\ \\ \\x\\\"\n by sorry\n\nlemma arctan_le_self: \"0 \\ x \\ arctan x \\ x\"\n by sorry\n\nlemma abs_tan_ge: \"\\x\\ < pi/2 \\ \\x\\ \\ \\tan x\\\"\n by sorry\n\nlemma arctan_bounds:\n assumes \"0 \\ x\" \"x < 1\"\n shows arctan_lower_bound:\n \"(\\k<2 * n. (- 1) ^ k * (1 / real (k * 2 + 1) * x ^ (k * 2 + 1))) \\ arctan x\" (is \"(\\k<_. _ * ?a k) \\ _\")\n and arctan_upper_bound:\n \"arctan x \\ (\\k<2 * n + 1. (- 1) ^ k * (1 / real (k * 2 + 1) * x ^ (k * 2 + 1)))\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Bounds on pi using real arctangent\\\n\nlemma pi_machin: \"pi = 16 * arctan (1 / 5) - 4 * arctan (1 / 239)\"\n by sorry\n\nlemma pi_approx: \"3.141592653588 \\ pi\" \"pi \\ 3.1415926535899\"\n by sorry\n\nlemma pi_gt3: \"pi > 3\"\n by sorry\n\nsubsection\\Inverse Sine\\\n\ndefinition\\<^marker>\\tag important\\ Arcsin :: \"complex \\ complex\" where\n \"Arcsin \\ \\z. -\\ * Ln(\\ * z + csqrt(1 - z\\<^sup>2))\"\n\nlemma Arcsin_body_lemma: \"\\ * z + csqrt(1 - z\\<^sup>2) \\ 0\"\n by sorry\n\nlemma Arcsin_range_lemma: \"\\Re z\\ < 1 \\ 0 < Re(\\ * z + csqrt(1 - z\\<^sup>2))\"\n by sorry\n\nlemma Re_Arcsin: \"Re(Arcsin z) = Im (Ln (\\ * z + csqrt(1 - z\\<^sup>2)))\"\n by sorry\n\nlemma Im_Arcsin: \"Im(Arcsin z) = - ln (cmod (\\ * z + csqrt (1 - z\\<^sup>2)))\"\n by sorry\n\nlemma one_minus_z2_notin_nonpos_Reals:\n assumes \"Im z = 0 \\ \\Re z\\ < 1\"\n shows \"1 - z\\<^sup>2 \\ \\\\<^sub>\\\\<^sub>0\"\n by sorry\n\nlemma isCont_Arcsin_lemma:\n assumes le0: \"Re (\\ * z + csqrt (1 - z\\<^sup>2)) \\ 0\" and \"(Im z = 0 \\ \\Re z\\ < 1)\"\n shows False\n by sorry\n\nlemma isCont_Arcsin:\n assumes \"(Im z = 0 \\ \\Re z\\ < 1)\"\n shows \"isCont Arcsin z\"\n by sorry\n\nlemma isCont_Arcsin' [simp]:\n shows \"isCont f z \\ (Im (f z) = 0 \\ \\Re (f z)\\ < 1) \\ isCont (\\x. Arcsin (f x)) z\"\n by sorry\n\nlemma sin_Arcsin [simp]: \"sin(Arcsin z) = z\"\n by sorry\n\nlemma Re_eq_pihalf_lemma:\n \"\\Re z\\ = pi/2 \\ Im z = 0 \\\n Re ((exp (\\*z) + inverse (exp (\\*z))) / 2) = 0 \\ 0 \\ Im ((exp (\\*z) + inverse (exp (\\*z))) / 2)\"\n by sorry\n\nlemma Re_less_pihalf_lemma:\n assumes \"\\Re z\\ < pi / 2\"\n shows \"0 < Re ((exp (\\*z) + inverse (exp (\\*z))) / 2)\"\n by sorry\n\nlemma Arcsin_sin:\n assumes \"\\Re z\\ < pi/2 \\ (\\Re z\\ = pi/2 \\ Im z = 0)\"\n shows \"Arcsin(sin z) = z\"\n by sorry\n\nlemma Arcsin_unique:\n \"\\sin z = w; \\Re z\\ < pi/2 \\ (\\Re z\\ = pi/2 \\ Im z = 0)\\ \\ Arcsin w = z\"\n by sorry\n\nlemma Arcsin_0 [simp]: \"Arcsin 0 = 0\"\n by sorry\n\nlemma Arcsin_1 [simp]: \"Arcsin 1 = pi/2\"\n by sorry\n\nlemma Arcsin_minus_1 [simp]: \"Arcsin(-1) = - (pi/2)\"\n by sorry\n\nlemma has_field_derivative_Arcsin:\n assumes \"Im z = 0 \\ \\Re z\\ < 1\"\n shows \"(Arcsin has_field_derivative inverse(cos(Arcsin z))) (at z)\"\n by sorry\n\ndeclare has_field_derivative_Arcsin [derivative_intros]\ndeclare has_field_derivative_Arcsin [THEN DERIV_chain2, derivative_intros]\n\nlemma field_differentiable_at_Arcsin:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ Arcsin field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_Arcsin:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ Arcsin field_differentiable (at z within s)\"\n by sorry\n\nlemma continuous_within_Arcsin:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ continuous (at z within s) Arcsin\"\n by sorry\n\nlemma continuous_on_Arcsin [continuous_intros]:\n \"(\\z. z \\ s \\ Im z = 0 \\ \\Re z\\ < 1) \\ continuous_on s Arcsin\"\n by sorry\n\nlemma holomorphic_on_Arcsin: \"(\\z. z \\ s \\ Im z = 0 \\ \\Re z\\ < 1) \\ Arcsin holomorphic_on s\"\n by sorry\n\nsubsection\\Inverse Cosine\\\n\ndefinition\\<^marker>\\tag important\\ Arccos :: \"complex \\ complex\" where\n \"Arccos \\ \\z. -\\ * Ln(z + \\ * csqrt(1 - z\\<^sup>2))\"\n\nlemma Arccos_range_lemma: \"\\Re z\\ < 1 \\ 0 < Im(z + \\ * csqrt(1 - z\\<^sup>2))\"\n by sorry\n\nlemma Arccos_body_lemma: \"z + \\ * csqrt(1 - z\\<^sup>2) \\ 0\"\n by sorry\n\nlemma Re_Arccos: \"Re(Arccos z) = Im (Ln (z + \\ * csqrt(1 - z\\<^sup>2)))\"\n by sorry\n\nlemma Im_Arccos: \"Im(Arccos z) = - ln (cmod (z + \\ * csqrt (1 - z\\<^sup>2)))\"\n by sorry\n\ntext\\A very tricky argument to find!\\\nlemma isCont_Arccos_lemma:\n assumes eq0: \"Im (z + \\ * csqrt (1 - z\\<^sup>2)) = 0\" and \"Im z = 0 \\ \\Re z\\ < 1\"\n shows False\n by sorry\n\nlemma isCont_Arccos:\n assumes \"(Im z = 0 \\ \\Re z\\ < 1)\"\n shows \"isCont Arccos z\"\n by sorry\n\nlemma isCont_Arccos' [simp]:\n \"isCont f z \\ (Im (f z) = 0 \\ \\Re (f z)\\ < 1) \\ isCont (\\x. Arccos (f x)) z\"\n by sorry\n\nlemma cos_Arccos [simp]: \"cos(Arccos z) = z\"\n by sorry\n\nlemma Arccos_cos:\n assumes \"0 < Re z \\ Re z < pi \\\n Re z = 0 \\ 0 \\ Im z \\\n Re z = pi \\ Im z \\ 0\"\n shows \"Arccos(cos z) = z\"\n by sorry\n\nlemma Arccos_unique:\n \"\\cos z = w;\n 0 < Re z \\ Re z < pi \\\n Re z = 0 \\ 0 \\ Im z \\\n Re z = pi \\ Im z \\ 0\\ \\ Arccos w = z\"\n by sorry\n\nlemma Arccos_0 [simp]: \"Arccos 0 = pi/2\"\n by sorry\n\nlemma Arccos_1 [simp]: \"Arccos 1 = 0\"\n by sorry\n\nlemma Arccos_minus1: \"Arccos(-1) = pi\"\n by sorry\n\nlemma has_field_derivative_Arccos:\n assumes \"(Im z = 0 \\ \\Re z\\ < 1)\"\n shows \"(Arccos has_field_derivative - inverse(sin(Arccos z))) (at z)\"\n by sorry\n\ndeclare has_field_derivative_Arcsin [derivative_intros]\ndeclare has_field_derivative_Arcsin [THEN DERIV_chain2, derivative_intros]\n\nlemma field_differentiable_at_Arccos:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ Arccos field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_Arccos:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ Arccos field_differentiable (at z within s)\"\n by sorry\n\nlemma continuous_within_Arccos:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ continuous (at z within s) Arccos\"\n by sorry\n\nlemma continuous_on_Arccos [continuous_intros]:\n \"(\\z. z \\ s \\ Im z = 0 \\ \\Re z\\ < 1) \\ continuous_on s Arccos\"\n by sorry\n\nlemma holomorphic_on_Arccos: \"(\\z. z \\ s \\ Im z = 0 \\ \\Re z\\ < 1) \\ Arccos holomorphic_on s\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Upper and Lower Bounds for Inverse Sine and Cosine\\\n\nlemma Arcsin_bounds: \"\\Re z\\ < 1 \\ \\Re(Arcsin z)\\ < pi/2\"\n by sorry\n\nlemma Arccos_bounds: \"\\Re z\\ < 1 \\ 0 < Re(Arccos z) \\ Re(Arccos z) < pi\"\n by sorry\n\nlemma Re_Arccos_bounds: \"-pi < Re(Arccos z) \\ Re(Arccos z) \\ pi\"\n by sorry\n\nlemma Re_Arccos_bound: \"\\Re(Arccos z)\\ \\ pi\"\n by sorry\n\nlemma Im_Arccos_bound: \"\\Im (Arccos w)\\ \\ cmod w\"\n by sorry\n\nlemma Re_Arcsin_bounds: \"-pi < Re(Arcsin z) & Re(Arcsin z) \\ pi\"\n by sorry\n\nlemma Re_Arcsin_bound: \"\\Re(Arcsin z)\\ \\ pi\"\n by sorry\n\nlemma norm_Arccos_bounded:\n fixes w :: complex\n shows \"norm (Arccos w) \\ pi + norm w\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Interrelations between Arcsin and Arccos\\\n\nlemma cos_Arcsin_nonzero: \"z\\<^sup>2 \\ 1 \\cos(Arcsin z) \\ 0\"\n by sorry\n\nlemma sin_Arccos_nonzero: \"z\\<^sup>2 \\ 1 \\sin(Arccos z) \\ 0\"\n by sorry\n\nlemma cos_sin_csqrt:\n assumes \"0 < cos(Re z) \\ cos(Re z) = 0 \\ Im z * sin(Re z) \\ 0\"\n shows \"cos z = csqrt(1 - (sin z)\\<^sup>2)\"\n by sorry\n\nlemma sin_cos_csqrt:\n assumes \"0 < sin(Re z) \\ sin(Re z) = 0 \\ 0 \\ Im z * cos(Re z)\"\n shows \"sin z = csqrt(1 - (cos z)\\<^sup>2)\"\n by sorry\n\nlemma Arcsin_Arccos_csqrt_pos:\n \"(0 < Re z \\ Re z = 0 \\ 0 \\ Im z) \\ Arcsin z = Arccos(csqrt(1 - z\\<^sup>2))\"\n by sorry\n\nlemma Arccos_Arcsin_csqrt_pos:\n \"(0 < Re z \\ Re z = 0 \\ 0 \\ Im z) \\ Arccos z = Arcsin(csqrt(1 - z\\<^sup>2))\"\n by sorry\n\nlemma sin_Arccos:\n \"0 < Re z \\ Re z = 0 \\ 0 \\ Im z \\ sin(Arccos z) = csqrt(1 - z\\<^sup>2)\"\n by sorry\n\nlemma cos_Arcsin:\n \"0 < Re z \\ Re z = 0 \\ 0 \\ Im z \\ cos(Arcsin z) = csqrt(1 - z\\<^sup>2)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relationship with Arcsin on the Real Numbers\\\n\nlemma of_real_arcsin: \"\\x\\ \\ 1 \\ of_real(arcsin x) = Arcsin(of_real x)\"\n by sorry\n\nlemma Im_Arcsin_of_real: \"\\x\\ \\ 1 \\ Im (Arcsin (of_real x)) = 0\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Arcsin_in_Reals [simp]: \"z \\ \\ \\ \\Re z\\ \\ 1 \\ Arcsin z \\ \\\"\n by sorry\n\nlemma arcsin_eq_Re_Arcsin: \"\\x\\ \\ 1 \\ arcsin x = Re (Arcsin (of_real x))\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relationship with Arccos on the Real Numbers\\\n\nlemma of_real_arccos: \"\\x\\ \\ 1 \\ of_real(arccos x) = Arccos(of_real x)\"\n by sorry\n\nlemma Im_Arccos_of_real: \"\\x\\ \\ 1 \\ Im (Arccos (of_real x)) = 0\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Arccos_in_Reals [simp]: \"z \\ \\ \\ \\Re z\\ \\ 1 \\ Arccos z \\ \\\"\n by sorry\n\nlemma arccos_eq_Re_Arccos: \"\\x\\ \\ 1 \\ arccos x = Re (Arccos (of_real x))\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Continuity results for arcsin and arccos\\\n\nlemma continuous_on_Arcsin_real [continuous_intros]:\n \"continuous_on {w \\ \\. \\Re w\\ \\ 1} Arcsin\"\n by sorry\n\nlemma continuous_within_Arcsin_real:\n \"continuous (at z within {w \\ \\. \\Re w\\ \\ 1}) Arcsin\"\n by sorry\n\nlemma continuous_on_Arccos_real:\n \"continuous_on {w \\ \\. \\Re w\\ \\ 1} Arccos\"\n by sorry\n\nlemma continuous_within_Arccos_real:\n \"continuous (at z within {w \\ \\. \\Re w\\ \\ 1}) Arccos\"\n by sorry\n\nlemma sinh_ln_complex: \"x \\ 0 \\ sinh (ln x :: complex) = (x - inverse x) / 2\"\n by sorry\n\nlemma cosh_ln_complex: \"x \\ 0 \\ cosh (ln x :: complex) = (x + inverse x) / 2\"\n by sorry\n\nlemma tanh_ln_complex: \"x \\ 0 \\ tanh (ln x :: complex) = (x ^ 2 - 1) / (x ^ 2 + 1)\"\n by sorry\n\nsubsection\\Roots of unity\\\n\ntheorem complex_root_unity:\n fixes j::nat\n assumes \"n \\ 0\"\n shows \"exp(2 * of_real pi * \\ * of_nat j / of_nat n)^n = 1\"\n by sorry\n\nlemma complex_root_unity_eq:\n fixes j::nat and k::nat\n assumes \"1 \\ n\"\n shows \"(exp(2 * of_real pi * \\ * of_nat j / of_nat n) = exp(2 * of_real pi * \\ * of_nat k / of_nat n)\n \\ j mod n = k mod n)\"\n by sorry\n\ncorollary bij_betw_roots_unity:\n \"bij_betw (\\j. exp(2 * of_real pi * \\ * of_nat j / of_nat n))\n {.. * of_nat j / of_nat n) | j. j < n}\"\n by sorry\n\nlemma complex_root_unity_eq_1:\n fixes j::nat and k::nat\n assumes \"1 \\ n\"\n shows \"exp(2 * of_real pi * \\ * of_nat j / of_nat n) = 1 \\ n dvd j\"\n by sorry\n\nlemma finite_complex_roots_unity_explicit:\n \"finite {exp(2 * of_real pi * \\ * of_nat j / of_nat n) | j::nat. j < n}\"\n by sorry\n\nlemma card_complex_roots_unity_explicit:\n \"card {exp(2 * of_real pi * \\ * of_nat j / of_nat n) | j::nat. j < n} = n\"\n by sorry\n\nlemma complex_roots_unity:\n assumes \"1 \\ n\"\n shows \"{z::complex. z^n = 1} = {exp(2 * of_real pi * \\ * of_nat j / of_nat n) | j. j < n}\"\n by sorry\n\nlemma card_complex_roots_unity: \"1 \\ n \\ card {z::complex. z^n = 1} = n\"\n by sorry\n\nlemma complex_not_root_unity:\n \"1 \\ n \\ \\u::complex. norm u = 1 \\ u^n \\ 1\"\n by sorry\n\nsubsection \\Normalisation of angles\\\n\ntext \\\n The following operation normalises an angle $\\varphi$, i.e.\\ returns the unique\n $\\psi$ in the range $(-\\pi, \\pi]$ such that\n $\\varphi\\equiv\\psi\\hskip.5em(\\text{mod}\\ 2\\pi)$.\n This is the same convention used by the \\<^const>\\Arg\\ function.\n\\\ndefinition normalize_angle :: \"real \\ real\" where\n \"normalize_angle x = x - \\x / (2 * pi) - 1 / 2\\ * (2 * pi)\"\n\nlemma normalize_angle_id [simp]:\n assumes \"x \\ {-pi<..pi}\"\n shows \"normalize_angle x = x\"\n by sorry\n\nlemma normalize_angle_normalized: \"normalize_angle x \\ {-pi<..pi}\"\n by sorry\n\nlemma cis_normalize_angle [simp]: \"cis (normalize_angle x) = cis x\"\n by sorry\n\nlemma rcis_normalize_angle [simp]: \"rcis r (normalize_angle x) = rcis r x\"\n by sorry\n\nlemma normalize_angle_lbound [intro]: \"normalize_angle x > -pi\"\n and normalize_angle_ubound [intro]: \"normalize_angle x \\ pi\"\n by sorry\n\nlemma normalize_angle_idem [simp]: \"normalize_angle (normalize_angle x) = normalize_angle x\"\n by sorry\n\nlemma Arg_rcis': \"r > 0 \\ Arg (rcis r \\) = normalize_angle \\\"\n by sorry\n\nsubsection \\Convexity of circular sectors in the complex plane\\\n\ntext \\\n In this section we will show that if we have two non-zero points $w$ and $z$ in the complex plane\n whose arguments differ by less than $\\pi$, then the argument of any point on the line connecting\n $w$ and $z$ lies between the arguments of $w$ and $z$. Moreover, the norm of any such point is\n no greater than the norms of $w$ and $z$.\n\n Geometrically, this means that if we have a sector around the origin with a central angle\n less than $\\pi$ (minus the origin itself) then that region is convex.\n\\\n\nlemma Arg_closed_segment_aux1:\n assumes \"x \\ 0\" \"y \\ 0\" \"Re x > 0\" \"Re x = Re y\"\n assumes \"z \\ closed_segment x y\"\n shows \"Arg z \\ closed_segment (Arg x) (Arg y)\"\n by sorry\n\nlemma Arg_closed_segment_aux1':\n fixes r1 r2 \\1 \\2 :: real\n defines \"x \\ rcis r1 \\1\" and \"y \\ rcis r2 \\2\"\n assumes \"z \\ closed_segment x y\"\n assumes \"r1 > 0\" \"r2 > 0\" \"Re x = Re y\" \"Re x \\ 0\" \"Re x = 0 \\ Im x * Im y > 0\"\n assumes \"dist \\1 \\2 < pi\"\n obtains r \\ where \"r \\ {0<..max r1 r2}\" \"\\ \\ closed_segment \\1 \\2\" \"z = rcis r \\\"\n by sorry\n\nlemma Arg_closed_segment':\n fixes r1 r2 \\1 \\2 :: real\n defines \"x \\ rcis r1 \\1\" and \"y \\ rcis r2 \\2\"\n assumes \"r1 > 0\" \"r2 > 0\" \"dist \\1 \\2 < pi\" \"z \\ closed_segment x y\"\n obtains r \\ where \"r \\ {0<..max r1 r2}\" \"\\ \\ closed_segment \\1 \\2\" \"z = rcis r \\\"\n by sorry\n\nlemma Arg_closed_segment:\n assumes \"x \\ 0\" \"y \\ 0\" \"dist (Arg x) (Arg y) < pi\" \"z \\ closed_segment x y\"\n shows \"Arg z \\ closed_segment (Arg x) (Arg y)\"\n by sorry\n\nsubsection \\Complex cones\\\n\ntext \\\n We introduce the following notation to describe the set of all complex numbers of the form\n $c e^{ix}$ where $c\\geq 0$ and $x\\in [a, b]$.\n\\\ndefinition complex_cone :: \"real \\ real \\ complex set\" where\n \"complex_cone a b = (\\(r,a). rcis r a) ` ({0..} \\ closed_segment a b)\"\n\nlemma in_complex_cone_iff: \"z \\ complex_cone a b \\ (\\x\\closed_segment a b. z = rcis (norm z) x)\"\n by sorry\n\nlemma zero_in_complex_cone [simp, intro]: \"0 \\ complex_cone a b\"\n by sorry\n\nlemma in_complex_cone_iff_Arg: \n assumes \"a \\ {-pi<..pi}\" \"b \\ {-pi<..pi}\"\n shows \"z \\ complex_cone a b \\ z = 0 \\ Arg z \\ closed_segment a b\"\n by sorry\n\nlemma complex_cone_rotate: \"complex_cone (c + a) (c + b) = " }, { "theorem_id": 31, "title": "026_leibniz_s_series_for_pi", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Benjamin Davidson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Benjamin Davidson, Jeremy Tan\n-/\nmodule\n\npublic import Mathlib.Analysis.Complex.AbelLimit\npublic import Mathlib.Analysis.SpecialFunctions.Complex.Arctan\n\n/-! ### Leibniz's series for `π` -/\n\npublic section\n\nnamespace Real\n\nopen Filter Finset\n\nopen scoped Topology\n\n/-- **Leibniz's series for `π`**. The alternating sum of odd number reciprocals is `π / 4`,\nproved by using Abel's limit theorem to extend the Maclaurin series of `arctan` to 1. -/\ntheorem tendsto_sum_pi_div_four :\n Tendsto (fun k => ∑ i ∈ range k, (-1 : ℝ) ^ i / (2 * i + 1)) atTop (𝓝 (π / 4)) := by sorry\nend Real\n" }, { "theorem_id": 31, "title": "026_leibniz_s_series_for_pi", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From Stdlib Require Import Lra.\nFrom Stdlib Require Import Rbase.\nFrom Stdlib Require Import PSeries_reg.\nFrom Stdlib Require Import Rtrigo1.\nFrom Stdlib Require Import Rtrigo_facts.\nFrom Stdlib Require Import Ranalysis_reg.\nFrom Stdlib Require Import Rfunctions.\nFrom Stdlib Require Import AltSeries.\nFrom Stdlib Require Import Rseries.\nFrom Stdlib Require Import SeqProp.\nFrom Stdlib Require Import Ranalysis5.\nFrom Stdlib Require Import SeqSeries.\nFrom Stdlib Require Import PartSum.\nFrom Stdlib Require Import Lia.\nFrom Stdlib Require Import Znat.\n\n#[local] Open Scope R_scope.\n#[local] Ltac Tauto.intuition_solver ::= auto with rorders real arith.\n\nLemma Boule_half_to_interval : forall x,\n Boule (/2) posreal_half x -> 0 <= x <= 1.\nProof.\nAdmitted.\n\nLemma ub_opp : forall x, x < PI/2 -> -PI/2 < -x.\nProof.\nAdmitted.\n\nDefinition atan x := let (v, _) := pre_atan x in v.\n\nLemma atan_bound : forall x,\n -PI/2 < atan x < PI/2.\nProof.\nAdmitted.\n\nLemma Ratan_seq_opp : forall x n,\n Ratan_seq (-x) n = -Ratan_seq x n.\nProof.\nAdmitted.\n\nDefinition in_int (x : R) : {-1 <= x <= 1}+{~ -1 <= x <= 1}.\nProof.\nAdmitted.\n\nDefinition ps_atan (x : R) : R :=\n match in_int x with\n left h => let (v, _) := ps_atan_exists_1 x h in v\n | right h => atan x\n end.\n\nLemma ps_atan0_0 : ps_atan 0 = 0.\nProof.\nAdmitted.\n\nLemma ps_atan_exists_1_opp : forall x h h',\n proj1_sig (ps_atan_exists_1 (-x) h) = -(proj1_sig (ps_atan_exists_1 x h')).\nProof.\nAdmitted.\n\nLemma ps_atan_opp : forall x,\n ps_atan (-x) = -ps_atan x.\nProof.\nAdmitted.\n\nLemma ps_atanSeq_continuity_pt_1 : forall (N : nat) (x : R),\n 0 <= x -> x <= 1 ->\n continuity_pt (fun x => sum_f_R0 (tg_alt (Ratan_seq x)) N) x.\nProof.\nAdmitted.\n\nDefinition Datan_seq := fun (x : R) (n : nat) => x ^ (2*n).\n\nLemma pow_lt_1_compat : forall x n,\n 0 <= x < 1 -> (0 < n)%nat ->\n 0 <= x ^ n < 1.\nProof.\nAdmitted.\n\nLemma Datan_seq_Rabs : forall x n,\n Datan_seq (Rabs x) n = Datan_seq x n.\nProof.\nAdmitted.\n\nLemma Datan_seq_pos : forall x n, 0 < x ->\n 0 < Datan_seq x n.\nProof.\nAdmitted.\n\nLemma Datan_sum_eq :forall x n,\n sum_f_R0 (tg_alt (Datan_seq x)) n = (1 - (- x ^ 2) ^ S n)/(1 + x ^ 2).\nProof.\nAdmitted.\n\nLemma Datan_seq_increasing : forall x y n,\n (n > 0)%nat -> 0 <= x < y ->\n Datan_seq x n < Datan_seq y n.\nProof.\nAdmitted.\n\nLemma Datan_seq_decreasing : forall x, -1 < x -> x < 1 ->\n Un_decreasing (Datan_seq x).\nProof.\nAdmitted.\n\nLemma Datan_seq_CV_0 : forall x, -1 < x -> x < 1 ->\n Un_cv (Datan_seq x) 0.\nProof.\nAdmitted.\n\nLemma Datan_lim : forall x, -1 < x -> x < 1 ->\n Un_cv (fun N : nat => sum_f_R0 (tg_alt (Datan_seq x)) N) (/ (1 + x ^ 2)).\nProof.\nAdmitted.\n\nLemma Datan_CVU_prelim : forall c (r : posreal), Rabs c + r < 1 ->\n CVU (fun N x => sum_f_R0 (tg_alt (Datan_seq x)) N)\n (fun y : R => / (1 + y ^ 2)) c r.\nProof.\nAdmitted.\n\nLemma Datan_is_datan : forall (N : nat) (x : R),\n -1 <= x -> x < 1 ->\n derivable_pt_lim (fun x => sum_f_R0 (tg_alt (Ratan_seq x)) N) x (sum_f_R0 (tg_alt (Datan_seq x)) N).\nProof.\nAdmitted.\n\nLemma Ratan_CVU' :\n CVU (fun N x => sum_f_R0 (tg_alt (Ratan_seq x)) N)\n ps_atan (/2) posreal_half.\nProof.\nAdmitted.\n\nLemma Ratan_CVU :\n CVU (fun N x => sum_f_R0 (tg_alt (Ratan_seq x)) N)\n ps_atan 0 (mkposreal 1 Rlt_0_1).\nProof.\nAdmitted.\n\nLemma Alt_PI_tg : forall n, PI_tg n = Ratan_seq 1 n.\nProof.\nAdmitted.\n\nLemma Ratan_is_ps_atan : forall eps, eps > 0 ->\n exists N, forall n, (n >= N)%nat -> forall x, -1 < x -> x < 1 ->\n Rabs (sum_f_R0 (tg_alt (Ratan_seq x)) n - ps_atan x) < eps.\nProof.\nAdmitted.\n\nLemma Datan_continuity : continuity (fun x => /(1 + x^2)).\nProof.\nAdmitted.\n\nLemma derivable_pt_lim_ps_atan : forall x, -1 < x < 1 ->\n derivable_pt_lim ps_atan x ((fun y => /(1 + y ^ 2)) x).\nProof.\nAdmitted.\n\nLemma derivable_pt_ps_atan : forall x, -1 < x < 1 ->\n derivable_pt ps_atan x.\nProof.\nAdmitted.\n\nLemma ps_atan_continuity_pt_1 : forall eps : R,\n eps > 0 ->\n exists alp : R, alp > 0 /\\ (forall x, x < 1 -> 0 < x -> Rdist x 1 < alp ->\n dist R_met (ps_atan x) (Alt_PI/4) < eps).\nProof.\nAdmitted.\n\nLemma Datan_eq_DatanSeq_interv : forall x, -1 < x < 1 ->\n forall (Pratan:derivable_pt ps_atan x) (Prmymeta:derivable_pt atan x),\n derive_pt ps_atan x Pratan = derive_pt atan x Prmymeta.\nProof.\nAdmitted.\n\nLemma atan_eq_ps_atan : forall x, 0 < x < 1 ->\n atan x = ps_atan x.\nProof.\nAdmitted.\n\nTheorem Alt_PI_eq : Alt_PI = PI.\nProof.\nAdmitted.\n\nLemma PI_ineq : forall N : nat,\n sum_f_R0 (tg_alt PI_tg) (S (2 * N)) <= PI/4 <= sum_f_R0 (tg_alt PI_tg) (2 * N).\nProof.\nAdmitted.\n\nLemma sin_atan: forall x,\n sin (atan x) = x / sqrt (1 + x²).\nProof.\nAdmitted.\n\nLemma cos_atan: forall x,\n cos (atan x) = 1 / sqrt(1 + x²).\nProof.\nAdmitted.\n\nDefinition asin x :=\n if Rle_dec x (-1) then - (PI / 2) else\n if Rle_dec 1 x then PI / 2 else\n atan (x / sqrt (1 - x²)).\n\nLemma asin_atan : forall x, -1 < x < 1 ->\n asin x = atan (x / sqrt (1 - x²)).\nProof.\nAdmitted.\n\nLemma asin_0 : asin 0 = 0.\nProof.\nAdmitted.\n\nLemma asin_1 : asin 1 = PI / 2.\nProof.\nAdmitted.\n\nLemma asin_inv_sqrt2 : asin (/sqrt 2) = PI/4.\nProof.\nAdmitted.\n\nLemma asin_opp : forall x,\n asin (- x) = - asin x.\nProof.\nAdmitted.\n\nLemma asin_bound : forall x,\n - (PI/2) <= asin x <= PI/2.\nProof.\nAdmitted.\n\nLemma asin_bound_lt : forall x, -1 < x < 1 ->\n - (PI/2) < asin x < PI/2.\nProof.\nAdmitted.\n\nLemma sin_asin : forall x, -1 <= x <= 1 ->\n sin (asin x) = x.\nProof.\nAdmitted.\n\nLemma asin_sin : forall x, -(PI/2) <= x <= PI/2 ->\n asin (sin x) = x.\nProof.\nAdmitted.\n\nLemma cos_asin : forall x, -1 <= x <= 1 ->\n cos (asin x) = sqrt (1 - x²).\nProof.\nAdmitted.\n\nLemma tan_asin : forall x, -1 <= x <= 1 ->\n tan (asin x) = x / sqrt (1 - x²).\nProof.\nAdmitted.\n\nLemma derivable_pt_asin : forall x, -1 < x < 1 ->\n derivable_pt asin x.\nProof.\nAdmitted.\n\nLemma derive_pt_asin : forall (x : R) (Hxrange : -1 < x < 1),\n derive_pt asin x (derivable_pt_asin x Hxrange) = 1 / sqrt (1 - x²).\nProof.\nAdmitted.\n\nDefinition acos x :=\n if Rle_dec x (-1) then PI else\n if Rle_dec 1 x then 0 else\n PI/2 - atan (x/sqrt(1 - x²)).\n\nLemma acos_atan : forall x, 0 < x ->\n acos x = atan (sqrt (1 - x²) / x).\nProof.\nAdmitted.\n\nLemma acos_asin : forall x, -1 <= x <= 1 ->\n acos x = PI/2 - asin x.\nProof.\nAdmitted.\n\nLemma asin_acos : forall x, -1 <= x <= 1 ->\n asin x = PI/2 - acos x.\nProof.\nAdmitted.\n\nLemma acos_0 : acos 0 = PI/2.\nProof.\nAdmitted.\n\nLemma acos_1 : acos 1 = 0.\nProof.\nAdmitted.\n\nLemma acos_opp : forall x,\n acos (- x) = PI - acos x.\nProof.\nAdmitted.\n\nLemma acos_inv_sqrt2 : acos (/sqrt 2) = PI/4.\nProof.\nAdmitted.\n\nLemma acos_bound : forall x,\n 0 <= acos x <= PI.\nProof.\nAdmitted.\n\nLemma acos_bound_lt : forall x, -1 < x < 1 ->\n 0 < acos x < PI.\nProof.\nAdmitted.\n\nLemma cos_acos : forall x, -1 <= x <= 1 ->\n cos (acos x) = x.\nProof.\nAdmitted.\n\nLemma acos_cos : forall x, 0 <= x <= PI ->\n acos (cos x) = x.\nProof.\nAdmitted.\n\nLemma sin_acos : forall x, -1 <= x <= 1 ->\n sin (acos x) = sqrt (1 - x²).\nProof.\nAdmitted.\n\nLemma tan_acos : forall x, -1 <= x <= 1 ->\n tan (acos x) = sqrt (1 - x²) / x.\nProof.\nAdmitted.\n\nLemma derivable_pt_acos : forall x, -1 < x < 1 ->\n derivable_pt acos x.\nProof.\nAdmitted.\n\nLemma derive_pt_acos : forall (x : R) (Hxrange : -1 < x < 1),\n derive_pt acos x (derivable_pt_acos x Hxrange) = -1 / sqrt (1 - x²).\nProof.\nAdmitted.\n\nLemma sin_gt_x x : x < 0 -> x < sin x.\nProof.\nAdmitted." }, { "theorem_id": 32, "title": "027_sum_of_the_angles_of_a_triangle", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/realanalysis.ml\";;\n\nprioritize_vector();;\n\nlet PYTHAGORAS = `!A B C:real^N.\n orthogonal (A - B) (C - B)\n ==> norm(C - A) pow 2 = norm(B - A) pow 2 + norm(C - B) pow 2`;;\n\nlet vector_angle = new_definition\n `vector_angle x y = if x = vec 0 \\/ y = vec 0 then pi / &2\n else acs((x dot y) / (norm x * norm y))`;;\n\nlet VECTOR_ANGLE_LINEAR_IMAGE_EQ = `!f x y. linear f /\\ (!x. norm(f x) = norm x)\n ==> (vector_angle (f x) (f y) = vector_angle x y)`;;\n\nadd_linear_invariants [VECTOR_ANGLE_LINEAR_IMAGE_EQ];;\n\nlet VECTOR_ANGLE_ORTHOGONAL_TRANSFORMATION = `!f x y:real^N.\n orthogonal_transformation f\n ==> vector_angle (f x) (f y) = vector_angle x y`;;\n\nlet VECTOR_ANGLE_REFL = `!x. vector_angle x x = if x = vec 0 then pi / &2 else &0`;;\n\nlet VECTOR_ANGLE_SYM = `!x y. vector_angle x y = vector_angle y x`;;\n\nlet VECTOR_ANGLE_LMUL = `!a x y:real^N.\n vector_angle (a % x) y =\n if a = &0 then pi / &2\n else if &0 <= a then vector_angle x y\n else pi - vector_angle x y`;;\n\nlet VECTOR_ANGLE_RMUL = `!a x y:real^N.\n vector_angle x (a % y) =\n if a = &0 then pi / &2\n else if &0 <= a then vector_angle x y\n else pi - vector_angle x y`;;\n\nlet VECTOR_ANGLE_LNEG = `!x y. vector_angle (--x) y = pi - vector_angle x y`;;\n\nlet VECTOR_ANGLE_RNEG = `!x y. vector_angle x (--y) = pi - vector_angle x y`;;\n\nlet VECTOR_ANGLE_NEG2 = `!x y. vector_angle (--x) (--y) = vector_angle x y`;;\n\nlet SIN_VECTOR_ANGLE_LMUL = `!a x y:real^N.\n sin(vector_angle (a % x) y) =\n if a = &0 then &1 else sin(vector_angle x y)`;;\n\nlet SIN_VECTOR_ANGLE_RMUL = `!a x y:real^N.\n sin(vector_angle x (a % y)) =\n if a = &0 then &1 else sin(vector_angle x y)`;;\n\nlet VECTOR_ANGLE = `!x y:real^N. x dot y = norm(x) * norm(y) * cos(vector_angle x y)`;;\n\nlet VECTOR_ANGLE_RANGE = `!x y:real^N. &0 <= vector_angle x y /\\ vector_angle x y <= pi`;;\n\nlet ORTHOGONAL_VECTOR_ANGLE = `!x y:real^N. orthogonal x y <=> vector_angle x y = pi / &2`;;\n\nlet VECTOR_ANGLE_EQ_0 = `!x y:real^N. vector_angle x y = &0 <=>\n ~(x = vec 0) /\\ ~(y = vec 0) /\\ norm(x) % y = norm(y) % x`;;\n\nlet VECTOR_ANGLE_EQ_PI = `!x y:real^N. vector_angle x y = pi <=>\n ~(x = vec 0) /\\ ~(y = vec 0) /\\\n norm(x) % y + norm(y) % x = vec 0`;;\n\nlet VECTOR_ANGLE_EQ_0_DIST = `!x y:real^N. vector_angle x y = &0 <=>\n ~(x = vec 0) /\\ ~(y = vec 0) /\\ norm(x + y) = norm x + norm y`;;\n\nlet VECTOR_ANGLE_EQ_PI_DIST = `!x y:real^N. vector_angle x y = pi <=>\n ~(x = vec 0) /\\ ~(y = vec 0) /\\ norm(x - y) = norm x + norm y`;;\n\nlet SIN_VECTOR_ANGLE_POS = `!v w. &0 <= sin(vector_angle v w)`;;\n\nlet SIN_VECTOR_ANGLE_EQ_0 = `!x y. sin(vector_angle x y) = &0 <=>\n vector_angle x y = &0 \\/ vector_angle x y = pi`;;\n\nlet ASN_SIN_VECTOR_ANGLE = `!x y:real^N.\n asn(sin(vector_angle x y)) =\n if vector_angle x y <= pi / &2 then vector_angle x y\n else pi - vector_angle x y`;;\n\nlet SIN_VECTOR_ANGLE_EQ = `!x y w z.\n sin(vector_angle x y) = sin(vector_angle w z) <=>\n vector_angle x y = vector_angle w z \\/\n vector_angle x y = pi - vector_angle w z`;;\n\nlet CONTINUOUS_WITHIN_CX_VECTOR_ANGLE_COMPOSE = `!f:real^M->real^N g x s.\n ~(f x = vec 0) /\\ ~(g x = vec 0) /\\\n f continuous (at x within s) /\\\n g continuous (at x within s)\n ==> (\\x. Cx(vector_angle (f x) (g x))) continuous (at x within s)`;;\n\nlet CONTINUOUS_AT_CX_VECTOR_ANGLE = `!c x:real^N. ~(x = vec 0) ==> (Cx o vector_angle c) continuous (at x)`;;\n\nlet CONTINUOUS_WITHIN_CX_VECTOR_ANGLE = `!c x:real^N s.\n ~(x = vec 0) ==> (Cx o vector_angle c) continuous (at x within s)`;;\n\nlet REAL_CONTINUOUS_AT_VECTOR_ANGLE = `!c x:real^N. ~(x = vec 0) ==> (vector_angle c) real_continuous (at x)`;;\n\nlet REAL_CONTINUOUS_WITHIN_VECTOR_ANGLE = `!c s x:real^N. ~(x = vec 0)\n ==> (vector_angle c) real_continuous (at x within s)`;;\n\nlet CONTINUOUS_ON_CX_VECTOR_ANGLE = `!s. ~(vec 0 IN s) ==> (Cx o vector_angle c) continuous_on s`;;\n\nlet VECTOR_ANGLE_EQ = `!u v x y. ~(u = vec 0) /\\ ~(v = vec 0) /\\ ~(x = vec 0) /\\ ~(y = vec 0)\n ==> (vector_angle u v = vector_angle x y <=>\n (x dot y) * norm(u) * norm(v) =\n (u dot v) * norm(x) * norm(y))`;;\n\nlet COS_VECTOR_ANGLE_EQ = `!u v x y.\n cos(vector_angle u v) = cos(vector_angle x y) <=>\n vector_angle u v = vector_angle x y`;;\n\nlet COLLINEAR_VECTOR_ANGLE = `!x y. ~(x = vec 0) /\\ ~(y = vec 0)\n ==> (collinear {vec 0,x,y} <=>\n vector_angle x y = &0 \\/ vector_angle x y = pi)`;;\n\nlet COLLINEAR_SIN_VECTOR_ANGLE = `!x y. ~(x = vec 0) /\\ ~(y = vec 0)\n ==> (collinear {vec 0,x,y} <=> sin(vector_angle x y) = &0)`;;\n\nlet COLLINEAR_SIN_VECTOR_ANGLE_IMP = `!x y. sin(vector_angle x y) = &0\n ==> ~(x = vec 0) /\\ ~(y = vec 0) /\\ collinear {vec 0,x,y}`;;\n\nlet VECTOR_ANGLE_EQ_0_RIGHT = `!x y z:real^N. vector_angle x y = &0\n ==> (vector_angle x z = vector_angle y z)`;;\n\nlet VECTOR_ANGLE_EQ_0_LEFT = `!x y z:real^N. vector_angle x y = &0\n ==> (vector_angle z x = vector_angle z y)`;;\n\nlet VECTOR_ANGLE_EQ_PI_RIGHT = `!x y z:real^N. vector_angle x y = pi\n ==> (vector_angle x z = pi - vector_angle y z)`;;\n\nlet VECTOR_ANGLE_EQ_PI_LEFT = `!x y z:real^N. vector_angle x y = pi\n ==> (vector_angle z x = pi - vector_angle z y)`;;\n\nlet COS_VECTOR_ANGLE = `!x y:real^N.\n cos(vector_angle x y) = if x = vec 0 \\/ y = vec 0 then &0\n else (x dot y) / (norm x * norm y)`;;\n\nlet SIN_VECTOR_ANGLE = `!x y:real^N.\n sin(vector_angle x y) =\n if x = vec 0 \\/ y = vec 0 then &1\n else sqrt(&1 - ((x dot y) / (norm x * norm y)) pow 2)`;;\n\nlet SIN_SQUARED_VECTOR_ANGLE = `!x y:real^N.\n sin(vector_angle x y) pow 2 =\n if x = vec 0 \\/ y = vec 0 then &1\n else &1 - ((x dot y) / (norm x * norm y)) pow 2`;;\n\nlet VECTOR_ANGLE_COMPLEX_LMUL = `!a. ~(a = Cx(&0))\n ==> vector_angle (a * x) (a * y) = vector_angle x y`;;\n\nlet VECTOR_ANGLE_1 = `!x. vector_angle x (Cx(&1)) = acs(Re x / norm x)`;;\n\nlet ARG_EQ_VECTOR_ANGLE_1 = `!z. ~(z = Cx(&0)) /\\ &0 <= Im z ==> Arg z = vector_angle z (Cx(&1))`;;\n\nlet VECTOR_ANGLE_ARG = `!w z. ~(w = Cx(&0)) /\\ ~(z = Cx(&0))\n ==> vector_angle w z = if &0 <= Im(z / w) then Arg(z / w)\n else &2 * pi - Arg(z / w)`;;\n\nlet VECTOR_ANGLE_PRESERVING_EQ_SIMILARITY = `!f:real^N->real^N.\n linear f /\\ (!x y. vector_angle (f x) (f y) = vector_angle x y) <=>\n ?c g. ~(c = &0) /\\ orthogonal_transformation g /\\ f = \\z. c % g z`;;\n\nlet VECTOR_ANGLE_PRESERVING_EQ_SIMILARITY_ALT = `!f:real^N->real^N.\n linear f /\\ (!x y. vector_angle (f x) (f y) = vector_angle x y) <=>\n ?c g. &0 < c /\\ orthogonal_transformation g /\\ f = \\z. c % g z`;;\n\nlet angle = new_definition\n `angle(a,b,c) = vector_angle (a - b) (c - b)`;;\n\nlet ANGLE_LINEAR_IMAGE_EQ = `!f a b c.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> angle(f a,f b,f c) = angle(a,b,c)`;;\n\nadd_linear_invariants [ANGLE_LINEAR_IMAGE_EQ];;\n\nlet ANGLE_TRANSLATION_EQ = `!a b c d. angle(a + b,a + c,a + d) = angle(b,c,d)`;;\n\nadd_translation_invariants [ANGLE_TRANSLATION_EQ];;\n\nlet VECTOR_ANGLE_ANGLE = `vector_angle x y = angle(x,vec 0,y)`;;\n\nlet ANGLE_EQ_PI_DIST = `!A B C:real^N.\n angle(A,B,C) = pi <=>\n ~(A = B) /\\ ~(C = B) /\\ dist(A,C) = dist(A,B) + dist(B,C)`;;\n\nlet SIN_ANGLE_POS = `!A B C. &0 <= sin(angle(A,B,C))`;;\n\nlet ANGLE = `!A B C. (A - C) dot (B - C) = dist(A,C) * dist(B,C) * cos(angle(A,C,B))`;;\n\nlet ANGLE_REFL = `!A B. angle(A,A,B) = pi / &2 /\\ angle(B,A,A) = pi / &2`;;\n\nlet ANGLE_REFL_MID = `!A B. ~(A = B) ==> angle(A,B,A) = &0`;;\n\nlet ANGLE_SYM = `!A B C. angle(A,B,C) = angle(C,B,A)`;;\n\nlet ANGLE_RANGE = `!A B C. &0 <= angle(A,B,C) /\\ angle(A,B,C) <= pi`;;\n\nlet COS_ANGLE_EQ = `!a b c a' b' c'.\n cos(angle(a,b,c)) = cos(angle(a',b',c')) <=>\n angle(a,b,c) = angle(a',b',c')`;;\n\nlet ANGLE_EQ = `!a b c a' b' c'.\n ~(a = b) /\\ ~(c = b) /\\ ~(a' = b') /\\ ~(c' = b')\n ==> (angle(a,b,c) = angle(a',b',c') <=>\n ((a' - b') dot (c' - b')) * norm (a - b) * norm (c - b) =\n ((a - b) dot (c - b)) * norm (a' - b') * norm (c' - b'))`;;\n\nlet SIN_ANGLE_EQ_0 = `!A B C. sin(angle(A,B,C)) = &0 <=> angle(A,B,C) = &0 \\/ angle(A,B,C) = pi`;;\n\nlet SIN_ANGLE_EQ = `!A B C A' B' C'. sin(angle(A,B,C)) = sin(angle(A',B',C')) <=>\n angle(A,B,C) = angle(A',B',C') \\/\n angle(A,B,C) = pi - angle(A',B',C')`;;\n\nlet COLLINEAR_ANGLE = `!A B C. ~(A = B) /\\ ~(B = C)\n ==> (collinear {A,B,C} <=> angle(A,B,C) = &0 \\/ angle(A,B,C) = pi)`;;\n\nlet COLLINEAR_SIN_ANGLE = `!A B C. ~(A = B) /\\ ~(B = C)\n ==> (collinear {A,B,C} <=> sin(angle(A,B,C)) = &0)`;;\n\nlet COLLINEAR_SIN_ANGLE_IMP = `!A B C. sin(angle(A,B,C)) = &0\n ==> ~(A = B) /\\ ~(B = C) /\\ collinear {A,B,C}`;;\n\nlet ANGLE_EQ_0_RIGHT = `!A B C. angle(A,B,C) = &0 ==> angle(A,B,D) = angle(C,B,D)`;;\n\nlet ANGLE_EQ_0_LEFT = `!A B C. angle(A,B,C) = &0 ==> angle(D,B,A) = angle(D,B,C)`;;\n\nlet ANGLE_EQ_PI_RIGHT = `!A B C. angle(A,B,C) = pi ==> angle(D,B,A) = pi - angle(D,B,C)`;;\n\nlet ANGLE_EQ_PI_LEFT = `!A B C. angle(A,B,C) = pi ==> angle(A,B,D) = pi - angle(C,B,D)`;;\n\nlet COS_ANGLE = `!a b c. cos(angle(a,b,c)) = if a = b \\/ c = b then &0\n else ((a - b) dot (c - b)) /\n (norm(a - b) * norm(c - b))`;;\n\nlet SIN_ANGLE = `!a b c. sin(angle(a,b,c)) =\n if a = b \\/ c = b then &1\n else sqrt(&1 - (((a - b) dot (c - b)) /\n (norm(a - b) * norm(c - b))) pow 2)`;;\n\nlet SIN_SQUARED_ANGLE = `!a b c. sin(angle(a,b,c)) pow 2 =\n if a = b \\/ c = b then &1\n else &1 - (((a - b) dot (c - b)) /\n (norm(a - b) * norm(c - b))) pow 2`;;\n\nlet COS_ADJACENT_HYPOTENUSE = `!A B C:real^N.\n orthogonal (A - B) (C - B)\n ==> dist(A,C) * cos(angle(B,A,C)) = dist(A,B)`;;\n\nlet COS_ADJACENT_OVER_HYPOTENUSE = `!A B C:real^N.\n orthogonal (A - B) (C - B)\n ==> cos(angle(B,A,C)) = dist(A,B) / dist(A,C)`;;\n\nlet SIN_OPPOSITE_HYPOTENUSE = `!A B C:real^N.\n orthogonal (A - B) (C - B)\n ==> dist(A,C) * sin(angle(B,A,C)) = dist(C,B)`;;\n\nlet SIN_OPPOSITE_OVER_HYPOTENUSE = `!A B C:real^N.\n orthogonal (A - B) (C - B) /\\ ~(A = C)\n ==> sin(angle(B,A,C)) = dist(C,B) / dist(A,C)`;;\n\nlet TAN_OPPOSITE_ADJACENT = `!A B C:real^N.\n orthogonal (A - B) (C - B) /\\ ~(A = B)\n ==> dist(A,B) * tan(angle(B,A,C)) = dist(C,B)`;;\n\nlet TAN_OPPOSITE_OVER_ADJACENT = `!A B C:real^N.\n orthogonal (A - B) (C - B)\n ==> tan(angle(B,A,C)) = dist(C,B) / dist(A,B)`;;\n\nlet LAW_OF_COSINES = `!A B C:real^N.\n dist(B,C) pow 2 = (dist(A,B) pow 2 + dist(A,C) pow 2) -\n &2 * dist(A,B) * dist(A,C) * cos(angle(B,A,C))`;;\n\nlet LAW_OF_SINES = `!A B C:real^N.\n sin(angle(A,B,C)) * dist(B,C) = sin(angle(B,A,C)) * dist(A,C)`;;\n\nlet TRIANGLE_ANGLE_SUM_LEMMA = `!A B C:real^N. ~(A = B) /\\ ~(A = C) /\\ ~(B = C)\n ==> cos(angle(B,A,C) + angle(A,B,C) + angle(B,C,A)) = -- &1`;;\n\nlet COS_MINUS1_LEMMA = `!x. cos(x) = -- &1 /\\ &0 <= x /\\ x < &3 * pi ==> x = pi`;;\n\nlet TRIANGLE_ANGLE_SUM = `!A B C:real^N. ~(A = B /\\ B = C /\\ A = C)\n ==> angle(B,A,C) + angle(A,B,C) + angle(B,C,A) = pi`;;\n\nlet ANGLE_EQ_PI_OTHERS = `!A B C:real^N.\n angle(A,B,C) = pi\n ==> angle(B,C,A) = &0 /\\ angle(A,C,B) = &0 /\\\n angle(B,A,C) = &0 /\\ angle(C,A,B) = &0`;;\n\nlet ANGLE_EQ_0_DIST = `!A B C:real^N. angle(A,B,C) = &0 <=>\n ~(A = B) /\\ ~(C = B) /\\\n (dist(A,B) = dist(A,C) + dist(C,B) \\/\n dist(B,C) = dist(A,C) + dist(A,B))`;;\n\nlet ANGLE_EQ_0_DIST_ABS = `!A B C:real^N. angle(A,B,C) = &0 <=>\n ~(A = B) /\\ ~(C = B) /\\\n dist(A,C) = abs(dist(A,B) - dist(C,B))`;;\n\nlet CONGRUENT_TRIANGLES_SSS = `!A B C:real^M A' B' C':real^N.\n dist(A,B) = dist(A',B') /\\\n dist(B,C) = dist(B',C') /\\\n dist(C,A) = dist(C',A')\n ==> angle(A,B,C) = angle(A',B',C')`;;\n\nlet CONGRUENT_TRIANGLES_SAS = `!A B C:real^M A' B' C':real^N.\n dist(A,B) = dist(A',B') /\\\n angle(A,B,C) = angle(A',B',C') /\\\n dist(B,C) = dist(B',C')\n ==> dist(A,C) = dist(A',C')`;;\n\nlet CONGRUENT_TRIANGLES_AAS = `!A B C:real^M A' B' C':real^N.\n angle(A,B,C) = angle(A',B',C') /\\\n angle(B,C,A) = angle(B',C',A') /\\\n dist(A,B) = dist(A',B') /\\\n ~(collinear {A,B,C})\n ==> dist(A,C) = dist(A',C') /\\ dist(B,C) = dist(B',C')`;;\n\nlet CONGRUENT_TRIANGLES_ASA = `!A B C:real^M A' B' C':real^N.\n angle(A,B,C) = angle(A',B',C') /\\\n dist(A,B) = dist(A',B') /\\\n angle(B,A,C) = angle(B',A',C') /\\\n ~(collinear {A,B,C})\n ==> dist(A,C) = dist(A',C')`;;\n\nlet CONGRUENT_TRIANGLES_SSS_FULL = `!A B C:real^M A' B' C':real^N.\n dist(A,B) = dist(A',B') /\\\n dist(B,C) = dist(B',C') /\\\n dist(C,A) = dist(C',A')\n ==> dist(A,B) = dist(A',B') /\\\n dist(B,C) = dist(B',C') /\\\n dist(C,A) = dist(C',A') /\\\n angle(A,B,C) = angle(A',B',C') /\\\n angle(B,C,A) = angle(B',C',A') /\\\n angle(C,A,B) = angle(C',A',B')`;;\n\nlet CONGRUENT_TRIANGLES_SAS_FULL = `!A B C:real^M A' B' C':real^N.\n dist(A,B) = dist(A',B') /\\\n angle(A,B,C) = angle(A',B',C') /\\\n dist(B,C) = dist(B',C')\n ==> dist(A,B) = dist(A',B') /\\\n dist(B,C) = dist(B',C') /\\\n dist(C,A) = dist(C',A') /\\\n angle(A,B,C) = angle(A',B',C') /\\\n angle(B,C,A) = angle(B',C',A') /\\\n angle(C,A,B) = angle(C',A',B')`;;\n\nlet CONGRUENT_TRIANGLES_AAS_FULL = `!A B C:real^M A' B' C':real^N.\n angle(A,B,C) = angle(A',B',C') /\\\n angle(B,C,A) = angle(B',C',A') /\\\n dist(A,B) = dist(A',B') /\\\n ~(collinear {A,B,C})\n ==> dist(A,B) = dist(A',B') /\\\n dist(B,C) = dist(B',C') /\\\n dist(C,A) = dist(C',A') /\\\n angle(A,B,C) = angle(A',B',C') /\\\n angle(B,C,A) = angle(B',C',A') /\\\n angle(C,A,B) = angle(C',A',B')`;;\n\nlet CONGRUENT_TRIANGLES_ASA_FULL = `!A B C:real^M A' B' C':real^N.\n angle(A,B,C) = angle(A',B',C') /\\\n dist(A,B) = dist(A',B') /\\\n angle(B,A,C) = angle(B',A',C') /\\\n ~(collinear {A,B,C})\n ==> dist(A,B) = dist(A',B') /\\\n dist(B,C) = dist(B',C') /\\\n dist(C,A) = dist(C',A') /\\\n angle(A,B,C) = angle(A',B',C') /\\\n angle(B,C,A) = angle(B',C',A') /\\\n angle(C,A,B) = angle(C',A',B')`;;\n\nlet ANGLE_BETWEEN = `!a b x. angle(a,x,b) = pi <=> ~(x = a) /\\ ~(x = b) /\\ between x (a,b)`;;\n\nlet BETWEEN_ANGLE = `!a b x. between x (a,b) <=> x = a \\/ x = b \\/ angle(a,x,b) = pi`;;\n\nlet ANGLES_ALONG_LINE = `!A B C D:real^N.\n ~(C = A) /\\ ~(C = B) /\\ between C (A,B)\n ==> angle(A,C,D) + angle(B,C,D) = pi`;;\n\nlet ANGLES_ADD_BETWEEN = `!A B C D:real^N.\n between C (A,B) /\\ ~(D = A) /\\ ~(D = B)\n ==> angle(A,D,C) + angle(C,D,B) = angle(A,D,B)`;;\n\nlet SETDIST_POINT_LINE = `!x y z:real^N.\n setdist({x},affine hull {y,z}) = dist(x,y) * sin(angle(x,y,z))`;;\n\nlet AREA_TRIANGLE_SIN = `!a b c:real^2.\n measure(convex hull {a,b,c}) =\n (dist(a,b) * dist(a,c) * sin(angle(b,a,c))) / &2`;;\n\nlet ANGLE_TRIANGLE_LAW = `!p u v w:real^N. angle(u,p,w) <= angle(u,p,v) + angle(v,p,w)`;;\n\nlet VECTOR_ANGLE_TRIANGLE_LAW = `!u v w:real^N. vector_angle u w <= vector_angle u v + vector_angle v w`;;" }, { "theorem_id": 32, "title": "027_sum_of_the_angles_of_a_triangle", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Basic Properties of Triangles\\\ntheory Triangle\nimports\n Angles\nbegin\n\ntext \\\n We prove a number of basic geometric properties of triangles. All theorems hold\n in any real inner product space.\n\\\nsubsection \\Thales' theorem\\\n\ntheorem thales:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"dist B (midpoint A C) = dist A C / 2\"\n shows \"orthogonal (A - B) (C - B)\"\n by sorry\n\nsubsection \\Sine and cosine laws\\\n\ntext \\\n The proof of the Law of Cosines follows trivially from the definition of the angle,\n the definition of the norm in vector spaces with an inner product and the bilinearity\n of the inner product.\n\\\n\nlemma cosine_law_vector:\n \"norm (u - v) ^ 2 = norm u ^ 2 + norm v ^ 2 - 2 * norm u * norm v * cos (vangle u v)\"\n by sorry\n\nlemma cosine_law_triangle:\n \"dist b c ^ 2 = dist a b ^ 2 + dist a c ^ 2 - 2 * dist a b * dist a c * cos (angle b a c)\"\n by sorry\n\ntext \\\n According to our definition, angles are always between $0$ and $\\pi$ and therefore,\n the sign of an angle is always non-negative. We can therefore look at\n $\\sin(\\alpha)^2$, which we can express in terms of $\\cos(\\alpha)$ using the\n identity $\\sin(\\alpha)^2 + \\cos(\\alpha)^2 = 1$. The remaining proof is then a\n trivial consequence of the definitions.\n\\\nlemma sine_law_triangle:\n \"sin (angle a b c) * dist b c = sin (angle b a c) * dist a c\" (is \"?A = ?B\")\n by sorry\n\ntext \\\n The following forms of the Law of Sines/Cosines are more convenient for eliminating\n sines/cosines from a goal completely.\n\\\n\nlemma cosine_law_triangle':\n \"2 * dist a b * dist a c * cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2)\"\n by sorry\n\nlemma cosine_law_triangle'':\n \"cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2) / (2 * dist a b * dist a c)\"\n by sorry\n\nlemma sine_law_triangle':\n \"b \\ c \\ sin (angle a b c) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nlemma sine_law_triangle'':\n \"b \\ c \\ sin (angle c b a) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nsubsection \\Sum of angles\\\n\ncontext\nbegin\n\nprivate lemma gather_squares: \"a * (a * b) = a^2 * (b :: real)\"\n by (simp_all add: power2_eq_square)\n\nprivate lemma eval_power: \"x ^ numeral n = x * x ^ pred_numeral n\"\n by (subst numeral_eq_Suc, subst power_Suc) simp\n\ntext \\\n The proof that the sum of the angles in a triangle is $\\pi$ is somewhat more\n involved. Following the HOL Light proof by John Harrison, we first prove\n that $\\cos(\\alpha + \\beta + \\gamma) = -1$ and $\\alpha + \\beta + \\gamma \\in [0;3\\pi)$,\n which then implies the theorem.\n\n The main work is proving $\\cos(\\alpha + \\beta + \\gamma)$. This is done using the\n addition theorems for the sine and cosine, then using the Laws of Sines to eliminate\n all $\\sin$ terms save $\\sin(\\gamma)^2$, which only appears squared in the remaining goal.\n We then use $\\sin(\\gamma)^2 = 1 - \\cos(\\gamma)^2$ to eliminate this term and apply\n the law of cosines to eliminate this term as well.\n\n The remaining goal is a non-linear equation containing only the length of the sides\n of the triangle. It can be shown by simple algebraic rewriting.\n\\\nlemma angle_sum_triangle:\n assumes \"a \\ b \\ b \\ c \\ a \\ c\"\n shows \"angle c a b + angle a b c + angle b c a = pi\"\n by sorry\n\nend\n\nsubsection \\Congruence Theorems\\\n\ntext \\\n If two triangles agree on two angles at a non-degenerate side, the third angle\n must also be equal.\n\\\nlemma similar_triangle_aa:\n assumes \"b1 \\ c1\" \"b2 \\ c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n shows \"angle b1 a1 c1 = angle b2 a2 c2\"\n by sorry\n\ntext \\\n A triangle is defined by its three angles and the lengths of three sides up to congruence.\n Two triangles are congruent if they have their angles are the same and their sides have\n the same length.\n\\\n\nlocale congruent_triangle =\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes sides': \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n and angles': \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\"\n \"angle a1 c1 b1 = angle a2 c2 b2\"\nbegin\n\nlemma sides:\n \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n \"dist b1 a1 = dist a2 b2\" \"dist c1 a1 = dist a2 c2\" \"dist c1 b1 = dist b2 c2\"\n \"dist a1 b1 = dist b2 a2\" \"dist a1 c1 = dist c2 a2\" \"dist b1 c1 = dist c2 b2\"\n \"dist b1 a1 = dist b2 a2\" \"dist c1 a1 = dist c2 a2\" \"dist c1 b1 = dist c2 b2\"\n by sorry\n\nlemma angles:\n \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\" \"angle a1 c1 b1 = angle a2 c2 b2\"\n \"angle c1 a1 b1 = angle b2 a2 c2\" \"angle c1 b1 a1 = angle a2 b2 c2\" \"angle b1 c1 a1 = angle a2 c2 b2\"\n \"angle b1 a1 c1 = angle c2 a2 b2\" \"angle a1 b1 c1 = angle c2 b2 a2\" \"angle a1 c1 b1 = angle b2 c2 a2\"\n \"angle c1 a1 b1 = angle c2 a2 b2\" \"angle c1 b1 a1 = angle c2 b2 a2\" \"angle b1 c1 a1 = angle b2 c2 a2\"\n by sorry\n\nend\n\nlemmas congruent_triangleD = congruent_triangle.sides congruent_triangle.angles\n\ntext \\\n Given two triangles that agree on a subset of its side lengths and angles that are\n sufficient to define a triangle uniquely up to congruence, one can conclude that they\n must also agree on all remaining quantities, i.e. that they are congruent.\n\n The following four congruence theorems state what constitutes such a uniquely-defining\n subset of quantities. Each theorem states in its name which quantities are required and\n in which order (clockwise or counter-clockwise): an ``s'' stands for a side,\n an ``a'' stands for an angle.\n\n The lemma ``congruent-triangleI-sas, for example, requires that two adjacent sides and the\n angle inbetween are the same in both triangles.\n\\\n\nlemma congruent_triangleI_sss:\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"dist a1 c1 = dist a2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sss = congruent_triangleD[OF congruent_triangleI_sss]\n\nlemma congruent_triangleI_sas:\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sas = congruent_triangleD[OF congruent_triangleI_sas]\n\nlemma congruent_triangleI_aas:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"\\collinear {a1,b1,c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_aas = congruent_triangleD[OF congruent_triangleI_aas]\n\nlemma congruent_triangleI_asa:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"angle b1 a1 c1 = angle b2 a2 c2\"\n assumes \"\\collinear {a1, b1, c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_asa = congruent_triangleD[OF congruent_triangleI_asa]\n\nsubsection \\Isosceles Triangle Theorem\\\n\ntext \\\n We now prove the Isosceles Triangle Theorem: in a triangle where two sides have\n the same length, the two angles that are adjacent to only one of the two sides\n must be equal.\n\\\nlemma isosceles_triangle:\n assumes \"dist a c = dist b c\"\n shows \"angle b a c = angle a b c\"\n by sorry\n\ntext \\\n For the non-degenerate case (i.e. the three points are not collinear), We also\n prove the converse.\n\\\nlemma isosceles_triangle_converse:\n assumes \"angle a b c = angle b a c\" \"\\collinear {a,b,c}\"\n shows \"dist a c = dist b c\"\n by sorry\n\nsubsection\\Contributions by Lukas Bulwahn\\\n \nlemma Pythagoras:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"orthogonal (A - C) (B - C)\"\n shows \"(dist B C) ^ 2 + (dist C A) ^ 2 = (dist A B) ^ 2\"\n by sorry\n\nlemma isosceles_triangle_orthogonal_on_midpoint:\n fixes A B C :: \"'a :: euclidean_space\"\n assumes \"dist C A = dist C B\"\n shows \"orthogonal (C - midpoint A B) (A - midpoint A B)\"\n by sorry\n\nend" }, { "theorem_id": 32, "title": "027_sum_of_the_angles_of_a_triangle", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Manuel Candales\n-/\nmodule\n\npublic import Mathlib.Analysis.Normed.Affine.AddTorsor\npublic import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine\npublic import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine\npublic import Mathlib.Tactic.IntervalCases\n\n/-!\n# Triangles\n\nThis file proves basic geometrical results about distances and angles\nin (possibly degenerate) triangles in real inner product spaces and\nEuclidean affine spaces. More specialized results, and results\ndeveloped for simplices in general rather than just for triangles, are\nin separate files. Definitions and results that make sense in more\ngeneral affine spaces rather than just in the Euclidean case go under\n`LinearAlgebra.AffineSpace`.\n\n## Implementation notes\n\nResults in this file are generally given in a form with only those\nnon-degeneracy conditions needed for the particular result, rather\nthan requiring affine independence of the points of a triangle\nunnecessarily.\n\n## References\n\n* https://en.wikipedia.org/wiki/Law_of_cosines\n* https://en.wikipedia.org/wiki/Pons_asinorum\n* https://en.wikipedia.org/wiki/Sum_of_angles_of_a_triangle\n* https://en.wikipedia.org/wiki/Law_of_sines\n\n-/\n\npublic section\n\nnoncomputable section\n\nopen scoped CharZero Real RealInnerProductSpace\n\nnamespace InnerProductGeometry\n\n/-!\n### Geometrical results on triangles in real inner product spaces\n\nThis section develops some results on (possibly degenerate) triangles\nin real inner product spaces, where those definitions and results can\nmost conveniently be developed in terms of vectors and then used to\ndeduce corresponding results for Euclidean affine spaces.\n-/\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]\n\n/-- **Law of cosines** (cosine rule), vector angle form. -/\ntheorem norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle (x y : V) :\n ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ - 2 * ‖x‖ * ‖y‖ * Real.cos (angle x y) := by sorry\ntheorem sin_angle_mul_norm_eq_sin_angle_mul_norm (x y : V) :\n Real.sin (angle x y) * ‖x‖ = Real.sin (angle y (x - y)) * ‖x - y‖ := by sorry\ntheorem sin_angle_div_norm_eq_sin_angle_div_norm (x y : V) (hx : x ≠ 0) (hxy : x - y ≠ 0) :\n Real.sin (angle x y) / ‖x - y‖ = Real.sin (angle y (x - y)) / ‖x‖ := by sorry\ntheorem angle_sub_eq_angle_sub_rev_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) :\n angle x (x - y) = angle y (y - x) := by sorry\ntheorem norm_eq_of_angle_sub_eq_angle_sub_rev_of_angle_ne_pi {x y : V}\n (h : angle x (x - y) = angle y (y - x)) (hpi : angle x y ≠ π) : ‖x‖ = ‖y‖ := by sorry\ntheorem angle_eq_angle_add_add_angle_add (x : V) {y : V} (hy : y ≠ 0) :\n angle x y = angle x (x + y) + angle y (x + y) := by sorry\ntheorem angle_add_angle_sub_add_angle_sub_eq_pi (x : V) {y : V} (hy : y ≠ 0) :\n angle x y + angle x (x - y) + angle y (y - x) = π := by sorry\nend InnerProductGeometry\n\nnamespace Orientation\n\nopen Module InnerProductGeometry\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [Fact (finrank ℝ V = 2)]\nvariable (o : Orientation ℝ V (Fin 2))\n\n/-- **Converse of pons asinorum**, oriented vector angle form (given equality of angles mod `π`). -/\ntheorem norm_eq_of_two_zsmul_oangle_sub_eq {x y : V}\n (h : (2 : ℤ) • o.oangle x (x - y) = (2 : ℤ) • o.oangle (y - x) y) (h0 : o.oangle x y ≠ 0)\n (hpi : o.oangle x y ≠ π) : ‖x‖ = ‖y‖ := by sorry\nend Orientation\n\nnamespace EuclideanGeometry\n\n/-!\n### Geometrical results on triangles in Euclidean affine spaces\n\nThis section develops some geometrical definitions and results on\n(possibly degenerate) triangles in Euclidean affine spaces.\n-/\n\nopen InnerProductGeometry\nopen scoped EuclideanGeometry\n\nvariable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]\n [NormedAddTorsor V P]\n\n/-- **Law of cosines** (cosine rule), angle-at-point form. -/\ntheorem dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle (p₁ p₂ p₃ : P) :\n dist p₁ p₃ * dist p₁ p₃ = dist p₁ p₂ * dist p₁ p₂ + dist p₃ p₂ * dist p₃ p₂ -\n 2 * dist p₁ p₂ * dist p₃ p₂ * Real.cos (∠ p₁ p₂ p₃) := by sorry\ntheorem sin_angle_mul_dist_eq_sin_angle_mul_dist (p₁ p₂ p₃ : P) :\n Real.sin (∠ p₁ p₂ p₃) * dist p₂ p₃ = Real.sin (∠ p₃ p₁ p₂) * dist p₃ p₁ := by sorry\ntheorem sin_angle_div_dist_eq_sin_angle_div_dist {p₁ p₂ p₃ : P} (h23 : p₂ ≠ p₃) (h31 : p₃ ≠ p₁) :\n Real.sin (∠ p₁ p₂ p₃) / dist p₃ p₁ = Real.sin (∠ p₃ p₁ p₂) / dist p₂ p₃ := by sorry\ntheorem dist_eq_dist_mul_sin_angle_div_sin_angle {p₁ p₂ p₃ : P}\n (h : ¬Collinear ℝ ({p₁, p₂, p₃} : Set P)) :\n dist p₁ p₂ = dist p₃ p₁ * Real.sin (∠ p₂ p₃ p₁) / Real.sin (∠ p₁ p₂ p₃) := by sorry\ntheorem angle_eq_angle_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dist p₁ p₃) :\n ∠ p₁ p₂ p₃ = ∠ p₁ p₃ p₂ := by sorry\ntheorem dist_eq_of_angle_eq_angle_of_angle_ne_pi {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = ∠ p₁ p₃ p₂)\n (hpi : ∠ p₂ p₁ p₃ ≠ π) : dist p₁ p₂ = dist p₁ p₃ := by sorry\ntheorem dist_eq_of_two_zsmul_oangle_eq [Module.Oriented ℝ V (Fin 2)]\n [Fact (Module.finrank ℝ V = 2)] {p₁ p₂ p₃ : P} (h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₂ p₃ p₁)\n (h0 : ∡ p₃ p₁ p₂ ≠ 0) (hpi : ∡ p₃ p₁ p₂ ≠ π) : dist p₁ p₂ = dist p₁ p₃ := by sorry\ntheorem angle_add_angle_add_angle_eq_pi {p₁ p₂ : P} (p₃ : P) (h : p₂ ≠ p₁) :\n ∠ p₁ p₂ p₃ + ∠ p₂ p₃ p₁ + ∠ p₃ p₁ p₂ = π := by sorry\ntheorem exterior_angle_eq_angle_add_angle {p₁ p₂ p₃ : P} (p : P) (h : Sbtw ℝ p p₁ p₂) :\n ∠ p₃ p₁ p = ∠ p₁ p₃ p₂ + ∠ p₃ p₂ p₁ := by sorry\ntheorem oangle_add_oangle_add_oangle_eq_pi [Module.Oriented ℝ V (Fin 2)]\n [Fact (Module.finrank ℝ V = 2)] {p₁ p₂ p₃ : P} (h21 : p₂ ≠ p₁) (h32 : p₃ ≠ p₂)\n (h13 : p₁ ≠ p₃) : ∡ p₁ p₂ p₃ + ∡ p₂ p₃ p₁ + ∡ p₃ p₁ p₂ = π := by sorry\nlemma angle_add_of_ne_of_ne {a b c p : P} (hb : a ≠ b) (hc : a ≠ c) (hp : Wbtw ℝ b p c) :\n ∠ b a p + ∠ p a c = ∠ b a c := by sorry\ntheorem dist_sq_mul_dist_add_dist_sq_mul_dist (a b c p : P) (h : ∠ b p c = π) :\n dist a b ^ 2 * dist c p + dist a c ^ 2 * dist b p =\n dist b c * (dist a p ^ 2 + dist b p * dist c p) := by sorry\ntheorem dist_sq_add_dist_sq_eq_two_mul_dist_midpoint_sq_add_half_dist_sq (a b c : P) :\n dist a b ^ 2 + dist a c ^ 2 = 2 * (dist a (midpoint ℝ b c) ^ 2 + (dist b c / 2) ^ 2) := by sorry\ntheorem dist_mul_of_eq_angle_of_dist_mul (a b c a' b' c' : P) (r : ℝ) (h : ∠ a' b' c' = ∠ a b c)\n (hab : dist a' b' = r * dist a b) (hcb : dist c' b' = r * dist c b) :\n dist a' c' = r * dist a c := by sorry\ntheorem dist_lt_of_angle_lt {a b c : P} (h : ¬Collinear ℝ ({a, b, c} : Set P)) :\n ∠ a c b < ∠ a b c → dist a b < dist a c := by sorry\ntheorem angle_lt_iff_dist_lt {a b c : P} (h : ¬Collinear ℝ ({a, b, c} : Set P)) :\n ∠ a c b < ∠ a b c ↔ dist a b < dist a c := by sorry\ntheorem angle_le_iff_dist_le {a b c : P} (h : ¬Collinear ℝ ({a, b, c} : Set P)) :\n ∠ a c b ≤ ∠ a b c ↔ dist a b ≤ dist a c := by sorry\nlemma pi_div_three_le_angle_of_le_of_le {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₂ p₃ p₁ ≤ ∠ p₁ p₂ p₃)\n (h₃₁₂ : ∠ p₃ p₁ p₂ ≤ ∠ p₁ p₂ p₃) : π / 3 ≤ ∠ p₁ p₂ p₃ := by sorry\nlemma pi_div_three_lt_angle_of_le_of_le_of_ne {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₂ p₃ p₁ ≤ ∠ p₁ p₂ p₃)\n (h₃₁₂ : ∠ p₃ p₁ p₂ ≤ ∠ p₁ p₂ p₃)\n (hne : ∠ p₁ p₂ p₃ ≠ ∠ p₂ p₃ p₁ ∨ ∠ p₁ p₂ p₃ ≠ ∠ p₃ p₁ p₂ ∨ ∠ p₂ p₃ p₁ ≠ ∠ p₃ p₁ p₂) :\n π / 3 < ∠ p₁ p₂ p₃ := by sorry\nlemma angle_le_pi_div_three_of_le_of_le {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₁ p₂ p₃ ≤ ∠ p₂ p₃ p₁)\n (h₃₁₂ : ∠ p₁ p₂ p₃ ≤ ∠ p₃ p₁ p₂) (hnd : p₁ ≠ p₂ ∨ p₁ ≠ p₃ ∨ p₂ ≠ p₃) :\n ∠ p₁ p₂ p₃ ≤ π / 3 := by sorry\nlemma angle_lt_pi_div_three_of_le_of_le_of_ne {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₁ p₂ p₃ ≤ ∠ p₂ p₃ p₁)\n (h₃₁₂ : ∠ p₁ p₂ p₃ ≤ ∠ p₃ p₁ p₂)\n (hne : ∠ p₁ p₂ p₃ ≠ ∠ p₂ p₃ p₁ ∨ ∠ p₁ p₂ p₃ ≠ ∠ p₃ p₁ p₂ ∨ ∠ p₂ p₃ p₁ ≠ ∠ p₃ p₁ p₂) :\n ∠ p₁ p₂ p₃ < π / 3 := by sorry\nend EuclideanGeometry\n" }, { "theorem_id": 32, "title": "027_sum_of_the_angles_of_a_triangle", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From HighSchoolGeometry Require Export repere_ortho_plan.\nSet Implicit Arguments.\nUnset Strict Implicit.\nParameter AV : Type.\nParameter cons_AV : PP -> PP -> AV.\nParameter plus : AV -> AV -> AV.\nParameter opp : AV -> AV.\n \nAxiom\n existence_AB_unitaire : exists A : PO, (exists B : PO, distance A B = 1).\n\nAxiom\n existence_representant_cons :\n forall (a : AV) (A B C : PO),\n distance A B = 1 ->\n exists D : PO, distance C D = 1 /\\ a = cons_AV (vec A B) (vec C D).\n\nAxiom\n angles_representants_unitaires :\n forall A B C D E F : PO,\n A <> B ->\n C <> D ->\n cons_AV (vec A B) (vec C D) =\n cons_AV (representant_unitaire (vec A B))\n (representant_unitaire (vec C D)).\n \nAxiom\n Chasles :\n forall A B C D E F : PO,\n A <> B ->\n C <> D ->\n E <> F ->\n plus (cons_AV (vec A B) (vec C D)) (cons_AV (vec C D) (vec E F)) =\n cons_AV (vec A B) (vec E F).\n \nAxiom\n def_opp :\n forall A B C D : PO,\n A <> B ->\n C <> D -> opp (cons_AV (vec A B) (vec C D)) = cons_AV (vec C D) (vec A B).\nParameter AV0 : AV.\n\nParameter image_angle : R -> AV.\n \nAxiom AV0_zero : AV0 = image_angle 0.\n \nAxiom\n unicite_representant_angle_nul :\n forall A B C : PO,\n distance A B = 1 ->\n distance A C = 1 -> cons_AV (vec A B) (vec A C) = image_angle 0 -> C = B.\n \nAxiom\n tout_angle_a_une_mesure :\n forall A B C D : PO,\n A <> B :>PO ->\n C <> D :>PO ->\n exists x : R, image_angle x = cons_AV (vec A B) (vec C D) :>AV.\n\nAxiom\n add_mes_compatible :\n forall x y : R,\n image_angle (x + y) = plus (image_angle x) (image_angle y).\n \nAxiom mes_opp : forall x : R, image_angle (- x) = opp (image_angle x).\n\nParameter pisurdeux : R.\n \nDefinition pi := pisurdeux + pisurdeux.\n \nDefinition deuxpi := pi + pi.\n \nAxiom\n angle_plat :\n forall A B : PO, A <> B -> image_angle pi = cons_AV (vec A B) (vec B A).\n \nAxiom\n pisurdeux_droit :\n forall A B C : PO,\n image_angle pisurdeux = cons_AV (vec A B) (vec A C) ->\n orthogonal (vec A B) (vec A C).\n \nAxiom\n droit_direct_ou_indirect :\n forall A B C : PO,\n A <> B ->\n A <> C ->\n orthogonal (vec A B) (vec A C) ->\n image_angle pisurdeux = cons_AV (vec A B) (vec A C) \\/\n image_angle (- pisurdeux) = cons_AV (vec A B) (vec A C).\n \nLemma existence_representant_angle :\n forall (A B C : PO) (x : R),\n distance A B = 1 ->\n exists D : PO,\n distance C D = 1 /\\ image_angle x = cons_AV (vec A B) (vec C D).\nProof.\nAdmitted.\n \nLemma tout_angle_mesure : forall a : AV, exists x : R, a = image_angle x :>AV.\nProof.\nAdmitted.\n#[export] Hint Resolve mes_opp add_mes_compatible: geo.\n \nLtac mes a :=\n elim (tout_angle_mesure a); intros;\n match goal with\n | h:(a = image_angle ?X1) |- _ =>\n try rewrite h; repeat rewrite <- mes_opp;\n repeat rewrite <- add_mes_compatible; repeat rewrite <- mes_opp\n end.\n#[export] Hint Resolve def_opp Chasles angles_representants_unitaires: geo.\n \nLtac mesure A B C D :=\n elim (tout_angle_a_une_mesure (A:=A) (B:=B) (C:=C) (D:=D)); auto with geo;\n intros;\n match goal with\n | h:(image_angle ?X1 = cons_AV (vec A B) (vec C D)) |- _ =>\n try rewrite <- h; repeat rewrite <- mes_opp;\n repeat rewrite <- add_mes_compatible; repeat rewrite <- mes_opp\n end.\n \nLemma plus_commutative : forall a b : AV, plus a b = plus b a :>AV.\nProof.\nAdmitted.\n \nLemma plus_angle_zero : forall a : AV, plus a (image_angle 0) = a.\nProof.\nAdmitted.\n \nLemma plus_associative :\n forall a b c : AV, plus a (plus b c) = plus (plus a b) c :>AV.\nProof.\nAdmitted.\n#[export] Hint Resolve plus_angle_zero: geo.\n \nLemma opp_angle :\n forall a b : AV, plus a b = image_angle 0 :>AV -> b = opp a :>AV.\nProof.\nAdmitted.\n \nLemma plus_angle_oppose : forall a : AV, plus a (opp a) = image_angle 0.\nProof.\nAdmitted.\n \nLemma mes_oppx :\n forall (A B C D : PO) (x : R),\n A <> B ->\n C <> D ->\n image_angle x = cons_AV (vec A B) (vec C D) ->\n image_angle (- x) = cons_AV (vec C D) (vec A B).\nProof.\nAdmitted.\n \nLemma mes_opp_opp :\n forall (A B C D E F G I : PO) (a b : R),\n A <> B ->\n C <> D ->\n E <> F ->\n G <> I ->\n image_angle a = cons_AV (vec A B) (vec C D) ->\n image_angle b = cons_AV (vec E F) (vec G I) ->\n image_angle b = image_angle (- a) ->\n cons_AV (vec E F) (vec G I) = opp (cons_AV (vec A B) (vec C D)).\nProof.\nAdmitted.\n \nLemma permute_angles :\n forall A B C D E F G I : PO,\n A <> B :>PO ->\n C <> D :>PO ->\n E <> F :>PO ->\n G <> I :>PO ->\n cons_AV (vec A B) (vec C D) = cons_AV (vec E F) (vec G I) :>AV ->\n cons_AV (vec C D) (vec A B) = cons_AV (vec G I) (vec E F) :>AV.\nProof.\nAdmitted.\n#[export] Hint Resolve permute_angles: geo.\n \nLemma opp_plus_plus_opp :\n forall A B C D E F G I : PO,\n A <> B :>PO ->\n C <> D :>PO ->\n E <> F :>PO ->\n G <> I :>PO ->\n opp (plus (cons_AV (vec A B) (vec C D)) (cons_AV (vec E F) (vec G I))) =\n plus (opp (cons_AV (vec A B) (vec C D))) (opp (cons_AV (vec E F) (vec G I)))\n :>AV.\nProof.\nAdmitted.\n#[export] Hint Resolve opp_plus_plus_opp: geo.\n \nLemma Chasles_diff :\n forall A B C D E F : PO,\n A <> B :>PO ->\n C <> D :>PO ->\n E <> F :>PO ->\n plus (cons_AV (vec A B) (vec C D)) (opp (cons_AV (vec A B) (vec E F))) =\n cons_AV (vec E F) (vec C D) :>AV.\nProof.\nAdmitted.\n#[export] Hint Resolve pisurdeux_droit: geo.\n \nLemma pisurdeux_scalaire_nul :\n forall A B C : PO,\n image_angle pisurdeux = cons_AV (vec A B) (vec A C) ->\n scalaire (vec A B) (vec A C) = 0.\nProof.\nAdmitted.\n#[export] Hint Resolve pisurdeux_scalaire_nul: geo.\n \nLemma orthogonal_pisurdeux_or :\n forall A B C D : PO,\n A <> B ->\n C <> D ->\n orthogonal (vec A B) (vec C D) ->\n image_angle pisurdeux = cons_AV (vec A B) (vec C D) \\/\n image_angle (- pisurdeux) = cons_AV (vec A B) (vec C D).\nProof.\nAdmitted.\n \nLemma angle_nul :\n forall A B : PO, A <> B -> image_angle 0 = cons_AV (vec A B) (vec A B).\nProof.\nAdmitted.\n \nLemma pi_plus_pi : image_angle deuxpi = image_angle 0.\nProof.\nAdmitted.\n \nLemma mesure_mod_deuxpi :\n forall (x : R) (A B C D : PO),\n A <> B ->\n C <> D ->\n image_angle x = cons_AV (vec A B) (vec C D) ->\n image_angle (x + deuxpi) = cons_AV (vec A B) (vec C D).\nProof.\nAdmitted.\n \nLemma angle_oppu_oppv :\n forall A B C D : PO,\n A <> B :>PO ->\n C <> D :>PO ->\n cons_AV (vec B A) (vec D C) = cons_AV (vec A B) (vec C D) :>AV.\nProof.\nAdmitted.\n#[export] Hint Resolve angle_oppu_oppv: geo.\n \nTheorem somme_triangle :\n forall A B C : PO,\n A <> B :>PO ->\n A <> C :>PO ->\n B <> C :>PO ->\n plus (cons_AV (vec A B) (vec A C))\n (plus (cons_AV (vec B C) (vec B A)) (cons_AV (vec C A) (vec C B))) =\n image_angle pi :>AV.\nProof.\nAdmitted.\n \nLemma angle_triangle :\n forall A B C : PO,\n A <> B ->\n A <> C ->\n B <> C ->\n plus (image_angle pi)\n (opp (plus (cons_AV (vec A B) (vec A C)) (cons_AV (vec B C) (vec B A)))) =\n cons_AV (vec C A) (vec C B).\nProof.\nAdmitted.\n#[export] Hint Resolve angle_triangle: geo.\n \nLemma angles_complementaires_triangle_rectangle :\n forall (A B C : PO) (a : R),\n A <> B ->\n A <> C ->\n B <> C ->\n orthogonal (vec B A) (vec B C) ->\n image_angle a = cons_AV (vec A B) (vec A C) ->\n image_angle (pisurdeux + - a) = cons_AV (vec C A) (vec C B) \\/\n image_angle (- pisurdeux + - a) = cons_AV (vec C A) (vec C B).\nProof.\nAdmitted.\n \nLemma angle_produit_positif_r :\n forall (k : R) (A B C D E : PO),\n A <> B :>PO ->\n D <> E :>PO ->\n k > 0 ->\n vec A C = mult_PP k (vec A B) :>PP ->\n cons_AV (vec D E) (vec A C) = cons_AV (vec D E) (vec A B).\nProof.\nAdmitted.\n#[export] Hint Resolve angles_representants_unitaires: geo.\n \nLemma angle_produit_negatif_r :\n forall (k : R) (A B C D E : PO),\n A <> B ->\n D <> E ->\n k < 0 ->\n vec A C = mult_PP k (vec A B) ->\n cons_AV (vec D E) (vec A C) =\n plus (cons_AV (vec D E) (vec A B)) (image_angle pi).\nProof.\nAdmitted.\n \nLemma angle_produit_negatif_r2 :\n forall (k : R) (A B C D : PO),\n A <> B ->\n C <> D ->\n k < 0 ->\n cons_AV (vec C D) (mult_PP k (vec A B)) =\n plus (cons_AV (vec C D) (vec A B)) (image_angle pi).\nProof.\nAdmitted.\n \nLemma angle_produit_negatif_l :\n forall (k : R) (A B C D : PO),\n A <> B ->\n C <> D ->\n k < 0 ->\n cons_AV (mult_PP k (vec A B)) (vec C D) =\n plus (cons_AV (vec A B) (vec C D)) (image_angle pi).\nProof.\nAdmitted.\n \nLemma angle_produit_positif_r2 :\n forall (k : R) (A B C D : PO),\n A <> B ->\n C <> D ->\n k > 0 ->\n cons_AV (vec C D) (mult_PP k (vec A B)) = cons_AV (vec C D) (vec A B).\nProof.\nAdmitted.\n \nLemma angle_produit_positif_l :\n forall (k : R) (A B C D : PO),\n A <> B ->\n C <> D ->\n k > 0 ->\n cons_AV (mult_PP k (vec A B)) (vec C D) = cons_AV (vec A B) (vec C D).\nProof.\nAdmitted.\n \nLemma angle_nul_positif_colineaire :\n forall A B C : PO,\n A <> B ->\n A <> C ->\n cons_AV (vec A B) (vec A C) = image_angle 0 ->\n exists k : R, k > 0 /\\ vec A C = mult_PP k (vec A B).\nProof.\nAdmitted.\n \nLemma angles_milieu :\n forall A B C I : PO,\n B <> C :>PO ->\n B <> A :>PO ->\n I = milieu B C :>PO ->\n cons_AV (vec B C) (vec B A) = cons_AV (vec B I) (vec B A) :>AV.\nProof.\nAdmitted.\n \nLemma angles_milieu2 :\n forall A B C I : PO,\n B <> C :>PO ->\n C <> A :>PO ->\n I = milieu B C :>PO ->\n cons_AV (vec C A) (vec C B) = cons_AV (vec C A) (vec C I) :>AV.\nProof.\nAdmitted.\n \nLemma milieu_angles :\n forall A B M N : PO,\n A <> B ->\n M <> N ->\n M = milieu A B ->\n cons_AV (vec M A) (vec M N) =\n plus (cons_AV (vec M B) (vec M N)) (image_angle pi) :>AV.\nProof.\nAdmitted.\n \nAxiom\n milieu_angles_orthogonaux :\n forall A B M N : PO,\n A <> B ->\n M <> N ->\n M = milieu A B ->\n orthogonal (vec A B) (vec M N) ->\n cons_AV (vec M A) (vec M N) = cons_AV (vec M N) (vec M B) :>AV.\n \nLemma alignes_distance_positif_colineaire :\n forall (k : R) (A B C : PO),\n A <> B ->\n A <> C ->\n cons_AV (vec A B) (vec A C) = image_angle 0 ->\n distance A C = k * distance A B -> vec A C = mult_PP k (vec A B).\nProof.\nAdmitted.\n \nLemma angle_pi_negatif_colineaire :\n forall A B C : PO,\n A <> B ->\n A <> C ->\n cons_AV (vec A B) (vec A C) = image_angle pi ->\n exists k : R, k < 0 /\\ vec A C = mult_PP k (vec A B).\nProof.\nAdmitted.\n \nLemma alignes_distance_negatif_colineaire :\n forall (k : R) (A B C : PO),\n A <> B ->\n A <> C ->\n cons_AV (vec A B) (vec A C) = image_angle pi ->\n distance A C = k * distance A B -> vec A C = mult_PP (- k) (vec A B).\nProof.\nAdmitted.\n#[export] Hint Resolve plus_angle_zero: geo." }, { "theorem_id": 33, "title": "030_the_ballot_problem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/binomial.ml\";;\n\nprioritize_num();;\n\nparse_as_infix(\"-->\",(13,\"right\"));;\n\nlet funspace = new_definition\n `(s --> t) = {f:A->B | (!x. x IN s ==> f(x) IN t) /\\\n (!x. ~(x IN s) ==> f(x) = @y. T)}`;;\n\nlet FUNSPACE_EMPTY = `({} --> t) = {(\\x. @y. T)}`;;\n\nlet HAS_SIZE_FUNSPACE = `!s:A->bool t:B->bool m n.\n s HAS_SIZE m /\\ t HAS_SIZE n ==> (s --> t) HAS_SIZE (n EXP m)`;;\n\nlet FINITE_FUNSPACE = `!s t. FINITE s /\\ FINITE t ==> FINITE(s --> t)`;;\n\nlet vote_INDUCT,vote_RECURSION = define_type\n \"vote = A | B\";;\n\nlet all_countings = new_definition\n `all_countings a b =\n let n = a + b in\n CARD {f | f IN (1..n --> {A,B}) /\\\n CARD { i | i IN 1..n /\\ f(i) = A} = a /\\\n CARD { i | i IN 1..n /\\ f(i) = B} = b}`;;\n\nlet valid_countings = new_definition\n `valid_countings a b =\n let n = a + b in\n CARD {f | f IN (1..n --> {A,B}) /\\\n CARD { i | i IN 1..n /\\ f(i) = A} = a /\\\n CARD { i | i IN 1..n /\\ f(i) = B} = b /\\\n !m. 1 <= m /\\ m <= n\n ==> CARD { i | i IN 1..m /\\ f(i) = A} >\n CARD { i | i IN 1..m /\\ f(i) = B}}`;;\n\nlet vote_CASES = cases \"vote\"\nand vote_DISTINCT = distinctness \"vote\";;\n\nlet FINITE_COUNTINGS = `FINITE {f | f IN (1..n --> {A,B}) /\\ P f}`;;\n\nlet UNIV_VOTE = `(:vote) = {A,B}`;;\n\nlet ADD1_NOT_IN_NUMSEG = `!m n. ~((n + 1) IN m..n)`;;\n\nlet NUMSEG_1_CLAUSES = `!n. 1..(n+1) = (n + 1) INSERT (1..n)`;;\n\nlet NUMSEG_RESTRICT_SUC = `{i | i IN 1..(n+1) /\\ P i} =\n if P(n + 1) then (n + 1) INSERT {i | i IN 1..n /\\ P i}\n else {i | i IN 1..n /\\ P i}`;;\n\nlet CARD_NUMSEG_RESTRICT_SUC = `CARD {i | i IN 1..(n+1) /\\ P i} =\n if P(n + 1) then CARD {i | i IN 1..n /\\ P i} + 1\n else CARD {i | i IN 1..n /\\ P i}`;;\n\nlet FORALL_RANGE_SUC = `(!i. 1 <= i /\\ i <= n + 1 ==> P i) <=>\n P(n + 1) /\\ (!i. 1 <= i /\\ i <= n ==> P i)`;;\n\nlet IN_NUMSEG_RESTRICT_FALSE = `m <= n\n ==> (i IN 1..m /\\ (if i = n + 1 then p i else q i) <=> i IN 1..m /\\ q i)`;;\n\nlet CARD_NUMSEG_RESTRICT_EXTREMA = `(CARD {i | i IN 1..n /\\ P i} = n <=> !i. 1 <= i /\\ i <= n ==> P i) /\\\n (CARD {i | i IN 1..n /\\ P i} = 0 <=> !i. 1 <= i /\\ i <= n ==> ~(P i))`;;\n\nlet VOTE_NOT_EQ = `(!x. ~(x = A) <=> x = B) /\\\n (!x. ~(x = B) <=> x = A)`;;\n\nlet FUNSPACE_FIXED = `{f | f IN (s --> t) /\\ (!i. i IN s ==> f i = a)} =\n if s = {} \\/ a IN t then {(\\i. if i IN s then a else @x. T)} else {}`;;\n\nlet COUNTING_LEMMA = `CARD {f | f IN (1..(n+1) --> {A,B}) /\\ P f} =\n CARD {f | f IN (1..n --> {A,B}) /\\ P (\\i. if i = n + 1 then A else f i)} +\n CARD {f | f IN (1..n --> {A,B}) /\\ P (\\i. if i = n + 1 then B else f i)}`;;\n\nlet ALL_COUNTINGS_0 = `!a. all_countings a 0 = 1 /\\ all_countings 0 a = 1`;;\n\nlet VALID_COUNTINGS_0 = `valid_countings 0 0 = 1 /\\\n !a. valid_countings (SUC a) 0 = 1 /\\ valid_countings 0 (SUC a) = 0`;;\n\nlet ALL_COUNTINGS_SUC = `!a b. all_countings (a + 1) (b + 1) =\n all_countings a (b + 1) + all_countings (a + 1) b`;;\n\nlet VALID_COUNTINGS_SUC = `!a b. valid_countings (a + 1) (b + 1) =\n if a <= b then 0\n else valid_countings a (b + 1) + valid_countings (a + 1) b`;;\n\nlet ALL_COUNTINGS = `!a b. all_countings a b = binom(a + b,a)`;;\n\nlet VALID_COUNTINGS = `!a b. (a + b) * valid_countings a b = (a - b) * binom(a + b,a)`;;\n\nlet BALLOT = `!a b. &(valid_countings a b) =\n if a <= b then if b = 0 then &1 else &0\n else (&a - &b) / (&a + &b) * &(all_countings a b)`;;" }, { "theorem_id": 33, "title": "030_the_ballot_problem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Bertrand's Ballot Theorem\\\n\ntheory Ballot\nimports\n Complex_Main\n \"HOL-Library.FuncSet\"\nbegin\n\nsubsection \\Preliminaries\\\n\nlemma card_bij':\n assumes \"f \\ A \\ B\" \"\\x. x \\ A \\ g (f x) = x\"\n and \"g \\ B \\ A\" \"\\x. x \\ B \\ f (g x) = x\"\n shows \"card A = card B\"\n by sorry\n\nsubsection \\Formalization of Problem Statement\\\n\nsubsubsection \\Basic Definitions\\\n\ndatatype vote = A | B\n\ndefinition\n \"all_countings a b = card {f \\ {1 .. a + b} \\\\<^sub>E {A, B}.\n card {x \\ {1 .. a + b}. f x = A} = a \\ card {x \\ {1 .. a + b}. f x = B} = b}\"\n\ndefinition\n \"valid_countings a b =\n card {f\\{1..a+b} \\\\<^sub>E {A, B}.\n card {x\\{1..a+b}. f x = A} = a \\ card {x\\{1..a+b}. f x = B} = b \\\n (\\m\\{1..a+b}. card {x\\{1..m}. f x = A} > card {x\\{1..m}. f x = B})}\"\n\nsubsubsection \\Equivalence with Set Cardinality\\\n\nlemma Collect_on_transfer:\n assumes \"rel_set R X Y\"\n shows \"rel_fun (rel_fun R (=)) (rel_set R) (\\P. {x\\X. P x}) (\\P. {y\\Y. P y})\"\n by sorry\n\nlemma rel_fun_trans:\n \"rel_fun P Q g g' \\ rel_fun R P f f' \\ rel_fun R Q (\\x. g (f x)) (\\y. g' (f' y))\"\n by sorry\n\nlemma rel_fun_trans2:\n \"rel_fun P1 (rel_fun P2 Q) g g' \\ rel_fun R P1 f1 f1' \\ rel_fun R P2 f2 f2' \\\n rel_fun R Q (\\x. g (f1 x) (f2 x)) (\\y. g' (f1' y) (f2' y))\"\n by sorry\n\nlemma rel_fun_trans2':\n \"rel_fun R (=) f1 f1' \\ rel_fun R (=) f2 f2' \\\n rel_fun R (=) (\\x. g (f1 x) (f2 x)) (\\y. g (f1' y) (f2' y))\"\n by sorry\n\nlemma rel_fun_const: \"rel_fun R (=) (\\x. a) (\\y. a)\"\n by sorry\n\nlemma rel_fun_conj:\n \"rel_fun R (=) f f' \\ rel_fun R (=) g g' \\ rel_fun R (=) (\\x. f x \\ g x) (\\y. f' y \\ g' y)\"\n by sorry\n\nlemma rel_fun_ball:\n \"(\\i. i \\ I \\ rel_fun R (=) (f i) (f' i)) \\ rel_fun R (=) (\\x. \\i\\I. f i x) (\\y. \\i\\I. f' i y)\"\n by sorry\n\nlemma\n shows all_countings_set: \"all_countings a b = card {V\\Pow {0..Pow {0.. (\\m\\{1..a+b}. card ({0.. V) > m - card ({0.. V))}\"\n (is \"_ = card ?V\")\n by sorry\n\nlemma all_countings [code]: \"all_countings a b = (a + b) choose a\"\n by sorry\n\nsubsection \\Facts About \\<^term>\\valid_countings\\\\\n\nsubsubsection \\Non-Recursive Cases\\\n\nlemma card_V_eq_a: \"V \\ {0.. card V = a \\ V = {0.. b \\ 0 < b \\ valid_countings a b = 0\"\n by sorry\n\nlemma Ico_subset_finite: \"i \\ {a ..< b::nat} \\ finite i\"\n by sorry\n\nlemma Icc_Suc2: \"a \\ b \\ {a..Suc b} = insert (Suc b) {a..b}\"\n by sorry\n\nlemma Ico_Suc2: \"a \\ b \\ {a..Relation Between \\<^term>\\valid_countings\\ and \\<^term>\\all_countings\\\\\n\nlemma main_nat: \"(a + b) * valid_countings a b = (a - b) * all_countings a b\"\n by sorry\n\nlemma main_real:\n assumes \"b < a\"\n shows \"valid_countings a b = (a - b) / (a + b) * all_countings a b\"\n by sorry\n\nlemma\n \"valid_countings a b = (if a \\ b then (if b = 0 then 1 else 0) else (a - b) / (a + b) * all_countings a b)\"\n by sorry\n\nsubsubsection \\Executable Definition\\\n\nvalue \"all_countings 1 0\"\nvalue \"all_countings 0 1\"\nvalue \"all_countings 1 1\"\nvalue \"all_countings 2 1\"\nvalue \"all_countings 1 2\"\nvalue \"all_countings 2 4\"\nvalue \"all_countings 4 2\"\n\nsubsubsection \\Executable Definition\\\n\nvalue \"valid_countings 1 0\"\nvalue \"valid_countings 0 1\"\nvalue \"valid_countings 1 1\"\nvalue \"valid_countings 2 1\"\nvalue \"valid_countings 1 2\"\nvalue \"valid_countings 2 4\"\nvalue \"valid_countings 4 2\"\n\nend" }, { "theorem_id": 33, "title": "030_the_ballot_problem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2022 Bhavik Mehta, Kexing Ying. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Kexing Ying\n-/\nimport Mathlib.Probability.UniformOn\n\n/-!\n# Ballot problem\n\nThis file proves Theorem 30 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/).\n\nThe ballot problem asks, if in an election, candidate A receives `p` votes whereas candidate B\nreceives `q` votes where `p > q`, what is the probability that candidate A is strictly ahead\nthroughout the count. The probability of this is `(p - q) / (p + q)`.\n\n## Main definitions\n\n* `countedSequence`: given natural numbers `p` and `q`, `countedSequence p q` is the set of\n all lists containing `p` of `1`s and `q` of `-1`s representing the votes of candidate A and B\n respectively.\n* `staysPositive`: is the set of lists of integers which suffix has positive sum. In particular,\n the intersection of this set with `countedSequence` is the set of lists where candidate A is\n strictly ahead.\n\n## Main result\n\n* `ballot_problem`: the ballot problem.\n\n-/\n\n\nopen Set ProbabilityTheory MeasureTheory\nopen scoped ENNReal\n\nnamespace Ballot\n\n/-- The set of nonempty lists of integers which suffix has positive sum. -/\ndef staysPositive : Set (List ℤ) :=\n {l | ∀ l₂, l₂ ≠ [] → l₂ <:+ l → 0 < l₂.sum}\n\n@[simp]\ntheorem staysPositive_nil : [] ∈ staysPositive :=\n fun _ hl hl₁ => (hl (List.eq_nil_of_suffix_nil hl₁)).elim\n\ntheorem staysPositive_suffix {l₁ l₂ : List ℤ} (hl₂ : l₂ ∈ staysPositive) (h : l₁ <:+ l₂) :\n l₁ ∈ staysPositive := fun l hne hl ↦ hl₂ l hne <| hl.trans h\n\ntheorem staysPositive_cons {x : ℤ} {l : List ℤ} :\n x::l ∈ staysPositive ↔ l ∈ staysPositive ∧ 0 < x + l.sum := by sorry\ntheorem sum_nonneg_of_staysPositive : ∀ {l : List ℤ}, l ∈ staysPositive → 0 ≤ l.sum := by sorry\ntheorem staysPositive_cons_pos (x : ℤ) (hx : 0 < x) (l : List ℤ) :\n (x::l) ∈ staysPositive ↔ l ∈ staysPositive := by sorry\ndef countedSequence (p q : ℕ) : Set (List ℤ) :=\n {l | l.count 1 = p ∧ l.count (-1) = q ∧ ∀ x ∈ l, x = (1 : ℤ) ∨ x = -1}\n\nopen scoped List in\n/-- An alternative definition of `countedSequence` that uses `List.Perm`. -/\ntheorem mem_countedSequence_iff_perm {p q l} :\n l ∈ countedSequence p q ↔ l ~ List.replicate p (1 : ℤ) ++ List.replicate q (-1) := by sorry\ntheorem counted_right_zero (p : ℕ) : countedSequence p 0 = {List.replicate p 1} := by sorry\ntheorem counted_left_zero (q : ℕ) : countedSequence 0 q = {List.replicate q (-1)} := by sorry\ntheorem mem_of_mem_countedSequence {p q} {l} (hl : l ∈ countedSequence p q) {x : ℤ} (hx : x ∈ l) :\n x = 1 ∨ x = -1 :=\n hl.2.2 x hx\n\ntheorem length_of_mem_countedSequence {p q} {l : List ℤ} (hl : l ∈ countedSequence p q) :\n l.length = p + q := by simp [(mem_countedSequence_iff_perm.1 hl).length_eq]\n\ntheorem counted_eq_nil_iff {p q : ℕ} {l : List ℤ} (hl : l ∈ countedSequence p q) :\n l = [] ↔ p = 0 ∧ q = 0 :=\n List.length_eq_zero_iff.symm.trans <| by simp [length_of_mem_countedSequence hl]\n\ntheorem counted_ne_nil_left {p q : ℕ} (hp : p ≠ 0) {l : List ℤ} (hl : l ∈ countedSequence p q) :\n l ≠ [] := by simp [counted_eq_nil_iff hl, hp]\n\ntheorem counted_ne_nil_right {p q : ℕ} (hq : q ≠ 0) {l : List ℤ} (hl : l ∈ countedSequence p q) :\n l ≠ [] := by simp [counted_eq_nil_iff hl, hq]\n\ntheorem counted_succ_succ (p q : ℕ) :\n countedSequence (p + 1) (q + 1) =\n List.cons 1 '' countedSequence p (q + 1) ∪ List.cons (-1) '' countedSequence (p + 1) q := by sorry\ntheorem countedSequence_finite : ∀ p q : ℕ, (countedSequence p q).Finite := by sorry\ntheorem countedSequence_nonempty : ∀ p q : ℕ, (countedSequence p q).Nonempty := by sorry\ntheorem sum_of_mem_countedSequence {p q} {l : List ℤ} (hl : l ∈ countedSequence p q) :\n l.sum = p - q := by simp [(mem_countedSequence_iff_perm.1 hl).sum_eq, sub_eq_add_neg]\n\ntheorem disjoint_bits (p q : ℕ) :\n Disjoint (List.cons 1 '' countedSequence p (q + 1))\n (List.cons (-1) '' countedSequence (p + 1) q) := by sorry\nopen MeasureTheory.Measure\n\nprivate local instance measurableSpace_list_int : MeasurableSpace (List ℤ) := ⊤\n\nprivate local instance measurableSingletonClass_list_int : MeasurableSingletonClass (List ℤ) :=\n { measurableSet_singleton := fun _ => trivial }\n\nprivate theorem list_int_measurableSet {s : Set (List ℤ)} : MeasurableSet s := trivial\n\ntheorem count_countedSequence : ∀ p q : ℕ, count (countedSequence p q) = (p + q).choose p := by sorry\ntheorem first_vote_pos :\n ∀ p q,\n 0 < p + q → uniformOn (countedSequence p q : Set (List ℤ)) {l | l.headI = 1} = p / (p + q) := by sorry\ntheorem headI_mem_of_nonempty {α : Type*} [Inhabited α] : ∀ {l : List α} (_ : l ≠ []), l.headI ∈ l := by sorry\ntheorem first_vote_neg (p q : ℕ) (h : 0 < p + q) :\n uniformOn (countedSequence p q) {l | l.headI = 1}ᶜ = q / (p + q) := by sorry\ntheorem ballot_same (p : ℕ) : uniformOn (countedSequence (p + 1) (p + 1)) staysPositive = 0 := by sorry\ntheorem ballot_edge (p : ℕ) : uniformOn (countedSequence (p + 1) 0) staysPositive = 1 := by sorry\ntheorem countedSequence_int_pos_counted_succ_succ (p q : ℕ) :\n countedSequence (p + 1) (q + 1) ∩ {l | l.headI = 1} =\n (countedSequence p (q + 1)).image (List.cons 1) := by sorry\ntheorem ballot_pos (p q : ℕ) :\n uniformOn (countedSequence (p + 1) (q + 1) ∩ {l | l.headI = 1}) staysPositive =\n uniformOn (countedSequence p (q + 1)) staysPositive := by sorry\ntheorem countedSequence_int_neg_counted_succ_succ (p q : ℕ) :\n countedSequence (p + 1) (q + 1) ∩ {l | l.headI = 1}ᶜ =\n (countedSequence (p + 1) q).image (List.cons (-1)) := by sorry\ntheorem ballot_neg (p q : ℕ) (qp : q < p) :\n uniformOn (countedSequence (p + 1) (q + 1) ∩ {l | l.headI = 1}ᶜ) staysPositive =\n uniformOn (countedSequence (p + 1) q) staysPositive := by sorry\ntheorem ballot_problem' :\n ∀ q p, q < p → (uniformOn (countedSequence p q) staysPositive).toReal = (p - q) / (p + q) := by sorry\ntheorem ballot_problem :\n ∀ q p, q < p → uniformOn (countedSequence p q) staysPositive = (p - q) / (p + q) := by sorry\nend Ballot\n" }, { "theorem_id": 33, "title": "030_the_ballot_problem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Arith.\nRequire Import ZArith.\nRequire Import String.\nRequire Import List.\nRequire Import Psatz.\nRequire Import Factorial.\n\nLemma recurrence a b Afirst Bfirst all Afirst_ahead Bfirst_ahead ahead :\n 0 < b -> b < a ->\n (a + b) * Afirst = a * all ->\n (a + b) * Bfirst = b * all ->\n Afirst + Bfirst = all ->\n (a - 1 + b) * Afirst_ahead = (a - b - 1) * Afirst ->\n (a - 1 + b) * Bfirst_ahead = (a - (b - 1)) * Bfirst ->\n Afirst_ahead + Bfirst_ahead = ahead ->\n (a + b) * ahead = (a - b) * all.\nProof.\nAdmitted.\n\nImport ListNotations.\n\nFixpoint cartesian_product {A B} (xs : list A) (ys : list B) : list (A * B) :=\n match xs with\n | [] => []\n | x :: xs => map (pair x) ys ++ cartesian_product xs ys\n end.\n\nFixpoint picks {A} n (l : list A) : list (list A) :=\n match n with\n | O => [[]]\n | S n => map (fun x => fst x :: snd x) (cartesian_product l (picks n l))\n end.\n\nFixpoint pickbools n :=\n match n with\n | O => [[]]\n | S n => map (cons true) (pickbools n) ++ map (cons false) (pickbools n)\n end.\n\nFixpoint proper_suffixes {A} (l : list A) : list (list A) :=\n match l with\n | [] => []\n | x :: l => (x :: l) :: proper_suffixes l\n end.\n\nDefinition throughout {A} f (l : list A) := forallb f (proper_suffixes l).\n\nDefinition countb b l := count_occ Bool.bool_dec l b.\n\nNotation length := length.\n\nLemma countb_false l : countb false l = length l - countb true l.\nProof.\nAdmitted.\n\nDefinition winb votes := countb false votes B) l :\n filter f (map g l) = map g (filter (fun b => f (g b)) l).\nProof.\nAdmitted.\n\nLemma filter_filter {A} (f g : A -> bool) l :\n filter f (filter g l) = filter (fun b => andb (g b) (f b)) l.\nProof.\nAdmitted.\n\nLemma filter_ext {A} f g l : (forall x : A, f x = g x) -> filter f l = filter g l.\nProof.\nAdmitted.\n\nLemma filter_sub {A} f g l : (forall x : A, f x = true -> g x = true) -> filter f l = filter g (filter f l).\nProof.\nAdmitted.\n\nFixpoint binomial (n k : nat) : nat :=\n match n with\n | 0 =>\n match k with\n | 0 => 1\n | S _ => 0\n end\n | S n' =>\n match k with\n | 0 => 1\n | S k' => (binomial n' k') + (binomial n' k)\n end\n end.\n\nLemma binomial_lt n p : n < p -> binomial n p = 0.\nProof.\nAdmitted.\n\nLemma binomial_0_r n : binomial n 0 = 1.\nProof.\nAdmitted.\n\nLemma binomial_1_r n : binomial n 1 = n.\nProof.\nAdmitted.\n\nLemma binomial_diag n : binomial n n = 1.\nProof.\nAdmitted.\n\nLemma binomial_factorial n k : k <= n -> fact k * fact (n - k) * binomial n k = fact n.\nProof.\nAdmitted.\n\nLemma binomial_complement n k : k <= n -> binomial n k = binomial n (n - k).\nProof.\nAdmitted.\n\nLemma binomial_S n k :\n k <= n ->\n S n * binomial n k = S k * binomial (S n) (S k).\nProof.\nAdmitted.\n\nLemma count_sumtrue_cons_true p l :\n filter (sumtrue (S p)) (map (cons true) l) =\n map (cons true) (filter (sumtrue p) l).\nProof.\nAdmitted.\n\nLemma count_0_wins_cons_true l :\n filter (sumtrue 0) (map (cons true) l) = [].\nProof.\nAdmitted.\n\nLemma count_sumtrue_cons_false p l :\n filter (sumtrue p) (map (cons false) l) =\n map (cons false) (filter (sumtrue p) l).\nProof.\nAdmitted.\n\nLemma count_sumtrue p n :\n length (filter (sumtrue p) (pickbools n)) = binomial n p.\nProof.\nAdmitted.\n\nLemma first_vote_split p q :\n filter (sumtrue (1 + p)) (pickbools (1 + p + q)) =\n map (cons true) (filter (sumtrue p) (pickbools (p + q))) ++\n map (cons false) (filter (sumtrue (1 + p)) (pickbools (p + q))).\nProof.\nAdmitted.\n\nLemma pickbools_length n : pickbools n = filter (fun l => length l =? n) (pickbools n).\nProof.\nAdmitted.\n\nLemma counting_wins p q :\n q < p ->\n filter winb (filter (sumtrue p) (pickbools (p + q))) =\n filter (sumtrue p) (pickbools (p + q)).\nProof.\nAdmitted.\n\nLemma pickbools_wins_minus p q :\n q <= p ->\n (p - q) * length (filter (sumtrue p) (pickbools (p + q))) =\n (p - q) * length (filter winb (filter (sumtrue p) (pickbools (p + q)))).\nProof.\nAdmitted.\n \nLemma bertrand_ballot_bool_eq p q :\n p <> 0 ->\n p = q ->\n let l := filter (fun votes => countb true votes =? p) (pickbools (p + q)) in\n (p + q) * length (filter (throughout winb) l) =\n (p - q) * length (filter winb l).\nProof.\nAdmitted.\n\nTheorem bertrand_ballot_bool p q :\n q <= p ->\n let l := filter (sumtrue p) (pickbools (p + q)) in\n (p + q) * length (filter (throughout winb) l) =\n (p - q) * length (filter winb l).\nProof.\nAdmitted.\n\nDefinition count_votes := count_occ string_dec.\n\nDefinition wins A B votes := count_votes votes B count_votes votes \"A\" =? p)%nat (picks (p + q) [\"A\"; \"B\"]) in\n p >= q ->\n (p + q) * List.\nProof.\nAdmitted." }, { "theorem_id": 34, "title": "034_divergence_of_the_harmonic_series", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "prioritize_real();;\n\nlet HARMONIC_DIVERGES = `~(?s. !e. &0 < e\n ==> ?N. !n. N <= n ==> abs(sum(1..n) (\\i. &1 / &i) - s) < e)`;;\n\nneeds \"Library/analysis.ml\";;\n\nlet HARMONIC_DIVERGES' = `~(convergent (\\n. sum(1..n) (\\i. &1 / &i)))`;;\n\nlet HARMONIC_LEMMA = `!m. sum(1..2 EXP m) (\\n. &1 / &n) >= &m / &2`;;\n\nneeds \"Library/transc.ml\";;\n\nlet LOG_BOUND = `&0 < x /\\ x < &1 ==> ln(&1 + x) >= x / &2`;;" }, { "theorem_id": 34, "title": "034_divergence_of_the_harmonic_series", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Harmonic Numbers\\\n\ntheory Harmonic_Numbers\nimports\n Complex_Transcendental\n Summation_Tests\nbegin\n\ntext \\\n The definition of the Harmonic Numbers and the Euler-Mascheroni constant.\n Also provides a reasonably accurate approximation of \\<^term>\\ln 2 :: real\\\n and the Euler-Mascheroni constant.\n\\\n\nsubsection \\The Harmonic numbers\\\n\ndefinition\\<^marker>\\tag important\\ harm :: \"nat \\ 'a :: real_normed_field\" where\n \"harm n = (\\k=1..n. inverse (of_nat k))\"\n\nlemma harm_altdef: \"harm n = (\\k (0 :: 'a :: {real_normed_field,linordered_field})\"\n by sorry\n\nlemma harm_pos: \"n > 0 \\ harm n > (0 :: 'a :: {real_normed_field,linordered_field})\"\n by sorry\n\nlemma harm_mono: \"m \\ n \\ harm m \\ (harm n :: 'a :: {real_normed_field,linordered_field})\"\n by sorry\n\nlemma of_real_harm: \"of_real (harm n) = harm n\"\n by sorry\n\nlemma abs_harm [simp]: \"(abs (harm n) :: real) = harm n\"\n by sorry\n\nlemma norm_harm: \"norm (harm n) = harm n\"\n by sorry\n\nlemma harm_expand:\n \"harm 0 = 0\"\n \"harm (Suc 0) = 1\"\n \"harm (numeral n) = harm (pred_numeral n) + inverse (numeral n)\"\n by sorry\n\ntheorem not_convergent_harm: \"\\convergent (harm :: nat \\ 'a :: real_normed_field)\"\n by sorry\n\nlemma harm_pos_iff [simp]: \"harm n > (0 :: 'a :: {real_normed_field,linordered_field}) \\ n > 0\"\n by sorry\n\nlemma ln_diff_le_inverse:\n assumes \"x \\ (1::real)\"\n shows \"ln (x + 1) - ln x < 1 / x\"\n by sorry\n\nlemma ln_le_harm: \"ln (real n + 1) \\ (harm n :: real)\"\n by sorry\n\nlemma harm_at_top: \"filterlim (harm :: nat \\ real) at_top sequentially\"\n by sorry\n\nsubsection \\The Euler-Mascheroni constant\\\n\ntext \\\n The limit of the difference between the partial harmonic sum and the natural logarithm\n (approximately 0.577216). This value occurs e.g. in the definition of the Gamma function.\n \\\ndefinition euler_mascheroni :: \"'a :: real_normed_algebra_1\" where\n \"euler_mascheroni = of_real (lim (\\n. harm n - ln (of_nat n)))\"\n\nlemma of_real_euler_mascheroni [simp]: \"of_real euler_mascheroni = euler_mascheroni\"\n by sorry\n\nlemma harm_ge_ln: \"harm n \\ ln (real n + 1)\"\n by sorry\n\nlemma decseq_harm_diff_ln: \"decseq (\\n. harm (Suc n) - ln (Suc n))\"\n by sorry\n\nlemma euler_mascheroni_sequence_nonneg:\n assumes \"n > 0\"\n shows \"harm n - ln (real n) \\ (0 :: real)\"\n by sorry\n\nlemma euler_mascheroni_convergent: \"convergent (\\n. harm n - ln n)\"\n by sorry\n\nlemma euler_mascheroni_sequence_decreasing:\n \"m > 0 \\ m \\ n \\ harm n - ln (of_nat n) \\ harm m - ln (of_nat m :: real)\"\n by sorry\n \nlemma\\<^marker>\\tag important\\ euler_mascheroni_LIMSEQ:\n \"(\\n. harm n - ln (of_nat n) :: real) \\ euler_mascheroni\"\n by sorry\n\nlemma harm_le: \"n \\ 1 \\ harm n \\ ln n + 1\"\n by sorry\n\nlemma euler_mascheroni_LIMSEQ_of_real:\n \"(\\n. of_real (harm n - ln (of_nat n))) \\\n (euler_mascheroni :: 'a :: {real_normed_algebra_1, topological_space})\"\n by sorry\n\nlemma euler_mascheroni_sum_real:\n \"(\\n. inverse (of_nat (n+1)) + ln (of_nat (n+1)) - ln (of_nat (n+2)) :: real)\n sums euler_mascheroni\"\n by sorry\n\nlemma euler_mascheroni_sum:\n \"(\\n. inverse (of_nat (n+1)) + of_real (ln (of_nat (n+1))) - of_real (ln (of_nat (n+2))))\n sums (euler_mascheroni :: 'a :: {banach, real_normed_field})\"\n by sorry\n\ntheorem alternating_harmonic_series_sums: \"(\\k. (-1)^k / real_of_nat (Suc k)) sums ln 2\"\n by sorry\n\nlemma alternating_harmonic_series_sums':\n \"(\\k. inverse (real_of_nat (2*k+1)) - inverse (real_of_nat (2*k+2))) sums ln 2\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Bounds on the Euler-Mascheroni constant\\\n\nlemma ln_inverse_approx_le:\n assumes \"(x::real) > 0\" \"a > 0\"\n shows \"ln (x + a) - ln x \\ a * (inverse x + inverse (x + a))/2\" (is \"_ \\ ?A\")\n by sorry\n\nlemma ln_inverse_approx_ge:\n assumes \"(x::real) > 0\" \"x < y\"\n shows \"ln y - ln x \\ 2 * (y - x) / (x + y)\" (is \"_ \\ ?A\")\n by sorry\n\nlemma euler_mascheroni_lower:\n \"euler_mascheroni \\ harm (Suc n) - ln (real_of_nat (n + 2)) + 1/real_of_nat (2 * (n + 2))\"\n and euler_mascheroni_upper:\n \"euler_mascheroni \\ harm (Suc n) - ln (real_of_nat (n + 2)) + 1/real_of_nat (2 * (n + 1))\"\n by sorry\n\nlemma euler_mascheroni_pos: \"euler_mascheroni > (0::real)\"\n by sorry\n\ncontext\nbegin\n\nprivate lemma ln_approx_aux:\n fixes n :: nat and x :: real\n defines \"y \\ (x-1)/(x+1)\"\n assumes x: \"x > 0\" \"x \\ 1\"\n shows \"inverse (2*y^(2*n+1)) * (ln x - (\\k\n {0..(1 / (1 - y^2) / of_nat (2*n+1))}\"\nproof -\n from x have norm_y: \"norm y < 1\" unfolding y_def by simp\n from power_strict_mono[OF this, of 2] have norm_y': \"norm y^2 < 1\" by simp\n\n let ?f = \"\\k. 2 * y ^ (2*k+1) / of_nat (2*k+1)\"\n note sums = ln_series_quadratic[OF x(1)]\n define c where \"c = inverse (2*y^(2*n+1))\"\n let ?d = \"c * (ln x - (\\kk. y\\<^sup>2^k / of_nat (2*(k+n)+1) \\ y\\<^sup>2 ^ k / of_nat (2*n+1)\"\n by (intro divide_left_mono mult_right_mono mult_pos_pos zero_le_power[of \"y^2\"]) simp_all\n moreover {\n have \"(\\k. ?f (k + n)) sums (ln x - (\\kk. c * ?f (k + n)) sums ?d\" by (rule sums_mult)\n also have \"(\\k. c * (2*y^(2*(k+n)+1) / of_nat (2*(k+n)+1))) =\n (\\k. (c * (2*y^(2*n+1))) * ((y^2)^k / of_nat (2*(k+n)+1)))\"\n by (simp only: ring_distribs power_add power_mult) (simp add: mult_ac)\n also from x have \"c * (2*y^(2*n+1)) = 1\" by (simp add: c_def y_def)\n finally have \"(\\k. (y^2)^k / of_nat (2*(k+n)+1)) sums ?d\" by simp\n } note sums' = this\n moreover from norm_y' have \"(\\k. (y^2)^k / of_nat (2*n+1)) sums (1 / (1 - y^2) / of_nat (2*n+1))\"\n by (intro sums_divide geometric_sums) (simp_all add: norm_power)\n ultimately have \"?d \\ (1 / (1 - y^2) / of_nat (2*n+1))\" by (rule sums_le)\n moreover have \"c * (ln x - (\\k 0\"\n by (intro sums_le[OF _ sums_zero sums']) simp_all\n ultimately show ?thesis unfolding c_def by simp\nqed\n\nlemma\n fixes n :: nat and x :: real\n defines \"y \\ (x-1)/(x+1)\"\n defines \"approx \\ (\\k y^(2*n+1) / (1 - y^2) / of_nat (2*n+1)\"\n assumes x: \"x > 1\"\n shows ln_approx_bounds: \"ln x \\ {approx..approx + 2*d}\"\n and ln_approx_abs: \"abs (ln x - (approx + d)) \\ d\"\n by sorry\n\nend\n\nlemma euler_mascheroni_bounds:\n fixes n :: nat assumes \"n \\ 1\" defines \"t \\ harm n - ln (of_nat (Suc n)) :: real\"\n shows \"euler_mascheroni \\ {t + inverse (of_nat (2*(n+1)))..t + inverse (of_nat (2*n))}\"\n by sorry\n\nlemma euler_mascheroni_bounds':\n fixes n :: nat assumes \"n \\ 1\" \"ln (real_of_nat (Suc n)) \\ {l<..\n {harm n - u + inverse (of_nat (2*(n+1)))<..\n Approximation of \\<^term>\\ln 2\\. The lower bound is accurate to about 0.03; the upper\n bound is accurate to about 0.0015.\n\\\nlemma ln2_ge_two_thirds: \"2/3 \\ ln (2::real)\"\n and ln2_le_25_over_36: \"ln (2::real) \\ 25/36\"\n by sorry\n\ntext \\\n Approximation of the Euler-Mascheroni constant. The lower bound is accurate to about 0.0015;\n the upper bound is accurate to about 0.015.\n\\\nlemma euler_mascheroni_gt_19_over_33: \"(euler_mascheroni :: real) > 19/33\" (is ?th1)\n and euler_mascheroni_less_13_over_22: \"(euler_mascheroni :: real) < 13/22\" (is ?th2)\n by sorry\n\nend" }, { "theorem_id": 34, "title": "034_divergence_of_the_harmonic_series", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nmodule\n\npublic import Mathlib.Analysis.SpecialFunctions.Pow.NNReal\npublic import Mathlib.Analysis.SpecialFunctions.Pow.Continuity\npublic import Mathlib.Analysis.SumOverResidueClass\n\n/-!\n# Convergence of `p`-series\n\nIn this file we prove that the series `∑' k in ℕ, 1 / k ^ p` converges if and only if `p > 1`.\nThe proof is based on the\n[Cauchy condensation test](https://en.wikipedia.org/wiki/Cauchy_condensation_test): `∑ k, f k`\nconverges if and only if so does `∑ k, 2 ^ k f (2 ^ k)`. We prove this test in\n`NNReal.summable_condensed_iff` and `summable_condensed_iff_of_nonneg`, then use it to prove\n`summable_one_div_rpow`. After this transformation, a `p`-series turns into a geometric series.\n\n## Tags\n\np-series, Cauchy condensation test\n-/\n\n@[expose] public section\n\n/-!\n### Schlömilch's generalization of the Cauchy condensation test\n\nIn this section we prove the Schlömilch's generalization of the Cauchy condensation test:\nfor a strictly increasing `u : ℕ → ℕ` with ratio of successive differences bounded and an\nantitone `f : ℕ → ℝ≥0` or `f : ℕ → ℝ`, `∑ k, f k` converges if and only if\nso does `∑ k, (u (k + 1) - u k) * f (u k)`. Instead of giving a monolithic proof, we split it\ninto a series of lemmas with explicit estimates of partial sums of each series in terms of the\npartial sums of the other series.\n-/\n\n/--\nA sequence `u` has the property that its ratio of successive differences is bounded\nwhen there is a positive real number `C` such that, for all n ∈ ℕ,\n(u (n + 2) - u (n + 1)) ≤ C * (u (n + 1) - u n)\n-/\ndef SuccDiffBounded (C : ℕ) (u : ℕ → ℕ) : Prop :=\n ∀ n : ℕ, u (n + 2) - u (n + 1) ≤ C • (u (n + 1) - u n)\n\nnamespace Finset\n\nvariable {M : Type*} [AddCommMonoid M] [PartialOrder M] [IsOrderedAddMonoid M]\n {f : ℕ → M} {u : ℕ → ℕ}\n\ntheorem le_sum_schlomilch' (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)\n (hu : Monotone u) (n : ℕ) :\n (∑ k ∈ Ico (u 0) (u n), f k) ≤ ∑ k ∈ range n, (u (k + 1) - u k) • f (u k) := by sorry\ntheorem le_sum_condensed' (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (n : ℕ) :\n (∑ k ∈ Ico 1 (2 ^ n), f k) ≤ ∑ k ∈ range n, 2 ^ k • f (2 ^ k) := by sorry\ntheorem le_sum_schlomilch (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)\n (hu : Monotone u) (n : ℕ) :\n (∑ k ∈ range (u n), f k) ≤\n ∑ k ∈ range (u 0), f k + ∑ k ∈ range n, (u (k + 1) - u k) • f (u k) := by sorry\ntheorem le_sum_condensed (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (n : ℕ) :\n (∑ k ∈ range (2 ^ n), f k) ≤ f 0 + ∑ k ∈ range n, 2 ^ k • f (2 ^ k) := by sorry\ntheorem sum_schlomilch_le' (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)\n (hu : Monotone u) (n : ℕ) :\n (∑ k ∈ range n, (u (k + 1) - u k) • f (u (k + 1))) ≤ ∑ k ∈ Ico (u 0 + 1) (u n + 1), f k := by sorry\ntheorem sum_condensed_le' (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (n : ℕ) :\n (∑ k ∈ range n, 2 ^ k • f (2 ^ (k + 1))) ≤ ∑ k ∈ Ico 2 (2 ^ n + 1), f k := by sorry\ntheorem sum_schlomilch_le {C : ℕ} (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)\n (h_nonneg : ∀ n, 0 ≤ f n) (hu : Monotone u) (h_succ_diff : SuccDiffBounded C u) (n : ℕ) :\n ∑ k ∈ range (n + 1), (u (k + 1) - u k) • f (u k) ≤\n (u 1 - u 0) • f (u 0) + C • ∑ k ∈ Ico (u 0 + 1) (u n + 1), f k := by sorry\ntheorem sum_condensed_le (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (n : ℕ) :\n (∑ k ∈ range (n + 1), 2 ^ k • f (2 ^ k)) ≤ f 1 + 2 • ∑ k ∈ Ico 2 (2 ^ n + 1), f k := by sorry\nend Finset\n\nnamespace ENNReal\n\nopen Filter Finset\n\nvariable {u : ℕ → ℕ} {f : ℕ → ℝ≥0∞}\n\nopen NNReal in\ntheorem le_tsum_schlomilch (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)\n (hu : StrictMono u) :\n ∑' k, f k ≤ ∑ k ∈ range (u 0), f k + ∑' k : ℕ, (u (k + 1) - u k) * f (u k) := by sorry\ntheorem le_tsum_condensed (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) :\n ∑' k, f k ≤ f 0 + ∑' k : ℕ, 2 ^ k * f (2 ^ k) := by sorry\ntheorem tsum_schlomilch_le {C : ℕ} (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)\n (h_nonneg : ∀ n, 0 ≤ f n) (hu : Monotone u) (h_succ_diff : SuccDiffBounded C u) :\n ∑' k : ℕ, (u (k + 1) - u k) * f (u k) ≤ (u 1 - u 0) * f (u 0) + C * ∑' k, f k := by sorry\ntheorem tsum_condensed_le (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) :\n (∑' k : ℕ, 2 ^ k * f (2 ^ k)) ≤ f 1 + 2 * ∑' k, f k := by sorry\nend ENNReal\n\nnamespace NNReal\n\nopen Finset\n\nopen ENNReal in\n/-- for a series of `NNReal` version. -/\ntheorem summable_schlomilch_iff {C : ℕ} {u : ℕ → ℕ} {f : ℕ → ℝ≥0}\n (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m)\n (h_pos : ∀ n, 0 < u n) (hu_strict : StrictMono u)\n (hC_nonzero : C ≠ 0) (h_succ_diff : SuccDiffBounded C u) :\n (Summable fun k : ℕ => (u (k + 1) - (u k : ℝ≥0)) * f (u k)) ↔ Summable f := by sorry\nopen ENNReal in\ntheorem summable_condensed_iff {f : ℕ → ℝ≥0} (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) :\n (Summable fun k : ℕ => (2 : ℝ≥0) ^ k * f (2 ^ k)) ↔ Summable f := by sorry\nend NNReal\n\nopen NNReal in\n/-- for series of nonnegative real numbers. -/\ntheorem summable_schlomilch_iff_of_nonneg {C : ℕ} {u : ℕ → ℕ} {f : ℕ → ℝ} (h_nonneg : ∀ n, 0 ≤ f n)\n (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)\n (hu_strict : StrictMono u) (hC_nonzero : C ≠ 0) (h_succ_diff : SuccDiffBounded C u) :\n (Summable fun k : ℕ => (u (k + 1) - (u k : ℝ)) * f (u k)) ↔ Summable f := by sorry\ntheorem summable_condensed_iff_of_nonneg {f : ℕ → ℝ} (h_nonneg : ∀ n, 0 ≤ f n)\n (h_mono : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) :\n (Summable fun k : ℕ => (2 : ℝ) ^ k * f (2 ^ k)) ↔ Summable f := by sorry\ntheorem summable_condensed_iff_of_eventually_nonneg {f : ℕ → ℝ} (h_nonneg : 0 ≤ᶠ[Filter.atTop] f)\n (h_mono : ∀ᶠ k in Filter.atTop, f (k + 1) ≤ f k) :\n (Summable fun k : ℕ => (2 : ℝ) ^ k * f (2 ^ k)) ↔ Summable f := by sorry\nsection p_series\n\n/-!\n### Convergence of the `p`-series\n\nIn this section we prove that for a real number `p`, the series `∑' n : ℕ, 1 / (n ^ p)` converges if\nand only if `1 < p`. There are many different proofs of this fact. The proof in this file uses the\nCauchy condensation test we formalized above. This test implies that `∑ n, 1 / (n ^ p)` converges if\nand only if `∑ n, 2 ^ n / ((2 ^ n) ^ p)` converges, and the latter series is a geometric series with\ncommon ratio `2 ^ {1 - p}`. -/\n\nnamespace Real\n\nopen Filter\n\n/-- Test for convergence of the `p`-series: the real-valued series `∑' n : ℕ, (n ^ p)⁻¹` converges\nif and only if `1 < p`. -/\n@[simp]\ntheorem summable_nat_rpow_inv {p : ℝ} :\n Summable (fun n => ((n : ℝ) ^ p)⁻¹ : ℕ → ℝ) ↔ 1 < p := by sorry\ntheorem summable_nat_rpow {p : ℝ} : Summable (fun n => (n : ℝ) ^ p : ℕ → ℝ) ↔ p < -1 := by sorry\ntheorem summable_one_div_nat_rpow {p : ℝ} :\n Summable (fun n => 1 / (n : ℝ) ^ p : ℕ → ℝ) ↔ 1 < p := by sorry\ntheorem summable_nat_pow_inv {p : ℕ} :\n Summable (fun n => ((n : ℝ) ^ p)⁻¹ : ℕ → ℝ) ↔ 1 < p := by sorry\ntheorem summable_one_div_nat_pow {p : ℕ} :\n Summable (fun n => 1 / (n : ℝ) ^ p : ℕ → ℝ) ↔ 1 < p := by sorry\ntheorem summable_one_div_int_pow {p : ℕ} :\n (Summable fun n : ℤ ↦ 1 / (n : ℝ) ^ p) ↔ 1 < p := by sorry\ntheorem summable_abs_int_rpow {b : ℝ} (hb : 1 < b) :\n Summable fun n : ℤ => |(n : ℝ)| ^ (-b) := by sorry\ntheorem not_summable_natCast_inv : ¬Summable (fun n => n⁻¹ : ℕ → ℝ) := by sorry\ntheorem not_summable_one_div_natCast : ¬Summable (fun n => 1 / n : ℕ → ℝ) := by sorry\ntheorem tendsto_sum_range_one_div_nat_succ_atTop :\n Tendsto (fun n => ∑ i ∈ Finset.range n, (1 / (i + 1) : ℝ)) atTop atTop := by sorry\nend Real\n\nnamespace NNReal\n\n@[simp]\ntheorem summable_rpow_inv {p : ℝ} :\n Summable (fun n => ((n : ℝ≥0) ^ p)⁻¹ : ℕ → ℝ≥0) ↔ 1 < p := by sorry\ntheorem summable_rpow {p : ℝ} : Summable (fun n => (n : ℝ≥0) ^ p : ℕ → ℝ≥0) ↔ p < -1 := by sorry\ntheorem summable_one_div_rpow {p : ℝ} :\n Summable (fun n => 1 / (n : ℝ≥0) ^ p : ℕ → ℝ≥0) ↔ 1 < p := by sorry\nend NNReal\n\nend p_series\n\nsection\n\nopen Finset\n\nvariable {α : Type*} [Field α] [LinearOrder α] [IsStrictOrderedRing α]\n\ntheorem sum_Ioc_inv_sq_le_sub {k n : ℕ} (hk : k ≠ 0) (h : k ≤ n) :\n (∑ i ∈ Ioc k n, ((i : α) ^ 2)⁻¹) ≤ (k : α)⁻¹ - (n : α)⁻¹ := by sorry\ntheorem sum_Ioo_inv_sq_le (k n : ℕ) : (∑ i ∈ Ioo k n, (i ^ 2 : α)⁻¹) ≤ 2 / (k + 1) :=\n calc\n (∑ i ∈ Ioo k n, ((i : α) ^ 2)⁻¹) ≤ ∑ i ∈ Ioc k (max (k + 1) n), ((i : α) ^ 2)⁻¹ := by sorry\nend\n\nopen Set Nat in\n/-- The harmonic series restricted to a residue class is not summable. -/\nlemma Real.not_summable_indicator_one_div_natCast {m : ℕ} (hm : m ≠ 0) (k : ZMod m) :\n ¬ Summable ({n : ℕ | (n : ZMod m) = k}.indicator fun n : ℕ ↦ (1 / n : ℝ)) := by sorry\nsection shifted\n\nopen Filter Asymptotics Topology\n\n-- see https://github.com/leanprover-community/mathlib4/issues/29041\nset_option linter.unusedSimpArgs false in\nlemma Real.summable_one_div_nat_add_rpow (a : ℝ) (s : ℝ) :\n Summable (fun n : ℕ ↦ 1 / |n + a| ^ s) ↔ 1 < s := by sorry\nlemma Real.summable_one_div_int_add_rpow (a : ℝ) (s : ℝ) :\n Summable (fun n : ℤ ↦ 1 / |n + a| ^ s) ↔ 1 < s := by sorry\ntheorem summable_pow_div_add {α : Type*} (x : α) [RCLike α] (q k : ℕ) (hq : 1 < q) :\n Summable fun n : ℕ => ‖(x / (↑n + k) ^ q)‖ := by sorry\nend shifted\n" }, { "theorem_id": 34, "title": "034_divergence_of_the_harmonic_series", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Rseries_def.\nRequire Import Rseries_facts.\nRequire Import RiemannInt.\nRequire Import Lra.\nRequire Import Rsequence_facts.\nRequire Import Rsequence_subsequence.\nRequire Import Riemann_integrable.\nRequire Import Rintegral.\n\nLocal Open Scope R_scope.\n\nSection Rseries_RiemannInt.\n\nLocal Coercion INR : nat >-> R.\n\nLemma Rle_minus' : forall a b, b <= a -> 0 <= a - b.\nProof.\nAdmitted.\nLemma Rminus_le_compat_r: forall r r1 r2 : R, r2 <= r1 -> r - r1 <= r - r2.\nProof.\nAdmitted.\n\nLemma Telescoping_series : forall a n, sum_f_R0 (fun i => a (S i) - a i) n = a (S n) - a O.\nProof.\nAdmitted.\n\nLemma Telescoping_series_opp : forall a n, sum_f_R0 (fun i => a i - a (S i)) n = a O - a (S n).\nProof.\nAdmitted.\n\nLemma Rint_generalized_Chasles : forall f An, \n (forall n : nat, Rint f n (S n) (An n)) -> \n forall n : nat, Rint f 0 (S n) (sum_f_R0 An n).\nProof.\nAdmitted.\n\nSection Rser_RiemannInt_link.\n\nVariable f : R -> R.\nHypothesis Hcont : forall x, 0 <= x -> continuity_pt f x.\nHypothesis Hpos : forall x, 0 <= x -> 0 <= f x.\nHypothesis Hdec : forall x y : R, 0 <= x <= y -> f y <= f x.\n\nLemma Riemann_integrable_f_n_Sn : forall (n : nat), Riemann_integrable f (INR n) (INR (S n)).\nProof.\nAdmitted.\n\nLemma Rser_RiemannInt_link_general_term_integrable : forall (n : nat), \n Riemann_integrable (fun x => fct_cte (f (INR n)) x - f x) (INR n) (INR (S n)).\nProof.\nAdmitted.\n\nLemma Rser_RiemannInt_link_general_term_bound (n : nat) : \n RiemannInt (Rser_RiemannInt_link_general_term_integrable n) <= f (INR n) - f (INR (S n)).\nProof.\nAdmitted.\n\nLemma Rser_RiemannInt_link : { l | Rser_cv (fun n => f (INR n) - RiemannInt (Riemann_integrable_f_n_Sn n) ) l}.\nProof.\nAdmitted.\n\nLemma Rser_RiemannInt_cv_pos_infty : \n exists pr : forall (n : nat), Riemann_integrable f 0 (INR n), \n Rseq_cv_pos_infty (fun n => RiemannInt (pr (S n))) ->\n (sum_f_R0 (fun n => f (INR n))) ~ (fun n => RiemannInt (pr (S n))).\nProof.\nAdmitted.\n\nEnd Rser_RiemannInt_link.\n\nSection Applications.\n\nDefinition ln1 := comp ln (fun x => x+1).\n\nLemma Rint_inv1 : forall a b, \n -1 < a <= b -> Rint (/(id + fct_cte 1))%F a b (ln (b + 1) - ln (a + 1)).\nProof.\nAdmitted. \n \nLemma harmonic_series_equiv : (sum_f_R0 (fun n => / (S n))) ~ (fun n => ln (S (S n))).\nProof.\nAdmitted.\n\nEnd Applications.\n\nEnd Rseries_RiemannInt." }, { "theorem_id": 35, "title": "035_taylor_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/analysis.ml\";;\n\nlet POWDIFF_LEMMA = `!n x y. sum(0,SUC n)(\\p. (x pow p) * y pow ((SUC n) - p)) =\n y * sum(0,SUC n)(\\p. (x pow p) * (y pow (n - p)))`;;\n\nlet POWDIFF = `!n x y. (x pow (SUC n)) - (y pow (SUC n)) =\n (x - y) * sum(0,SUC n)(\\p. (x pow p) * (y pow (n - p)))`;;\n\nlet POWREV = `!n x y. sum(0,SUC n)(\\p. (x pow p) * (y pow (n - p))) =\n sum(0,SUC n)(\\p. (x pow (n - p)) * (y pow p))`;;\n\nlet POWSER_INSIDEA = `!f x z. summable (\\n. f(n) * (x pow n)) /\\ abs(z) < abs(x)\n ==> summable (\\n. abs(f(n)) * (z pow n))`;;\n\nlet POWSER_INSIDE = `!f x z. summable (\\n. f(n) * (x pow n)) /\\ abs(z) < abs(x)\n ==> summable (\\n. f(n) * (z pow n))`;;\n\nlet diffs = new_definition\n `diffs c = (\\n. &(SUC n) * c(SUC n))`;;\n\nlet DIFFS_NEG = `!c. diffs(\\n. --(c n)) = \\n. --((diffs c) n)`;;\n\nlet DIFFS_LEMMA = `!n c x. sum(0,n) (\\n. (diffs c)(n) * (x pow n)) =\n sum(0,n) (\\n. &n * c(n) * (x pow (n - 1))) +\n (&n * c(n) * x pow (n - 1))`;;\n\nlet DIFFS_LEMMA2 = `!n c x. sum(0,n) (\\n. &n * c(n) * (x pow (n - 1))) =\n sum(0,n) (\\n. (diffs c)(n) * (x pow n)) -\n (&n * c(n) * x pow (n - 1))`;;\n\nlet DIFFS_EQUIV = `!c x. summable(\\n. (diffs c)(n) * (x pow n)) ==>\n (\\n. &n * c(n) * (x pow (n - 1))) sums\n (suminf(\\n. (diffs c)(n) * (x pow n)))`;;\n\nlet TERMDIFF_LEMMA1 = `!m z h.\n sum(0,m)(\\p. (((z + h) pow (m - p)) * (z pow p)) - (z pow m)) =\n sum(0,m)(\\p. (z pow p) *\n (((z + h) pow (m - p)) - (z pow (m - p))))`;;\n\nlet TERMDIFF_LEMMA2 = `!z h. ~(h = &0) ==>\n (((((z + h) pow n) - (z pow n)) / h) - (&n * (z pow (n - 1))) =\n h * sum(0,n - 1)(\\p. (z pow p) *\n sum(0,(n - 1) - p)\n (\\q. ((z + h) pow q) *\n (z pow (((n - 2) - p) - q)))))`;;\n\nlet TERMDIFF_LEMMA3 = `!z h n K. ~(h = &0) /\\ abs(z) <= K /\\ abs(z + h) <= K ==>\n abs(((((z + h) pow n) - (z pow n)) / h) - (&n * (z pow (n - 1))))\n <= &n * &(n - 1) * (K pow (n - 2)) * abs(h)`;;\n\nlet TERMDIFF_LEMMA4 = `!f K k. &0 < k /\\\n (!h. &0 < abs(h) /\\ abs(h) < k ==> abs(f h) <= K * abs(h))\n ==> (f tends_real_real &0)(&0)`;;\n\nlet TERMDIFF_LEMMA5 = `!f g k. &0 < k /\\\n summable(f) /\\\n (!h. &0 < abs(h) /\\ abs(h) < k ==> !n. abs(g(h) n) <= (f(n) * abs(h)))\n ==> ((\\h. suminf(g h)) tends_real_real &0)(&0)`;;\n\nlet TERMDIFF = `!c K. summable(\\n. c(n) * (K pow n)) /\\\n summable(\\n. (diffs c)(n) * (K pow n)) /\\\n summable(\\n. (diffs(diffs c))(n) * (K pow n)) /\\\n abs(x) < abs(K)\n ==> ((\\x. suminf (\\n. c(n) * (x pow n))) diffl\n (suminf (\\n. (diffs c)(n) * (x pow n))))(x)`;;\n\nlet SEQ_NPOW = `!x. abs(x) < &1 ==> (\\n. &n * x pow n) tends_num_real &0`;;\n\nlet TERMDIFF_CONVERGES = `!K. (!x. abs(x) < K ==> summable(\\n. c(n) * x pow n))\n ==> !x. abs(x) < K ==> summable (\\n. diffs c n * x pow n)`;;\n\nlet TERMDIFF_STRONG = `!c K x.\n summable(\\n. c(n) * (K pow n)) /\\ abs(x) < abs(K)\n ==> ((\\x. suminf (\\n. c(n) * (x pow n))) diffl\n (suminf (\\n. (diffs c)(n) * (x pow n))))(x)`;;\n\nlet POWSER_0 = `!a. (\\n. a n * (&0) pow n) sums a(0)`;;\n\nlet POWSER_LIMIT_0 = `!f a s. &0 < s /\\\n (!x. abs(x) < s ==> (\\n. a n * x pow n) sums (f x))\n ==> (f tends_real_real a(0))(&0)`;;\n\nlet POWSER_LIMIT_0_STRONG = `!f a s.\n &0 < s /\\\n (!x. &0 < abs(x) /\\ abs(x) < s ==> (\\n. a n * x pow n) sums (f x))\n ==> (f tends_real_real a(0))(&0)`;;\n\nlet POWSER_EQUAL_0 = `!f a b P.\n (!e. &0 < e ==> ?x. P x /\\ &0 < abs x /\\ abs(x) < e) /\\\n (!x. &0 < abs(x) /\\ P x\n ==> (\\n. a n * x pow n) sums (f x) /\\\n (\\n. b n * x pow n) sums (f x))\n ==> (a(0) = b(0))`;;\n\nlet POWSER_EQUAL = `!f a b P.\n (!e. &0 < e ==> ?x. P x /\\ &0 < abs x /\\ abs(x) < e) /\\\n (!x. P x ==> (\\n. a n * x pow n) sums (f x) /\\\n (\\n. b n * x pow n) sums (f x))\n ==> (a = b)`;;\n\nprioritize_num();;\n\nset_basic_rewrites (subtract' equals_thm (basic_rewrites())\n [SPEC_ALL BETA_THM]);;\n\nlet MULT_DIV_2 = `!n. (2 * n) DIV 2 = n`;;\n\nlet EVEN_DIV2 = `!n. ~(EVEN n) ==> ((SUC n) DIV 2 = SUC((n - 1) DIV 2))`;;\n\nprioritize_real();;\n\nlet POW_ZERO = `!n x. (x pow n = &0) ==> (x = &0)`;;\n\nlet POW_ZERO_EQ = `!n x. (x pow (SUC n) = &0) <=> (x = &0)`;;\n\nlet POW_LT = `!n x y. &0 <= x /\\ x < y ==> (x pow (SUC n)) < (y pow (SUC n))`;;\n\nlet POW_EQ = `!n x y. &0 <= x /\\ &0 <= y /\\ (x pow (SUC n) = y pow (SUC n))\n ==> (x = y)`;;\n\nlet diff_net = ref empty_net;;\n\nlet add_to_diff_net th =\n let t = lhand(rator(rand(concl th))) in\n let net = !diff_net in\n let net' = enter [] (t,PART_MATCH (lhand o rator o rand) th) net in\n diff_net := net';;\n\nlet exp = new_definition\n `exp(x) = suminf(\\n. ((\\n. inv(&(FACT n)))) n * (x pow n))`;;\n\nlet sin = new_definition\n `sin(x) = suminf(\\n. ((\\n. if EVEN n then &0 else\n ((--(&1)) pow ((n - 1) DIV 2)) / &(FACT n))) n * (x pow n))`;;\n\nlet cos = new_definition\n `cos(x) = suminf(\\n. ((\\n. if EVEN n then ((--(&1)) pow (n DIV 2)) / &(FACT n)\n else &0)) n * (x pow n))`;;\n\nlet REAL_EXP_CONVERGES = `!x. (\\n. ((\\n. inv(&(FACT n)))) n * (x pow n)) sums exp(x)`;;\n\nlet SIN_CONVERGES = `!x. (\\n. ((\\n. if EVEN n then &0 else\n ((--(&1)) pow ((n - 1) DIV 2)) / &(FACT n))) n * (x pow n)) sums\n sin(x)`;;\n\nlet COS_CONVERGES = `!x. (\\n. ((\\n. if EVEN n then ((--(&1)) pow (n DIV 2)) / &(FACT n) else &0)) n\n * (x pow n)) sums cos(x)`;;\n\nlet REAL_EXP_FDIFF = `diffs (\\n. inv(&(FACT n))) = (\\n. inv(&(FACT n)))`;;\n\nlet SIN_FDIFF = `diffs (\\n. if EVEN n then &0 else ((--(&1)) pow ((n - 1) DIV 2)) / &(FACT n))\n = (\\n. if EVEN n then ((--(&1)) pow (n DIV 2)) / &(FACT n) else &0)`;;\n\nlet COS_FDIFF = `diffs (\\n. if EVEN n then ((--(&1)) pow (n DIV 2)) / &(FACT n) else &0) =\n (\\n. --(((\\n. if EVEN n then &0 else ((--(&1)) pow ((n - 1) DIV 2)) /\n &(FACT n))) n))`;;\n\nlet SIN_NEGLEMMA = `!x. --(sin x) = suminf (\\n. --(((\\n. if EVEN n then &0 else ((--(&1))\n pow ((n - 1) DIV 2)) / &(FACT n))) n * (x pow n)))`;;\n\nlet DIFF_EXP = `!x. (exp diffl exp(x))(x)`;;\n\nlet DIFF_SIN = `!x. (sin diffl cos(x))(x)`;;\n\nlet DIFF_COS = `!x. (cos diffl --(sin(x)))(x)`;;\n\nlet DIFF_CONV =\n let lookup_expr tm =\n tryfind (fun f -> f tm) (lookup tm (!diff_net)) in\n let v = `x:real` and k = `k:real` and diffl_tm = `(diffl)` in\n let DIFF_var = SPEC v DIFF_X\n and DIFF_const = SPECL [k;v] DIFF_CONST in\n let uneta_CONV = REWR_CONV (GSYM ETA_AX) in\n let rec DIFF_CONV tm =\n if not (is_abs tm) then\n let th0 = uneta_CONV tm in\n let th1 = DIFF_CONV (rand(concl th0)) in\n CONV_RULE (RATOR_CONV(LAND_CONV(K(SYM th0)))) th1 else\n let x,bod = dest_abs tm in\n if bod = x then INST [x,v] DIFF_var\n else if not(free_in x bod) then INST [bod,k; x,v] DIFF_const else\n let th = lookup_expr tm in\n let hyp = fst(dest_imp(concl th)) in\n let hyps = conjuncts hyp in\n let dhyps,sides = partition\n (fun t -> try funpow 3 rator t = diffl_tm\n with Failure _ -> false) hyps in\n let tha = CONJ_ACI_RULE(mk_eq(hyp,list_mk_conj(dhyps@sides))) in\n let thb = CONV_RULE (LAND_CONV (K tha)) th in\n let dths = map (DIFF_CONV o lhand o rator) dhyps in\n MATCH_MP thb (end_itlist CONJ (dths @ map ASSUME sides)) in\n fun tm ->\n let xv = try bndvar tm with Failure _ -> v in\n GEN xv (DISCH_ALL(DIFF_CONV tm));;\n\nlet DIFF_COMPOSITE = `((f diffl l)(x) /\\ ~(f(x) = &0) ==>\n ((\\x. inv(f x)) diffl --(l / (f(x) pow 2)))(x)) /\\\n ((f diffl l)(x) /\\ (g diffl m)(x) /\\ ~(g(x) = &0) ==>\n ((\\x. f(x) / g(x)) diffl (((l * g(x)) - (m * f(x))) / (g(x) pow 2)))(x)) /\\\n ((f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) + g(x)) diffl (l + m))(x)) /\\\n ((f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) * g(x)) diffl ((l * g(x)) + (m * f(x))))(x)) /\\\n ((f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) - g(x)) diffl (l - m))(x)) /\\\n ((f diffl l)(x) ==> ((\\x. --(f x)) diffl --l)(x)) /\\\n ((g diffl m)(x) ==>\n ((\\x. (g x) pow n) diffl ((&n * (g x) pow (n - 1)) * m))(x)) /\\\n ((g diffl m)(x) ==> ((\\x. exp(g x)) diffl (exp(g x) * m))(x)) /\\\n ((g diffl m)(x) ==> ((\\x. sin(g x)) diffl (cos(g x) * m))(x)) /\\\n ((g diffl m)(x) ==> ((\\x. cos(g x)) diffl (--(sin(g x)) * m))(x))`;;\n\ndo_list add_to_diff_net (CONJUNCTS DIFF_COMPOSITE);;\n\nlet DIFF_TAC =\n W(fun (asl,w) -> MP_TAC(SPEC(rand w) (DIFF_CONV(lhand(rator w)))) THEN\n MATCH_MP_TAC EQ_IMP THEN AP_THM_TAC THEN AP_TERM_TAC);;\n\nlet DIFFERENTIABLE_RULE =\n let pth = `(f diffl l) x ==> f differentiable x`;;\n\nlet DIFFERENTIABLE_CONV = EQT_INTRO o DIFFERENTIABLE_RULE;;\n\nlet CONTINUOUS_RULE =\n let pth = `!f x. f differentiable x ==> f contl x`;;\n\nlet CONTINUOUS_CONV = EQT_INTRO o CONTINUOUS_RULE;;\n\nlet REAL_EXP_0 = `exp(&0) = &1`;;\n\nlet REAL_EXP_LE_X = `!x. &0 <= x ==> (&1 + x) <= exp(x)`;;\n\nlet REAL_EXP_LT_1 = `!x. &0 < x ==> &1 < exp(x)`;;\n\nlet REAL_EXP_ADD_MUL = `!x y. exp(x + y) * exp(--x) = exp(y)`;;\n\nlet REAL_EXP_NEG_MUL = `!x. exp(x) * exp(--x) = &1`;;\n\nlet REAL_EXP_NEG_MUL2 = `!x. exp(--x) * exp(x) = &1`;;\n\nlet REAL_EXP_NEG = `!x. exp(--x) = inv(exp(x))`;;\n\nlet REAL_EXP_ADD = `!x y. exp(x + y) = exp(x) * exp(y)`;;\n\nlet REAL_EXP_POS_LE = `!x. &0 <= exp(x)`;;\n\nlet REAL_EXP_NZ = `!x. ~(exp(x) = &0)`;;\n\nlet REAL_EXP_POS_LT = `!x. &0 < exp(x)`;;\n\nlet REAL_EXP_N = `!n x. exp(&n * x) = exp(x) pow n`;;\n\nlet REAL_EXP_SUB = `!x y. exp(x - y) = exp(x) / exp(y)`;;\n\nlet REAL_EXP_MONO_IMP = `!x y. x < y ==> exp(x) < exp(y)`;;\n\nlet REAL_EXP_MONO_LT = `!x y. exp(x) < exp(y) <=> x < y`;;\n\nlet REAL_EXP_MONO_LE = `!x y. exp(x) <= exp(y) <=> x <= y`;;\n\nlet REAL_EXP_INJ = `!x y. (exp(x) = exp(y)) <=> (x = y)`;;\n\nlet REAL_EXP_TOTAL_LEMMA = `!y. &1 <= y ==> ?x. &0 <= x /\\ x <= y - &1 /\\ (exp(x) = y)`;;\n\nlet REAL_EXP_TOTAL = `!y. &0 < y ==> ?x. exp(x) = y`;;\n\nlet REAL_EXP_BOUND_LEMMA = `!x. &0 <= x /\\ x <= inv(&2) ==> exp(x) <= &1 + &2 * x`;;\n\nlet ln = new_definition\n `ln x = @u. exp(u) = x`;;\n\nlet LN_EXP = `!x. ln(exp x) = x`;;\n\nlet REAL_EXP_LN = `!x. (exp(ln x) = x) <=> &0 < x`;;\n\nlet EXP_LN = `!x. &0 < x ==> exp(ln x) = x`;;\n\nlet LN_MUL = `!x y. &0 < x /\\ &0 < y ==> (ln(x * y) = ln(x) + ln(y))`;;\n\nlet LN_INJ = `!x y. &0 < x /\\ &0 < y ==> ((ln(x) = ln(y)) <=> (x = y))`;;\n\nlet LN_1 = `ln(&1) = &0`;;\n\nlet LN_INV = `!x. &0 < x ==> (ln(inv x) = --(ln x))`;;\n\nlet LN_DIV = `!x. &0 < x /\\ &0 < y ==> (ln(x / y) = ln(x) - ln(y))`;;\n\nlet LN_MONO_LT = `!x y. &0 < x /\\ &0 < y ==> (ln(x) < ln(y) <=> x < y)`;;\n\nlet LN_MONO_LE = `!x y. &0 < x /\\ &0 < y ==> (ln(x) <= ln(y) <=> x <= y)`;;\n\nlet LN_POW = `!n x. &0 < x ==> (ln(x pow n) = &n * ln(x))`;;\n\nlet LN_LE = `!x. &0 <= x ==> ln(&1 + x) <= x`;;\n\nlet LN_LT_X = `!x. &0 < x ==> ln(x) < x`;;\n\nlet LN_POS = `!x. &1 <= x ==> &0 <= ln(x)`;;\n\nlet LN_POS_LT = `!x. &1 < x ==> &0 < ln(x)`;;\n\nlet DIFF_LN = `!x. &0 < x ==> (ln diffl (inv x))(x)`;;\n\nlet root = new_definition\n `root(n) x = @u. (&0 < x ==> &0 < u) /\\ (u pow n = x)`;;\n\nlet ROOT_LT_LEMMA = `!n x. &0 < x ==> (exp(ln(x) / &(SUC n)) pow (SUC n) = x)`;;\n\nlet ROOT_LN = `!x. &0 < x ==> !n. root(SUC n) x = exp(ln(x) / &(SUC n))`;;\n\nlet ROOT_0 = `!n. root(SUC n) (&0) = &0`;;\n\nlet ROOT_1 = `!n. root(SUC n) (&1) = &1`;;\n\nlet ROOT_POW_POS = `!n x. &0 <= x ==> ((root(SUC n) x) pow (SUC n) = x)`;;\n\nlet POW_ROOT_POS = `!n x. &0 <= x ==> (root(SUC n)(x pow (SUC n)) = x)`;;\n\nlet ROOT_POS_POSITIVE = `!x n. &0 <= x ==> &0 <= root(SUC n) x`;;\n\nlet ROOT_POS_UNIQ = `!n x y. &0 <= x /\\ &0 <= y /\\ (y pow (SUC n) = x)\n ==> (root (SUC n) x = y)`;;\n\nlet ROOT_MUL = `!n x y. &0 <= x /\\ &0 <= y\n ==> (root(SUC n) (x * y) = root(SUC n) x * root(SUC n) y)`;;\n\nlet ROOT_INV = `!n x. &0 <= x ==> (root(SUC n) (inv x) = inv(root(SUC n) x))`;;\n\nlet ROOT_DIV = `!n x y. &0 <= x /\\ &0 <= y\n ==> (root(SUC n) (x / y) = root(SUC n) x / root(SUC n) y)`;;\n\nlet ROOT_MONO_LT = `!x y. &0 <= x /\\ x < y ==> root(SUC n) x < root(SUC n) y`;;\n\nlet ROOT_MONO_LE = `!x y. &0 <= x /\\ x <= y ==> root(SUC n) x <= root(SUC n) y`;;\n\nlet ROOT_MONO_LT_EQ = `!x y. &0 <= x /\\ &0 <= y ==> (root(SUC n) x < root(SUC n) y <=> x < y)`;;\n\nlet ROOT_MONO_LE_EQ = `!x y. &0 <= x /\\ &0 <= y ==> (root(SUC n) x <= root(SUC n) y <=> x <= y)`;;\n\nlet ROOT_INJ = `!x y. &0 <= x /\\ &0 <= y ==> ((root(SUC n) x = root(SUC n) y) <=> (x = y))`;;\n\nlet SQRT_EVEN_POW2 = `!n. EVEN n ==> (sqrt(&2 pow n) = &2 pow (n DIV 2))`;;\n\nlet REAL_DIV_SQRT = `!x. &0 <= x ==> x / sqrt(x) = sqrt(x)`;;\n\nlet DIFF_SQRT = `!x. &0 < x ==> (sqrt diffl inv(&2 * sqrt(x))) x`;;\n\nlet DIFF_SQRT_COMPOSITE = `!g m x. (g diffl m)(x) /\\ &0 < g x\n ==> ((\\x. sqrt(g x)) diffl (inv(&2 * sqrt(g x)) * m))(x)`;;\n\nlet SIN_0 = `sin(&0) = &0`;;\n\nlet COS_0 = `cos(&0) = &1`;;\n\nlet SIN_CIRCLE = `!x. (sin(x) pow 2) + (cos(x) pow 2) = &1`;;\n\nlet SIN_BOUND = `!x. abs(sin x) <= &1`;;\n\nlet SIN_BOUNDS = `!x. --(&1) <= sin(x) /\\ sin(x) <= &1`;;\n\nlet COS_BOUND = `!x. abs(cos x) <= &1`;;\n\nlet COS_BOUNDS = `!x. --(&1) <= cos(x) /\\ cos(x) <= &1`;;\n\nlet SIN_COS_ADD = `!x y. ((sin(x + y) - ((sin(x) * cos(y)) + (cos(x) * sin(y)))) pow 2) +\n ((cos(x + y) - ((cos(x) * cos(y)) - (sin(x) * sin(y)))) pow 2) = &0`;;\n\nlet SIN_COS_NEG = `!x. ((sin(--x) + (sin x)) pow 2) +\n ((cos(--x) - (cos x)) pow 2) = &0`;;\n\nlet SIN_ADD = `!x y. sin(x + y) = (sin(x) * cos(y)) + (cos(x) * sin(y))`;;\n\nlet COS_ADD = `!x y. cos(x + y) = (cos(x) * cos(y)) - (sin(x) * sin(y))`;;\n\nlet SIN_NEG = `!x. sin(--x) = --(sin(x))`;;\n\nlet COS_NEG = `!x. cos(--x) = cos(x)`;;\n\nlet SIN_DOUBLE = `!x. sin(&2 * x) = &2 * sin(x) * cos(x)`;;\n\nlet COS_DOUBLE = `!x. cos(&2 * x) = (cos(x) pow 2) - (sin(x) pow 2)`;;\n\nlet COS_ABS = `!x. cos(abs x) = cos(x)`;;\n\nlet SIN_PAIRED = `!x. (\\n. (((--(&1)) pow n) / &(FACT((2 * n) + 1)))\n * (x pow ((2 * n) + 1))) sums (sin x)`;;\n\nlet SIN_POS = `!x. &0 < x /\\ x < &2 ==> &0 < sin(x)`;;\n\nlet COS_PAIRED = `!x. (\\n. (((--(&1)) pow n) / &(FACT(2 * n)))\n * (x pow (2 * n))) sums (cos x)`;;\n\nlet COS_2 = `cos(&2) < &0`;;\n\nlet COS_ISZERO = `?!x. &0 <= x /\\ x <= &2 /\\ (cos x = &0)`;;\n\nlet pi = new_definition\n `pi = &2 * @x. &0 <= x /\\ x <= &2 /\\ (cos x = &0)`;;\n\nlet PI2 = `pi / &2 = @x. &0 <= x /\\ x <= &2 /\\ (cos(x) = &0)`;;\n\nlet COS_PI2 = `cos(pi / &2) = &0`;;\n\nlet PI2_BOUNDS = `&0 < (pi / &2) /\\ (pi / &2) < &2`;;\n\nlet PI_POS = `&0 < pi`;;\n\nlet SIN_PI2 = `sin(pi / &2) = &1`;;\n\nlet COS_PI = `cos(pi) = --(&1)`;;\n\nlet SIN_PI = `sin(pi) = &0`;;\n\nlet SIN_COS = `!x. sin(x) = cos((pi / &2) - x)`;;\n\nlet COS_SIN = `!x. cos(x) = sin((pi / &2) - x)`;;\n\nlet SIN_PERIODIC_PI = `!x. sin(x + pi) = --(sin(x))`;;\n\nlet COS_PERIODIC_PI = `!x. cos(x + pi) = --(cos(x))`;;\n\nlet SIN_PERIODIC = `!x. sin(x + (&2 * pi)) = sin(x)`;;\n\nlet COS_PERIODIC = `!x. cos(x + (&2 * pi)) = cos(x)`;;\n\nlet COS_NPI = `!n. cos(&n * pi) = --(&1) pow n`;;\n\nlet SIN_NPI = `!n. sin(&n * pi) = &0`;;\n\nlet SIN_POS_PI2 = `!x. &0 < x /\\ x < pi / &2 ==> &0 < sin(x)`;;\n\nlet COS_POS_PI2 = `!x. &0 < x /\\ x < pi / &2 ==> &0 < cos(x)`;;\n\nlet COS_POS_PI = `!x. --(pi / &2) < x /\\ x < pi / &2 ==> &0 < cos(x)`;;\n\nlet SIN_POS_PI = `!x. &0 < x /\\ x < pi ==> &0 < sin(x)`;;\n\nlet SIN_POS_PI_LE = `!x. &0 <= x /\\ x <= pi ==> &0 <= sin(x)`;;\n\nlet COS_TOTAL = `!y. --(&1) <= y /\\ y <= &1 ==> ?!x. &0 <= x /\\ x <= pi /\\ (cos(x) = y)`;;\n\nlet SIN_TOTAL = `!y. --(&1) <= y /\\ y <= &1 ==>\n ?!x. --(pi / &2) <= x /\\ x <= pi / &2 /\\ (sin(x) = y)`;;\n\nlet COS_ZERO_LEMMA = `!x. &0 <= x /\\ (cos(x) = &0) ==>\n ?n. ~EVEN n /\\ (x = &n * (pi / &2))`;;\n\nlet SIN_ZERO_LEMMA = `!x. &0 <= x /\\ (sin(x) = &0) ==>\n ?n. EVEN n /\\ (x = &n * (pi / &2))`;;\n\nlet COS_ZERO = `!x. (cos(x) = &0) <=> (?n. ~EVEN n /\\ (x = &n * (pi / &2))) \\/\n (?n. ~EVEN n /\\ (x = --(&n * (pi / &2))))`;;\n\nlet SIN_ZERO = `!x. (sin(x) = &0) <=> (?n. EVEN n /\\ (x = &n * (pi / &2))) \\/\n (?n. EVEN n /\\ (x = --(&n * (pi / &2))))`;;\n\nlet SIN_ZERO_PI = `!x. (sin(x) = &0) <=> (?n. x = &n * pi) \\/ (?n. x = --(&n * pi))`;;\n\nlet COS_ONE_2PI = `!x. (cos(x) = &1) <=> (?n. x = &n * &2 * pi) \\/ (?n. x = --(&n * &2 * pi))`;;\n\nlet tan = new_definition\n `tan(x) = sin(x) / cos(x)`;;\n\nlet TAN_0 = `tan(&0) = &0`;;\n\nlet TAN_PI = `tan(pi) = &0`;;\n\nlet TAN_NPI = `!n. tan(&n * pi) = &0`;;\n\nlet TAN_NEG = `!x. tan(--x) = --(tan x)`;;\n\nlet TAN_PERIODIC = `!x. tan(x + &2 * pi) = tan(x)`;;\n\nlet TAN_PERIODIC_PI = `!x. tan(x + pi) = tan(x)`;;\n\nlet TAN_PERIODIC_NPI = `!x n. tan(x + &n * pi) = tan(x)`;;\n\nlet TAN_ADD = `!x y. ~(cos(x) = &0) /\\ ~(cos(y) = &0) /\\ ~(cos(x + y) = &0) ==>\n (tan(x + y) = (tan(x) + tan(y)) / (&1 - tan(x) * tan(y)))`;;\n\nlet TAN_DOUBLE = `!x. ~(cos(x) = &0) /\\ ~(cos(&2 * x) = &0) ==>\n (tan(&2 * x) = (&2 * tan(x)) / (&1 - (tan(x) pow 2)))`;;\n\nlet TAN_POS_PI2 = `!x. &0 < x /\\ x < pi / &2 ==> &0 < tan(x)`;;\n\nlet DIFF_TAN = `!x. ~(cos(x) = &0) ==> (tan diffl inv(cos(x) pow 2))(x)`;;\n\nlet DIFF_TAN_COMPOSITE = `(g diffl m)(x) /\\ ~(cos(g x) = &0)\n ==> ((\\x. tan(g x)) diffl (inv(cos(g x) pow 2) * m))(x)`;;\n\nlet TAN_TOTAL_POS = `!y. &0 <= y ==> ?x. &0 <= x /\\ x < pi / &2 /\\ (tan(x) = y)`;;\n\nlet TAN_TOTAL = `!y. ?!x. --(pi / &2) < x /\\ x < (pi / &2) /\\ (tan(x) = y)`;;\n\nlet PI2_PI4 = `pi / &2 = &2 * pi / &4`;;\n\nlet TAN_PI4 = `tan(pi / &4) = &1`;;\n\nlet TAN_COT = `!x. tan(pi / &2 - x) = inv(tan x)`;;\n\nlet TAN_BOUND_PI2 = `!x. abs(x) < pi / &4 ==> abs(tan x) < &1`;;\n\nlet TAN_ABS_GE_X = `!x. abs(x) < pi / &2 ==> abs(x) <= abs(tan x)`;;\n\nlet asn = new_definition\n `asn(y) = @x. --(pi / &2) <= x /\\ x <= pi / &2 /\\ (sin x = y)`;;\n\nlet acs = new_definition\n `acs(y) = @x. &0 <= x /\\ x <= pi /\\ (cos x = y)`;;\n\nlet atn = new_definition\n `atn(y) = @x. --(pi / &2) < x /\\ x < pi / &2 /\\ (tan x = y)`;;\n\nlet ASN = `!y. --(&1) <= y /\\ y <= &1 ==>\n --(pi / &2) <= asn(y) /\\ asn(y) <= pi / &2 /\\ (sin(asn y) = y)`;;\n\nlet ASN_SIN = `!y. --(&1) <= y /\\ y <= &1 ==> (sin(asn(y)) = y)`;;\n\nlet ASN_BOUNDS = `!y. --(&1) <= y /\\ y <= &1 ==> --(pi / &2) <= asn(y) /\\ asn(y) <= pi / &2`;;\n\nlet ASN_BOUNDS_LT = `!y. --(&1) < y /\\ y < &1 ==> --(pi / &2) < asn(y) /\\ asn(y) < pi / &2`;;\n\nlet SIN_ASN = `!x. --(pi / &2) <= x /\\ x <= pi / &2 ==> (asn(sin(x)) = x)`;;\n\nlet ACS = `!y. --(&1) <= y /\\ y <= &1 ==>\n &0 <= acs(y) /\\ acs(y) <= pi /\\ (cos(acs y) = y)`;;\n\nlet ACS_COS = `!y. --(&1) <= y /\\ y <= &1 ==> (cos(acs(y)) = y)`;;\n\nlet ACS_BOUNDS = `!y. --(&1) <= y /\\ y <= &1 ==> &0 <= acs(y) /\\ acs(y) <= pi`;;\n\nlet ACS_BOUNDS_LT = `!y. --(&1) < y /\\ y < &1 ==> &0 < acs(y) /\\ acs(y) < pi`;;\n\nlet COS_ACS = `!x. &0 <= x /\\ x <= pi ==> (acs(cos(x)) = x)`;;\n\nlet ATN = `!y. --(pi / &2) < atn(y) /\\ atn(y) < (pi / &2) /\\ (tan(atn y) = y)`;;\n\nlet ATN_TAN = `!y. tan(atn y) = y`;;\n\nlet ATN_BOUNDS = `!y. --(pi / &2) < atn(y) /\\ atn(y) < (pi / &2)`;;\n\nlet TAN_ATN = `!x. --(pi / &2) < x /\\ x < (pi / &2) ==> (atn(tan(x)) = x)`;;\n\nlet ATN_0 = `atn(&0) = &0`;;\n\nlet ATN_1 = `atn(&1) = pi / &4`;;\n\nlet ATN_NEG = `!x. atn(--x) = --(atn x)`;;\n\nlet COS_ATN_NZ = `!x. ~(cos(atn(x)) = &0)`;;\n\nlet TAN_SEC = `!x. ~(cos(x) = &0) ==> (&1 + (tan(x) pow 2) = inv(cos x) pow 2)`;;\n\nlet DIFF_ATN = `!x. (atn diffl (inv(&1 + (x pow 2))))(x)`;;\n\nlet DIFF_ATN_COMPOSITE = `(g diffl m)(x) ==> ((\\x. atn(g x)) diffl (inv(&1 + (g x) pow 2) * m))(x)`;;\n\nlet ATN_MONO_LT_EQ = `!x y. atn(x) < atn(y) <=> x < y`;;\n\nlet ATN_MONO_LE_EQ = `!x y. atn(x) <= atn(y) <=> x <= y`;;\n\nlet ATN_INJ = `!x y. (atn x = atn y) <=> (x = y)`;;\n\nlet ATN_POS_LT = `&0 < atn(x) <=> &0 < x`;;\n\nlet ATN_POS_LE = `&0 <= atn(x) <=> &0 <= x`;;\n\nlet ATN_LT_PI4_POS = `!x. x < &1 ==> atn(x) < pi / &4`;;\n\nlet ATN_LT_PI4_NEG = `!x. --(&1) < x ==> --(pi / &4) < atn(x)`;;\n\nlet ATN_LT_PI4 = `!x. abs(x) < &1 ==> abs(atn x) < pi / &4`;;\n\nlet ATN_LE_PI4 = `!x. abs(x) <= &1 ==> abs(atn x) <= pi / &4`;;\n\nlet COS_SIN_SQRT = `!x. &0 <= cos(x) ==> (cos(x) = sqrt(&1 - (sin(x) pow 2)))`;;\n\nlet COS_ASN_NZ = `!x. --(&1) < x /\\ x < &1 ==> ~(cos(asn(x)) = &0)`;;\n\nlet DIFF_ASN_COS = `!x. --(&1) < x /\\ x < &1 ==> (asn diffl (inv(cos(asn x))))(x)`;;\n\nlet DIFF_ASN = `!x. --(&1) < x /\\ x < &1 ==> (asn diffl (inv(sqrt(&1 - (x pow 2)))))(x)`;;\n\nlet DIFF_ASN_COMPOSITE = `(g diffl m)(x) /\\ -- &1 < g(x) /\\ g(x) < &1\n ==> ((\\x. asn(g x)) diffl (inv(sqrt (&1 - g(x) pow 2)) * m))(x)`;;\n\nlet SIN_ACS_NZ = `!x. --(&1) < x /\\ x < &1 ==> ~(sin(acs(x)) = &0)`;;\n\nlet DIFF_ACS_SIN = `!x. --(&1) < x /\\ x < &1 ==> (acs diffl (inv(--(sin(acs x)))))(x)`;;\n\nlet DIFF_ACS = `!x. --(&1) < x /\\ x < &1 ==> (acs diffl --(inv(sqrt(&1 - (x pow 2)))))(x)`;;\n\nlet DIFF_ACS_COMPOSITE = `(g diffl m)(x) /\\ -- &1 < g(x) /\\ g(x) < &1\n ==> ((\\x. acs(g x)) diffl (--inv(sqrt(&1 - g(x) pow 2)) * m))(x)`;;\n\nlet ACS_MONO_LT = `!x y. --(&1) < x /\\ x < y /\\ y < &1 ==> acs(y) < acs(x)`;;\n\nlet LE_MATCH_TAC th (asl,w) =\n let thi = PART_MATCH (rand o rator) th (rand(rator w)) in\n let tm = rand(concl thi) in\n (MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC tm THEN CONJ_TAC THENL\n [MATCH_ACCEPT_TAC th; ALL_TAC]) (asl,w);;\n\nlet LESS_SUC_EQ = `!m n. m < SUC n <=> m <= n`;;\n\nlet LESS_1 = `!n. n < 1 <=> (n = 0)`;;\n\nlet division = new_definition\n `division(a,b) D <=>\n (D 0 = a) /\\\n (?N. (!n. n < N ==> D(n) < D(SUC n)) /\\\n (!n. n >= N ==> (D(n) = b)))`;;\n\nlet dsize = new_definition\n `dsize D =\n @N. (!n. n < N ==> D(n) < D(SUC n)) /\\\n (!n. n >= N ==> (D(n) = D(N)))`;;\n\nlet tdiv = new_definition\n `tdiv(a,b) (D,p) <=>\n division(a,b) D /\\\n (!n. D(n) <= p(n) /\\ p(n) <= D(SUC n))`;;\n\nlet gauge = new_definition\n `gauge(E) (g:real->real) <=> !x. E x ==> &0 < g(x)`;;\n\nlet fine = new_definition\n `fine(g:real->real) (D,p) <=>\n !n. n < (dsize D) ==> (D(SUC n) - D(n)) < g(p(n))`;;\n\nlet rsum = new_definition\n `rsum (D,(p:num->real)) f =\n sum(0,dsize(D))(\\n. f(p n) * (D(SUC n) - D(n)))`;;\n\nlet defint = new_definition\n `defint(a,b) f k <=>\n !e. &0 < e ==>\n ?g. gauge(\\x. a <= x /\\ x <= b) g /\\\n !D p. tdiv(a,b) (D,p) /\\ fine(g)(D,p) ==>\n abs(rsum(D,p) f - k) < e`;;\n\nlet DIVISION_0 = `!a b. (a = b) ==> (dsize(\\n. if (n = 0) then a else b) = 0)`;;\n\nlet DIVISION_1 = `!a b. a < b ==> (dsize(\\n. if (n = 0) then a else b) = 1)`;;\n\nlet DIVISION_SINGLE = `!a b. a <= b ==> division(a,b)(\\n. if (n = 0) then a else b)`;;\n\nlet DIVISION_LHS = `!D a b. division(a,b) D ==> (D(0) = a)`;;\n\nlet DIVISION_THM = `!D a b. division(a,b) D <=>\n (D(0) = a) /\\\n (!n. n < (dsize D) ==> D(n) < D(SUC n)) /\\\n (!n. n >= (dsize D) ==> (D(n) = b))`;;\n\nlet DIVISION_RHS = `!D a b. division(a,b) D ==> (D(dsize D) = b)`;;\n\nlet DIVISION_LT_GEN = `!D a b m n. division(a,b) D /\\\n m < n /\\\n n <= (dsize D) ==> D(m) < D(n)`;;\n\nlet DIVISION_LT = `!D a b. division(a,b) D ==> !n. n < (dsize D) ==> D(0) < D(SUC n)`;;\n\nlet DIVISION_LE = `!D a b. division(a,b) D ==> a <= b`;;\n\nlet DIVISION_GT = `!D a b. division(a,b) D ==> !n. n < (dsize D) ==> D(n) < D(dsize D)`;;\n\nlet DIVISION_EQ = `!D a b. division(a,b) D ==> ((a = b) <=> (dsize D = 0))`;;\n\nlet DIVISION_LBOUND = `!D a b r. division(a,b) D ==> a <= D(r)`;;\n\nlet DIVISION_LBOUND_LT = `!D a b n. division(a,b) D /\\ ~(dsize D = 0) ==> a < D(SUC n)`;;\n\nlet DIVISION_UBOUND = `!D a b r. division(a,b) D ==> D(r) <= b`;;\n\nlet DIVISION_UBOUND_LT = `!D a b n. division(a,b) D /\\\n n < dsize D ==> D(n) < b`;;\n\nlet DIVISION_APPEND_LEMMA1 = `!a b c D1 D2. division(a,b) D1 /\\ division(b,c) D2 ==>\n (!n. n < ((dsize D1) + (dsize D2)) ==>\n (\\n. if (n < (dsize D1)) then D1(n) else\n D2(n - (dsize D1)))(n) <\n (\\n. if (n < (dsize D1)) then D1(n) else D2(n - (dsize D1)))(SUC n)) /\\\n (!n. n >= ((dsize D1) + (dsize D2)) ==>\n ((\\n. if (n < (dsize D1)) then D1(n) else\n D2(n - (dsize D1)))(n) = (\\n. if (n < (dsize D1)) then D1(n) else\n D2(n - (dsize D1)))((dsize D1) + (dsize D2))))`;;\n\nlet DIVISION_APPEND_LEMMA2 = `!a b c D1 D2. division(a,b) D1 /\\ division(b,c) D2 ==>\n (dsize(\\n. if (n < (dsize D1)) then D1(n) else\n D2(n - (dsize D1))) = dsize(D1) + dsize(D2))`;;\n\nlet DIVISION_APPEND_EXPLICIT = `!a b c g d1 p1 d2 p2.\n tdiv(a,b) (d1,p1) /\\\n fine g (d1,p1) /\\\n tdiv(b,c) (d2,p2) /\\\n fine g (d2,p2)\n ==> tdiv(a,c)\n ((\\n. if n < dsize d1 then d1(n) else d2(n - (dsize d1))),\n (\\n. if n < dsize d1\n then p1(n) else p2(n - (dsize d1)))) /\\\n fine g ((\\n. if n < dsize d1 then d1(n) else d2(n - (dsize d1))),\n (\\n. if n < dsize d1\n then p1(n) else p2(n - (dsize d1)))) /\\\n !f. rsum((\\n. if n < dsize d1 then d1(n) else d2(n - (dsize d1))),\n (\\n. if n < dsize d1\n then p1(n) else p2(n - (dsize d1)))) f =\n rsum(d1,p1) f + rsum(d2,p2) f`;;\n\nlet DIVISION_APPEND_STRONG = `!a b c D1 p1 D2 p2.\n tdiv(a,b) (D1,p1) /\\ fine(g) (D1,p1) /\\\n tdiv(b,c) (D2,p2) /\\ fine(g) (D2,p2)\n ==> ?D p. tdiv(a,c) (D,p) /\\ fine(g) (D,p) /\\\n !f. rsum(D,p) f = rsum(D1,p1) f + rsum(D2,p2) f`;;\n\nlet DIVISION_APPEND = `!a b c.\n (?D1 p1. tdiv(a,b) (D1,p1) /\\ fine(g) (D1,p1)) /\\\n (?D2 p2. tdiv(b,c) (D2,p2) /\\ fine(g) (D2,p2)) ==>\n ?D p. tdiv(a,c) (D,p) /\\ fine(g) (D,p)`;;\n\nlet DIVISION_EXISTS = `!a b g. a <= b /\\ gauge(\\x. a <= x /\\ x <= b) g ==>\n ?D p. tdiv(a,b) (D,p) /\\ fine(g) (D,p)`;;\n\nlet GAUGE_MIN = `!E g1 g2. gauge(E) g1 /\\ gauge(E) g2 ==>\n gauge(E) (\\x. if g1(x) < g2(x) then g1(x) else g2(x))`;;\n\nlet FINE_MIN = `!g1 g2 D p. fine (\\x. if g1(x) < g2(x) then g1(x) else g2(x)) (D,p) ==>\n fine(g1) (D,p) /\\ fine(g2) (D,p)`;;\n\nlet DINT_UNIQ = `!a b f k1 k2. a <= b /\\ defint(a,b) f k1 /\\ defint(a,b) f k2 ==> (k1 = k2)`;;\n\nlet INTEGRAL_NULL = `!f a. defint(a,a) f (&0)`;;\n\nlet STRADDLE_LEMMA = `!f f' a b e. (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\ &0 < e\n ==> ?g. gauge(\\x. a <= x /\\ x <= b) g /\\\n !x u v. a <= u /\\ u <= x /\\ x <= v /\\ v <= b /\\ (v - u) < g(x)\n ==> abs((f(v) - f(u)) - (f'(x) * (v - u))) <= e * (v - u)`;;\n\nlet FTC1 = `!f f' a b. a <= b /\\ (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x))\n ==> defint(a,b) f' (f(b) - f(a))`;;\n\nlet integrable = new_definition\n `integrable(a,b) f = ?i. defint(a,b) f i`;;\n\nlet integral = new_definition\n `integral(a,b) f = @i. defint(a,b) f i`;;\n\nlet INTEGRABLE_DEFINT = `!f a b. integrable(a,b) f ==> defint(a,b) f (integral(a,b) f)`;;\n\nlet DIVISION_BOUNDS = `!d a b. division(a,b) d ==> !n. a <= d(n) /\\ d(n) <= b`;;\n\nlet TDIV_BOUNDS = `!d p a b. tdiv(a,b) (d,p)\n ==> !n. a <= d(n) /\\ d(n) <= b /\\ a <= p(n) /\\ p(n) <= b`;;\n\nlet TDIV_LE = `!d p a b. tdiv(a,b) (d,p) ==> a <= b`;;\n\nlet DEFINT_WRONG = `!a b f i. b < a ==> defint(a,b) f i`;;\n\nlet DEFINT_INTEGRAL = `!f a b i. a <= b /\\ defint(a,b) f i ==> integral(a,b) f = i`;;\n\nlet DEFINT_CONST = `!a b c. defint(a,b) (\\x. c) (c * (b - a))`;;\n\nlet DEFINT_0 = `!a b. defint(a,b) (\\x. &0) (&0)`;;\n\nlet DEFINT_NEG = `!f a b i. defint(a,b) f i ==> defint(a,b) (\\x. --f x) (--i)`;;\n\nlet DEFINT_CMUL = `!f a b c i. defint(a,b) f i ==> defint(a,b) (\\x. c * f x) (c * i)`;;\n\nlet DEFINT_ADD = `!f g a b i j.\n defint(a,b) f i /\\ defint(a,b) g j\n ==> defint(a,b) (\\x. f x + g x) (i + j)`;;\n\nlet DEFINT_SUB = `!f g a b i j.\n defint(a,b) f i /\\ defint(a,b) g j\n ==> defint(a,b) (\\x. f x - g x) (i - j)`;;\n\nlet INTEGRAL_LE = `!f g a b i j.\n a <= b /\\ integrable(a,b) f /\\ integrable(a,b) g /\\\n (!x. a <= x /\\ x <= b ==> f(x) <= g(x))\n ==> integral(a,b) f <= integral(a,b) g`;;\n\nlet DEFINT_LE = `!f g a b i j. a <= b /\\ defint(a,b) f i /\\ defint(a,b) g j /\\\n (!x. a <= x /\\ x <= b ==> f(x) <= g(x))\n ==> i <= j`;;\n\nlet DEFINT_TRIANGLE = `!f a b i j. a <= b /\\ defint(a,b) f i /\\ defint(a,b) (\\x. abs(f x)) j\n ==> abs(i) <= j`;;\n\nlet DEFINT_EQ = `!f g a b i j. a <= b /\\ defint(a,b) f i /\\ defint(a,b) g j /\\\n (!x. a <= x /\\ x <= b ==> f(x) = g(x))\n ==> i = j`;;\n\nlet INTEGRAL_EQ = `!f g a b i. defint(a,b) f i /\\\n (!x. a <= x /\\ x <= b ==> f(x) = g(x))\n ==> defint(a,b) g i`;;\n\nlet INTEGRATION_BY_PARTS = `!f g f' g' a b.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n (!x. a <= x /\\ x <= b ==> (g diffl g'(x))(x))\n ==> defint(a,b) (\\x. f'(x) * g(x) + f(x) * g'(x))\n (f(b) * g(b) - f(a) * g(a))`;;\n\nlet DIVISION_LE_SUC = `!d a b. division(a,b) d ==> !n. d(n) <= d(SUC n)`;;\n\nlet DIVISION_MONO_LE = `!d a b. division(a,b) d ==> !m n. m <= n ==> d(m) <= d(n)`;;\n\nlet DIVISION_MONO_LE_SUC = `!d a b. division(a,b) d ==> !n. d(n) <= d(SUC n)`;;\n\nlet DIVISION_INTERMEDIATE = `!d a b c. division(a,b) d /\\ a <= c /\\ c <= b\n ==> ?n. n <= dsize d /\\ d(n) <= c /\\ c <= d(SUC n)`;;\n\nlet DIVISION_DSIZE_LE = `!a b d n. division(a,b) d /\\ d(SUC n) = d(n) ==> dsize d <= n`;;\n\nlet DIVISION_DSIZE_GE = `!a b d n. division(a,b) d /\\ d(n) < d(SUC n) ==> SUC n <= dsize d`;;\n\nlet DIVISION_DSIZE_EQ = `!a b d n. division(a,b) d /\\ d(n) < d(SUC n) /\\ d(SUC(SUC n)) = d(SUC n)\n ==> dsize d = SUC n`;;\n\nlet DIVISION_DSIZE_EQ_ALT = `!a b d n. division(a,b) d /\\ d(SUC n) = d(n) /\\\n (!i. i < n ==> d(i) < d(SUC i))\n ==> dsize d = n`;;\n\nlet DEFINT_COMBINE = `!f a b c i j. a <= b /\\ b <= c /\\ defint(a,b) f i /\\ defint(b,c) f j\n ==> defint(a,c) f (i + j)`;;\n\nlet DEFINT_DELTA_LEFT = `!a b. defint(a,b) (\\x. if x = a then &1 else &0) (&0)`;;\n\nlet DEFINT_DELTA_RIGHT = `!a b. defint(a,b) (\\x. if x = b then &1 else &0) (&0)`;;\n\nlet DEFINT_DELTA = `!a b c. defint(a,b) (\\x. if x = c then &1 else &0) (&0)`;;\n\nlet DEFINT_POINT_SPIKE = `!f g a b c i.\n (!x. a <= x /\\ x <= b /\\ ~(x = c) ==> (f x = g x)) /\\ defint(a,b) f i\n ==> defint(a,b) g i`;;\n\nlet DEFINT_FINITE_SPIKE = `!f g a b s i.\n FINITE s /\\\n (!x. a <= x /\\ x <= b /\\ ~(x IN s) ==> (f x = g x)) /\\\n defint(a,b) f i\n ==> defint(a,b) g i`;;\n\nlet GAUGE_MIN_FINITE = `!s gs n. (!m:num. m <= n ==> gauge s (gs m))\n ==> ?g. gauge s g /\\\n !d p. fine g (d,p) ==> !m. m <= n ==> fine (gs m) (d,p)`;;\n\nlet INTEGRABLE_CAUCHY = `!f a b. integrable(a,b) f <=>\n !e. &0 < e\n ==> ?g. gauge (\\x. a <= x /\\ x <= b) g /\\\n !d1 p1 d2 p2.\n tdiv (a,b) (d1,p1) /\\ fine g (d1,p1) /\\\n tdiv (a,b) (d2,p2) /\\ fine g (d2,p2)\n ==> abs (rsum(d1,p1) f - rsum(d2,p2) f) < e`;;\n\nlet SUM_DIFFS = `!m n. sum(m,n) (\\i. d(SUC i) - d(i)) = d(m + n) - d m`;;\n\nlet RSUM_BOUND = `!a b d p e f.\n tdiv(a,b) (d,p) /\\\n (!x. a <= x /\\ x <= b ==> abs(f x) <= e)\n ==> abs(rsum(d,p) f) <= e * (b - a)`;;\n\nlet RSUM_DIFF_BOUND = `!a b d p e f g.\n tdiv(a,b) (d,p) /\\\n (!x. a <= x /\\ x <= b ==> abs(f x - g x) <= e)\n ==> abs(rsum (d,p) f - rsum (d,p) g) <= e * (b - a)`;;\n\nlet INTEGRABLE_LIMIT = `!f a b. (!e. &0 < e\n ==> ?g. (!x. a <= x /\\ x <= b ==> abs(f x - g x) <= e) /\\\n integrable(a,b) g)\n ==> integrable(a,b) f`;;\n\nlet INTEGRABLE_CONST = `!a b c. integrable(a,b) (\\x. c)`;;\n\nlet INTEGRABLE_COMBINE = `!f a b c. a <= b /\\ b <= c /\\ integrable(a,b) f /\\ integrable(b,c) f\n ==> integrable(a,c) f`;;\n\nlet INTEGRABLE_POINT_SPIKE = `!f g a b c.\n (!x. a <= x /\\ x <= b /\\ ~(x = c) ==> f x = g x) /\\ integrable(a,b) f\n ==> integrable(a,b) g`;;\n\nlet INTEGRABLE_CONTINUOUS = `!f a b. (!x. a <= x /\\ x <= b ==> f contl x) ==> integrable(a,b) f`;;\n\nlet INTEGRABLE_SPLIT_SIDES = `!f a b c.\n a <= c /\\ c <= b /\\ integrable(a,b) f\n ==> ?i. !e. &0 < e\n ==> ?g. gauge(\\x. a <= x /\\ x <= b) g /\\\n !d1 p1 d2 p2. tdiv(a,c) (d1,p1) /\\\n fine g (d1,p1) /\\\n tdiv(c,b) (d2,p2) /\\\n fine g (d2,p2)\n ==> abs((rsum(d1,p1) f +\n rsum(d2,p2) f) - i) < e`;;\n\nlet INTEGRABLE_SUBINTERVAL_LEFT = `!f a b c. a <= c /\\ c <= b /\\ integrable(a,b) f ==> integrable(a,c) f`;;\n\nlet INTEGRABLE_SUBINTERVAL_RIGHT = `!f a b c. a <= c /\\ c <= b /\\ integrable(a,b) f ==> integrable(c,b) f`;;\n\nlet INTEGRABLE_SUBINTERVAL = `!f a b c d. a <= c /\\ c <= d /\\ d <= b /\\ integrable(a,b) f\n ==> integrable(c,d) f`;;\n\nlet INTEGRABLE_RULE =\n let pth = `(!x. f contl x) ==> integrable(a,b) f`;;\n\nlet INTEGRAL_CMUL = `!f c a b. a <= b /\\ integrable(a,b) f\n ==> integral(a,b) (\\x. c * f(x)) = c * integral(a,b) f`;;\n\nlet INTEGRAL_ADD = `!f g a b. a <= b /\\ integrable(a,b) f /\\ integrable(a,b) g\n ==> integral(a,b) (\\x. f(x) + g(x)) =\n integral(a,b) f + integral(a,b) g`;;\n\nlet INTEGRAL_SUB = `!f g a b. a <= b /\\ integrable(a,b) f /\\ integrable(a,b) g\n ==> integral(a,b) (\\x. f(x) - g(x)) =\n integral(a,b) f - integral(a,b) g`;;\n\nlet INTEGRAL_BY_PARTS = `!f g f' g' a b.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f' x) x) /\\\n (!x. a <= x /\\ x <= b ==> (g diffl g' x) x) /\\\n integrable(a,b) (\\x. f' x * g x) /\\\n integrable(a,b) (\\x. f x * g' x)\n ==> integral(a,b) (\\x. f x * g' x) =\n (f b * g b - f a * g a) - integral(a,b) (\\x. f' x * g x)`;;\n\nlet SYM_CANON_CONV sym fn =\n REWR_CONV sym o check\n (not o fn o ((snd o dest_comb) F_F I) o dest_comb);;\n\nlet EXT_CONV = SYM o uncurry X_FUN_EQ_CONV o\n (I F_F (mk_eq o (rator F_F rator) o dest_eq)) o dest_forall;;\n\nlet MCLAURIN = `!f diff h n.\n &0 < h /\\\n 0 < n /\\\n (diff(0) = f) /\\\n (!m t. m < n /\\ &0 <= t /\\ t <= h ==>\n (diff(m) diffl diff(SUC m)(t))(t)) ==>\n (?t. &0 < t /\\ t < h /\\\n (f(h) = sum(0,n)(\\m. (diff(m)(&0) / &(FACT m)) * (h pow m)) +\n ((diff(n)(t) / &(FACT n)) * (h pow n))))`;;\n\nlet MCLAURIN_NEG = `!f diff h n.\n h < &0 /\\\n 0 < n /\\\n (diff(0) = f) /\\\n (!m t. m < n /\\ h <= t /\\ t <= &0 ==>\n (diff(m) diffl diff(SUC m)(t))(t)) ==>\n (?t. h < t /\\ t < &0 /\\\n (f(h) = sum(0,n)(\\m. (diff(m)(&0) / &(FACT m)) * (h pow m)) +\n ((diff(n)(t) / &(FACT n)) * (h pow n))))`;;\n\nlet MCLAURIN_BI_LE = `!f diff x n.\n (diff 0 = f) /\\\n (!m t. m < n /\\ abs(t) <= abs(x) ==> (diff m diffl diff (SUC m) t) t)\n ==> ?t. abs(t) <= abs(x) /\\\n (f x = sum (0,n) (\\m. diff m (&0) / &(FACT m) * x pow m) +\n diff n t / &(FACT n) * x pow n)`;;\n\nlet MCLAURIN_ALL_LT = `!f diff.\n (diff 0 = f) /\\\n (!m x. ((diff m) diffl (diff(SUC m) x)) x)\n ==> !x n. ~(x = &0) /\\ 0 < n\n ==> ?t. &0 < abs(t) /\\ abs(t) < abs(x) /\\\n (f(x) = sum(0,n)(\\m. (diff m (&0) / &(FACT m)) * x pow m) +\n (diff n t / &(FACT n)) * x pow n)`;;\n\nlet MCLAURIN_ZERO = `!diff n x. (x = &0) /\\ 0 < n ==>\n (sum(0,n)(\\m. (diff m (&0) / &(FACT m)) * x pow m) = diff 0 (&0))`;;\n\nlet MCLAURIN_ALL_LE = `!f diff.\n (diff 0 = f) /\\\n (!m x. ((diff m) diffl (diff(SUC m) x)) x)\n ==> !x n. ?t. abs(t) <= abs(x) /\\\n (f(x) = sum(0,n)(\\m. (diff m (&0) / &(FACT m)) * x pow m) +\n (diff n t / &(FACT n)) * x pow n)`;;\n\nlet MCLAURIN_EXP_LEMMA = `((\\n:num. exp) 0 = exp) /\\\n (!m x. (((\\n:num. exp) m) diffl ((\\n:num. exp) (SUC m) x)) x)`;;\n\nlet MCLAURIN_EXP_LT = `!x n. ~(x = &0) /\\ 0 < n\n ==> ?t. &0 < abs(t) /\\\n abs(t) < abs(x) /\\\n (exp(x) = sum(0,n)(\\m. x pow m / &(FACT m)) +\n (exp(t) / &(FACT n)) * x pow n)`;;\n\nlet MCLAURIN_EXP_LE = `!x n. ?t. abs(t) <= abs(x) /\\\n (exp(x) = sum(0,n)(\\m. x pow m / &(FACT m)) +\n (exp(t) / &(FACT n)) * x pow n)`;;\n\nlet DIFF_LN_COMPOSITE = `!g m x. (g diffl m)(x) /\\ &0 < g x\n ==> ((\\x. ln(g x)) diffl (inv(g x) * m))(x)`;;\n\nlet MCLAURIN_LN_POS = `!x n.\n &0 < x /\\ 0 < n\n ==> ?t. &0 < t /\\\n t < x /\\\n (ln(&1 + x) = sum(0,n)\n (\\m. --(&1) pow (SUC m) * (x pow m) / &m) +\n --(&1) pow (SUC n) * x pow n / (&n * (&1 + t) pow n))`;;\n\nlet MCLAURIN_LN_NEG = `!x n. &0 < x /\\ x < &1 /\\ 0 < n\n ==> ?t. &0 < t /\\\n t < x /\\\n (--(ln(&1 - x)) = sum(0,n) (\\m. (x pow m) / &m) +\n x pow n / (&n * (&1 - t) pow n))`;;\n\nlet MCLAURIN_SIN = `!x n. abs(sin x -\n sum(0,n) (\\m. (if EVEN m then &0\n else -- &1 pow ((m - 1) DIV 2) / &(FACT m)) *\n x pow m))\n <= inv(&(FACT n)) * abs(x) pow n`;;\n\nlet MCLAURIN_COS = `!x n. abs(cos x -\n sum(0,n) (\\m. (if EVEN m\n then -- &1 pow (m DIV 2) / &(FACT m)\n else &0) * x pow m))\n <= inv(&(FACT n)) * abs(x) pow n`;;\n\nlet REAL_ATN_POWSER_SUMMABLE = `!x. abs(x) < &1\n ==> summable (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n) * x pow n)`;;\n\nlet REAL_ATN_POWSER_DIFFS_SUMMABLE = `!x. abs(x) < &1\n ==> summable (\\n. diffs (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n)) n *\n x pow n)`;;\n\nlet REAL_ATN_POWSER_DIFFS_SUM = `!x. abs(x) < &1\n ==> (\\n. diffs (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n)) n * x pow n)\n sums (inv(&1 + x pow 2))`;;\n\nlet REAL_ATN_POWSER_DIFFS_DIFFS_SUMMABLE = `!x. abs(x) < &1\n ==> summable\n (\\n. diffs (diffs\n (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n))) n * x pow n)`;;\n\nlet REAL_ATN_POWSER_DIFFL = `!x. abs(x) < &1\n ==> ((\\x. suminf (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n) * x pow n))\n diffl (inv(&1 + x pow 2))) x`;;\n\nlet REAL_ATN_POWSER = `!x. abs(x) < &1\n ==> (\\n. (if EVEN n then &0\n else --(&1) pow ((n - 1) DIV 2) / &n) * x pow n)\n sums (atn x)`;;\n\nlet MCLAURIN_ATN = `!x n. abs(x) < &1\n ==> abs(atn x -\n sum(0,n) (\\m. (if EVEN m then &0\n else --(&1) pow ((m - 1) DIV 2) / &m) *\n x pow m))\n <= abs(x) pow n / (&1 - abs x)`;;" }, { "theorem_id": 35, "title": "035_taylor_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory Taylor_Models\n imports\n \"Horner_Eval\"\n \"Polynomial_Expression_Additional\"\n \"Taylor_Models_Misc\"\n \"HOL-Decision_Procs.Approximation\"\n \"HOL-Library.Function_Algebras\"\n \"HOL-Library.Set_Algebras\"\n \"Affine_Arithmetic.Straight_Line_Program\"\n \"Affine_Arithmetic.Affine_Approximation\"\nbegin\n\ntext \\TODO: get rid of float poly/float inteval and use real poly/real interval\n and data refinement?\\\n\nsection \\Multivariate Taylor Models\\\n\nsubsection \\Computing interval bounds on arithmetic expressions\\\n\ntext \\This is a wrapper around the \"approx\" function.\n It computes range bounds on floatarith expressions.\\\nfun compute_bound_fa :: \"nat \\ floatarith \\ float interval list \\ float interval option\"\n where \"compute_bound_fa prec f I = approx prec f (map Some I)\"\n\nlemma compute_bound_fa_correct:\n \"interpret_floatarith f i \\\\<^sub>r ivl\"\n if \"compute_bound_fa prec f I = Some ivl\"\n \"i all_in I\"\n for i::\"real list\"\n by sorry\n\nsubsection \\Definition of Taylor models and notion of rangeity\\\n\ntext \\Taylor models are a pair of a polynomial and an absolute error bound.\\\ndatatype taylor_model = TaylorModel (tm_poly: \"float poly\") (tm_bound: \"float interval\")\n\ntext \\Taylor model for a real valuation of variables\\\n\nprimrec insertion :: \"(nat \\ 'a) \\ 'a poly \\ 'a::{plus,zero,minus,uminus,times,one,power}\"\nwhere\n \"insertion bs (C c) = c\"\n| \"insertion bs (poly.Bound n) = bs n\"\n| \"insertion bs (Neg a) = - insertion bs a\"\n| \"insertion bs (poly.Add a b) = insertion bs a + insertion bs b\"\n| \"insertion bs (Sub a b) = insertion bs a - insertion bs b\"\n| \"insertion bs (Mul a b) = insertion bs a * insertion bs b\"\n| \"insertion bs (Pw t n) = insertion bs t ^ n\"\n| \"insertion bs (CN c n p) = insertion bs c + (bs n) * insertion bs p\"\n\ndefinition range_tm :: \"(nat \\ real) \\ taylor_model \\ real interval\" where\n\"range_tm e tm = interval_of (insertion e (tm_poly tm)) + real_interval (tm_bound tm)\"\n\nlemma Ipoly_num_params_cong: \"Ipoly xs p = Ipoly ys p\"\n if \"\\i. i < num_params p \\ xs ! i = ys ! i\"\n by sorry\n\nlemma insertion_num_params_cong: \"insertion e p = insertion f p\"\n if \"\\i. i < num_params p \\ e i = f i\"\n by sorry\n\nlemma insertion_eq_IpolyI: \"insertion xs p = Ipoly ys p\"\n if \"\\i. i < num_params p \\ xs i = ys ! i\"\n by sorry\n\nlemma Ipoly_eq_insertionI: \"Ipoly ys p = insertion xs p\"\n if \"\\i. i < num_params p \\ xs i = ys ! i\"\n by sorry\n\nlemma range_tmI:\n \"x \\\\<^sub>i range_tm e tm\"\n if x: \"x \\\\<^sub>i interval_of (insertion e ((tm_poly tm))) + real_interval (tm_bound tm)\"\n for e::\"nat\\real\"\n by sorry\n\nlemma range_tmD:\n \"x \\\\<^sub>i interval_of (insertion e (tm_poly tm)) + real_interval (tm_bound tm)\"\n if \"x \\\\<^sub>i range_tm e tm\"\n for e::\"nat\\real\"\n by sorry\n\nsubsection \\Interval bounds for Taylor models\\\n\ntext \\Bound a polynomial by simply approximating it with interval arguments.\\\nfun compute_bound_poly :: \"nat \\ float interval poly \\ (float interval list) \\ (float interval list) \\ float interval\" where\n \"compute_bound_poly prec (poly.C f) I a = f\"\n| \"compute_bound_poly prec (poly.Bound n) I a = round_interval prec (I ! n - (a ! n))\"\n| \"compute_bound_poly prec (poly.Add p q) I a =\n round_interval prec (compute_bound_poly prec p I a + compute_bound_poly prec q I a)\"\n| \"compute_bound_poly prec (poly.Sub p q) I a =\n round_interval prec (compute_bound_poly prec p I a - compute_bound_poly prec q I a)\"\n| \"compute_bound_poly prec (poly.Mul p q) I a =\n mult_float_interval prec (compute_bound_poly prec p I a) (compute_bound_poly prec q I a)\"\n| \"compute_bound_poly prec (poly.Neg p) I a = -compute_bound_poly prec p I a\"\n| \"compute_bound_poly prec (poly.Pw p n) I a = power_float_interval prec n (compute_bound_poly prec p I a)\"\n| \"compute_bound_poly prec (poly.CN p n q) I a =\n round_interval prec (compute_bound_poly prec p I a +\n mult_float_interval prec (round_interval prec (I ! n - (a ! n))) (compute_bound_poly prec q I a))\"\n\ntext \\Bounds on Taylor models are simply a bound on its polynomial, widened by the approximation error.\\\nfun compute_bound_tm :: \"nat \\ float interval list \\ float interval list \\ taylor_model \\ float interval\"\n where \"compute_bound_tm prec I a (TaylorModel p e) = compute_bound_poly prec p I a + e\"\n\nlemma compute_bound_tm_def:\n \"compute_bound_tm prec I a tm = compute_bound_poly prec (tm_poly tm) I a + (tm_bound tm)\"\n by sorry\n\nlemma real_of_float_in_real_interval_of[intro, simp]: \"real_of_float x \\\\<^sub>r X\" if \"x \\\\<^sub>i X\"\n by sorry\n\nlemma in_set_of_round_interval[intro, simp]:\n \"x \\\\<^sub>r round_interval prec X\" if \"x \\\\<^sub>r X\"\n by sorry\n\nlemma in_set_real_minus_interval[intro, simp]:\n \"x - y \\\\<^sub>r X - Y\" if \"x \\\\<^sub>r X\" \"y \\\\<^sub>r Y\"\n by sorry\n\nlemma real_interval_plus: \"real_interval (a + b) = real_interval a + real_interval b\"\n by sorry\n\nlemma real_interval_uminus: \"real_interval (- b) = - real_interval b\"\n by sorry\n\nlemma real_interval_of: \"real_interval (interval_of b) = interval_of b\"\n by sorry\n\nlemma real_interval_minus: \"real_interval (a - b) = real_interval a - real_interval b\"\n by sorry\n\nlemma in_set_real_plus_interval[intro, simp]:\n \"x + y \\\\<^sub>r X + Y\" if \"x \\\\<^sub>r X\" \"y \\\\<^sub>r Y\"\n by sorry\n\nlemma in_set_neg_plus_interval[intro, simp]:\n \"- y \\\\<^sub>r - Y\" if \"y \\\\<^sub>r Y\"\n by sorry\n\nlemma in_set_real_times_interval[intro, simp]:\n \"x * y \\\\<^sub>r X * Y\" if \"x \\\\<^sub>r X\" \"y \\\\<^sub>r Y\"\n by sorry\n\nlemma real_interval_one: \"real_interval 1 = 1\"\n by sorry\n\nlemma real_interval_zero: \"real_interval 0 = 0\"\n by sorry\n\nlemma real_interval_power: \"real_interval (a ^ b) = real_interval a ^ b\"\n by sorry\n\nlemma in_set_real_power_interval[intro, simp]:\n \"x ^ n \\\\<^sub>r X ^ n\" if \"x \\\\<^sub>r X\"\n by sorry\n\nlemma power_float_interval_real_interval[intro, simp]:\n \"x ^ n \\\\<^sub>r power_float_interval prec n X\" if \"x \\\\<^sub>r X\"\n by sorry\n\nlemma in_set_mult_float_interval[intro, simp]:\n \"x * y \\\\<^sub>r mult_float_interval prec X Y\" if \"x \\\\<^sub>r X\" \"y \\\\<^sub>r Y\"\n by sorry\n\nlemma in_set_real_minus_swapI: \"e i \\\\<^sub>r I ! i - a ! i\"\n if \"x - e i \\\\<^sub>r a ! i\" \"x \\\\<^sub>r I ! i\"\n by sorry\n\ndefinition develops_at_within::\"(nat \\ real) \\ float interval list \\ float interval list \\ bool\"\n where \"develops_at_within e a I \\ (a all_subset I) \\ (\\i < length I. e i \\\\<^sub>r I ! i - a ! i)\"\n\nlemma develops_at_withinI:\n assumes all_in: \"a all_subset I\"\n assumes e: \"\\i. i < length I \\ e i \\\\<^sub>r I ! i - a ! i\"\n shows \"develops_at_within e a I\"\n by sorry\n\nlemma develops_at_withinD:\n assumes \"develops_at_within e a I\"\n shows \"a all_subset I\"\n \"\\i. i < length I \\ e i \\\\<^sub>r I ! i - a ! i\"\n by sorry\n\nlemma compute_bound_poly_correct:\n fixes p::\"float poly\"\n assumes \"num_params p \\ length I\"\n assumes dev: \"develops_at_within e a I\"\n shows \"insertion e (p::real poly) \\\\<^sub>r compute_bound_poly prec (map_poly interval_of p) I a\"\n by sorry\n\nlemma compute_bound_tm_correct:\n fixes I :: \"float interval list\" and f :: \"real list \\ real\"\n assumes n: \"num_params (tm_poly t) \\ length I\"\n assumes dev: \"develops_at_within e a I\"\n assumes x0: \"x0 \\\\<^sub>i range_tm e t\"\n shows \"x0 \\\\<^sub>r compute_bound_tm prec I a t\"\n by sorry\n\nlemma compute_bound_tm_correct_subset:\n fixes I :: \"float interval list\" and f :: \"real list \\ real\"\n assumes n: \"num_params (tm_poly t) \\ length I\"\n assumes dev: \"develops_at_within e a I\"\n shows \"set_of (range_tm e t) \\ set_of (real_interval (compute_bound_tm prec I a t))\"\n by sorry\n\nlemma compute_bound_poly_mono:\n assumes \"num_params p \\ length I\"\n assumes mem: \"I all_subset J\" \"a all_subset I\"\n shows \"set_of (compute_bound_poly prec p I a) \\ set_of (compute_bound_poly prec p J a)\"\n by sorry\n\nlemma compute_bound_tm_mono:\n fixes I :: \"float interval list\" and f :: \"real list \\ real\"\n assumes \"num_params (tm_poly t) \\ length I\"\n assumes \"I all_subset J\"\n assumes \"a all_subset I\"\n shows \"set_of (compute_bound_tm prec I a t) \\ set_of (compute_bound_tm prec J a t)\"\n by sorry\n\nsubsection \\Computing taylor models for basic, univariate functions\\\n\ndefinition tm_const :: \"float \\ taylor_model\"\n where \"tm_const c = TaylorModel (poly.C c) 0\"\n\ncontext includes floatarith_syntax begin\n\ndefinition tm_pi :: \"nat \\ taylor_model\"\n where \"tm_pi prec = (\n let pi_ivl = the (compute_bound_fa prec Pi [])\n in TaylorModel (poly.C (mid pi_ivl)) (centered pi_ivl)\n)\"\n\nlemma zero_real_interval[intro,simp]: \"0 \\\\<^sub>r 0\"\n by sorry\n\nlemma range_TM_tm_const[simp]: \"range_tm e (tm_const c) = interval_of c\"\n by sorry\n\nlemma num_params_tm_const[simp]: \"num_params (tm_poly (tm_const c)) = 0\"\n by sorry\n\nlemma num_params_tm_pi[simp]: \"num_params (tm_poly (tm_pi prec)) = 0\"\n by sorry\n\nlemma range_tm_tm_pi: \"pi \\\\<^sub>i range_tm e (tm_pi prec)\"\n by sorry\n\nsubsubsection \\Derivations of floatarith expressions\\\n\ntext \\Compute the nth derivative of a floatarith expression\\\nfun deriv :: \"nat \\ floatarith \\ nat \\ floatarith\"\n where \"deriv v f 0 = f\"\n | \"deriv v f (Suc n) = DERIV_floatarith v (deriv v f n)\"\n\nlemma isDERIV_DERIV_floatarith:\n assumes \"isDERIV v f vs\"\n shows \"isDERIV v (DERIV_floatarith v f) vs\"\n by sorry\n\nlemma isDERIV_is_analytic:\n \"isDERIV i (Taylor_Models.deriv i f n) xs\"\n if \"isDERIV i f xs\"\n by sorry\n\nlemma deriv_correct:\n assumes \"isDERIV i f (xs[i:=t])\" \"i < length xs\"\n shows \"((\\x. interpret_floatarith (deriv i f n) (xs[i:=x])) has_real_derivative interpret_floatarith (deriv i f (Suc n)) (xs[i:=t]))\n (at t within S)\"\n by sorry\n\ntext \\Faster derivation for univariate functions, producing smaller terms and thus less over-approximation.\\\ntext \\TODO: Extend to Arctan, Log!\\\nfun deriv_rec :: \"floatarith \\ nat \\ floatarith\"\n where \"deriv_rec (Exp (Var 0)) _ = Exp (Var 0)\"\n | \"deriv_rec (Cos (Var 0)) n = (case n mod 4\n of 0 \\ Cos (Var 0)\n | Suc 0 \\ Minus (Sin (Var 0))\n | Suc (Suc 0) \\ Minus (Cos (Var 0))\n | Suc (Suc (Suc 0)) \\ Sin (Var 0))\"\n | \"deriv_rec (Inverse (Var 0)) n = (if n = 0 then Inverse (Var 0) else Mult (Num (fact n * (if n mod 2 = 0 then 1 else -1))) (Inverse (Power (Var 0) (Suc n))))\"\n | \"deriv_rec f n = deriv 0 f n\"\n\nlemma deriv_rec_correct:\n assumes \"isDERIV 0 f (xs[0:=t])\" \"0 < length xs\"\n shows \"((\\x. interpret_floatarith (deriv_rec f n) (xs[0:=x])) has_real_derivative interpret_floatarith (deriv_rec f (Suc n)) (xs[0:=t])) (at t within S)\"\n by sorry\n\nlemma deriv_rec_0_idem[simp]:\n shows \"deriv_rec f 0 = f\"\n by sorry\n\nsubsubsection \\Computing Taylor models for arbitrary univariate expressions\\ \n\nfun tmf_c :: \"nat \\ float interval list \\ floatarith \\ nat \\ float interval option\"\n where \"tmf_c prec I f i = compute_bound_fa prec (Mult (deriv_rec f i) (Inverse (Num (fact i)))) I\"\n \\ \\The interval coefficients of the Taylor polynomial,\n i.e. the real coefficients approximated by a float interval.\\\n\nfun tmf_ivl_cs :: \"nat \\ nat \\ float interval list \\ float list \\ floatarith \\ float interval list option\"\n where \"tmf_ivl_cs prec ord I a f = those (map (tmf_c prec a f) [0.. \\Make a list of bounds on the n+1 coefficients, with the n+1-th coefficient bounding\n the remainder term of the Taylor-Lagrange formula.\\\n\nfun tmf_polys :: \"float interval list \\ float poly \\ float interval poly\"\n where \"tmf_polys [] = (poly.C 0, poly.C 0)\"\n | \"tmf_polys (c # cs) = (\n let (pf, pi) = tmf_polys cs\n in (poly.CN (poly.C (mid c)) 0 pf, poly.CN (poly.C (centered c)) 0 pi)\n )\"\n\nfun tm_floatarith :: \"nat \\ nat \\ float interval list \\ float list \\ floatarith \\ taylor_model option\"\n where \"tm_floatarith prec ord I a f = (\n map_option (\\cs. \n let (pf, pi) = tmf_polys cs;\n _ = compute_bound_tm prec (List.map2 (-) I a);\n e = round_interval prec (Ipoly (List.map2 (-) I a) pi) \\ \\TODO: use \\compute_bound_tm\\ here?!\\\n in TaylorModel pf e\n ) (tmf_ivl_cs prec ord I a f)\n)\" \\ \\Compute a Taylor model from an arbitrary, univariate floatarith expression, if possible.\n This is used to compute Taylor models for elemental functions like sin, cos, exp, etc.\\\n\nterm compute_bound_poly\nlemma tmf_c_correct:\n fixes A::\"float interval list\" and I::\"float interval\" and f::floatarith and a::\"real list\"\n assumes \"a all_in A\"\n assumes \"tmf_c prec A f i = Some I\"\n shows \"interpret_floatarith (deriv_rec f i) a / fact i \\\\<^sub>r I\"\n by sorry\n\nlemma tmf_ivl_cs_length:\n assumes \"tmf_ivl_cs prec n A a f = Some cs\"\n shows \"length cs = n + 1\"\n by sorry\n\nlemma tmf_ivl_cs_correct:\n fixes A::\"float interval list\" and f::floatarith\n assumes \"a all_in I\"\n assumes \"tmf_ivl_cs prec ord I a f = Some cs\"\n shows \"\\i. i < ord \\ tmf_c prec (map interval_of a) f i = Some (cs!i)\"\n and \"tmf_c prec I f ord = Some (cs!ord)\"\n and \"length cs = Suc ord\"\n by sorry\n\nlemma Ipoly_fst_tmf_polys:\n \"Ipoly xs (fst (tmf_polys z)) = (\\ii real\"\n by sorry\n\nlemma Ipoly_snd_tmf_polys:\n \"set_of (horner_eval (real_interval o centered o nth z) x (length z)) \\ set_of (Ipoly [x] (map_poly real_interval (snd (tmf_polys z))))\"\n by sorry\n\nlemma zero_interval[intro,simp]: \"0 \\\\<^sub>i 0\"\n by sorry\n\nlemma sum_in_intervalI: \"sum f X \\\\<^sub>i sum g X\" if \"\\x. x \\ X \\ f x \\\\<^sub>i g x\"\n for f :: \"_ \\ 'a :: ordered_comm_monoid_add\"\n by sorry\n\nlemma set_of_sum_subset: \"set_of (sum f X) \\ set_of (sum g X)\"\n if \"\\x. x \\ X \\ set_of (f x) \\ set_of (g x)\"\n for f :: \"_\\'a::linordered_ab_group_add interval\"\n by sorry\n\nlemma interval_of_plus: \"interval_of (a + b) = interval_of a + interval_of b\"\n by sorry\n\nlemma interval_of_uminus: \"interval_of (- a) = - interval_of a\"\n by sorry\n\nlemma interval_of_zero: \"interval_of 0 = 0\"\n by sorry\n\nlemma interval_of_sum: \"interval_of (sum f X) = sum (\\x. interval_of (f x)) X\"\n by sorry\n\nlemma interval_of_prod: \"interval_of (a * b) = interval_of a * interval_of b\"\n by sorry\n\nlemma in_set_of_interval_of[simp]: \"x \\\\<^sub>i (interval_of y) \\ x = y\" for x y::\"'a::order\"\n by sorry\n\nlemma real_interval_Ipoly: \"real_interval (Ipoly xs p) = Ipoly (map real_interval xs) (map_poly real_interval p)\"\n if \"num_params p \\ length xs\"\n by sorry\n\nlemma num_params_tmf_polys1: \"num_params (fst (tmf_polys z)) \\ Suc 0\"\n by sorry\n\nlemma num_params_tmf_polys2: \"num_params (snd (tmf_polys z)) \\ Suc 0\"\n by sorry\n\nlemma set_of_real_interval_subset: \"set_of (real_interval x) \\ set_of (real_interval y)\"\n if \"set_of x \\ set_of y\"\n by sorry\n\ntheorem tm_floatarith:\n assumes t: \"tm_floatarith prec ord I xs f = Some t\"\n assumes a: \"xs all_in I\" and x: \"x \\\\<^sub>r I ! 0\"\n assumes xs_ne: \"xs \\ []\"\n assumes deriv: \"\\x. x \\\\<^sub>r I ! 0 \\ isDERIV 0 f (xs[0 := x])\"\n assumes \"\\i. 0 < i \\ i < length xs \\ e i = real_of_float (xs ! i)\"\n assumes diff_e: \"(x - real_of_float (xs ! 0)) = e 0\"\n shows \"interpret_floatarith f (xs[0:=x]) \\\\<^sub>i range_tm e t\"\n by sorry\n\nsubsection \\Operations on Taylor models\\\n\nfun tm_norm_poly :: \"taylor_model \\ taylor_model\"\n where \"tm_norm_poly (TaylorModel p e) = TaylorModel (polynate p) e\"\n\\ \\Normalizes the Taylor model by transforming its polynomial into horner form.\\\n\nfun tm_lower_order tm_lower_order_of_normed :: \"nat \\ nat \\ float interval list \\ float interval list \\ taylor_model \\ taylor_model\"\n where \"tm_lower_order prec ord I a t = tm_lower_order_of_normed prec ord I a (tm_norm_poly t)\"\n | \"tm_lower_order_of_normed prec ord I a (TaylorModel p e) = (\n let (l, r) = split_by_degree ord p\n in TaylorModel l (round_interval prec (e + compute_bound_poly prec r I a))\n )\"\n\\ \\Reduces the degree of a Taylor model's polynomial to n and keeps it range by increasing the error bound.\\\n\nfun tm_round_floats tm_round_floats_of_normed :: \"nat \\ float interval list \\ float interval list \\ taylor_model \\ taylor_model\"\n where \"tm_round_floats prec I a t = tm_round_floats_of_normed prec I a (tm_norm_poly t)\"\n | \"tm_round_floats_of_normed prec I a (TaylorModel p e) = (\n let (l, r) = split_by_prec prec p\n in TaylorModel l (round_interval prec (e + compute_bound_poly prec r I a))\n )\"\n\\ \\Rounding of Taylor models. Rounds both the coefficients of the polynomial and the floats in the error bound.\\\n\nfun tm_norm tm_norm' :: \"nat \\ nat \\ float interval list \\ float interval list \\ taylor_model \\ taylor_model\"\n where \"tm_norm prec ord I a t = tm_norm' prec ord I a (tm_norm_poly t)\"\n | \"tm_norm' prec ord I a t = tm_round_floats_of_normed prec I a (tm_lower_order_of_normed prec ord I a t)\" \n\\ \\Normalization of taylor models. Performs order lowering and rounding on tayor models,\n also converts the polynomial into horner form.\\\n\nfun tm_neg :: \"taylor_model \\ taylor_model\"\n where \"tm_neg (TaylorModel p e) = TaylorModel (~\\<^sub>p p) (-e)\"\n\nfun tm_add :: \"taylor_model \\ taylor_model \\ taylor_model\"\n where \"tm_add (TaylorModel p1 e1) (TaylorModel p2 e2) = TaylorModel (p1 +\\<^sub>p p2) (e1 + e2)\"\n\nfun tm_sub :: \"taylor_model \\ taylor_model \\ taylor_model\"\n where \"tm_sub t1 t2 = tm_add t1 (tm_neg t2)\"\n\nfun tm_mul :: \"nat \\ nat \\ float interval list \\ float interval list \\ taylor_model \\ taylor_model \\ taylor_model\"\n where \"tm_mul prec ord I a (TaylorModel p1 e1) (TaylorModel p2 e2) = (\n let d1 = compute_bound_poly prec p1 I a;\n d2 = compute_bound_poly prec p2 I a;\n p = p1 *\\<^sub>p p2;\n e = e1*d2 + d1*e2 + e1*e2\n in tm_norm' prec ord I a (TaylorModel p e)\n )\"\nlemmas [simp del] = tm_norm'.simps\n\nfun tm_pow :: \"nat \\ nat \\ float interval list \\ float interval list \\ taylor_model \\ nat \\ taylor_model\"\n where \"tm_pow prec ord I a t 0 = tm_const 1\"\n | \"tm_pow prec ord I a t (Suc n) = (\n if odd (Suc n)\n then tm_mul prec ord I a t (tm_pow prec ord I a t n)\n else let t' = tm_pow prec ord I a t ((Suc n) div 2)\n in tm_mul prec ord I a t' t'\n )\"\n\ntext \\Evaluates a float polynomial, using a Taylor model as the parameter. This is used to compose Taylor models.\\\nfun eval_poly_at_tm :: \"nat \\ nat \\ float interval list \\ float interval list \\ float poly \\ taylor_model \\ taylor_model\"\n where \"eval_poly_at_tm prec ord I a (poly.C c) t = tm_const c\"\n | \"eval_poly_at_tm prec ord I a (poly.Bound n) t = t\"\n | \"eval_poly_at_tm prec ord I a (poly.Add p1 p2) t\n = tm_add (eval_poly_at_tm prec ord I a p1 t)\n (eval_poly_at_tm prec ord I a p2 t)\"\n | \"eval_poly_at_tm prec ord I a (poly.Sub p1 p2) t\n = tm_sub (eval_poly_at_tm prec ord I a p1 t)\n (eval_poly_at_tm prec ord I a p2 t)\"\n | \"eval_poly_at_tm prec ord I a (poly.Mul p1 p2) t\n = tm_mul prec ord I a (eval_poly_at_tm prec ord I a p1 t)\n (eval_poly_at_tm prec ord I a p2 t)\"\n | \"eval_poly_at_tm prec ord I a (poly.Neg p) t\n = tm_neg (eval_poly_at_tm prec ord I a p t)\"\n | \"eval_poly_at_tm prec ord I a (poly.Pw p n) t\n = tm_pow prec ord I a (eval_poly_at_tm prec ord I a p t) n\"\n | \"eval_poly_at_tm prec ord I a (poly.CN c n p) t = (\n let pt = eval_poly_at_tm prec ord I a p t;\n t_mul_pt = tm_mul prec ord I a t pt \n in tm_add (eval_poly_at_tm prec ord I a c t) t_mul_pt\n )\"\n\nfun tm_inc_err :: \"float interval \\ taylor_model \\ taylor_model\"\n where \"tm_inc_err i (TaylorModel p e) = TaylorModel p (e + i)\"\n\nfun tm_comp :: \"nat \\ nat \\ float interval list \\ float interval list \\ float \\ taylor_model \\ taylor_model \\ taylor_model\"\n where \"tm_comp prec ord I a ta (TaylorModel p e) t = (\n let t_sub_ta = tm_sub t (tm_const ta);\n pt = eval_poly_at_tm prec ord I a p t_sub_ta\n in tm_inc_err e pt\n )\"\n\ntext \\\\tm_max\\, \\tm_min\\ and \\tm_abs\\ are implemented extremely naively, because I don't expect them to be very useful.\n But the implementation is fairly modular, i.e. \\tm_{abs,min,max}\\ all can easily be swapped out,\n as long as the corresponding correctness lemmas \\tm_{abs,min,max}_range\\ are updated as well.\\\nfun tm_abs :: \"nat \\ float interval list \\ float interval list \\ taylor_model \\ taylor_model\"\n where \"tm_abs prec I a t = (\n let bound = compute_bound_tm prec I a t; abs_bound=Ivl (0::float) (max (abs (lower bound)) (abs (upper bound)))\n in TaylorModel (poly.C (mid abs_bound)) (centered abs_bound))\"\n\nfun tm_union :: \"nat \\ float interval list \\ float interval list \\ taylor_model \\ taylor_model \\ taylor_model\"\n where \"tm_union prec I a t1 t2 = (\n let b1 = compute_bound_tm prec I a t1; b2 = compute_bound_tm prec I a t2;\n b_combined = sup b1 b2\n in TaylorModel (poly.C (mid b_combined)) (centered b_combined))\"\n\nfun tm_min :: \"nat \\ float interval list \\ float interval list \\ taylor_model \\ taylor_model \\ taylor_model\"\n where \"tm_min prec I a t1 t2 = tm_union prec I a t1 t2\"\n\nfun tm_max :: \"nat \\ float interval list \\ float interval list \\ taylor_model \\ taylor_model \\ taylor_model\"\n where \"tm_max prec I a t1 t2 = tm_union prec I a t1 t2\"\n\ntext \\Rangeity of is preserved by our operations on Taylor models.\\\n\nlemma insertion_polyadd[simp]: \"insertion e (a +\\<^sub>p b) = insertion e a + insertion e b\"\n for a b::\"'a::ring_1 poly\"\n by sorry\n\nlemma insertion_polyneg[simp]: \"insertion e (~\\<^sub>p b) = - insertion e b\"\n for b::\"'a::ring_1 poly\"\n by sorry\n\nlemma insertion_polysub[simp]: \"insertion e (a -\\<^sub>p b) = insertion e a - insertion e b\"\n for a b::\"'a::ring_1 poly\"\n by sorry\n\nlemma insertion_polymul[simp]: \"insertion e (a *\\<^sub>p b) = insertion e a * insertion e b\"\n for a b::\"'a::comm_ring_1 poly\"\n by sorry\n\nlemma insertion_polypow[simp]: \"insertion e (a ^\\<^sub>p b) = insertion e a ^ b\"\n for a::\"'a::comm_ring_1 poly\"\n by sorry\n\nlemma insertion_polynate [simp]:\n \"insertion bs (polynate p) = (insertion bs p :: 'a::comm_ring_1)\"\n by sorry\n\nlemma tm_norm_poly_range:\n assumes \"x \\\\<^sub>i range_tm e t\"\n shows \"x \\\\<^sub>i range_tm e (tm_norm_poly t)\"\n by sorry\n\nlemma split_by_degree_correct_insertion:\n fixes x :: \"nat \\ real\" and p :: \"float poly\"\n assumes \"split_by_degree ord p = (l, r)\"\n shows \"maxdegree l \\ ord\" (is ?P1)\n and \"insertion x p = insertion x l + insertion x r\" (is ?P2)\n and \"num_params l \\ num_params p\" (is ?P3)\n and \"num_params r \\ num_params p\" (is ?P4)\n by sorry\n\nlemma split_by_prec_correct_insertion:\n fixes x :: \"nat \\ real\" and p :: \"float poly\"\n assumes \"split_by_prec ord p = (l, r)\"\n shows \"insertion x p = insertion x l + insertion x r\" (is ?P1)\n and \"num_params l \\ num_params p\" (is ?P2)\n and \"num_params r \\ num_params p\" (is ?P3)\n by sorry\n\nlemma tm_lower_order_of_normed_range:\n assumes \"x \\\\<^sub>i range_tm e t\"\n assumes dev: \"develops_at_within e a I\"\n assumes \"num_params (tm_poly t) \\ length I\"\n shows \"x \\\\<^sub>i range_tm e (tm_lower_order_of_normed prec ord I a t)\"\n by sorry\n\nlemma num_params_tm_norm_poly_le: \"num_params (tm_poly (tm_norm_poly t)) \\ X\"\n if \"num_params (tm_poly t) \\ X\"\n by sorry\n\nlemma tm_lower_order_range:\n assumes \"x \\\\<^sub>i range_tm e t\"\n assumes dev: \"develops_at_within e a I\"\n assumes \"num_params (tm_poly t) \\ length I\"\n shows \"x \\\\<^sub>i range_tm e (tm_lower_order prec ord I a t)\"\n by sorry\n\nlemma tm_round_floats_of_normed_range:\n assumes \"x \\\\<^sub>i range_tm e t\"\n assumes dev: \"develops_at_within e a I\"\n assumes \"num_params (tm_poly t) \\ length I\"\n shows \"x \\\\<^sub>i range_tm e (tm_round_floats_of_normed prec I a t)\"\n \\ \\TODO: this is a clone of @{thm tm_lower_order_of_normed_range} -> general sweeping method!\\\n by sorry\n\nlemma num_params_split_by_degree_le: \"num_params (fst (split_by_degree ord x)) \\ K\"\n \"num_params (snd (split_by_degree ord x)) \\ K\"\n if \"num_params x \\ K\" for x::\"float poly\"\n by sorry\n\nlemma num_params_split_by_prec_le: \"num_params (fst (split_by_prec ord x)) \\ K\"\n \"num_params (snd (split_by_prec ord x)) \\ K\"\n if \"num_params x \\ K\" for x::\"float poly\"\n by sorry\n\nlemma num_params_tm_norm'_le:\n \"num_params (tm_poly (tm_round_floats_of_normed prec I a t)) \\ X\"\n if \"num_params (tm_poly t) \\ X\"\n by sorry\n\nlemma tm_round_floats_range:\n assumes \"x \\\\<^sub>i range_tm e t\" \"develops_at_within e a I\" \"num_params (tm_poly t) \\ length I\"\n shows \"x \\\\<^sub>i range_tm e (tm_round_floats prec I a t)\"\n by sorry\n\nlemma num_params_tm_lower_order_of_normed_le: \"num_params (tm_poly (tm_lower_order_of_normed prec ord I a t)) \\ X\"\n if \"num_params (tm_poly t) \\ X\"\n by sorry\n\nlemma tm_norm'_range:\n assumes \"x \\\\<^sub>i range_tm e t\" \"develops_at_within e a I\" \"num_params (tm_poly t) \\ length I\"\n shows \"x \\\\<^sub>i range_tm e (tm_norm' prec ord I a t)\"\n by sorry\n\nlemma num_params_tm_norm':\n \"num_params (tm_poly (tm_norm' prec ord I a t)) \\ X\"\n if \"num_params (tm_poly t) \\ X\"\n by sorry\n\nlemma tm_norm_range:\n assumes \"x \\\\<^sub>i range_tm e t\" \"develops_at_within e a I\" \"num_params (tm_poly t) \\ length I\"\n shows \"x \\\\<^sub>i range_tm e (tm_norm prec ord I a t)\"\n by sorry\nlemmas [simp del] = tm_norm.simps\n\nlemma tm_neg_range:\n assumes \"x \\\\<^sub>i range_tm e t\"\n shows \"- x \\\\<^sub>i range_tm e (tm_neg t)\"\n by sorry\nlemmas [simp del] = tm_neg.simps\n\nlemma tm_bound_tm_add[simp]: \"tm_bound (tm_add t1 t2) = tm_bound t1 + tm_bound t2\"\n by sorry\n\nlemma interval_of_add: \"interval_of (a + b) = interval_of a + interval_of b\"\n by sorry\n\nlemma tm_add_range:\n \"x + y \\\\<^sub>i range_tm e (tm_add t1 t2)\"\n if \"x \\\\<^sub>i range_tm e t1\"\n \"y \\\\<^sub>i range_tm e t2\"\n by sorry\nlemmas [simp del] = tm_add.simps\n\nlemma tm_sub_range:\n assumes \"x \\\\<^sub>i range_tm e t1\"\n assumes \"y \\\\<^sub>i range_tm e t2\"\n shows \"x - y \\\\<^sub>i range_tm e (tm_sub t1 t2)\"\n by sorry\nlemmas [simp del] = tm_sub.simps\n\nlemma set_of_intervalI: \"set_of (interval_of y) \\ set_of Y\" if \"y \\\\<^sub>i Y\" for y::\"'a::order\"\n by sorry\n\nlemma set_of_real_intervalI: \"set_of (interval_of y) \\ set_of (real_interval Y)\" if \"y \\\\<^sub>r Y\"\n by sorry\n\nlemma tm_mul_range:\n assumes \"x \\\\<^sub>i range_tm e t1\"\n assumes \"y \\\\<^sub>i range_tm e t2\"\n assumes dev: \"develops_at_within e a I\"\n assumes params: \"num_params (tm_poly t1) \\ length I\" \"num_params (tm_poly t2) \\ length I\"\n shows \"x * y \\\\<^sub>i range_tm e (tm_mul prec ord I a t1 t2)\"\n by sorry\n\nlemma num_params_tm_mul_le:\n \"num_params (tm_poly (tm_mul prec ord I a t1 t2)) \\ X\"\n if \"num_params (tm_poly t1) \\ X\"\n \"num_params (tm_poly t2) \\ X\"\n by sorry\n\nlemmas [simp del] = tm_pow.simps\\ \\TODO: make a systematic decision\\\n\nlemma\n shows tm_pow_range: \"num_params (tm_poly t) \\ length I \\\n develops_at_within e a I \\\n x \\\\<^sub>i range_tm e t \\\n x ^ n \\\\<^sub>i range_tm e (tm_pow prec ord I a t n)\"\n and num_params_tm_pow_le[THEN order_trans]:\n \"num_params (tm_poly (tm_pow prec ord I a t n)) \\ num_params (tm_poly t)\"\n by sorry\n\nlemma num_params_tm_add_le:\n \"num_params (tm_poly (tm_add t1 t2)) \\ X\"\n if \"num_params (tm_poly t1) \\ X\"\n \"num_params (tm_poly t2) \\ X\"\n by sorry\n\nlemma num_params_tm_neg_eq[simp]:\n \"num_params (tm_poly (tm_neg t1)) = num_params (tm_poly t1)\"\n by sorry\n\nlemma num_params_tm_sub_le:\n \"num_params (tm_poly (tm_sub t1 t2)) \\ X\"\n if \"num_params (tm_poly t1) \\ X\"\n \"num_params (tm_poly t2) \\ X\"\n by sorry\n\nlemma num_params_eval_poly_le: \"num_params (tm_poly (eval_poly_at_tm prec ord I a p t)) \\ x\"\n if \"num_params (tm_poly t) \\ x\" \"num_params p \\ max 1 x\"\n by sorry\n\nlemma eval_poly_at_tm_range:\n assumes \"num_params p \\ 1\"\n assumes tg_def: \"e' 0 \\\\<^sub>i range_tm e tg\"\n assumes dev: \"develops_at_within e a I\" and params: \"num_params (tm_poly tg) \\ length I\"\n shows \"insertion e' p \\\\<^sub>i range_tm e (eval_poly_at_tm prec ord I a p tg)\"\n by sorry\n\nlemma tm_inc_err_range: \"x \\\\<^sub>i range_tm e (tm_inc_err i t)\"\n if \"x \\\\<^sub>i range_tm e t + real_interval i\"\n by sorry\n\nlemma num_params_tm_inc_err: \"num_params (tm_poly (tm_inc_err i t)) \\ X\"\n if \"num_params (tm_poly t) \\ X\"\n by sorry\n\nlemma num_params_tm_comp_le: \"num_params (tm_poly (tm_comp prec ord I a ga tf tg)) \\ X\"\n if \"num_params (tm_poly tf) \\ max 1 X\" \"num_params (tm_poly tg) \\ X\"\n by sorry\n\nlemma tm_comp_range:\n assumes tf_def: \"x \\\\<^sub>i range_tm e' tf\"\n assumes tg_def: \"e' 0 \\\\<^sub>i range_tm e (tm_sub tg (tm_const ga))\"\n assumes params: \"num_params (tm_poly tf) \\ 1\" \"num_params (tm_poly tg) \\ length I\"\n assumes dev: \"develops_at_within e a I\"\n shows \"x \\\\<^sub>i range_tm e (tm_comp prec ord I a ga tf tg)\"\n by sorry\n\nlemma mid_centered_collapse:\n \"interval_of (real_of_float (mid abs_bound)) + real_interval (centered abs_bound) =\n real_interval abs_bound\"\n by sorry\n\nlemmas [simp del] = tm_abs.simps\nlemma tm_abs_range:\n assumes x: \"x \\\\<^sub>i range_tm e t\"\n assumes n: \"num_params (tm_poly t) \\ length I\" and d: \"develops_at_within e a I\"\n shows \"abs x \\\\<^sub>i range_tm e (tm_abs prec I a t)\"\n by sorry\n\nlemma num_params_tm_abs_le: \"num_params (tm_poly (tm_abs prec I a t)) \\ X\" if \"num_params (tm_poly t) \\ X\"\n by sorry\n\nlemma real_interval_sup: \"real_interval (sup a b) = sup (real_interval a) (real_interval b)\"\n by sorry\n\nlemma in_interval_supI1: \"x \\\\<^sub>i a \\ x \\\\<^sub>i sup a b\"\n and in_interval_supI2: \"x \\\\<^sub>i b \\ x \\\\<^sub>i sup a b\"\n for x::\"'a::lattice\"\n by sorry\n \nlemma tm_union_range_left:\n assumes \"x \\\\<^sub>i range_tm e t1\"\n \"num_params (tm_poly t1) \\ length I\" \"develops_at_within e a I\"\n shows \"x \\\\<^sub>i range_tm e (tm_union prec I a t1 t2)\"\n by sorry\n\nlemma tm_union_range_right:\n assumes \"x \\\\<^sub>i range_tm e t2\"\n \"num_params (tm_poly t2) \\ length I\" \"develops_at_within e a I\"\n shows \"x \\\\<^sub>i range_tm e (tm_union prec I a t1 t2)\"\n by sorry\n\nlemma num_params_tm_union_le:\n \"num_params (tm_poly (tm_union prec I a t1 t2)) \\ X\"\n if \"num_params (tm_poly t1) \\ X\" \"num_params (tm_poly t2) \\ X\"\n by sorry\n \nlemmas [simp del] = tm_union.simps tm_min.simps tm_max.simps\n\nlemma tm_min_range:\n assumes \"x \\\\<^sub>i range_tm e t1\"\n assumes \"y \\\\<^sub>i range_tm e t2\"\n \"num_params (tm_poly t1) \\ length I\"\n \"num_params (tm_poly t2) \\ length I\"\n \"develops_at_within e a I\"\n shows \"min x y \\\\<^sub>i range_tm e (tm_min prec I a t1 t2)\"\n by sorry\n\nlemma tm_max_range:\n assumes \"x \\\\<^sub>i range_tm e t1\"\n assumes \"y \\\\<^sub>i range_tm e t2\"\n \"num_params (tm_poly t1) \\ length I\"\n \"num_params (tm_poly t2) \\ length I\"\n \"develops_at_within e a I\"\n shows \"max x y \\\\<^sub>i range_tm e (tm_max prec I a t1 t2)\"\n by sorry\n\nsubsection \\Computing Taylor models for multivariate expressions\\\n\ntext \\Compute Taylor models for expressions of the form \"f (g x)\", where f is an elementary function like exp or cos,\n by composing Taylor models for f and g. For our correctness proof, we need to make it explicit that the range\n of g on I is inside the domain of f, by introducing the \\f_exists_on\\ predicate.\\\nfun compute_tm_by_comp :: \"nat \\ nat \\ float interval list \\ float interval list \\ floatarith \\ taylor_model option \\ (float interval \\ bool) \\ taylor_model option\"\n where \"compute_tm_by_comp prec ord I a f g f_exists_on = (\n case g\n of Some tg \\ (\n let gI = compute_bound_tm prec I a tg;\n ga = mid (compute_bound_tm prec a a tg)\n in if f_exists_on gI\n then map_option (\\tf. tm_comp prec ord I a ga tf tg ) (tm_floatarith prec ord [gI] [ga] f)\n else None)\n | _ \\ None\n )\"\n\ntext \\Compute Taylor models with numerical precision \\prec\\ of degree \\ord\\,\n with Taylor models in the environment \\env\\ whose variables are jointly interpreted with domain\n \\I\\ and expanded around point \\a\\.\n from floatarith expressions on a rectangular domain.\\\nfun approx_tm :: \"nat \\ nat \\ float interval list \\ float interval list \\ floatarith \\ taylor_model list \\\n taylor_model option\"\n where \"approx_tm _ _ I _ (Num c) env = Some (tm_const c)\"\n | \"approx_tm _ _ I a (Var n) env = (if n < length env then Some (env ! n) else None)\"\n | \"approx_tm prec ord I a (Add l r) env = (\n case (approx_tm prec ord I a l env, approx_tm prec ord I a r env) \n of (Some t1, Some t2) \\ Some (tm_add t1 t2)\n | _ \\ None)\"\n | \"approx_tm prec ord I a (Minus f) env\n = map_option tm_neg (approx_tm prec ord I a f env)\"\n | \"approx_tm prec ord I a (Mult l r) env = (\n case (approx_tm prec ord I a l env, approx_tm prec ord I a r env) \n of (Some t1, Some t2) \\ Some (tm_mul prec ord I a t1 t2)\n | _ \\ None)\" \n | \"approx_tm prec ord I a (Power f k) env\n = map_option (\\t. tm_pow prec ord I a t k)\n (approx_tm prec ord I a f env)\"\n | \"approx_tm prec ord I a (Inverse f) env\n = compute_tm_by_comp prec ord I a (Inverse (Var 0)) (approx_tm prec ord I a f env) (\\x. 0 < lower x \\ upper x < 0)\"\n | \"approx_tm prec ord I a (Cos f) env\n = compute_tm_by_comp prec ord I a (Cos (Var 0)) (approx_tm prec ord I a f env) (\\x. True)\"\n | \"approx_tm prec ord I a (Arctan f) env\n = compute_tm_by_comp prec ord I a (Arctan (Var 0)) (approx_tm prec ord I a f env) (\\x. True)\"\n | \"approx_tm prec ord I a (Exp f) env\n = compute_tm_by_comp prec ord I a (Exp (Var 0)) (approx_tm prec ord I a f env) (\\x. True)\"\n | \"approx_tm prec ord I a (Ln f) env\n = compute_tm_by_comp prec ord I a (Ln (Var 0)) (approx_tm prec ord I a f env) (\\x. 0 < lower x)\"\n | \"approx_tm prec ord I a (Sqrt f) env\n = compute_tm_by_comp prec ord I a (Sqrt (Var 0)) (approx_tm prec ord I a f env) (\\x. 0 < lower x)\"\n | \"approx_tm prec ord I a Pi env = Some (tm_pi prec)\"\n | \"approx_tm prec ord I a (Abs f) env\n = map_option (tm_abs prec I a) (approx_tm prec ord I a f env)\"\n | \"approx_tm prec ord I a (Min l r) env = (\n case (approx_tm prec ord I a l env, approx_tm prec ord I a r env) \n of (Some t1, Some t2) \\ Some (tm_min prec I a t1 t2)\n | _ \\ None)\"\n | \"approx_tm prec ord I a (Max l r) env = (\n case (approx_tm prec ord I a l env, approx_tm prec ord I a r env)\n of (Some t1, Some t2) \\ Some (tm_max prec I a t1 t2)\n | _ \\ None)\"\n | \"approx_tm prec ord I a (Powr l r) env = None\" \\ \\TODO\\\n | \"approx_tm prec ord I a (Floor l) env = None\" \\ \\TODO\\\n\nlemma mid_in_real_interval: \"mid i \\\\<^sub>r i\"\n by sorry\n\nlemma set_of_real_interval_mono:\"set_of (real_interval x) \\ set_of (real_interval y)\"\n if \"set_of x \\ set_of y\"\n by sorry\n\nlemmas [simp del] = compute_bound_poly.simps tm_floatarith.simps\n\nlemmas [simp del] = tmf_ivl_cs.simps compute_bound_tm.simps tmf_polys.simps\n\nlemma tm_floatarith_eq_Some_num_params:\n \"tm_floatarith prec ord a b f = Some tf \\ num_params (tm_poly tf) \\ 1\"\n by sorry\n\nlemma compute_tm_by_comp_range:\n assumes \"max_Var_floatarith f \\ 1\"\n assumes a: \"a all_subset I\"\n assumes tx_range: \"x \\\\<^sub>i range_tm e tg\"\n assumes t_def: \"compute_tm_by_comp prec ord I a f (Some tg) c = Some t\"\n assumes f_deriv:\n \"\\x. x \\\\<^sub>r compute_bound_tm prec I a tg \\ c (compute_bound_tm prec I a tg) \\ isDERIV 0 f [x]\"\n assumes params: \"num_params (tm_poly tg) \\ length I\"\n and dev: \"develops_at_within e a I\"\n shows \"interpret_floatarith f [x] \\\\<^sub>i range_tm e t\"\n by sorry\n\nlemmas [simp del] = compute_tm_by_comp.simps\n\nlemma compute_tm_by_comp_num_params_le:\n assumes \"compute_tm_by_comp prec ord I a f (Some t0) i = Some t\"\n assumes \"1 \\ X\" \"num_params (tm_poly t0) \\ X\"\n shows \"num_params (tm_poly t) \\ X\"\n by sorry\n\nlemma compute_tm_by_comp_eq_Some_iff: \"compute_tm_by_comp prec ord I a f t0 i = Some t \\\n (\\z x2. t0 = Some x2 \\\n tm_floatarith prec ord [compute_bound_tm prec I a x2]\n [mid (compute_bound_tm prec a a x2)] f =\n Some z\n \\ tm_comp prec ord I a\n (mid (compute_bound_tm prec a a x2)) z x2 = t\n \\ i (compute_bound_tm prec I a x2))\"\n by sorry\n\nlemma num_params_approx_tm:\n assumes \"approx_tm prec ord I a f env = Some t\"\n assumes \"\\tm. tm \\ set env \\ num_params (tm_poly tm) \\ length I\"\n shows \"num_params (tm_poly t) \\ length I\"\n by sorry\n\nlemma in_interval_realI: \"a \\\\<^sub>i I\" if \"a \\\\<^sub>r I\" using that by (auto simp: set_of_eq)\n\nlemma all_subset_all_inI: \"map interval_of a all_subset I\" if \"a all_in I\"\n by sorry\n\nlemma compute_tm_by_comp_None: \"compute_tm_by_comp p ord I a x None k = None\"\n by sorry\n\nlemma approx_tm_num_Vars_None:\n assumes \"max_Var_floatarith f > length env\"\n shows \"approx_tm p ord I a f env = None\"\n by sorry\n\nlemma approx_tm_num_Vars:\n assumes \"approx_tm prec ord I a f env = Some t\"\n shows \"max_Var_floatarith f \\ length env\"\n by sorry\n\ndefinition \"range_tms e xs = map (range_tm e) xs\"\n\nlemma approx_tm_range:\n assumes a: \"a all_subset I\"\n assumes t_def: \"approx_tm prec ord I a f env = Some t\"\n assumes allin: \"xs all_in\\<^sub>i range_tms e env\"\n assumes devs: \"develops_at_within e a I\"\n assumes env: \"\\tm. tm \\ set env \\ num_params (tm_poly tm) \\ length I\"\n shows \"interpret_floatarith f xs \\\\<^sub>i range_tm e t\"\n by sorry\n\ntext \\Evaluate expression with Taylor models in environment.\\\n\nsubsection \\Computing bounds for floatarith expressions\\\n\ntext \\TODO: compare parametrization of input vs. uncertainty for input...\\\n\ndefinition \"tm_of_ivl_par n ivl = TaylorModel (CN (C ((upper ivl + lower ivl)*Float 1 (-1))) n\n (C ((upper ivl - lower ivl)*Float 1 (-1)))) 0\"\n \\ \\track uncertainty in parameter \\n\\, which is to be interpreted over standardized domain \\[-1, 1]\\.\\\n\nvalue \"tm_of_ivl_par 3 (Ivl (-1) 1)\"\n\ndefinition \"tms_of_ivls ivls = map (\\(i, ivl). tm_of_ivl_par i ivl) (zip [0.. nat \\ float interval list \\ float interval list \\ slp \\\n taylor_model list \\ taylor_model list option\"\nwhere\n \"approx_slp' p ord I a [] xs = Some xs\"\n| \"approx_slp' p ord I a (ea # eas) xs =\n do {\n r \\ approx_tm p ord I a ea xs;\n approx_slp' p ord I a eas (r#xs)\n }\"\n\nlemma mem_range_tms_Cons_iff[simp]: \"x#xs all_in\\<^sub>i range_tms e (X#XS) \\ x \\\\<^sub>i range_tm e X \\ xs all_in\\<^sub>i range_tms e XS\"\n by sorry\n\nlemma approx_slp'_range:\n assumes i: \"i all_subset I\"\n assumes dev: \"develops_at_within e i I\"\n assumes vs: \"vs all_in\\<^sub>i range_tms e VS\" \"(\\tm. tm \\ set VS \\ num_params (tm_poly tm) \\ length I)\"\n assumes appr: \"approx_slp' p ord I i ra VS = Some X\"\n shows \"interpret_slp ra vs all_in\\<^sub>i range_tms e X\"\n by sorry\n\ndefinition approx_slp::\"nat \\ nat \\ nat \\ slp \\ taylor_model list \\ taylor_model list option\"\n where\n \"approx_slp p ord d slp tms =\n map_option (take d)\n (approx_slp' p ord (replicate (length tms) (Ivl (-1) 1)) (replicate (length tms) 0) slp tms)\"\n\nlemma length_range_tms[simp]: \"length (range_tms e VS) = length VS\"\n by sorry\n\nlemma set_of_Ivl: \"set_of (Ivl a b) = {a .. b}\" if \"a \\ b\"\n by sorry\n\nlemma set_of_zero[simp]: \"set_of 0 = {0::'a::ordered_comm_monoid_add}\"\n by sorry\n\ntheorem approx_slp_range_tms:\n assumes \"approx_slp p ord d slp VS = Some X\"\n assumes slp_def: \"slp = slp_of_fas fas\"\n assumes d_def: \"d = length fas\"\n assumes e: \"e \\ UNIV \\ {-1 .. 1}\"\n assumes vs: \"vs all_in\\<^sub>i range_tms e VS\"\n assumes lens: \"\\tm. tm \\ set VS \\ num_params (tm_poly tm) \\ length vs\"\n shows \"interpret_floatariths fas vs all_in\\<^sub>i range_tms e X\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 35, "title": "035_taylor_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2022 Moritz Doll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Moritz Doll\n-/\nmodule\n\npublic import Mathlib.Algebra.Polynomial.Module.Basic\npublic import Mathlib.Analysis.Calculus.ContDiff.Operations\npublic import Mathlib.Analysis.Calculus.Deriv.MeanValue\npublic import Mathlib.Analysis.Calculus.Deriv.Pow\npublic import Mathlib.Analysis.Calculus.IteratedDeriv.Defs\npublic import Mathlib.MeasureTheory.Integral.IntervalIntegral.AbsolutelyContinuousFun\npublic import Mathlib.MeasureTheory.Integral.IntervalIntegral.IntegrationByParts\n\n/-!\n# Taylor's theorem\n\nThis file defines the Taylor polynomial of a real function `f : ℝ → E`,\nwhere `E` is a normed vector space over `ℝ` and proves Taylor's theorem,\nwhich states that if `f` is sufficiently smooth, then\n`f` can be approximated by the Taylor polynomial up to an explicit error term.\n\n## Main definitions\n\n* `taylorCoeffWithin`: the Taylor coefficient using `iteratedDerivWithin`\n* `taylorWithin`: the Taylor polynomial using `iteratedDerivWithin`\n\n## Main statements\n\n* `taylor_tendsto`: Taylor's theorem as a limit\n* `taylor_isLittleO`: Taylor's theorem using little-o notation\n* `taylor_mean_remainder`: Taylor's theorem with the general form of the remainder term\n* `taylor_mean_remainder_lagrange`: Taylor's theorem with the Lagrange remainder\n* `taylor_mean_remainder_cauchy`: Taylor's theorem with the Cauchy remainder\n* `exists_taylor_mean_remainder_bound`: Taylor's theorem for vector-valued functions with a\n polynomial bound on the remainder\n* `taylor_integral_remainder_of_absolutelyContinuous`,\n `taylor_integral_remainder`: Taylor's theorem with the integral form of the\n remainder\n\n## TODO\n\n* Generalization to higher dimensions\n\n## Tags\n\nTaylor polynomial, Taylor's theorem\n-/\n\n@[expose] public section\n\n\nopen scoped Interval Topology Nat\n\nopen Set\n\nvariable {𝕜 E F : Type*}\nvariable [NormedAddCommGroup E] [NormedSpace ℝ E]\n\n/-- The `k`th coefficient of the Taylor polynomial. -/\nnoncomputable def taylorCoeffWithin (f : ℝ → E) (k : ℕ) (s : Set ℝ) (x₀ : ℝ) : E :=\n (k ! : ℝ)⁻¹ • iteratedDerivWithin k f s x₀\n\n/-- The Taylor polynomial with derivatives inside of a set `s`.\n\nThe Taylor polynomial is given by\n$$∑_{k=0}^n \\frac{(x - x₀)^k}{k!} f^{(k)}(x₀),$$\nwhere $f^{(k)}(x₀)$ denotes the iterated derivative in the set `s`. -/\nnoncomputable def taylorWithin (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) : PolynomialModule ℝ E :=\n (Finset.range (n + 1)).sum fun k =>\n PolynomialModule.comp (Polynomial.X - Polynomial.C x₀)\n (PolynomialModule.single ℝ k (taylorCoeffWithin f k s x₀))\n\n/-- The Taylor polynomial with derivatives inside of a set `s` considered as a function `ℝ → E` -/\nnoncomputable def taylorWithinEval (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) : E :=\n PolynomialModule.eval x (taylorWithin f n s x₀)\n\ntheorem taylorWithin_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) :\n taylorWithin f (n + 1) s x₀ = taylorWithin f n s x₀ +\n PolynomialModule.comp (Polynomial.X - Polynomial.C x₀)\n (PolynomialModule.single ℝ (n + 1) (taylorCoeffWithin f (n + 1) s x₀)) := by sorry\ntheorem taylorWithinEval_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) :\n taylorWithinEval f (n + 1) s x₀ x = taylorWithinEval f n s x₀ x +\n (((n + 1 : ℝ) * n !)⁻¹ * (x - x₀) ^ (n + 1)) • iteratedDerivWithin (n + 1) f s x₀ := by sorry\ntheorem taylor_within_zero_eval (f : ℝ → E) (s : Set ℝ) (x₀ x : ℝ) :\n taylorWithinEval f 0 s x₀ x = f x₀ := by sorry\ntheorem taylorWithinEval_self (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) :\n taylorWithinEval f n s x₀ x₀ = f x₀ := by sorry\ntheorem taylor_within_apply (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) :\n taylorWithinEval f n s x₀ x =\n ∑ k ∈ Finset.range (n + 1), ((k ! : ℝ)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀ := by sorry\ntheorem continuousOn_taylorWithinEval {f : ℝ → E} {x : ℝ} {n : ℕ} {s : Set ℝ}\n (hs : UniqueDiffOn ℝ s) (hf : ContDiffOn ℝ n f s) :\n ContinuousOn (fun t => taylorWithinEval f n s t x) s := by sorry\ntheorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) :\n HasDerivAt (fun y => (x - y) ^ (n + 1)) (-(n + 1) * (x - t) ^ n) t := by sorry\ntheorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k : ℕ} {s t : Set ℝ}\n (ht : UniqueDiffWithinAt ℝ t y) (hs : s ∈ 𝓝[t] y)\n (hf : DifferentiableWithinAt ℝ (iteratedDerivWithin (k + 1) f s) s y) :\n HasDerivWithinAt\n (fun z => (((k + 1 : ℝ) * k !)⁻¹ * (x - z) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s z)\n ((((k + 1 : ℝ) * k !)⁻¹ * (x - y) ^ (k + 1)) • iteratedDerivWithin (k + 2) f s y -\n ((k ! : ℝ)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y) t y := by sorry\ntheorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ} {s s' : Set ℝ}\n (hs_unique : UniqueDiffOn ℝ s) (hs' : s' ∈ 𝓝[s] y)\n (hy : y ∈ s') (h : s' ⊆ s) (hf : ContDiffOn ℝ n f s)\n (hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y) :\n HasDerivWithinAt (fun t => taylorWithinEval f n s t x)\n (((n ! : ℝ)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f s y) s' y := by sorry\ntheorem taylorWithinEval_hasDerivAt_Ioo {f : ℝ → E} {a b t : ℝ} (x : ℝ) {n : ℕ} (hx : a < b)\n (ht : t ∈ Ioo a b) (hf : ContDiffOn ℝ n f (Icc a b))\n (hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Ioo a b)) :\n HasDerivAt (fun y => taylorWithinEval f n (Icc a b) y x)\n (((n ! : ℝ)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) t :=\n have h_nhds : Ioo a b ∈ 𝓝 t := isOpen_Ioo.mem_nhds ht\n have h_nhds' : Ioo a b ∈ 𝓝[Icc a b] t := nhdsWithin_le_nhds h_nhds\n (hasDerivWithinAt_taylorWithinEval (uniqueDiffOn_Icc hx) h_nhds' ht\n Ioo_subset_Icc_self hf <| (hf' t ht).mono_of_mem_nhdsWithin h_nhds').hasDerivAt h_nhds\n\n/-- Calculate the derivative of the Taylor polynomial with respect to `x₀`.\n\nVersion for closed intervals -/\ntheorem hasDerivWithinAt_taylorWithinEval_at_Icc {f : ℝ → E} {a b t : ℝ} (x : ℝ) {n : ℕ}\n (hx : a < b) (ht : t ∈ Icc a b) (hf : ContDiffOn ℝ n f (Icc a b))\n (hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)) :\n HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)\n (((n ! : ℝ)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a b) t :=\n hasDerivWithinAt_taylorWithinEval (uniqueDiffOn_Icc hx)\n self_mem_nhdsWithin ht rfl.subset hf (hf' t ht)\n\n/-- Calculate the derivative of the Taylor polynomial with respect to `x`. -/\ntheorem hasDerivAt_taylorWithinEval_succ {x₀ x : ℝ} {s : Set ℝ} (f : ℝ → E) (n : ℕ) :\n HasDerivAt (taylorWithinEval f (n + 1) s x₀)\n (taylorWithinEval (derivWithin f s) n s x₀ x) x := by sorry\ntheorem taylor_isLittleO {f : ℝ → E} {x₀ : ℝ} {n : ℕ} {s : Set ℝ}\n (hs : Convex ℝ s) (hx₀s : x₀ ∈ s) (hf : ContDiffOn ℝ n f s) :\n (fun x ↦ f x - taylorWithinEval f n s x₀ x) =o[𝓝[s] x₀] fun x ↦ (x - x₀) ^ n := by sorry\ntheorem taylor_isLittleO_univ {f : ℝ → E} {x₀ : ℝ} {n : ℕ} (hf : ContDiff ℝ n f) :\n (fun x ↦ f x - taylorWithinEval f n univ x₀ x) =o[𝓝 x₀] fun x ↦ (x - x₀) ^ n := by sorry\ntheorem taylor_tendsto {f : ℝ → E} {x₀ : ℝ} {n : ℕ} {s : Set ℝ}\n (hs : Convex ℝ s) (hx₀s : x₀ ∈ s) (hf : ContDiffOn ℝ n f s) :\n Filter.Tendsto (fun x ↦ ((x - x₀) ^ n)⁻¹ • (f x - taylorWithinEval f n s x₀ x))\n (𝓝[s] x₀) (𝓝 0) := by sorry\ntheorem Real.taylor_tendsto {f : ℝ → ℝ} {x₀ : ℝ} {n : ℕ} {s : Set ℝ}\n (hs : Convex ℝ s) (hx₀s : x₀ ∈ s) (hf : ContDiffOn ℝ n f s) :\n Filter.Tendsto (fun x ↦ (f x - taylorWithinEval f n s x₀ x) / (x - x₀) ^ n)\n (𝓝[s] x₀) (𝓝 0) := by sorry\ntheorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ ≠ x)\n (hf : ContDiffOn ℝ n f (uIcc x₀ x))\n (hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (uIcc x₀ x)) (uIoo x₀ x))\n (gcont : ContinuousOn g (uIcc x₀ x))\n (gdiff : ∀ x_1 : ℝ, x_1 ∈ uIoo x₀ x → HasDerivAt g (g' x_1) x_1)\n (g'_ne : ∀ x_1 : ℝ, x_1 ∈ uIoo x₀ x → g' x_1 ≠ 0) :\n ∃ x' ∈ uIoo x₀ x, f x - taylorWithinEval f n (uIcc x₀ x) x₀ x = ((x - x') ^ n / n ! *\n (g x - g x₀) / g' x') • iteratedDerivWithin (n + 1) f (uIcc x₀ x) x' := by sorry\ntheorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ ≠ x)\n (hf : ContDiffOn ℝ n f (uIcc x₀ x))\n (hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (uIcc x₀ x)) (uIoo x₀ x)) :\n ∃ x' ∈ uIoo x₀ x, f x - taylorWithinEval f n (uIcc x₀ x) x₀ x =\n iteratedDerivWithin (n + 1) f (uIcc x₀ x) x' * (x - x₀) ^ (n + 1) / (n + 1)! := by sorry\nlemma taylor_mean_remainder_lagrange_iteratedDeriv {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ ≠ x)\n (hf : ContDiffOn ℝ (n + 1) f (uIcc x₀ x)) :\n ∃ x' ∈ uIoo x₀ x, f x - taylorWithinEval f n (uIcc x₀ x) x₀ x =\n iteratedDeriv (n + 1) f x' * (x - x₀) ^ (n + 1) / (n + 1)! := by sorry\ntheorem taylor_mean_remainder_cauchy {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ ≠ x)\n (hf : ContDiffOn ℝ n f (uIcc x₀ x))\n (hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (uIcc x₀ x)) (uIoo x₀ x)) :\n ∃ x' ∈ uIoo x₀ x, f x - taylorWithinEval f n (uIcc x₀ x) x₀ x =\n iteratedDerivWithin (n + 1) f (uIcc x₀ x) x' * (x - x') ^ n / n ! * (x - x₀) := by sorry\ntheorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (hab : a ≤ b)\n (hf : ContDiffOn ℝ (n + 1) f (Icc a b)) (hx : x ∈ Icc a b)\n (hC : ∀ y ∈ Icc a b, ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C) :\n ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / n ! := by sorry\ntheorem exists_taylor_mean_remainder_bound {f : ℝ → E} {a b : ℝ} {n : ℕ} (hab : a ≤ b)\n (hf : ContDiffOn ℝ (n + 1) f (Icc a b)) :\n ∃ C, ∀ x ∈ Icc a b, ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) := by sorry\ntheorem taylor_integral_remainder_aux [NormedAddCommGroup F] [NormedSpace ℝ F]\n {f : ℝ → F} {x x₀ : ℝ} {n : ℕ}\n (hf : ∀ k ≤ n, let u := fun t ↦ (x - t) ^ k / k !;\n let v := fun t ↦ iteratedDerivWithin k f [[x₀, x]] t;\n ∫ (t : ℝ) in x₀..x, u t • deriv v t = u x • v x - u x₀ • v x₀ -\n ∫ (t : ℝ) in x₀..x, deriv u t • v t) :\n f x - taylorWithinEval f n (uIcc x₀ x) x₀ x =\n ∫ t in x₀..x, ((x - t) ^ n / n !) • iteratedDerivWithin (n + 1) f (uIcc x₀ x) t := by sorry\ntheorem taylor_integral_remainder_of_absolutelyContinuous {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ}\n (hf₁ : ContDiffOn ℝ n f (uIcc x₀ x))\n (hf₂ : AbsolutelyContinuousOnInterval (iteratedDerivWithin n f (uIcc x₀ x)) x₀ x) :\n f x - taylorWithinEval f n (uIcc x₀ x) x₀ x =\n ∫ t in x₀..x, ((x - t) ^ n / n !) * iteratedDerivWithin (n + 1) f (uIcc x₀ x) t := by sorry\ntheorem taylor_integral_remainder [NormedAddCommGroup F] [NormedSpace ℝ F]\n [CompleteSpace F] {f : ℝ → F} {x x₀ : ℝ} {n : ℕ}\n (hf : ContDiffOn ℝ (n + 1 : ℕ) f (uIcc x₀ x)) :\n f x - taylorWithinEval f n (uIcc x₀ x) x₀ x =\n ∫ t in x₀..x, ((x - t) ^ n / n !) • iteratedDerivWithin (n + 1) f (uIcc x₀ x) t := by sorry\n" }, { "theorem_id": 35, "title": "035_taylor_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Export CoRN.ftc.TaylorLemma.\n\nOpaque Min Max N_Deriv.\n\nSection More_Taylor_Defs.\n\nVariable I : interval.\nHypothesis pI : proper I.\n\nVariable F : PartIR.\n\nLet deriv_Sn b n Hf :=\n N_Deriv _ pI (S n) F Hf{*} [-C-] ([1][/] _[//]nring_fac_ap_zero _ n) {*} ( [-C-]b{-}FId) {^}n.\n\nVariables a b : IR.\nHypothesis Ha : I a.\nHypothesis Hb : I b.\n\nLet fi n Hf i Hi :=\n N_Deriv _ pI _ _ (le_imp_Diffble_n _ _ _ _ (proj1 (Nat.lt_succ_r i n) Hi) F Hf).\n\nLet funct_i n Hf i Hi :=\n [-C-] (fi n Hf i Hi a Ha[/] _[//]nring_fac_ap_zero _ i) {*} (FId{-} [-C-]a) {^}i.\n\nDefinition Taylor_Seq' n Hf := FSumx _ (funct_i n Hf).\n\nLemma TaylorB : forall n Hf, Dom (Taylor_Seq' n Hf) b.\nProof.\nAdmitted.\n\nDefinition Taylor_Rem n Hf := F b (Diffble_n_imp_inc _ _ _ _ Hf b Hb) [-]\n Taylor_Seq' n Hf b (TaylorB n Hf).\n\nLemma Taylor_Sumx_lemma : forall n x z y y', (forall H, y 0 H [=] z) ->\n (forall i H H', y' i H' [=] y (S i) H) ->\n x[-]Sumx (G:=IR) (n:=S n) y [=] x[-]z[-]Sumx (G:=IR) (n:=n) y'.\nProof.\nAdmitted.\n\nLemma Taylor_lemma_ap : forall n Hf Hf' Ha',\n Taylor_Rem n Hf'[-]deriv_Sn b n Hf a Ha'[*] (b[-]a) [#] [0] -> a [#] b.\nProof.\nAdmitted.\n\nTheorem Taylor' : forall n Hf Hf' e, [0] [<] e -> {c : IR | Compact (Min_leEq_Max a b) c |\n forall Hc, AbsIR (Taylor_Rem n Hf'[-]deriv_Sn b n Hf c Hc[*] (b[-]a)) [<=] e}.\nProof.\nAdmitted.\n\nEnd More_Taylor_Defs.\n\nSection Taylor_Theorem.\n\nVariable I : interval.\nHypothesis pI : proper I.\n\nVariable F : PartIR.\n\nVariable n : nat.\nVariable f : forall i : nat, i < S n -> PartIR.\n\nHypothesis goodF : ext_fun_seq f.\nHypothesis goodF' : ext_fun_seq' f.\n\nHypothesis derF : forall i Hi, Derivative_n i I pI F (f i Hi).\n\nVariable F' : PartIR.\nHypothesis derF' : Derivative_n (S n) I pI F F'.\n\nVariables a b : IR.\nHypothesis Ha : I a.\nHypothesis Hb : I b.\n\nLet funct_i i Hi := let HX := (Derivative_n_imp_inc' _ _ _ _ _ (derF i Hi) a Ha) in\n[-C-] (f i Hi a HX [/] _[//] nring_fac_ap_zero _ i) {*} (FId{-} [-C-]a) {^}i.\n\nDefinition Taylor_Seq := FSumx _ funct_i.\n\nLet deriv_Sn := F'{*} [-C-] ([1][/] _[//]nring_fac_ap_zero _ n) {*} ( [-C-]b{-}FId) {^}n.\n\nLemma Taylor_aux : Dom Taylor_Seq b.\nProof.\nAdmitted.\n\nTheorem Taylor : forall e, [0] [<] e -> forall Hb', {c : IR | Compact (Min_leEq_Max a b) c |\n forall Hc, AbsIR (F b Hb'[-]Part _ _ Taylor_aux[-]deriv_Sn c Hc[*] (b[-]a)) [<=] e}.\nProof.\nAdmitted.\n\nEnd Taylor_Theorem." }, { "theorem_id": 36, "title": "037_the_solution_of_a_cubic", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Complex/complex_transc.ml\";;\n\nprioritize_complex();;\n\nlet ccbrt = new_definition\n `ccbrt(z) = if z = Cx(&0) then Cx(&0) else cexp(clog(z) / Cx(&3))`;;\n\nlet CCBRT = `!z. ccbrt(z) pow 3 = z`;;\n\nlet CUBIC_REDUCTION = COMPLEX_FIELD\n `~(a = Cx(&0)) /\\\n x = y - b / (Cx(&3) * a) /\\\n p = (Cx(&3) * a * c - b pow 2) / (Cx(&9) * a pow 2) /\\\n q = (Cx(&9) * a * b * c - Cx(&2) * b pow 3 - Cx(&27) * a pow 2 * d) /\n (Cx(&54) * a pow 3)\n ==> (a * x pow 3 + b * x pow 2 + c * x + d = Cx(&0) <=>\n y pow 3 + Cx(&3) * p * y - Cx(&2) * q = Cx(&0))`;;\n\nlet CUBIC_BASIC = COMPLEX_FIELD\n `!i t s.\n s pow 2 = q pow 2 + p pow 3 /\\\n (s1 pow 3 = if p = Cx(&0) then Cx(&2) * q else q + s) /\\\n s2 = --s1 * (Cx(&1) + i * t) / Cx(&2) /\\\n s3 = --s1 * (Cx(&1) - i * t) / Cx(&2) /\\\n i pow 2 + Cx(&1) = Cx(&0) /\\\n t pow 2 = Cx(&3)\n ==> if p = Cx(&0) then\n (y pow 3 + Cx(&3) * p * y - Cx(&2) * q = Cx(&0) <=>\n y = s1 \\/ y = s2 \\/ y = s3)\n else\n ~(s1 = Cx(&0)) /\\\n (y pow 3 + Cx(&3) * p * y - Cx(&2) * q = Cx(&0) <=>\n (y = s1 - p / s1 \\/ y = s2 - p / s2 \\/ y = s3 - p / s3))`;;\n\nlet CUBIC = `~(a = Cx(&0))\n ==> let p = (Cx(&3) * a * c - b pow 2) / (Cx(&9) * a pow 2)\n and q = (Cx(&9) * a * b * c - Cx(&2) * b pow 3 - Cx(&27) * a pow 2 * d) /\n (Cx(&54) * a pow 3) in\n let s = csqrt(q pow 2 + p pow 3) in\n let s1 = if p = Cx(&0) then ccbrt(Cx(&2) * q) else ccbrt(q + s) in\n let s2 = --s1 * (Cx(&1) + ii * csqrt(Cx(&3))) / Cx(&2)\n and s3 = --s1 * (Cx(&1) - ii * csqrt(Cx(&3))) / Cx(&2) in\n if p = Cx(&0) then\n a * x pow 3 + b * x pow 2 + c * x + d = Cx(&0) <=>\n x = s1 - b / (Cx(&3) * a) \\/\n x = s2 - b / (Cx(&3) * a) \\/\n x = s3 - b / (Cx(&3) * a)\n else\n ~(s1 = Cx(&0)) /\\\n (a * x pow 3 + b * x pow 2 + c * x + d = Cx(&0) <=>\n x = s1 - p / s1 - b / (Cx(&3) * a) \\/\n x = s2 - p / s2 - b / (Cx(&3) * a) \\/\n x = s3 - p / s3 - b / (Cx(&3) * a))`;;" }, { "theorem_id": 36, "title": "037_the_solution_of_a_cubic", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Algorithms to compute all complex and real roots of a cubic polynomial\\\n\ntheory Cubic_Polynomials\n imports \n Cardanos_Formula\n Complex_Roots\nbegin\n\ntext \\The real case where a result is only delivered if the discriminant is negative\\\n\ndefinition solve_depressed_cubic_Cardano_real :: \"real \\ real \\ real option\" where\n \"solve_depressed_cubic_Cardano_real e f = (\n if e = 0 then Some (root 3 (-f)) else\n let v = - (e ^ 3 / 27) in\n case rroots2 [:v,f,1:] of \n [u,_] \\ let rt = root 3 u in Some (rt - e / (3 * rt))\n | _ \\ None)\" \n\nlemma solve_depressed_cubic_Cardano_real: \n assumes \"solve_depressed_cubic_Cardano_real e f = Some y\" \n shows \"{y. y^3 + e * y + f = 0} = {y}\"\n by sorry\n\ntext \\The complex case\\\n\ndefinition solve_depressed_cubic_complex :: \"complex \\ complex \\ complex list\" where\n \"solve_depressed_cubic_complex e f = (let\n ys = (if e = 0 then all_croots 3 (- f) else (let\n u = hd (croots2 [: - (e ^ 3 / 27) ,f,1:]); \n zs = all_croots 3 u \n in map (\\ z. z - e / (3 * z)) zs))\n in remdups ys)\" \n\nlemma solve_depressed_cubic_complex_code[code]: \n \"solve_depressed_cubic_complex e f = (let\n ys = (if e = 0 then all_croots 3 (- f) else (let\n f2 = f / 2;\n u = - f2 + csqrt (f2^2 + e ^ 3 / 27);\n zs = all_croots 3 u \n in map (\\ z. z - e / (3 * z)) zs))\n in remdups ys)\" \n by sorry\n\n\nlemma solve_depressed_cubic_complex: \"y \\ set (solve_depressed_cubic_complex e f) \n \\ (y^3 + e * y + f = 0)\"\n by sorry\n\ntext \\For the general real case, we first try Cardano with negative discrimiant and only if it is not applicable,\n then we go for the calculation using complex numbers. Note that for for non-negative delta \n no filter is required to identify the real roots from the list of complex roots, since in that case we \n already know that all roots are real.\\\ndefinition solve_depressed_cubic_real :: \"real \\ real \\ real list\" where\n \"solve_depressed_cubic_real e f = (case solve_depressed_cubic_Cardano_real e f \n of Some y \\ [y] \n | None \\ map Re (solve_depressed_cubic_complex (of_real e) (of_real f)))\"\n\nlemma solve_depressed_cubic_real_code[code]: \"solve_depressed_cubic_real e f =\n (if e = 0 then [root 3 (-f)] else \n let v = e ^ 3 / 27; \n f2 = f / 2;\n f2v = f2^2 + v in\n if f2v > 0 then \n let u = -f2 + sqrt f2v;\n rt = root 3 u\n in [rt - e / (3 * rt)]\n else \n let ce3 = of_real e / 3; \n u = - of_real f2 + csqrt (of_real f2v) in\n map Re (remdups (map (\\rt. rt - ce3 / rt) (all_croots 3 u))))\" \n by sorry\n\nlemma solve_depressed_cubic_real: \"y \\ set (solve_depressed_cubic_real e f) \n \\ (y^3 + e * y + f = 0)\" \n by sorry\n\ntext \\Combining the various algorithms\\\n\nlemma degree3_coeffs: \"degree p = 3 \\\n \\ a b c d. p = [: d, c, b, a :] \\ a \\ 0\"\n by sorry\n\ndefinition roots3_generic :: \"('a :: field_char_0 \\ 'a \\ 'a list) \\ 'a poly \\ 'a list\" where\n \"roots3_generic depressed_solver p = (let \n cs = coeffs p; \n a = cs ! 3; b = cs ! 2; c = cs ! 1; d = cs ! 0;\n a3 = 3 * a;\n ba3 = b / a3;\n b2 = b * b;\n b3 = b2 * b;\n e = (c - b2 / a3) / a;\n f = (d + 2 * b3 / (27 * a^2) - b * c / a3) / a;\n roots = depressed_solver e f\n in map (\\ y. y - ba3) roots)\" \n\nlemma roots3_generic: assumes deg: \"degree p = 3\" \n and solver: \"\\ e f y. y \\ set (depressed_solver e f) \\ y^3 + e * y + f = 0\" \n shows \"set (roots3_generic depressed_solver p) = {x. poly p x = 0}\" \n by sorry\n\ndefinition croots3 :: \"complex poly \\ complex list\" where\n \"croots3 = roots3_generic solve_depressed_cubic_complex\"\n\nlemma croots3: assumes deg: \"degree p = 3\" \n shows \"set (croots3 p) = { x. poly p x = 0}\" \n by sorry\n\ndefinition rroots3 :: \"real poly \\ real list\" where\n \"rroots3 = roots3_generic solve_depressed_cubic_real\"\n\nlemma rroots3: assumes deg: \"degree p = 3\" \n shows \"set (rroots3 p) = { x. poly p x = 0}\" \n by sorry\n\nend" }, { "theorem_id": 36, "title": "037_the_solution_of_a_cubic", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2022 Jeoff Lee. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeoff Lee, Thomas Zhu\n-/\nimport Mathlib.Tactic.LinearCombination\nimport Mathlib.RingTheory.Polynomial.Cyclotomic.Roots\n\n/-!\n# The roots of cubic and quartic polynomials\n\nThis file proves Theorem 37 and 46 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/).\n\nWe give the solutions to the cubic equation `a * x^3 + b * x^2 + c * x + d = 0` over a field `K`\nthat has characteristic neither 2 nor 3, that has a third primitive root of\nunity, and in which certain other quantities admit square and cube roots. This is based on the\n[Cardano's Formula](https://en.wikipedia.org/wiki/Cubic_equation#Cardano's_formula).\n\nWe also give solutions to the quartic equation `a * x^4 + b * x^3 + c * x^2 + d * x + e = 0` over\na field `K` that is not characteristic 2, and in which certain quantities admit square roots, in\nterms of a quantity that is a root of a particular cubic equation.\n\n## Main statements\n\n- `cubic_eq_zero_iff`: gives the roots of the cubic equation\n where the discriminant `p = 3 * a * c - b^2` is nonzero.\n- `cubic_eq_zero_iff_of_p_eq_zero`: gives the roots of the cubic equation\n where the discriminant equals zero.\n- `quartic_eq_zero_iff`: gives the roots of the quartic equation\n where the quantity `b^3 - 4 * a * b * c + 8 * a^2 * d` is nonzero, in terms of a root `u`\n to a cubic resolvent.\n- `quartic_eq_zero_iff_of_q_eq_zero`: gives the roots of the quartic equation\n where the quantity `b^3 - 4 * a * b * c + 8 * a^2 * d` equals zero.\n\n## Proof outline\n\nProofs of the cubic and quartic formulas are similar in outline.\n\nFor a cubic:\n1. Given cubic $ax^3 + bx^2 + cx + d = 0$, we show it is equivalent to some \"depressed cubic\"\n $y^3 + 3py - 2q = 0$ where $y = x + b / (3a)$, $p = (3ac - b^2) / (9a^2)$, and\n $q = (9abc - 2b^3 - 27a^2d) / (54a^3)$ (`h₁` in `cubic_eq_zero_iff`).\n2. When $p$ is zero, this is easily solved (`cubic_eq_zero_iff_of_p_eq_zero`).\n3. Otherwise one can directly derive a factorization of the depressed cubic, in terms of some\n primitive cube root of unity $\\omega^3 = 1$ (`cubic_depressed_eq_zero_iff`).\n\nSimilarly, for a quartic:\n1. Given quartic $ax^4 + bx^3 + cx^2 + dx + e = 0$, it is equivalent to some \"depressed quartic\"\n $y^4 + py^2 + qy + r = 0$ where $y = x + b / (4a)$, $p = (8ac - 3b^2) / (8a^2))$,\n $q = b^3 - 4abc + 8a^2d) / (8a^3))$, and $r = (16ab^2c + 256a^3e - 3b^4 - 64a^2bd) / (256a^4)$\n (`h₁` in `quartic_eq_zero_iff`).\n2. When $q$ is zero, this is easily solved as a quadratic in $y^2$\n (`quartic_eq_zero_iff_of_q_eq_zero`).\n3. Otherwise one can directly derive a factorization of the depressed quartic into two quadratics,\n in terms of some root of the *cubic resolvent* $u^3 - pu^2 - 4ru + 4pr - q^2 = 0$\n (`quartic_depressed_eq_zero_iff`).\n\n## References\n\nThe cubic formula was originally ported from Isabelle/HOL. The\n[original file](https://isabelle.in.tum.de/dist/library/HOL/HOL-ex/Cubic_Quartic.html) was written by Amine Chaieb.\n\nThe proof of the quartic formula is similar in structure to the cubic, and uses the formulation in\n[Zwillinger, *CRC Standard Mathematical Tables and Formulae*](zwillinger2003).\n\n## Tags\n\npolynomial, cubic, quartic, root\n-/\n\n\nnamespace Theorems100\n\nsection Field\n\nopen Polynomial\n\nvariable {K : Type*} [Field K] (a b c d e : K) {ω p q r s t u v w x y : K}\n\nsection Cubic\n\ntheorem cube_root_of_unity_sum (hω : IsPrimitiveRoot ω 3) : 1 + ω + ω ^ 2 = 0 := by sorry\ntheorem cubic_depressed_eq_zero_iff (hω : IsPrimitiveRoot ω 3) (hp_nonzero : p ≠ 0)\n (hr : r ^ 2 = q ^ 2 + p ^ 3) (hs3 : s ^ 3 = q + r) (ht : t * s = p) (x : K) :\n x ^ 3 + 3 * p * x - 2 * q = 0 ↔ x = s - t ∨ x = s * ω - t * ω ^ 2 ∨ x = s * ω ^ 2 - t * ω := by sorry\nvariable [Invertible (2 : K)] [Invertible (3 : K)]\n\n/-- **The Solution of Cubic**.\n The roots of a cubic polynomial whose discriminant is nonzero. -/\ntheorem cubic_eq_zero_iff (ha : a ≠ 0) (hω : IsPrimitiveRoot ω 3)\n (hp : p = (3 * a * c - b ^ 2) / (9 * a ^ 2)) (hp_nonzero : p ≠ 0)\n (hq : q = (9 * a * b * c - 2 * b ^ 3 - 27 * a ^ 2 * d) / (54 * a ^ 3))\n (hr : r ^ 2 = q ^ 2 + p ^ 3) (hs3 : s ^ 3 = q + r) (ht : t * s = p) (x : K) :\n a * x ^ 3 + b * x ^ 2 + c * x + d = 0 ↔\n x = s - t - b / (3 * a) ∨\n x = s * ω - t * ω ^ 2 - b / (3 * a) ∨ x = s * ω ^ 2 - t * ω - b / (3 * a) := by sorry\ntheorem cubic_eq_zero_iff_of_p_eq_zero (ha : a ≠ 0) (hω : IsPrimitiveRoot ω 3)\n (hpz : 3 * a * c - b ^ 2 = 0)\n (hq : q = (9 * a * b * c - 2 * b ^ 3 - 27 * a ^ 2 * d) / (54 * a ^ 3)) (hs3 : s ^ 3 = 2 * q)\n (x : K) :\n a * x ^ 3 + b * x ^ 2 + c * x + d = 0 ↔\n x = s - b / (3 * a) ∨ x = s * ω - b / (3 * a) ∨ x = s * ω ^ 2 - b / (3 * a) := by sorry\nend Cubic\n\nsection Quartic\n\nvariable [Invertible (2 : K)]\n\n/-- Roots of a quartic whose cubic term is zero and linear term is nonzero,\n In terms of some `u` that satisfies a particular cubic resolvent. -/\ntheorem quartic_depressed_eq_zero_iff\n (hq_nonzero : q ≠ 0)\n (hu : u ^ 3 - p * u ^ 2 - 4 * r * u + 4 * p * r - q ^ 2 = 0)\n (hs : s ^ 2 = u - p)\n (hv : v ^ 2 = 4 * s ^ 2 - 8 * (u - q / s))\n (hw : w ^ 2 = 4 * s ^ 2 - 8 * (u + q / s))\n (x : K) :\n x ^ 4 + p * x ^ 2 + q * x + r = 0 ↔\n x = (-2 * s - v) / 4 ∨ x = (-2 * s + v) / 4 ∨ x = (2 * s - w) / 4 ∨ x = (2 * s + w) / 4 := by sorry\ntheorem quartic_eq_zero_iff (ha : a ≠ 0)\n (hp : p = (8 * a * c - 3 * b ^ 2) / (8 * a ^ 2))\n (hq : q = (b ^ 3 - 4 * a * b * c + 8 * a ^ 2 * d) / (8 * a ^ 3)) (hq_nonzero : q ≠ 0)\n (hr : r =\n (16 * a * b ^ 2 * c + 256 * a ^ 3 * e - 3 * b ^ 4 - 64 * a ^ 2 * b * d) / (256 * a ^ 4))\n (hu : u ^ 3 - p * u ^ 2 - 4 * r * u + 4 * p * r - q ^ 2 = 0)\n (hs : s ^ 2 = u - p)\n (hv : v ^ 2 = 4 * s ^ 2 - 8 * (u - q / s))\n (hw : w ^ 2 = 4 * s ^ 2 - 8 * (u + q / s)) (x : K) :\n a * x ^ 4 + b * x ^ 3 + c * x ^ 2 + d * x + e = 0 ↔\n x = (-2 * s - v) / 4 - b / (4 * a) ∨ x = (-2 * s + v) / 4 - b / (4 * a) ∨\n x = (2 * s - w) / 4 - b / (4 * a) ∨ x = (2 * s + w) / 4 - b / (4 * a) := by sorry\ntheorem quartic_eq_zero_iff_of_q_eq_zero (ha : a ≠ 0)\n (hp : p = (8 * a * c - 3 * b ^ 2) / (8 * a ^ 2))\n (hqz : b ^ 3 - 4 * a * b * c + 8 * a ^ 2 * d = 0)\n (hr : r =\n (16 * a * b ^ 2 * c + 256 * a ^ 3 * e - 3 * b ^ 4 - 64 * a ^ 2 * b * d) / (256 * a ^ 4))\n (ht : t ^ 2 = p ^ 2 - 4 * r)\n (hv : v ^ 2 = (-p + t) / 2)\n (hw : w ^ 2 = (-p - t) / 2) (x : K) :\n a * x ^ 4 + b * x ^ 3 + c * x ^ 2 + d * x + e = 0 ↔\n x = v - b / (4 * a) ∨ x = -v - b / (4 * a) ∨ x = w - b / (4 * a) ∨ x = -w - b / (4 * a) := by sorry\nend Quartic\n\nend Field\n\nend Theorems100\n" }, { "theorem_id": 36, "title": "037_the_solution_of_a_cubic", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Reals Coq.Reals.Rtrigo_def Coquelicot.Coquelicot Coquelicot.ElemFct Lra.\n\nOpen Scope R_scope.\n\nLtac Rsimpl:=\nrepeat (\ntry rewrite Ropp_involutive;\ntry rewrite Ropp_0;\ntry rewrite Rplus_opp_l;\ntry rewrite Rplus_opp_r;\ntry rewrite Rplus_0_l;\ntry rewrite Rplus_0_r;\ntry rewrite Rmult_1_l;\ntry rewrite Rmult_1_r;\ntry rewrite Rmult_0_l;\ntry rewrite Rmult_0_r\n).\n\nLtac Csimpl:=\n repeat (\n try rewrite Copp_0;\n try rewrite Cplus_opp_r;\n try rewrite Cplus_0_l;\n try rewrite Cplus_0_r;\n try rewrite Cmult_0_r;\n try rewrite Cmult_1_r;\n try rewrite Cmult_0_l;\n try rewrite Cmult_1_l).\n\nLemma contraposition_neg : forall P Q:Prop, ( P -> Q ) -> ( (~Q) -> (~P)).\nProof.\nAdmitted.\n\nDefinition Csqrt:=fun (z:C) =>\nlet (u,v):=z in\nlet a:=(sqrt(((Cmod z)+u)/2))%R in\nlet b:=(if (Rneg_or_not z) \n then v/2/a\n else sqrt(-u))%R in\n(a,b)%C : C.\n\nLemma Csqrt_Cpow2 : forall z: C, (Csqrt z)*(Csqrt z)=z.\nProof.\nAdmitted.\n\nDefinition cargument (z: C) : R := \nif (Rneg_or_not z) then (INR 2)*atan((Im (Csqrt z))/(Re (Csqrt z))) \nelse PI.\n\nLemma trigoform: forall z : C,\n z=(cos(cargument z),sin(cargument z))*(Cmod z,0).\nProof.\nAdmitted.\n \nLemma factorisationdeg3 : forall z1 z2 z3:C, forall z:C, \n(z-z1)*(z-z2)*(z-z3)=Cpow z 3+(-(z1+z2+z3))*Cpow z 2+(z1*z2+z2*z3+z3*z1)*z+(-(z1*z2*z3)).\nProof.\nAdmitted.\n\nTheorem Cpowexp : forall n:nat, forall x:R, ((exp(x))^n=exp((INR n)*x)) % R.\nProof.\nAdmitted.\n\nTheorem comCpow: forall n : nat, forall z:C, forall u:C, (Cpow (z*u)%C n)=((Cpow z n)*(Cpow u n))%C.\nProof.\nAdmitted.\n\nLemma RCpow : forall n:nat,forall x:R, Cpow (x,0)%C n = ((x^n)%R,0)%C.\nProof.\nAdmitted.\n\nDefinition nroot (n:nat) (z:C) : C:= \nif Ceq_dec z 0 then 0 \nelse let argn:=((cargument z)/(INR n))%R in\n (cos(argn),sin(argn))*(exp((ln (Cmod z))/(INR n)),0).\n\nTheorem nroot_Cpown : forall n:nat,forall z:C,n<>O-> Cpow (nroot n z) n=z.\nProof.\nAdmitted.\n\nLemma nrootpositive : forall x:R, forall n:nat, 0<=x -> Im( nroot n x ) =0%R.\nProof.\nAdmitted.\n\nDefinition cubicroot (z:C) := if(Rcase_abs (Re z)) then -nroot 3 (-z) else nroot 3 z.\n\nLemma cubicroot3 : forall z:C, Cpow (cubicroot z) 3=z.\nProof.\nAdmitted.\n\nLemma cubicrootreal : forall (x:R), 0%R=Im (cubicroot x).\nProof.\nAdmitted.\n\nDefinition CJ := ((-/2)%R,(sqrt (3/4))%R)%C.\n\nLemma CJ2: CJ*CJ=-CJ-1.\nProof.\nAdmitted.\n\nLemma CJ3 : CJ*CJ*CJ=1%C.\nProof.\nAdmitted.\n\nLemma Cval2 : RtoC 2=RtoC 1+RtoC 1.\nProof.\nAdmitted.\nLemma Cval3 : RtoC 3=RtoC 1+RtoC 1+RtoC 1.\nProof.\nAdmitted.\nLemma Cval4: (RtoC 4=(RtoC 1+RtoC 1)*(RtoC 1+RtoC 1)).\nProof.\nAdmitted.\nLemma Cval6 : RtoC 6=(RtoC 1+RtoC 1+RtoC 1)*(RtoC 1+RtoC 1).\nProof.\nAdmitted.\nLemma Cval8 : RtoC 8=(RtoC 1+RtoC 1)*(RtoC 1+RtoC 1)*(RtoC 1+RtoC 1).\nProof.\nAdmitted.\n\nLemma shiftdeg3 : forall u:C, forall a b c:C, forall z:C, \nCpow (z+u) 3+a*Cpow (z+u) 2+b*(z+u)+c\n=Cpow z 3+(a+3*u)*Cpow z 2+(b+2*u*a+3*Cpow u 2)*z+(c+b*u+a*Cpow u 2+Cpow u 3).\nProof.\nAdmitted.\n\nLemma permprod: forall e f g:C, g*f*e=e*g*f.\nProof.\nAdmitted.\n\nLtac nneq0:=unfold RtoC;\ninjection;\nintro;\nlra.\n\nLtac developall:=\n unfold Cpow;\n repeat (try Csimpl;\n try rewrite Cmult_plus_distr_r;\n try rewrite Cmult_plus_distr_l);\n repeat (\n repeat rewrite (permprod CJ);\n repeat rewrite Cmult_assoc).\n\nDefinition Cardan_Tartaglia_formula:=fun (a1:C) (a2:C) (a3:C) (n:nat) =>\nlet s:=-a1/3 in \nlet p:=a2+2*s*a1+3*Cpow s 2 in\nlet q:=a3+a2*s+a1*Cpow s 2+Cpow s 3 in\nlet Delta:=(Cpow (q/2) 2)+(Cpow (p/3) 3) in\nlet alpha : C :=if(Ceq_dec p 0) then (RtoC 0) else (cubicroot (-(q/2)+Csqrt Delta)) in\nlet beta:=if(Ceq_dec p 0) then -cubicroot q else -(p/3)/alpha in\ns+(alpha*Cpow CJ n+beta*Cpow CJ (n+n)).\n\nTheorem Cardan_Tartaglia : forall a1 a2 a3 :C,\nlet u1:=(Cardan_Tartaglia_formula a1 a2 a3 0) in\nlet u2:=(Cardan_Tartaglia_formula a1 a2 a3 1) in\nlet u3:=(Cardan_Tartaglia_formula a1 a2 a3 2) in\nforall u:C, (u-u1)*(u-u2)*(u-u3)=Cpow u 3+a1*Cpow u 2+a2*u+a3.\nProof.\nAdmitted.\n\nLemma shiftdeg4 : forall u:C, forall a b c d:C, forall z:C, \nCpow (z+u) 4+a*Cpow (z+u) 3+b*Cpow (z+u) 2+c*(z+u)+d\n=Cpow z 4+(a+4*u)*Cpow z 3+(b+3*u*a+6*Cpow u 2)*Cpow z 2\n +(c+2*b*u+3*a*Cpow u 2+4*Cpow u 3)*z+(d+c*u+b*Cpow u 2+a*Cpow u 3+Cpow u 4).\nProof.\nAdmitted.\n\nDefinition binom_solution:= fun (b:C) (c:C) (n:nat) =>\n-b/2+(Csqrt (Cpow (b/2) 2-c))*Cpow (-1) n.\n\nLemma Binom_solution_proof : forall (b:C) (c:C), forall z:C,\nCpow z 2+b*z+c=(z-binom_solution b c 0)*(z-binom_solution b c 1).\nProof.\nAdmitted.\n\nTheorem Ferrari_formula: forall (a:C) (b:C) (c:C) (d:C), \nlet s:=-a/4 in \nlet p:= b+3*s*a+6*Cpow s 2 in\nlet q:= c+2*b*s+3*a*Cpow s 2+4*Cpow s 3 in\nlet r:= d+c*s+b*Cpow s 2+a*Cpow s 3+Cpow s 4 in\nlet lambda:=Cardan_Tartaglia_formula (-p/2) (-r) (r*p/2-/8*Cpow q 2) 0 in\nlet A:=Csqrt(2*lambda-p) in\nlet cond:=(Ceq_dec (2*lambda) p) in\nlet B:=if cond then (RtoC 0) else (-q/(2*A)) in\nlet z1:=if cond then Csqrt (binom_solution p r 0) \n else binom_solution A (B+lambda) 0 in\nlet z2:=if cond then -Csqrt (binom_solution p r 0) \n else binom_solution A (B+lambda) 1 in\nlet z3:=if cond then Csqrt (binom_solution p r 1) \n else binom_solution (-A) (-B+lambda) 0 in\nlet z4:=if cond then -Csqrt (binom_solution p r 1) \n else binom_solution (-A) (-B+lambda) 1 in\nlet u1:=z1+s in\nlet u2:=z2+s in\nlet u3:=z3+s in\nlet u4:=z4+s in\nforall u:C, (u-u1)*(u-u2)*(u-u3)*(u-u4)=Cpow u 4+a*Cpow u 3+b*Cpow u 2+c*u+d.\nProof.\nAdmitted." }, { "theorem_id": 37, "title": "038_arithmetic_mean___geometric_mean", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/products.ml\";;\nprioritize_real();;\n\nlet LEMMA_1 = `!x n. x pow (n + 1) - (&n + &1) * x + &n =\n (x - &1) pow 2 * sum(1..n) (\\k. &k * x pow (n - k))`;;\n\nlet LEMMA_2 = `!n x. &0 <= x ==> &0 <= x pow (n + 1) - (&n + &1) * x + &n`;;\n\nlet LEMMA_3 = `!n x. 1 <= n /\\ (!i. 1 <= i /\\ i <= n + 1 ==> &0 <= x i)\n ==> x(n + 1) * (sum(1..n) x / &n) pow n\n <= (sum(1..n+1) x / (&n + &1)) pow (n + 1)`;;\n\nlet AGM = `!n a. 1 <= n /\\ (!i. 1 <= i /\\ i <= n ==> &0 <= a(i))\n ==> product(1..n) a <= (sum(1..n) a / &n) pow n`;;\n\nneeds \"Library/transc.ml\";;\n\nlet AGM_ROOT = `!n a. 1 <= n /\\ (!i. 1 <= i /\\ i <= n ==> &0 <= a(i))\n ==> root n (product(1..n) a) <= sum(1..n) a / &n`;;" }, { "theorem_id": 37, "title": "038_arithmetic_mean___geometric_mean", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\The Weighted Arithmetic--Geometric Mean Inequality\\\ntheory Weighted_Arithmetic_Geometric_Mean\n imports Complex_Main\nbegin\n\nsubsection \\Auxiliary Facts\\\n\nlemma root_powr_inverse': \"0 < n \\ 0 \\ x \\ root n x = x powr (1/n)\"\n by sorry\n\nlemma powr_sum_distrib_real_right:\n assumes \"a \\ 0\"\n shows \"(\\x\\X. a powr e x :: real) = a powr (\\x\\X. e x)\"\n by sorry\n\nlemma powr_sum_distrib_real_left:\n assumes \"\\x. x \\ X \\ a x \\ 0\"\n shows \"(\\x\\X. a x powr e :: real) = (\\x\\X. a x) powr e\"\n by sorry\n\nlemma prod_ge_pointwise_le_imp_pointwise_eq:\n fixes f :: \"'a \\ real\"\n assumes \"finite X\"\n assumes ge: \"prod f X \\ prod g X\"\n assumes nonneg: \"\\x. x \\ X \\ f x \\ 0\"\n assumes pos: \"\\x. x \\ X \\ g x > 0\"\n assumes le: \"\\x. x \\ X \\ f x \\ g x\" and x: \"x \\ X\"\n shows \"f x = g x\"\n by sorry\n\nlemma powr_right_real_eq_iff:\n assumes \"a \\ (0 :: real)\"\n shows \"a powr x = a powr y \\ a = 0 \\ a = 1 \\ x = y\"\n by sorry\n\nlemma powr_left_real_eq_iff:\n assumes \"a \\ (0 :: real)\" \"b \\ 0\" \"x \\ 0\"\n shows \"a powr x = b powr x \\ a = b\"\n by sorry\n\nlemma exp_real_eq_one_plus_iff:\n fixes x :: real\n shows \"exp x = 1 + x \\ x = 0\"\n by sorry\n\n\nsubsection \\The Inequality\\\n\ntext \\\n We first prove the equality under the assumption that all the $a_i$ and $w_i$ are positive.\n\\\nlemma weighted_arithmetic_geometric_mean_pos:\n fixes a w :: \"'a \\ real\"\n assumes \"finite X\"\n assumes pos1: \"\\x. x \\ X \\ a x > 0\"\n assumes pos2: \"\\x. x \\ X \\ w x > 0\"\n assumes sum_weights: \"(\\x\\X. w x) = 1\"\n shows \"(\\x\\X. a x powr w x) \\ (\\x\\X. w x * a x)\"\n by sorry\n\ntext \\\n We can now relax the positivity assumptions to non-negativity: if one of the $a_i$ is\n zero, the theorem becomes trivial (note that $0^0 = 0$ by convention for the real-valued\n power operator \\<^term>\\(powr) :: real \\ real \\ real\\).\n\n Otherwise, we can simply remove all the indices that have weight 0 and apply the\n above auxiliary version of the theorem.\n\\\ntheorem weighted_arithmetic_geometric_mean:\n fixes a w :: \"'a \\ real\"\n assumes \"finite X\"\n assumes nonneg1: \"\\x. x \\ X \\ a x \\ 0\"\n assumes nonneg2: \"\\x. x \\ X \\ w x \\ 0\"\n assumes sum_weights: \"(\\x\\X. w x) = 1\"\n shows \"(\\x\\X. a x powr w x) \\ (\\x\\X. w x * a x)\"\n by sorry\n\ntext \\\n We can derive the regular arithmetic/geometric mean inequality from this by simply\n setting all the weights to $\\frac{1}{n}$:\n\\\ncorollary arithmetic_geometric_mean:\n fixes a :: \"'a \\ real\"\n assumes \"finite X\"\n defines \"n \\ card X\"\n assumes nonneg: \"\\x. x \\ X \\ a x \\ 0\"\n shows \"root n (\\x\\X. a x) \\ (\\x\\X. a x) / n\"\n by sorry\n\n\nsubsection \\The Equality Case\\\n\ntext \\\n Next, we show that weighted arithmetic and geometric mean are equal if and only if all the \n $a_i$ are equal.\n\n We first prove the more difficult direction as a lemmas and again first assume positivity\n of all $a_i$ and $w_i$ and will relax this somewhat later.\n\\\nlemma weighted_arithmetic_geometric_mean_eq_iff_pos:\n fixes a w :: \"'a \\ real\"\n assumes \"finite X\"\n assumes pos1: \"\\x. x \\ X \\ a x > 0\"\n assumes pos2: \"\\x. x \\ X \\ w x > 0\"\n assumes sum_weights: \"(\\x\\X. w x) = 1\"\n assumes eq: \"(\\x\\X. a x powr w x) = (\\x\\X. w x * a x)\"\n shows \"\\x\\X. \\y\\X. a x = a y\"\n by sorry\n\ntext \\\n We can now show the full theorem and relax the positivity condition on the $a_i$ to\n non-negativity. This is possible because if some $a_i$ is zero and the two means\n coincide, then the product is obviously 0, but the sum can only be 0 if \\<^term>\\all\\\n the $a_i$ are 0.\n\\\ntheorem weighted_arithmetic_geometric_mean_eq_iff:\n fixes a w :: \"'a \\ real\"\n assumes \"finite X\"\n assumes nonneg1: \"\\x. x \\ X \\ a x \\ 0\"\n assumes pos2: \"\\x. x \\ X \\ w x > 0\"\n assumes sum_weights: \"(\\x\\X. w x) = 1\"\n shows \"(\\x\\X. a x powr w x) = (\\x\\X. w x * a x) \\ X \\ {} \\ (\\x\\X. \\y\\X. a x = a y)\"\n by sorry\n\ntext \\\n Again, we derive a version for the unweighted arithmetic/geometric mean.\n\\\ncorollary arithmetic_geometric_mean_eq_iff:\n fixes a :: \"'a \\ real\"\n assumes \"finite X\"\n defines \"n \\ card X\"\n assumes nonneg: \"\\x. x \\ X \\ a x \\ 0\"\n shows \"root n (\\x\\X. a x) = (\\x\\X. a x) / n \\ (\\x\\X. \\y\\X. a x = a y)\"\n by sorry\n\n\nsubsection \\The Binary Version\\\n\ntext \\\n For convenience, we also derive versions for only two numbers:\n\\\ncorollary weighted_arithmetic_geometric_mean_binary:\n fixes w1 w2 x1 x2 :: real\n assumes \"x1 \\ 0\" \"x2 \\ 0\" \"w1 \\ 0\" \"w2 \\ 0\" \"w1 + w2 = 1\"\n shows \"x1 powr w1 * x2 powr w2 \\ w1 * x1 + w2 * x2\"\n by sorry\n\ncorollary weighted_arithmetic_geometric_mean_eq_iff_binary:\n fixes w1 w2 x1 x2 :: real\n assumes \"x1 \\ 0\" \"x2 \\ 0\" \"w1 > 0\" \"w2 > 0\" \"w1 + w2 = 1\"\n shows \"x1 powr w1 * x2 powr w2 = w1 * x1 + w2 * x2 \\ x1 = x2\"\n by sorry\n\ncorollary arithmetic_geometric_mean_binary:\n fixes x1 x2 :: real\n assumes \"x1 \\ 0\" \"x2 \\ 0\"\n shows \"sqrt (x1 * x2) \\ (x1 + x2) / 2\"\n by sorry\n\ncorollary arithmetic_geometric_mean_eq_iff_binary:\n fixes x1 x2 :: real\n assumes \"x1 \\ 0\" \"x2 \\ 0\"\n shows \"sqrt (x1 * x2) = (x1 + x2) / 2 \\ x1 = x2\"\n by sorry\n\nend" }, { "theorem_id": 37, "title": "038_arithmetic_mean___geometric_mean", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne, Jireh Loreaux\n-/\nmodule\n\npublic import Mathlib.Algebra.BigOperators.Expect\npublic import Mathlib.Algebra.BigOperators.Field\npublic import Mathlib.Analysis.Convex.Jensen\npublic import Mathlib.Analysis.Convex.SpecificFunctions.Basic\npublic import Mathlib.Analysis.SpecialFunctions.Pow.NNReal\npublic import Mathlib.Data.Real.ConjExponents\n\n/-!\n# Mean value inequalities\n\nIn this file we prove several inequalities for finite sums, including AM-GM inequality,\nHM-GM inequality, Young's inequality, Hölder inequality, and Minkowski inequality. Versions for\nintegrals of some of these inequalities are available in\n`Mathlib/MeasureTheory/Integral/MeanInequalities.lean`.\n\n## Main theorems\n\n### AM-GM inequality:\n\nThe inequality says that the geometric mean of a tuple of non-negative numbers is less than or equal\nto their arithmetic mean. We prove the weighted version of this inequality: if $w$ and $z$\nare two non-negative vectors and $\\sum_{i\\in s} w_i=1$, then\n$$\n\\prod_{i\\in s} z_i^{w_i} ≤ \\sum_{i\\in s} w_iz_i.\n$$\nThe classical version is a special case of this inequality for $w_i=\\frac{1}{n}$.\n\nWe prove a few versions of this inequality. Each of the following lemmas comes in two versions:\na version for real-valued non-negative functions is in the `Real` namespace, and a version for\n`NNReal`-valued functions is in the `NNReal` namespace.\n\n- `geom_mean_le_arith_mean_weighted` : weighted version for functions on `Finset`s;\n- `geom_mean_le_arith_mean2_weighted` : weighted version for two numbers;\n- `geom_mean_le_arith_mean3_weighted` : weighted version for three numbers;\n- `geom_mean_le_arith_mean4_weighted` : weighted version for four numbers.\n\n\n### HM-GM inequality:\n\nThe inequality says that the harmonic mean of a tuple of positive numbers is less than or equal\nto their geometric mean. We prove the weighted version of this inequality: if $w$ and $z$\nare two positive vectors and $\\sum_{i\\in s} w_i=1$, then\n$$\n1/(\\sum_{i\\in s} w_i/z_i) ≤ \\prod_{i\\in s} z_i^{w_i}\n$$\nThe classical version is proven as a special case of this inequality for $w_i=\\frac{1}{n}$.\n\nThe inequalities are proven only for real-valued positive functions on `Finset`s, and namespaced in\n`Real`. The weighted version follows as a corollary of the weighted AM-GM inequality.\n\n### Young's inequality\n\nYoung's inequality says that for non-negative numbers `a`, `b`, `p`, `q` such that\n$\\frac{1}{p}+\\frac{1}{q}=1$ we have\n$$\nab ≤ \\frac{a^p}{p} + \\frac{b^q}{q}.\n$$\n\nThis inequality is a special case of the AM-GM inequality. It is then used to prove Hölder's\ninequality (see below).\n\n### Hölder's inequality\n\nThe inequality says that for two conjugate exponents `p` and `q` (i.e., for two positive numbers\nsuch that $\\frac{1}{p}+\\frac{1}{q}=1$) and any two non-negative vectors their inner product is\nless than or equal to the product of the $L_p$ norm of the first vector and the $L_q$ norm of the\nsecond vector:\n$$\n\\sum_{i\\in s} a_ib_i ≤ \\sqrt[p]{\\sum_{i\\in s} a_i^p}\\sqrt[q]{\\sum_{i\\in s} b_i^q}.\n$$\n\nWe give versions of this result in `ℝ`, `ℝ≥0` and `ℝ≥0∞`.\n\nThere are at least two short proofs of this inequality. In our proof we prenormalize both vectors,\nthen apply Young's inequality to each $a_ib_i$. Another possible proof would be to deduce this\ninequality from the generalized mean inequality for well-chosen vectors and weights.\n\n### Minkowski's inequality\n\nThe inequality says that for `p ≥ 1` the function\n$$\n\\|a\\|_p=\\sqrt[p]{\\sum_{i\\in s} a_i^p}\n$$\nsatisfies the triangle inequality $\\|a+b\\|_p\\le \\|a\\|_p+\\|b\\|_p$.\n\nWe give versions of this result in `Real`, `ℝ≥0` and `ℝ≥0∞`.\n\nWe deduce this inequality from Hölder's inequality. Namely, Hölder inequality implies that $\\|a\\|_p$\nis the maximum of the inner product $\\sum_{i\\in s}a_ib_i$ over `b` such that $\\|b\\|_q\\le 1$. Now\nMinkowski's inequality follows from the fact that the maximum value of the sum of two functions is\nless than or equal to the sum of the maximum values of the summands.\n\n## TODO\n\n- each inequality `A ≤ B` should come with a theorem `A = B ↔ _`; one of the ways to prove them\n is to define `StrictConvexOn` functions.\n- generalized mean inequality with any `p ≤ q`, including negative numbers;\n- prove that the power mean tends to the geometric mean as the exponent tends to zero.\n\n-/\n\npublic section\n\n\nuniverse u v\n\nopen Finset NNReal ENNReal\nopen scoped BigOperators\n\nnoncomputable section\n\nvariable {ι : Type u} (s : Finset ι)\n\nsection GeomMeanLEArithMean\n\n/-! ### AM-GM inequality -/\n\n\nnamespace Real\n\n/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted\nversion for real-valued nonnegative functions. -/\ntheorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :\n ∏ i ∈ s, z i ^ w i ≤ ∑ i ∈ s, w i * z i := by sorry\ntheorem geom_mean_le_arith_mean {ι : Type*} (s : Finset ι) (w : ι → ℝ) (z : ι → ℝ)\n (hw : ∀ i ∈ s, 0 ≤ w i) (hw' : 0 < ∑ i ∈ s, w i) (hz : ∀ i ∈ s, 0 ≤ z i) :\n (∏ i ∈ s, z i ^ w i) ^ (∑ i ∈ s, w i)⁻¹ ≤ (∑ i ∈ s, w i * z i) / (∑ i ∈ s, w i) := by sorry\ntheorem geom_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :\n ∏ i ∈ s, z i ^ w i = x :=\n calc\n ∏ i ∈ s, z i ^ w i = ∏ i ∈ s, x ^ w i := by sorry\ntheorem arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw' : ∑ i ∈ s, w i = 1)\n (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) : ∑ i ∈ s, w i * z i = x :=\n calc\n ∑ i ∈ s, w i * z i = ∑ i ∈ s, w i * x := by sorry\ntheorem geom_mean_eq_arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :\n ∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i := by sorry\ntheorem geom_mean_eq_arith_mean_weighted_iff' (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 < w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :\n ∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i ↔ ∀ j ∈ s, z j = ∑ i ∈ s, w i * z i := by sorry\ntheorem geom_mean_eq_arith_mean_weighted_iff (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :\n ∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i ↔ ∀ j ∈ s, w j ≠ 0 → z j = ∑ i ∈ s, w i * z i := by sorry\ntheorem geom_mean_lt_arith_mean_weighted_iff_of_pos (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 < w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :\n ∏ i ∈ s, z i ^ w i < ∑ i ∈ s, w i * z i ↔ ∃ j ∈ s, ∃ k ∈ s, z j ≠ z k := by sorry\nend Real\n\nnamespace NNReal\n\n/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted\nversion for `NNReal`-valued functions. -/\ntheorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) :\n (∏ i ∈ s, z i ^ (w i : ℝ)) ≤ ∑ i ∈ s, w i * z i :=\n mod_cast\n Real.geom_mean_le_arith_mean_weighted _ _ _ (fun i _ => (w i).coe_nonneg)\n (by assumption_mod_cast) fun i _ => (z i).coe_nonneg\n\n/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted\nversion for two `NNReal` numbers. -/\ntheorem geom_mean_le_arith_mean2_weighted (w₁ w₂ p₁ p₂ : ℝ≥0) :\n w₁ + w₂ = 1 → p₁ ^ (w₁ : ℝ) * p₂ ^ (w₂ : ℝ) ≤ w₁ * p₁ + w₂ * p₂ := by sorry\ntheorem geom_mean_le_arith_mean3_weighted (w₁ w₂ w₃ p₁ p₂ p₃ : ℝ≥0) :\n w₁ + w₂ + w₃ = 1 →\n p₁ ^ (w₁ : ℝ) * p₂ ^ (w₂ : ℝ) * p₃ ^ (w₃ : ℝ) ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ := by sorry\ntheorem geom_mean_le_arith_mean4_weighted (w₁ w₂ w₃ w₄ p₁ p₂ p₃ p₄ : ℝ≥0) :\n w₁ + w₂ + w₃ + w₄ = 1 →\n p₁ ^ (w₁ : ℝ) * p₂ ^ (w₂ : ℝ) * p₃ ^ (w₃ : ℝ) * p₄ ^ (w₄ : ℝ) ≤\n w₁ * p₁ + w₂ * p₂ + w₃ * p₃ + w₄ * p₄ := by sorry\nend NNReal\n\nnamespace Real\n\ntheorem geom_mean_le_arith_mean2_weighted {w₁ w₂ p₁ p₂ : ℝ} (hw₁ : 0 ≤ w₁) (hw₂ : 0 ≤ w₂)\n (hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hw : w₁ + w₂ = 1) : p₁ ^ w₁ * p₂ ^ w₂ ≤ w₁ * p₁ + w₂ * p₂ :=\n NNReal.geom_mean_le_arith_mean2_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ <|\n NNReal.coe_inj.1 <| by assumption\n\ntheorem geom_mean_le_arith_mean3_weighted {w₁ w₂ w₃ p₁ p₂ p₃ : ℝ} (hw₁ : 0 ≤ w₁) (hw₂ : 0 ≤ w₂)\n (hw₃ : 0 ≤ w₃) (hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hp₃ : 0 ≤ p₃) (hw : w₁ + w₂ + w₃ = 1) :\n p₁ ^ w₁ * p₂ ^ w₂ * p₃ ^ w₃ ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ :=\n NNReal.geom_mean_le_arith_mean3_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨w₃, hw₃⟩ ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩\n ⟨p₃, hp₃⟩ <|\n NNReal.coe_inj.1 hw\n\ntheorem geom_mean_le_arith_mean4_weighted {w₁ w₂ w₃ w₄ p₁ p₂ p₃ p₄ : ℝ} (hw₁ : 0 ≤ w₁)\n (hw₂ : 0 ≤ w₂) (hw₃ : 0 ≤ w₃) (hw₄ : 0 ≤ w₄) (hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hp₃ : 0 ≤ p₃)\n (hp₄ : 0 ≤ p₄) (hw : w₁ + w₂ + w₃ + w₄ = 1) :\n p₁ ^ w₁ * p₂ ^ w₂ * p₃ ^ w₃ * p₄ ^ w₄ ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ + w₄ * p₄ :=\n NNReal.geom_mean_le_arith_mean4_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨w₃, hw₃⟩ ⟨w₄, hw₄⟩ ⟨p₁, hp₁⟩\n ⟨p₂, hp₂⟩ ⟨p₃, hp₃⟩ ⟨p₄, hp₄⟩ <|\n NNReal.coe_inj.1 <| by assumption\n\nend Real\n\nend GeomMeanLEArithMean\n\nsection HarmMeanLEGeomMean\n\n/-! ### HM-GM inequality -/\n\nnamespace Real\n\n/-- **HM-GM inequality**: The harmonic mean is less than or equal to the geometric mean, weighted\nversion for real-valued nonnegative functions. -/\ntheorem harm_mean_le_geom_mean_weighted (w z : ι → ℝ) (hs : s.Nonempty) (hw : ∀ i ∈ s, 0 < w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 < z i) :\n (∑ i ∈ s, w i / z i)⁻¹ ≤ ∏ i ∈ s, z i ^ w i := by sorry\ntheorem harm_mean_le_geom_mean {ι : Type*} (s : Finset ι) (hs : s.Nonempty) (w : ι → ℝ)\n (z : ι → ℝ) (hw : ∀ i ∈ s, 0 < w i) (hw' : 0 < ∑ i ∈ s, w i) (hz : ∀ i ∈ s, 0 < z i) :\n (∑ i ∈ s, w i) / (∑ i ∈ s, w i / z i) ≤ (∏ i ∈ s, z i ^ w i) ^ (∑ i ∈ s, w i)⁻¹ := by sorry\nend Real\n\nend HarmMeanLEGeomMean\n\n\nsection Young\n\n/-! ### Young's inequality -/\n\n\nnamespace Real\n\n/-- **Young's inequality**, a version for nonnegative real numbers. -/\ntheorem young_inequality_of_nonneg {a b p q : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b)\n (hpq : p.HolderConjugate q) : a * b ≤ a ^ p / p + b ^ q / q := by sorry\ntheorem young_inequality (a b : ℝ) {p q : ℝ} (hpq : p.HolderConjugate q) :\n a * b ≤ |a| ^ p / p + |b| ^ q / q :=\n calc\n a * b ≤ |a * b| := le_abs_self (a * b)\n _ = |a| * |b| := abs_mul a b\n _ ≤ |a| ^ p / p + |b| ^ q / q :=\n Real.young_inequality_of_nonneg (abs_nonneg a) (abs_nonneg b) hpq\n\nend Real\n\nnamespace NNReal\n\n/-- **Young's inequality**, `ℝ≥0` version. We use `{p q : ℝ≥0}` in order to avoid constructing\nwitnesses of `0 ≤ p` and `0 ≤ q` for the denominators. -/\ntheorem young_inequality (a b : ℝ≥0) {p q : ℝ≥0} (hpq : p.HolderConjugate q) :\n a * b ≤ a ^ (p : ℝ) / p + b ^ (q : ℝ) / q :=\n Real.young_inequality_of_nonneg a.coe_nonneg b.coe_nonneg hpq.coe\n\n/-- **Young's inequality**, `ℝ≥0` version with real conjugate exponents. -/\ntheorem young_inequality_real (a b : ℝ≥0) {p q : ℝ} (hpq : p.HolderConjugate q) :\n a * b ≤ a ^ p / Real.toNNReal p + b ^ q / Real.toNNReal q := by sorry\nend NNReal\n\nnamespace ENNReal\n\n/-- **Young's inequality**, `ℝ≥0∞` version with real conjugate exponents. -/\ntheorem young_inequality (a b : ℝ≥0∞) {p q : ℝ} (hpq : p.HolderConjugate q) :\n a * b ≤ a ^ p / ENNReal.ofReal p + b ^ q / ENNReal.ofReal q := by sorry\nend ENNReal\n\nend Young\n\nsection HoelderMinkowski\n\n/-! ### Hölder's and Minkowski's inequalities -/\n\n\nnamespace NNReal\n\nprivate theorem inner_le_Lp_mul_Lp_of_norm_le_one (f g : ι → ℝ≥0) {p q : ℝ}\n (hpq : p.HolderConjugate q) (hf : ∑ i ∈ s, f i ^ p ≤ 1) (hg : ∑ i ∈ s, g i ^ q ≤ 1) :\n ∑ i ∈ s, f i * g i ≤ 1 := by sorry\ntheorem inner_le_Lp_mul_Lq (f g : ι → ℝ≥0) {p q : ℝ} (hpq : p.HolderConjugate q) :\n ∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by sorry\ntheorem Lr_rpow_le_Lp_mul_Lq (f g : ι → ℝ≥0) {p q r : ℝ} (hpqr : p.HolderTriple q r) :\n ∑ i ∈ s, (f i * g i) ^ r ≤ (∑ i ∈ s, f i ^ p) ^ (r / p) * (∑ i ∈ s, g i ^ q) ^ (r / q) := by sorry\ntheorem Lr_le_Lp_mul_Lq (f g : ι → ℝ≥0) {p q r : ℝ} (hpqr : p.HolderTriple q r) :\n (∑ i ∈ s, (f i * g i) ^ r) ^ (1 / r) ≤\n (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by sorry\nlemma inner_le_weight_mul_Lp (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) (w f : ι → ℝ≥0) :\n ∑ i ∈ s, w i * f i ≤ (∑ i ∈ s, w i) ^ (1 - p⁻¹) * (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ := by sorry\ntheorem summable_and_Lr_rpow_le_Lp_mul_Lq_tsum {f g : ι → ℝ≥0} {p q r : ℝ}\n (hpqr : p.HolderTriple q r) (hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :\n (Summable fun i => (f i * g i) ^ r) ∧\n ∑' i, (f i * g i) ^ r ≤ (∑' i, f i ^ p) ^ (r / p) * (∑' i, g i ^ q) ^ (r / q) := by sorry\ntheorem summable_and_inner_le_Lp_mul_Lq_tsum {f g : ι → ℝ≥0} {p q : ℝ} (hpq : p.HolderConjugate q)\n (hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :\n (Summable fun i => f i * g i) ∧\n ∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by sorry\ntheorem summable_mul_rpow_of_Lp_Lq {f g : ι → ℝ≥0} {p q r : ℝ} (hpqr : p.HolderTriple q r)\n (hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :\n Summable fun i => (f i * g i) ^ r :=\n (summable_and_Lr_rpow_le_Lp_mul_Lq_tsum hpqr hf hg).1\n\ntheorem summable_mul_of_Lp_Lq {f g : ι → ℝ≥0} {p q : ℝ} (hpq : p.HolderConjugate q)\n (hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :\n Summable fun i => f i * g i :=\n (summable_and_inner_le_Lp_mul_Lq_tsum hpq hf hg).1\n\ntheorem Lr_rpow_le_Lp_mul_Lq_tsum {f g : ι → ℝ≥0} {p q r : ℝ} (hpqr : p.HolderTriple q r)\n (hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :\n ∑' i, (f i * g i) ^ r ≤ (∑' i, f i ^ p) ^ (r / p) * (∑' i, g i ^ q) ^ (r / q) :=\n (summable_and_Lr_rpow_le_Lp_mul_Lq_tsum hpqr hf hg).2\n\ntheorem Lr_le_Lp_mul_Lq_tsum {f g : ι → ℝ≥0} {p q r : ℝ} (hpqr : p.HolderTriple q r)\n (hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :\n (∑' i, (f i * g i) ^ r) ^ (1 / r) ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by sorry\ntheorem inner_le_Lp_mul_Lq_tsum {f g : ι → ℝ≥0} {p q : ℝ} (hpq : p.HolderConjugate q)\n (hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :\n ∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) :=\n (summable_and_inner_le_Lp_mul_Lq_tsum hpq hf hg).2\n\n@[deprecated (since := \"2026-02-12\")] alias inner_le_Lp_mul_Lq_tsum' := inner_le_Lp_mul_Lq_tsum\n\n/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their\n`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `NNReal`-valued\nfunctions. For an alternative version, convenient if the infinite sums are not already expressed as\n`p`-th powers, see `inner_le_Lp_mul_Lq_tsum`. -/\ntheorem inner_le_Lp_mul_Lq_hasSum {f g : ι → ℝ≥0} {A B : ℝ≥0} {p q : ℝ}\n (hpq : p.HolderConjugate q) (hf : HasSum (fun i => f i ^ p) (A ^ p))\n (hg : HasSum (fun i => g i ^ q) (B ^ q)) : ∃ C, C ≤ A * B ∧ HasSum (fun i => f i * g i) C := by sorry\ntheorem rpow_sum_le_const_mul_sum_rpow (f : ι → ℝ≥0) {p : ℝ} (hp : 1 ≤ p) :\n (∑ i ∈ s, f i) ^ p ≤ (#s : ℝ≥0) ^ (p - 1) * ∑ i ∈ s, f i ^ p := by sorry\ntheorem isGreatest_Lp (f : ι → ℝ≥0) {p q : ℝ} (hpq : p.HolderConjugate q) :\n IsGreatest ((fun g : ι → ℝ≥0 => ∑ i ∈ s, f i * g i) '' { g | ∑ i ∈ s, g i ^ q ≤ 1 })\n ((∑ i ∈ s, f i ^ p) ^ (1 / p)) := by sorry\ntheorem Lp_add_le (f g : ι → ℝ≥0) {p : ℝ} (hp : 1 ≤ p) :\n (∑ i ∈ s, (f i + g i) ^ p) ^ (1 / p) ≤\n (∑ i ∈ s, f i ^ p) ^ (1 / p) + (∑ i ∈ s, g i ^ p) ^ (1 / p) := by sorry\ntheorem Lp_add_le_tsum {f g : ι → ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : Summable fun i => f i ^ p)\n (hg : Summable fun i => g i ^ p) :\n (Summable fun i => (f i + g i) ^ p) ∧\n (∑' i, (f i + g i) ^ p) ^ (1 / p) ≤\n (∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) := by sorry\ntheorem summable_Lp_add {f g : ι → ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : Summable fun i => f i ^ p)\n (hg : Summable fun i => g i ^ p) : Summable fun i => (f i + g i) ^ p :=\n (Lp_add_le_tsum hp hf hg).1\n\ntheorem Lp_add_le_tsum' {f g : ι → ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : Summable fun i => f i ^ p)\n (hg : Summable fun i => g i ^ p) :\n (∑' i, (f i + g i) ^ p) ^ (1 / p) ≤ (∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) :=\n (Lp_add_le_tsum hp hf hg).2\n\n/-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or\nequal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both\nexist. A version for `NNReal`-valued functions. For an alternative version, convenient if the\ninfinite sums are not already expressed as `p`-th powers, see `Lp_add_le_tsum_of_nonneg`. -/\ntheorem Lp_add_le_hasSum {f g : ι → ℝ≥0} {A B : ℝ≥0} {p : ℝ} (hp : 1 ≤ p)\n (hf : HasSum (fun i => f i ^ p) (A ^ p)) (hg : HasSum (fun i => g i ^ p) (B ^ p)) :\n ∃ C, C ≤ A + B ∧ HasSum (fun i => (f i + g i) ^ p) (C ^ p) := by sorry\nend NNReal\n\nnamespace Real\n\nvariable (f g : ι → ℝ) {p q r : ℝ}\n\n/-- **Hölder inequality**: the sum of (the `r`-powers of) the product of two functions is bounded by\nthe product of their `L^p` and `L^q` norms when `p`, `q` and `r` form a `Real.HolderTriple`.\nVersion for sums over finite sets, with real-valued functions. -/\ntheorem Lr_rpow_le_Lp_mul_Lq (hpqr : HolderTriple p q r) :\n ∑ i ∈ s, |f i * g i| ^ r ≤ (∑ i ∈ s, |f i| ^ p) ^ (r / p) * (∑ i ∈ s, |g i| ^ q) ^ (r / q) := by sorry\ntheorem inner_le_Lp_mul_Lq (hpq : HolderConjugate p q) :\n ∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, |f i| ^ p) ^ (1 / p) * (∑ i ∈ s, |g i| ^ q) ^ (1 / q) := by sorry\ntheorem rpow_sum_le_const_mul_sum_rpow (hp : 1 ≤ p) :\n (∑ i ∈ s, |f i|) ^ p ≤ (#s : ℝ) ^ (p - 1) * ∑ i ∈ s, |f i| ^ p := by sorry\ntheorem Lp_add_le (hp : 1 ≤ p) :\n (∑ i ∈ s, |f i + g i| ^ p) ^ (1 / p) ≤\n (∑ i ∈ s, |f i| ^ p) ^ (1 / p) + (∑ i ∈ s, |g i| ^ p) ^ (1 / p) := by sorry\nvariable {f g}\n\n/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their\n`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,\nwith real-valued nonnegative functions. -/\ntheorem inner_le_Lp_mul_Lq_of_nonneg (hpq : HolderConjugate p q) (hf : ∀ i ∈ s, 0 ≤ f i)\n (hg : ∀ i ∈ s, 0 ≤ g i) :\n ∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by sorry\ntheorem Lr_rpow_le_Lp_mul_Lq_of_nonneg {ι : Type*} (s : Finset ι) {f g : ι → ℝ} {p q r : ℝ}\n (hpqr : p.HolderTriple q r) (hf : ∀ i ∈ s, 0 ≤ f i) (hg : ∀ i ∈ s, 0 ≤ g i) :\n ∑ i ∈ s, (f i * g i) ^ r ≤ (∑ i ∈ s, f i ^ p) ^ (r / p) * (∑ i ∈ s, g i ^ q) ^ (r / q) := by sorry\nlemma inner_le_weight_mul_Lp_of_nonneg (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) (w f : ι → ℝ)\n (hw : ∀ i, 0 ≤ w i) (hf : ∀ i, 0 ≤ f i) :\n ∑ i ∈ s, w i * f i ≤ (∑ i ∈ s, w i) ^ (1 - p⁻¹) * (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ := by sorry\nlemma compact_inner_le_weight_mul_Lp_of_nonneg (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) {w f : ι → ℝ}\n (hw : ∀ i, 0 ≤ w i) (hf : ∀ i, 0 ≤ f i) :\n 𝔼 i ∈ s, w i * f i ≤ (𝔼 i ∈ s, w i) ^ (1 - p⁻¹) * (𝔼 i ∈ s, w i * f i ^ p) ^ p⁻¹ := by sorry\ntheorem summable_and_Lr_rpow_le_Lp_mul_Lq_tsum_of_nonneg (hpqr : p.HolderTriple q r)\n (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p)\n (hg_sum : Summable fun i => g i ^ q) :\n (Summable fun i => (f i * g i) ^ r) ∧\n ∑' i, (f i * g i) ^ r ≤ (∑' i, f i ^ p) ^ (r / p) * (∑' i, g i ^ q) ^ (r / q) := by sorry\ntheorem summable_and_inner_le_Lp_mul_Lq_tsum_of_nonneg (hpq : p.HolderConjugate q)\n (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p)\n (hg_sum : Summable fun i => g i ^ q) :\n (Summable fun i => f i * g i) ∧\n ∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by sorry\ntheorem summable_Lr_of_Lp_Lq_of_nonneg (hpqr : p.HolderTriple q r) (hf : ∀ i, 0 ≤ f i)\n (hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :\n Summable fun i => (f i * g i) ^ r :=\n (summable_and_Lr_rpow_le_Lp_mul_Lq_tsum_of_nonneg hpqr hf hg hf_sum hg_sum).1\n\ntheorem summable_mul_of_Lp_Lq_of_nonneg (hpq : p.HolderConjugate q) (hf : ∀ i, 0 ≤ f i)\n (hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :\n Summable fun i => f i * g i :=\n (summable_and_inner_le_Lp_mul_Lq_tsum_of_nonneg hpq hf hg hf_sum hg_sum).1\n\ntheorem Lr_rpow_le_Lp_mul_Lq_tsum_of_nonneg (hpqr : p.HolderTriple q r) (hf : ∀ i, 0 ≤ f i)\n (hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :\n ∑' i, (f i * g i) ^ r ≤ (∑' i, f i ^ p) ^ (r / p) * (∑' i, g i ^ q) ^ (r / q) :=\n (summable_and_Lr_rpow_le_Lp_mul_Lq_tsum_of_nonneg hpqr hf hg hf_sum hg_sum).2\n\ntheorem Lr_le_Lp_mul_Lq_tsum_of_nonneg (hpqr : p.HolderTriple q r) (hf : ∀ i, 0 ≤ f i)\n (hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :\n (∑' i, (f i * g i) ^ r) ^ (1 / r) ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by sorry\ntheorem inner_le_Lp_mul_Lq_tsum_of_nonneg (hpq : p.HolderConjugate q) (hf : ∀ i, 0 ≤ f i)\n (hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :\n ∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) :=\n (summable_and_inner_le_Lp_mul_Lq_tsum_of_nonneg hpq hf hg hf_sum hg_sum).2\n\n@[deprecated (since := \"2026-02-12\")]\nalias inner_le_Lp_mul_Lq_of_nonneg' := inner_le_Lp_mul_Lq_of_nonneg\n\n/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their\n`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `NNReal`-valued\nfunctions. For an alternative version, convenient if the infinite sums are not already expressed as\n`p`-th powers, see `inner_le_Lp_mul_Lq_tsum_of_nonneg`. -/\ntheorem inner_le_Lp_mul_Lq_hasSum_of_nonneg (hpq : p.HolderConjugate q) {A B : ℝ} (hA : 0 ≤ A)\n (hB : 0 ≤ B) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)\n (hf_sum : HasSum (fun i => f i ^ p) (A ^ p)) (hg_sum : HasSum (fun i => g i ^ q) (B ^ q)) :\n ∃ C : ℝ, 0 ≤ C ∧ C ≤ A * B ∧ HasSum (fun i => f i * g i) C := by sorry\ntheorem rpow_sum_le_const_mul_sum_rpow_of_nonneg (hp : 1 ≤ p) (hf : ∀ i ∈ s, 0 ≤ f i) :\n (∑ i ∈ s, f i) ^ p ≤ (#s : ℝ) ^ (p - 1) * ∑ i ∈ s, f i ^ p := by sorry\ntheorem Lp_add_le_of_nonneg (hp : 1 ≤ p) (hf : ∀ i ∈ s, 0 ≤ f i) (hg : ∀ i ∈ s, 0 ≤ g i) :\n (∑ i ∈ s, (f i + g i) ^ p) ^ (1 / p) ≤\n (∑ i ∈ s, f i ^ p) ^ (1 / p) + (∑ i ∈ s, g i ^ p) ^ (1 / p) := by sorry\ntheorem Lp_add_le_tsum_of_nonneg (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)\n (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ p) :\n (Summable fun i => (f i + g i) ^ p) ∧\n (∑' i, (f i + g i) ^ p) ^ (1 / p) ≤\n (∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) := by sorry\ntheorem summable_Lp_add_of_nonneg (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)\n (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ p) :\n Summable fun i => (f i + g i) ^ p :=\n (Lp_add_le_tsum_of_nonneg hp hf hg hf_sum hg_sum).1\n\ntheorem Lp_add_le_tsum_of_nonneg' (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)\n (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ p) :\n (∑' i, (f i + g i) ^ p) ^ (1 / p) ≤ (∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) :=\n (Lp_add_le_tsum_of_nonneg hp hf hg hf_sum hg_sum).2\n\n/-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or\nequal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both\nexist. A version for `ℝ`-valued functions. For an alternative version, convenient if the infinite\nsums are not already expressed as `p`-th powers, see `Lp_add_le_tsum_of_nonneg`. -/\ntheorem Lp_add_le_hasSum_of_nonneg (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i) {A B : ℝ}\n (hA : 0 ≤ A) (hB : 0 ≤ B) (hfA : HasSum (fun i => f i ^ p) (A ^ p))\n (hgB : HasSum (fun i => g i ^ p) (B ^ p)) :\n ∃ C, 0 ≤ C ∧ C ≤ A + B ∧ HasSum (fun i => (f i + g i) ^ p) (C ^ p) := by sorry\nend Real\n\nnamespace ENNReal\n\nvariable (f g : ι → ℝ≥0∞) {p q : ℝ}\n\n-- TODO: fix the non-terminal simp on the last line\nset_option linter.flexible false in\n/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their\n`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,\nwith `ℝ≥0∞`-valued functions. -/\ntheorem inner_le_Lp_mul_Lq (hpq : p.HolderConjugate q) :\n ∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by sorry\nlemma inner_le_weight_mul_Lp_of_nonneg (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) (w f : ι → ℝ≥0∞) :\n ∑ i ∈ s, w i * f i ≤ (∑ i ∈ s, w i) ^ (1 - p⁻¹) * (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ := by sorry\ntheorem rpow_sum_le_const_mul_sum_rpow (hp : 1 ≤ p) :\n (∑ i ∈ s, f i) ^ p ≤ (card s : ℝ≥0∞) ^ (p - 1) * ∑ i ∈ s, f i ^ p := by sorry\ntheorem Lp_add_le (hp : 1 ≤ p) :\n (∑ i ∈ s, (f i + g i) ^ p) ^ (1 / p) ≤\n (∑ i ∈ s, f i ^ p) ^ (1 / p) + (∑ i ∈ s, g i ^ p) ^ (1 / p) := by sorry\nend ENNReal\n\nend HoelderMinkowski\n" }, { "theorem_id": 37, "title": "038_arithmetic_mean___geometric_mean", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Lia Reals Psatz.\n\nOpen Scope R_scope.\n\nTactic Notation \"assert_specialize\" hyp(H) :=\n match type of H with\n forall x : ?P, _ =>\n let Htemp := fresh \"Htemp\" in\n assert P as Htemp; [ | specialize (H Htemp); try clear Htemp ]\n end.\n\nTactic Notation \"assert_specialize\" hyp(H) \"by\" tactic(tac) :=\n match type of H with\n forall x : ?P, _ =>\n let Htemp := fresh \"Htemp\" in\n assert P as Htemp by tac; specialize (H Htemp); try clear Htemp\n end.\n\nLtac exact_eq H :=\n revert H;\n match goal with\n |- ?p -> ?q => cut (p = q); [intros ->; auto | ]\n end.\n\nLemma base x y : 4 * (x * y) <= (x + y) * (x + y).\nProof.\nAdmitted.\n\nLemma base' x y : (x * y) <= (x + y) * (x + y) / 4.\nProof.\nAdmitted.\n\nLemma base_strict x y : x <> y -> 4 * (x * y) < (x + y) * (x + y).\nProof.\nAdmitted.\n\nLemma mean2 x y :\n 0 <= x ->\n 0 <= y ->\n sqrt (x * y) <= (x + y) / 2.\nProof.\nAdmitted.\n\nLemma mean2_strict x y :\n 0 <= x ->\n 0 <= y ->\n x <> y ->\n sqrt (x * y) < (x + y) / 2.\nProof.\nAdmitted.\n\nLemma mean2_ge x y :\n 0 <= x ->\n 0 <= y ->\n sqrt (x * y) >= (x + y) / 2 ->\n x = y.\nProof.\nAdmitted.\n\nLemma mean2_rev x y :\n 0 <= x ->\n 0 <= y ->\n sqrt (x * y) = (x + y) / 2 ->\n x = y.\nProof.\nAdmitted.\n\nLemma Rdiv_fold x y : x * / y = x / y.\nProof.\nAdmitted.\n\nLemma mean_aux x1 y1 x2 y2 :\n 0 <= x1 -> 0 <= y1 -> \n x1 <= x2 -> y1 <= y2 ->\n sqrt (x1 * y1) = (x2 + y2) / 2 ->\n x1 = x2 /\\ y1 = y2 /\\ x1 = y1.\nProof.\nAdmitted.\n\nDefinition shift {X} n (u : nat -> X) : nat -> X := fun i => u (plus i n).\n\nFixpoint sum n u := match n with O => 0 | S n => u O + sum n (shift 1 u) end.\n\nFixpoint prod n u := match n with O => 1 | S n => u O * prod n (shift 1 u) end.\n\nFixpoint pow2 n := (match n with O => 1 | S n => 2 * pow2 n end)%nat.\n\nLemma sum_ext n u v : (forall x, u x = v x) -> sum n u = sum n v.\nProof.\nAdmitted.\n\nLemma prod_ext n u v : (forall x, u x = v x) -> prod n u = prod n v.\nProof.\nAdmitted.\n\nLemma sum_ext_lt n u v : (forall i, lt i n -> u i = v i) -> sum n u = sum n v.\nProof.\nAdmitted.\n\nLemma prod_ext_lt n u v : (forall i, lt i n -> u i = v i) -> prod n u = prod n v.\nProof.\nAdmitted.\n\nLemma sum_plus n m u : sum (n + m) u = sum n u + sum m (shift n u).\nProof.\nAdmitted.\n\nLemma prod_plus n m u : prod (n + m) u = prod n u * prod m (shift n u).\nProof.\nAdmitted.\n\nLemma prod_pos n u : (forall i, 0 <= u i) -> 0 <= prod n u.\nProof.\nAdmitted.\n\nLemma sum_pos n u : (forall i, 0 <= u i) -> 0 <= sum n u.\nProof.\nAdmitted.\n\nLemma sum_pos_lt n u : (forall i, lt i n -> 0 <= u i) -> 0 <= sum n u.\nProof.\nAdmitted.\n\nDefinition sqrtk k := Nat.iter k sqrt.\n\nLemma sqrtk_pos k a : 0 <= a -> 0 <= sqrtk k a.\nProof.\nAdmitted.\n\nLemma sqrtk_mult k a b : 0 <= a -> 0 <= b -> sqrtk k (a * b) = sqrtk k a * sqrtk k b.\nProof.\nAdmitted.\n\nLemma pow2_sqrtk k a : 0 <= a -> pow (sqrtk k a) (pow2 k) = a.\nProof.\nAdmitted.\n\nLemma sqrtk_pow2 k a : 0 <= a -> sqrtk k (pow a (pow2 k)) = a.\nProof.\nAdmitted.\n\nLemma INR_pow2 k : 0 < INR (pow2 k).\nProof.\nAdmitted.\n\nLemma mean_power_of_two a :\n (forall i, 0 <= a i) ->\n forall k,\n sqrtk k (prod (pow2 k) a) <=\n sum (pow2 k) a / INR (pow2 k).\nProof.\nAdmitted.\n\nLemma mean_power_of_two_eq a :\n (forall i, 0 <= a i) ->\n forall k,\n sqrtk k (prod (pow2 k) a) = sum (pow2 k) a / INR (pow2 k) ->\n forall i j, lt i (pow2 k) -> lt j (pow2 k) -> a i = a j.\nProof.\nAdmitted.\n\nTheorem geometric_arithmetic_mean (a : nat -> R) (n : nat) :\n n <> O ->\n (forall i, (i < n)%nat -> 0 <= a i) ->\n prod n a <= (sum n a / INR n) ^ n\n /\\\n (prod n a = (sum n a / INR n) ^ n -> forall i, (i < n)%nat -> a i = a O).\nProof.\nAdmitted." }, { "theorem_id": 38, "title": "042_sum_of_the_reciprocals_of_the_triangular_numbers", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/misc.ml\";; \n\nprioritize_real();;\n\nlet triangle = new_definition\n `triangle n = (n * (n + 1)) DIV 2`;;\n\nlet REAL_TRIANGLE = `&(triangle n) = (&n * (&n + &1)) / &2`;;\n\nlet TRIANGLE_FINITE_SUM = `!n. sum(1..n) (\\k. &1 / &(triangle k)) = &2 - &2 / (&n + &1)`;;\n\nlet TRIANGLE_CONVERGES = `!e. &0 < e\n ==> ?N. !n. n >= N\n ==> abs(sum(1..n) (\\k. &1 / &(triangle k)) - &2) < e`;;\n\nneeds \"Library/analysis.ml\";;\n\noverride_interface (\"-->\",`(tends_num_real)`);;\n\nlet TRIANGLE_CONVERGES' = `(\\n. sum(1..n) (\\k. &1 / &(triangle k))) --> &2`;;" }, { "theorem_id": 38, "title": "042_sum_of_the_reciprocals_of_the_triangular_numbers", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Basic Properties of Triangles\\\ntheory Triangle\nimports\n Angles\nbegin\n\ntext \\\n We prove a number of basic geometric properties of triangles. All theorems hold\n in any real inner product space.\n\\\nsubsection \\Thales' theorem\\\n\ntheorem thales:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"dist B (midpoint A C) = dist A C / 2\"\n shows \"orthogonal (A - B) (C - B)\"\n by sorry\n\nsubsection \\Sine and cosine laws\\\n\ntext \\\n The proof of the Law of Cosines follows trivially from the definition of the angle,\n the definition of the norm in vector spaces with an inner product and the bilinearity\n of the inner product.\n\\\n\nlemma cosine_law_vector:\n \"norm (u - v) ^ 2 = norm u ^ 2 + norm v ^ 2 - 2 * norm u * norm v * cos (vangle u v)\"\n by sorry\n\nlemma cosine_law_triangle:\n \"dist b c ^ 2 = dist a b ^ 2 + dist a c ^ 2 - 2 * dist a b * dist a c * cos (angle b a c)\"\n by sorry\n\ntext \\\n According to our definition, angles are always between $0$ and $\\pi$ and therefore,\n the sign of an angle is always non-negative. We can therefore look at\n $\\sin(\\alpha)^2$, which we can express in terms of $\\cos(\\alpha)$ using the\n identity $\\sin(\\alpha)^2 + \\cos(\\alpha)^2 = 1$. The remaining proof is then a\n trivial consequence of the definitions.\n\\\nlemma sine_law_triangle:\n \"sin (angle a b c) * dist b c = sin (angle b a c) * dist a c\" (is \"?A = ?B\")\n by sorry\n\ntext \\\n The following forms of the Law of Sines/Cosines are more convenient for eliminating\n sines/cosines from a goal completely.\n\\\n\nlemma cosine_law_triangle':\n \"2 * dist a b * dist a c * cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2)\"\n by sorry\n\nlemma cosine_law_triangle'':\n \"cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2) / (2 * dist a b * dist a c)\"\n by sorry\n\nlemma sine_law_triangle':\n \"b \\ c \\ sin (angle a b c) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nlemma sine_law_triangle'':\n \"b \\ c \\ sin (angle c b a) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nsubsection \\Sum of angles\\\n\ncontext\nbegin\n\nprivate lemma gather_squares: \"a * (a * b) = a^2 * (b :: real)\"\n by (simp_all add: power2_eq_square)\n\nprivate lemma eval_power: \"x ^ numeral n = x * x ^ pred_numeral n\"\n by (subst numeral_eq_Suc, subst power_Suc) simp\n\ntext \\\n The proof that the sum of the angles in a triangle is $\\pi$ is somewhat more\n involved. Following the HOL Light proof by John Harrison, we first prove\n that $\\cos(\\alpha + \\beta + \\gamma) = -1$ and $\\alpha + \\beta + \\gamma \\in [0;3\\pi)$,\n which then implies the theorem.\n\n The main work is proving $\\cos(\\alpha + \\beta + \\gamma)$. This is done using the\n addition theorems for the sine and cosine, then using the Laws of Sines to eliminate\n all $\\sin$ terms save $\\sin(\\gamma)^2$, which only appears squared in the remaining goal.\n We then use $\\sin(\\gamma)^2 = 1 - \\cos(\\gamma)^2$ to eliminate this term and apply\n the law of cosines to eliminate this term as well.\n\n The remaining goal is a non-linear equation containing only the length of the sides\n of the triangle. It can be shown by simple algebraic rewriting.\n\\\nlemma angle_sum_triangle:\n assumes \"a \\ b \\ b \\ c \\ a \\ c\"\n shows \"angle c a b + angle a b c + angle b c a = pi\"\n by sorry\n\nend\n\nsubsection \\Congruence Theorems\\\n\ntext \\\n If two triangles agree on two angles at a non-degenerate side, the third angle\n must also be equal.\n\\\nlemma similar_triangle_aa:\n assumes \"b1 \\ c1\" \"b2 \\ c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n shows \"angle b1 a1 c1 = angle b2 a2 c2\"\n by sorry\n\ntext \\\n A triangle is defined by its three angles and the lengths of three sides up to congruence.\n Two triangles are congruent if they have their angles are the same and their sides have\n the same length.\n\\\n\nlocale congruent_triangle =\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes sides': \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n and angles': \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\"\n \"angle a1 c1 b1 = angle a2 c2 b2\"\nbegin\n\nlemma sides:\n \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n \"dist b1 a1 = dist a2 b2\" \"dist c1 a1 = dist a2 c2\" \"dist c1 b1 = dist b2 c2\"\n \"dist a1 b1 = dist b2 a2\" \"dist a1 c1 = dist c2 a2\" \"dist b1 c1 = dist c2 b2\"\n \"dist b1 a1 = dist b2 a2\" \"dist c1 a1 = dist c2 a2\" \"dist c1 b1 = dist c2 b2\"\n by sorry\n\nlemma angles:\n \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\" \"angle a1 c1 b1 = angle a2 c2 b2\"\n \"angle c1 a1 b1 = angle b2 a2 c2\" \"angle c1 b1 a1 = angle a2 b2 c2\" \"angle b1 c1 a1 = angle a2 c2 b2\"\n \"angle b1 a1 c1 = angle c2 a2 b2\" \"angle a1 b1 c1 = angle c2 b2 a2\" \"angle a1 c1 b1 = angle b2 c2 a2\"\n \"angle c1 a1 b1 = angle c2 a2 b2\" \"angle c1 b1 a1 = angle c2 b2 a2\" \"angle b1 c1 a1 = angle b2 c2 a2\"\n by sorry\n\nend\n\nlemmas congruent_triangleD = congruent_triangle.sides congruent_triangle.angles\n\ntext \\\n Given two triangles that agree on a subset of its side lengths and angles that are\n sufficient to define a triangle uniquely up to congruence, one can conclude that they\n must also agree on all remaining quantities, i.e. that they are congruent.\n\n The following four congruence theorems state what constitutes such a uniquely-defining\n subset of quantities. Each theorem states in its name which quantities are required and\n in which order (clockwise or counter-clockwise): an ``s'' stands for a side,\n an ``a'' stands for an angle.\n\n The lemma ``congruent-triangleI-sas, for example, requires that two adjacent sides and the\n angle inbetween are the same in both triangles.\n\\\n\nlemma congruent_triangleI_sss:\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"dist a1 c1 = dist a2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sss = congruent_triangleD[OF congruent_triangleI_sss]\n\nlemma congruent_triangleI_sas:\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sas = congruent_triangleD[OF congruent_triangleI_sas]\n\nlemma congruent_triangleI_aas:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"\\collinear {a1,b1,c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_aas = congruent_triangleD[OF congruent_triangleI_aas]\n\nlemma congruent_triangleI_asa:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"angle b1 a1 c1 = angle b2 a2 c2\"\n assumes \"\\collinear {a1, b1, c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_asa = congruent_triangleD[OF congruent_triangleI_asa]\n\nsubsection \\Isosceles Triangle Theorem\\\n\ntext \\\n We now prove the Isosceles Triangle Theorem: in a triangle where two sides have\n the same length, the two angles that are adjacent to only one of the two sides\n must be equal.\n\\\nlemma isosceles_triangle:\n assumes \"dist a c = dist b c\"\n shows \"angle b a c = angle a b c\"\n by sorry\n\ntext \\\n For the non-degenerate case (i.e. the three points are not collinear), We also\n prove the converse.\n\\\nlemma isosceles_triangle_converse:\n assumes \"angle a b c = angle b a c\" \"\\collinear {a,b,c}\"\n shows \"dist a c = dist b c\"\n by sorry\n\nsubsection\\Contributions by Lukas Bulwahn\\\n \nlemma Pythagoras:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"orthogonal (A - C) (B - C)\"\n shows \"(dist B C) ^ 2 + (dist C A) ^ 2 = (dist A B) ^ 2\"\n by sorry\n\nlemma isosceles_triangle_orthogonal_on_midpoint:\n fixes A B C :: \"'a :: euclidean_space\"\n assumes \"dist C A = dist C B\"\n shows \"orthogonal (C - midpoint A B) (A - midpoint A B)\"\n by sorry\n\nend" }, { "theorem_id": 38, "title": "042_sum_of_the_reciprocals_of_the_triangular_numbers", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jalex Stark, Yury Kudryashov\n-/\nimport Mathlib.Algebra.BigOperators.Group.Finset.Powerset\nimport Mathlib.Data.Real.Basic\nimport Mathlib.Tactic.FieldSimp\nimport Mathlib.Tactic.Positivity.Basic\nimport Mathlib.Tactic.Ring\n\n/-!\n# Sum of the Reciprocals of the Triangular Numbers\n\nThis file proves Theorem 42 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/).\n\nWe interpret “triangular numbers” as naturals of the form $\\frac{k(k+1)}{2}$ for natural `k`.\nWe prove that the sum of the reciprocals of the first `n` triangular numbers is $2 - \\frac2n$.\n\n## Tags\n\ndiscrete_sum\n-/\n\n\nopen Finset\n\n/-- **Sum of the Reciprocals of the Triangular Numbers** -/\ntheorem Theorems100.inverse_triangle_sum (n : ℕ) :\n ∑ k ∈ range n, (2 : ℚ) / (k * (k + 1)) = if n = 0 then 0 else 2 - (2 : ℚ) / n := by sorry\n" }, { "theorem_id": 38, "title": "042_sum_of_the_reciprocals_of_the_triangular_numbers", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Rseries_RiemannInt.\nRequire Import Rseries_facts.\nRequire Import Rtactic.\nRequire Import Rsequence_facts.\nRequire Import Lra.\n\nDefinition triangle n := INR (n * S n) / 2.\n\nLemma triangle_sum n : sum_f_R0 INR n = triangle n.\nProof.\nAdmitted.\n\nLemma triangle_non_negative n : 0 <= triangle n.\nProof.\nAdmitted.\n\nLemma triangle_positive n : 0 < triangle (S n).\nProof.\nAdmitted.\n\nLemma sum_consecutive_triangle n : triangle (S n) + triangle n = INR (S n) * INR (S n).\nProof.\nAdmitted.\n\nLemma difference_consecutive_triangle n : (triangle (S n) - triangle n)² = INR (S n) * INR (S n).\nProof.\nAdmitted.\n\nLemma sum_triangular_tetrahedral n : sum_f_R0 triangle n = INR (n * S n * S (S n)) / 6.\nProof.\nAdmitted.\n\nDefinition inv_snssn n := / INR (S n * S (S n)).\n\nDefinition inv_sn n := / INR (S n).\n\nLemma diff_inv_snssn n : inv_snssn n = inv_sn n - inv_sn (S n).\nProof.\nAdmitted.\n\nLemma sum_inv_snssn n : sum_f_R0 inv_snssn n = 1 - inv_sn (S n).\nProof.\nAdmitted.\n\nLemma inv_sn_cv_0 : Rseq_cv inv_sn 0.\nProof.\nAdmitted.\n\nLemma ser_cv_inv_snssn : Rser_cv inv_snssn 1.\nProof.\nAdmitted.\n\nLemma sum_reciprocal_triangular : Rser_cv (fun n => / triangle (S n)) 2.\nProof.\nAdmitted." }, { "theorem_id": 39, "title": "044_the_binomial_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "let binom = define\n `(!n. binom(n,0) = 1) /\\\n (!k. binom(0,SUC(k)) = 0) /\\\n (!n k. binom(SUC(n),SUC(k)) = binom(n,SUC(k)) + binom(n,k))`;;\n\nlet BINOM_0 = `!n. binom(0,n) = if n = 0 then 1 else 0`;;\n\nlet BINOM_LT = `!n k. n < k ==> binom(n,k) = 0`;;\n\nlet BINOM_REFL = `!n. binom(n,n) = 1`;;\n\nlet BINOM_1 = `!n. binom(n,1) = n`;;\n\nlet BINOM_FACT = `!n k. FACT n * FACT k * binom(n+k,k) = FACT(n + k)`;;\n\nlet BINOM_EQ_0 = `!n k. binom(n,k) = 0 <=> n < k`;;\n\nlet BINOM_PENULT = `!n. binom(SUC n,n) = SUC n`;;\n\nlet BINOM_GE_TOP = `!m n. 1 <= m /\\ m < n ==> n <= binom(n,m)`;;\n\nlet BINOM_TOP_STEP = `!n k. ((n + 1) - k) * binom(n + 1,k) = (n + 1) * binom(n,k)`;;\n\nlet BINOM_BOTTOM_STEP = `!n k. (k + 1) * binom(n,k + 1) = (n - k) * binom(n,k)`;;\n\nlet HAS_SIZE_RESTRICTED_POWERSET = `!n m s:A->bool.\n s HAS_SIZE n ==> {t | t SUBSET s /\\ t HAS_SIZE m} HAS_SIZE binom(n,m)`;;\n\nlet CARD_RESTRICTED_POWERSET = `!s k. FINITE s ==> CARD {t | t SUBSET s /\\ t HAS_SIZE k} = binom(CARD s,k)`;;\n\nlet BINOMIAL_THEOREM = `!n x y.\n (x + y) EXP n = nsum(0..n) (\\k. binom(n,k) * x EXP k * y EXP (n - k))`;;\n\nlet REAL_BINOMIAL_THEOREM = `!n x y.\n (x + y) pow n = sum(0..n) (\\k. &(binom(n,k)) * x pow k * y pow (n - k))`;;\n\nlet BINOM_TOP_STEP_REAL = `!n k. &(binom(n + 1,k)):real =\n if k = n + 1 then &1\n else (&n + &1) / (&n + &1 - &k) * &(binom(n,k))`;;\n\nlet BINOM_BOTTOM_STEP_REAL = `!n k. &(binom(n,k+1)):real = (&n - &k) / (&k + &1) * &(binom(n,k))`;;\n\nlet REAL_OF_NUM_BINOM = `!n k. &(binom(n,k)):real =\n if k <= n then &(FACT n) / (&(FACT(n - k)) * &(FACT k))\n else &0`;;\n\nlet BINOM_BOTH_STEP_REAL = `!p k. &(binom(p + 1,k + 1)):real = (&p + &1) / (&k + &1) * &(binom(p,k))`;;\n\nlet BINOM_BOTH_STEP = `!p k. (k + 1) * binom(p + 1,k + 1) = (p + 1) * binom(p,k)`;;\n\nlet BINOM_BOTH_STEP_DOWN = `!p k. (k = 0 ==> p = 0) ==> k * binom(p,k) = p * binom(p - 1,k - 1)`;;\n\nlet BINOM = `!n k. binom(n,k) =\n if k <= n then FACT(n) DIV (FACT(n - k) * FACT(k))\n else 0`;;\n\nlet DIVIDES_GCD_BINOM = `!n k. n divides gcd(n,k) * binom(n,k)`;;\n\nlet DIVIDES_COPRIME_BINOM = `!n k. coprime(n,k) ==> n divides binom (n,k)`;;\n\nlet DIVIDES_PRIME_BINOM = `!n p. prime p /\\ 0 < n /\\ n < p ==> p divides binom(p,n)`;;\n\nlet BINOM_SYM = `!n k. binom(n,n-k) = if k <= n then binom(n,k) else 1`;;\n\nlet BINOM_MUL_SHIFT = `!m n k. k <= m\n ==> binom(n,m) * binom(m,k) = binom(n,k) * binom(n - k,m - k)`;;\n\nlet APPELL_SEQUENCE = `!c n x y. sum (0..n)\n (\\k. &(binom(n,k)) *\n sum(0..k)\n (\\l. &(binom(k,l)) * c l * x pow (k - l)) *\n y pow (n - k)) =\n sum (0..n) (\\k. &(binom(n,k)) * c k * (x + y) pow (n - k))`;;\n\nlet NUM_BINOM_CONV =\n let pth_step = `binom(n,k) = y\n ==> k <= n\n ==> (SUC n) * y = ((n + 1) - k) * x ==> binom(SUC n,k) = x`;;" }, { "theorem_id": 39, "title": "044_the_binomial_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Binomial Coefficients, Binomial Theorem, Inclusion-exclusion Principle\\\n\ntheory Binomial\n imports Presburger Factorial\nbegin\n\nsubsection \\Binomial coefficients\\\n\ntext \\This development is based on the work of Andy Gordon and Florian Kammueller.\\\n\ntext \\Combinatorial definition\\\n\ndefinition binomial :: \"nat \\ nat \\ nat\"\n where \"binomial n k = card {K\\Pow {0..choose\\ 64)\nend\n\nlemma binomial_right_mono:\n assumes \"m \\ n\" shows \"m choose k \\ n choose k\"\n by sorry\n\ntheorem n_subsets:\n assumes \"finite A\"\n shows \"card {B. B \\ A \\ card B = k} = card A choose k\"\n by sorry\n\ntext \\Recursive characterization\\\n\nlemma binomial_n_0 [simp]: \"n choose 0 = 1\"\n by sorry\n\nlemma binomial_0_Suc [simp]: \"0 choose Suc k = 0\"\n by sorry\n\nlemma binomial_Suc_Suc [simp]: \"Suc n choose Suc k = (n choose k) + (n choose Suc k)\"\n by sorry\n\nlemma binomial_eq_0: \"n < k \\ n choose k = 0\"\n by sorry\n\nlemma zero_less_binomial: \"k \\ n \\ n choose k > 0\"\n by sorry\n\nlemma binomial_eq_0_iff [simp]: \"n choose k = 0 \\ n < k\"\n by sorry\n\nlemma zero_less_binomial_iff [simp]: \"n choose k > 0 \\ k \\ n\"\n by sorry\n\nlemma binomial_n_n [simp]: \"n choose n = 1\"\n by sorry\n\nlemma binomial_Suc_n [simp]: \"Suc n choose n = Suc n\"\n by sorry\n\nlemma binomial_1 [simp]: \"n choose Suc 0 = n\"\n by sorry\n\nlemma choose_one: \"n choose 1 = n\" for n :: nat\n by sorry\n\nlemma choose_reduce_nat:\n \"0 < n \\ 0 < k \\\n n choose k = ((n - 1) choose (k - 1)) + ((n - 1) choose k)\"\n by sorry\n\nlemma Suc_times_binomial_eq: \"Suc n * (n choose k) = (Suc n choose Suc k) * Suc k\"\n by sorry\n\nlemma binomial_le_pow2: \"n choose k \\ 2^n\"\n by sorry\n\ntext \\The absorption property.\\\nlemma Suc_times_binomial: \"Suc k * (Suc n choose Suc k) = Suc n * (n choose k)\"\n by sorry\n\ntext \\This is the well-known version of absorption, but it's harder to use\n because of the need to reason about division.\\\nlemma binomial_Suc_Suc_eq_times: \"(Suc n choose Suc k) = (Suc n * (n choose k)) div Suc k\"\n by sorry\n\ntext \\Another version of absorption, with \\-1\\ instead of \\Suc\\.\\\nlemma times_binomial_minus1_eq: \"0 < k \\ k * (n choose k) = n * ((n - 1) choose (k - 1))\"\n by sorry\n\nsubsection \\The binomial theorem (courtesy of Tobias Nipkow):\\\n\ntext \\Avigad's version, generalized to any commutative ring\\\ntheorem (in comm_semiring_1) binomial_ring:\n \"(a + b :: 'a)^n = (\\k\\n. (of_nat (n choose k)) * a^k * b^(n-k))\"\n by sorry\n\ntext \\Original version for the naturals.\\\ncorollary binomial: \"(a + b :: nat)^n = (\\k\\n. (of_nat (n choose k)) * a^k * b^(n - k))\"\n by sorry\n\nlemma binomial_fact_lemma: \"k \\ n \\ fact k * fact (n - k) * (n choose k) = fact n\"\n by sorry\n\nlemma binomial_fact':\n assumes \"k \\ n\"\n shows \"n choose k = fact n div (fact k * fact (n - k))\"\n by sorry\n\nlemma binomial_fact:\n assumes kn: \"k \\ n\"\n shows \"(of_nat (n choose k) :: 'a::field_char_0) = fact n / (fact k * fact (n - k))\"\n by sorry\n\nlemma fact_binomial:\n assumes \"k \\ n\"\n shows \"fact k * of_nat (n choose k) = (fact n / fact (n - k) :: 'a::field_char_0)\"\n by sorry\n\nlemma binomial_fact_pow: \"(n choose s) * fact s \\ n^s\"\n by sorry\n\nlemma choose_two: \"n choose 2 = n * (n - 1) div 2\"\n by sorry\n\nlemma choose_row_sum: \"(\\k\\n. n choose k) = 2^n\"\n by sorry\n\nlemma sum_choose_lower: \"(\\k\\n. (r+k) choose k) = Suc (r+n) choose n\"\n by sorry\n\nlemma sum_choose_upper: \"(\\k\\n. k choose m) = Suc n choose Suc m\"\n by sorry\n\nlemma choose_alternating_sum:\n \"n > 0 \\ (\\i\\n. (-1)^i * of_nat (n choose i)) = (0 :: 'a::comm_ring_1)\"\n by sorry\n\nlemma choose_even_sum:\n assumes \"n > 0\"\n shows \"2 * (\\i\\n. if even i then of_nat (n choose i) else 0) = (2 ^ n :: 'a::comm_ring_1)\"\n by sorry\n\nlemma choose_odd_sum:\n assumes \"n > 0\"\n shows \"2 * (\\i\\n. if odd i then of_nat (n choose i) else 0) = (2 ^ n :: 'a::comm_ring_1)\"\n by sorry\n\ntext\\NW diagonal sum property\\\nlemma sum_choose_diagonal:\n assumes \"m \\ n\"\n shows \"(\\k\\m. (n - k) choose (m - k)) = Suc n choose m\"\n by sorry\n\nsubsection \\Generalized binomial coefficients\\\n\ndefinition gbinomial :: \"'a::{semidom_divide,semiring_char_0} \\ nat \\ 'a\" (infix \\gchoose\\ 64)\n where gbinomial_prod_rev: \"a gchoose k = (\\i=0..i. a - of_nat i) {0..k} div fact (Suc k)\"\n by sorry\n\nlemma gbinomial_1 [simp]: \"a gchoose 1 = a\"\n by sorry\n\nlemma gbinomial_Suc0 [simp]: \"a gchoose Suc 0 = a\"\n by sorry\n\nlemma gbinomial_0_left: \"0 gchoose k = (if k = 0 then 1 else 0)\"\n by sorry\n\nlemma gbinomial_mult_fact: \"fact k * (a gchoose k) = (\\i = 0..i = 0..Sign.add_const_constraint (\\<^const_name>\\gbinomial\\, SOME \\<^typ>\\'a::field_char_0 \\ nat \\ 'a\\)\\\n\nlemma gbinomial_mult_1:\n fixes a :: \"'a::field_char_0\"\n shows \"a * (a gchoose k) = of_nat k * (a gchoose k) + of_nat (Suc k) * (a gchoose (Suc k))\"\n (is \"?l = ?r\")\n by sorry\n\nlemma gbinomial_mult_1':\n \"(a gchoose k) * a = of_nat k * (a gchoose k) + of_nat (Suc k) * (a gchoose (Suc k))\"\n for a :: \"'a::field_char_0\"\n by sorry\n\nlemma gbinomial_Suc_Suc: \"(a + 1) gchoose (Suc k) = (a gchoose k) + (a gchoose (Suc k))\"\n for a :: \"'a::field_char_0\"\n by sorry\n\nlemma gbinomial_reduce_nat: \"0 < k \\ a gchoose k = (a-1 gchoose k-1) + (a-1 gchoose k)\"\n for a :: \"'a::field_char_0\"\n by sorry\n\nlemma gchoose_row_sum_weighted:\n \"(\\k = 0..m. (r gchoose k) * (r/2 - of_nat k)) = of_nat(Suc m) / 2 * (r gchoose (Suc m))\"\n for r :: \"'a::field_char_0\"\n by sorry\n\nlemma binomial_symmetric:\n assumes kn: \"k \\ n\"\n shows \"n choose k = n choose (n - k)\"\n by sorry\n\nlemma choose_rising_sum:\n \"(\\j\\m. ((n + j) choose n)) = ((n + m + 1) choose (n + 1))\"\n \"(\\j\\m. ((n + j) choose n)) = ((n + m + 1) choose m)\"\n by sorry\n\nlemma choose_linear_sum: \"(\\i\\n. i * (n choose i)) = n * 2 ^ (n - 1)\"\n by sorry\n\nlemma choose_alternating_linear_sum:\n assumes \"n \\ 1\"\n shows \"(\\i\\n. (-1)^i * of_nat i * of_nat (n choose i) :: 'a::comm_ring_1) = 0\"\n by sorry\n\nlemma vandermonde: \"(\\k\\r. (m choose k) * (n choose (r - k))) = (m + n) choose r\"\n by sorry\n\nlemma choose_square_sum: \"(\\k\\n. (n choose k)^2) = ((2*n) choose n)\"\n by sorry\n\nlemma pochhammer_binomial_sum:\n fixes a b :: \"'a::comm_ring_1\"\n shows \"pochhammer (a + b) n = (\\k\\n. of_nat (n choose k) * pochhammer a k * pochhammer b (n - k))\"\n by sorry\n\ntext \\Contributed by Manuel Eberl, generalised by LCP.\n Alternative definition of the binomial coefficient as \\<^term>\\\\i.\\\nlemma gbinomial_altdef_of_nat: \"a gchoose k = (\\i = 0.. a\"\n shows \"(a / of_nat k :: 'a) ^ k \\ a gchoose k\"\n by sorry\n\nlemma gbinomial_negated_upper: \"(a gchoose k) = (-1) ^ k * ((of_nat k - a - 1) gchoose k)\"\n by sorry\n\nlemma gbinomial_minus: \"((-a) gchoose k) = (-1) ^ k * ((a + of_nat k - 1) gchoose k)\"\n by sorry\n\nlemma Suc_times_gbinomial: \"of_nat (Suc k) * ((a + 1) gchoose (Suc k)) = (a + 1) * (a gchoose k)\"\n by sorry\n\nlemma gbinomial_factors: \"((a + 1) gchoose (Suc k)) = (a + 1) / of_nat (Suc k) * (a gchoose k)\"\n by sorry\n\nlemma gbinomial_rec: \"((a + 1) gchoose (Suc k)) = (a gchoose k) * ((a + 1) / of_nat (Suc k))\"\n by sorry\n\nlemma gbinomial_of_nat_symmetric: \"k \\ n \\ (of_nat n) gchoose k = (of_nat n) gchoose (n - k)\"\n by sorry\n\ntext \\The absorption identity (equation 5.5 \\<^cite>\\\\p.~157\\ in GKP_CM\\):\n\\[\n{r \\choose k} = \\frac{r}{k}{r - 1 \\choose k - 1},\\quad \\textnormal{integer } k \\neq 0.\n\\]\\\nlemma gbinomial_absorption': \"k > 0 \\ a gchoose k = (a / of_nat k) * (a - 1 gchoose (k - 1))\"\n by sorry\n\ntext \\The absorption identity is written in the following form to avoid\ndivision by $k$ (the lower index) and therefore remove the $k \\neq 0$\nrestriction \\<^cite>\\\\p.~157\\ in GKP_CM\\:\n\\[\nk{r \\choose k} = r{r - 1 \\choose k - 1}, \\quad \\textnormal{integer } k.\n\\]\\\nlemma gbinomial_absorption: \"of_nat (Suc k) * (a gchoose Suc k) = a * ((a - 1) gchoose k)\"\n by sorry\n\ntext \\The absorption identity for natural number binomial coefficients:\\\nlemma binomial_absorption: \"Suc k * (n choose Suc k) = n * ((n - 1) choose k)\"\n by sorry\n\ntext \\The absorption companion identity for natural number coefficients,\n following the proof by GKP \\<^cite>\\\\p.~157\\ in GKP_CM\\:\\\nlemma binomial_absorb_comp: \"(n - k) * (n choose k) = n * ((n - 1) choose k)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\ntext \\The generalised absorption companion identity:\\\nlemma gbinomial_absorb_comp: \"(a - of_nat k) * (a gchoose k) = a * ((a - 1) gchoose k)\"\n by sorry\n\nlemma gbinomial_addition_formula:\n \"a gchoose (Suc k) = ((a - 1) gchoose (Suc k)) + ((a - 1) gchoose k)\"\n by sorry\n\nlemma binomial_addition_formula:\n \"0 < n \\ n choose (Suc k) = ((n - 1) choose (Suc k)) + ((n - 1) choose k)\"\n by sorry\n\ntext \\\n Equation 5.9 of the reference material \\<^cite>\\\\p.~159\\ in GKP_CM\\ is a useful\n summation formula, operating on both indices:\n \\[\n \\sum\\limits_{k \\leq n}{r + k \\choose k} = {r + n + 1 \\choose n},\n \\quad \\textnormal{integer } n.\n \\]\n\\\nlemma gbinomial_parallel_sum: \"(\\k\\n. (a + of_nat k) gchoose k) = (a + of_nat n + 1) gchoose n\"\n by sorry\n\nsubsection \\Summation on the upper index\\\n\ntext \\\n Another summation formula is equation 5.10 of the reference material \\<^cite>\\\\p.~160\\ in GKP_CM\\,\n aptly named \\emph{summation on the upper index}:\\[\\sum_{0 \\leq k \\leq n} {k \\choose m} =\n {n + 1 \\choose m + 1}, \\quad \\textnormal{integers } m, n \\geq 0.\\]\n\\\nlemma gbinomial_sum_up_index:\n \"(\\j = 0..n. (of_nat j gchoose k) :: 'a::field_char_0) = (of_nat n + 1) gchoose (k + 1)\"\n by sorry\n\nlemma gbinomial_index_swap:\n \"((-1) ^ k) * ((- (of_nat n) - 1) gchoose k) = ((-1) ^ n) * ((- (of_nat k) - 1) gchoose n)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma gbinomial_sum_lower_neg: \"(\\k\\m. (a gchoose k) * (- 1) ^ k) = (- 1) ^ m * (a - 1 gchoose m)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma gbinomial_partial_row_sum:\n \"(\\k\\m. (a gchoose k) * ((a / 2) - of_nat k)) = ((of_nat m + 1)/2) * (a gchoose (m + 1))\"\n by sorry\n\nlemma sum_bounds_lt_plus1: \"(\\kk=1..mm. f k)\"\n by sorry\n\nlemma gbinomial_partial_sum_poly:\n \"(\\k\\m. (of_nat m + a gchoose k) * x^k * y^(m-k)) =\n (\\k\\m. (-a gchoose k) * (-x)^k * (x + y)^(m-k))\"\n (is \"?lhs m = ?rhs m\")\n by sorry\n\nlemma gbinomial_partial_sum_poly_xpos:\n \"(\\k\\m. (of_nat m + a gchoose k) * x^k * y^(m-k)) =\n (\\k\\m. (of_nat k + a - 1 gchoose k) * x^k * (x + y)^(m-k))\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma binomial_r_part_sum: \"(\\k\\m. (2 * m + 1 choose k)) = 2 ^ (2 * m)\"\n by sorry\n\nlemma gbinomial_r_part_sum: \"(\\k\\m. (2 * (of_nat m) + 1 gchoose k)) = 2 ^ (2 * m)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma gbinomial_sum_nat_pow2:\n \"(\\k\\m. (of_nat (m + k) gchoose k :: 'a::field_char_0) / 2 ^ k) = 2 ^ m\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma gbinomial_trinomial_revision:\n assumes \"k \\ m\"\n shows \"(a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))\"\n by sorry\n\ntext \\Versions of the theorems above for the natural-number version of \"choose\"\\\nlemma binomial_altdef_of_nat:\n \"k \\ n \\ of_nat (n choose k) = (\\i = 0.. n \\ (of_nat n / of_nat k :: 'a) ^ k \\ of_nat (n choose k)\"\n for k n :: nat and x :: \"'a::linordered_field\"\n by sorry\n\nlemma binomial_le_pow:\n assumes \"r \\ n\"\n shows \"n choose r \\ n ^ r\"\n by sorry\n\nlemma choose_dvd:\n assumes \"k \\ n\" shows \"fact k * fact (n - k) dvd (fact n)\"\n by sorry\n\nlemma fact_fact_dvd_fact:\n \"fact k * fact n dvd (fact (k + n))\"\n by sorry\n\nlemma choose_mult_lemma:\n \"((m + r + k) choose (m + k)) * ((m + k) choose k) = ((m + r + k) choose k) * ((m + r) choose m)\"\n (is \"?lhs = _\")\n by sorry\n\ntext \\The \"Subset of a Subset\" identity.\\\nlemma choose_mult:\n \"k \\ m \\ m \\ n \\ (n choose m) * (m choose k) = (n choose k) * ((n - k) choose (m - k))\"\n by sorry\n\nlemma of_nat_binomial_eq_mult_binomial_Suc:\n assumes \"k \\ n\"\n shows \"(of_nat :: (nat \\ ('a :: field_char_0))) (n choose k) = of_nat (n + 1 - k) / of_nat (n + 1) * of_nat (Suc n choose k)\"\n by sorry\n\nsubsection \\More on Binomial Coefficients\\\n\ntext \\The number of nat lists of length \\m\\ summing to \\N\\ is \\<^term>\\(N + m - 1) choose N\\:\\\nlemma card_length_sum_list_rec:\n assumes \"m \\ 1\"\n shows \"card {l::nat list. length l = m \\ sum_list l = N} =\n card {l. length l = (m - 1) \\ sum_list l = N} +\n card {l. length l = m \\ sum_list l + 1 = N}\"\n (is \"card ?C = card ?A + card ?B\")\n by sorry\n\nlemma card_length_sum_list: \"card {l::nat list. size l = m \\ sum_list l = N} = (N + m - 1) choose N\"\n \\ \\by Holden Lee, tidied by Tobias Nipkow\\\n by sorry\n\nlemma card_disjoint_shuffles:\n assumes \"set xs \\ set ys = {}\"\n shows \"card (shuffles xs ys) = (length xs + length ys) choose length xs\"\n by sorry\n\nlemma Suc_times_binomial_add: \"Suc a * (Suc (a + b) choose Suc a) = Suc b * (Suc (a + b) choose a)\"\n \\ \\by Lukas Bulwahn\\\n by sorry\n\nsubsection \\Inclusion-exclusion principle\\\n\ntext \\Ported from HOL Light by lcp\\\n\nlemma Inter_over_Union:\n \"\\ {\\ (\\ x) |x. x \\ S} = \\ {\\ (G ` S) |G. \\x\\S. G x \\ \\ x}\" \n by sorry\n\nlemma subset_insert_lemma:\n \"{T. T \\ (insert a S) \\ P T} = {T. T \\ S \\ P T} \\ {insert a T |T. T \\ S \\ P(insert a T)}\" (is \"?L=?R\")\n by sorry\n\ntext\\Versions for additive real functions, where the additivity applies only to some\n specific subsets (e.g. cardinality of finite sets, measurable sets with bounded measure.\n (From HOL Light)\\\n\nlocale Incl_Excl =\n fixes P :: \"'a set \\ bool\" and f :: \"'a set \\ 'b::ring_1\"\n assumes disj_add: \"\\P S; P T; disjnt S T\\ \\ f(S \\ T) = f S + f T\"\n and empty: \"P{}\"\n and Int: \"\\P S; P T\\ \\ P(S \\ T)\"\n and Un: \"\\P S; P T\\ \\ P(S \\ T)\"\n and Diff: \"\\P S; P T\\ \\ P(S - T)\"\n\nbegin\n\nlemma f_empty [simp]: \"f{} = 0\"\n by sorry\n\nlemma f_Un_Int: \"\\P S; P T\\ \\ f(S \\ T) + f(S \\ T) = f S + f T\"\n by sorry\n\nlemma restricted_indexed:\n assumes \"finite A\" and X: \"\\a. a \\ A \\ P(X a)\"\n shows \"f(\\(X ` A)) = (\\B | B \\ A \\ B \\ {}. (- 1) ^ (card B + 1) * f (\\ (X ` B)))\"\n by sorry\n\nlemma restricted:\n assumes \"finite A\" \"\\a. a \\ A \\ P a\"\n shows \"f(\\ A) = (\\B | B \\ A \\ B \\ {}. (- 1) ^ (card B + 1) * f (\\ B))\"\n by sorry\n\nend\n\nsubsection\\Versions for unrestrictedly additive functions\\\n\nlemma Incl_Excl_UN:\n fixes f :: \"'a set \\ 'b::ring_1\"\n assumes \"\\S T. disjnt S T \\ f(S \\ T) = f S + f T\" \"finite A\"\n shows \"f(\\(G ` A)) = (\\B | B \\ A \\ B \\ {}. (-1) ^ (card B + 1) * f (\\ (G ` B)))\"\n by sorry\n\nlemma Incl_Excl_Union:\n fixes f :: \"'a set \\ 'b::ring_1\"\n assumes \"\\S T. disjnt S T \\ f(S \\ T) = f S + f T\" \"finite A\"\n shows \"f(\\ A) = (\\B | B \\ A \\ B \\ {}. (- 1) ^ (card B + 1) * f (\\ B))\"\n by sorry\n\ntext \\The famous inclusion-exclusion formula for the cardinality of a union\\\nlemma int_card_UNION:\n assumes \"finite A\" \"\\K. K \\ A \\ finite K\"\n shows \"int (card (\\A)) = (\\I | I \\ A \\ I \\ {}. (- 1) ^ (card I + 1) * int (card (\\I)))\"\n by sorry" }, { "theorem_id": 39, "title": "044_the_binomial_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Patrick Stevens\n-/\nmodule\n\npublic import Mathlib.Algebra.BigOperators.Intervals\npublic import Mathlib.Algebra.BigOperators.NatAntidiagonal\npublic import Mathlib.Algebra.BigOperators.Ring.Finset\npublic import Mathlib.Algebra.Order.BigOperators.Group.Finset\npublic import Mathlib.Tactic.Linarith\npublic import Mathlib.Tactic.Ring\n\n/-!\n# Sums of binomial coefficients\n\nThis file includes variants of the binomial theorem and other results on sums of binomial\ncoefficients. Theorems whose proofs depend on such sums may also go in this file for import\nreasons.\n-/\n\npublic section\n\nopen Nat Finset\n\nvariable {R : Type*}\n\nnamespace Commute\n\nvariable [Semiring R] {x y : R}\n\n/-- A version of the **binomial theorem** for commuting elements in noncommutative semirings. -/\ntheorem add_pow (h : Commute x y) (n : ℕ) :\n (x + y) ^ n = ∑ m ∈ range (n + 1), x ^ m * y ^ (n - m) * n.choose m := by sorry\ntheorem add_pow' (h : Commute x y) (n : ℕ) :\n (x + y) ^ n = ∑ m ∈ antidiagonal n, n.choose m.1 • (x ^ m.1 * y ^ m.2) := by sorry\nend Commute\n\n/-- The **binomial theorem** -/\ntheorem add_pow [CommSemiring R] (x y : R) (n : ℕ) :\n (x + y) ^ n = ∑ m ∈ range (n + 1), x ^ m * y ^ (n - m) * n.choose m :=\n (Commute.all x y).add_pow n\n\n/-- A special case of the **binomial theorem** -/\ntheorem sub_pow [CommRing R] (x y : R) (n : ℕ) :\n (x - y) ^ n = ∑ m ∈ range (n + 1), (-1) ^ (m + n) * x ^ m * y ^ (n - m) * n.choose m := by sorry\nnamespace Nat\n\n/-- The sum of entries in a row of Pascal's triangle -/\ntheorem sum_range_choose (n : ℕ) : (∑ m ∈ range (n + 1), n.choose m) = 2 ^ n := by sorry\ntheorem sum_range_choose_halfway (m : ℕ) : (∑ i ∈ range (m + 1), (2 * m + 1).choose i) = 4 ^ m :=\n have : (∑ i ∈ range (m + 1), (2 * m + 1).choose (2 * m + 1 - i)) =\n ∑ i ∈ range (m + 1), (2 * m + 1).choose i :=\n sum_congr rfl fun i hi ↦ choose_symm <| by linarith [mem_range.1 hi]\n mul_right_injective₀ two_ne_zero <|\n calc\n (2 * ∑ i ∈ range (m + 1), (2 * m + 1).choose i) =\n (∑ i ∈ range (m + 1), (2 * m + 1).choose i) +\n ∑ i ∈ range (m + 1), (2 * m + 1).choose (2 * m + 1 - i) := by rw [two_mul, this]\n _ = (∑ i ∈ range (m + 1), (2 * m + 1).choose i) +\n ∑ i ∈ Ico (m + 1) (2 * m + 2), (2 * m + 1).choose i := by sorry\ntheorem choose_middle_le_pow (n : ℕ) : (2 * n + 1).choose n ≤ 4 ^ n := by sorry\ntheorem four_pow_le_two_mul_add_one_mul_central_binom (n : ℕ) :\n 4 ^ n ≤ (2 * n + 1) * (2 * n).choose n :=\n calc\n 4 ^ n = (1 + 1) ^ (2 * n) := by simp [pow_mul]\n _ = ∑ m ∈ range (2 * n + 1), (2 * n).choose m := by simp [-Nat.reduceAdd, add_pow]\n _ ≤ ∑ _ ∈ range (2 * n + 1), (2 * n).choose (2 * n / 2) := by gcongr; apply choose_le_middle\n _ = (2 * n + 1) * choose (2 * n) n := by simp\n\n/-- **Zhu Shijie's identity** aka hockey-stick identity, version with `Icc`. -/\ntheorem sum_Icc_choose (n k : ℕ) : ∑ m ∈ Icc k n, m.choose k = (n + 1).choose (k + 1) := by sorry\nlemma sum_range_add_choose (n k : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (i + k).choose k = (n + k + 1).choose (k + 1) := by sorry\ntheorem sum_range_mul_choose (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), i * (n.choose i) = n * 2 ^ (n - 1) := by sorry\nlemma sum_range_multichoose (n k : ℕ) :\n ∑ i ∈ Finset.range (n + 1), k.multichoose i = (n + k).choose k := by sorry\nend Nat\n\ntheorem Int.alternating_sum_range_choose_eq_choose {n m : ℕ} :\n (∑ k ∈ range (m + 1), ((-1) ^ k * (n + 1).choose k : ℤ)) = (-1) ^ m * n.choose m := by sorry\ntheorem Int.alternating_sum_range_choose {n : ℕ} :\n (∑ m ∈ range (n + 1), ((-1) ^ m * n.choose m : ℤ)) = if n = 0 then 1 else 0 := by sorry\ntheorem Int.alternating_sum_range_choose_of_ne {n : ℕ} (h0 : n ≠ 0) :\n (∑ m ∈ range (n + 1), ((-1) ^ m * n.choose m : ℤ)) = 0 := by sorry\nnamespace Finset\n\ntheorem sum_powerset_apply_card {α β : Type*} [AddCommMonoid α] (f : ℕ → α) {x : Finset β} :\n ∑ m ∈ x.powerset, f #m = ∑ m ∈ range (#x + 1), (#x).choose m • f m := by sorry\ntheorem sum_powerset_neg_one_pow_card {α : Type*} [DecidableEq α] {x : Finset α} :\n (∑ m ∈ x.powerset, (-1 : ℤ) ^ #m) = if x = ∅ then 1 else 0 := by sorry\ntheorem sum_powerset_neg_one_pow_card_of_nonempty {α : Type*} {x : Finset α} (h0 : x.Nonempty) :\n (∑ m ∈ x.powerset, (-1 : ℤ) ^ #m) = 0 := by sorry\nvariable [NonAssocSemiring R]\n\n@[to_additive sum_choose_succ_nsmul]\ntheorem prod_pow_choose_succ {M : Type*} [CommMonoid M] (f : ℕ → ℕ → M) (n : ℕ) :\n (∏ i ∈ range (n + 2), f i (n + 1 - i) ^ (n + 1).choose i) =\n (∏ i ∈ range (n + 1), f i (n + 1 - i) ^ n.choose i) *\n ∏ i ∈ range (n + 1), f (i + 1) (n - i) ^ n.choose i := by sorry\ntheorem prod_antidiagonal_pow_choose_succ {M : Type*} [CommMonoid M] (f : ℕ → ℕ → M) (n : ℕ) :\n (∏ ij ∈ antidiagonal (n + 1), f ij.1 ij.2 ^ (n + 1).choose ij.1) =\n (∏ ij ∈ antidiagonal n, f ij.1 (ij.2 + 1) ^ n.choose ij.1) *\n ∏ ij ∈ antidiagonal n, f (ij.1 + 1) ij.2 ^ n.choose ij.2 := by sorry\ntheorem sum_choose_succ_mul (f : ℕ → ℕ → R) (n : ℕ) :\n (∑ i ∈ range (n + 2), ((n + 1).choose i : R) * f i (n + 1 - i)) =\n (∑ i ∈ range (n + 1), (n.choose i : R) * f i (n + 1 - i)) +\n ∑ i ∈ range (n + 1), (n.choose i : R) * f (i + 1) (n - i) := by sorry\ntheorem sum_antidiagonal_choose_succ_mul (f : ℕ → ℕ → R) (n : ℕ) :\n (∑ ij ∈ antidiagonal (n + 1), ((n + 1).choose ij.1 : R) * f ij.1 ij.2) =\n (∑ ij ∈ antidiagonal n, (n.choose ij.1 : R) * f ij.1 (ij.2 + 1)) +\n ∑ ij ∈ antidiagonal n, (n.choose ij.2 : R) * f (ij.1 + 1) ij.2 := by sorry\ntheorem sum_antidiagonal_choose_add (d n : ℕ) :\n (∑ ij ∈ antidiagonal n, (d + ij.2).choose d) = (d + n + 1).choose (d + 1) := by sorry\nend Finset\n" }, { "theorem_id": 39, "title": "044_the_binomial_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From Stdlib Require Import Rbase.\nFrom Stdlib Require Import Rfunctions.\nFrom Stdlib Require Import PartSum.\nFrom Stdlib Require Import Arith.Factorial.\n#[local] Open Scope R_scope.\n\nDefinition C (n p:nat) : R :=\n INR (fact n) / (INR (fact p) * INR (fact (n - p))).\n\nLemma pascal_step1 : forall n i:nat, (i <= n)%nat -> C n i = C n (n - i).\nProof.\nAdmitted.\n\nLemma pascal_step2 :\n forall n i:nat,\n (i <= n)%nat -> C (S n) i = INR (S n) / INR (S n - i) * C n i.\nProof.\nAdmitted.\n\nLemma pascal_step3 :\n forall n i:nat, (i < n)%nat -> C n (S i) = INR (n - i) / INR (S i) * C n i.\nProof.\nAdmitted.\n\nLemma pascal :\n forall n i:nat, (i < n)%nat -> C n i + C n (S i) = C (S n) (S i).\nProof.\nAdmitted.\n\nLemma binomial :\n forall (x y:R) (n:nat),\n (x + y) ^ n = sum_f_R0 (fun i:nat => C n i * x ^ i * y ^ (n - i)) n.\nProof.\nAdmitted." }, { "theorem_id": 40, "title": "046_the_solution_of_the_general_quartic_equation", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "prioritize_real();;\n\nlet QUARTIC_1 = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n R = &0 /\\\n s pow 2 = y pow 2 - &4 * d /\\\n D pow 2 = &3 * a pow 2 / &4 - &2 * b + &2 * s /\\\n x = --a / &4 + R / &2 + D / &2\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_2 = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n R = &0 /\\\n s pow 2 = y pow 2 - &4 * d /\\\n D pow 2 = &3 * a pow 2 / &4 - &2 * b + &2 * s /\\\n x = --a / &4 + R / &2 - D / &2\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_3 = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n R = &0 /\\\n s pow 2 = y pow 2 - &4 * d /\\\n E pow 2 = &3 * a pow 2 / &4 - &2 * b - &2 * s /\\\n x = --a / &4 - R / &2 + E / &2\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_4 = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n R = &0 /\\\n s pow 2 = y pow 2 - &4 * d /\\\n E pow 2 = &3 * a pow 2 / &4 - &2 * b - &2 * s /\\\n x = --a / &4 - R / &2 - E / &2\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_1' = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n ~(R = &0) /\\\n D pow 2 = &3 * a pow 2 / &4 - R pow 2 - &2 * b +\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R) /\\\n x = --a / &4 + R / &2 + D / &2\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_2' = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n ~(R = &0) /\\\n D pow 2 = &3 * a pow 2 / &4 - R pow 2 - &2 * b +\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R) /\\\n x = --a / &4 + R / &2 - D / &2\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_3' = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n ~(R = &0) /\\\n E pow 2 = &3 * a pow 2 / &4 - R pow 2 - &2 * b -\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R) /\\\n x = --a / &4 - R / &2 + E / &2\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_4' = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n ~(R = &0) /\\\n E pow 2 = &3 * a pow 2 / &4 - R pow 2 - &2 * b -\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R) /\\\n x = --a / &4 - R / &2 - E / &2\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_1 = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n s pow 2 = y pow 2 - &4 * d /\\\n (D pow 2 = if R = &0 then &3 * a pow 2 / &4 - &2 * b + &2 * s\n else &3 * a pow 2 / &4 - R pow 2 - &2 * b +\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R)) /\\\n x = --a / &4 + R / &2 + D / &2\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_1 = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n s pow 2 = y pow 2 - &4 * d /\\\n (D pow 2 = if R = &0 then &3 * a pow 2 / &4 - &2 * b + &2 * s\n else &3 * a pow 2 / &4 - R pow 2 - &2 * b +\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R)) /\\\n (E pow 2 = if R = &0 then &3 * a pow 2 / &4 - &2 * b - &2 * s\n else &3 * a pow 2 / &4 - R pow 2 - &2 * b -\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R)) /\\\n (x = --a / &4 + R / &2 + D / &2 \\/\n x = --a / &4 - R / &2 + E / &2)\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_CASES = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n s pow 2 = y pow 2 - &4 * d /\\\n (D pow 2 = if R = &0 then &3 * a pow 2 / &4 - &2 * b + &2 * s\n else &3 * a pow 2 / &4 - R pow 2 - &2 * b +\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R)) /\\\n (E pow 2 = if R = &0 then &3 * a pow 2 / &4 - &2 * b - &2 * s\n else &3 * a pow 2 / &4 - R pow 2 - &2 * b -\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R)) /\\\n (x = --a / &4 + R / &2 + D / &2 \\/\n x = --a / &4 + R / &2 - D / &2 \\/\n x = --a / &4 - R / &2 + E / &2 \\/\n x = --a / &4 - R / &2 - E / &2)\n ==> x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0`;;\n\nlet QUARTIC_CASES = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n s pow 2 = y pow 2 - &4 * d /\\\n (D pow 2 = if R = &0 then &3 * a pow 2 / &4 - &2 * b + &2 * s\n else &3 * a pow 2 / &4 - R pow 2 - &2 * b +\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R)) /\\\n (E pow 2 = if R = &0 then &3 * a pow 2 / &4 - &2 * b - &2 * s\n else &3 * a pow 2 / &4 - R pow 2 - &2 * b -\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R))\n ==> (x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0 <=>\n x = --a / &4 + R / &2 + D / &2 \\/\n x = --a / &4 + R / &2 - D / &2 \\/\n x = --a / &4 - R / &2 + E / &2 \\/\n x = --a / &4 - R / &2 - E / &2)`;;\n\nlet QUARTIC_CASES = `y pow 3 - b * y pow 2 + (a * c - &4 * d) * y -\n a pow 2 * d + &4 * b * d - c pow 2 = &0 /\\\n R pow 2 = a pow 2 / &4 - b + y /\\\n s pow 2 = y pow 2 - &4 * d /\\\n (D pow 2 = if R = &0 then &3 * a pow 2 / &4 - &2 * b + &2 * s\n else &3 * a pow 2 / &4 - R pow 2 - &2 * b +\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R)) /\\\n (E pow 2 = if R = &0 then &3 * a pow 2 / &4 - &2 * b - &2 * s\n else &3 * a pow 2 / &4 - R pow 2 - &2 * b -\n (&4 * a * b - &8 * c - a pow 3) / (&4 * R))\n ==> (x pow 4 + a * x pow 3 + b * x pow 2 + c * x + d = &0 <=>\n x = --a / &4 + R / &2 + D / &2 \\/\n x = --a / &4 + R / &2 - D / &2 \\/\n x = --a / &4 - R / &2 + E / &2 \\/\n x = --a / &4 - R / &2 - E / &2)`;;" }, { "theorem_id": 40, "title": "046_the_solution_of_the_general_quartic_equation", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Ferrari's formula for solving quartic equations\\\n\ntheory Ferraris_Formula\n imports \n Polynomial_Factorization.Explicit_Roots\n Polynomial_Interpolation.Ring_Hom_Poly\n Complex_Geometry.More_Complex\nbegin\n\nsubsection \\Translation to depressed case\\\n\ntext \\Solving an arbitrary quartic equation can easily be turned into the depressed case, i.e., where\n there is no cubic part.\\\n\nlemma to_depressed_quartic: fixes a4 :: \"'a :: field_char_0\"\n assumes a4: \"a4 \\ 0\" \n and b: \"b = a3 / a4\" \n and c: \"c = a2 / a4\" \n and d: \"d = a1 / a4\" \n and e: \"e = a0 / a4\" \n and p: \"p = c - (3/8) * b^2\" \n and q: \"q = (b^3 - 4*b*c + 8 * d) / 8\" \n and r: \"r = ( -3 * b^4 + 256 * e - 64 * b * d + 16 * b^2 * c) / 256\" \n and x: \"x = y - b/4\" \nshows \"a4 * x^4 + a3 * x^3 + a2 * x^2 + a1 * x + a0 = 0 \n \\ y^4 + p * y^2 + q * y + r = 0\" \n by sorry\n\nlemma biquadratic_solution: fixes p q :: \"'a :: field_char_0\"\n shows \"y^4 + p * y^2 + q = 0 \\ (\\ z. z^2 + p * z + q = 0 \\ z = y^2)\" \n by sorry\n\nsubsection \\Solving the depressed case via Ferrari's formula\\\n\nlemma depressed_quartic_Ferrari: fixes p q r :: \"'a :: field_char_0\" \n assumes cubic_root: \"8*m^3 + (8 * p) * m^2 + (2 * p^2 - 8 * r) * m - q^2 = 0\" \n and q0: \"q \\ 0\" \\ \\otherwise m might be zero, so a is zero and then there is a division by zero in b1 and b2\\\n and sqrt: \"a * a = 2 * m\" \n and b1: \"b1 = p / 2 + m - q / (2 * a)\" \n and b2: \"b2 = p / 2 + m + q / (2 * a)\" \n shows \"y^4 + p * y^2 + q * y + r = 0 \\ poly [:b1,a,1:] y = 0 \\ poly [:b2,-a,1:] y = 0\" \n by sorry\n\nend" }, { "theorem_id": 40, "title": "046_the_solution_of_the_general_quartic_equation", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2022 Jeoff Lee. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeoff Lee, Thomas Zhu\n-/\nimport Mathlib.Tactic.LinearCombination\nimport Mathlib.RingTheory.Polynomial.Cyclotomic.Roots\n\n/-!\n# The roots of cubic and quartic polynomials\n\nThis file proves Theorem 37 and 46 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/).\n\nWe give the solutions to the cubic equation `a * x^3 + b * x^2 + c * x + d = 0` over a field `K`\nthat has characteristic neither 2 nor 3, that has a third primitive root of\nunity, and in which certain other quantities admit square and cube roots. This is based on the\n[Cardano's Formula](https://en.wikipedia.org/wiki/Cubic_equation#Cardano's_formula).\n\nWe also give solutions to the quartic equation `a * x^4 + b * x^3 + c * x^2 + d * x + e = 0` over\na field `K` that is not characteristic 2, and in which certain quantities admit square roots, in\nterms of a quantity that is a root of a particular cubic equation.\n\n## Main statements\n\n- `cubic_eq_zero_iff`: gives the roots of the cubic equation\n where the discriminant `p = 3 * a * c - b^2` is nonzero.\n- `cubic_eq_zero_iff_of_p_eq_zero`: gives the roots of the cubic equation\n where the discriminant equals zero.\n- `quartic_eq_zero_iff`: gives the roots of the quartic equation\n where the quantity `b^3 - 4 * a * b * c + 8 * a^2 * d` is nonzero, in terms of a root `u`\n to a cubic resolvent.\n- `quartic_eq_zero_iff_of_q_eq_zero`: gives the roots of the quartic equation\n where the quantity `b^3 - 4 * a * b * c + 8 * a^2 * d` equals zero.\n\n## Proof outline\n\nProofs of the cubic and quartic formulas are similar in outline.\n\nFor a cubic:\n1. Given cubic $ax^3 + bx^2 + cx + d = 0$, we show it is equivalent to some \"depressed cubic\"\n $y^3 + 3py - 2q = 0$ where $y = x + b / (3a)$, $p = (3ac - b^2) / (9a^2)$, and\n $q = (9abc - 2b^3 - 27a^2d) / (54a^3)$ (`h₁` in `cubic_eq_zero_iff`).\n2. When $p$ is zero, this is easily solved (`cubic_eq_zero_iff_of_p_eq_zero`).\n3. Otherwise one can directly derive a factorization of the depressed cubic, in terms of some\n primitive cube root of unity $\\omega^3 = 1$ (`cubic_depressed_eq_zero_iff`).\n\nSimilarly, for a quartic:\n1. Given quartic $ax^4 + bx^3 + cx^2 + dx + e = 0$, it is equivalent to some \"depressed quartic\"\n $y^4 + py^2 + qy + r = 0$ where $y = x + b / (4a)$, $p = (8ac - 3b^2) / (8a^2))$,\n $q = b^3 - 4abc + 8a^2d) / (8a^3))$, and $r = (16ab^2c + 256a^3e - 3b^4 - 64a^2bd) / (256a^4)$\n (`h₁` in `quartic_eq_zero_iff`).\n2. When $q$ is zero, this is easily solved as a quadratic in $y^2$\n (`quartic_eq_zero_iff_of_q_eq_zero`).\n3. Otherwise one can directly derive a factorization of the depressed quartic into two quadratics,\n in terms of some root of the *cubic resolvent* $u^3 - pu^2 - 4ru + 4pr - q^2 = 0$\n (`quartic_depressed_eq_zero_iff`).\n\n## References\n\nThe cubic formula was originally ported from Isabelle/HOL. The\n[original file](https://isabelle.in.tum.de/dist/library/HOL/HOL-ex/Cubic_Quartic.html) was written by Amine Chaieb.\n\nThe proof of the quartic formula is similar in structure to the cubic, and uses the formulation in\n[Zwillinger, *CRC Standard Mathematical Tables and Formulae*](zwillinger2003).\n\n## Tags\n\npolynomial, cubic, quartic, root\n-/\n\n\nnamespace Theorems100\n\nsection Field\n\nopen Polynomial\n\nvariable {K : Type*} [Field K] (a b c d e : K) {ω p q r s t u v w x y : K}\n\nsection Cubic\n\ntheorem cube_root_of_unity_sum (hω : IsPrimitiveRoot ω 3) : 1 + ω + ω ^ 2 = 0 := by sorry\ntheorem cubic_depressed_eq_zero_iff (hω : IsPrimitiveRoot ω 3) (hp_nonzero : p ≠ 0)\n (hr : r ^ 2 = q ^ 2 + p ^ 3) (hs3 : s ^ 3 = q + r) (ht : t * s = p) (x : K) :\n x ^ 3 + 3 * p * x - 2 * q = 0 ↔ x = s - t ∨ x = s * ω - t * ω ^ 2 ∨ x = s * ω ^ 2 - t * ω := by sorry\nvariable [Invertible (2 : K)] [Invertible (3 : K)]\n\n/-- **The Solution of Cubic**.\n The roots of a cubic polynomial whose discriminant is nonzero. -/\ntheorem cubic_eq_zero_iff (ha : a ≠ 0) (hω : IsPrimitiveRoot ω 3)\n (hp : p = (3 * a * c - b ^ 2) / (9 * a ^ 2)) (hp_nonzero : p ≠ 0)\n (hq : q = (9 * a * b * c - 2 * b ^ 3 - 27 * a ^ 2 * d) / (54 * a ^ 3))\n (hr : r ^ 2 = q ^ 2 + p ^ 3) (hs3 : s ^ 3 = q + r) (ht : t * s = p) (x : K) :\n a * x ^ 3 + b * x ^ 2 + c * x + d = 0 ↔\n x = s - t - b / (3 * a) ∨\n x = s * ω - t * ω ^ 2 - b / (3 * a) ∨ x = s * ω ^ 2 - t * ω - b / (3 * a) := by sorry\ntheorem cubic_eq_zero_iff_of_p_eq_zero (ha : a ≠ 0) (hω : IsPrimitiveRoot ω 3)\n (hpz : 3 * a * c - b ^ 2 = 0)\n (hq : q = (9 * a * b * c - 2 * b ^ 3 - 27 * a ^ 2 * d) / (54 * a ^ 3)) (hs3 : s ^ 3 = 2 * q)\n (x : K) :\n a * x ^ 3 + b * x ^ 2 + c * x + d = 0 ↔\n x = s - b / (3 * a) ∨ x = s * ω - b / (3 * a) ∨ x = s * ω ^ 2 - b / (3 * a) := by sorry\nend Cubic\n\nsection Quartic\n\nvariable [Invertible (2 : K)]\n\n/-- Roots of a quartic whose cubic term is zero and linear term is nonzero,\n In terms of some `u` that satisfies a particular cubic resolvent. -/\ntheorem quartic_depressed_eq_zero_iff\n (hq_nonzero : q ≠ 0)\n (hu : u ^ 3 - p * u ^ 2 - 4 * r * u + 4 * p * r - q ^ 2 = 0)\n (hs : s ^ 2 = u - p)\n (hv : v ^ 2 = 4 * s ^ 2 - 8 * (u - q / s))\n (hw : w ^ 2 = 4 * s ^ 2 - 8 * (u + q / s))\n (x : K) :\n x ^ 4 + p * x ^ 2 + q * x + r = 0 ↔\n x = (-2 * s - v) / 4 ∨ x = (-2 * s + v) / 4 ∨ x = (2 * s - w) / 4 ∨ x = (2 * s + w) / 4 := by sorry\ntheorem quartic_eq_zero_iff (ha : a ≠ 0)\n (hp : p = (8 * a * c - 3 * b ^ 2) / (8 * a ^ 2))\n (hq : q = (b ^ 3 - 4 * a * b * c + 8 * a ^ 2 * d) / (8 * a ^ 3)) (hq_nonzero : q ≠ 0)\n (hr : r =\n (16 * a * b ^ 2 * c + 256 * a ^ 3 * e - 3 * b ^ 4 - 64 * a ^ 2 * b * d) / (256 * a ^ 4))\n (hu : u ^ 3 - p * u ^ 2 - 4 * r * u + 4 * p * r - q ^ 2 = 0)\n (hs : s ^ 2 = u - p)\n (hv : v ^ 2 = 4 * s ^ 2 - 8 * (u - q / s))\n (hw : w ^ 2 = 4 * s ^ 2 - 8 * (u + q / s)) (x : K) :\n a * x ^ 4 + b * x ^ 3 + c * x ^ 2 + d * x + e = 0 ↔\n x = (-2 * s - v) / 4 - b / (4 * a) ∨ x = (-2 * s + v) / 4 - b / (4 * a) ∨\n x = (2 * s - w) / 4 - b / (4 * a) ∨ x = (2 * s + w) / 4 - b / (4 * a) := by sorry\ntheorem quartic_eq_zero_iff_of_q_eq_zero (ha : a ≠ 0)\n (hp : p = (8 * a * c - 3 * b ^ 2) / (8 * a ^ 2))\n (hqz : b ^ 3 - 4 * a * b * c + 8 * a ^ 2 * d = 0)\n (hr : r =\n (16 * a * b ^ 2 * c + 256 * a ^ 3 * e - 3 * b ^ 4 - 64 * a ^ 2 * b * d) / (256 * a ^ 4))\n (ht : t ^ 2 = p ^ 2 - 4 * r)\n (hv : v ^ 2 = (-p + t) / 2)\n (hw : w ^ 2 = (-p - t) / 2) (x : K) :\n a * x ^ 4 + b * x ^ 3 + c * x ^ 2 + d * x + e = 0 ↔\n x = v - b / (4 * a) ∨ x = -v - b / (4 * a) ∨ x = w - b / (4 * a) ∨ x = -w - b / (4 * a) := by sorry\nend Quartic\n\nend Field\n\nend Theorems100\n" }, { "theorem_id": 40, "title": "046_the_solution_of_the_general_quartic_equation", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Reals Coq.Reals.Rtrigo_def Coquelicot.Coquelicot Coquelicot.ElemFct Lra.\n\nOpen Scope R_scope.\n\nLtac Rsimpl:=\nrepeat (\ntry rewrite Ropp_involutive;\ntry rewrite Ropp_0;\ntry rewrite Rplus_opp_l;\ntry rewrite Rplus_opp_r;\ntry rewrite Rplus_0_l;\ntry rewrite Rplus_0_r;\ntry rewrite Rmult_1_l;\ntry rewrite Rmult_1_r;\ntry rewrite Rmult_0_l;\ntry rewrite Rmult_0_r\n).\n\nLtac Csimpl:=\n repeat (\n try rewrite Copp_0;\n try rewrite Cplus_opp_r;\n try rewrite Cplus_0_l;\n try rewrite Cplus_0_r;\n try rewrite Cmult_0_r;\n try rewrite Cmult_1_r;\n try rewrite Cmult_0_l;\n try rewrite Cmult_1_l).\n\nLemma contraposition_neg : forall P Q:Prop, ( P -> Q ) -> ( (~Q) -> (~P)).\nProof.\nAdmitted.\n\nDefinition Csqrt:=fun (z:C) =>\nlet (u,v):=z in\nlet a:=(sqrt(((Cmod z)+u)/2))%R in\nlet b:=(if (Rneg_or_not z) \n then v/2/a\n else sqrt(-u))%R in\n(a,b)%C : C.\n\nLemma Csqrt_Cpow2 : forall z: C, (Csqrt z)*(Csqrt z)=z.\nProof.\nAdmitted.\n\nDefinition cargument (z: C) : R := \nif (Rneg_or_not z) then (INR 2)*atan((Im (Csqrt z))/(Re (Csqrt z))) \nelse PI.\n\nLemma trigoform: forall z : C,\n z=(cos(cargument z),sin(cargument z))*(Cmod z,0).\nProof.\nAdmitted.\n \nLemma factorisationdeg3 : forall z1 z2 z3:C, forall z:C, \n(z-z1)*(z-z2)*(z-z3)=Cpow z 3+(-(z1+z2+z3))*Cpow z 2+(z1*z2+z2*z3+z3*z1)*z+(-(z1*z2*z3)).\nProof.\nAdmitted.\n\nTheorem Cpowexp : forall n:nat, forall x:R, ((exp(x))^n=exp((INR n)*x)) % R.\nProof.\nAdmitted.\n\nTheorem comCpow: forall n : nat, forall z:C, forall u:C, (Cpow (z*u)%C n)=((Cpow z n)*(Cpow u n))%C.\nProof.\nAdmitted.\n\nLemma RCpow : forall n:nat,forall x:R, Cpow (x,0)%C n = ((x^n)%R,0)%C.\nProof.\nAdmitted.\n\nDefinition nroot (n:nat) (z:C) : C:= \nif Ceq_dec z 0 then 0 \nelse let argn:=((cargument z)/(INR n))%R in\n (cos(argn),sin(argn))*(exp((ln (Cmod z))/(INR n)),0).\n\nTheorem nroot_Cpown : forall n:nat,forall z:C,n<>O-> Cpow (nroot n z) n=z.\nProof.\nAdmitted.\n\nLemma nrootpositive : forall x:R, forall n:nat, 0<=x -> Im( nroot n x ) =0%R.\nProof.\nAdmitted.\n\nDefinition cubicroot (z:C) := if(Rcase_abs (Re z)) then -nroot 3 (-z) else nroot 3 z.\n\nLemma cubicroot3 : forall z:C, Cpow (cubicroot z) 3=z.\nProof.\nAdmitted.\n\nLemma cubicrootreal : forall (x:R), 0%R=Im (cubicroot x).\nProof.\nAdmitted.\n\nDefinition CJ := ((-/2)%R,(sqrt (3/4))%R)%C.\n\nLemma CJ2: CJ*CJ=-CJ-1.\nProof.\nAdmitted.\n\nLemma CJ3 : CJ*CJ*CJ=1%C.\nProof.\nAdmitted.\n\nLemma Cval2 : RtoC 2=RtoC 1+RtoC 1.\nProof.\nAdmitted.\nLemma Cval3 : RtoC 3=RtoC 1+RtoC 1+RtoC 1.\nProof.\nAdmitted.\nLemma Cval4: (RtoC 4=(RtoC 1+RtoC 1)*(RtoC 1+RtoC 1)).\nProof.\nAdmitted.\nLemma Cval6 : RtoC 6=(RtoC 1+RtoC 1+RtoC 1)*(RtoC 1+RtoC 1).\nProof.\nAdmitted.\nLemma Cval8 : RtoC 8=(RtoC 1+RtoC 1)*(RtoC 1+RtoC 1)*(RtoC 1+RtoC 1).\nProof.\nAdmitted.\n\nLemma shiftdeg3 : forall u:C, forall a b c:C, forall z:C, \nCpow (z+u) 3+a*Cpow (z+u) 2+b*(z+u)+c\n=Cpow z 3+(a+3*u)*Cpow z 2+(b+2*u*a+3*Cpow u 2)*z+(c+b*u+a*Cpow u 2+Cpow u 3).\nProof.\nAdmitted.\n\nLemma permprod: forall e f g:C, g*f*e=e*g*f.\nProof.\nAdmitted.\n\nLtac nneq0:=unfold RtoC;\ninjection;\nintro;\nlra.\n\nLtac developall:=\n unfold Cpow;\n repeat (try Csimpl;\n try rewrite Cmult_plus_distr_r;\n try rewrite Cmult_plus_distr_l);\n repeat (\n repeat rewrite (permprod CJ);\n repeat rewrite Cmult_assoc).\n\nDefinition Cardan_Tartaglia_formula:=fun (a1:C) (a2:C) (a3:C) (n:nat) =>\nlet s:=-a1/3 in \nlet p:=a2+2*s*a1+3*Cpow s 2 in\nlet q:=a3+a2*s+a1*Cpow s 2+Cpow s 3 in\nlet Delta:=(Cpow (q/2) 2)+(Cpow (p/3) 3) in\nlet alpha : C :=if(Ceq_dec p 0) then (RtoC 0) else (cubicroot (-(q/2)+Csqrt Delta)) in\nlet beta:=if(Ceq_dec p 0) then -cubicroot q else -(p/3)/alpha in\ns+(alpha*Cpow CJ n+beta*Cpow CJ (n+n)).\n\nTheorem Cardan_Tartaglia : forall a1 a2 a3 :C,\nlet u1:=(Cardan_Tartaglia_formula a1 a2 a3 0) in\nlet u2:=(Cardan_Tartaglia_formula a1 a2 a3 1) in\nlet u3:=(Cardan_Tartaglia_formula a1 a2 a3 2) in\nforall u:C, (u-u1)*(u-u2)*(u-u3)=Cpow u 3+a1*Cpow u 2+a2*u+a3.\nProof.\nAdmitted.\n\nLemma shiftdeg4 : forall u:C, forall a b c d:C, forall z:C, \nCpow (z+u) 4+a*Cpow (z+u) 3+b*Cpow (z+u) 2+c*(z+u)+d\n=Cpow z 4+(a+4*u)*Cpow z 3+(b+3*u*a+6*Cpow u 2)*Cpow z 2\n +(c+2*b*u+3*a*Cpow u 2+4*Cpow u 3)*z+(d+c*u+b*Cpow u 2+a*Cpow u 3+Cpow u 4).\nProof.\nAdmitted.\n\nDefinition binom_solution:= fun (b:C) (c:C) (n:nat) =>\n-b/2+(Csqrt (Cpow (b/2) 2-c))*Cpow (-1) n.\n\nLemma Binom_solution_proof : forall (b:C) (c:C), forall z:C,\nCpow z 2+b*z+c=(z-binom_solution b c 0)*(z-binom_solution b c 1).\nProof.\nAdmitted.\n\nTheorem Ferrari_formula: forall (a:C) (b:C) (c:C) (d:C), \nlet s:=-a/4 in \nlet p:= b+3*s*a+6*Cpow s 2 in\nlet q:= c+2*b*s+3*a*Cpow s 2+4*Cpow s 3 in\nlet r:= d+c*s+b*Cpow s 2+a*Cpow s 3+Cpow s 4 in\nlet lambda:=Cardan_Tartaglia_formula (-p/2) (-r) (r*p/2-/8*Cpow q 2) 0 in\nlet A:=Csqrt(2*lambda-p) in\nlet cond:=(Ceq_dec (2*lambda) p) in\nlet B:=if cond then (RtoC 0) else (-q/(2*A)) in\nlet z1:=if cond then Csqrt (binom_solution p r 0) \n else binom_solution A (B+lambda) 0 in\nlet z2:=if cond then -Csqrt (binom_solution p r 0) \n else binom_solution A (B+lambda) 1 in\nlet z3:=if cond then Csqrt (binom_solution p r 1) \n else binom_solution (-A) (-B+lambda) 0 in\nlet z4:=if cond then -Csqrt (binom_solution p r 1) \n else binom_solution (-A) (-B+lambda) 1 in\nlet u1:=z1+s in\nlet u2:=z2+s in\nlet u3:=z3+s in\nlet u4:=z4+s in\nforall u:C, (u-u1)*(u-u2)*(u-u3)*(u-u4)=Cpow u 4+a*Cpow u 3+b*Cpow u 2+c*u+d.\nProof.\nAdmitted." }, { "theorem_id": 41, "title": "049_the_cayley-hamilton_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/complexes.ml\";;\nneeds \"Multivariate/msum.ml\";;\n\nparse_as_infix(\"mpow\",(24,\"left\"));;\n\nlet mpow = define\n `(!A:real^N^N. A mpow 0 = (mat 1 :real^N^N)) /\\\n (!A:real^N^N n. A mpow (SUC n) = A ** A mpow n)`;;\n\nlet MPOW_ADD = `!A:real^N^N m n. A mpow (m + n) = A mpow m ** A mpow n`;;\n\nlet MPOW_1 = `!A:real^N^N. A mpow 1 = A`;;\n\nlet MPOW_SUC = `!A:real^N^N n. A mpow (SUC n) = A mpow n ** A`;;\n\nlet MATRIC_POLYFUN_EQ_0 = `!n A:num->real^N^M.\n (!x. msum(0..n) (\\i. x pow i %% A i) = mat 0) <=>\n (!i. i IN 0..n ==> A i = mat 0)`;;\n\nlet MATRIC_POLY_LEMMA = `!(A:real^N^N) B (C:real^N^N) n.\n (!x. msum (0..n) (\\i. (x pow i) %% B i) ** (A - x %% mat 1) = C)\n ==> C = mat 0`;;\n\nlet POLYFUN_N_CONST = `!c n. ?b. !x. c = sum(0..n) (\\i. b i * x pow i)`;;\n\nlet POLYFUN_N_ADD = `!f g. (?b. !x. f(x) = sum(0..n) (\\i. b i * x pow i)) /\\\n (?c. !x. g(x) = sum(0..n) (\\i. c i * x pow i))\n ==> ?d. !x. f(x) + g(x) = sum(0..n) (\\i. d i * x pow i)`;;\n\nlet POLYFUN_N_CMUL = `!f c. (?b. !x. f(x) = sum(0..n) (\\i. b i * x pow i))\n ==> ?b. !x. c * f(x) = sum(0..n) (\\i. b i * x pow i)`;;\n\nlet POLYFUN_N_SUM = `!f s. FINITE s /\\\n (!a. a IN s ==> ?b. !x. f x a = sum(0..n) (\\i. b i * x pow i))\n ==> ?b. !x. sum s (f x) = sum(0..n) (\\i. b i * x pow i)`;;\n\nlet POLYFUN_N_PRODUCT = `!f s n. FINITE s /\\\n (!a:A. a IN s ==> ?c d. !x. f x a = c + d * x) /\\ CARD(s) <= n\n ==> ?b. !x. product s (f x) = sum(0..n) (\\i. b i * x pow i)`;;\n\nlet COFACTOR_ENTRY_AS_POLYFUN = `!A:real^N^N x i j.\n 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> ?c. !x. cofactor(A - x %% mat 1)$i$j =\n sum(0..dimindex(:N)-1) (\\i. c(i) * x pow i)`;;\n\nlet DETERMINANT_AS_POLYFUN = `!A:real^N^N.\n ?c. !x. det(A - x %% mat 1) =\n sum(0..dimindex(:N)) (\\i. c(i) * x pow i)`;;\n\nlet char_poly = new_specification [\"char_poly\"]\n (REWRITE_RULE[SKOLEM_THM] DETERMINANT_AS_POLYFUN);;\n\nlet COFACTOR_AS_MATRIC_POLYNOMIAL = `!A:real^N^N. ?C.\n !x. cofactor(A - x %% mat 1) =\n msum(0..dimindex(:N)-1) (\\i. x pow i %% C i)`;;\n\nlet MATRIC_POWER_DIFFERENCE = `!A:real^N^N x n.\n A mpow (SUC n) - x pow (SUC n) %% mat 1 =\n msum (0..n) (\\i. x pow i %% A mpow (n - i)) ** (A - x %% mat 1)`;;\n\nlet MATRIC_CHARPOLY_DIFFERENCE = `!A:real^N^N. ?B.\n !x. msum(0..dimindex(:N)) (\\i. char_poly A i %% A mpow i) -\n sum(0..dimindex(:N)) (\\i. char_poly A i * x pow i) %% mat 1 =\n msum(0..(dimindex(:N)-1)) (\\i. x pow i %% B i) ** (A - x %% mat 1)`;;\n\nlet CAYLEY_HAMILTON = `!A:real^N^N. msum(0..dimindex(:N)) (\\i. char_poly A i %% A mpow i) = mat 0`;;" }, { "theorem_id": 41, "title": "049_the_cayley-hamilton_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory Cayley_Hamilton\nimports\n Square_Matrix\n \"HOL-Computational_Algebra.Polynomial\" \nbegin\n\ndefinition C :: \"'a \\ 'a::ring_1 poly\" where \"C c = [:c:]\"\nabbreviation CC (\\\\<^bold>C\\) where \"\\<^bold>C \\ map_sq_matrix C\"\n\nlemma degree_C[simp]: \"degree (C a) = 0\"\n by sorry\n\nlemma coeff_C_0[simp]: \"coeff (C x) 0 = x\"\n by sorry\n\nlemma coeff_C_gt0[simp]: \"0 < n \\ coeff (C x) n = 0\"\n by sorry\n\nlemma coeff_C_eq: \"coeff (C x) n = (if n = 0 then x else 0)\"\n by sorry\n\nlemma coeff_mult_C[simp]: \"coeff (a * C x) n = coeff a n * x\"\n by sorry\n\nlemma coeff_C_mult[simp]: \"coeff (C x * a) n = x * coeff a n\"\n by sorry\n\nlemma C_0[simp]: \"C 0 = 0\"\n by sorry\n\nlemma C_1[simp]: \"C 1 = 1\"\n by sorry\n\nlemma C_linear:\n shows C_mult: \"C (a * b) = C b * C a\"\n and C_add: \"C (a + b) = C a + C b\"\n and C_minus: \"C (- a) = - C a\"\n and C_diff: \"C (a - b) = C a - C b\"\n by sorry\n\ndefinition X :: \"'a::ring_1 poly\" where \"X = [:0, 1:]\"\nabbreviation XX (\\\\<^bold>X\\) where \"\\<^bold>X \\ diag X\"\n\nlemma degree_X[simp]: \"degree X = 1\"\n by sorry\n\nlemma coeff_X_Suc_0[simp]: \"coeff X (Suc 0) = 1\"\n by sorry\n\nlemma coeff_X_mult[simp]: \"coeff (X * p) (Suc i) = coeff p i\"\n by sorry\n\nlemma coeff_mult_X[simp]: \"coeff (p * X) (Suc i) = coeff p i\"\n by sorry\n\nlemma coeff_X_mult_0[simp]: \"coeff (X * p) 0 = 0\"\n by sorry\n\nlemma coeff_mult_X_0[simp]: \"coeff (p * X) 0 = 0\"\n by sorry\n\nlemma coeff_X: \"coeff X i = (if i = 1 then 1 else 0)\"\n by sorry\n\nlemma coeff_pow_X: \"coeff (X ^ i) n = (if i = n then 1 else 0)\"\n by sorry\n\nlemma coeff_pow_X_eq[simp]: \"coeff (X^i) i = 1\"\n by sorry\n\nlemma (in monoid_mult) power_ac: \"a * (a^n * x) = a^n * (a * x)\"\n by sorry\n\ntext\\This theory contains auxiliary lemmas on polynomials.\\\n\nlemma degree_prod_le: \"degree (\\i\\S. f i) \\ (\\i\\S. degree (f i))\"\n by sorry\n\nlemma coeff_mult_sum:\n \"degree p \\ m \\ degree q \\ n \\ coeff (p * q) (m + n) = coeff p m * coeff q n\"\n by sorry\n\nlemma coeff_mult_prod_sum:\n \"coeff (\\i\\S. f i) (\\i\\S. degree (f i)) = (\\i\\S. coeff (f i) (degree (f i)))\"\n by sorry\n\nlemma degree_sum_less:\n \"0 < n \\ (\\x. x \\ A \\ degree (f x) < n) \\ degree (\\x\\A. f x) < n\" \n by sorry\n\nlemma degree_sum_le:\n shows \"(\\x. x \\ A \\ degree (f x) \\ n) \\ degree (\\x\\A. f x) \\ n\"\n by sorry\n\nlemma degree_sum_le_Max:\n \"finite F \\ degree (sum f F) \\ Max ((\\x. degree (f x))`F)\"\n by sorry\n\nlemma poly_as_sum_of_monoms': assumes n: \"degree p \\ n\" shows \"(\\i\\n. X^i * C (coeff p i)) = p\"\n by sorry\n\nlemma poly_as_sum_of_monoms: \"(\\i\\degree p. X^i * C (coeff p i)) = p\"\n by sorry\n\nlemma degree_sum_unique':\n assumes I: \"finite I\" \"i \\ I\" \"\\j. j \\ I \\ degree (p j) < degree (p i)\"\n shows \"degree (\\i\\insert i I. p i) = degree (p i)\"\n by sorry\n\nlemma degree_sum_unique:\n \"finite I \\ i \\ I \\ (\\j. j \\ I \\ j \\ i \\ degree (p j) < degree (p i)) \\\n degree (\\i\\I. p i) = degree (p i)\"\n by sorry\n\nlemma coeff_sum_unique:\n fixes p :: \"'a \\ 'b::semiring_0 poly\"\n assumes I: \"finite I\" \"i \\ I\" \"\\j. j \\ I \\ j \\ i \\ degree (p j) < degree (p i)\"\n shows \"coeff (\\i\\I. p i) (degree (p i)) = coeff (p i) (degree (p i))\"\n by sorry\n\nlemma diag_coeff: \"diag (coeff x i) = map_sq_matrix (\\x. coeff x i) (diag x)\"\n by sorry\n\nlemma smult_one: \"x *\\<^sub>S 1 = diag x\"\n by sorry\n\nlemma sum_telescope_Ico: \"a \\ b \\ (\\i=a ..< b. f i - f (Suc i) ::_::ab_group_add) = f a - f b\"\n by sorry\n\nlemmas map_sq_matrix = map_sq_matrix_diff map_sq_matrix_add map_sq_matrix_smult map_sq_matrix_sum\n\nlemma sign_permut: \"degree (of_int (sign p) * q) = degree q\" \n by sorry\n\nlemma degree_det:\n assumes \"\\j. j permutes UNIV \\ j \\ id \\ degree (\\i\\UNIV. to_fun A i (j i)) < degree (\\i\\UNIV. to_fun A i i)\"\n shows \"degree (det A) = degree (\\i\\UNIV. to_fun A i i)\"\n by sorry\n\ndefinition max_degree :: \"'a::zero poly^^'n \\ nat\" where\n \"max_degree A = Max (range (\\(i, j). degree (to_fun A i j)))\"\n\nlemma degree_le_max_degree: \"degree (to_fun A i j) \\ max_degree A\"\n by sorry\n\ndefinition \"charpoly A = det (\\<^bold>X - \\<^bold>C A)\"\n\nlemma degree_diff_cancel: \"degree q < degree p \\ degree (p - q::_::ab_group_add poly) = degree p\"\n by sorry\n\nlemma\n fixes A :: \"'a::comm_ring_1^^'n\"\n shows degree_charpoly: \"degree (charpoly A) = CARD('n)\"\n and coeff_charpoly: \"coeff (charpoly A) (degree (charpoly A)) = 1\"\n by sorry\n\ndefinition \"max_perm_degree A = Max ((\\p. \\i\\UNIV. degree (to_fun A i (p i)))`{p. p permutes UNIV})\"\n\nlemma max_perm_degree_eqI:\n \"(\\p. p permutes (UNIV::'a::finite set) \\ (\\i\\UNIV. degree (to_fun A i (p i))) \\ x) \\\n (\\p. p permutes UNIV \\ (\\i\\UNIV. degree (to_fun A i (p i))) = x) \\\n max_perm_degree A = x\"\n by sorry\n\nlemma degree_prod_le_max_perm_degree:\n \"j permutes (UNIV::'a::finite set) \\ degree (\\i\\UNIV. to_fun A i (j i)) \\ max_perm_degree A\"\n by sorry\n\nlemma degree_le_max_perm_degree: \"degree (det A) \\ max_perm_degree A\"\n by sorry\n\nlemma max_degree_adjugate:\n fixes A :: \"_^^'n\"\n shows \"max_degree (adjugate (\\<^bold>X - \\<^bold>C A)) = CARD('n) - 1\"\n (is \"?R = _\")\n by sorry\n\ndefinition poly_mat :: \"'a::ring_1 poly \\ 'a^^'n \\ 'a^^'n\" where\n \"poly_mat p A = (\\i\\degree p. coeff p i *\\<^sub>S A^i)\"\n\nlemma zero_smult[simp]: \"0 *\\<^sub>S M = (0::'a::semiring_1^^'n)\"\n by sorry\n\nlemma smult_smult: \"a *\\<^sub>S b *\\<^sub>S M = (a * b::'a::monoid_mult) *\\<^sub>S M\"\n by sorry\n\nlemma map_sq_matrix_mult_eq_smult[simp]: \"map_sq_matrix (" }, { "theorem_id": 41, "title": "049_the_cayley-hamilton_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Kim Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\nmodule\n\npublic import Mathlib.Algebra.Polynomial.Eval.SMul\npublic import Mathlib.LinearAlgebra.Matrix.Adjugate\npublic import Mathlib.LinearAlgebra.Matrix.Block\npublic import Mathlib.RingTheory.MatrixPolynomialAlgebra\n\n/-!\n# Characteristic polynomials and the Cayley-Hamilton theorem\n\nWe define characteristic polynomials of matrices and\nprove the Cayley–Hamilton theorem over arbitrary commutative rings.\n\nSee the file `Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean` for corollaries of this theorem.\n\n## Main definitions\n\n* `Matrix.charpoly` is the characteristic polynomial of a matrix.\n\n## Implementation details\n\nWe follow a nice proof from http://drorbn.net/AcademicPensieve/2015-12/CayleyHamilton.pdf\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nuniverse u v w\n\nnamespace Matrix\n\nopen Finset Matrix Polynomial\n\nvariable {R S : Type*} [CommRing R] [CommRing S]\nvariable {m n : Type*} [DecidableEq m] [DecidableEq n] [Fintype m] [Fintype n]\nvariable (M₁₁ : Matrix m m R) (M₁₂ : Matrix m n R) (M₂₁ : Matrix n m R) (M₂₂ M : Matrix n n R)\nvariable (i j : n)\n\n\n/-- The \"characteristic matrix\" of `M : Matrix n n R` is the matrix of polynomials $t I - M$.\nThe determinant of this matrix is the characteristic polynomial.\n-/\ndef charmatrix (M : Matrix n n R) : Matrix n n R[X] :=\n Matrix.scalar n (X : R[X]) - (C : R →+* R[X]).mapMatrix M\n\ntheorem charmatrix_apply :\n charmatrix M i j = (Matrix.diagonal fun _ : n => X) i j - C (M i j) :=\n rfl\n\n@[simp]\ntheorem charmatrix_apply_eq : charmatrix M i i = (X : R[X]) - C (M i i) := by sorry\ntheorem charmatrix_apply_ne (h : i ≠ j) : charmatrix M i j = -C (M i j) := by sorry\ntheorem charmatrix_zero : charmatrix (0 : Matrix n n R) = Matrix.scalar n (X : R[X]) := by sorry\ntheorem charmatrix_diagonal (d : n → R) :\n charmatrix (diagonal d) = diagonal fun i => X - C (d i) := by sorry\ntheorem charmatrix_one : charmatrix (1 : Matrix n n R) = diagonal fun _ => X - 1 :=\n charmatrix_diagonal _\n\n@[simp]\ntheorem charmatrix_natCast (k : ℕ) :\n charmatrix (k : Matrix n n R) = diagonal fun _ => X - (k : R[X]) :=\n charmatrix_diagonal _\n\n@[simp]\ntheorem charmatrix_ofNat (k : ℕ) [k.AtLeastTwo] :\n charmatrix (ofNat(k) : Matrix n n R) = diagonal fun _ => X - ofNat(k) :=\n charmatrix_natCast _\n\n@[simp]\ntheorem charmatrix_transpose (M : Matrix n n R) : (Mᵀ).charmatrix = M.charmatrixᵀ := by sorry\ntheorem matPolyEquiv_charmatrix : matPolyEquiv (charmatrix M) = X - C M := by sorry\ntheorem charmatrix_reindex (e : n ≃ m) :\n charmatrix (reindex e e M) = reindex e e (charmatrix M) := by sorry\nlemma charmatrix_map (M : Matrix n n R) (f : R →+* S) :\n charmatrix (M.map f) = (charmatrix M).map (Polynomial.map f) := by sorry\nlemma charmatrix_fromBlocks :\n charmatrix (fromBlocks M₁₁ M₁₂ M₂₁ M₂₂) =\n fromBlocks (charmatrix M₁₁) (- M₁₂.map C) (- M₂₁.map C) (charmatrix M₂₂) := by sorry\nlemma charmatrix_blockTriangular_iff {α : Type*} [Preorder α] {M : Matrix n n R} {b : n → α} :\n M.charmatrix.BlockTriangular b ↔ M.BlockTriangular b := by sorry\ndef charpoly (M : Matrix n n R) : R[X] :=\n (charmatrix M).det\n\ntheorem eval_charpoly (M : Matrix m m R) (t : R) :\n M.charpoly.eval t = (Matrix.scalar _ t - M).det := by sorry\ntheorem charpoly_isEmpty [IsEmpty n] {A : Matrix n n R} : charpoly A = 1 := by sorry\ntheorem charpoly_zero : charpoly (0 : Matrix n n R) = X ^ Fintype.card n := by sorry\ntheorem charpoly_diagonal (d : n → R) : charpoly (diagonal d) = ∏ i, (X - C (d i)) := by sorry\ntheorem charpoly_one : charpoly (1 : Matrix n n R) = (X - 1) ^ Fintype.card n := by sorry\ntheorem charpoly_natCast (k : ℕ) :\n charpoly (k : Matrix n n R) = (X - (k : R[X])) ^ Fintype.card n := by sorry\ntheorem charpoly_ofNat (k : ℕ) [k.AtLeastTwo] :\n charpoly (ofNat(k) : Matrix n n R) = (X - ofNat(k)) ^ Fintype.card n :=\n charpoly_natCast _\n\n@[simp]\ntheorem charpoly_transpose (M : Matrix n n R) : (Mᵀ).charpoly = M.charpoly := by sorry\ntheorem charpoly_reindex (e : n ≃ m)\n (M : Matrix n n R) : (reindex e e M).charpoly = M.charpoly := by sorry\nlemma charpoly_map (M : Matrix n n R) (f : R →+* S) :\n (M.map f).charpoly = M.charpoly.map f := by sorry\nlemma charpoly_fromBlocks_zero₁₂ :\n (fromBlocks M₁₁ 0 M₂₁ M₂₂).charpoly = (M₁₁.charpoly * M₂₂.charpoly) := by sorry\nlemma charpoly_fromBlocks_zero₂₁ :\n (fromBlocks M₁₁ M₁₂ 0 M₂₂).charpoly = (M₁₁.charpoly * M₂₂.charpoly) := by sorry\nlemma charmatrix_toSquareBlock {α : Type*} [DecidableEq α] {b : n → α} {a : α} :\n (M.toSquareBlock b a).charmatrix = M.charmatrix.toSquareBlock b a := by sorry\nlemma BlockTriangular.charpoly {α : Type*} {b : n → α} [LinearOrder α] (h : M.BlockTriangular b) :\n M.charpoly = ∏ a ∈ image b univ, (M.toSquareBlock b a).charpoly := by sorry\nlemma charpoly_of_upperTriangular [LinearOrder n] (M : Matrix n n R) (h : M.BlockTriangular id) :\n M.charpoly = ∏ i : n, (X - C (M i i)) := by sorry\ntheorem aeval_self_charpoly (M : Matrix n n R) : aeval M M.charpoly = 0 := by sorry\ntheorem charpoly_mul_comm' (A : Matrix m n R) (B : Matrix n m R) :\n X ^ Fintype.card n * (A * B).charpoly = X ^ Fintype.card m * (B * A).charpoly := by sorry\ntheorem charpoly_mul_comm_of_le\n (A : Matrix m n R) (B : Matrix n m R) (hle : Fintype.card n ≤ Fintype.card m) :\n (A * B).charpoly = X ^ (Fintype.card m - Fintype.card n) * (B * A).charpoly := by sorry\ntheorem charpoly_mul_comm (A B : Matrix n n R) : (A * B).charpoly = (B * A).charpoly :=\n (isRegular_X_pow _).left.eq_iff.mp <| charpoly_mul_comm' A B\n\ntheorem charpoly_vecMulVec (u v : n → R) :\n (vecMulVec u v).charpoly = X ^ Fintype.card n - (u ⬝ᵥ v) • X ^ (Fintype.card n - 1) := by sorry\ntheorem charpoly_units_conj (M : (Matrix n n R)ˣ) (N : Matrix n n R) :\n (M.val * N * M⁻¹.val).charpoly = N.charpoly := by sorry\ntheorem charpoly_units_conj' (M : (Matrix n n R)ˣ) (N : Matrix n n R) :\n (M⁻¹.val * N * M.val).charpoly = N.charpoly :=\n charpoly_units_conj M⁻¹ N\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem charpoly_sub_scalar (M : Matrix n n R) (μ : R) :\n (M - scalar n μ).charpoly = M.charpoly.comp (X + C μ) := by sorry\nend Matrix\n" }, { "theorem_id": 41, "title": "049_the_cayley-hamilton_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From HB Require Import structures.\nFrom mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq div.\nFrom mathcomp Require Import choice fintype tuple finfun bigop fingroup perm.\nFrom mathcomp Require Import nmodule algebra divalg decfield matrix mxalgebra.\nFrom mathcomp Require Import poly polydiv.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nImport GRing.Theory.\nImport Monoid.Theory.\n\nLocal Open Scope ring_scope.\n\nImport Pdiv.Idomain.\n\nSection RowPoly.\n\nVariables (R : nzSemiRingType) (d : nat).\nImplicit Types u v : 'rV[R]_d.\nImplicit Types p q : {poly R}.\n\nDefinition rVpoly v := \\poly_(k < d) (if insub k is Some i then v 0 i else 0).\nDefinition poly_rV p := \\row_(i < d) p`_i.\n\nLemma coef_rVpoly v k : (rVpoly v)`_k = if insub k is Some i then v 0 i else 0.\nProof.\nAdmitted.\n\nLet split_diagA :\n exists2 q, \\prod_(x <- diagA) ('X - x%:P) + q = char_poly & size q <= n.-1.\nProof.\nAdmitted.\n\nLemma size_char_poly : size char_poly = n.\nProof.\nAdmitted.\nLet intR_XsubC u :\n integralOver RtoK (- u) -> {in 'X - u%:P : seq K, integralRange RtoK}.\nProof.\nAdmitted.\n\nLemma integral_opp u : integralOver RtoK u -> integralOver RtoK (- u).\nProof.\nAdmitted.\n\nLemma codiagonalizable_on m n (V_ : 'I_n -> 'M[F]_m) (As : seq 'M[F]_m) :\n (\\sum_i V_ i :=: 1%:M)%MS -> mxdirect (\\sum_i V_ i) ->\n (forall i, all (fun A => stablemx (V_ i) A) As) ->\n (forall i, codiagonalizable (map (restrictmx (V_ i)) As)) ->\n codiagonalizable As.\nProof.\nAdmitted.\n\nLemma diagonalizable_diag {n} (d : 'rV[F]_n) : diagonalizable (diag_mx d).\nProof.\nAdmitted.\nHint Resolve diagonalizable_diag : core.\n\nLemma diagonalizable_scalar {n} (a : F) : diagonalizable (a%:M : 'M_n).\nProof.\nAdmitted.\nHint Resolve diagonalizable_scalar : core.\n\nLemma diagonalizable0 {n} : diagonalizable (0 : 'M[F]_n).\nProof.\nAdmitted.\nHint Resolve diagonalizable0 : core.\n\nLemma diagonalizablePeigen {n} {A : 'M[F]_n} :\n diagonalizable A <->\n exists2 rs, uniq rs & (\\sum_(r <- rs) eigenspace A r :=: 1%:M)%MS.\nProof.\nAdmitted.\n\nLemma diagonalizableP n' (n := n'.\nProof.\nAdmitted.\n\nLemma diagonalizable_conj_diag m n (V : 'M[F]_(m, n)) (d : 'rV[F]_n) :\n stablemx V (diag_mx d) -> row_free V -> diagonalizable (conjmx V (diag_mx d)).\nProof.\nAdmitted.\n\nLemma codiagonalizableP n (As : seq 'M[F]_n) :\n {in As &, forall A B, comm_mx A B} /\\ {in As, forall A, diagonalizable A}\n <-> codiagonalizable As.\nProof.\nAdmitted.\n\nEnd Diag." }, { "theorem_id": 42, "title": "051_wilson_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";;\nneeds \"Library/pocklington.ml\";;\n\nprioritize_num();;\n\nlet FACT_NPRODUCT = `!n. FACT(n) = nproduct(1..n) (\\i. i)`;;\n\nlet FACT_NPRODUCT_ALT = `!n. FACT(n) = nproduct(2..n) (\\i. i)`;;\n\nlet NPRODUCT_PAIRUP_INDUCT = `!f r n s. FINITE s /\\ CARD s = n /\\\n (!x:A. x IN s ==> ?!y. y IN s /\\ ~(y = x) /\\\n (f(x) * f(y) == 1) (mod r))\n ==> (nproduct s f == 1) (mod r)`;;\n\nlet NPRODUCT_PAIRUP = `!f r s. FINITE s /\\\n (!x:A. x IN s ==> ?!y. y IN s /\\ ~(y = x) /\\\n (f(x) * f(y) == 1) (mod r))\n ==> (nproduct s f == 1) (mod r)`;;\n\nlet WILSON = `!p. prime(p) ==> (FACT(p - 1) == p - 1) (mod p)`;;\n\nlet WILSON_EQ = `!p. ~(p = 1) ==> (prime p <=> (FACT(p - 1) == p - 1) (mod p))`;;" }, { "theorem_id": 42, "title": "051_wilson_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory Coset\nimports Group\nbegin\n\nsection \\Cosets and Quotient Groups\\\n\ndefinition\n r_coset :: \"[_, 'a set, 'a] \\ 'a set\" (infixl \\#>\\\\ 60)\n where \"H #>\\<^bsub>G\\<^esub> a = (\\h\\H. {h \\\\<^bsub>G\\<^esub> a})\"\n\ndefinition\n l_coset :: \"[_, 'a, 'a set] \\ 'a set\" (infixl \\<#\\\\ 60)\n where \"a <#\\<^bsub>G\\<^esub> H = (\\h\\H. {a \\\\<^bsub>G\\<^esub> h})\"\n\ndefinition\n RCOSETS :: \"[_, 'a set] \\ ('a set)set\"\n (\\(\\open_block notation=\\prefix rcosets\\\\rcosets\\ _)\\ [81] 80)\n where \"rcosets\\<^bsub>G\\<^esub> H = (\\a\\carrier G. {H #>\\<^bsub>G\\<^esub> a})\"\n\ndefinition\n set_mult :: \"[_, 'a set ,'a set] \\ 'a set\" (infixl \\<#>\\\\ 60)\n where \"H <#>\\<^bsub>G\\<^esub> K = (\\h\\H. \\k\\K. {h \\\\<^bsub>G\\<^esub> k})\"\n\ndefinition\n SET_INV :: \"[_,'a set] \\ 'a set\"\n (\\(\\open_block notation=\\prefix set_inv\\\\set'_inv\\ _)\\ [81] 80)\n where \"set_inv\\<^bsub>G\\<^esub> H = (\\h\\H. {inv\\<^bsub>G\\<^esub> h})\"\n\nlocale normal = subgroup + group +\n assumes coset_eq: \"(\\x \\ carrier G. H #> x = x <# H)\"\n\nabbreviation\n normal_rel :: \"['a set, ('a, 'b) monoid_scheme] \\ bool\" (infixl \\\\\\ 60) where\n \"H \\ G \\ normal H G\"\n\nlemma (in comm_group) subgroup_imp_normal: \"subgroup A G \\ A \\ G\"\n by sorry\n\nlemma l_coset_eq_set_mult: \\<^marker>\\contributor \\Martin Baillon\\\\\n fixes G (structure)\n shows \"x <# H = {x} <#> H\"\n by sorry\n\nlemma r_coset_eq_set_mult: \\<^marker>\\contributor \\Martin Baillon\\\\\n fixes G (structure)\n shows \"H #> x = H <#> {x}\"\n by sorry\n\nlemma (in subgroup) rcosets_non_empty: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"R \\ rcosets H\"\n shows \"R \\ {}\"\n by sorry\n\nlemma (in group) diff_neutralizes: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"subgroup H G\" \"R \\ rcosets H\"\n shows \"\\r1 r2. \\ r1 \\ R; r2 \\ R \\ \\ r1 \\ (inv r2) \\ H\"\n by sorry\n\nlemma mono_set_mult: \"\\ H \\ H'; K \\ K' \\ \\ H <#>\\<^bsub>G\\<^esub> K \\ H' <#>\\<^bsub>G\\<^esub> K'\" \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n by sorry\n\nsubsection \\Stable Operations for Subgroups\\\n\nlemma set_mult_consistent [simp]: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n \"N <#>\\<^bsub>(G \\ carrier := H \\)\\<^esub> K = N <#>\\<^bsub>G\\<^esub> K\"\n by sorry\n\nlemma r_coset_consistent [simp]: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n \"I #>\\<^bsub>G \\ carrier := H \\\\<^esub> h = I #>\\<^bsub>G\\<^esub> h\"\n by sorry\n\nlemma l_coset_consistent [simp]: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n \"h <#\\<^bsub>G \\ carrier := H \\\\<^esub> I = h <#\\<^bsub>G\\<^esub> I\"\n by sorry\n\nsubsection \\Basic Properties of set multiplication\\\n\nlemma (in group) setmult_subset_G:\n assumes \"H \\ carrier G\" \"K \\ carrier G\"\n shows \"H <#> K \\ carrier G\" using assms\n by sorry\n\nlemma (in monoid) set_mult_closed:\n assumes \"H \\ carrier G\" \"K \\ carrier G\"\n shows \"H <#> K \\ carrier G\"\n by sorry\n\nlemma (in group) set_mult_assoc: \\<^marker>\\contributor \\Martin Baillon\\\\\n assumes \"M \\ carrier G\" \"H \\ carrier G\" \"K \\ carrier G\"\n shows \"(M <#> H) <#> K = M <#> (H <#> K)\"\n by sorry\n\nsubsection \\Basic Properties of Cosets\\\n\nlemma (in group) coset_mult_assoc:\n assumes \"M \\ carrier G\" \"g \\ carrier G\" \"h \\ carrier G\"\n shows \"(M #> g) #> h = M #> (g \\ h)\"\n by sorry\n\nlemma (in group) coset_assoc:\n assumes \"x \\ carrier G\" \"y \\ carrier G\" \"H \\ carrier G\"\n shows \"x <# (H #> y) = (x <# H) #> y\"\n by sorry\n\nlemma (in group) coset_mult_one [simp]: \"M \\ carrier G ==> M #> \\ = M\"\n by sorry\n\nlemma (in group) coset_mult_inv1:\n assumes \"M #> (x \\ (inv y)) = M\"\n and \"x \\ carrier G\" \"y \\ carrier G\" \"M \\ carrier G\"\n shows \"M #> x = M #> y\" using assms\n by sorry\n\nlemma (in group) coset_mult_inv2:\n assumes \"M #> x = M #> y\"\n and \"x \\ carrier G\" \"y \\ carrier G\" \"M \\ carrier G\"\n shows \"M #> (x \\ (inv y)) = M \" using assms\n by sorry\n\nlemma (in group) coset_join1:\n assumes \"H #> x = H\"\n and \"x \\ carrier G\" \"subgroup H G\"\n shows \"x \\ H\"\n by sorry\n\nlemma (in group) solve_equation:\n assumes \"subgroup H G\" \"x \\ H\" \"y \\ H\"\n shows \"\\h \\ H. y = h \\ x\"\n by sorry\n\nlemma (in group_hom) inj_on_one_iff:\n \"inj_on h (carrier G) \\ (\\x. x \\ carrier G \\ h x = one H \\ x = one G)\"\n by sorry\n\nlemma inj_on_one_iff':\n \"\\h \\ hom G H; group G; group H\\ \\ inj_on h (carrier G) \\ (\\x. x \\ carrier G \\ h x = one H \\ x = one G)\"\n by sorry\n\nlemma mon_iff_hom_one:\n \"\\group G; group H\\ \\ f \\ mon G H \\ f \\ hom G H \\ (\\x. x \\ carrier G \\ f x = \\\\<^bsub>H\\<^esub> \\ x = \\\\<^bsub>G\\<^esub>)\"\n by sorry\n\nlemma (in group_hom) iso_iff: \"h \\ iso G H \\ carrier H \\ h ` carrier G \\ (\\x\\carrier G. h x = \\\\<^bsub>H\\<^esub> \\ x = \\)\"\n by sorry\n\nlemma (in group) repr_independence:\n assumes \"y \\ H #> x\" \"x \\ carrier G\" \"subgroup H G\"\n shows \"H #> x = H #> y\" using assms\n by sorry\n\nlemma (in group) coset_join2:\n assumes \"x \\ carrier G\" \"subgroup H G\" \"x \\ H\"\n shows \"H #> x = H\" using assms\n \\ \\Alternative proof is to put \\<^term>\\x=\\\\ in \\repr_independence\\.\\\n by sorry\n\nlemma (in group) coset_join3:\n assumes \"x \\ carrier G\" \"subgroup H G\" \"x \\ H\"\n shows \"x <# H = H\"\n by sorry\n\nlemma (in monoid) r_coset_subset_G:\n \"\\ H \\ carrier G; x \\ carrier G \\ \\ H #> x \\ carrier G\"\n by sorry\n\nlemma (in group) rcosI:\n \"\\ h \\ H; H \\ carrier G; x \\ carrier G \\ \\ h \\ x \\ H #> x\"\n by sorry\n\nlemma (in group) rcosetsI:\n \"\\H \\ carrier G; x \\ carrier G\\ \\ H #> x \\ rcosets H\"\n by sorry\n\nlemma (in group) rcos_self:\n \"\\ x \\ carrier G; subgroup H G \\ \\ x \\ H #> x\"\n by sorry\n\ntext (in group) \\Opposite of @{thm [source] \"repr_independence\"}\\\nlemma (in group) repr_independenceD:\n assumes \"subgroup H G\" \"y \\ carrier G\"\n and \"H #> x = H #> y\"\n shows \"y \\ H #> x\"\n by sorry\n\ntext \\Elements of a right coset are in the carrier\\\nlemma (in subgroup) elemrcos_carrier:\n assumes \"group G\" \"a \\ carrier G\"\n and \"a' \\ H #> a\"\n shows \"a' \\ carrier G\"\n by sorry\n\nlemma (in subgroup) rcos_const:\n assumes \"group G\" \"h \\ H\"\n shows \"H #> h = H\"\n by sorry\n\nlemma (in subgroup) rcos_module_imp:\n assumes \"group G\" \"x \\ carrier G\"\n and \"x' \\ H #> x\"\n shows \"(x' \\ inv x) \\ H\"\n by sorry\n\nlemma (in subgroup) rcos_module_rev:\n assumes \"group G\" \"x \\ carrier G\" \"x' \\ carrier G\"\n and \"(x' \\ inv x) \\ H\"\n shows \"x' \\ H #> x\"\n by sorry\n\ntext \\Module property of right cosets\\\nlemma (in subgroup) rcos_module:\n assumes \"group G\" \"x \\ carrier G\" \"x' \\ carrier G\"\n shows \"(x' \\ H #> x) = (x' \\ inv x \\ H)\"\n by sorry\n\ntext \\Right cosets are subsets of the carrier.\\\nlemma (in subgroup) rcosets_carrier:\n assumes \"group G\" \"X \\ rcosets H\"\n shows \"X \\ carrier G\"\n by sorry\n\ntext \\Multiplication of general subsets\\\n\nlemma (in comm_group) mult_subgroups:\n assumes HG: \"subgroup H G\" and KG: \"subgroup K G\"\n shows \"subgroup (H <#> K) G\"\n by sorry\n\nlemma (in subgroup) lcos_module_rev:\n assumes \"group G\" \"x \\ carrier G\" \"x' \\ carrier G\"\n and \"(inv x \\ x') \\ H\"\n shows \"x' \\ x <# H\"\n by sorry\n\nsubsection \\Normal subgroups\\\n\nlemma normal_imp_subgroup: \"H \\ G \\ subgroup H G\"\n by sorry\n\nlemma (in group) normalI:\n \"subgroup H G \\ (\\x \\ carrier G. H #> x = x <# H) \\ H \\ G\"\n by sorry\n\nlemma (in normal) inv_op_closed1:\n assumes \"x \\ carrier G\" and \"h \\ H\"\n shows \"(inv x) \\ h \\ x \\ H\"\n by sorry\n\nlemma (in normal) inv_op_closed2:\n assumes \"x \\ carrier G\" and \"h \\ H\"\n shows \"x \\ h \\ (inv x) \\ H\"\n by sorry\n\nlemma (in comm_group) normal_iff_subgroup:\n \"N \\ G \\ subgroup N G\"\n by sorry\n\ntext\\Alternative characterization of normal subgroups\\\nlemma (in group) normal_inv_iff:\n \"(N \\ G) =\n (subgroup N G \\ (\\x \\ carrier G. \\h \\ N. x \\ h \\ (inv x) \\ N))\"\n (is \"_ = ?rhs\")\n by sorry\n\ncorollary (in group) normal_invI:\n assumes \"subgroup N G\" and \"\\x h. \\ x \\ carrier G; h \\ N \\ \\ x \\ h \\ inv x \\ N\"\n shows \"N \\ G\"\n by sorry\n\ncorollary (in group) normal_invE:\n assumes \"N \\ G\"\n shows \"subgroup N G\" and \"\\x h. \\ x \\ carrier G; h \\ N \\ \\ x \\ h \\ inv x \\ N\"\n by sorry\n\nlemma (in group) one_is_normal: \"{\\} \\ G\"\n by sorry\n\ntext \\The intersection of two normal subgroups is, again, a normal subgroup.\\\nlemma (in group) normal_subgroup_intersect:\n assumes \"M \\ G\" and \"N \\ G\" shows \"M \\ N \\ G\"\n by sorry\n\ntext \\Being a normal subgroup is preserved by surjective homomorphisms.\\\n\nlemma (in normal) surj_hom_normal_subgroup:\n assumes \\: \"group_hom G F \\\"\n assumes \\surj: \"\\ ` (carrier G) = carrier F\"\n shows \"(\\ ` H) \\ F\"\n by sorry\n\ntext \\Being a normal subgroup is preserved by group isomorphisms.\\\nlemma iso_normal_subgroup:\n assumes \\: \"\\ \\ iso G F\" \"group G\" \"group F\" \"H \\ G\"\n shows \"(\\ ` H) \\ F\"\n by sorry\n\ntext \\The set product of two normal subgroups is a normal subgroup.\\\nlemma (in group) setmult_lcos_assoc:\n \"\\H \\ carrier G; K \\ carrier G; x \\ carrier G\\\n \\ (x <# H) <#> K = x <# (H <#> K)\"\n by sorry\n\nsubsection\\More Properties of Left Cosets\\\n\nlemma (in group) l_repr_independence:\n assumes \"y \\ x <# H\" \"x \\ carrier G\" and HG: \"subgroup H G\"\n shows \"x <# H = y <# H\"\n by sorry\n\nlemma (in group) lcos_m_assoc:\n \"\\ M \\ carrier G; g \\ carrier G; h \\ carrier G \\ \\ g <# (h <# M) = (g \\ h) <# M\"\n by sorry\n\nlemma (in group) lcos_mult_one: \"M \\ carrier G \\ \\ <# M = M\"\n by sorry\n\nlemma (in group) l_coset_subset_G:\n \"\\ H \\ carrier G; x \\ carrier G \\ \\ x <# H \\ carrier G\"\n by sorry\n\nlemma (in group) l_coset_carrier:\n \"\\ y \\ x <# H; x \\ carrier G; subgroup H G \\ \\ y \\ carrier G\"\n by sorry\n\nlemma (in group) l_coset_swap:\n assumes \"y \\ x <# H\" \"x \\ carrier G\" \"subgroup H G\"\n shows \"x \\ y <# H\"\n by sorry\n\nlemma (in group) subgroup_mult_id:\n assumes \"subgroup H G\"\n shows \"H <#> H = H\"\n by sorry\n\nsubsubsection \\Set of Inverses of an \\r_coset\\.\\\n\nlemma (in normal) rcos_inv:\n assumes x: \"x \\ carrier G\"\n shows \"set_inv (H #> x) = H #> (inv x)\"\n by sorry\n\nsubsubsection \\Theorems for \\<#>\\ with \\#>\\ or \\<#\\.\\\n\nlemma (in group) setmult_rcos_assoc:\n \"\\H \\ carrier G; K \\ carrier G; x \\ carrier G\\ \\\n H <#> (K #> x) = (H <#> K) #> x\"\n by sorry\n\nlemma (in group) rcos_assoc_lcos:\n \"\\H \\ carrier G; K \\ carrier G; x \\ carrier G\\ \\\n (H #> x) <#> K = H <#> (x <# K)\"\n by sorry\n\nlemma (in normal) rcos_mult_step1:\n \"\\x \\ carrier G; y \\ carrier G\\ \\\n (H #> x) <#> (H #> y) = (H <#> (x <# H)) #> y\"\n by sorry\n\nlemma (in normal) rcos_mult_step2:\n \"\\x \\ carrier G; y \\ carrier G\\\n \\ (H <#> (x <# H)) #> y = (H <#> (H #> x)) #> y\"\n by sorry\n\nlemma (in normal) rcos_mult_step3:\n \"\\x \\ carrier G; y \\ carrier G\\\n \\ (H <#> (H #> x)) #> y = H #> (x \\ y)\"\n by sorry\n\nlemma (in normal) rcos_sum:\n \"\\x \\ carrier G; y \\ carrier G\\\n \\ (H #> x) <#> (H #> y) = H #> (x \\ y)\"\n by sorry\n\nlemma (in normal) rcosets_mult_eq: \"M \\ rcosets H \\ H <#> M = M\"\n \\ \\generalizes \\subgroup_mult_id\\\\\n by sorry\n\nsubsubsection\\An Equivalence Relation\\\n\ndefinition\n r_congruent :: \"[('a,'b)monoid_scheme, 'a set] \\ ('a*'a)set\"\n (\\(\\open_block notation=\\prefix rcong\\\\rcong\\ _)\\)\n where \"rcong\\<^bsub>G\\<^esub> H = {(x,y). x \\ carrier G \\ y \\ carrier G \\ inv\\<^bsub>G\\<^esub> x \\\\<^bsub>G\\<^esub> y \\ H}\"\n\nlemma (in subgroup) equiv_rcong:\n assumes \"group G\"\n shows \"equiv (carrier G) (rcong H)\"\n by sorry\n\ntext\\Equivalence classes of \\rcong\\ correspond to left cosets.\n Was there a mistake in the definitions? I'd have expected them to\n correspond to right cosets.\\\n\nlemma (in subgroup) l_coset_eq_rcong:\n assumes \"group G\"\n assumes a: \"a \\ carrier G\"\n shows \"a <# H = (rcong H) `` {a}\"\n by sorry\n\nsubsubsection\\Two Distinct Right Cosets are Disjoint\\\n\nlemma (in group) rcos_equation:\n assumes \"subgroup H G\"\n assumes p: \"ha \\ a = h \\ b\" \"a \\ carrier G\" \"b \\ carrier G\" \"h \\ H\" \"ha \\ H\" \"hb \\ H\"\n shows \"hb \\ a \\ (\\h\\H. {h \\ b})\"\n by sorry\n\nlemma (in group) rcos_disjoint:\n assumes \"subgroup H G\"\n shows \"pairwise disjnt (rcosets H)\"\n by sorry\n\nsubsection \\Further lemmas for \\r_congruent\\\\\n\ntext \\The relation is a congruence\\\n\nlemma (in normal) congruent_rcong:\n shows \"congruent2 (rcong H) (rcong H) (\\a b. a \\ b <# H)\"\n by sorry\n\nsubsection \\Order of a Group and Lagrange's Theorem\\\n\ndefinition\n order :: \"('a, 'b) monoid_scheme \\ nat\"\n where \"order S = card (carrier S)\"\n\nlemma iso_same_order:\n assumes \"\\ \\ iso G H\"\n shows \"order G = order H\"\n by sorry\n\nlemma (in monoid) order_gt_0_iff_finite: \"0 < order G \\ finite (carrier G)\"\n by sorry\n\nlemma (in group) order_one_triv_iff:\n shows \"(order G = 1) = (carrier G = {\\})\"\n by sorry\n\nlemma (in group) rcosets_part_G:\n assumes \"subgroup H G\"\n shows \"\\(rcosets H) = carrier G\"\n by sorry\n\nlemma (in group) cosets_finite:\n \"\\c \\ rcosets H; H \\ carrier G; finite (carrier G)\\ \\ finite c\"\n by sorry\n\ntext\\The next two lemmas support the proof of \\card_cosets_equal\\.\\\nlemma (in group) inj_on_f:\n assumes \"H \\ carrier G\" and a: \"a \\ carrier G\"\n shows \"inj_on (\\y. y \\ inv a) (H #> a)\"\n by sorry\n\nlemma (in group) inj_on_g:\n \"\\H \\ carrier G; a \\ carrier G\\ \\ inj_on (\\y. y \\ a) H\"\n by sorry\n\nlemma (in group) card_cosets_equal:\n assumes \"R \\ rcosets H\" \"H \\ carrier G\"\n shows \"\\f. bij_betw f H R\"\n by sorry\n\ncorollary (in group) card_rcosets_equal:\n assumes \"R \\ rcosets H\" \"H \\ carrier G\"\n shows \"card H = card R\"\n by sorry\n\ncorollary (in group) rcosets_finite:\n assumes \"R \\ rcosets H\" \"H \\ carrier G\" \"finite H\"\n shows \"finite R\"\n by sorry\n\nlemma (in group) rcosets_subset_PowG:\n \"subgroup H G \\ rcosets H \\ Pow(carrier G)\"\n by sorry\n\nproposition (in group) lagrange_finite:\n assumes \"finite(carrier G)\" and HG: \"subgroup H G\"\n shows \"card(rcosets H) * card(H) = order(G)\"\n by sorry\n\ntheorem (in group) lagrange:\n assumes \"subgroup H G\"\n shows \"card (rcosets H) * card H = order G\"\n by sorry\n\ntext \\The cardinality of the right cosets of the trivial subgroup is the cardinality of the group itself:\\\ncorollary (in group) card_rcosets_triv:\n assumes \"finite (carrier G)\"\n shows \"card (rcosets {\\}) = order G\"\n by sorry\n\nsubsection \\Quotient Groups: Factorization of a Group\\\n\ndefinition\n FactGroup :: \"[('a,'b) monoid_scheme, 'a set] \\ ('a set) monoid\" (infixl \\Mod\\ 65)\n \\ \\Actually defined for groups rather than monoids\\\n where \"FactGroup G H = \\carrier = rcosets\\<^bsub>G\\<^esub> H, mult = set_mult G, one = H\\\"\n\nlemma (in normal) setmult_closed:\n \"\\K1 \\ rcosets H; K2 \\ rcosets H\\ \\ K1 <#> K2 \\ rcosets H\"\n by sorry\n\nlemma (in normal) setinv_closed:\n \"K \\ rcosets H \\ set_inv K \\ rcosets H\"\n by sorry\n\nlemma (in normal) rcosets_assoc:\n \"\\M1 \\ rcosets H; M2 \\ rcosets H; M3 \\ rcosets H\\\n \\ M1 <#> M2 <#> M3 = M1 <#> (M2 <#> M3)\"\n by sorry\n\nlemma (in subgroup) subgroup_in_rcosets:\n assumes \"group G\"\n shows \"H \\ rcosets H\"\n by sorry\n\nlemma (in normal) rcosets_inv_mult_group_eq:\n \"M \\ rcosets H \\ set_inv M <#> M = H\"\n by sorry\n\ntheorem (in normal) factorgroup_is_group: \"group (G Mod H)\"\n by sorry\n\nlemma carrier_FactGroup: \"carrier(G Mod N) = (\\x. r_coset G N x) ` carrier G\"\n by sorry\n\nlemma one_FactGroup [simp]: \"one(G Mod N) = N\"\n by sorry\n\nlemma mult_FactGroup [simp]: \"monoid.mult (G Mod N) = set_mult G\"\n by sorry\n\nlemma (in normal) inv_FactGroup:\n assumes \"X \\ carrier (G Mod H)\"\n shows \"inv\\<^bsub>G Mod H\\<^esub> X = set_inv X\"\n by sorry\n\ntext\\The coset map is a homomorphism from \\<^term>\\G\\ to the quotient group\n \\<^term>\\G Mod H\\\\\nlemma (in normal) r_coset_hom_Mod:\n \"(\\a. H #> a) \\ hom G (G Mod H)\"\n by sorry\n\nlemma (in comm_group) set_mult_commute:\n assumes \"N \\ carrier G\" \"x \\ rcosets N\" \"y \\ rcosets N\"\n shows \"x <#> y = y <#> x\"\n by sorry\n\nlemma (in comm_group) abelian_FactGroup:\n assumes \"subgroup N G\" shows \"comm_group(G Mod N)\"\n by sorry\n\nlemma FactGroup_universal:\n assumes \"h \\ hom G H\" \"N \\ G\"\n and h: \"\\x y. \\x \\ carrier G; y \\ carrier G; r_coset G N x = r_coset G N y\\ \\ h x = h y\"\n obtains g\n where \"g \\ hom (G Mod N) H\" \"\\x. x \\ carrier G \\ g(r_coset G N x) = h x\"\n by sorry\n\nlemma (in normal) FactGroup_pow:\n fixes k::nat\n assumes \"a \\ carrier G\"\n shows \"pow (FactGroup G H) (r_coset G H a) k = r_coset G H (pow G a k)\"\n by sorry\n\nlemma (in normal) FactGroup_int_pow:\n fixes k::int\n assumes \"a \\ carrier G\"\n shows \"pow (FactGroup G H) (r_coset G H a) k = r_coset G H (pow G a k)\"\n by sorry\n\nsubsection\\The First Isomorphism Theorem\\\n\ntext\\The quotient by the kernel of a homomorphism is isomorphic to the\n range of that homomorphism.\\\n\ndefinition\n kernel :: \"('a, 'm) monoid_scheme \\ ('b, 'n) monoid_scheme \\ ('a \\ 'b) \\ 'a set\"\n \\ \\the kernel of a homomorphism\\\n where \"kernel G H h = {x. x \\ carrier G \\ h x = \\\\<^bsub>H\\<^esub>}\"\n\nlemma (in group_hom) subgroup_kernel: \"subgroup (kernel G H h) G\"\n by sorry\n\ntext\\The kernel of a homomorphism is a normal subgroup\\\nlemma (in group_hom) normal_kernel: \"(kernel G H h) \\ G\"\n by sorry\n\nlemma iso_kernel_image:\n assumes \"group G\" \"group H\"\n shows \"f \\ iso G H \\ f \\ hom G H \\ kernel G H f = {\\\\<^bsub>G\\<^esub>} \\ f ` carrier G = carrier H\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma (in group_hom) FactGroup_nonempty:\n assumes \"X \\ carrier (G Mod kernel G H h)\"\n shows \"X \\ {}\"\n by sorry\n\nlemma (in group_hom) FactGroup_universal_kernel:\n assumes \"N \\ G\" and h: \"N \\ kernel G H h\"\n obtains g where \"g \\ hom (G Mod N) H\" \"\\x. x \\ carrier G \\ g(r_coset G N x) = h x\"\n by sorry\n\nlemma (in group_hom) FactGroup_the_elem_mem:\n assumes X: \"X \\ carrier (G Mod (kernel G H h))\"\n shows \"the_elem (h`X) \\ carrier H\"\n by sorry\n\nlemma (in group_hom) FactGroup_hom:\n \"(\\X. the_elem (h`X)) \\ hom (G Mod (kernel G H h)) H\"\n by sorry\n\ntext\\Lemma for the following injectivity result\\\nlemma (in group_hom) FactGroup_subset:\n assumes \"g \\ carrier G\" \"g' \\ carrier G\" \"h g = h g'\"\n shows \"kernel G H h #> g \\ kernel G H h #> g'\"\n by sorry\n\nlemma (in group_hom) FactGroup_inj_on:\n \"inj_on (\\X. the_elem (h ` X)) (carrier (G Mod kernel G H h))\"\n by sorry\n\ntext\\If the homomorphism \\<^term>\\h\\ is onto \\<^term>\\H\\, then so is the\nhomomorphism from the quotient group\\\nlemma (in group_hom) FactGroup_onto:\n assumes h: \"h ` carrier G = carrier H\"\n shows \"(\\X. the_elem (h ` X)) ` carrier (G Mod kernel G H h) = carrier H\"\n by sorry\n\ntext\\If \\<^term>\\h\\ is a homomorphism from \\<^term>\\G\\ onto \\<^term>\\H\\, then the\n quotient group \\<^term>\\G Mod (kernel G H h)\\ is isomorphic to \\<^term>\\H\\.\\\ntheorem (in group_hom) FactGroup_iso_set:\n \"h ` carrier G = carrier H\n \\ (\\X. the_elem (h`X)) \\ iso (G Mod (kernel G H h)) H\"\n by sorry\n\ncorollary (in group_hom) FactGroup_iso :\n \"h ` carrier G = carrier H\n \\ (G Mod (kernel G H h))\\ H\"\n by sorry\n\nlemma (in group_hom) trivial_hom_iff: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n \"h ` (carrier G) = { \\\\<^bsub>H\\<^esub> } \\ kernel G H h = carrier G\"\n by sorry\n\nlemma (in group_hom) trivial_ker_imp_inj: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"kernel G H h = { \\ }\"\n shows \"inj_on h (carrier G)\"\n by sorry\n\nlemma (in group_hom) inj_iff_trivial_ker:\n shows \"inj_on h (carrier G) \\ kernel G H h = { \\ }\"\n by sorry\n\nlemma (in group_hom) induced_group_hom':\n assumes \"subgroup I G\" shows \"group_hom (G \\ carrier := I \\) H h\"\n by sorry\n\nlemma (in group_hom) inj_on_subgroup_iff_trivial_ker:\n assumes \"subgroup I G\"\n shows \"inj_on h I \\ kernel (G \\ carrier := I \\) H h = { \\ }\"\n by sorry\n\nlemma set_mult_hom:\n assumes \"h \\ hom G H\" \"I \\ carrier G\" and \"J \\ carrier G\"\n shows \"h ` (I <#>\\<^bsub>G\\<^esub> J) = (h ` I) <#>\\<^bsub>H\\<^esub> (h ` J)\"\n by sorry\n\ncorollary coset_hom:\n assumes \"h \\ hom G H\" \"I \\ carrier G\" \"a \\ carrier G\"\n shows \"h ` (a <#\\<^bsub>G\\<^esub> I) = h a <#\\<^bsub>H\\<^esub> (h ` I)\" and \"h ` (I #>\\<^bsub>G\\<^esub> a) = (h ` I) #>\\<^bsub>H\\<^esub> h a\"\n by sorry\n\ncorollary (in group_hom) set_mult_ker_hom:\n assumes \"I \\ carrier G\"\n shows \"h ` (I <#> (kernel G H h)) = h ` I\" and \"h ` ((kernel G H h) <#> I) = h ` I\"\n by sorry\n\nsubsubsection\\Trivial homomorphisms\\\n\ndefinition trivial_homomorphism where\n \"trivial_homomorphism G H f \\ f \\ hom G H \\ (\\x \\ carrier G. f x = one H)\"\n\nlemma trivial_homomorphism_kernel:\n \"trivial_homomorphism G H f \\ f \\ hom G H \\ kernel G H f = carrier G\"\n by sorry\n\nlemma (in group) trivial_homomorphism_image:\n \"trivial_homomorphism G H f \\ f \\ hom G H \\ f ` carrier G = {one H}\"\n by sorry\n\nsubsection \\Image kernel theorems\\\n\nlemma group_Int_image_ker:\n assumes f: \"f \\ hom G H\" and g: \"g \\ hom H K\" \n and \"inj_on (g \\ f) (carrier G)\" \"group G\" \"group H\" \"group K\"\n shows \"(f ` carrier G) \\ (kernel H K g) = {\\\\<^bsub>H\\<^esub>}\"\n by sorry\n\nlemma group_sum_image_ker:\n assumes f: \"f \\ hom G H\" and g: \"g \\ hom H K\" and eq: \"(g \\ f) ` (carrier G) = carrier K\"\n and \"group G\" \"group H\" \"group K\"\n shows \"set_mult H (f ` carrier G) (kernel H K g) = carrier H\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma group_sum_ker_image:\n assumes f: \"f \\ hom G H\" and g: \"g \\ hom H K\" and eq: \"(g \\ f) ` (carrier G) = carrier K\"\n and \"group G\" \"group H\" \"group K\"\n shows \"set_mult H (kernel H K g) (f ` carrier G) = carrier H\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma group_semidirect_sum_ker_image:\n assumes \"(g \\ f) \\ iso G K\" \"f \\ hom G H\" \"g \\ hom H K\" \"group G\" \"group H\" \"group K\"\n shows \"(kernel H K g) \\ (f ` carrier G) = {\\\\<^bsub>H\\<^esub>}\"\n \"kernel H K g <#>\\<^bsub>H\\<^esub> (f ` carrier G) = carrier H\"\n by sorry\n\nlemma group_semidirect_sum_image_ker:\n assumes f: \"f \\ hom G H\" and g: \"g \\ hom H K\" and iso: \"(g \\ f) \\ iso G K\"\n and \"group G\" \"group H\" \"group K\"\n shows \"(f ` carrier G) \\ (kernel H K g) = {\\\\<^bsub>H\\<^esub>}\"\n \"f ` carrier G <#>\\<^bsub>H\\<^esub> (kernel H K g) = carrier H\"\n by sorry\n\nsubsection \\Factor Groups and Direct product\\\n\nlemma (in group) DirProd_normal : \\<^marker>\\contributor \\Martin Baillon\\\\\n assumes \"group K\"\n and \"H \\ G\"\n and \"N \\ K\"\n shows \"H \\ N \\ G \\\\ K\"\n by sorry\n\nlemma (in group) FactGroup_DirProd_multiplication_iso_set : \\<^marker>\\contributor \\Martin Baillon\\\\\n assumes \"group K\"\n and \"H \\ G\"\n and \"N \\ K\"\n shows \"(\\ (X, Y). X \\ Y) \\ iso ((G Mod H) \\\\ (K Mod N)) (G \\\\ K Mod H \\ N)\"\n by sorry\n\ncorollary (in group) FactGroup_DirProd_multiplication_iso_1 : \\<^marker>\\contributor \\Martin Baillon\\\\\n assumes \"group K\"\n and \"H \\ G\"\n and \"N \\ K\"\n shows \" ((G Mod H) \\\\ (K Mod N)) \\ (G \\\\ K Mod H \\ N)\"\n by sorry\n\ncorollary (in group) FactGroup_DirProd_multiplication_iso_2 : \\<^marker>\\contributor \\Martin Baillon\\\\\n assumes \"group K\"\n and \"H \\ G\"\n and \"N \\ K\"\n shows \"(G \\\\ K Mod H \\ N) \\ ((G Mod H) \\\\ (K Mod N))\"\n by sorry\n\nsubsubsection \"More Lemmas about set multiplication\"\n\ntext \\A group multiplied by a subgroup stays the same\\\nlemma (in group) set_mult_carrier_idem:\n assumes \"subgroup H G\"\n shows \"(carrier G) <#> H = carrier G\"\n by sorry\n\ntext \\Same lemma as above, but everything is included in a subgroup\\\nlemma (in group) set_mult_subgroup_idem:\n assumes HG: \"subgroup H G\" and NG: \"subgroup N (G \\ carrier := H \\)\"\n shows \"H <#> N = H\"\n by sorry\n\ntext \\A normal subgroup is commutative with set multiplication\\\nlemma (in group) commut_normal:\n assumes \"subgroup H G\" and \"N\\G\"\n shows \"H<#>N = N<#>H\"\n by sorry\n\ntext \\Same lemma as above, but everything is included in a subgroup\\\nlemma (in group) commut_normal_subgroup:\n assumes \"subgroup H G\" and \"N \\ (G\\ carrier := H \\)\"\n and \"subgroup K (G \\ carrier := H \\)\"\n shows \"K <#> N = N <#> K\"\n by sorry\n\nsubsubsection \"Lemmas about intersection and normal subgroups\"\ntext \\Mostly by Jakob von Raumer\\\n\nlemma (in group) normal_inter:\n assumes \"subgroup H G\"\n and \"subgroup K G\"\n and \"H1\\G\\carrier := H\\\"\n shows \"(H1\\K)\\(G\\carrier:= (H\\K)\\)\"\n by sorry\n\nlemma (in group) normal_Int_subgroup:\n assumes \"subgroup H G\"\n and \"N \\ G\"\n shows \"(N\\H) \\ (G\\carrier := H\\)\"\n by sorry\n\nlemma (in group) normal_restrict_supergroup:\n assumes \"subgroup S G\" \"N \\ G\" \"N \\ S\"\n shows \"N \\ (G\\carrier := S\\)\"\n by sorry\n\ntext \\A subgroup relation survives factoring by a normal subgroup.\\\nlemma (in group) normal_subgroup_factorize:\n assumes \"N \\ G\" and \"N \\ H\" and \"subgroup H G\"\n shows \"subgroup (rcosets\\<^bsub>G\\carrier := H\\\\<^esub> N) (G Mod N)\"\n by sorry\n\ntext \\A normality relation survives factoring by a normal subgroup.\\\nlemma (in group) normality_factorization:\n assumes NG: \"N \\ G\" and NH: \"N \\ H\" and HG: \"H \\ G\"\n shows \"(rcosets\\<^bsub>G\\carrier := H\\\\<^esub> N) \\ (G Mod N)\"\n by sorry\n\ntext \\Factorizing by the trivial subgroup is an isomorphism.\\\nlemma (in group) trivial_factor_iso:\n shows \"the_elem \\ iso (G Mod {\\}) G\"\n by sorry\n\ntext \\And the dual theorem to the previous one: Factorizing by the group itself gives the trivial group\\\n\nlemma (in group) self_factor_iso:\n shows \"(\\X. the_elem ((\\x. \\) ` X)) \\ iso (G Mod (carrier G)) (G\\ carrier := {\\} \\)\"\n by sorry\n\ntext \\Factoring by a normal subgroups yields the trivial group iff the subgroup is the whole group.\\\nlemma (in normal) fact_group_trivial_iff:\n assumes \"finite (carrier G)\"\n shows \"(carrier (G Mod H) = {\\\\<^bsub>G Mod H\\<^esub>}) \\ (H = carrier G)\"\n by sorry\n\ntext \\The union of all the cosets contained in a subgroup of a quotient group acts as a represenation for that subgroup.\\\n\nlemma (in normal) factgroup_subgroup_union_char:\n assumes \"subgroup A (G Mod H)\"\n shows \"(\\A) = {x \\ carrier G. H #> x \\ A}\"\n by sorry\n\nlemma (in normal) factgroup_subgroup_union_subgroup:\n assumes \"subgroup A (G Mod H)\"\n shows \"subgroup (\\A) G\"\n by sorry\n\nlemma (in normal) factgroup_subgroup_union_normal:\n assumes \"A \\ (G Mod H)\"\n shows \"\\A \\ G\"\n by sorry\n\nlemma (in normal) factgroup_subgroup_union_factor:\n assumes \"subgroup A (G Mod H)\"\n shows \"A = rcosets\\<^bsub>G\\carrier := \\A\\\\<^esub> H\"\n by sorry\n\nsection \\Flattening the type of group carriers\\\n\ntext \\Flattening here means to convert the type of group elements from 'a set to 'a.\nThis is possible whenever the empty set is not an element of the group. By Jakob von Raumer\\\n\ndefinition flatten where\n \"flatten (G::('a set, 'b) monoid_scheme) rep = \\carrier=(rep ` (carrier G)),\n monoid.mult=(\\ x y. rep ((the_inv_into (carrier G) rep x) \\\\<^bsub>G\\<^esub> (the_inv_into (carrier G) rep y))), \n one=rep \\\\<^bsub>G\\<^esub> \\\"\n\nlemma flatten_set_group_hom:\n assumes group: \"group G\"\n assumes inj: \"inj_on rep (carrier G)\"\n shows \"rep \\ hom G (flatten G rep)\"\n by sorry\n\nlemma flatten_set_group:\n assumes \"group G\" \"inj_on rep (carrier G)\"\n shows \"group (flatten G rep)\"\n by sorry\n\nlemma (in normal) flatten_set_group_mod_inj:\n shows \"inj_on (\\U. SOME g. g \\ U) (carrier (G Mod H))\"\n by sorry\n\nlemma (in normal) flatten_set_group_mod:\n shows \"group (flatten (G Mod H) (\\U. SOME g. g \\ U))\"\n by sorry\n\nlemma (in normal) flatten_set_group_mod_iso:\n shows \"(\\U. SOME g. g \\ U) \\ iso (G Mod H) (flatten (G Mod H) (\\U. SOME g. g \\ U))\"\n by sorry\n\nend" }, { "theorem_id": 42, "title": "051_wilson_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2022 John Nicol. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: John Nicol\n-/\nmodule\n\npublic import Mathlib.FieldTheory.Finite.Basic\n\n/-!\n# Wilson's theorem.\n\nThis file contains a proof of Wilson's theorem.\n\nThe heavy lifting is mostly done by the previous `wilsons_lemma`,\nbut here we also prove the other logical direction.\n\nThis could be generalized to similar results about finite abelian groups.\n\n## References\n\n* [Wilson's Theorem](https://en.wikipedia.org/wiki/Wilson%27s_theorem)\n\n## TODO\n\n* Give `wilsons_lemma` a descriptive name.\n-/\n\npublic section\n\nassert_not_exists legendreSym.quadratic_reciprocity\n\nopen Finset Nat FiniteField ZMod\n\nopen scoped Nat\n\nnamespace ZMod\n\nvariable (p : ℕ) [Fact p.Prime]\n\n/-- **Wilson's Lemma**: the product of `1`, ..., `p-1` is `-1` modulo `p`. -/\n@[simp]\ntheorem wilsons_lemma : ((p - 1)! : ZMod p) = -1 := by sorry\ntheorem prod_Ico_one_prime : ∏ x ∈ Ico 1 p, (x : ZMod p) = -1 := by sorry\nend ZMod\n\nnamespace Nat\n\nvariable {n : ℕ}\n\n/-- For `n ≠ 1`, `(n-1)!` is congruent to `-1` modulo `n` only if n is prime. -/\ntheorem prime_of_fac_equiv_neg_one (h : ((n - 1)! : ZMod n) = -1) (h1 : n ≠ 1) : Prime n := by sorry\ntheorem prime_iff_fac_equiv_neg_one (h : n ≠ 1) : Prime n ↔ ((n - 1)! : ZMod n) = -1 := by sorry\nend Nat\n" }, { "theorem_id": 42, "title": "051_wilson_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Export ZisMod.\nOpen Scope Z_scope.\n \nTheorem Zis_mod_rel_prime_inverse:\n forall a p,\n 1 < p ->\n rel_prime a p ->\n (exists b , ( 1 <= b <= p - 1 ) /\\ (rel_prime b p /\\ Zis_mod (a * b) 1 p) ).\nProof.\nAdmitted.\n \nTheorem wilson: forall p, prime p -> Zis_mod (Zfact (p - 1)) (- 1) p.\nProof.\nAdmitted.\nHint Unfold Zfact : core.\n \nTheorem wilson_converse:\n forall p, 1 < p -> Zis_mod (Zfact (p - 1)) (- 1) p -> prime p.\nProof.\nAdmitted." }, { "theorem_id": 43, "title": "052_the_number_of_subsets_of_a_set", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"int.ml\";;\n\nparse_as_infix(\"IN\",(11,\"right\"));;\nparse_as_infix(\"SUBSET\",(12,\"right\"));;\nparse_as_infix(\"PSUBSET\",(12,\"right\"));;\nparse_as_infix(\"INTER\",(20,\"right\"));;\nparse_as_infix(\"UNION\",(16,\"right\"));;\nparse_as_infix(\"DIFF\",(18,\"left\"));;\nparse_as_infix(\"INSERT\",(21,\"right\"));;\nparse_as_infix(\"DELETE\",(21,\"left\"));;\n\nparse_as_infix(\"HAS_SIZE\",(12,\"right\"));;\nparse_as_infix(\"<=_c\",(12,\"right\"));;\nparse_as_infix(\"<_c\",(12,\"right\"));;\nparse_as_infix(\">=_c\",(12,\"right\"));;\nparse_as_infix(\">_c\",(12,\"right\"));;\nparse_as_infix(\"=_c\",(12,\"right\"));;\n\nlet IN = new_definition\n `!P:A->bool. !x. x IN P <=> P x`;;\n\nlet EXTENSION = `!s t. (s = t) <=> !x:A. x IN s <=> x IN t`;;\n\nlet GSPEC = new_definition\n `GSPEC (p:A->bool) = p`;;\n\nlet SETSPEC = new_definition\n `SETSPEC (v:A) P t <=> P /\\ (v = t)`;;\n\nlet IN_ELIM_THM = `(!P x:A. x IN GSPEC (\\v. P (SETSPEC v)) <=> P (\\p t. p /\\ (x = t))) /\\\n (!p x:A. x IN GSPEC (\\v. ?y. SETSPEC v (p y) y) <=> p x) /\\\n (!P x:A. GSPEC (\\v. P (SETSPEC v)) x <=> P (\\p t. p /\\ (x = t))) /\\\n (!p x:A. GSPEC (\\v. ?y. SETSPEC v (p y) y) x <=> p x) /\\\n (!p x:A. x IN (\\y. p y) <=> p x)`;;\n\nlet EMPTY = new_definition\n `EMPTY = (\\x:A. F)`;;\n\nlet INSERT_DEF = new_definition\n `x INSERT s = \\y:A. y IN s \\/ (y = x)`;;\n\nlet UNIV = new_definition\n `UNIV = (\\x:A. T)`;;\n\nlet UNION = new_definition\n `s UNION t = {x:A | x IN s \\/ x IN t}`;;\n\nlet UNIONS = new_definition\n `UNIONS s = {x:A | ?u. u IN s /\\ x IN u}`;;\n\nlet INTER = new_definition\n `s INTER t = {x:A | x IN s /\\ x IN t}`;;\n\nlet INTERS = new_definition\n `INTERS s = {x:A | !u. u IN s ==> x IN u}`;;\n\nlet DIFF = new_definition\n `s DIFF t = {x:A | x IN s /\\ ~(x IN t)}`;;\n\nlet INSERT = `x INSERT s = {y:A | y IN s \\/ (y = x)}`;;\n\nlet DELETE = new_definition\n `s DELETE x = {y:A | y IN s /\\ ~(y = x)}`;;\n\nlet SUBSET = new_definition\n `s SUBSET t <=> !x:A. x IN s ==> x IN t`;;\n\nlet PSUBSET = new_definition\n `(s:A->bool) PSUBSET t <=> s SUBSET t /\\ ~(s = t)`;;\n\nlet DISJOINT = new_definition\n `DISJOINT (s:A->bool) t <=> (s INTER t = EMPTY)`;;\n\nlet SING = new_definition\n `SING s = ?x:A. s = {x}`;;\n\nlet FINITE_RULES,FINITE_INDUCT,FINITE_CASES =\n new_inductive_definition\n `FINITE (EMPTY:A->bool) /\\\n !(x:A) s. FINITE s ==> FINITE (x INSERT s)`;;\n\nlet INFINITE = new_definition\n `INFINITE (s:A->bool) <=> ~(FINITE s)`;;\n\nlet IMAGE = new_definition\n `IMAGE (f:A->B) s = { y | ?x. x IN s /\\ (y = f x)}`;;\n\nlet INJ = new_definition\n `INJ (f:A->B) s t <=>\n (!x. x IN s ==> (f x) IN t) /\\\n (!x y. x IN s /\\ y IN s /\\ (f x = f y) ==> (x = y))`;;\n\nlet SURJ = new_definition\n `SURJ (f:A->B) s t <=>\n (!x. x IN s ==> (f x) IN t) /\\\n (!x. (x IN t) ==> ?y. y IN s /\\ (f y = x))`;;\n\nlet BIJ = new_definition\n `BIJ (f:A->B) s t <=> INJ f s t /\\ SURJ f s t`;;\n\nlet CHOICE = new_definition\n `CHOICE s = @x:A. x IN s`;;\n\nlet REST = new_definition\n `REST (s:A->bool) = s DELETE (CHOICE s)`;;\n\nlet NOT_IN_EMPTY = `!x:A. ~(x IN EMPTY)`;;\n\nlet IN_UNIV = `!x:A. x IN UNIV`;;\n\nlet IN_UNION = `!s t (x:A). x IN (s UNION t) <=> x IN s \\/ x IN t`;;\n\nlet IN_UNIONS = `!s (x:A). x IN (UNIONS s) <=> ?t. t IN s /\\ x IN t`;;\n\nlet IN_INTER = `!s t (x:A). x IN (s INTER t) <=> x IN s /\\ x IN t`;;\n\nlet IN_INTERS = `!s (x:A). x IN (INTERS s) <=> !t. t IN s ==> x IN t`;;\n\nlet IN_DIFF = `!(s:A->bool) t x. x IN (s DIFF t) <=> x IN s /\\ ~(x IN t)`;;\n\nlet IN_INSERT = `!x:A. !y s. x IN (y INSERT s) <=> (x = y) \\/ x IN s`;;\n\nlet IN_DELETE = `!s. !x:A. !y. x IN (s DELETE y) <=> x IN s /\\ ~(x = y)`;;\n\nlet IN_SING = `!x y. x IN {y:A} <=> (x = y)`;;\n\nlet IN_IMAGE = `!y:B. !s f. (y IN (IMAGE f s)) <=> ?x:A. (y = f x) /\\ x IN s`;;\n\nlet IN_REST = `!x:A. !s. x IN (REST s) <=> x IN s /\\ ~(x = CHOICE s)`;;\n\nlet FORALL_IN_INSERT = `!P a s. (!x:A. x IN (a INSERT s) ==> P x) <=> P a /\\ (!x. x IN s ==> P x)`;;\n\nlet EXISTS_IN_INSERT = `!P a s. (?x:A. x IN (a INSERT s) /\\ P x) <=> P a \\/ ?x. x IN s /\\ P x`;;\n\nlet FORALL_IN_UNION = `!P s t:A->bool.\n (!x. x IN s UNION t ==> P x) <=>\n (!x. x IN s ==> P x) /\\ (!x. x IN t ==> P x)`;;\n\nlet EXISTS_IN_UNION = `!P s t:A->bool.\n (?x. x IN s UNION t /\\ P x) <=>\n (?x. x IN s /\\ P x) \\/ (?x. x IN t /\\ P x)`;;\n\nlet FORALL_IN_IMAGE = `!(f:A->B) s. (!y. y IN IMAGE f s ==> P y) <=> (!x. x IN s ==> P(f x))`;;\n\nlet EXISTS_IN_IMAGE = `!(f:A->B) s. (?y. y IN IMAGE f s /\\ P y) <=> ?x. x IN s /\\ P(f x)`;;\n\nlet FORALL_IN_GSPEC = `(!P Q (f:A->B). (!z. z IN {f x | P x} ==> Q z) <=> (!x. P x ==> Q(f x))) /\\\n (!P Q (f:A->B->C).\n (!z. z IN {f x y | P x y} ==> Q z) <=>\n (!x y. P x y ==> Q(f x y))) /\\\n (!P Q (f:A->B->C->D).\n (!z. z IN {f w x y | P w x y} ==> Q z) <=>\n (!w x y. P w x y ==> Q(f w x y))) /\\\n (!P Q (f:A->B->C->D->E).\n (!z. z IN {f v w x y | P v w x y} ==> Q z) <=>\n (!v w x y. P v w x y ==> Q(f v w x y)))`;;\n\nlet EXISTS_IN_GSPEC = `(!P Q (f:A->B). (?z. z IN {f x | P x} /\\ Q z) <=> (?x. P x /\\ Q(f x))) /\\\n (!P Q (f:A->B->C).\n (?z. z IN {f x y | P x y} /\\ Q z) <=>\n (?x y. P x y /\\ Q(f x y))) /\\\n (!P Q (f:A->B->C->D).\n (?z. z IN {f w x y | P w x y} /\\ Q z) <=>\n (?w x y. P w x y /\\ Q(f w x y))) /\\\n (!P Q (f:A->B->C->D->E).\n (?z. z IN {f v w x y | P v w x y} /\\ Q z) <=>\n (?v w x y. P v w x y /\\ Q(f v w x y)))`;;\n\nlet UNIONS_IMAGE = `!(f:A->B->bool) s. UNIONS (IMAGE f s) = {y | ?x. x IN s /\\ y IN f x}`;;\n\nlet INTERS_IMAGE = `!(f:A->B->bool) s. INTERS (IMAGE f s) = {y | !x. x IN s ==> y IN f x}`;;\n\nlet UNIONS_GSPEC = `(!P (f:A->B->bool).\n UNIONS {f x | P x} = {a | ?x. P x /\\ a IN (f x)}) /\\\n (!P (f:A->B->C->bool).\n UNIONS {f x y | P x y} = {a | ?x y. P x y /\\ a IN (f x y)}) /\\\n (!P (f:A->B->C->D->bool).\n UNIONS {f x y z | P x y z} =\n {a | ?x y z. P x y z /\\ a IN (f x y z)})`;;\n\nlet INTERS_GSPEC = `(!P (f:A->B->bool).\n INTERS {f x | P x} = {a | !x. P x ==> a IN (f x)}) /\\\n (!P (f:A->B->C->bool).\n INTERS {f x y | P x y} = {a | !x y. P x y ==> a IN (f x y)}) /\\\n (!P (f:A->B->C->D->bool).\n INTERS {f x y z | P x y z} =\n {a | !x y z. P x y z ==> a IN (f x y z)})`;;\n\nlet CHOICE_DEF = `!s:A->bool. ~(s = EMPTY) ==> (CHOICE s) IN s`;;\n\nlet SET_TAC =\n let PRESET_CONV =\n REWRITE_CONV[INTERS_IMAGE; INTERS_GSPEC; UNIONS_IMAGE; UNIONS_GSPEC] THENC\n REWRITE_CONV[EXTENSION; SUBSET; PSUBSET; DISJOINT; SING;\n BIJ; INJ; SURJ] THENC\n REWRITE_CONV[NOT_IN_EMPTY; IN_UNIV; IN_UNION; IN_INTER; IN_DIFF; IN_INSERT;\n IN_DELETE; IN_REST; IN_INTERS; IN_UNIONS; IN_IMAGE;\n IN_ELIM_THM; IN] in\n fun ths ->\n MAP_EVERY MP_TAC ths THEN POP_ASSUM_LIST(K ALL_TAC) THEN\n REPEAT(COND_CASES_TAC THEN POP_ASSUM MP_TAC) THEN\n CONV_TAC PRESET_CONV THEN MAP_EVERY MP_TAC\n (filter (fun th -> CONV_RULE PRESET_CONV th = TRUTH) ths) THEN\n REWRITE_TAC[IN] THEN MESON_TAC[];;\n\nlet SET_RULE tm = prove(tm,SET_TAC[]);;\n\nlet NOT_EQUAL_SETS = `!s:A->bool. !t. ~(s = t) <=> ?x. x IN t <=> ~(x IN s)`;;\n\nlet INSERT_RESTRICT = `!P s a:A.\n {x | x IN a INSERT s /\\ P x} =\n if P a then a INSERT {x | x IN s /\\ P x} else {x | x IN s /\\ P x}`;;\n\nlet UNIV_1 = `(:1) = {one}`;;\n\nlet MEMBER_NOT_EMPTY = `!s:A->bool. (?x. x IN s) <=> ~(s = EMPTY)`;;\n\nlet UNIV_NOT_EMPTY = `~(UNIV:A->bool = EMPTY)`;;\n\nlet EMPTY_NOT_UNIV = `~(EMPTY:A->bool = UNIV)`;;\n\nlet EQ_UNIV = `(!x:A. x IN s) <=> (s = UNIV)`;;\n\nlet SUBSET_TRANS = `!(s:A->bool) t u. s SUBSET t /\\ t SUBSET u ==> s SUBSET u`;;\n\nlet SUBSET_REFL = `!s:A->bool. s SUBSET s`;;\n\nlet SUBSET_ANTISYM = `!(s:A->bool) t. s SUBSET t /\\ t SUBSET s ==> s = t`;;\n\nlet SUBSET_ANTISYM_EQ = `!(s:A->bool) t. s SUBSET t /\\ t SUBSET s <=> s = t`;;\n\nlet EMPTY_SUBSET = `!s:A->bool. EMPTY SUBSET s`;;\n\nlet SUBSET_EMPTY = `!s:A->bool. s SUBSET EMPTY <=> (s = EMPTY)`;;\n\nlet SUBSET_UNIV = `!s:A->bool. s SUBSET UNIV`;;\n\nlet UNIV_SUBSET = `!s:A->bool. UNIV SUBSET s <=> (s = UNIV)`;;\n\nlet SING_SUBSET = `!s x:A. {x} SUBSET s <=> x IN s`;;\n\nlet SUBSET_RESTRICT = `!s P. {x:A | x IN s /\\ P x} SUBSET s`;;\n\nlet PSUBSET_TRANS = `!(s:A->bool) t u. s PSUBSET t /\\ t PSUBSET u ==> s PSUBSET u`;;\n\nlet PSUBSET_SUBSET_TRANS = `!(s:A->bool) t u. s PSUBSET t /\\ t SUBSET u ==> s PSUBSET u`;;\n\nlet SUBSET_PSUBSET_TRANS = `!(s:A->bool) t u. s SUBSET t /\\ t PSUBSET u ==> s PSUBSET u`;;\n\nlet PSUBSET_IRREFL = `!s:A->bool. ~(s PSUBSET s)`;;\n\nlet NOT_PSUBSET_EMPTY = `!s:A->bool. ~(s PSUBSET EMPTY)`;;\n\nlet NOT_UNIV_PSUBSET = `!s:A->bool. ~(UNIV PSUBSET s)`;;\n\nlet PSUBSET_UNIV = `!s:A->bool. s PSUBSET UNIV <=> ?x. ~(x IN s)`;;\n\nlet PSUBSET_ALT = `!s t:A->bool. s PSUBSET t <=> s SUBSET t /\\ (?a. a IN t /\\ ~(a IN s))`;;\n\nlet UNION_ASSOC = `!(s:A->bool) t u. (s UNION t) UNION u = s UNION (t UNION u)`;;\n\nlet UNION_IDEMPOT = `!s:A->bool. s UNION s = s`;;\n\nlet UNION_COMM = `!(s:A->bool) t. s UNION t = t UNION s`;;\n\nlet SUBSET_UNION = `(!s:A->bool. !t. s SUBSET (s UNION t)) /\\\n (!s:A->bool. !t. s SUBSET (t UNION s))`;;\n\nlet SUBSET_UNION_ABSORPTION = `!s:A->bool. !t. s SUBSET t <=> (s UNION t = t)`;;\n\nlet UNION_EMPTY = `(!s:A->bool. EMPTY UNION s = s) /\\\n (!s:A->bool. s UNION EMPTY = s)`;;\n\nlet UNION_UNIV = `(!s:A->bool. UNIV UNION s = UNIV) /\\\n (!s:A->bool. s UNION UNIV = UNIV)`;;\n\nlet EMPTY_UNION = `!s:A->bool. !t. (s UNION t = EMPTY) <=> (s = EMPTY) /\\ (t = EMPTY)`;;\n\nlet UNION_SUBSET = `!s t u:A->bool. (s UNION t) SUBSET u <=> s SUBSET u /\\ t SUBSET u`;;\n\nlet UNION_RESTRICT = `!P s t:A->bool.\n {x | x IN (s UNION t) /\\ P x} =\n {x | x IN s /\\ P x} UNION {x | x IN t /\\ P x}`;;\n\nlet FORALL_SUBSET_UNION = `!t u:A->bool.\n (!s. s SUBSET t UNION u ==> P s) <=>\n (!t' u'. t' SUBSET t /\\ u' SUBSET u ==> P(t' UNION u'))`;;\n\nlet EXISTS_SUBSET_UNION = `!t u:A->bool.\n (?s. s SUBSET t UNION u /\\ P s) <=>\n (?t' u'. t' SUBSET t /\\ u' SUBSET u /\\ P(t' UNION u'))`;;\n\nlet FORALL_SUBSET_INSERT = `!a:A t. (!s. s SUBSET a INSERT t ==> P s) <=>\n (!s. s SUBSET t ==> P s /\\ P (a INSERT s))`;;\n\nlet EXISTS_SUBSET_INSERT = `!a:A t. (?s. s SUBSET a INSERT t /\\ P s) <=>\n (?s. s SUBSET t /\\ (P s \\/ P (a INSERT s)))`;;\n\nlet INTER_ASSOC = `!(s:A->bool) t u. (s INTER t) INTER u = s INTER (t INTER u)`;;\n\nlet INTER_IDEMPOT = `!s:A->bool. s INTER s = s`;;\n\nlet INTER_COMM = `!(s:A->bool) t. s INTER t = t INTER s`;;\n\nlet INTER_SUBSET = `(!s:A->bool. !t. (s INTER t) SUBSET s) /\\\n (!s:A->bool. !t. (t INTER s) SUBSET s)`;;\n\nlet SUBSET_INTER_ABSORPTION = `!s:A->bool. !t. s SUBSET t <=> (s INTER t = s)`;;\n\nlet INTER_EMPTY = `(!s:A->bool. EMPTY INTER s = EMPTY) /\\\n (!s:A->bool. s INTER EMPTY = EMPTY)`;;\n\nlet INTER_UNIV = `(!s:A->bool. UNIV INTER s = s) /\\\n (!s:A->bool. s INTER UNIV = s)`;;\n\nlet SUBSET_INTER = `!s t u:A->bool. s SUBSET (t INTER u) <=> s SUBSET t /\\ s SUBSET u`;;\n\nlet INTER_RESTRICT = `!P s (t:A->bool).\n {x | x IN (s INTER t) /\\ P x} =\n {x | x IN s /\\ P x} INTER {x | x IN t /\\ P x}`;;\n\nlet UNION_OVER_INTER = `!s:A->bool. !t u. s INTER (t UNION u) = (s INTER t) UNION (s INTER u)`;;\n\nlet INTER_OVER_UNION = `!s:A->bool. !t u. s UNION (t INTER u) = (s UNION t) INTER (s UNION u)`;;\n\nlet IN_DISJOINT = `!s:A->bool. !t. DISJOINT s t <=> ~(?x. x IN s /\\ x IN t)`;;\n\nlet DISJOINT_SYM = `!s:A->bool. !t. DISJOINT s t <=> DISJOINT t s`;;\n\nlet DISJOINT_EMPTY = `!s:A->bool. DISJOINT EMPTY s /\\ DISJOINT s EMPTY`;;\n\nlet DISJOINT_EMPTY_REFL = `!s:A->bool. (s = EMPTY) <=> (DISJOINT s s)`;;\n\nlet DISJOINT_UNION = `!s:A->bool. !t u. DISJOINT (s UNION t) u <=> DISJOINT s u /\\ DISJOINT t u`;;\n\nlet DISJOINT_SING = `(!s a:A. DISJOINT s {a} <=> ~(a IN s)) /\\\n (!s a:A. DISJOINT {a} s <=> ~(a IN s))`;;\n\nlet DIFF_EMPTY = `!s:A->bool. s DIFF EMPTY = s`;;\n\nlet EMPTY_DIFF = `!s:A->bool. EMPTY DIFF s = EMPTY`;;\n\nlet DIFF_UNIV = `!s:A->bool. s DIFF UNIV = EMPTY`;;\n\nlet DIFF_DIFF = `!s:A->bool. !t. (s DIFF t) DIFF t = s DIFF t`;;\n\nlet DIFF_EQ_EMPTY = `!s:A->bool. s DIFF s = EMPTY`;;\n\nlet SUBSET_DIFF = `!s t:A->bool. (s DIFF t) SUBSET s`;;\n\nlet COMPL_COMPL = `!s. (:A) DIFF ((:A) DIFF s) = s`;;\n\nlet DIFF_RESTRICT = `!P s (t:A->bool).\n {x | x IN (s DIFF t) /\\ P x} =\n {x | x IN s /\\ P x} DIFF {x | x IN t /\\ P x}`;;\n\nlet COMPONENT = `!x:A. !s. x IN (x INSERT s)`;;\n\nlet DECOMPOSITION = `!s:A->bool. !x. x IN s <=> ?t. (s = x INSERT t) /\\ ~(x IN t)`;;\n\nlet SET_CASES = `!s:A->bool. (s = EMPTY) \\/ ?x:A. ?t. (s = x INSERT t) /\\ ~(x IN t)`;;\n\nlet ABSORPTION = `!x:A. !s. x IN s <=> (x INSERT s = s)`;;\n\nlet INSERT_INSERT = `!x:A. !s. x INSERT (x INSERT s) = x INSERT s`;;\n\nlet INSERT_COMM = `!x:A. !y s. x INSERT (y INSERT s) = y INSERT (x INSERT s)`;;\n\nlet INSERT_UNIV = `!x:A. x INSERT UNIV = UNIV`;;\n\nlet NOT_INSERT_EMPTY = `!x:A. !s. ~(x INSERT s = EMPTY)`;;\n\nlet NOT_EMPTY_INSERT = `!x:A. !s. ~(EMPTY = x INSERT s)`;;\n\nlet INSERT_UNION = `!x:A. !s t. (x INSERT s) UNION t =\n if x IN t then s UNION t else x INSERT (s UNION t)`;;\n\nlet INSERT_UNION_EQ = `!x:A. !s t. (x INSERT s) UNION t = x INSERT (s UNION t)`;;\n\nlet INSERT_INTER = `!x:A. !s t. (x INSERT s) INTER t =\n if x IN t then x INSERT (s INTER t) else s INTER t`;;\n\nlet DISJOINT_INSERT = `!(x:A) s t. DISJOINT (x INSERT s) t <=> (DISJOINT s t) /\\ ~(x IN t)`;;\n\nlet INSERT_SUBSET = `!x:A. !s t. (x INSERT s) SUBSET t <=> (x IN t /\\ s SUBSET t)`;;\n\nlet SUBSET_INSERT = `!x:A. !s. ~(x IN s) ==> !t. s SUBSET (x INSERT t) <=> s SUBSET t`;;\n\nlet INSERT_DIFF = `!s t. !x:A. (x INSERT s) DIFF t =\n if x IN t then s DIFF t else x INSERT (s DIFF t)`;;\n\nlet INSERT_AC = `(x:A) INSERT (y INSERT s) = y INSERT (x INSERT s) /\\\n x INSERT (x INSERT s) = x INSERT s`;;\n\nlet INTER_ACI = `((p:A->bool) INTER q = q INTER p) /\\\n ((p INTER q) INTER r = p INTER q INTER r) /\\\n (p INTER q INTER r = q INTER p INTER r) /\\\n (p INTER p = p) /\\\n (p INTER p INTER q = p INTER q)`;;\n\nlet UNION_ACI = `((p:A->bool) UNION q = q UNION p) /\\\n ((p UNION q) UNION r = p UNION q UNION r) /\\\n (p UNION q UNION r = q UNION p UNION r) /\\\n (p UNION p = p) /\\\n (p UNION p UNION q = p UNION q)`;;\n\nlet DELETE_NON_ELEMENT = `!x:A. !s. ~(x IN s) <=> (s DELETE x = s)`;;\n\nlet IN_DELETE_EQ = `!s x. !x':A.\n (x IN s <=> x' IN s) <=> (x IN (s DELETE x') <=> x' IN (s DELETE x))`;;\n\nlet EMPTY_DELETE = `!x:A. EMPTY DELETE x = EMPTY`;;\n\nlet DELETE_DELETE = `!x:A. !s. (s DELETE x) DELETE x = s DELETE x`;;\n\nlet DELETE_COMM = `!x:A. !y. !s. (s DELETE x) DELETE y = (s DELETE y) DELETE x`;;\n\nlet DELETE_SUBSET = `!x:A. !s. (s DELETE x) SUBSET s`;;\n\nlet SUBSET_DELETE = `!x:A. !s t. s SUBSET (t DELETE x) <=> ~(x IN s) /\\ (s SUBSET t)`;;\n\nlet SUBSET_INSERT_DELETE = `!x:A. !s t. s SUBSET (x INSERT t) <=> ((s DELETE x) SUBSET t)`;;\n\nlet DIFF_INSERT = `!s t. !x:A. s DIFF (x INSERT t) = (s DELETE x) DIFF t`;;\n\nlet PSUBSET_INSERT_SUBSET = `!s t. s PSUBSET t <=> ?x:A. ~(x IN s) /\\ (x INSERT s) SUBSET t`;;\n\nlet DELETE_INSERT = `!x:A. !y s.\n (x INSERT s) DELETE y =\n if x = y then s DELETE y else x INSERT (s DELETE y)`;;\n\nlet INSERT_DELETE = `!x:A. !s. x IN s ==> (x INSERT (s DELETE x) = s)`;;\n\nlet DELETE_INTER = `!s t. !x:A. (s DELETE x) INTER t = (s INTER t) DELETE x`;;\n\nlet DISJOINT_DELETE_SYM = `!s t. !x:A. DISJOINT (s DELETE x) t = DISJOINT (t DELETE x) s`;;\n\nlet UNIONS_0 = `UNIONS {}:A->bool = {}`;;\n\nlet UNIONS_1 = `!s:A->bool. UNIONS {s} = s`;;\n\nlet UNIONS_2 = `!s (t:A->bool). UNIONS {s,t} = s UNION t`;;\n\nlet UNIONS_INSERT = `!(s:A->bool) u. UNIONS (s INSERT u) = s UNION (UNIONS u)`;;\n\nlet FORALL_IN_UNIONS = `!P s. (!x:A. x IN UNIONS s ==> P x) <=> !t x. t IN s /\\ x IN t ==> P x`;;\n\nlet EXISTS_IN_UNIONS = `!P s. (?x:A. x IN UNIONS s /\\ P x) <=> (?t x. t IN s /\\ x IN t /\\ P x)`;;\n\nlet EMPTY_UNIONS = `!s. (UNIONS s = {}) <=> !t:A->bool. t IN s ==> t = {}`;;\n\nlet INTER_UNIONS = `(!s (t:A->bool). UNIONS s INTER t = UNIONS {x INTER t | x IN s}) /\\\n (!s (t:A->bool). t INTER UNIONS s = UNIONS {t INTER x | x IN s})`;;\n\nlet UNIONS_SUBSET = `!f (t:A->bool). UNIONS f SUBSET t <=> !s. s IN f ==> s SUBSET t`;;\n\nlet SUBSET_UNIONS = `!(f:(A->bool)->bool) g. f SUBSET g ==> UNIONS f SUBSET UNIONS g`;;\n\nlet UNIONS_UNION = `!s t:(A->bool)->bool. UNIONS(s UNION t) = (UNIONS s) UNION (UNIONS t)`;;\n\nlet INTERS_UNION = `!s t:(A->bool)->bool. INTERS (s UNION t) = INTERS s INTER INTERS t`;;\n\nlet UNIONS_MONO = `!s t:(A->bool)->bool.\n (!x. x IN s ==> ?y. y IN t /\\ x SUBSET y) ==> UNIONS s SUBSET UNIONS t`;;\n\nlet UNIONS_MONO_IMAGE = `!(f:A->B->bool) g s.\n (!x. x IN s ==> f x SUBSET g x)\n ==> UNIONS(IMAGE f s) SUBSET UNIONS(IMAGE g s)`;;\n\nlet UNIONS_UNIV = `UNIONS (:A->bool) = (:A)`;;\n\nlet UNIONS_INSERT_EMPTY = `!s:(A->bool)->bool. UNIONS({} INSERT s) = UNIONS s`;;\n\nlet UNIONS_DELETE_EMPTY = `!s:(A->bool)->bool. UNIONS(s DELETE {}) = UNIONS s`;;\n\nlet INTERS_0 = `INTERS {} = (:A)`;;\n\nlet INTERS_1 = `!s:A->bool. INTERS {s} = s`;;\n\nlet INTERS_2 = `!s (t:A->bool). INTERS {s,t} = s INTER t`;;\n\nlet INTERS_INSERT = `!(s:A->bool) u. INTERS (s INSERT u) = s INTER (INTERS u)`;;\n\nlet SUBSET_INTERS = `!(s:A->bool) f. s SUBSET INTERS f <=> (!t. t IN f ==> s SUBSET t)`;;\n\nlet INTERS_SUBSET = `!u s:A->bool.\n ~(u = {}) /\\ (!t. t IN u ==> t SUBSET s) ==> INTERS u SUBSET s`;;\n\nlet INTERS_SUBSET_STRONG = `!u s:A->bool. (?t. t IN u /\\ t SUBSET s) ==> INTERS u SUBSET s`;;\n\nlet INTERS_ANTIMONO = `!(f:(A->bool)->bool) g. g SUBSET f ==> INTERS f SUBSET INTERS g`;;\n\nlet INTERS_EQ_UNIV = `!f. INTERS f = (:A) <=> !s. s IN f ==> s = (:A)`;;\n\nlet INTERS_ANTIMONO_GEN = `!s (t:(A->bool)->bool).\n (!y. y IN t ==> ?x. x IN s /\\ x SUBSET y)\n ==> INTERS s SUBSET INTERS t`;;\n\nlet IMAGE_CLAUSES = `(IMAGE (f:A->B) {} = {}) /\\\n (IMAGE f (x INSERT s) = (f x) INSERT (IMAGE f s))`;;\n\nlet IMAGE_UNION = `!(f:A->B) s t. IMAGE f (s UNION t) = (IMAGE f s) UNION (IMAGE f t)`;;\n\nlet IMAGE_ID = `!s:A->bool. IMAGE (\\x. x) s = s`;;\n\nlet IMAGE_I = `!s:A->bool. IMAGE I s = s`;;\n\nlet IMAGE_o = `!(f:B->C) (g:A->B) s. IMAGE (f o g) s = IMAGE f (IMAGE g s)`;;\n\nlet IMAGE_SUBSET = `!(f:A->B) s t. s SUBSET t ==> (IMAGE f s) SUBSET (IMAGE f t)`;;\n\nlet IMAGE_INTER_INJ = `!(f:A->B) s t.\n (!x y. f(x) = f(y) ==> x = y)\n ==> (IMAGE f (s INTER t) = (IMAGE f s) INTER (IMAGE f t))`;;\n\nlet IMAGE_DIFF_INJ = `!f:A->B s t.\n (!x y. x IN s /\\ y IN t /\\ f x = f y ==> x = y)\n ==> IMAGE f (s DIFF t) = IMAGE f s DIFF IMAGE f t`;;\n\nlet IMAGE_DIFF_INJ_ALT = `!f:A->B s t.\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y) /\\ t SUBSET s\n ==> IMAGE f (s DIFF t) = IMAGE f s DIFF IMAGE f t`;;\n\nlet IMAGE_DELETE_INJ = `!f:A->B s a.\n (!x. x IN s /\\ f x = f a ==> x = a)\n ==> IMAGE f (s DELETE a) = IMAGE f s DELETE f a`;;\n\nlet IMAGE_DELETE_INJ_ALT = `!f:A->B s a.\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y) /\\ a IN s\n ==> IMAGE f (s DELETE a) = IMAGE f s DELETE f a`;;\n\nlet IMAGE_EQ_EMPTY = `!(f:A->B) s. (IMAGE f s = {}) <=> (s = {})`;;\n\nlet FORALL_IN_IMAGE_2 = `!(f:A->B) P s. (!x y. x IN IMAGE f s /\\ y IN IMAGE f s ==> P x y) <=>\n (!x y. x IN s /\\ y IN s ==> P (f x) (f y))`;;\n\nlet IMAGE_CONST = `!(s:A->bool) (c:B). IMAGE (\\x. c) s = if s = {} then {} else {c}`;;\n\nlet SIMPLE_IMAGE = `!(f:A->B) s. {f x | x IN s} = IMAGE f s`;;\n\nlet SIMPLE_IMAGE_GEN = `!(f:A->B) P. {f x | P x} = IMAGE f {x | P x}`;;\n\nlet IMAGE_UNIONS = `!(f:A->B) s. IMAGE f (UNIONS s) = UNIONS (IMAGE (IMAGE f) s)`;;\n\nlet FUN_IN_IMAGE = `!(f:A->B) s x. x IN s ==> f(x) IN IMAGE f s`;;\n\nlet SURJECTIVE_IMAGE_EQ = `!(f:A->B) s t.\n (!y. y IN t ==> ?x. f x = y) /\\ (!x. (f x) IN t <=> x IN s)\n ==> IMAGE f s = t`;;\n\nlet IMAGE_EQ = `!(f:A->B) g s. (!x. x IN s ==> f x = g x) ==> IMAGE f s = IMAGE g s`;;\n\nlet EMPTY_GSPEC = `{x:A | F} = {}`;;\n\nlet UNIV_GSPEC = `{x | T} = (:A)`;;\n\nlet SING_GSPEC = `(!a:A. {x | x = a} = {a}) /\\\n (!a:A. {x | a = x} = {a})`;;\n\nlet SING_ALT = `!s:A->bool. (?x. s = {x}) <=> ?!x. x IN s`;;\n\nlet IN_GSPEC = `!s:A->bool. {x | x IN s} = s`;;\n\nlet IN_ELIM_PAIR_THM = `!(P:A->B->bool) a b. (a,b) IN {(x,y) | P x y} <=> P a b`;;\n\nlet IN_ELIM_TRIPLE_THM = `(!(P:A->B->C->bool) a b c. (a,b,c) IN {(x,y,z) | P x y z} <=> P a b c) /\\\n (!(P:A->B->C->bool) a b c. ((a,b),c) IN {((x,y),z) | P x y z} <=> P a b c)`;;\n\nlet IN_ELIM_QUAD_THM = `(!(P:A->B->C->D->bool) a b c d.\n (a,b,c,d) IN {w,x,y,z | P w x y z} <=> P a b c d) /\\\n (!(P:A->B->C->D->bool) a b c d.\n ((a,b),(c,d)) IN {(w,x),(y,z) | P w x y z} <=> P a b c d) /\\\n (!(P:A->B->C->D->bool) a b c d.\n (((a,b),c),d) IN {(((w,x),y),z) | P w x y z} <=> P a b c d)`;;\n\nlet SET_PAIR_THM = `!(P:A#B->bool). {p | P p} = {(a,b) | P(a,b)}`;;\n\nlet SET_PROVE_CASES = `!P:(A->bool)->bool.\n P {} /\\ (!a s. ~(a IN s) ==> P(a INSERT s))\n ==> !s. P s`;;\n\nlet UNIONS_SINGS_GEN = `!P:A->bool. UNIONS {{x} | P x} = {x | P x}`;;\n\nlet UNIONS_SINGS = `!s:A->bool. UNIONS {{x} | x IN s} = s`;;\n\nlet IMAGE_INTERS = `!(f:A->B) s.\n ~(s = {}) /\\\n (!x y. x IN UNIONS s /\\ y IN UNIONS s /\\ f x = f y ==> x = y)\n ==> IMAGE f (INTERS s) = INTERS(IMAGE (IMAGE f) s)`;;\n\nlet DIFF_INTERS = `!(u:A->bool) s. u DIFF INTERS s = UNIONS {u DIFF t | t IN s}`;;\n\nlet INTERS_UNIONS = `!s. INTERS s = UNIV DIFF (UNIONS {(:A) DIFF t | t IN s})`;;\n\nlet UNIONS_INTERS = `!s. UNIONS s = UNIV DIFF (INTERS {(:A) DIFF t | t IN s})`;;\n\nlet UNIONS_DIFF = `!s t:A->bool. UNIONS s DIFF t = UNIONS {x DIFF t | x IN s}`;;\n\nlet DIFF_UNIONS = `!(u:A->bool) s. u DIFF UNIONS s = u INTER INTERS {u DIFF t | t IN s}`;;\n\nlet DIFF_UNIONS_NONEMPTY = `!(u:A->bool) s. ~(s = {}) ==> u DIFF UNIONS s = INTERS {u DIFF t | t IN s}`;;\n\nlet INTERS_OVER_UNIONS = `!f:A->(B->bool)->bool s.\n INTERS { UNIONS(f x) | x IN s} =\n UNIONS { INTERS {g x | x IN s} |g| !x. x IN s ==> g x IN f x}`;;\n\nlet INTER_INTERS = `(!f s:A->bool.\n s INTER INTERS f =\n if f = {} then s else INTERS {s INTER t | t IN f}) /\\\n (!f s:A->bool.\n INTERS f INTER s =\n if f = {} then s else INTERS {t INTER s | t IN f})`;;\n\nlet UNIONS_OVER_INTERS = `!f:A->(B->bool)->bool s.\n UNIONS { INTERS(f x) | x IN s} =\n INTERS { UNIONS {g x | x IN s} |g| !x. x IN s ==> g x IN f x}`;;\n\nlet UNIONS_EQ_INTERS = `!f:(A->bool)->bool. UNIONS f = INTERS f <=> ?s. f = {s}`;;\n\nlet EXISTS_UNIQUE_UNIONS_INTERS = `!P. (?!s:A->bool. P s) <=> UNIONS {s | P s} = INTERS {s | P s}`;;\n\nlet IMAGE_INTERS_SUBSET = `!(f:A->B) g. IMAGE f (INTERS g) SUBSET INTERS (IMAGE (IMAGE f) g)`;;\n\nlet IMAGE_INTER_SUBSET = `!(f:A->B) s t. IMAGE f (s INTER t) SUBSET IMAGE f s INTER IMAGE f t`;;\n\nlet IMAGE_INTER_SATURATED_GEN = `!f:A->B s t u.\n {x | x IN u /\\ f(x) IN IMAGE f s} SUBSET s /\\ t SUBSET u \\/\n {x | x IN u /\\ f(x) IN IMAGE f t} SUBSET t /\\ s SUBSET u\n ==> IMAGE f (s INTER t) = IMAGE f s INTER IMAGE f t`;;\n\nlet IMAGE_INTERS_SATURATED_GEN = `!f:A->B g s u.\n ~(g = {}) /\\\n (!t. t IN g ==> t SUBSET u) /\\\n (!t. t IN g DELETE s ==> {x | x IN u /\\ f(x) IN IMAGE f t} SUBSET t)\n ==> IMAGE f (INTERS g) = INTERS (IMAGE (IMAGE f) g)`;;\n\nlet IMAGE_INTER_SATURATED = `!f:A->B s t.\n {x | f(x) IN IMAGE f s} SUBSET s \\/ {x | f(x) IN IMAGE f t} SUBSET t\n ==> IMAGE f (s INTER t) = IMAGE f s INTER IMAGE f t`;;\n\nlet IMAGE_INTERS_SATURATED = `!f:A->B g s.\n ~(g = {}) /\\ (!t. t IN g DELETE s ==> {x | f(x) IN IMAGE f t} SUBSET t)\n ==> IMAGE f (INTERS g) = INTERS (IMAGE (IMAGE f) g)`;;\n\nlet FINITE_INDUCT_STRONG = `!P:(A->bool)->bool.\n P {} /\\ (!x s. P s /\\ ~(x IN s) /\\ FINITE s ==> P(x INSERT s))\n ==> !s. FINITE s ==> P s`;;\n\nlet INJECTIVE_ON_ALT = `!P f:A->B.\n (!x y. P x /\\ P y /\\ f x = f y ==> x = y) <=>\n (!x y. P x /\\ P y ==> (f x = f y <=> x = y))`;;\n\nlet INJECTIVE_ALT = `!f:A->B. (!x y. f x = f y ==> x = y) <=> (!x y. f x = f y <=> x = y)`;;\n\nlet SURJECTIVE_ON_RIGHT_INVERSE = `!(f:A->B) t.\n (!y. y IN t ==> ?x. x IN s /\\ (f(x) = y)) <=>\n (?g. !y. y IN t ==> g(y) IN s /\\ (f(g(y)) = y))`;;\n\nlet INJECTIVE_ON_LEFT_INVERSE = `!(f:A->B) s. (!x y. x IN s /\\ y IN s /\\ (f x = f y) ==> (x = y)) <=>\n (?g. !x. x IN s ==> (g(f(x)) = x))`;;\n\nlet BIJECTIVE_ON_LEFT_RIGHT_INVERSE = `!(f:A->B) s t.\n (!x. x IN s ==> f(x) IN t)\n ==> ((!x y. x IN s /\\ y IN s /\\ f(x) = f(y) ==> x = y) /\\\n (!y. y IN t ==> ?x. x IN s /\\ f x = y) <=>\n ?g. (!y. y IN t ==> g(y) IN s) /\\\n (!y. y IN t ==> (f(g(y)) = y)) /\\\n (!x. x IN s ==> (g(f(x)) = x)))`;;\n\nlet SURJECTIVE_RIGHT_INVERSE = `!f:A->B. (!y. ?x. f(x) = y) <=> (?g. !y. f(g(y)) = y)`;;\n\nlet INJECTIVE_LEFT_INVERSE = `!f:A->B. (!x y. f x = f y ==> x = y) <=> (?g. !x. g(f(x)) = x)`;;\n\nlet BIJECTIVE_LEFT_RIGHT_INVERSE = `!f:A->B.\n (!x y. f(x) = f(y) ==> x = y) /\\ (!y. ?x. f x = y) <=>\n ?g. (!y. f(g(y)) = y) /\\ (!x. g(f(x)) = x)`;;\n\nlet FUNCTION_FACTORS_LEFT_GEN = `!P (f:A->B) (g:A->C).\n (!x y. P x /\\ P y /\\ g x = g y ==> f x = f y) <=>\n (?h. !x. P x ==> f(x) = h(g x))`;;\n\nlet FUNCTION_FACTORS_LEFT = `!(f:A->B) (g:A->C). (!x y. g x = g y ==> f x = f y) <=> ?h. f = h o g`;;\n\nlet FUNCTION_FACTORS_RIGHT_GEN = `!P (f:A->C) (g:B->C).\n (!x. P x ==> ?y. g(y) = f(x)) <=>\n (?h. !x. P x ==> f(x) = g(h x))`;;\n\nlet FUNCTION_FACTORS_RIGHT = `!(f:A->C) (g:B->C). (!x. ?y. g(y) = f(x)) <=> ?h. f = g o h`;;\n\nlet SURJECTIVE_FORALL_THM = `!f:A->B. (!y. ?x. f x = y) <=> (!P. (!x. P(f x)) <=> (!y. P y))`;;\n\nlet SURJECTIVE_EXISTS_THM = `!f:A->B. (!y. ?x. f x = y) <=> (!P. (?x. P(f x)) <=> (?y. P y))`;;\n\nlet SURJECTIVE_IMAGE_THM = `!f:A->B. (!y. ?x. f x = y) <=> (!P. IMAGE f {x | P(f x)} = {x | P x})`;;\n\nlet IMAGE_INJECTIVE_IMAGE_OF_SUBSET = `!f:A->B s.\n ?t. t SUBSET s /\\\n IMAGE f s = IMAGE f t /\\\n (!x y. x IN t /\\ y IN t /\\ f x = f y ==> x = y)`;;\n\nlet FINITE_EMPTY = `FINITE ({}:A->bool)`;;\n\nlet FINITE_SUBSET = `!(s:A->bool) t. FINITE t /\\ s SUBSET t ==> FINITE s`;;\n\nlet FINITE_RESTRICT = `!s:A->bool P. FINITE s ==> FINITE {x | x IN s /\\ P x}`;;\n\nlet FINITE_UNION_IMP = `!(s:A->bool) t. FINITE s /\\ FINITE t ==> FINITE (s UNION t)`;;\n\nlet FINITE_UNION = `!(s:A->bool) t. FINITE(s UNION t) <=> FINITE(s) /\\ FINITE(t)`;;\n\nlet FINITE_INTER = `!(s:A->bool) t. FINITE s \\/ FINITE t ==> FINITE (s INTER t)`;;\n\nlet FINITE_INSERT = `!(s:A->bool) x. FINITE (x INSERT s) <=> FINITE s`;;\n\nlet FINITE_SING = `!a:A. FINITE {a}`;;\n\nlet FINITE_DELETE_IMP = `!(s:A->bool) x. FINITE s ==> FINITE (s DELETE x)`;;\n\nlet FINITE_DELETE = `!(s:A->bool) x. FINITE (s DELETE x) <=> FINITE s`;;\n\nlet FINITE_FINITE_UNIONS = `!s:(A->bool)->bool.\n FINITE(s) ==> (FINITE(UNIONS s) <=> (!t. t IN s ==> FINITE(t)))`;;\n\nlet FINITE_IMAGE_EXPAND = `!(f:A->B) s. FINITE s ==> FINITE {y | ?x. x IN s /\\ (y = f x)}`;;\n\nlet FINITE_IMAGE = `!(f:A->B) s. FINITE s ==> FINITE (IMAGE f s)`;;\n\nlet FINITE_IMAGE_INJ_GENERAL = `!(f:A->B) A s.\n (!x y. x IN s /\\ y IN s /\\ f(x) = f(y) ==> x = y) /\\\n FINITE A\n ==> FINITE {x | x IN s /\\ f(x) IN A}`;;\n\nlet FINITE_FINITE_PREIMAGE_GENERAL = `!f:A->B s t.\n FINITE t /\\\n (!y. y IN t ==> FINITE {x | x IN s /\\ f(x) = y})\n ==> FINITE {x | x IN s /\\ f(x) IN t}`;;\n\nlet FINITE_FINITE_PREIMAGE = `!f:A->B t.\n FINITE t /\\\n (!y. y IN t ==> FINITE {x | f(x) = y})\n ==> FINITE {x | f(x) IN t}`;;\n\nlet FINITE_IMAGE_INJ_EQ = `!(f:A->B) s.\n (!x y. x IN s /\\ y IN s /\\ f(x) = f(y) ==> x = y)\n ==> (FINITE(IMAGE f s) <=> FINITE s)`;;\n\nlet FINITE_IMAGE_INJ = `!(f:A->B) A.\n (!x y. f(x) = f(y) ==> x = y) /\\ FINITE A\n ==> FINITE {x | f(x) IN A}`;;\n\nlet FINITE_IMAGE_GEN = `!(f:A->B) (g:A->C) s t.\n IMAGE f s SUBSET t /\\ FINITE t /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> g x = g y)\n ==> FINITE(IMAGE g s)`;;\n\nlet INFINITE_IMAGE = `!f:A->B s.\n INFINITE s /\\ (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)\n ==> INFINITE (IMAGE f s)`;;\n\nlet INFINITE_IMAGE_INJ = `!f:A->B. (!x y. (f x = f y) ==> (x = y))\n ==> !s. INFINITE s ==> INFINITE(IMAGE f s)`;;\n\nlet INFINITE_NONEMPTY = `!s:A->bool. INFINITE(s) ==> ~(s = EMPTY)`;;\n\nlet INFINITE_DIFF_FINITE = `!s:A->bool t. INFINITE(s) /\\ FINITE(t) ==> INFINITE(s DIFF t)`;;\n\nlet SUBSET_IMAGE_INJ = `!f:A->B s t.\n s SUBSET (IMAGE f t) <=>\n ?u. u SUBSET t /\\\n (!x y. x IN u /\\ y IN u ==> (f x = f y <=> x = y)) /\\\n s = IMAGE f u`;;\n\nlet SUBSET_IMAGE = `!f:A->B s t. s SUBSET (IMAGE f t) <=> ?u. u SUBSET t /\\ (s = IMAGE f u)`;;\n\nlet EXISTS_SUBSET_IMAGE = `!P (f:A->B) s.\n (?t. t SUBSET IMAGE f s /\\ P t) <=> (?t. t SUBSET s /\\ P (IMAGE f t))`;;\n\nlet FORALL_SUBSET_IMAGE = `!P (f:A->B) s.\n (!t. t SUBSET IMAGE f s ==> P t) <=>\n (!t. t SUBSET s ==> P(IMAGE f t))`;;\n\nlet EXISTS_SUBSET_IMAGE_INJ = `!P (f:A->B) s.\n (?t. t SUBSET IMAGE f s /\\ P t) <=>\n (?t. t SUBSET s /\\\n (!x y. x IN t /\\ y IN t ==> (f x = f y <=> x = y)) /\\\n P (IMAGE f t))`;;\n\nlet FORALL_SUBSET_IMAGE_INJ = `!P (f:A->B) s.\n (!t. t SUBSET IMAGE f s ==> P t) <=>\n (!t. t SUBSET s /\\\n (!x y. x IN t /\\ y IN t ==> (f x = f y <=> x = y))\n ==> P(IMAGE f t))`;;\n\nlet EXISTS_FINITE_SUBSET_IMAGE_INJ = `!P (f:A->B) s.\n (?t. FINITE t /\\ t SUBSET IMAGE f s /\\ P t) <=>\n (?t. FINITE t /\\ t SUBSET s /\\\n (!x y. x IN t /\\ y IN t ==> (f x = f y <=> x = y)) /\\\n P (IMAGE f t))`;;\n\nlet FORALL_FINITE_SUBSET_IMAGE_INJ = `!P (f:A->B) s.\n (!t. FINITE t /\\ t SUBSET IMAGE f s ==> P t) <=>\n (!t. FINITE t /\\ t SUBSET s /\\\n (!x y. x IN t /\\ y IN t ==> (f x = f y <=> x = y))\n ==> P(IMAGE f t))`;;\n\nlet EXISTS_FINITE_SUBSET_IMAGE = `!P (f:A->B) s.\n (?t. FINITE t /\\ t SUBSET IMAGE f s /\\ P t) <=>\n (?t. FINITE t /\\ t SUBSET s /\\ P (IMAGE f t))`;;\n\nlet FORALL_FINITE_SUBSET_IMAGE = `!P (f:A->B) s.\n (!t. FINITE t /\\ t SUBSET IMAGE f s ==> P t) <=>\n (!t. FINITE t /\\ t SUBSET s ==> P(IMAGE f t))`;;\n\nlet FINITE_SUBSET_IMAGE = `!f:A->B s t.\n FINITE(t) /\\ t SUBSET (IMAGE f s) <=>\n ?s'. FINITE s' /\\ s' SUBSET s /\\ (t = IMAGE f s')`;;\n\nlet FINITE_SUBSET_IMAGE_IMP = `!f:A->B s t.\n FINITE(t) /\\ t SUBSET (IMAGE f s)\n ==> ?s'. FINITE s' /\\ s' SUBSET s /\\ t SUBSET (IMAGE f s')`;;\n\nlet FINITE_IMAGE_EQ = `!(f:A->B) s. FINITE(IMAGE f s) <=>\n ?t. FINITE t /\\ t SUBSET s /\\ IMAGE f s = IMAGE f t`;;\n\nlet FINITE_IMAGE_EQ_INJ = `!(f:A->B) s. FINITE(IMAGE f s) <=>\n ?t. FINITE t /\\ t SUBSET s /\\ IMAGE f s = IMAGE f t /\\\n (!x y. x IN t /\\ y IN t ==> (f x = f y <=> x = y))`;;\n\nlet FINITE_DIFF = `!s t:A->bool. FINITE s ==> FINITE(s DIFF t)`;;\n\nlet INFINITE_SUPERSET = `!s t:A->bool. INFINITE s /\\ s SUBSET t ==> INFINITE t`;;\n\nlet FINITE_TRANSITIVITY_CHAIN = `!R s:A->bool.\n FINITE s /\\\n (!x. ~(R x x)) /\\\n (!x y z. R x y /\\ R y z ==> R x z) /\\\n (!x. x IN s ==> ?y. y IN s /\\ R x y)\n ==> s = {}`;;\n\nlet UNIONS_MAXIMAL_SETS = `!f. FINITE f\n ==> UNIONS {t:A->bool | t IN f /\\ !u. u IN f ==> ~(t PSUBSET u)} =\n UNIONS f`;;\n\nlet FINITE_SUBSET_UNIONS = `!f s:A->bool.\n FINITE s /\\ s SUBSET UNIONS f\n ==> ?f'. FINITE f' /\\ f' SUBSET f /\\ s SUBSET UNIONS f'`;;\n\nlet UNIONS_IN_CHAIN = `!f:(A->bool)->bool.\n FINITE f /\\ ~(f = {}) /\\\n (!s t. s IN f /\\ t IN f ==> s SUBSET t \\/ t SUBSET s)\n ==> UNIONS f IN f`;;\n\nlet INTERS_IN_CHAIN = `!f:(A->bool)->bool.\n FINITE f /\\ ~(f = {}) /\\\n (!s t. s IN f /\\ t IN f ==> s SUBSET t \\/ t SUBSET s)\n ==> INTERS f IN f`;;\n\nlet FINITE_SUBSET_UNIONS_DIRECTED_EQ = `!f s:A->bool.\n ~(f = {}) /\\\n (!t u. t IN f /\\ u IN f\n ==> ?v. v IN f /\\ t SUBSET v /\\ u SUBSET v) /\\\n FINITE s\n ==> (s SUBSET UNIONS f <=> ?t. t IN f /\\ s SUBSET t)`;;\n\nlet FINITE_SUBSET_UNIONS_CHAIN_EQ = time prove\n (`!f s:A->bool.\n ~(f = {}) /\\\n (!t u. t IN f /\\ u IN f ==> t SUBSET u \\/ u SUBSET t) /\\\n FINITE s\n ==> (s SUBSET UNIONS f <=> ?t. t IN f /\\ s SUBSET t)`,\n REPEAT STRIP_TAC THEN MATCH_MP_TAC FINITE_SUBSET_UNIONS_DIRECTED_EQ THEN\n ASM_MESON_TAC[SUBSET_REFL]);;\n\nlet FINITE_SUBSET_UNIONS_CHAIN = `!f s:A->bool.\n FINITE s /\\ s SUBSET UNIONS f /\\ ~(f = {}) /\\\n (!t u. t IN f /\\ u IN f ==> t SUBSET u \\/ u SUBSET t)\n ==> ?t. t IN f /\\ s SUBSET t`;;\n\nlet FINREC = new_recursive_definition num_RECURSION\n `(FINREC (f:A->B->B) b s a 0 <=> (s = {}) /\\ (a = b)) /\\\n (FINREC (f:A->B->B) b s a (SUC n) <=>\n ?x c. x IN s /\\\n FINREC f b (s DELETE x) c n /\\\n (a = f x c))`;;\n\nlet FINREC_1_LEMMA = `!(f:A->B->B) b s a. FINREC f b s a (SUC 0) <=> ?x. s = {x} /\\ a = f x b`;;\n\nlet FINREC_SUC_LEMMA = `!(f:A->B->B) b.\n (!x y s. ~(x = y) ==> (f x (f y s) = f y (f x s)))\n ==> !n s z.\n FINREC f b s z (SUC n)\n ==> !x. x IN s ==> ?w. FINREC f b (s DELETE x) w n /\\\n (z = f x w)`;;\n\nlet FINREC_UNIQUE_LEMMA = `!(f:A->B->B) b.\n (!x y s. ~(x = y) ==> (f x (f y s) = f y (f x s)))\n ==> !n1 n2 s a1 a2.\n FINREC f b s a1 n1 /\\ FINREC f b s a2 n2\n ==> (a1 = a2) /\\ (n1 = n2)`;;\n\nlet FINREC_EXISTS_LEMMA = `!(f:A->B->B) b s. FINITE s ==> ?a n. FINREC f b s a n`;;\n\nlet FINREC_FUN_LEMMA = `!P (R:A->B->C->bool).\n (!s. P s ==> ?a n. R s a n) /\\\n (!n1 n2 s a1 a2. R s a1 n1 /\\ R s a2 n2 ==> (a1 = a2) /\\ (n1 = n2))\n ==> ?f. !s a. P s ==> ((?n. R s a n) <=> (f s = a))`;;\n\nlet FINREC_FUN = `!(f:A->B->B) b.\n (!x y s. ~(x = y) ==> (f x (f y s) = f y (f x s)))\n ==> ?g. (g {} = b) /\\\n !s x. FINITE s /\\ x IN s\n ==> (g s = f x (g (s DELETE x)))`;;\n\nlet SET_RECURSION_LEMMA = `!(f:A->B->B) b.\n (!x y s. ~(x = y) ==> (f x (f y s) = f y (f x s)))\n ==> ?g. (g {} = b) /\\\n !x s. FINITE s\n ==> (g (x INSERT s) =\n if x IN s then g s else f x (g s))`;;\n\nlet ITSET = new_definition\n `ITSET (f:A->B->B) s b =\n (@g. (g {} = b) /\\\n !x s. FINITE s\n ==> (g (x INSERT s) = if x IN s then g s else f x (g s)))\n s`;;\n\nlet FINITE_RECURSION = `!(f:A->B->B) b.\n (!x y s. ~(x = y) ==> (f x (f y s) = f y (f x s)))\n ==> (ITSET f {} b = b) /\\\n !x s. FINITE s\n ==> (ITSET f (x INSERT s) b =\n if x IN s then ITSET f s b\n else f x (ITSET f s b))`;;\n\nlet FINITE_RECURSION_DELETE = `!(f:A->B->B) b.\n (!x y s. ~(x = y) ==> (f x (f y s) = f y (f x s)))\n ==> (ITSET f {} b = b) /\\\n !x s. FINITE s\n ==> (ITSET f s b =\n if x IN s then f x (ITSET f (s DELETE x) b)\n else ITSET f (s DELETE x) b)`;;\n\nlet ITSET_EQ = `!s (f:A->B->B) g b.\n FINITE(s) /\\ (!x. x IN s ==> (f x = g x)) /\\\n (!x y s. ~(x = y) ==> (f x (f y s) = f y (f x s))) /\\\n (!x y s. ~(x = y) ==> (g x (g y s) = g y (g x s)))\n ==> (ITSET f s b = ITSET g s b)`;;\n\nlet CARD = new_definition\n `CARD (s:A->bool) = ITSET (\\x n. SUC n) s 0`;;\n\nlet CARD_CLAUSES = `(CARD ({}:A->bool) = 0) /\\\n (!(x:A) s. FINITE s ==>\n (CARD (x INSERT s) =\n if x IN s then CARD s else SUC(CARD s)))`;;\n\nlet CARD_UNION = `!(s:A->bool) t. FINITE(s) /\\ FINITE(t) /\\ (s INTER t = EMPTY)\n ==> (CARD (s UNION t) = CARD s + CARD t)`;;\n\nlet CARD_DELETE = `!x:A s. FINITE(s)\n ==> (CARD(s DELETE x) = if x IN s then CARD(s) - 1 else CARD(s))`;;\n\nlet CARD_UNION_EQ = `!s t u:A->bool.\n FINITE u /\\ s INTER t = {} /\\ s UNION t = u\n ==> (CARD s + CARD t = CARD u)`;;\n\nlet CARD_DIFF = `!s t:A->bool. FINITE s /\\ t SUBSET s ==> CARD(s DIFF t) = CARD s - CARD t`;;\n\nlet CARD_EQ_0 = `!s:A->bool. FINITE s ==> ((CARD s = 0) <=> (s = {}))`;;\n\nlet CARD_SING = `!a:A. CARD {a} = 1`;;\n\nlet FINITE_INDUCT_DELETE = `!P. P {} /\\\n (!s. FINITE s /\\ ~(s = {}) ==> ?x. x IN s /\\ (P(s DELETE x) ==> P s))\n ==> !s:A->bool. FINITE s ==> P s`;;\n\nlet HAS_SIZE = new_definition\n `(s:A->bool) HAS_SIZE n <=> FINITE s /\\ CARD s = n`;;\n\nlet HAS_SIZE_CARD = `!(s:A->bool) n. s HAS_SIZE n ==> CARD s = n`;;\n\nlet HAS_SIZE_0 = `!(s:A->bool). s HAS_SIZE 0 <=> (s = {})`;;\n\nlet HAS_SIZE_SUC = `!(s:A->bool) n. s HAS_SIZE (SUC n) <=>\n ~(s = {}) /\\ !a. a IN s ==> (s DELETE a) HAS_SIZE n`;;\n\nlet HAS_SIZE_UNION = `!(s:A->bool) t m n.\n s HAS_SIZE m /\\ t HAS_SIZE n /\\ DISJOINT s t\n ==> (s UNION t) HAS_SIZE (m + n)`;;\n\nlet HAS_SIZE_DIFF = `!(s:A->bool) t m n.\n s HAS_SIZE m /\\ t HAS_SIZE n /\\ t SUBSET s\n ==> (s DIFF t) HAS_SIZE (m - n)`;;\n\nlet HAS_SIZE_UNIONS = `!s t:A->B->bool m n.\n s HAS_SIZE m /\\\n (!x. x IN s ==> t(x) HAS_SIZE n) /\\\n (!x y. x IN s /\\ y IN s /\\ ~(x = y) ==> DISJOINT (t x) (t y))\n ==> UNIONS {t(x) | x IN s} HAS_SIZE (m * n)`;;\n\nlet FINITE_HAS_SIZE = `!s:A->bool. FINITE s <=> s HAS_SIZE CARD s`;;\n\nlet HAS_SIZE_CLAUSES = `(s HAS_SIZE 0 <=> s = {}) /\\\n (s HAS_SIZE (SUC n) <=>\n ?(a:A) t. t HAS_SIZE n /\\ ~(a IN t) /\\ (s = a INSERT t))`;;\n\nlet HAS_SIZE_CONV =\n let pth = `(~((a:A) IN {}) /\\ P <=> P) /\\\n (~(a IN {b}) /\\ P <=> ~(a = b) /\\ P) /\\\n (~(a IN (b INSERT cs)) /\\ P <=> ~(a = b) /\\ ~(a IN cs) /\\ P)`;;\n\nlet CARD_SUBSET = `!(a:A->bool) b. a SUBSET b /\\ FINITE(b) ==> CARD(a) <= CARD(b)`;;\n\nlet CARD_SUBSET_LE = `!(a:A->bool) b. FINITE b /\\ a SUBSET b /\\ CARD b <= CARD a ==> a = b`;;\n\nlet SUBSET_CARD_EQ = `!s t:A->bool. FINITE t /\\ s SUBSET t ==> (CARD s = CARD t <=> s = t)`;;\n\nlet FINITE_CARD_LE_SUBSET = `!s (t:A->bool) n.\n s SUBSET t /\\ FINITE t /\\ CARD t <= n\n ==> FINITE s /\\ CARD s <= n`;;\n\nlet CARD_PSUBSET = `!(a:A->bool) b. a PSUBSET b /\\ FINITE(b) ==> CARD(a) < CARD(b)`;;\n\nlet CARD_PSUBSET_IMP = `!a b:A->bool. a SUBSET b /\\ ~(CARD a = CARD b) ==> a PSUBSET b`;;\n\nlet CARD_PSUBSET_EQ = `!a b:A->bool. FINITE b /\\ a SUBSET b ==> (a PSUBSET b <=> CARD a < CARD b)`;;\n\nlet CARD_UNION_LE = `!s t:A->bool.\n FINITE s /\\ FINITE t ==> CARD(s UNION t) <= CARD(s) + CARD(t)`;;\n\nlet FINITE_CARD_LE_UNION = `!s (t:A->bool) m n.\n (FINITE s /\\ CARD s <= m) /\\\n (FINITE t /\\ CARD t <= n)\n ==> FINITE(s UNION t) /\\ CARD(s UNION t) <= m + n`;;\n\nlet CARD_UNIONS_LE = `!s t:A->B->bool m n.\n s HAS_SIZE m /\\ (!x. x IN s ==> FINITE(t x) /\\ CARD(t x) <= n)\n ==> CARD(UNIONS {t(x) | x IN s}) <= m * n`;;\n\nlet CARD_UNION_GEN = `!s t:A->bool.\n FINITE s /\\ FINITE t\n ==> CARD(s UNION t) = (CARD(s) + CARD(t)) - CARD(s INTER t)`;;\n\nlet CARD_UNION_OVERLAP_EQ = `!s t:A->bool.\n FINITE s /\\ FINITE t\n ==> (CARD(s UNION t) = CARD s + CARD t <=> s INTER t = {})`;;\n\nlet CARD_UNION_OVERLAP = `!s t:A->bool.\n FINITE s /\\ FINITE t /\\ CARD(s UNION t) < CARD(s) + CARD(t)\n ==> ~(s INTER t = {})`;;\n\nlet CARD_IMAGE_INJ = `!(f:A->B) s. (!x y. x IN s /\\ y IN s /\\ (f(x) = f(y)) ==> (x = y)) /\\\n FINITE s ==> (CARD (IMAGE f s) = CARD s)`;;\n\nlet HAS_SIZE_IMAGE_INJ = `!(f:A->B) s n.\n (!x y. x IN s /\\ y IN s /\\ (f(x) = f(y)) ==> (x = y)) /\\ s HAS_SIZE n\n ==> (IMAGE f s) HAS_SIZE n`;;\n\nlet CARD_IMAGE_LE = `!(f:A->B) s. FINITE s ==> CARD(IMAGE f s) <= CARD s`;;\n\nlet FINITE_CARD_LE_IMAGE = `!(f:A->B) s n.\n FINITE s /\\ CARD s <= n ==> FINITE(IMAGE f s) /\\ CARD(IMAGE f s) <= n`;;\n\nlet CARD_IMAGE_INJ_EQ = `!f:A->B s t.\n FINITE s /\\\n (!x. x IN s ==> f(x) IN t) /\\\n (!y. y IN t ==> ?!x. x IN s /\\ f(x) = y)\n ==> CARD t = CARD s`;;\n\nlet CARD_SUBSET_IMAGE = `!(f:A->B) s t. FINITE t /\\ s SUBSET IMAGE f t ==> CARD s <= CARD t`;;\n\nlet HAS_SIZE_IMAGE_INJ_EQ = `!(f:A->B) s n.\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)\n ==> ((IMAGE f s) HAS_SIZE n <=> s HAS_SIZE n)`;;\n\nlet CARD_IMAGE_EQ_INJ = `!f:A->B s.\n FINITE s\n ==> (CARD(IMAGE f s) = CARD s <=>\n !x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)`;;\n\nlet EXISTS_SMALL_SUBSET_IMAGE_INJ = `!P (f:A->B) s n.\n (?t. FINITE t /\\ CARD t < n /\\ t SUBSET IMAGE f s /\\ P t) <=>\n (?t. FINITE t /\\ CARD t < n /\\ t SUBSET s /\\\n (!x y. x IN t /\\ y IN t ==> (f x = f y <=> x = y)) /\\\n P (IMAGE f t))`;;\n\nlet FORALL_SMALL_SUBSET_IMAGE_INJ = `!P (f:A->B) s n.\n (!t. FINITE t /\\ CARD t < n /\\ t SUBSET IMAGE f s ==> P t) <=>\n (!t. FINITE t /\\ CARD t < n /\\ t SUBSET s /\\\n (!x y. x IN t /\\ y IN t ==> (f x = f y <=> x = y))\n ==> P (IMAGE f t))`;;\n\nlet EXISTS_SMALL_SUBSET_IMAGE = `!P (f:A->B) s n.\n (?t. FINITE t /\\ CARD t < n /\\ t SUBSET IMAGE f s /\\ P t) <=>\n (?t. FINITE t /\\ CARD t < n /\\ t SUBSET s /\\\n P (IMAGE f t))`;;\n\nlet FORALL_SMALL_SUBSET_IMAGE = `!P (f:A->B) s n.\n (!t. FINITE t /\\ CARD t < n /\\ t SUBSET IMAGE f s ==> P t) <=>\n (!t. FINITE t /\\ CARD t < n /\\ t SUBSET s ==> P (IMAGE f t))`;;\n\nlet CARD_IMAGE_LE2 = `!(f:A->B) (g:A->C) s.\n FINITE s /\\\n (!x y. x IN s /\\ y IN s /\\ g x = g y ==> f x = f y)\n ==> CARD(IMAGE f s) <= CARD(IMAGE g s)`;;\n\nlet CARD_IMAGE_LT2 = `!(f:A->B) (g:A->C) s.\n FINITE s /\\\n (!x y. x IN s /\\ y IN s /\\ g x = g y ==> f x = f y) /\\\n ~(!x y. x IN s /\\ y IN s /\\ f x = f y ==> g x = g y)\n ==> CARD(IMAGE f s) < CARD(IMAGE g s)`;;\n\nlet CHOOSE_SUBSET_STRONG = `!n s:A->bool.\n (FINITE s ==> n <= CARD s) ==> ?t. t SUBSET s /\\ t HAS_SIZE n`;;\n\nlet CHOOSE_SUBSET_EQ = `!n s:A->bool.\n (FINITE s ==> n <= CARD s) <=> (?t. t SUBSET s /\\ t HAS_SIZE n)`;;\n\nlet CHOOSE_SUBSET = `!s:A->bool. FINITE s ==> !n. n <= CARD s ==> ?t. t SUBSET s /\\ t HAS_SIZE n`;;\n\nlet CHOOSE_SUBSET_BETWEEN = `!n s u:A->bool.\n s SUBSET u /\\ FINITE s /\\ CARD s <= n /\\ (FINITE u ==> n <= CARD u)\n ==> ?t. s SUBSET t /\\ t SUBSET u /\\ t HAS_SIZE n`;;\n\nlet CARD_LE_UNIONS_CHAIN = `!(f:(A->bool)->bool) n.\n (!t u. t IN f /\\ u IN f ==> t SUBSET u \\/ u SUBSET t) /\\\n (!t. t IN f ==> FINITE t /\\ CARD t <= n)\n ==> FINITE(UNIONS f) /\\ CARD(UNIONS f) <= n`;;\n\nlet CARD_LE_1 = `!s:A->bool. FINITE s /\\ CARD s <= 1 <=> ?a. s SUBSET {a}`;;\n\nlet INVOLUTION_EVEN_NOFIXPOINTS = `!f (s:A->bool).\n FINITE s /\\ (!x. x IN s ==> f x IN s /\\ ~(f x = x) /\\ f(f x) = x)\n ==> EVEN(CARD s)`;;\n\nlet INVOLUTION_EVEN_FIXPOINTS = `!f (s:A->bool).\n FINITE s /\\ (!x. x IN s ==> f x IN s /\\ f(f x) = x)\n ==> (EVEN(CARD {x | x IN s /\\ f x = x}) <=> EVEN(CARD s))`;;\n\nlet HAS_SIZE_PRODUCT_DEPENDENT = `!s m t n.\n s HAS_SIZE m /\\ (!x. x IN s ==> t(x) HAS_SIZE n)\n ==> {(x:A,y:B) | x IN s /\\ y IN t(x)} HAS_SIZE (m * n)`;;\n\nlet FINITE_PRODUCT_DEPENDENT = `!f:A->B->C s t.\n FINITE s /\\ (!x. x IN s ==> FINITE(t x))\n ==> FINITE {f x y | x IN s /\\ y IN (t x)}`;;\n\nlet FINITE_PRODUCT = `!s t. FINITE s /\\ FINITE t ==> FINITE {(x:A,y:B) | x IN s /\\ y IN t}`;;\n\nlet CARD_PRODUCT = `!s t. FINITE s /\\ FINITE t\n ==> (CARD {(x:A,y:B) | x IN s /\\ y IN t} = CARD s * CARD t)`;;\n\nlet HAS_SIZE_PRODUCT = `!s m t n. s HAS_SIZE m /\\ t HAS_SIZE n\n ==> {(x:A,y:B) | x IN s /\\ y IN t} HAS_SIZE (m * n)`;;\n\nparse_as_infix(\"CROSS\",(22,\"right\"));;\n\nlet CROSS = new_definition\n `(s:A->bool) CROSS (t:B->bool) = {x,y | x IN s /\\ y IN t}`;;\n\nlet IN_CROSS = `!(x:A) (y:B) s t. (x,y) IN (s CROSS t) <=> x IN s /\\ y IN t`;;\n\nlet HAS_SIZE_CROSS = `!(s:A->bool) (t:B->bool) m n.\n s HAS_SIZE m /\\ t HAS_SIZE n ==> (s CROSS t) HAS_SIZE (m * n)`;;\n\nlet FINITE_CROSS = `!(s:A->bool) (t:B->bool). FINITE s /\\ FINITE t ==> FINITE(s CROSS t)`;;\n\nlet CARD_CROSS = `!(s:A->bool) (t:B->bool). FINITE s /\\ FINITE t ==> CARD(s CROSS t) = CARD s * CARD t`;;\n\nlet CROSS_EQ_EMPTY = `!(s:A->bool) (t:B->bool). s CROSS t = {} <=> s = {} \\/ t = {}`;;\n\nlet CROSS_EMPTY = `(!s:A->bool. s CROSS {} = {}) /\\ (!t:B->bool. {} CROSS t = {})`;;\n\nlet CROSS_SING = `!x:A y:B. {x} CROSS {y} = {(x,y)}`;;\n\nlet CROSS_UNIV = `(:A) CROSS (:B) = (:A#B)`;;\n\nlet FINITE_CROSS_EQ = `!s:A->bool t:B->bool.\n FINITE(s CROSS t) <=> s = {} \\/ t = {} \\/ FINITE s /\\ FINITE t`;;\n\nlet INFINITE_CROSS_EQ = `!(s:A->bool) (t:B->bool).\n INFINITE(s CROSS t) <=>\n ~(s = {}) /\\ INFINITE t \\/ INFINITE s /\\ ~(t = {})`;;\n\nlet FINITE_CROSS_UNIV = `FINITE(:A#B) <=> FINITE(:A) /\\ FINITE(:B)`;;\n\nlet INFINITE_CROSS_UNIV = `INFINITE(:A#B) <=> INFINITE(:A) \\/ INFINITE(:B)`;;\n\nlet FINITE_UNIV_PAIR = `FINITE(:A#A) <=> FINITE(:A)`;;\n\nlet INFINITE_UNIV_PAIR = `INFINITE(:A#A) <=> INFINITE(:A)`;;\n\nlet FORALL_IN_CROSS = `!P s t. (!z:A#B. z IN s CROSS t ==> P z) <=>\n (!x y. x IN s /\\ y IN t ==> P(x,y))`;;\n\nlet EXISTS_IN_CROSS = `!P s t. (?z:A#B. z IN s CROSS t /\\ P z) <=>\n (?x y. x IN s /\\ y IN t /\\ P(x,y))`;;\n\nlet SUBSET_CROSS = `!(s:A->bool) (t:B->bool) s' t'.\n s CROSS t SUBSET s' CROSS t' <=>\n s = {} \\/ t = {} \\/ s SUBSET s' /\\ t SUBSET t'`;;\n\nlet CROSS_MONO = `!(s:A->bool) (t:B->bool) s' t'. s SUBSET s' /\\ t SUBSET t' ==> s CROSS t SUBSET s' CROSS t'`;;\n\nlet CROSS_EQ = `!s s':A->bool t t':B->bool.\n s CROSS t = s' CROSS t' <=>\n (s = {} \\/ t = {}) /\\ (s' = {} \\/ t' = {}) \\/ s = s' /\\ t = t'`;;\n\nlet IMAGE_FST_CROSS = `!s:A->bool t:B->bool.\n IMAGE FST (s CROSS t) = if t = {} then {} else s`;;\n\nlet IMAGE_SND_CROSS = `!s:A->bool t:B->bool.\n IMAGE SND (s CROSS t) = if s = {} then {} else t`;;\n\nlet IMAGE_PAIRED_CROSS = `!(f:A->B) (g:C->D) s t.\n IMAGE (\\(x,y). f x,g y) (s CROSS t) = (IMAGE f s) CROSS (IMAGE g t)`;;\n\nlet CROSS_INTER = `(!(s:A->bool) (t:B->bool) u.\n s CROSS (t INTER u) = (s CROSS t) INTER (s CROSS u)) /\\\n (!(s:A->bool) t (u:B->bool).\n (s INTER t) CROSS u = (s CROSS u) INTER (t CROSS u))`;;\n\nlet CROSS_UNION = `(!(s:A->bool) (t:B->bool) u.\n s CROSS (t UNION u) = (s CROSS t) UNION (s CROSS u)) /\\\n (!(s:A->bool) t (u:B->bool).\n (s UNION t) CROSS u = (s CROSS u) UNION (t CROSS u))`;;\n\nlet CROSS_DIFF = `(!(s:A->bool) (t:B->bool) u.\n s CROSS (t DIFF u) = (s CROSS t) DIFF (s CROSS u)) /\\\n (!(s:A->bool) t (u:B->bool).\n (s DIFF t) CROSS u = (s CROSS u) DIFF (t CROSS u))`;;\n\nlet INTER_CROSS = `!(s:A->bool) s' (t:B->bool) t'.\n (s CROSS t) INTER (s' CROSS t') = (s INTER s') CROSS (t INTER t')`;;\n\nlet CROSS_UNIONS_UNIONS,CROSS_UNIONS = (CONJ_PAIR o prove)\n (`(!(f:(A->bool)->bool) (g:(B->bool)->bool).\n (UNIONS f) CROSS (UNIONS g) =\n UNIONS {s CROSS t | s IN f /\\ t IN g}) /\\\n (!(s:A->bool) (f:(A->bool)->bool).\n s CROSS (UNIONS f) = UNIONS {s CROSS t | t IN f}) /\\\n (!(f:(A->bool)->bool) (t:B->bool).\n (UNIONS f) CROSS t = UNIONS {s CROSS t | s IN f})`,\n REWRITE_TAC[UNIONS_GSPEC; EXTENSION; FORALL_PAIR_THM; IN_ELIM_THM;\n IN_CROSS] THEN\n SET_TAC[]);;\n\nlet CROSS_INTERS_INTERS,CROSS_INTERS = (CONJ_PAIR o prove)\n (`(!(f:(A->bool)->bool) (g:(B->bool)->bool).\n (INTERS f) CROSS (INTERS g) =\n if f = {} then INTERS {UNIV CROSS t | t IN g}\n else if g = {} then INTERS {s CROSS UNIV | s IN f}\n else INTERS {s CROSS t | s IN f /\\ t IN g}) /\\\n (!(s:A->bool) (f:(A->bool)->bool).\n s CROSS (INTERS f) =\n if f = {} then s CROSS UNIV else INTERS {s CROSS t | t IN f}) /\\\n (!(f:(A->bool)->bool) (t:B->bool).\n (INTERS f) CROSS t =\n if f = {} then UNIV CROSS t else INTERS {s CROSS t | s IN f})`,\n REPEAT STRIP_TAC THEN REPEAT (COND_CASES_TAC THEN REWRITE_TAC[]) THEN\n ASM_REWRITE_TAC[INTERS_GSPEC; EXTENSION; FORALL_PAIR_THM; IN_ELIM_THM;\n IN_CROSS; NOT_IN_EMPTY] THEN\n ASM SET_TAC[]);;\n\nlet DISJOINT_CROSS = `!s:A->bool t:B->bool s' t'.\n DISJOINT (s CROSS t) (s' CROSS t') <=>\n DISJOINT s s' \\/ DISJOINT t t'`;;\n\nlet ARB = new_definition\n `ARB = (@x:A. F)`;;\n\nlet EXTENSIONAL = new_definition\n `EXTENSIONAL s = {f:A->B | !x. ~(x IN s) ==> f x = ARB}`;;\n\nlet IN_EXTENSIONAL = `!s f:A->B. f IN EXTENSIONAL s <=> (!x. ~(x IN s) ==> f x = ARB)`;;\n\nlet IN_EXTENSIONAL_UNDEFINED = `!s f:A->B x. f IN EXTENSIONAL s /\\ ~(x IN s) ==> f x = ARB`;;\n\nlet EXTENSIONAL_EMPTY = `EXTENSIONAL {} = {\\x:A. ARB:B}`;;\n\nlet EXTENSIONAL_UNIV = `!f:A->B. EXTENSIONAL (:A) f`;;\n\nlet EXTENSIONAL_EQ = `!s f g:A->B.\n f IN EXTENSIONAL s /\\ g IN EXTENSIONAL s /\\ (!x. x IN s ==> f x = g x)\n ==> f = g`;;\n\nlet RESTRICTION = new_definition\n `RESTRICTION s (f:A->B) x = if x IN s then f x else ARB`;;\n\nlet RESTRICTION_THM = `!s (f:A->B). RESTRICTION s f = \\x. if x IN s then f x else ARB`;;\n\nlet RESTRICTION_DEFINED = `!s f:A->B x. x IN s ==> RESTRICTION s f x = f x`;;\n\nlet RESTRICTION_UNDEFINED = `!s f:A->B x. ~(x IN s) ==> RESTRICTION s f x = ARB`;;\n\nlet RESTRICTION_EQ = `!s f:A->B x y. x IN s /\\ f x = y ==> RESTRICTION s f x = y`;;\n\nlet RESTRICTION_IN_EXTENSIONAL = `!s f:A->B. RESTRICTION s f IN EXTENSIONAL s`;;\n\nlet RESTRICTION_EXTENSION = `!s f g:A->B. RESTRICTION s f = RESTRICTION s g <=>\n (!x. x IN s ==> f x = g x)`;;\n\nlet RESTRICTION_FIXPOINT = `!s f:A->B. RESTRICTION s f = f <=> f IN EXTENSIONAL s`;;\n\nlet RESTRICTION_UNIV = `!f:A->B. RESTRICTION UNIV f = f`;;\n\nlet RESTRICTION_RESTRICTION = `!s t f:A->B.\n s SUBSET t ==> RESTRICTION s (RESTRICTION t f) = RESTRICTION s f`;;\n\nlet RESTRICTION_IDEMP = `!s f:A->B. RESTRICTION s (RESTRICTION s f) = RESTRICTION s f`;;\n\nlet IMAGE_RESTRICTION = `!f:A->B s t. s SUBSET t ==> IMAGE (RESTRICTION t f) s = IMAGE f s`;;\n\nlet RESTRICTION_COMPOSE_RIGHT = `!f:A->B g:B->C s.\n RESTRICTION s (g o RESTRICTION s f) =\n RESTRICTION s (g o f)`;;\n\nlet RESTRICTION_COMPOSE_LEFT = `!f:A->B g:B->C s t.\n IMAGE f s SUBSET t\n ==> RESTRICTION s (RESTRICTION t g o f) =\n RESTRICTION s (g o f)`;;\n\nlet RESTRICTION_COMPOSE = `!f:A->B g:B->C s t.\n IMAGE f s SUBSET t\n ==> RESTRICTION s (RESTRICTION t g o RESTRICTION s f) =\n RESTRICTION s (g o f)`;;\n\nlet RESTRICTION_UNIQUE = `!s (f:A->B) g.\n RESTRICTION s f = g <=> EXTENSIONAL s g /\\ !x. x IN s ==> f x = g x`;;\n\nlet RESTRICTION_UNIQUE_ALT = `!s (f:A->B) g.\n f = RESTRICTION s g <=> EXTENSIONAL s f /\\ !x. x IN s ==> f x = g x`;;\n\nlet cartesian_product = new_definition\n `cartesian_product k s =\n {f:K->A | EXTENSIONAL k f /\\ !i. i IN k ==> f i IN s i}`;;\n\nlet IN_CARTESIAN_PRODUCT = `!k s (x:K->A).\n x IN cartesian_product k s <=>\n EXTENSIONAL k x /\\ (!i. i IN k ==> x i IN s i)`;;\n\nlet CARTESIAN_PRODUCT = `!k s. cartesian_product k s =\n {f:K->A | !i. f i IN (if i IN k then s i else {ARB})}`;;\n\nlet RESTRICTION_IN_CARTESIAN_PRODUCT = `!k s (f:K->A).\n RESTRICTION k f IN cartesian_product k s <=>\n !i. i IN k ==> (f i) IN (s i)`;;\n\nlet CARTESIAN_PRODUCT_AS_RESTRICTIONS = `!k (s:K->A->bool).\n cartesian_product k s =\n {RESTRICTION k f |f| !i. i IN k ==> f i IN s i}`;;\n\nlet CARTESIAN_PRODUCT_EQ_EMPTY = `!k s:K->A->bool.\n cartesian_product k s = {} <=> ?i. i IN k /\\ s i = {}`;;\n\nlet CARTESIAN_PRODUCT_EMPTY = `!(s:K->A->bool). cartesian_product {} s = {(\\i. ARB)}`;;\n\nlet CARTESIAN_PRODUCT_EQ_MEMBERS = `!k s x y:K->A.\n x IN cartesian_product k s /\\ y IN cartesian_product k s /\\\n (!i. i IN k ==> x i = y i)\n ==> x = y`;;\n\nlet CARTESIAN_PRODUCT_EQ_MEMBERS_EQ = `!k s x y:K->A.\n x IN cartesian_product k s /\\\n y IN cartesian_product k s\n ==> (x = y <=> !i. i IN k ==> x i = y i)`;;\n\nlet SUBSET_CARTESIAN_PRODUCT = `!k s t:K->A->bool.\n cartesian_product k s SUBSET cartesian_product k t <=>\n cartesian_product k s = {} \\/ !i. i IN k ==> s i SUBSET t i`;;\n\nlet CARTESIAN_PRODUCT_EQ = `!k s t:K->A->bool.\n cartesian_product k s = cartesian_product k t <=>\n cartesian_product k s = {} /\\ cartesian_product k t = {} \\/\n !i. i IN k ==> s i = t i`;;\n\nlet INTER_CARTESIAN_PRODUCT = `!k s t:K->A->bool.\n (cartesian_product k s) INTER (cartesian_product k t) =\n cartesian_product k (\\i. s i INTER t i)`;;\n\nlet CARTESIAN_PRODUCT_UNIV = `cartesian_product (:K) (\\i. (:A)) = (:K->A)`;;\n\nlet CARTESIAN_PRODUCT_SINGS = `!k x:K->A. EXTENSIONAL k x ==> cartesian_product k (\\i. {x i}) = {x}`;;\n\nlet CARTESIAN_PRODUCT_SINGS_GEN = `!k (x:K->A). cartesian_product k (\\i. {x i}) = {RESTRICTION k x}`;;\n\nlet IMAGE_PROJECTION_CARTESIAN_PRODUCT = `!k s:K->A->bool i.\n IMAGE (\\x. x i) (cartesian_product k s) =\n if cartesian_product k s = {} then {}\n else if i IN k then s i else {ARB}`;;\n\nlet FORALL_CARTESIAN_PRODUCT_ELEMENTS = `!P k s:K->A->bool.\n (!z i. z IN cartesian_product k s /\\ i IN k ==> P i (z i)) <=>\n cartesian_product k s = {} \\/\n (!i x. i IN k /\\ x IN s i ==> P i x)`;;\n\nlet FORALL_CARTESIAN_PRODUCT_ELEMENTS_EQ = `!P k (s:K->A->bool).\n ~(cartesian_product k s = {})\n ==> ((!i x. i IN k /\\ x IN s i ==> P i x) <=>\n !z i. z IN cartesian_product k s /\\ i IN k ==> P i (z i))`;;\n\nlet EXISTS_CARTESIAN_PRODUCT_ELEMENT = `!P k s:K->A->bool.\n (?z. z IN cartesian_product k s /\\ (!i. i IN k ==> P i (z i))) <=>\n (!i. i IN k ==> ?x. x IN (s i) /\\ P i x)`;;\n\nlet product_map = new_definition\n `product_map k (f:K->A->B) = \\x. RESTRICTION k (\\i. f i (x i))`;;\n\nlet PRODUCT_MAP_RESTRICTION = `!(f:K->A->B) k x.\n product_map k f (RESTRICTION k x) = RESTRICTION k (\\i. f i (x i))`;;\n\nlet IMAGE_PRODUCT_MAP = `!(f:K->A->B) k s.\n IMAGE (product_map k f) (cartesian_product k s) =\n cartesian_product k (\\i. IMAGE (f i) (s i))`;;\n\nlet disjoint_union = new_definition\n `disjoint_union (k:K->bool) (s:K->A->bool) = { (i,x) | i IN k /\\ x IN s i}`;;\n\nlet SUBSET_DISJOINT_UNION = `!k (s:K->A->bool) t.\n disjoint_union k s SUBSET disjoint_union k t <=>\n !i. i IN k ==> s i SUBSET t i`;;\n\nlet DISJOINT_UNION_EQ = `!k (s:K->A->bool) t.\n disjoint_union k s = disjoint_union k t <=>\n !i. i IN k ==> s i = t i`;;\n\nlet SUBSET_DISJOINT_UNION_EXISTS = `!k (s:K->A->bool) u.\n u SUBSET disjoint_union k s <=>\n ?t. u = disjoint_union k t /\\ !i. i IN k ==> t i SUBSET s i`;;\n\nlet INTER_DISJOINT_UNION = `!k s t:K->A->bool.\n (disjoint_union k s) INTER (disjoint_union k t) =\n disjoint_union k (\\i. s i INTER t i)`;;\n\nlet UNION_DISJOINT_UNION = `!k s t:K->A->bool.\n (disjoint_union k s) UNION (disjoint_union k t) =\n disjoint_union k (\\i. s i UNION t i)`;;\n\nlet DISJOINT_UNION_EQ_EMPTY = `!k s:K->A->bool.\n disjoint_union k s = {} <=> !i. i IN k ==> s i = {}`;;\n\nlet DISJOINT_DISJOINT_UNION = `!k s t:K->A->bool.\n DISJOINT (disjoint_union k s) (disjoint_union k t) =\n !i. i IN k ==> DISJOINT (s i) (t i)`;;\n\nlet HAS_SIZE_FUNSPACE = `!d n t:B->bool m s:A->bool.\n s HAS_SIZE m /\\ t HAS_SIZE n\n ==> {f | (!x. x IN s ==> f(x) IN t) /\\ (!x. ~(x IN s) ==> (f x = d))}\n HAS_SIZE (n EXP m)`;;\n\nlet CARD_FUNSPACE = `!s t. FINITE s /\\ FINITE t\n ==> (CARD {f:A->B | (!x. x IN s ==> f(x) IN t) /\\\n (!x. ~(x IN s) ==> (f x = d))} =\n (CARD t) EXP (CARD s))`;;\n\nlet FINITE_FUNSPACE = `!s t. FINITE s /\\ FINITE t\n ==> FINITE {f:A->B | (!x. x IN s ==> f(x) IN t) /\\\n (!x. ~(x IN s) ==> (f x = d))}`;;\n\nlet HAS_SIZE_FUNSPACE_UNIV = `!m n. (:A) HAS_SIZE m /\\ (:B) HAS_SIZE n ==> (:A->B) HAS_SIZE (n EXP m)`;;\n\nlet CARD_FUNSPACE_UNIV = `FINITE(:A) /\\ FINITE(:B) ==> CARD(:A->B) = CARD(:B) EXP CARD(:A)`;;\n\nlet FINITE_FUNSPACE_UNIV = `FINITE(:A) /\\ FINITE(:B) ==> FINITE(:A->B)`;;\n\nlet HAS_SIZE_BOOL = `(:bool) HAS_SIZE 2`;;\n\nlet CARD_BOOL = `CARD(:bool) = 2`;;\n\nlet FINITE_BOOL = `FINITE(:bool)`;;\n\nlet HAS_SIZE_POWERSET = `!(s:A->bool) n. s HAS_SIZE n ==> {t | t SUBSET s} HAS_SIZE (2 EXP n)`;;\n\nlet CARD_POWERSET = `!s:A->bool. FINITE s ==> (CARD {t | t SUBSET s} = 2 EXP (CARD s))`;;\n\nlet FINITE_POWERSET = `!s:A->bool. FINITE s ==> FINITE {t | t SUBSET s}`;;\n\nlet FINITE_POWERSET_EQ = `!s:A->bool. FINITE {t | t SUBSET s} <=> FINITE s`;;\n\nlet FINITE_RESTRICTED_SUBSETS = `!P s:A->bool. FINITE s ==> FINITE {t | t SUBSET s /\\ P t}`;;\n\nlet FINITE_UNIONS = `!s:(A->bool)->bool.\n FINITE(UNIONS s) <=> FINITE s /\\ (!t. t IN s ==> FINITE t)`;;\n\nlet FINITE_CARD_LE_UNIONS = `!s (t:A->B->bool) m n.\n (!x. x IN s ==> FINITE(t x) /\\ CARD(t x) <= n) /\\\n FINITE s /\\ CARD s <= m\n ==> FINITE(UNIONS {t x | x IN s}) /\\\n CARD(UNIONS {t x | x IN s}) <= m * n`;;\n\nlet POWERSET_CLAUSES = `{s:A->bool | s SUBSET {}} = {{}} /\\\n (!a:A t. {s | s SUBSET (a INSERT t)} =\n {s | s SUBSET t} UNION IMAGE (\\s. a INSERT s) {s | s SUBSET t})`;;\n\nlet FINITE_IMAGE_INFINITE = `!f:A->B s.\n INFINITE s /\\ FINITE(IMAGE f s)\n ==> ?a. a IN s /\\ INFINITE {x | x IN s /\\ f x = f a}`;;\n\nlet FINITE_RESTRICTED_POWERSET = `!(s:A->bool) n.\n FINITE {t | t SUBSET s /\\ t HAS_SIZE n} <=>\n FINITE s \\/ n = 0`;;\n\nlet FINITE_RESTRICTED_FUNSPACE = `!s:A->bool t:B->bool k.\n FINITE s /\\ FINITE t\n ==> FINITE {f | IMAGE f s SUBSET t /\\ {x | ~(f x = k x)} SUBSET s}`;;\n\nlet NUMSEG_CLAUSES_LT = `{i | i < 0} = {} /\\\n (!k. {i | i < SUC k} = k INSERT {i | i < k})`;;\n\nlet HAS_SIZE_NUMSEG_LT = `!n. {m | m < n} HAS_SIZE n`;;\n\nlet CARD_NUMSEG_LT = `!n. CARD {m | m < n} = n`;;\n\nlet FINITE_NUMSEG_LT = `!n:num. FINITE {m | m < n}`;;\n\nlet NUMSEG_CLAUSES_LE = `{i | i <= 0} = {0} /\\\n (!k. {i | i <= SUC k} = SUC k INSERT {i | i <= k})`;;\n\nlet HAS_SIZE_NUMSEG_LE = `!n. {m | m <= n} HAS_SIZE (n + 1)`;;\n\nlet FINITE_NUMSEG_LE = `!n. FINITE {m | m <= n}`;;\n\nlet CARD_NUMSEG_LE = `!n. CARD {m | m <= n} = n + 1`;;\n\nlet num_FINITE = `!s:num->bool. FINITE s <=> ?a. !x. x IN s ==> x <= a`;;\n\nlet num_FINITE_AVOID = `!s:num->bool. FINITE(s) ==> ?a. ~(a IN s)`;;\n\nlet num_INFINITE_EQ = `!s:num->bool. INFINITE s <=> !N. ?n. N <= n /\\ n IN s`;;\n\nlet num_INFINITE = `INFINITE(:num)`;;\n\nlet string_INFINITE = `INFINITE(:string)`;;\n\nlet FINITE_REAL_INTERVAL = `(!a. ~FINITE {x:real | a < x}) /\\\n (!a. ~FINITE {x:real | a <= x}) /\\\n (!b. ~FINITE {x:real | x < b}) /\\\n (!b. ~FINITE {x:real | x <= b}) /\\\n (!a b. FINITE {x:real | a < x /\\ x < b} <=> b <= a) /\\\n (!a b. FINITE {x:real | a <= x /\\ x < b} <=> b <= a) /\\\n (!a b. FINITE {x:real | a < x /\\ x <= b} <=> b <= a) /\\\n (!a b. FINITE {x:real | a <= x /\\ x <= b} <=> b <= a)`;;\n\nlet real_INFINITE = `INFINITE(:real)`;;\n\nlet HAS_SIZE_INDEX = `!s n. s HAS_SIZE n\n ==> ?f:num->A. (!m. m < n ==> f(m) IN s) /\\\n (!x. x IN s ==> ?!m. m < n /\\ (f m = x))`;;\n\nlet INFINITE_ENUMERATE = `!s:num->bool.\n INFINITE s\n ==> ?r:num->num. (!m n. m < n ==> r(m) < r(n)) /\\\n IMAGE r (:num) = s`;;\n\nlet INFINITE_ENUMERATE_EQ = `!s:num->bool.\n INFINITE s <=> ?r. (!m n:num. m < n ==> r m < r n) /\\ IMAGE r (:num) = s`;;\n\nlet INFINITE_ENUMERATE_SUBSET = `!s. INFINITE s <=>\n ?f:num->A. (!x. f x IN s) /\\ (!x y. f x = f y ==> x = y)`;;\n\nlet set_of_list = new_recursive_definition list_RECURSION\n `(set_of_list ([]:A list) = {}) /\\\n (set_of_list (CONS (h:A) t) = h INSERT (set_of_list t))`;;\n\nlet list_of_set = new_definition\n `list_of_set s = @l:A list. set_of_list l = s /\\ LENGTH l = CARD s`;;\n\nlet LIST_OF_SET_PROPERTIES = `!s:A->bool. FINITE(s)\n ==> (set_of_list(list_of_set s) = s) /\\\n (LENGTH(list_of_set s) = CARD s)`;;\n\nlet SET_OF_LIST_OF_SET = `!s:A->bool. FINITE(s) ==> (set_of_list(list_of_set s) = s)`;;\n\nlet LENGTH_LIST_OF_SET = `!s:A->bool. FINITE(s) ==> (LENGTH(list_of_set s) = CARD s)`;;\n\nlet MEM_LIST_OF_SET = `!s:A->bool. FINITE(s) ==> !x. MEM x (list_of_set s) <=> x IN s`;;\n\nlet FINITE_SET_OF_LIST = `!l:A list. FINITE(set_of_list l)`;;\n\nlet IN_SET_OF_LIST = `!x l:A list. x IN (set_of_list l) <=> MEM x l`;;\n\nlet SET_OF_LIST_APPEND = `!l1 l2:A list.\n set_of_list(APPEND l1 l2) = set_of_list(l1) UNION set_of_list(l2)`;;\n\nlet SET_OF_LIST_MAP = `!(f:A->B) l. set_of_list(MAP f l) = IMAGE f (set_of_list l)`;;\n\nlet SET_OF_LIST_EQ_EMPTY = `!l:A list. set_of_list l = {} <=> l = []`;;\n\nlet LIST_OF_SET_EMPTY = `list_of_set {}:A list = []`;;\n\nlet LIST_OF_SET_SING = `!a:A. list_of_set {a} = [a]`;;\n\nlet dest_setenum =\n let fn = splitlist (dest_binary \"INSERT\") in\n fun tm -> let l,n = fn tm in\n if is_const n && fst(dest_const n) = \"EMPTY\" then l\n else failwith \"dest_setenum: not a finite set enumeration\";;\n\nlet is_setenum = can dest_setenum;;\n\nlet mk_setenum =\n let insert_atm = `(INSERT):A->(A->bool)->(A->bool)`\n and nil_atm = `(EMPTY):A->bool` in\n fun (l,ty) ->\n let insert_tm = inst [ty,aty] insert_atm\n and nil_tm = inst [ty,aty] nil_atm in\n itlist (mk_binop insert_tm) l nil_tm;;\n\nlet mk_fset l = mk_setenum(l,type_of(hd l));;\n\nlet pairwise = new_definition\n `pairwise r (s:A->bool) <=> !x y. x IN s /\\ y IN s /\\ ~(x = y) ==> r x y`;;\n\nlet PAIRWISE_EMPTY = `!r:A->A->bool. pairwise r {} <=> T`;;\n\nlet PAIRWISE_SING = `!r x:A. pairwise r {x} <=> T`;;\n\nlet PAIRWISE_IMP = `!P Q s:A->bool.\n pairwise P s /\\\n (!x y. x IN s /\\ y IN s /\\ P x y /\\ ~(x = y) ==> Q x y)\n ==> pairwise Q s`;;\n\nlet PAIRWISE_MONO = `!(r:A->A->bool) s t. pairwise r s /\\ t SUBSET s ==> pairwise r t`;;\n\nlet PAIRWISE_AND = `!R R' s. pairwise R s /\\ pairwise R' s <=>\n pairwise (\\x y:A. R x y /\\ R' x y) s`;;\n\nlet PAIRWISE_INSERT = `!r x s.\n pairwise r (x INSERT s) <=>\n (!y:A. y IN s /\\ ~(y = x) ==> r x y /\\ r y x) /\\\n pairwise r s`;;\n\nlet PAIRWISE_INSERT_SYMMETRIC = `!r (x:A) s.\n (!y. y IN s ==> (r x y <=> r y x))\n ==> (pairwise r (x INSERT s) <=>\n (!y. y IN s /\\ ~(y = x) ==> r x y) /\\ pairwise r s)`;;\n\nlet PAIRWISE_IMAGE = `!r (f:A->B).\n pairwise r (IMAGE f s) <=>\n pairwise (\\x y. ~(f x = f y) ==> r (f x) (f y)) s`;;\n\nlet PAIRWISE_UNION = `!R s t. pairwise R (s UNION t) <=>\n pairwise R s /\\ pairwise R t /\\\n (!x y:A. x IN s DIFF t /\\ y IN t DIFF s ==> R x y /\\ R y x)`;;\n\nlet PAIRWISE_CHAIN_UNIONS = `!R:A->A->bool c.\n (!s. s IN c ==> pairwise R s) /\\\n (!s t. s IN c /\\ t IN c ==> s SUBSET t \\/ t SUBSET s)\n ==> pairwise R (UNIONS c)`;;\n\nlet DIFF_UNIONS_PAIRWISE_DISJOINT = `!s t:(A->bool)->bool.\n pairwise DISJOINT s /\\ t SUBSET s\n ==> UNIONS s DIFF UNIONS t = UNIONS(s DIFF t)`;;\n\nlet INTER_UNIONS_PAIRWISE_DISJOINT = `!s t:(A->bool)->bool.\n pairwise DISJOINT (s UNION t)\n ==> UNIONS s INTER UNIONS t = UNIONS(s INTER t)`;;\n\nlet PSUBSET_UNIONS_PAIRWISE_DISJOINT = `!u v:(A->bool)->bool.\n pairwise DISJOINT v /\\ u PSUBSET (v DELETE {})\n ==> UNIONS u PSUBSET UNIONS v`;;\n\nparse_as_infix(\"UNION_OF\",(20,\"right\"));;\nparse_as_infix(\"INTERSECTION_OF\",(20,\"right\"));;\n\nlet UNION_OF = new_definition\n `P UNION_OF Q =\n \\s:A->bool. ?u. P u /\\ (!c. c IN u ==> Q c) /\\ UNIONS u = s`;;\n\nlet INTERSECTION_OF = new_definition\n `P INTERSECTION_OF Q =\n \\s:A->bool. ?u. P u /\\ (!c. c IN u ==> Q c) /\\ INTERS u = s`;;\n\nlet UNION_OF_INC = `!P Q s:A->bool. P {s} /\\ Q s ==> (P UNION_OF Q) s`;;\n\nlet INTERSECTION_OF_INC = `!P Q s:A->bool. P {s} /\\ Q s ==> (P INTERSECTION_OF Q) s`;;\n\nlet UNION_OF_MONO = `!P Q Q' s:A->bool.\n (P UNION_OF Q) s /\\ (!x. Q x ==> Q' x) ==> (P UNION_OF Q') s`;;\n\nlet INTERSECTION_OF_MONO = `!P Q Q' s:A->bool.\n (P INTERSECTION_OF Q) s /\\ (!x. Q x ==> Q' x)\n ==> (P INTERSECTION_OF Q') s`;;\n\nlet FORALL_UNION_OF = `(!s:A->bool. (P UNION_OF Q) s ==> R s) <=>\n (!t. P t /\\ (!c. c IN t ==> Q c) ==> R(UNIONS t))`;;\n\nlet FORALL_INTERSECTION_OF = `(!s:A->bool. (P INTERSECTION_OF Q) s ==> R s) <=>\n (!t. P t /\\ (!c. c IN t ==> Q c) ==> R(INTERS t))`;;\n\nlet UNION_OF_EMPTY = `!P Q:(A->bool)->bool. P {} ==> (P UNION_OF Q) {}`;;\n\nlet INTERSECTION_OF_EMPTY = `!P Q:(A->bool)->bool. P {} ==> (P INTERSECTION_OF Q) UNIV`;;\n\nlet ARBITRARY = new_definition\n `ARBITRARY (s:(A->bool)->bool) <=> T`;;\n\nlet ARBITRARY_UNION_OF_ALT = `!B s:A->bool.\n (ARBITRARY UNION_OF B) s <=>\n !x. x IN s ==> ?u. u IN B /\\ x IN u /\\ u SUBSET s`;;\n\nlet ARBITRARY_UNION_OF_EMPTY = `!P:(A->bool)->bool. (ARBITRARY UNION_OF P) {}`;;\n\nlet ARBITRARY_INTERSECTION_OF_EMPTY = `!P:(A->bool)->bool. (ARBITRARY INTERSECTION_OF P) UNIV`;;\n\nlet ARBITRARY_UNION_OF_INC = `!P s:A->bool. P s ==> (ARBITRARY UNION_OF P) s`;;\n\nlet ARBITRARY_INTERSECTION_OF_INC = `!P s:A->bool. P s ==> (ARBITRARY INTERSECTION_OF P) s`;;\n\nlet ARBITRARY_UNION_OF_COMPLEMENT = `!P s. (ARBITRARY UNION_OF P) s <=>\n (ARBITRARY INTERSECTION_OF (\\s. P((:A) DIFF s))) ((:A) DIFF s)`;;\n\nlet ARBITRARY_INTERSECTION_OF_COMPLEMENT = `!P s. (ARBITRARY INTERSECTION_OF P) s <=>\n (ARBITRARY UNION_OF (\\s. P((:A) DIFF s))) ((:A) DIFF s)`;;\n\nlet ARBITRARY_UNION_OF_IDEMPOT = `!P:(A->bool)->bool.\n ARBITRARY UNION_OF ARBITRARY UNION_OF P = ARBITRARY UNION_OF P`;;\n\nlet ARBITRARY_INTERSECTION_OF_IDEMPOT = `!P:(A->bool)->bool.\n ARBITRARY INTERSECTION_OF ARBITRARY INTERSECTION_OF P =\n ARBITRARY INTERSECTION_OF P`;;\n\nlet ARBITRARY_UNION_OF_UNIONS = `!P u:(A->bool)->bool.\n (!s. s IN u ==> (ARBITRARY UNION_OF P) s)\n ==> (ARBITRARY UNION_OF P) (UNIONS u)`;;\n\nlet ARBITRARY_UNION_OF_UNION = `!P s t:A->bool.\n (ARBITRARY UNION_OF P) s /\\ (ARBITRARY UNION_OF P) t\n ==> (ARBITRARY UNION_OF P) (s UNION t)`;;\n\nlet ARBITRARY_INTERSECTION_OF_INTERS = `!P u:(A->bool)->bool.\n (!s. s IN u ==> (ARBITRARY INTERSECTION_OF P) s)\n ==> (ARBITRARY INTERSECTION_OF P) (INTERS u)`;;\n\nlet ARBITRARY_INTERSECTION_OF_INTER = `!P s t:A->bool.\n (ARBITRARY INTERSECTION_OF P) s /\\ (ARBITRARY INTERSECTION_OF P) t\n ==> (ARBITRARY INTERSECTION_OF P) (s INTER t)`;;\n\nlet ARBITRARY_UNION_OF_INTER_EQ = `!P:(A->bool)->bool.\n (!s t. (ARBITRARY UNION_OF P) s /\\ (ARBITRARY UNION_OF P) t\n ==> (ARBITRARY UNION_OF P) (s INTER t)) <=>\n (!s t. P s /\\ P t ==> (ARBITRARY UNION_OF P) (s INTER t))`;;\n\nlet ARBITRARY_UNION_OF_INTER = `!P:(A->bool)->bool.\n (!s t. P s /\\ P t ==> P(s INTER t))\n ==> (!s t. (ARBITRARY UNION_OF P) s /\\ (ARBITRARY UNION_OF P) t\n ==> (ARBITRARY UNION_OF P) (s INTER t))`;;\n\nlet ARBITRARY_INTERSECTION_OF_UNION_EQ = `!P:(A->bool)->bool.\n (!s t. (ARBITRARY INTERSECTION_OF P) s /\\\n (ARBITRARY INTERSECTION_OF P) t\n ==> (ARBITRARY INTERSECTION_OF P) (s UNION t)) <=>\n (!s t. P s /\\ P t ==> (ARBITRARY INTERSECTION_OF P) (s UNION t))`;;\n\nlet ARBITRARY_INTERSECTION_OF_UNION = `!P:(A->bool)->bool.\n (!s t. P s /\\ P t ==> P(s UNION t))\n ==> (!s t. (ARBITRARY INTERSECTION_OF P) s /\\\n (ARBITRARY INTERSECTION_OF P) t\n ==> (ARBITRARY INTERSECTION_OF P) (s UNION t))`;;\n\nlet FINITE_UNION_OF_EMPTY = `!P:(A->bool)->bool. (FINITE UNION_OF P) {}`;;\n\nlet FINITE_INTERSECTION_OF_EMPTY = `!P:(A->bool)->bool. (FINITE INTERSECTION_OF P) UNIV`;;\n\nlet FINITE_UNION_OF_INC = `!P s:A->bool. P s ==> (FINITE UNION_OF P) s`;;\n\nlet FINITE_INTERSECTION_OF_INC = `!P s:A->bool. P s ==> (FINITE INTERSECTION_OF P) s`;;\n\nlet FINITE_UNION_OF_COMPLEMENT = `!P s. (FINITE UNION_OF P) s <=>\n (FINITE INTERSECTION_OF (\\s. P((:A) DIFF s))) ((:A) DIFF s)`;;\n\nlet FINITE_INTERSECTION_OF_COMPLEMENT = `!P s. (FINITE INTERSECTION_OF P) s <=>\n (FINITE UNION_OF (\\s. P((:A) DIFF s))) ((:A) DIFF s)`;;\n\nlet FINITE_UNION_OF_IDEMPOT = `!P:(A->bool)->bool.\n FINITE UNION_OF FINITE UNION_OF P = FINITE UNION_OF P`;;\n\nlet FINITE_INTERSECTION_OF_IDEMPOT = `!P:(A->bool)->bool.\n FINITE INTERSECTION_OF FINITE INTERSECTION_OF P =\n FINITE INTERSECTION_OF P`;;\n\nlet FINITE_UNION_OF_UNIONS = `!P u:(A->bool)->bool.\n FINITE u /\\ (!s. s IN u ==> (FINITE UNION_OF P) s)\n ==> (FINITE UNION_OF P) (UNIONS u)`;;\n\nlet FINITE_UNION_OF_UNION = `!P s t:A->bool.\n (FINITE UNION_OF P) s /\\ (FINITE UNION_OF P) t\n ==> (FINITE UNION_OF P) (s UNION t)`;;\n\nlet FINITE_INTERSECTION_OF_INTERS = `!P u:(A->bool)->bool.\n FINITE u /\\ (!s. s IN u ==> (FINITE INTERSECTION_OF P) s)\n ==> (FINITE INTERSECTION_OF P) (INTERS u)`;;\n\nlet FINITE_INTERSECTION_OF_INTER = `!P s t:A->bool.\n (FINITE INTERSECTION_OF P) s /\\ (FINITE INTERSECTION_OF P) t\n ==> (FINITE INTERSECTION_OF P) (s INTER t)`;;\n\nlet FINITE_UNION_OF_INTER_EQ = `!P:(A->bool)->bool.\n (!s t. (FINITE UNION_OF P) s /\\ (FINITE UNION_OF P) t\n ==> (FINITE UNION_OF P) (s INTER t)) <=>\n (!s t. P s /\\ P t ==> (FINITE UNION_OF P) (s INTER t))`;;\n\nlet FINITE_UNION_OF_INTER = `!P:(A->bool)->bool.\n (!s t. P s /\\ P t ==> P(s INTER t))\n ==> (!s t. (FINITE UNION_OF P) s /\\ (FINITE UNION_OF P) t\n ==> (FINITE UNION_OF P) (s INTER t))`;;\n\nlet FINITE_INTERSECTION_OF_UNION_EQ = `!P:(A->bool)->bool.\n (!s t. (FINITE INTERSECTION_OF P) s /\\\n (FINITE INTERSECTION_OF P) t\n ==> (FINITE INTERSECTION_OF P) (s UNION t)) <=>\n (!s t. P s /\\ P t ==> (FINITE INTERSECTION_OF P) (s UNION t))`;;\n\nlet FINITE_INTERSECTION_OF_UNION = `!P:(A->bool)->bool.\n (!s t. P s /\\ P t ==> P(s UNION t))\n ==> (!s t. (FINITE INTERSECTION_OF P) s /\\\n (FINITE INTERSECTION_OF P) t\n ==> (FINITE INTERSECTION_OF P) (s UNION t))`;;\n\nlet CARD_SET_OF_LIST_LE = `!l:A list. CARD(set_of_list l) <= LENGTH l`;;\n\nlet HAS_SIZE_SET_OF_LIST = `!l. (set_of_list l) HAS_SIZE (LENGTH l) <=> PAIRWISE (\\x y:A. ~(x = y)) l`;;\n\nlet SURJECTIVE_IFF_INJECTIVE_GEN = `!s t f:A->B.\n FINITE s /\\ FINITE t /\\ (CARD s = CARD t) /\\ (IMAGE f s) SUBSET t\n ==> ((!y. y IN t ==> ?x. x IN s /\\ (f x = y)) <=>\n (!x y. x IN s /\\ y IN s /\\ (f x = f y) ==> (x = y)))`;;\n\nlet SURJECTIVE_IFF_INJECTIVE = `!s f:A->A.\n FINITE s /\\ (IMAGE f s) SUBSET s\n ==> ((!y. y IN s ==> ?x. x IN s /\\ (f x = y)) <=>\n (!x y. x IN s /\\ y IN s /\\ (f x = f y) ==> (x = y)))`;;\n\nlet IMAGE_IMP_INJECTIVE_GEN = `!s t f:A->B.\n FINITE s /\\ (CARD s = CARD t) /\\ (IMAGE f s = t)\n ==> !x y. x IN s /\\ y IN s /\\ (f x = f y) ==> (x = y)`;;\n\nlet IMAGE_IMP_INJECTIVE = `!s f:A->A.\n FINITE s /\\ IMAGE f s = s\n ==> !x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y`;;\n\nlet HAS_SIZE_IMAGE_INJ_RESTRICT = `!(f:A->B) s t P n.\n FINITE s /\\ FINITE t /\\ CARD s = CARD t /\\\n IMAGE f s SUBSET t /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y) /\\\n {x | x IN s /\\ P(f x)} HAS_SIZE n\n ==> {x | x IN t /\\ P x} HAS_SIZE n`;;\n\nlet CARD_LE_INJ = `!s t. FINITE s /\\ FINITE t /\\ CARD s <= CARD t\n ==> ?f:A->B. (IMAGE f s) SUBSET t /\\\n !x y. x IN s /\\ y IN s /\\ (f x = f y) ==> (x = y)`;;\n\nlet FORALL_IN_CLAUSES = `(!P. (!x:A. x IN {} ==> P x) <=> T) /\\\n (!P a s. (!x:A. x IN (a INSERT s) ==> P x) <=> P a /\\ (!x. x IN s ==> P x))`;;\n\nlet EXISTS_IN_CLAUSES = `(!P. (?x:A. x IN {} /\\ P x) <=> F) /\\\n (!P a s. (?x:A. x IN (a INSERT s) /\\ P x) <=> P a \\/ (?x. x IN s /\\ P x))`;;\n\nlet INJECTIVE_ON_IMAGE = `!f:A->B u.\n (!s t. s SUBSET u /\\ t SUBSET u /\\ IMAGE f s = IMAGE f t ==> s = t) <=>\n (!x y. x IN u /\\ y IN u /\\ f x = f y ==> x = y)`;;\n\nlet INJECTIVE_IMAGE = `!f:A->B.\n (!s t. IMAGE f s = IMAGE f t ==> s = t) <=> (!x y. f x = f y ==> x = y)`;;\n\nlet SURJECTIVE_ON_IMAGE = `!f:A->B u v.\n (!t. t SUBSET v ==> ?s. s SUBSET u /\\ IMAGE f s = t) <=>\n (!y. y IN v ==> ?x. x IN u /\\ f x = y)`;;\n\nlet SURJECTIVE_IMAGE = `!f:A->B. (!t. ?s. IMAGE f s = t) <=> (!y. ?x. f x = y)`;;\n\nlet INJECTIVE_ON_PREIMAGE = `!f:A->B s u.\n (!t t'. t SUBSET u /\\ t' SUBSET u /\\\n {x | x IN s /\\ f x IN t} = {x | x IN s /\\ f x IN t'}\n ==> t = t') <=>\n u SUBSET IMAGE f s`;;\n\nlet SURJECTIVE_ON_PREIMAGE = `!f:A->B s u.\n (!k. k SUBSET s\n ==> ?t. t SUBSET u /\\ {x | x IN s /\\ f x IN t} = k) <=>\n IMAGE f s SUBSET u /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)`;;\n\nlet INJECTIVE_PREIMAGE = `!f:A->B.\n (!t t'. {x | f x IN t} = {x | f x IN t'} ==> t = t') <=>\n IMAGE f UNIV = UNIV`;;\n\nlet SURJECTIVE_PREIMAGE = `!f:A->B. (!k. ?t. {x | f x IN t} = k) <=> (!x y. f x = f y ==> x = y)`;;\n\nlet CARD_EQ_BIJECTION = `!s t. FINITE s /\\ FINITE t /\\ CARD s = CARD t\n ==> ?f:A->B. (!x. x IN s ==> f(x) IN t) /\\\n (!y. y IN t ==> ?x. x IN s /\\ f x = y) /\\\n !x y. x IN s /\\ y IN s /\\ (f x = f y) ==> (x = y)`;;\n\nlet CARD_EQ_BIJECTIONS = `!s t. FINITE s /\\ FINITE t /\\ CARD s = CARD t\n ==> ?f:A->B g. (!x. x IN s ==> f(x) IN t /\\ g(f x) = x) /\\\n (!y. y IN t ==> g(y) IN s /\\ f(g y) = y)`;;\n\nlet CARD_EQ_BIJECTIONS_SPECIAL = `!s t (a:A) (b:B).\n FINITE s /\\ FINITE t /\\ CARD s = CARD t /\\ a IN s /\\ b IN t\n ==> ?f g. f a = b /\\ g b = a /\\\n (!x. x IN s ==> f x IN t /\\ g (f x) = x) /\\\n (!y. y IN t ==> g y IN s /\\ f (g y) = y)`;;\n\nlet BIJECTIONS_HAS_SIZE = `!s t f:A->B g.\n (!x. x IN s ==> f(x) IN t /\\ g(f x) = x) /\\\n (!y. y IN t ==> g(y) IN s /\\ f(g y) = y) /\\\n s HAS_SIZE n\n ==> t HAS_SIZE n`;;\n\nlet BIJECTIONS_HAS_SIZE_EQ = `!s t f:A->B g.\n (!x. x IN s ==> f(x) IN t /\\ g(f x) = x) /\\\n (!y. y IN t ==> g(y) IN s /\\ f(g y) = y)\n ==> !n. s HAS_SIZE n <=> t HAS_SIZE n`;;\n\nlet BIJECTIONS_CARD_EQ = `!s t f:A->B g.\n (FINITE s \\/ FINITE t) /\\\n (!x. x IN s ==> f(x) IN t /\\ g(f x) = x) /\\\n (!y. y IN t ==> g(y) IN s /\\ f(g y) = y)\n ==> CARD s = CARD t`;;\n\nlet WF_FINITE = `!(<<). (!x. ~(x << x)) /\\ (!x y z. x << y /\\ y << z ==> x << z) /\\\n (!x:A. FINITE {y | y << x})\n ==> WF(<<)`;;\n\nlet WF_PSUBSET = `!s:A->bool. FINITE s ==> WF (\\t1 t2. t1 PSUBSET t2 /\\ t2 SUBSET s)`;;\n\nlet le_c = new_definition\n `s <=_c t <=>\n ?f:A->B. (!x. x IN s ==> f(x) IN t) /\\\n (!x y. x IN s /\\ y IN s /\\ f(x) = f(y) ==> x = y)`;;\n\nlet lt_c = new_definition\n `(s:A->bool) <_c (t:B->bool) <=> s <=_c t /\\ ~(t <=_c s)`;;\n\nlet eq_c = new_definition\n `(s:A->bool) =_c (t:B->bool) <=>\n ?f. (!x. x IN s ==> f(x) IN t) /\\\n !y. y IN t ==> ?!x. x IN s /\\ (f x = y)`;;\n\nlet ge_c = new_definition\n `(s:A->bool) >=_c (t:B->bool) <=> t <=_c s`;;\n\nlet gt_c = new_definition\n `(s:A->bool) >_c (t:B->bool) <=> t <_c s`;;\n\nlet LE_C = `!s t. s <=_c t <=> ?g:A->B. !x. x IN s ==> ?y. y IN t /\\ g y = x`;;\n\nlet GE_C = `!s t. s >=_c t <=> ?f:A->B. !y. y IN t ==> ?x. x IN s /\\ (y = f x)`;;\n\nlet COUNTABLE = new_definition\n `COUNTABLE (t:A->bool) <=> (:num) >=_c t`;;\n\nlet sup = new_definition\n `sup s = @a:real. (!x. x IN s ==> x <= a) /\\\n !b. (!x. x IN s ==> x <= b) ==> a <= b`;;\n\nlet SUP_EQ = `!s t. (!b. (!x. x IN s ==> x <= b) <=> (!x. x IN t ==> x <= b))\n ==> sup s = sup t`;;\n\nlet SUP = `!s. ~(s = {}) /\\ (?b. !x. x IN s ==> x <= b)\n ==> (!x. x IN s ==> x <= sup s) /\\\n !b. (!x. x IN s ==> x <= b) ==> sup s <= b`;;\n\nlet SUP_FINITE_LEMMA = `!s. FINITE s /\\ ~(s = {}) ==> ?b:real. b IN s /\\ !x. x IN s ==> x <= b`;;\n\nlet SUP_FINITE = `!s. FINITE s /\\ ~(s = {}) ==> (sup s) IN s /\\ !x. x IN s ==> x <= sup s`;;\n\nlet REAL_LE_SUP_FINITE = `!s a. FINITE s /\\ ~(s = {}) ==> (a <= sup s <=> ?x. x IN s /\\ a <= x)`;;\n\nlet REAL_SUP_LE_FINITE = `!s a. FINITE s /\\ ~(s = {}) ==> (sup s <= a <=> !x. x IN s ==> x <= a)`;;\n\nlet REAL_LT_SUP_FINITE = `!s a. FINITE s /\\ ~(s = {}) ==> (a < sup s <=> ?x. x IN s /\\ a < x)`;;\n\nlet REAL_SUP_LT_FINITE = `!s a. FINITE s /\\ ~(s = {}) ==> (sup s < a <=> !x. x IN s ==> x < a)`;;\n\nlet REAL_SUP_UNIQUE = `!s b. (!x. x IN s ==> x <= b) /\\\n (!b'. b' < b ==> ?x. x IN s /\\ b' < x)\n ==> sup s = b`;;\n\nlet REAL_SUP_LE = `!b. ~(s = {}) /\\ (!x. x IN s ==> x <= b) ==> sup s <= b`;;\n\nlet REAL_SUP_LE_SUBSET = `!s t. ~(s = {}) /\\ s SUBSET t /\\ (?b. !x. x IN t ==> x <= b)\n ==> sup s <= sup t`;;\n\nlet REAL_SUP_BOUNDS = `!s a b. ~(s = {}) /\\ (!x. x IN s ==> a <= x /\\ x <= b)\n ==> a <= sup s /\\ sup s <= b`;;\n\nlet REAL_ABS_SUP_LE = `!s a. ~(s = {}) /\\ (!x. x IN s ==> abs(x) <= a) ==> abs(sup s) <= a`;;\n\nlet REAL_SUP_ASCLOSE = `!s l e. ~(s = {}) /\\ (!x. x IN s ==> abs(x - l) <= e)\n ==> abs(sup s - l) <= e`;;\n\nlet SUP_UNIQUE_FINITE = `!s. FINITE s /\\ ~(s = {})\n ==> (sup s = a <=> a IN s /\\ !y. y IN s ==> y <= a)`;;\n\nlet SUP_INSERT_FINITE = `!x s. FINITE s ==> sup(x INSERT s) = if s = {} then x else max x (sup s)`;;\n\nlet SUP_SING = `!a. sup {a} = a`;;\n\nlet SUP_INSERT_INSERT = `!a b s. sup (b INSERT a INSERT s) = sup (max a b INSERT s)`;;\n\nlet REAL_LE_SUP = `!s a b y. y IN s /\\ a <= y /\\ (!x. x IN s ==> x <= b) ==> a <= sup s`;;\n\nlet REAL_SUP_LE_EQ = `!s y. ~(s = {}) /\\ (?b. !x. x IN s ==> x <= b)\n ==> (sup s <= y <=> !x. x IN s ==> x <= y)`;;\n\nlet SUP_UNIQUE = `!s b. (!c. (!x. x IN s ==> x <= c) <=> b <= c) ==> sup s = b`;;\n\nlet SUP_UNION = `!s t. ~(s = {}) /\\ ~(t = {}) /\\\n (?b. !x. x IN s ==> x <= b) /\\ (?c. !x. x IN t ==> x <= c)\n ==> sup(s UNION t) = max (sup s) (sup t)`;;\n\nlet ELEMENT_LE_SUP = `!s a. (?b. !x. x IN s ==> x <= b) /\\ a IN s ==> a <= sup s`;;\n\nlet SUP_APPROACH = `!s c. ~(s = {}) /\\ (?b. !x. x IN s ==> x <= b) /\\ c < sup s\n ==> ?x. x IN s /\\ c < x`;;\n\nlet REAL_MAX_SUP = `!x y. max x y = sup {x,y}`;;\n\nlet inf = new_definition\n `inf s = @a:real. (!x. x IN s ==> a <= x) /\\\n !b. (!x. x IN s ==> b <= x) ==> b <= a`;;\n\nlet INF_EQ = `!s t. (!a. (!x. x IN s ==> a <= x) <=> (!x. x IN t ==> a <= x))\n ==> inf s = inf t`;;\n\nlet INF = `!s. ~(s = {}) /\\ (?b. !x. x IN s ==> b <= x)\n ==> (!x. x IN s ==> inf s <= x) /\\\n !b. (!x. x IN s ==> b <= x) ==> b <= inf s`;;\n\nlet INF_FINITE_LEMMA = `!s. FINITE s /\\ ~(s = {}) ==> ?b:real. b IN s /\\ !x. x IN s ==> b <= x`;;\n\nlet INF_FINITE = `!s. FINITE s /\\ ~(s = {}) ==> (inf s) IN s /\\ !x. x IN s ==> inf s <= x`;;\n\nlet REAL_LE_INF_FINITE = `!s a. FINITE s /\\ ~(s = {}) ==> (a <= inf s <=> !x. x IN s ==> a <= x)`;;\n\nlet REAL_INF_LE_FINITE = `!s a. FINITE s /\\ ~(s = {}) ==> (inf s <= a <=> ?x. x IN s /\\ x <= a)`;;\n\nlet REAL_LT_INF_FINITE = `!s a. FINITE s /\\ ~(s = {}) ==> (a < inf s <=> !x. x IN s ==> a < x)`;;\n\nlet REAL_INF_LT_FINITE = `!s a. FINITE s /\\ ~(s = {}) ==> (inf s < a <=> ?x. x IN s /\\ x < a)`;;\n\nlet REAL_INF_UNIQUE = `!s b. (!x. x IN s ==> b <= x) /\\\n (!b'. b < b' ==> ?x. x IN s /\\ x < b')\n ==> inf s = b`;;\n\nlet REAL_LE_INF = `!b. ~(s = {}) /\\ (!x. x IN s ==> b <= x) ==> b <= inf s`;;\n\nlet REAL_LE_INF_SUBSET = `!s t. ~(t = {}) /\\ t SUBSET s /\\ (?b. !x. x IN s ==> b <= x)\n ==> inf s <= inf t`;;\n\nlet REAL_INF_BOUNDS = `!s a b. ~(s = {}) /\\ (!x. x IN s ==> a <= x /\\ x <= b)\n ==> a <= inf s /\\ inf s <= b`;;\n\nlet REAL_ABS_INF_LE = `!s a. ~(s = {}) /\\ (!x. x IN s ==> abs(x) <= a) ==> abs(inf s) <= a`;;\n\nlet REAL_INF_ASCLOSE = `!s l e. ~(s = {}) /\\ (!x. x IN s ==> abs(x - l) <= e)\n ==> abs(inf s - l) <= e`;;\n\nlet INF_UNIQUE_FINITE = `!s. FINITE s /\\ ~(s = {})\n ==> (inf s = a <=> a IN s /\\ !y. y IN s ==> a <= y)`;;\n\nlet INF_INSERT_FINITE = `!x s. FINITE s ==> inf(x INSERT s) = if s = {} then x else min x (inf s)`;;\n\nlet INF_SING = `!a. inf {a} = a`;;\n\nlet INF_INSERT_INSERT = `!a b s. inf (b INSERT a INSERT s) = inf (min a b INSERT s)`;;\n\nlet REAL_SUP_EQ_INF = `!s. ~(s = {}) /\\ (?B. !x. x IN s ==> abs(x) <= B)\n ==> (sup s = inf s <=> ?a. s = {a})`;;\n\nlet REAL_INF_LE = `!s a b y. y IN s /\\ y <= b /\\ (!x. x IN s ==> a <= x) ==> inf s <= b`;;\n\nlet REAL_LE_INF_EQ = `!s y. ~(s = {}) /\\ (?b. !x. x IN s ==> b <= x)\n ==> (y <= inf s <=> !x. x IN s ==> y <= x)`;;\n\nlet INF_UNIQUE = `!s b. (!c. (!x. x IN s ==> c <= x) <=> c <= b) ==> inf s = b`;;\n\nlet INF_UNION = `!s t. ~(s = {}) /\\ ~(t = {}) /\\\n (?b. !x. x IN s ==> b <= x) /\\ (?c. !x. x IN t ==> c <= x)\n ==> inf(s UNION t) = min (inf s) (inf t)`;;\n\nlet INF_LE_ELEMENT = `!s a. (?b. !x. x IN s ==> b <= x) /\\ a IN s ==> inf s <= a`;;\n\nlet INF_APPROACH = `!s c. ~(s = {}) /\\ (?b. !x. x IN s ==> b <= x) /\\ inf s < c\n ==> ?x. x IN s /\\ x < c`;;\n\nlet REAL_MIN_INF = `!x y. min x y = inf {x,y}`;;\n\nparse_as_infix (\"has_inf\",(12,\"right\"));;\nparse_as_infix (\"has_sup\",(12,\"right\"));;\n\nlet has_inf = new_definition\n `s has_inf b <=> (!c. (!x:real. x IN s ==> c <= x) <=> c <= b)`;;\n\nlet has_sup = new_definition\n `s has_sup b <=> (!c. (!x:real. x IN s ==> x <= c) <=> b <= c)`;;\n\nlet HAS_INF_LBOUND = `!s b x. s has_inf b /\\ x IN s ==> b <= x`;;\n\nlet HAS_SUP_UBOUND = `!s b x. s has_sup b /\\ x IN s ==> x <= b`;;\n\nlet HAS_INF_INF = `!s l. s has_inf l <=>\n ~(s = {}) /\\\n (?b. !x. x IN s ==> b <= x) /\\\n inf s = l`;;\n\nlet HAS_SUP_SUP = `!s l. s has_sup l <=>\n ~(s = {}) /\\\n (?b. !x. x IN s ==> x <= b) /\\\n sup s = l`;;\n\nlet INF_EXISTS = `!s. (?l. s has_inf l) <=> ~(s = {}) /\\ (?b. !x. x IN s ==> b <= x)`;;\n\nlet SUP_EXISTS = `!s. (?l. s has_sup l) <=> ~(s = {}) /\\ (?b. !x. x IN s ==> x <= b)`;;\n\nlet HAS_INF_APPROACH = `!s l c. s has_inf l /\\ l < c ==> ?x. x IN s /\\ x < c`;;\n\nlet HAS_SUP_APPROACH = `!s l c. s has_sup l /\\ c < l ==> ?x. x IN s /\\ c < x`;;\n\nlet HAS_INF = `!s l. s has_inf l <=>\n ~(s = {}) /\\\n (!x. x IN s ==> l <= x) /\\\n (!c. l < c ==> ?x. x IN s /\\ x < c)`;;\n\nlet HAS_SUP = `!s l. s has_sup l <=>\n ~(s = {}) /\\\n (!x. x IN s ==> x <= l) /\\\n (!c. c < l ==> ?x. x IN s /\\ c < x)`;;\n\nlet HAS_INF_LE = `!s t l m. s has_inf l /\\ t has_inf m /\\\n (!y. y IN t ==> ?x. x IN s /\\ x <= y)\n ==> l <= m`;;\n\nlet HAS_SUP_LE = `!s t l m. s has_sup l /\\ t has_sup m /\\\n (!y. y IN t ==> ?x. x IN s /\\ y <= x)\n ==> m <= l`;;\n\nlet new_inductive_set =\n let const_of_var v = mk_mconst(name_of v,type_of v) in\n let comb_all =\n let rec f (n:int) (tm:term) : hol_type list -> term = function\n | [] -> tm\n | ty::tys ->\n let v = variant (variables tm) (mk_var(\"x\"^string_of_int n,ty)) in\n f (n+1) (mk_comb(tm,v)) tys in\n fun tm -> let tys = fst (splitlist dest_fun_ty (type_of tm)) in\n f 0 tm tys in\n let mk_eqin = REWR_CONV (GSYM IN) o comb_all in\n let transf conv = rhs o concl o conv in\n let remove_in_conv ptm : conv =\n let rconv = REWR_CONV(SYM(mk_eqin ptm)) in\n fun tm -> let htm = fst(strip_comb(snd(dest_binary \"IN\" tm))) in\n if htm = ptm then rconv tm else fail() in\n let remove_in_transf =\n transf o ONCE_DEPTH_CONV o FIRST_CONV o map remove_in_conv in\n let rule_head tm =\n let tm = snd(strip_forall tm) in\n let tm = snd(splitlist(dest_binop `(==>)`) tm) in\n let tm = snd(dest_binary \"IN\" tm) in\n fst(strip_comb tm) in\n let find_pvars = setify o map rule_head o binops `(/\\)` in\n fun tm ->\n let pvars = find_pvars tm in\n let dtm = remove_in_transf pvars tm in\n let th_rules, th_induct, th_cases = new_inductive_definition dtm in\n let insert_in_rule = REWRITE_RULE(map (mk_eqin o const_of_var) pvars) in\n insert_in_rule th_rules,\n insert_in_rule th_induct,\n insert_in_rule th_cases;;" }, { "theorem_id": 43, "title": "052_the_number_of_subsets_of_a_set", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Set theory for higher-order logic\\\n\ntheory Set\n imports Lattices Boolean_Algebras\nbegin\n\nsubsection \\Sets as predicates\\\n\ntypedecl 'a set\n\naxiomatization Collect :: \"('a \\ bool) \\ 'a set\" \\ \\comprehension\\\n and member :: \"'a \\ 'a set \\ bool\" \\ \\membership\\\n where mem_Collect_eq [iff, code_unfold]: \"member a (Collect P) = P a\"\n and Collect_mem_eq [simp, code_unfold]: \"Collect (\\x. member x A) = A\"\n\nnotation\n member (\\'(\\')\\) and\n member (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50)\n\nabbreviation not_member\n where \"not_member x A \\ \\ (x \\ A)\" \\ \\non-membership\\\nnotation\n not_member (\\'(\\')\\) and\n not_member (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50)\n\nopen_bundle member_ASCII_syntax\nbegin\nnotation (ASCII)\n member (\\'(:')\\) and\n member (\\(\\notation=\\infix :\\\\_/ : _)\\ [51, 51] 50) and\n not_member (\\'(~:')\\) and\n not_member (\\(\\notation=\\infix ~:\\\\_/ ~: _)\\ [51, 51] 50)\nend\n\ntext \\Set comprehensions\\\n\nsyntax\n \"_Coll\" :: \"pttrn \\ bool \\ 'a set\" (\\(\\indent=1 notation=\\mixfix set comprehension\\\\{_./ _})\\)\nsyntax_consts\n \"_Coll\" \\ Collect\ntranslations\n \"{x. P}\" \\ \"CONST Collect (\\x. P)\"\n\nsyntax (ASCII)\n \"_Collect\" :: \"pttrn \\ 'a set \\ bool \\ 'a set\" (\\(\\indent=1 notation=\\mixfix set comprehension\\\\{(_/: _)./ _})\\)\nsyntax\n \"_Collect\" :: \"pttrn \\ 'a set \\ bool \\ 'a set\" (\\(\\indent=1 notation=\\mixfix set comprehension\\\\{(_/ \\ _)./ _})\\)\ntranslations\n \"{p:A. P}\" \\ \"CONST Collect (\\p. p \\ A \\ P)\"\n\nML \\\n fun Collect_binder_tr' c [Abs (x, T, t), Const (\\<^const_syntax>\\Collect\\, _) $ Abs (y, _, P)] =\n if x = y then\n let\n val x' = Syntax_Trans.mark_bound_body (x, T);\n val t' = subst_bound (x', t);\n val P' = subst_bound (x', P);\n in Syntax.const c $ Syntax_Trans.mark_bound_abs (x, T) $ P' $ t' end\n else raise Match\n | Collect_binder_tr' _ _ = raise Match\n\\\n\nlemma CollectI: \"P a \\ a \\ {x. P x}\"\n by sorry\n\nlemma CollectD: \"a \\ {x. P x} \\ P a\"\n by sorry\n\nlemma Collect_cong: \"(\\x. P x = Q x) \\ {x. P x} = {x. Q x}\"\n by sorry\n\ntext \\\n Simproc for pulling \\x = t\\ in \\{x. \\ \\ x = t \\ \\}\\\n to the front (and similarly for \\t = x\\):\n\\\n\nsimproc_setup defined_Collect (\"{x. P x \\ Q x}\") = \\\n K (Quantifier1.rearrange_Collect\n (fn ctxt =>\n resolve_tac ctxt @{thms Collect_cong} 1 THEN\n resolve_tac ctxt @{thms iffI} 1 THEN\n ALLGOALS\n (EVERY' [REPEAT_DETERM o eresolve_tac ctxt @{thms conjE},\n DEPTH_SOLVE_1 o (assume_tac ctxt ORELSE' resolve_tac ctxt @{thms conjI})])))\n\\\n\nlemmas CollectE = CollectD [elim_format]\n\nlemma set_eqI:\n assumes \"\\x. x \\ A \\ x \\ B\"\n shows \"A = B\"\n by sorry\n\nlemma set_eq_iff: \"A = B \\ (\\x. x \\ A \\ x \\ B)\"\n by sorry\n\nlemma Collect_eqI:\n assumes \"\\x. P x = Q x\"\n shows \"Collect P = Collect Q\"\n by sorry\n\ntext \\Lifting of predicate class instances\\\n\ninstantiation set :: (type) boolean_algebra\nbegin\n\ndefinition less_eq_set\n where \"A \\ B \\ (\\x. member x A) \\ (\\x. member x B)\"\n\ndefinition less_set\n where \"A < B \\ (\\x. member x A) < (\\x. member x B)\"\n\ndefinition inf_set\n where \"A \\ B = Collect ((\\x. member x A) \\ (\\x. member x B))\"\n\ndefinition sup_set\n where \"A \\ B = Collect ((\\x. member x A) \\ (\\x. member x B))\"\n\ndefinition bot_set\n where \"\\ = Collect \\\"\n\ndefinition top_set\n where \"\\ = Collect \\\"\n\ndefinition uminus_set\n where \"- A = Collect (- (\\x. member x A))\"\n\ndefinition minus_set\n where \"A - B = Collect ((\\x. member x A) - (\\x. member x B))\"\n\ninstance\n by standard\n (simp_all add: less_eq_set_def less_set_def inf_set_def sup_set_def\n bot_set_def top_set_def uminus_set_def minus_set_def\n less_le_not_le sup_inf_distrib1 diff_eq set_eqI fun_eq_iff\n del: inf_apply sup_apply bot_apply top_apply minus_apply uminus_apply)\n\nend\n\ntext \\Set enumerations\\\n\nabbreviation empty :: \"'a set\" (\\{}\\)\n where \"{} \\ bot\"\n\ndefinition insert :: \"'a \\ 'a set \\ 'a set\"\n where insert_compr: \"insert a B = {x. x = a \\ x \\ B}\"\n\nopen_bundle set_enumeration_syntax\nbegin\n\nsyntax\n \"_Finset\" :: \"args \\ 'a set\" (\\(\\indent=1 notation=\\mixfix set enumeration\\\\{_})\\)\nsyntax_consts\n \"_Finset\" \\ insert\ntranslations\n \"{x, xs}\" \\ \"CONST insert x {xs}\"\n \"{x}\" \\ \"CONST insert x {}\"\n\nend\n\nsubsection \\Subsets and bounded quantifiers\\\n\nabbreviation subset :: \"'a set \\ 'a set \\ bool\"\n where \"subset \\ less\"\n\nabbreviation subset_eq :: \"'a set \\ 'a set \\ bool\"\n where \"subset_eq \\ less_eq\"\n\nnotation\n subset (\\'(\\')\\) and\n subset (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50) and\n subset_eq (\\'(\\')\\) and\n subset_eq (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50)\n\nabbreviation (input)\n supset :: \"'a set \\ 'a set \\ bool\" where\n \"supset \\ greater\"\n\nabbreviation (input)\n supset_eq :: \"'a set \\ 'a set \\ bool\" where\n \"supset_eq \\ greater_eq\"\n\nnotation\n supset (\\'(\\')\\) and\n supset (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50) and\n supset_eq (\\'(\\')\\) and\n supset_eq (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50)\n\nnotation (ASCII output)\n subset (\\'(<')\\) and\n subset (\\(\\notation=\\infix <\\\\_/ < _)\\ [51, 51] 50) and\n subset_eq (\\'(<=')\\) and\n subset_eq (\\(\\notation=\\infix <=\\\\_/ <= _)\\ [51, 51] 50)\n\ndefinition Ball :: \"'a set \\ ('a \\ bool) \\ bool\"\n where \"Ball A P \\ (\\x. x \\ A \\ P x)\" \\ \\bounded universal quantifiers\\\n\ndefinition Bex :: \"'a set \\ ('a \\ bool) \\ bool\"\n where \"Bex A P \\ (\\x. x \\ A \\ P x)\" \\ \\bounded existential quantifiers\\\n\nsyntax (ASCII)\n \"_Ball\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder ALL :\\\\ALL (_/:_)./ _)\\ [0, 0, 10] 10)\n \"_Bex\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder EX :\\\\EX (_/:_)./ _)\\ [0, 0, 10] 10)\n \"_Bex1\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder EX! :\\\\EX! (_/:_)./ _)\\ [0, 0, 10] 10)\n \"_Bleast\" :: \"id \\ 'a set \\ bool \\ 'a\" (\\(\\indent=3 notation=\\binder LEAST :\\\\LEAST (_/:_)./ _)\\ [0, 0, 10] 10)\n\nsyntax (input)\n \"_Ball\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder ! :\\\\! (_/:_)./ _)\\ [0, 0, 10] 10)\n \"_Bex\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder ? :\\\\? (_/:_)./ _)\\ [0, 0, 10] 10)\n \"_Bex1\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder ?! :\\\\?! (_/:_)./ _)\\ [0, 0, 10] 10)\n\nsyntax\n \"_Ball\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\(_/\\_)./ _)\\ [0, 0, 10] 10)\n \"_Bex\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\(_/\\_)./ _)\\ [0, 0, 10] 10)\n \"_Bex1\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder \\!\\\\\\!(_/\\_)./ _)\\ [0, 0, 10] 10)\n \"_Bleast\" :: \"id \\ 'a set \\ bool \\ 'a\" (\\(\\indent=3 notation=\\binder LEAST\\\\LEAST(_/\\_)./ _)\\ [0, 0, 10] 10)\n\nsyntax_consts\n \"_Ball\" \\ Ball and\n \"_Bex\" \\ Bex and\n \"_Bex1\" \\ Ex1 and\n \"_Bleast\" \\ Least\n\ntranslations\n \"\\x\\A. P\" \\ \"CONST Ball A (\\x. P)\"\n \"\\x\\A. P\" \\ \"CONST Bex A (\\x. P)\"\n \"\\!x\\A. P\" \\ \"\\!x. x \\ A \\ P\"\n \"LEAST x:A. P\" \\ \"LEAST x. x \\ A \\ P\"\n\nsyntax (ASCII output)\n \"_setlessAll\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder ALL\\\\ALL _<_./ _)\\ [0, 0, 10] 10)\n \"_setlessEx\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder EX\\\\EX _<_./ _)\\ [0, 0, 10] 10)\n \"_setleAll\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder ALL\\\\ALL _<=_./ _)\\ [0, 0, 10] 10)\n \"_setleEx\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder EX\\\\EX _<=_./ _)\\ [0, 0, 10] 10)\n \"_setleEx1\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder EX!\\\\EX! _<=_./ _)\\ [0, 0, 10] 10)\n\nsyntax\n \"_setlessAll\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\_\\_./ _)\\ [0, 0, 10] 10)\n \"_setlessEx\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\_\\_./ _)\\ [0, 0, 10] 10)\n \"_setleAll\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\_\\_./ _)\\ [0, 0, 10] 10)\n \"_setleEx\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\_\\_./ _)\\ [0, 0, 10] 10)\n \"_setleEx1\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder \\!\\\\\\!_\\_./ _)\\ [0, 0, 10] 10)\n\nsyntax_consts\n \"_setlessAll\" \"_setleAll\" \\ All and\n \"_setlessEx\" \"_setleEx\" \\ Ex and\n \"_setleEx1\" \\ Ex1\n\ntranslations\n \"\\A\\B. P\" \\ \"\\A. A \\ B \\ P\"\n \"\\A\\B. P\" \\ \"\\A. A \\ B \\ P\"\n \"\\A\\B. P\" \\ \"\\A. A \\ B \\ P\"\n \"\\A\\B. P\" \\ \"\\A. A \\ B \\ P\"\n \"\\!A\\B. P\" \\ \"\\!A. A \\ B \\ P\"\n\nprint_translation \\\n let\n val All_binder = Mixfix.binder_name \\<^const_syntax>\\All\\;\n val Ex_binder = Mixfix.binder_name \\<^const_syntax>\\Ex\\;\n val impl = \\<^const_syntax>\\HOL.implies\\;\n val conj = \\<^const_syntax>\\HOL.conj\\;\n val sbset = \\<^const_syntax>\\subset\\;\n val sbset_eq = \\<^const_syntax>\\subset_eq\\;\n\n val trans =\n [((All_binder, impl, sbset), \\<^syntax_const>\\_setlessAll\\),\n ((All_binder, impl, sbset_eq), \\<^syntax_const>\\_setleAll\\),\n ((Ex_binder, conj, sbset), \\<^syntax_const>\\_setlessEx\\),\n ((Ex_binder, conj, sbset_eq), \\<^syntax_const>\\_setleEx\\)];\n\n fun mk v (v', T) c n P =\n if v = v' andalso not (Term.exists_subterm (fn Free (x, _) => x = v | _ => false) n)\n then Syntax.const c $ Syntax_Trans.mark_bound_body (v', T) $ n $ P\n else raise Match;\n\n fun tr' q = (q, fn _ =>\n (fn [Const (\\<^syntax_const>\\_bound\\, _) $ Free (v, \\<^Type>\\set _\\),\n Const (c, _) $\n (Const (d, _) $ (Const (\\<^syntax_const>\\_bound\\, _) $ Free (v', T)) $ n) $ P] =>\n (case AList.lookup (=) trans (q, c, d) of\n NONE => raise Match\n | SOME l => mk v (v', T) l n P)\n | _ => raise Match));\n in\n [tr' All_binder, tr' Ex_binder]\n end\n\\\n\ntext \\\n \\<^medskip>\n Translate between \\{e | x1\\xn. P}\\ and \\{u. \\x1\\xn. u = e \\ P}\\;\n \\{y. \\x1\\xn. y = e \\ P}\\ is only translated if \\[0..n] \\ bvs e\\.\n\\\n\nsyntax\n \"_Setcompr\" :: \"'a \\ idts \\ bool \\ 'a set\"\n (\\(\\indent=1 notation=\\mixfix set comprehension\\\\{_ |/_./ _})\\)\nsyntax_consts\n \"_Setcompr\" \\ Collect\n\nparse_translation \\\n let\n val ex_tr = snd (Syntax_Trans.mk_binder_tr (\"EX \", \\<^const_syntax>\\Ex\\));\n\n fun nvars (Const (\\<^syntax_const>\\_idts\\, _) $ _ $ idts) = nvars idts + 1\n | nvars _ = 1;\n\n fun setcompr_tr ctxt [e, idts, b] =\n let\n val eq = Syntax.const \\<^const_syntax>\\HOL.eq\\ $ Bound (nvars idts) $ e;\n val P = Syntax.const \\<^const_syntax>\\HOL.conj\\ $ eq $ b;\n val exP = ex_tr ctxt [idts, P];\n in Syntax.const \\<^const_syntax>\\Collect\\ $ absdummy dummyT exP end;\n\n in [(\\<^syntax_const>\\_Setcompr\\, setcompr_tr)] end\n\\\n\ntyped_print_translation \\\n [(\\<^const_syntax>\\Ball\\, Syntax_Trans.preserve_binder_abs2_tr' \\<^syntax_const>\\_Ball\\),\n (\\<^const_syntax>\\Bex\\, Syntax_Trans.preserve_binder_abs2_tr' \\<^syntax_const>\\_Bex\\)]\n\\ \\ \\to avoid eta-contraction of body\\\n\nprint_translation \\\nlet\n val ex_tr' = snd (Syntax_Trans.mk_binder_tr' (\\<^const_syntax>\\Ex\\, \"DUMMY\"));\n\n fun setcompr_tr' ctxt [Abs (abs as (_, _, P))] =\n let\n fun check (Const (\\<^const_syntax>\\Ex\\, _) $ Abs (_, _, P), n) = check (P, n + 1)\n | check (Const (\\<^const_syntax>\\HOL.conj\\, _) $\n (Const (\\<^const_syntax>\\HOL.eq\\, _) $ Bound m $ e) $ P, n) =\n n > 0 andalso m = n andalso not (loose_bvar1 (P, n)) andalso\n subset (=) (0 upto (n - 1), add_loose_bnos (e, 0, []))\n | check _ = false;\n\n fun tr' (_ $ abs) =\n let val _ $ idts $ (_ $ (_ $ _ $ e) $ Q) = ex_tr' ctxt [abs]\n in Syntax.const \\<^syntax_const>\\_Setcompr\\ $ e $ idts $ Q end;\n in\n if check (P, 0) then tr' P\n else\n let\n val (x as _ $ Free(xN, _), t) = Syntax_Trans.atomic_abs_tr' ctxt abs;\n val M = Syntax.const \\<^syntax_const>\\_Coll\\ $ x $ t;\n in\n case t of\n Const (\\<^const_syntax>\\HOL.conj\\, _) $\n (Const (\\<^const_syntax>\\Set.member\\, _) $\n (Const (\\<^syntax_const>\\_bound\\, _) $ Free (yN, _)) $ A) $ P =>\n if xN = yN then Syntax.const \\<^syntax_const>\\_Collect\\ $ x $ A $ P else M\n | _ => M\n end\n end;\n in [(\\<^const_syntax>\\Collect\\, setcompr_tr')] end\n\\\n\nsimproc_setup defined_Bex (\"\\x\\A. P x \\ Q x\") = \\\n K (Quantifier1.rearrange_Bex (fn ctxt => unfold_tac ctxt @{thms Bex_def}))\n\\\n\nsimproc_setup defined_All (\"\\x\\A. P x \\ Q x\") = \\\n K (Quantifier1.rearrange_Ball (fn ctxt => unfold_tac ctxt @{thms Ball_def}))\n\\\n\nlemma ballI [intro!]: \"(\\x. x \\ A \\ P x) \\ \\x\\A. P x\"\n by sorry\n\nlemmas strip = impI allI ballI\n\nlemma bspec [dest?]: \"\\x\\A. P x \\ x \\ A \\ P x\"\n by sorry\n\ntext \\Gives better instantiation for bound:\\\nsetup \\\n map_theory_claset (fn ctxt =>\n ctxt addbefore (\"bspec\", fn ctxt' => dresolve_tac ctxt' @{thms bspec} THEN' assume_tac ctxt'))\n\\\n\nML \\\nstructure Simpdata =\nstruct\n open Simpdata;\n val mksimps_pairs = [(\\<^const_name>\\Ball\\, @{thms bspec})] @ mksimps_pairs;\nend;\n\nopen Simpdata;\n\\\n\ndeclaration \\fn _ => Simplifier.map_simpset (Simplifier.set_mksimps (mksimps mksimps_pairs))\\\n\nlemma ballE [elim]: \"\\x\\A. P x \\ (P x \\ Q) \\ (x \\ A \\ Q) \\ Q\"\n by sorry\n\nlemma bexI [intro]: \"P x \\ x \\ A \\ \\x\\A. P x\"\n \\ \\Normally the best argument order: \\P x\\ constrains the choice of \\x \\ A\\.\\\n by sorry\n\nlemma rev_bexI [intro?]: \"x \\ A \\ P x \\ \\x\\A. P x\"\n \\ \\The best argument order when there is only one \\x \\ A\\.\\\n by sorry\n\nlemma bexCI: \"(\\x\\A. \\ P x \\ P a) \\ a \\ A \\ \\x\\A. P x\"\n by sorry\n\nlemma bexE [elim!]: \"\\x\\A. P x \\ (\\x. x \\ A \\ P x \\ Q) \\ Q\"\n by sorry\n\nlemma ball_triv [simp]: \"(\\x\\A. P) \\ ((\\x. x \\ A) \\ P)\"\n \\ \\trivial rewrite rule.\\\n by sorry\n\nlemma bex_triv [simp]: \"(\\x\\A. P) \\ ((\\x. x \\ A) \\ P)\"\n \\ \\Dual form for existentials.\\\n by sorry\n\nlemma bex_triv_one_point1 [simp]: \"(\\x\\A. x = a) \\ a \\ A\"\n by sorry\n\nlemma bex_triv_one_point2 [simp]: \"(\\x\\A. a = x) \\ a \\ A\"\n by sorry\n\nlemma bex_one_point1 [simp]: \"(\\x\\A. x = a \\ P x) \\ a \\ A \\ P a\"\n by sorry\n\nlemma bex_one_point2 [simp]: \"(\\x\\A. a = x \\ P x) \\ a \\ A \\ P a\"\n by sorry\n\nlemma ball_one_point1 [simp]: \"(\\x\\A. x = a \\ P x) \\ (a \\ A \\ P a)\"\n by sorry\n\nlemma ball_one_point2 [simp]: \"(\\x\\A. a = x \\ P x) \\ (a \\ A \\ P a)\"\n by sorry\n\nlemma ball_conj_distrib: \"(\\x\\A. P x \\ Q x) \\ (\\x\\A. P x) \\ (\\x\\A. Q x)\"\n by sorry\n\nlemma bex_disj_distrib: \"(\\x\\A. P x \\ Q x) \\ (\\x\\A. P x) \\ (\\x\\A. Q x)\"\n by sorry\n\ntext \\Congruence rules\\\n\nlemma ball_cong:\n \"\\ A = B; \\x. x \\ B \\ P x \\ Q x \\ \\\n (\\x\\A. P x) \\ (\\x\\B. Q x)\"\n by sorry\n\nlemma ball_cong_simp [cong]:\n \"\\ A = B; \\x. x \\ B =simp=> P x \\ Q x \\ \\\n (\\x\\A. P x) \\ (\\x\\B. Q x)\"\n by sorry\n\nlemma bex_cong:\n \"\\ A = B; \\x. x \\ B \\ P x \\ Q x \\ \\\n (\\x\\A. P x) \\ (\\x\\B. Q x)\"\n by sorry\n\nlemma bex_cong_simp [cong]:\n \"\\ A = B; \\x. x \\ B =simp=> P x \\ Q x \\ \\\n (\\x\\A. P x) \\ (\\x\\B. Q x)\"\n by sorry\n\nlemma bex1_def: \"(\\!x\\X. P x) \\ (\\x\\X. P x) \\ (\\x\\X. \\y\\X. P x \\ P y \\ x = y)\"\n by sorry\n\nsubsection \\Basic operations\\\n\nsubsubsection \\Subsets\\\n\nlemma subsetI [intro!]: \"(\\x. x \\ A \\ x \\ B) \\ A \\ B\"\n by sorry\n\ntext \\\n \\<^medskip>\n Map the type \\'a set \\ anything\\ to just \\'a\\; for overloading constants\n whose first argument has type \\'a set\\.\n\\\n\nlemma subsetD [elim, intro?]: \"A \\ B \\ c \\ A \\ c \\ B\"\n by sorry\n\nlemma rev_subsetD [intro?,no_atp]: \"c \\ A \\ A \\ B \\ c \\ B\"\n \\ \\The same, with reversed premises for use with @{method erule} -- cf. @{thm rev_mp}.\\\n by sorry\n\nlemma subsetCE [elim,no_atp]: \"A \\ B \\ (c \\ A \\ P) \\ (c \\ B \\ P) \\ P\"\n \\ \\Classical elimination rule.\\\n by sorry\n\nlemma subset_eq: \"A \\ B \\ (\\x\\A. x \\ B)\"\n by sorry\n\nlemma contra_subsetD [no_atp]: \"A \\ B \\ c \\ B \\ c \\ A\"\n by sorry\n\nlemma subset_refl: \"A \\ A\"\n by sorry\n\nlemma subset_trans: \"A \\ B \\ B \\ C \\ A \\ C\"\n by sorry\n\nlemma subset_not_subset_eq [code]: \"A \\ B \\ A \\ B \\ \\ B \\ A\"\n by sorry\n\nlemma eq_mem_trans: \"a = b \\ b \\ A \\ a \\ A\"\n by sorry\n\nlemmas basic_trans_rules [trans] =\n order_trans_rules rev_subsetD subsetD eq_mem_trans\n\nsubsubsection \\Equality\\\n\nlemma subset_antisym [intro!]: \"A \\ B \\ B \\ A \\ A = B\"\n \\ \\Anti-symmetry of the subset relation.\\\n by sorry\n\ntext \\\\<^medskip> Equality rules from ZF set theory -- are they appropriate here?\\\n\nlemma equalityD1: \"A = B \\ A \\ B\"\n by sorry\n\nlemma equalityD2: \"A = B \\ B \\ A\"\n by sorry\n\ntext \\\n \\<^medskip>\n Be careful when adding this to the claset as \\subset_empty\\ is in the\n simpset: \\<^prop>\\A = {}\\ goes to \\<^prop>\\{} \\ A\\ and \\<^prop>\\A \\ {}\\\n and then back to \\<^prop>\\A = {}\\!\n\\\n\nlemma equalityE: \"A = B \\ (A \\ B \\ B \\ A \\ P) \\ P\"\n by sorry\n\nlemma equalityCE [elim]: \"A = B \\ (c \\ A \\ c \\ B \\ P) \\ (c \\ A \\ c \\ B \\ P) \\ P\"\n by sorry\n\nlemma eqset_imp_iff: \"A = B \\ x \\ A \\ x \\ B\"\n by sorry\n\nlemma eqelem_imp_iff: \"x = y \\ x \\ A \\ y \\ A\"\n by sorry\n\nsubsubsection \\The empty set\\\n\nlemma empty_def: \"{} = {x. False}\"\n by sorry\n\nlemma empty_iff [simp]: \"c \\ {} \\ False\"\n by sorry\n\nlemma emptyE [elim!]: \"a \\ {} \\ P\"\n by sorry\n\nlemma empty_subsetI [iff]: \"{} \\ A\"\n \\ \\One effect is to delete the ASSUMPTION \\<^prop>\\{} \\ A\\\\\n by sorry\n\nlemma equals0I: \"(\\y. y \\ A \\ False) \\ A = {}\"\n by sorry\n\nlemma equals0D: \"A = {} \\ a \\ A\"\n \\ \\Use for reasoning about disjointness: \\A \\ B = {}\\\\\n by sorry\n\nlemma ball_empty [simp]: \"Ball {} P \\ True\"\n by sorry\n\nlemma bex_empty [simp]: \"Bex {} P \\ False\"\n by sorry\n\nsubsubsection \\The universal set -- UNIV\\\n\nabbreviation UNIV :: \"'a set\"\n where \"UNIV \\ top\"\n\nlemma UNIV_def: \"UNIV = {x. True}\"\n by sorry\n\nlemma UNIV_I [simp]: \"x \\ UNIV\"\n by sorry\n\ndeclare UNIV_I [intro] \\ \\unsafe makes it less likely to cause problems\\\n\nlemma UNIV_witness [intro?]: \"\\x. x \\ UNIV\"\n by sorry\n\nlemma subset_UNIV: \"A \\ UNIV\"\n by sorry\n\ntext \\\n \\<^medskip>\n Eta-contracting these two rules (to remove \\P\\) causes them\n to be ignored because of their interaction with congruence rules.\n\\\n\nlemma ball_UNIV [simp]: \"Ball UNIV P \\ All P\"\n by sorry\n\nlemma bex_UNIV [simp]: \"Bex UNIV P \\ Ex P\"\n by sorry\n\nlemma UNIV_eq_I: \"(\\x. x \\ A) \\ UNIV = A\"\n by sorry\n\nlemma UNIV_not_empty [iff]: \"UNIV \\ {}\"\n by sorry\n\nlemma empty_not_UNIV[simp]: \"{} \\ UNIV\"\n by sorry\n\nsubsubsection \\The Powerset operator -- Pow\\\n\ndefinition Pow :: \"'a set \\ 'a set set\"\n where Pow_def: \"Pow A = {B. B \\ A}\"\n\nlemma Pow_iff [iff]: \"A \\ Pow B \\ A \\ B\"\n by sorry\n\nlemma PowI: \"A \\ B \\ A \\ Pow B\"\n by sorry\n\nlemma PowD: \"A \\ Pow B \\ A \\ B\"\n by sorry\n\nlemma Pow_bottom: \"{} \\ Pow B\"\n by sorry\n\nlemma Pow_top: \"A \\ Pow A\"\n by sorry\n\nlemma Pow_not_empty: \"Pow A \\ {}\"\n by sorry\n\nsubsubsection \\Set complement\\\n\nlemma Compl_iff [simp]: \"c \\ - A \\ c \\ A\"\n by sorry\n\nlemma ComplI [intro!]: \"(c \\ A \\ False) \\ c \\ - A\"\n by sorry\n\ntext \\\n \\<^medskip>\n This form, with negated conclusion, works well with the Classical prover.\n Negated assumptions behave like formulae on the right side of the\n notional turnstile \\dots\n\\\n\nlemma ComplD [dest!]: \"c \\ - A \\ c \\ A\"\n by sorry\n\nlemmas ComplE = ComplD [elim_format]\n\nlemma Compl_eq: \"- A = {x. \\ x \\ A}\"\n by sorry\n\nsubsubsection \\Binary intersection\\\n\nabbreviation inter :: \"'a set \\ 'a set \\ 'a set\" (infixl \\\\\\ 70)\n where \"(\\) \\ inf\"\n\nnotation (ASCII)\n inter (infixl \\Int\\ 70)\n\nlemma Int_def: \"A \\ B = {x. x \\ A \\ x \\ B}\"\n by sorry\n\nlemma Int_iff [simp]: \"c \\ A \\ B \\ c \\ A \\ c \\ B\"\n by sorry\n\nlemma IntI [intro!]: \"c \\ A \\ c \\ B \\ c \\ A \\ B\"\n by sorry\n\nlemma IntD1: \"c \\ A \\ B \\ c \\ A\"\n by sorry\n\nlemma IntD2: \"c \\ A \\ B \\ c \\ B\"\n by sorry\n\nlemma IntE [elim!]: \"c \\ A \\ B \\ (c \\ A \\ c \\ B \\ P) \\ P\"\n by sorry\n\nsubsubsection \\Binary union\\\n\nabbreviation union :: \"'a set \\ 'a set \\ 'a set\" (infixl \\\\\\ 65)\n where \"union \\ sup\"\n\nnotation (ASCII)\n union (infixl \\Un\\ 65)\n\nlemma Un_def: \"A \\ B = {x. x \\ A \\ x \\ B}\"\n by sorry\n\nlemma Un_iff [simp]: \"c \\ A \\ B \\ c \\ A \\ c \\ B\"\n by sorry\n\nlemma UnI1 [elim?]: \"c \\ A \\ c \\ A \\ B\"\n by sorry\n\nlemma UnI2 [elim?]: \"c \\ B \\ c \\ A \\ B\"\n by sorry\n\ntext \\\\<^medskip> Classical introduction rule: no commitment to \\A\\ vs. \\B\\.\\\nlemma UnCI [intro!]: \"(c \\ B \\ c \\ A) \\ c \\ A \\ B\"\n by sorry\n\nlemma UnE [elim!]: \"c \\ A \\ B \\ (c \\ A \\ P) \\ (c \\ B \\ P) \\ P\"\n by sorry\n\nlemma insert_def: \"insert a B = {x. x = a} \\ B\"\n by sorry\n\nsubsubsection \\Set difference\\\n\ntext \\The minius-sign syntax continues to be accepted\\\nabbreviation set_difference :: \"['a set, 'a set] \\ 'a set\" \n (infixl \"\\\" 65) where \"A \\ B \\ A-B\"\n\nlemma Diff_iff [simp]: \"c \\ A - B \\ c \\ A \\ c \\ B\"\n by sorry\n\nlemma DiffI [intro!]: \"c \\ A \\ c \\ B \\ c \\ A - B\"\n by sorry\n\nlemma DiffD1: \"c \\ A - B \\ c \\ A\"\n by sorry\n\nlemma DiffD2: \"c \\ A - B \\ c \\ B \\ P\"\n by sorry\n\nlemma DiffE [elim!]: \"c \\ A - B \\ (c \\ A \\ c \\ B \\ P) \\ P\"\n by sorry\n\nlemma set_diff_eq: \"A - B = {x. x \\ A \\ x \\ B}\"\n by sorry\n\nlemma Compl_eq_Diff_UNIV: \"- A = (UNIV - A)\"\n by sorry\n\nabbreviation sym_diff :: \"'a set \\ 'a set \\ 'a set\" where\n \"sym_diff A B \\ ((A - B) \\ (B-A))\"\n\nsubsubsection \\Augmenting a set -- \\<^const>\\insert\\\\\n\nlemma insert_iff [simp]: \"a \\ insert b A \\ a = b \\ a \\ A\"\n by sorry\n\nlemma insertI1: \"a \\ insert a B\"\n by sorry\n\nlemma insertI2: \"a \\ B \\ a \\ insert b B\"\n by sorry\n\nlemma insertE [elim!]: \"a \\ insert b A \\ (a = b \\ P) \\ (a \\ A \\ P) \\ P\"\n by sorry\n\nlemma insertCI [intro!]: \"(a \\ B \\ a = b) \\ a \\ insert b B\"\n \\ \\Classical introduction rule.\\\n by sorry\n\nlemma subset_insert_iff: \"A \\ insert x B \\ (if x \\ A then A - {x} \\ B else A \\ B)\"\n by sorry\n\nlemma set_insert:\n assumes \"x \\ A\"\n obtains B where \"A = insert x B\" and \"x \\ B\"\n by sorry\n\nlemma insert_ident: \"x \\ A \\ x \\ B \\ insert x A = insert x B \\ A = B\"\n by sorry\n\nlemma insert_eq_iff:\n assumes \"a \\ A\" \"b \\ B\"\n shows \"insert a A = insert b B \\\n (if a = b then A = B else \\C. A = insert b C \\ b \\ C \\ B = insert a C \\ a \\ C)\"\n (is \"?L \\ ?R\")\n by sorry\n\nlemma insert_UNIV[simp]: \"insert x UNIV = UNIV\"\n by sorry\n\nsubsubsection \\Singletons, using insert\\\n\nlemma singletonI [intro!]: \"a \\ {a}\"\n \\ \\Redundant? But unlike \\insertCI\\, it proves the subgoal immediately!\\\n by sorry\n\nlemma singletonD [dest!]: \"b \\ {a} \\ b = a\"\n by sorry\n\nlemmas singletonE = singletonD [elim_format]\n\nlemma singleton_iff: \"b \\ {a} \\ b = a\"\n by sorry\n\nlemma singleton_inject [dest!]: \"{a} = {b} \\ a = b\"\n by sorry\n\nlemma singleton_insert_inj_eq [iff]: \"{b} = insert a A \\ a = b \\ A \\ {b}\"\n by sorry\n\nlemma singleton_insert_inj_eq' [iff]: \"insert a A = {b} \\ a = b \\ A \\ {b}\"\n by sorry\n\nlemma subset_singletonD: \"A \\ {x} \\ A = {} \\ A = {x}\"\n by sorry\n\nlemma subset_singleton_iff: \"X \\ {a} \\ X = {} \\ X = {a}\"\n by sorry\n\nlemma subset_singleton_iff_Uniq: \"(\\a. A \\ {a}) \\ (\\\\<^sub>\\\\<^sub>1x. x \\ A)\"\n by sorry\n\nlemma singleton_conv [simp]: \"{x. x = a} = {a}\"\n by sorry\n\nlemma singleton_conv2 [simp]: \"{x. a = x} = {a}\"\n by sorry\n\nlemma Diff_single_insert: \"A - {x} \\ B \\ A \\ insert x B\"\n by sorry\n\nlemma subset_Diff_insert: \"A \\ B - insert x C \\ A \\ B - C \\ x \\ A\"\n by sorry\n\nlemma doubleton_eq_iff: \"{a, b} = {c, d} \\ a = c \\ b = d \\ a = d \\ b = c\"\n by sorry\n\nlemma Un_singleton_iff: \"A \\ B = {x} \\ A = {} \\ B = {x} \\ A = {x} \\ B = {} \\ A = {x} \\ B = {x}\"\n by sorry\n\nlemma singleton_Un_iff: \"{x} = A \\ B \\ A = {} \\ B = {x} \\ A = {x} \\ B = {} \\ A = {x} \\ B = {x}\"\n by sorry\n\nsubsubsection \\Image of a set under a function\\\n\ntext \\Frequently \\b\\ does not have the syntactic form of \\f x\\.\\\n\ndefinition image :: \"('a \\ 'b) \\ 'a set \\ 'b set\" (infixr \\`\\ 90)\n where \"f ` A = {y. \\x\\A. y = f x}\"\n\nlemma image_eqI [simp, intro]: \"b = f x \\ x \\ A \\ b \\ f ` A\"\n by sorry\n\nlemma imageI: \"x \\ A \\ f x \\ f ` A\"\n by sorry\n\nlemma rev_image_eqI: \"x \\ A \\ b = f x \\ b \\ f ` A\"\n \\ \\This version's more effective when we already have the required \\x\\.\\\n by sorry\n\nlemma imageE [elim!]:\n assumes \"b \\ (\\x. f x) ` A\" \\ \\The eta-expansion gives variable-name preservation.\\\n obtains x where \"b = f x\" and \"x \\ A\"\n by sorry\n\nlemma Compr_image_eq: \"{x \\ f ` A. P x} = f ` {x \\ A. P (f x)}\"\n by sorry\n\nlemma image_Un: \"f ` (A \\ B) = f ` A \\ f ` B\"\n by sorry\n\nlemma image_iff: \"z \\ f ` A \\ (\\x\\A. z = f x)\"\n by sorry\n\nlemma image_subsetI: \"(\\x. x \\ A \\ f x \\ B) \\ f ` A \\ B\"\n \\ \\Replaces the three steps \\subsetI\\, \\imageE\\,\n \\hypsubst\\, but breaks too many existing proofs.\\\n by sorry\n\nlemma image_subset_iff: \"f ` A \\ B \\ (\\x\\A. f x \\ B)\"\n \\ \\This rewrite rule would confuse users if made default.\\\n by sorry\n\nlemma subset_imageE:\n assumes \"B \\ f ` A\"\n obtains C where \"C \\ A\" and \"B = f ` C\"\n by sorry\n\nlemma subset_image_iff: \"B \\ f ` A \\ (\\AA\\A. B = f ` AA)\"\n by sorry\n\nlemma image_ident [simp]: \"(\\x. x) ` Y = Y\"\n by sorry\n\nlemma image_empty [simp]: \"f ` {} = {}\"\n by sorry\n\nlemma image_insert [simp]: \"f ` insert a B = insert (f a) (f ` B)\"\n by sorry\n\nlemma image_constant: \"x \\ A \\ (\\x. c) ` A = {c}\"\n by sorry\n\nlemma image_constant_conv: \"(\\x. c) ` A = (if A = {} then {} else {c})\"\n by sorry\n\nlemma image_image: \"f ` (g ` A) = (\\x. f (g x)) ` A\"\n by sorry\n\nlemma insert_image [simp]: \"x \\ A \\ insert (f x) (f ` A) = f ` A\"\n by sorry\n\nlemma image_is_empty [iff]: \"f ` A = {} \\ A = {}\"\n by sorry\n\nlemma empty_is_image [iff]: \"{} = f ` A \\ A = {}\"\n by sorry\n\nlemma image_Collect: \"f ` {x. P x} = {f x | x. P x}\"\n \\ \\NOT suitable as a default simp rule: the RHS isn't simpler than the LHS,\n with its implicit quantifier and conjunction. Also image enjoys better\n equational properties than does the RHS.\\\n by sorry\n\nlemma if_image_distrib [simp]:\n \"(\\x. if P x then f x else g x) ` S = f ` (S \\ {x. P x}) \\ g ` (S \\ {x. \\ P x})\"\n by sorry\n\nlemma image_cong:\n \"f ` M = g ` N\" if \"M = N\" \"\\x. x \\ N \\ f x = g x\"\n by sorry\n\nlemma image_cong_simp [cong]:\n \"f ` M = g ` N\" if \"M = N\" \"\\x. x \\ N =simp=> f x = g x\"\n by sorry\n\nlemma image_Int_subset: \"f ` (A \\ B) \\ f ` A \\ f ` B\"\n by sorry\n\nlemma image_diff_subset: \"f ` A - f ` B \\ f ` (A - B)\"\n by sorry\n\nlemma Setcompr_eq_image: \"{f x |x. x \\ A} = f ` A\"\n by sorry\n\nlemma setcompr_eq_image: \"{f x |x. P x} = f ` {x. P x}\"\n by sorry\n\nlemma ball_imageD: \"\\x\\f ` A. P x \\ \\x\\A. P (f x)\"\n by sorry\n\nlemma bex_imageD: \"\\x\\f ` A. P x \\ \\x\\A. P (f x)\"\n by sorry\n\nlemma image_add_0 [simp]: \"(+) (0::'a::comm_monoid_add) ` S = S\"\n by sorry\n\ntheorem Cantors_theorem: \"\\f. f ` A = Pow A\"\n by sorry\n\ntext \\\\<^medskip> Range of a function -- just an abbreviation for image!\\\n\nabbreviation range :: \"('a \\ 'b) \\ 'b set\" \\ \\of function\\\n where \"range f \\ f ` UNIV\"\n\nlemma range_eqI: \"b = f x \\ b \\ range f\"\n by sorry\n\nlemma rangeI: \"f x \\ range f\"\n by sorry\n\nlemma rangeE [elim?]: \"b \\ range (\\x. f x) \\ (\\x. b = f x \\ P) \\ P\"\n by sorry\n\nlemma range_subsetD: \"range f \\ B \\ f i \\ B\"\n by sorry\n\nlemma full_SetCompr_eq: \"{u. \\x. u = f x} = range f\"\n by sorry\n\nlemma range_composition: \"range (\\x. f (g x)) = f ` range g\"\n by sorry\n\nlemma range_constant [simp]: \"range (\\_. x) = {x}\"\n by sorry\n\nlemma range_eq_singletonD: \"range f = {a} \\ f x = a\"\n by sorry\n\nsubsubsection \\Some rules with \\if\\\\\n\ntext \\Elimination of \\{x. \\ \\ x = t \\ \\}\\.\\\n\nlemma Collect_conv_if: \"{x. x = a \\ P x} = (if P a then {a} else {})\"\n by sorry\n\nlemma Collect_conv_if2: \"{x. a = x \\ P x} = (if P a then {a} else {})\"\n by sorry\n\ntext \\\n Rewrite rules for boolean case-splitting: faster than \\if_split [split]\\.\n\\\n\nlemma if_split_eq1: \"(if Q then x else y) = b \\ (Q \\ x = b) \\ (\\ Q \\ y = b)\"\n by sorry\n\nlemma if_split_eq2: \"a = (if Q then x else y) \\ (Q \\ a = x) \\ (\\ Q \\ a = y)\"\n by sorry\n\ntext \\\n Split ifs on either side of the membership relation.\n Not for \\[simp]\\ -- can cause goals to blow up!\n\\\n\nlemma if_split_mem1: \"(if Q then x else y) \\ b \\ (Q \\ x \\ b) \\ (\\ Q \\ y \\ b)\"\n by sorry\n\nlemma if_split_mem2: \"(a \\ (if Q then x else y)) \\ (Q \\ a \\ x) \\ (\\ Q \\ a \\ y)\"\n by sorry\n\nlemmas split_ifs = if_bool_eq_conj if_split_eq1 if_split_eq2 if_split_mem1 if_split_mem2\n\nsubsection \\Further operations and lemmas\\\n\nsubsubsection \\The ``proper subset'' relation\\\n\nlemma psubsetI [intro!]: \"A \\ B \\ A \\ B \\ A \\ B\"\n by sorry\n\nlemma psubsetE [elim!]: \"A \\ B \\ (A \\ B \\ \\ B \\ A \\ R) \\ R\"\n by sorry\n\nlemma psubset_insert_iff:\n \"A \\ insert x B \\ (if x \\ B then A \\ B else if x \\ A then A - {x} \\ B else A \\ B)\"\n by sorry\n\nlemma psubset_eq: \"A \\ B \\ A \\ B \\ A \\ B\"\n by sorry\n\nlemma psubset_imp_subset: \"A \\ B \\ A \\ B\"\n by sorry\n\nlemma psubset_trans: \"A \\ B \\ B \\ C \\ A \\ C\"\n by sorry\n\nlemma psubsetD: \"A \\ B \\ c \\ A \\ c \\ B\"\n by sorry\n\nlemma psubset_subset_trans: \"A \\ B \\ B \\ C \\ A \\ C\"\n by sorry\n\nlemma subset_psubset_trans: \"A \\ B \\ B \\ C \\ A \\ C\"\n by sorry\n\nlemma psubset_imp_ex_mem: \"A \\ B \\ \\b. b \\ B - A\"\n by sorry\n\nlemma atomize_ball: \"(\\x. x \\ A \\ P x) \\ Trueprop (\\x\\A. P x)\"\n by sorry\n\nlemmas [symmetric, rulify] = atomize_ball\n and [symmetric, defn] = atomize_ball\n\nlemma image_Pow_mono: \"f ` A \\ B \\ image f ` Pow A \\ Pow B\"\n by sorry\n\nlemma image_Pow_surj: \"f ` A = B \\ image f ` Pow A = Pow B\"\n by sorry\n\nsubsubsection \\Derived rules involving subsets.\\\n\ntext \\\\insert\\.\\\n\nlemma subset_insertI: \"B \\ insert a B\"\n by sorry\n\nlemma subset_insertI2: \"A \\ B \\ A \\ insert b B\"\n by sorry\n\nlemma subset_insert: \"x \\ A \\ A \\ insert x B \\ A \\ B\"\n by sorry\n\ntext \\\\<^medskip> Finite Union -- the least upper bound of two sets.\\\n\nlemma Un_upper1: \"A \\ A \\ B\"\n by sorry\n\nlemma Un_upper2: \"B \\ A \\ B\"\n by sorry\n\nlemma Un_least: \"A \\ C \\ B \\ C \\ A \\ B \\ C\"\n by sorry\n\ntext \\\\<^medskip> Finite Intersection -- the greatest lower bound of two sets.\\\n\nlemma Int_lower1: \"A \\ B \\ A\"\n by sorry\n\nlemma Int_lower2: \"A \\ B \\ B\"\n by sorry\n\nlemma Int_greatest: \"C \\ A \\ C \\ B \\ C \\ A \\ B\"\n by sorry\n\ntext \\\\<^medskip> Set difference.\\\n\nlemma Diff_subset[simp]: \"A - B \\ A\"\n by sorry\n\nlemma Diff_subset_conv: \"A - B \\ C \\ A \\ B \\ C\"\n by sorry\n\nsubsubsection \\Equalities involving union, intersection, inclusion, etc.\\\n\ntext \\\\{}\\.\\\n\nlemma Collect_const [simp]: \"{s. P} = (if P then UNIV else {})\"\n \\ \\supersedes \\Collect_False_empty\\\\\n by sorry\n\nlemma subset_empty [simp]: \"A \\ {} \\ A = {}\"\n by sorry\n\nlemma not_psubset_empty [iff]: \"\\ (A < {})\"\n by sorry\n\nlemma Collect_subset [simp]: \"{x\\A. P x} \\ A\" by auto\n\nlemma Collect_empty_eq [simp]: \"Collect P = {} \\ (\\x. \\ P x)\"\n by sorry\n\nlemma empty_Collect_eq [simp]: \"{} = Collect P \\ (\\x. \\ P x)\"\n by sorry\n\nlemma Collect_neg_eq: \"{x. \\ P x} = - {x. P x}\"\n by sorry\n\nlemma Collect_disj_eq: \"{x. P x \\ Q x} = {x. P x} \\ {x. Q x}\"\n by sorry\n\nlemma Collect_imp_eq: \"{x. P x \\ Q x} = - {x. P x} \\ {x. Q x}\"\n by sorry\n\nlemma Collect_conj_eq: \"{x. P x \\ Q x} = {x. P x} \\ {x. Q x}\"\n by sorry\n\nlemma Collect_conj_eq2: \"{x \\ A. P x \\ Q x} = {x \\ A. P x} \\ {x \\ A. Q x}\"\n by sorry\n\nlemma Collect_mono_iff: \"Collect P \\ Collect Q \\ (\\x. P x \\ Q x)\"\n by sorry\n\ntext \\\\<^medskip> \\insert\\.\\\n\nlemma insert_is_Un: \"insert a A = {a} \\ A\"\n \\ \\NOT SUITABLE FOR REWRITING since \\{a} \\ insert a {}\\\\\n by sorry\n\nlemma insert_not_empty [simp]: \"insert a A \\ {}\"\n and empty_not_insert [simp]: \"{} \\ insert a A\"\n by sorry\n\nlemma insert_absorb: \"a \\ A \\ insert a A = A\"\n \\ \\\\[simp]\\ causes recursive calls when there are nested inserts\\\n \\ \\with \\<^emph>\\quadratic\\ running time\\\n by sorry\n\nlemma insert_absorb2 [simp]: \"insert x (insert x A) = insert x A\"\n by sorry\n\nlemma insert_commute: \"insert x (insert y A) = insert y (insert x A)\"\n by sorry\n\nlemma insert_subset [simp]: \"insert x A \\ B \\ x \\ B \\ A \\ B\"\n by sorry\n\nlemma mk_disjoint_insert: \"a \\ A \\ \\B. A = insert a B \\ a \\ B\"\n \\ \\use new \\B\\ rather than \\A - {a}\\ to avoid infinite unfolding\\\n by sorry\n\nlemma insert_Collect: \"insert a (Collect P) = {u. u \\ a \\ P u}\"\n by sorry\n\nlemma insert_inter_insert [simp]: \"insert a A \\ insert a B = insert a (A \\ B)\"\n by sorry\n\nlemma insert_disjoint [simp]:\n \"insert a A \\ B = {} \\ a \\ B \\ A \\ B = {}\"\n \"{} = insert a A \\ B \\ a \\ B \\ {} = A \\ B\"\n by sorry\n\nlemma disjoint_insert [simp]:\n \"B \\ insert a A = {} \\ a \\ B \\ B \\ A = {}\"\n \"{} = A \\ insert b B \\ b \\ A \\ {} = A \\ B\"\n by sorry\n\ntext \\\\<^medskip> \\Int\\\\\n\nlemma Int_absorb: \"A \\ A = A\"\n by sorry\n\nlemma Int_left_absorb: \"A \\ (A \\ B) = A \\ B\"\n by sorry\n\nlemma Int_commute: \"A \\ B = B \\ A\"\n by sorry\n\nlemma Int_left_commute: \"A \\ (B \\ C) = B \\ (A \\ C)\"\n by sorry\n\nlemma Int_assoc: \"(A \\ B) \\ C = A \\ (B \\ C)\"\n by sorry\n\nlemmas Int_ac = Int_assoc Int_left_absorb Int_commute Int_left_commute\n \\ \\Intersection is an AC-operator\\\n\nlemma Int_absorb1: \"B \\ A \\ A \\ B = B\"\n by sorry\n\nlemma Int_absorb2: \"A \\ B \\ A \\ B = A\"\n by sorry\n\nlemma Int_empty_left: \"{} \\ B = {}\"\n by sorry\n\nlemma Int_empty_right: \"A \\ {} = {}\"\n by sorry\n\nlemma disjoint_eq_subset_Compl: \"A \\ B = {} \\ A \\ - B\"\n by sorry\n\nlemma disjoint_iff: \"A \\ B = {} \\ (\\x. x\\A \\ x \\ B)\"\n by sorry\n\nlemma disjoint_iff_not_equal: \"A \\ B = {} \\ (\\x\\A. \\y\\B. x \\ y)\"\n by sorry\n\nlemma Int_UNIV_left: \"UNIV \\ B = B\"\n by sorry\n\nlemma Int_UNIV_right: \"A \\ UNIV = A\"\n by sorry\n\nlemma Int_Un_distrib: \"A \\ (B \\ C) = (A \\ B) \\ (A \\ C)\"\n by sorry\n\nlemma Int_Un_distrib2: \"(B \\ C) \\ A = (B \\ A) \\ (C \\ A)\"\n by sorry\n\nlemma Int_UNIV: \"A \\ B = UNIV \\ A = UNIV \\ B = UNIV\"\n by sorry\n\nlemma Int_subset_iff: \"C \\ A \\ B \\ C \\ A \\ C \\ B\"\n by sorry\n\nlemma Int_Collect: \"x \\ A \\ {x. P x} \\ x \\ A \\ P x\"\n by sorry\n\ntext \\\\<^medskip> \\Un\\.\\\n\nlemma Un_absorb: \"A \\ A = A\"\n by sorry\n\nlemma Un_left_absorb: \"A \\ (A \\ B) = A \\ B\"\n by sorry\n\nlemma Un_commute: \"A \\ B = B \\ A\"\n by sorry\n\nlemma Un_left_commute: \"A \\ (B \\ C) = B \\ (A \\ C)\"\n by sorry\n\nlemma Un_assoc: \"(A \\ B) \\ C = A \\ (B \\ C)\"\n by sorry\n\nlemmas Un_ac = Un_assoc Un_left_absorb Un_commute Un_left_commute\n \\ \\Union is an AC-operator\\\n\nlemma Un_absorb1: \"A \\ B \\ A \\ B = B\"\n by sorry\n\nlemma Un_absorb2: \"B \\ A \\ A \\ B = A\"\n by sorry\n\nlemma Un_empty_left: \"{} \\ B = B\"\n by sorry\n\nlemma Un_empty_right: \"A \\ {} = A\"\n by sorry\n\nlemma Un_UNIV_left: \"UNIV \\ B = UNIV\"\n by sorry\n\nlemma Un_UNIV_right: \"A \\ UNIV = UNIV\"\n by sorry\n\nlemma Un_insert_left [simp]: \"(insert a B) \\ C = insert a (B \\ C)\"\n by sorry\n\nlemma Un_insert_right [simp]: \"A \\ (insert a B) = insert a (A \\ B)\"\n by sorry\n\nlemma Int_insert_left: \"(insert a B) \\ C = (if a \\ C then insert a (B \\ C) else B \\ C)\"\n by sorry\n\nlemma Int_insert_left_if0 [simp]: \"a \\ C \\ (insert a B) \\ C = B \\ C\"\n by sorry\n\nlemma Int_insert_left_if1 [simp]: \"a \\ C \\ (insert a B) \\ C = insert a (B \\ C)\"\n by sorry\n\nlemma Int_insert_right: \"A \\ (insert a B) = (if a \\ A then insert a (A \\ B) else A \\ B)\"\n by sorry\n\nlemma Int_insert_right_if0 [simp]: \"a \\ A \\ A \\ (insert a B) = A \\ B\"\n by sorry\n\nlemma Int_insert_right_if1 [simp]: \"a \\ A \\ A \\ (insert a B) = insert a (A \\ B)\"\n by sorry\n\nlemma Un_Int_distrib: \"A \\ (B \\ C) = (A \\ B) \\ (A \\ C)\"\n by sorry\n\nlemma Un_Int_distrib2: \"(B \\ C) \\ A = (B \\ A) \\ (C \\ A)\"\n by sorry\n\nlemma Un_Int_crazy: \"(A \\ B) \\ (B \\ C) \\ (C \\ A) = (A \\ B) \\ (B \\ C) \\ (C \\ A)\"\n by sorry\n\nlemma subset_Un_eq: \"A \\ B \\ A \\ B = B\"\n by sorry\n\nlemma Un_empty [iff]: \"A \\ B = {} \\ A = {} \\ B = {}\"\n by sorry\n\nlemma Un_subset_iff: \"A \\ B \\ C \\ A \\ C \\ B \\ C\"\n by sorry\n\nlemma Un_Diff_Int: \"(A - B) \\ (A \\ B) = A\"\n by sorry\n\nlemma Diff_Int2: \"A \\ C - B \\ C = A \\ C - B\"\n by sorry\n\nlemma subset_UnE:\n assumes \"C \\ A \\ B\"\n obtains A' B' where \"A' \\ A\" \"B' \\ B\" \"C = A' \\ B'\"\n by sorry\n\nlemma Un_Int_eq [simp]: \"(S \\ T) \\ S = S\" \"(S \\ T) \\ T = T\" \"S \\ (S \\ T) = S\" \"T \\ (S \\ T) = T\"\n by sorry\n\nlemma Int_Un_eq [simp]: \"(S \\ T) \\ S = S\" \"(S \\ T) \\ T = T\" \"S \\ (S \\ T) = S\" \"T \\ (S \\ T) = T\"\n by sorry\n\ntext \\\\<^medskip> Set complement\\\n\nlemma Compl_disjoint [simp]: \"A \\ - A = {}\"\n by sorry\n\nlemma Compl_disjoint2 [simp]: \"- A \\ A = {}\"\n by sorry\n\nlemma Compl_partition: \"A \\ - A = UNIV\"\n by sorry\n\nlemma Compl_partition2: \"- A \\ A = UNIV\"\n by sorry\n\nlemma double_complement: \"- (-A) = A\" for A :: \"'a set\"\n by sorry\n\nlemma Compl_Un: \"- (A \\ B) = (- A) \\ (- B)\"\n by sorry\n\nlemma Compl_Int: \"- (A \\ B) = (- A) \\ (- B)\"\n by sorry\n\nlemma subset_Compl_self_eq: \"A \\ - A \\ A = {}\"\n by sorry\n\nlemma Un_Int_assoc_eq: \"(A \\ B) \\ C = A \\ (B \\ C) \\ C \\ A\"\n \\ \\Halmos, Naive Set Theory, page 16.\\\n by sorry\n\nlemma Compl_UNIV_eq: \"- UNIV = {}\"\n by sorry\n\nlemma Compl_empty_eq: \"- {} = UNIV\"\n by sorry\n\nlemma Compl_subset_Compl_iff [iff]: \"- A \\ - B \\ B \\ A\"\n by sorry\n\nlemma Compl_eq_Compl_iff [iff]: \"- A = - B \\ A = B\"\n for A B :: \"'a set\"\n by sorry\n\nlemma Compl_insert: \"- insert x A = (- A) - {x}\"\n by sorry\n\ntext \\\\<^medskip> Bounded quantifiers.\n\n The following are not added to the default simpset because\n (a) they duplicate the body and (b) there are no similar rules for \\Int\\.\n\\\n\nlemma ball_Un: \"(\\x \\ A \\ B. P x) \\ (\\x\\A. P x) \\ (\\x\\B. P x)\"\n by sorry\n\nlemma bex_Un: \"(\\x \\ A \\ B. P x) \\ (\\x\\A. P x) \\ (\\x\\B. P x)\"\n by sorry\n\ntext \\\\<^medskip> Set difference.\\\n\nlemma Diff_eq: \"A - B = A \\ (- B)\"\n by sorry\n\nlemma Diff_eq_empty_iff: \"A - B = {} \\ A \\ B\"\n by sorry\n\nlemma Diff_cancel [simp]: \"A - A = {}\"\n by sorry\n\nlemma Diff_idemp [simp]: \"(A - B) - B = A - B\"\n for A B :: \"'a set\"\n by sorry\n\nlemma Diff_triv: \"A \\ B = {} \\ A - B = A\"\n by sorry\n\nlemma empty_Diff [simp]: \"{} - A = {}\"\n by sorry\n\nlemma Diff_empty [simp]: \"A - {} = A\"\n by sorry\n\nlemma Diff_UNIV [simp]: \"A - UNIV = {}\"\n by sorry\n\nlemma Diff_insert0 [simp]: \"x \\ A \\ A - insert x B = A - B\"\n by sorry\n\nlemma Diff_insert: \"A - insert a B = A - B - {a}\"\n \\ \\NOT SUITABLE FOR REWRITING since \\{a} \\ insert a 0\\\\\n by sorry\n\nlemma Diff_insert2: \"A - insert a B = A - {a} - B\"\n \\ \\NOT SUITABLE FOR REWRITING since \\{a} \\ insert a 0\\\\\n by sorry\n\nlemma insert_Diff_if: \"insert x A - B = (if x \\ B then A - B else insert x (A - B))\"\n by sorry\n\nlemma insert_Diff1 [simp]: \"x \\ B \\ insert x A - B = A - B\"\n by sorry\n\nlemma insert_Diff_single[simp]: \"insert a (A - {a}) = insert a A\"\n by sorry\n\nlemma insert_Diff: \"a \\ A \\ insert a (A - {a}) = A\"\n by sorry\n\nlemma Diff_insert_absorb: \"x \\ A \\ (insert x A) - {x} = A\"\n by sorry\n\nlemma Diff_disjoint [simp]: \"A \\ (B - A) = {}\"\n by sorry\n\nlemma Diff_partition: \"A \\ B \\ A \\ (B - A) = B\"\n by sorry\n\nlemma double_diff: \"A \\ B \\ B \\ C \\ B - (C - A) = A\"\n by sorry\n\nlemma Un_Diff_cancel [simp]: \"A \\ (B - A) = A \\ B\"\n by sorry\n\nlemma Un_Diff_cancel2 [simp]: \"(B - A) \\ A = B \\ A\"\n by sorry\n\nlemma Diff_Un: \"A - (B \\ C) = (A - B) \\ (A - C)\"\n by sorry\n\nlemma Diff_Int: \"A - (B \\ C) = (A - B) \\ (A - C)\"\n by sorry\n\nlemma Diff_Diff_Int: \"A - (A - B) = A \\ B\"\n by sorry\n\nlemma Un_Diff: \"(A \\ B) - C = (A - C) \\ (B - C)\"\n by sorry\n\nlemma Int_Diff: \"(A \\ B) - C = A \\ (B - C)\"\n by sorry\n\nlemma Diff_Int_distrib: \"C \\ (A - B) = (C \\ A) - (C \\ B)\"\n by sorry\n\nlemma Diff_Int_distrib2: \"(A - B) \\ C = (A \\ C) - (B \\ C)\"\n by sorry\n\nlemma Diff_Compl [simp]: \"A - (- B) = A \\ B\"\n by sorry\n\nlemma Compl_Diff_eq [simp]: \"- (A - B) = - A \\ B\"\n by sorry\n\nlemma subset_Compl_singleton [simp]: \"A \\ - {b} \\ b \\ A\"\n by sorry\n\ntext \\\\<^medskip> Quantification over type \\<^typ>\\bool\\.\\\n\nlemma bool_induct: \"P True \\ P False \\ P x\"\n by sorry\n\nlemma all_bool_eq: \"(\\b. P b) \\ P True \\ P False\"\n by sorry\n\nlemma bool_contrapos: \"P x \\ \\ P False \\ P True\"\n by sorry\n\nlemma ex_bool_eq: \"(\\b. P b) \\ P True \\ P False\"\n by sorry\n\nlemma UNIV_bool: \"UNIV = {False, True}\"\n by sorry\n\ntext \\\\<^medskip> \\Pow\\\\\n\nlemma Pow_empty [simp]: \"Pow {} = {{}}\"\n by sorry\n\nlemma Pow_singleton_iff [simp]: \"Pow X = {Y} \\ X = {} \\ Y = {}\"\n by sorry\n\nlemma Pow_insert: \"Pow (insert a A) = Pow A \\ (insert a ` Pow A)\"\n by sorry\n\nlemma Pow_Compl: \"Pow (- A) = {- B | B. A \\ Pow B}\"\n by sorry\n\nlemma Pow_UNIV [simp]: \"Pow UNIV = UNIV\"\n by sorry\n\nlemma Un_Pow_subset: \"Pow A \\ Pow B \\ Pow (A \\ B)\"\n by sorry\n\nlemma Pow_Int_eq [simp]: \"Pow (A \\ B) = Pow A \\ Pow B\"\n by sorry\n\ntext \\\\<^medskip> Miscellany.\\\n\nlemma Int_Diff_disjoint: \"A \\ B \\ (A - B) = {}\"\n by sorry\n\nlemma Int_Diff_Un: \"A \\ B \\ (A - B) = A\"\n by sorry\n\nlemma set_eq_subset: \"A = B \\ A \\ B \\ B \\ A\"\n by sorry\n\nlemma subset_iff: \"A \\ B \\ (\\t. t \\ A \\ t \\ B)\"\n by sorry\n\nlemma subset_iff_psubset_eq: \"A \\ B \\ A \\ B \\ A = B\"\n by sorry\n\nlemma all_not_in_conv [simp]: \"(\\x. x \\ A) \\ A = {}\"\n by sorry\n\nlemma ex_in_conv: \"(\\x. x \\ A) \\ A \\ {}\"\n by sorry\n\nlemma ball_simps [simp, no_atp]:\n \"\\A P Q. (\\x\\A. P x \\ Q) \\ ((\\x\\A. P x) \\ Q)\"\n \"\\A P Q. (\\x\\A. P \\ Q x) \\ (P \\ (\\x\\A. Q x))\"\n \"\\A P Q. (\\x\\A. P \\ Q x) \\ (P \\ (\\x\\A. Q x))\"\n \"\\A P Q. (\\x\\A. P x \\ Q) \\ ((\\x\\A. P x) \\ Q)\"\n \"\\P. (\\x\\{}. P x) \\ True\"\n \"\\P. (\\x\\UNIV. P x) \\ (\\x. P x)\"\n \"\\a B P. (\\x\\insert a B. P x) \\ (P a \\ (\\x\\B. P x))\"\n \"\\P Q. (\\x\\Collect Q. P x) \\ (\\x. Q x \\ P x)\"\n \"\\A P f. (\\x\\f`A. P x) \\ (\\x\\A. P (f x))\"\n \"\\A P. (\\ (\\x\\A. P x)) \\ (\\x\\A. \\ P x)\"\n by sorry\n\nlemma bex_simps [simp, no_atp]:\n \"\\A P Q. (\\x\\A. P x \\ Q) \\ ((\\x\\A. P x) \\ Q)\"\n \"\\A P Q. (\\x\\A. P \\ Q x) \\ (P \\ (\\x\\A. Q x))\"\n \"\\P. (\\x\\{}. P x) \\ False\"\n \"\\P. (\\x\\UNIV. P x) \\ (\\x. P x)\"\n \"\\a B P. (\\x\\insert a B. P x) \\ (P a \\ (\\x\\B. P x))\"\n \"\\P Q. (\\x\\Collect Q. P x) \\ (\\x. Q x \\ P x)\"\n \"\\A P f. (\\x\\f`A. P x) \\ (\\x\\A. P (f x))\"\n \"\\A P. (\\(\\x\\A. P x)) \\ (\\x\\A. \\ P x)\"\n by sorry\n\nlemma ex_image_cong_iff [simp, no_atp]:\n \"(\\x. x\\f`A) \\ A \\ {}\" \"(\\x. x\\f`A \\ P x) \\ (\\x\\A. P (f x))\"\n by sorry\n\nsubsubsection \\Monotonicity of various operations\\\n\nlemma image_mono: \"A \\ B \\ f ` A \\ f ` B\"\n by sorry\n\nlemma Pow_mono: \"A \\ B \\ Pow A \\ Pow B\"\n by sorry\n\nlemma insert_mono: \"C \\ D \\ insert a C \\ insert a D\"\n by sorry\n\nlemma Un_mono: \"A \\ C \\ B \\ D \\ A \\ B \\ C \\ D\"\n by sorry\n\nlemma Int_mono: \"A \\ C \\ B \\ D \\ A \\ B \\ C \\ D\"\n by sorry\n\nlemma Diff_mono: \"A \\ C \\ D \\ B \\ A - B \\ C - D\"\n by sorry\n\nlemma Compl_anti_mono: \"A \\ B \\ - B \\ - A\"\n by sorry\n\ntext \\\\<^medskip> Monotonicity of implications.\\\n\nlemma in_mono: \"A \\ B \\ x \\ A \\ x \\ B\"\n by sorry\n\nlemma conj_mono: \"P1 \\ Q1 \\ P2 \\ Q2 \\ (P1 \\ P2) \\ (Q1 \\ Q2)\"\n by sorry\n\nlemma disj_mono: \"P1 \\ Q1 \\ P2 \\ Q2 \\ (P1 \\ P2) \\ (Q1 \\ Q2)\"\n by sorry\n\nlemma imp_mono: \"Q1 \\ P1 \\ P2 \\ Q2 \\ (P1 \\ P2) \\ (Q1 \\ Q2)\"\n by sorry\n\nlemma imp_refl: \"P \\ P\" ..\n\nlemma not_mono: \"Q \\ P \\ \\ P \\ \\ Q\"\n by sorry\n\nlemma ex_mono: \"(\\x. P x \\ Q x) \\ (\\x. P x) \\ (\\x. Q x)\"\n by sorry\n\nlemma all_mono: \"(\\x. P x \\ Q x) \\ (\\x. P x) \\ (\\x. Q x)\"\n by sorry\n\nlemma Collect_mono: \"(\\x. P x \\ Q x) \\ Collect P \\ Collect Q\"\n by sorry\n\nlemma Int_Collect_mono: \"A \\ B \\ (\\x. x \\ A \\ P x \\ Q x) \\ A \\ Collect P \\ B \\ Collect Q\"\n by sorry\n\nlemmas basic_monos =\n subset_refl imp_refl disj_mono conj_mono ex_mono Collect_mono in_mono\n\nlemma eq_to_mono: \"a = b \\ c = d \\ b \\ d \\ a \\ c\"\n by sorry\n\nsubsubsection \\Inverse image of a function\\\n\ndefinition vimage :: \"('a \\ 'b) \\ 'b set \\ 'a set\" (infixr \\-`\\ 90)\n where \"f -` B \\ {x. f x \\ B}\"\n\nlemma vimage_eq [simp]: \"a \\ f -` B \\ f a \\ B\"\n by sorry\n\nlemma vimage_singleton_eq: \"a \\ f -` {b} \\ f a = b\"\n by sorry\n\nlemma vimageI [intro]: \"f a = b \\ b \\ B \\ a \\ f -` B\"\n by sorry\n\nlemma vimageI2: \"f a \\ A \\ a \\ f -` A\"\n by sorry\n\nlemma vimageE [elim!]: \"a \\ f -` B \\ (\\x. f a = x \\ x \\ B \\ P) \\ P\"\n by sorry\n\nlemma vimageD: \"a \\ f -` A \\ f a \\ A\"\n by sorry\n\nlemma vimage_empty [simp]: \"f -` {} = {}\"\n by sorry\n\nlemma vimage_Compl: \"f -` (- A) = - (f -` A)\"\n by sorry\n\nlemma vimage_Un [simp]: \"f -` (A \\ B) = (f -` A) \\ (f -` B)\"\n by sorry\n\nlemma vimage_Int [simp]: \"f -` (A \\ B) = (f -` A) \\ (f -` B)\"\n by sorry\n\nlemma vimage_Collect_eq [simp]: \"f -` Collect P = {y. P (f y)}\"\n by sorry\n\nlemma vimage_Collect: \"(\\x. P (f x) = Q x) \\ f -` (Collect P) = Collect Q\"\n by sorry\n\nlemma vimage_insert: \"f -` (insert a B) = (f -` {a}) \\ (f -` B)\"\n \\ \\NOT suitable for rewriting because of the recurrence of \\{a}\\.\\\n by sorry\n\nlemma vimage_Diff: \"f -` (A - B) = (f -` A) - (f -` B)\"\n by sorry\n\nlemma vimage_UNIV [simp]: \"f -` UNIV = UNIV\"\n by sorry\n\nlemma vimage_mono: \"A \\ B \\ f -` A \\ f -` B\"\n \\ \\monotonicity\\\n by sorry\n\nlemma vimage_image_eq: \"f -` (f ` A) = {y. \\x\\A. f x = f y}\"\n by sorry\n\nlemma image_vimage_subset: \"f ` (f -` A) \\ A\"\n by sorry\n\nlemma image_vimage_eq [simp]: \"f ` (f -` A) = A \\ range f\"\n by sorry\n\nlemma image_subset_iff_subset_vimage: \"f ` A \\ B \\ A \\ f -` B\"\n by sorry\n\nlemma subset_vimage_iff: \"A \\ f -` B \\ (\\x\\A. f x \\ B)\"\n by sorry\n\nlemma vimage_const [simp]: \"((\\x. c) -` A) = (if c \\ A then UNIV else {})\"\n by sorry\n\nlemma vimage_if [simp]: \"((\\x. if x \\ B then c else d) -` A) =\n (if c \\ A then (if d \\ A then UNIV else B)\n else if d \\ A then - B else {})\"\n by sorry\n\nlemma vimage_inter_cong: \"(\\ w. w \\ S \\ f w = g w) \\ f -` y \\ S = g -` y \\ S\"\n by sorry\n\nlemma vimage_ident [simp]: \"(\\x. x) -` Y = Y\"\n by sorry\n\nsubsubsection \\Singleton sets\\\n\ndefinition is_singleton :: \"'a set \\ bool\"\n where \"is_singleton A \\ (\\x. A = {x})\"\n\nlemma is_singletonI [simp, intro!]: \"is_singleton {x}\"\n by sorry\n\nlemma is_singletonI': \"A \\ {} \\ (\\x y. x \\ A \\ y \\ A \\ x = y) \\ is_singleton A\"\n by sorry\n\nlemma is_singletonE: \"is_singleton A \\ (\\x. A = {x} \\ P) \\ P\"\n by sorry\n\nlemma is_singleton_iff_ex1:\n \\is_singleton A \\ (\\!x. x \\ A)\\\n by sorry\n\nsubsubsection \\Getting the contents of a singleton set\\\n\ndefinition the_elem :: \"'a set \\ 'a\"\n where \"the_elem X = (THE x. X = {x})\"\n\nlemma the_elem_eq [simp]: \"the_elem {x} = x\"\n by sorry\n\nlemma is_singleton_the_elem: \"is_singleton A \\ A = {the_elem A}\"\n by sorry\n\nlemma the_elem_image_unique:\n assumes \"A \\ {}\"\n and *: \"\\y. y \\ A \\ f y = a\"\n shows \"the_elem (f ` A) = a\"\n by sorry\n\nsubsubsection \\Monad operation\\\n\ndefinition bind :: \"'a set \\ ('a \\ 'b set) \\ 'b set\"\n where \"bind A f = {x. \\B \\ f`A. x \\ B}\"\n\nhide_const (open) bind\n\nlemma bind_bind: \"Set.bind (Set.bind A B) C = Set.bind A (\\x. Set.bind (B x) C)\"\n for A :: \"'a set\"\n by sorry\n\nlemma empty_bind [simp]: \"Set.bind {} f = {}\"\n by sorry\n\nlemma nonempty_bind_const: \"A \\ {} \\ Set.bind A (\\_. B) = B\"\n by sorry\n\nlemma bind_const: \"Set.bind A (\\_. B) = (if A = {} then {} else B)\"\n by sorry\n\nlemma bind_singleton_conv_image: \"Set.bind A (\\x. {f x}) = f ` A\"\n by sorry\n\nsubsubsection \\Operations for execution\\\n\ntext \\\n Use those operations only for generating executable / efficient code.\n Otherwise use the RHSs directly.\n\\\n\ncontext\nbegin\n\nqualified definition is_empty :: \"'a set \\ bool\" \\ \\only for code generation\\\n where is_empty_iff [code_abbrev, simp]: \"is_empty A \\ A = {}\"\n\nqualified definition remove :: \"'a \\ 'a set \\ 'a set\" \\ \\only for code generation\\\n where remove_eq [code_abbrev, simp]: \"remove x A = A - {x}\"\n\nqualified definition filter :: \"('a \\ bool) \\ 'a set \\ 'a set\" \\ \\only for code generation\\\n where filter_eq [code_abbrev, simp]: \"filter P A = {a \\ A. P a}\"\n\nqualified definition can_select :: \"('a \\ bool) \\ 'a set \\ bool\" \\ \\only for code generation\\\n where can_select_iff [code_abbrev, simp]: \"can_select P A = (\\!x\\A. P x)\"\n\nqualified lemma can_select_iff_is_singleton:\n \\Set.can_select P A \\ is_singleton (Set.filter P A)\\\n by (simp add: is_singleton_iff_ex1)\n\nend\n\ninstantiation set :: (equal) equal\nbegin\n\ndefinition \"HOL.equal A B \\ A \\ B \\ B \\ A\"\n\ninstance\n by standard (auto simp add: equal_set_def)\n\nend\n\ntext \\Misc\\\n\ndefinition pairwise :: \"('a \\ 'a \\ bool) \\ 'a set \\ bool\"\n where \"pairwise R S \\ (\\x \\ S. \\y \\ S. x \\ y \\ R x y)\"\n\nlemma pairwise_alt: \"pairwise R S \\ (\\x\\S. \\y\\S-{x}. R x y)\"\n by sorry\n\nlemma pairwise_trivial [simp]: \"pairwise (\\i j. j \\ i) I\"\n by sorry\n\nlemma pairwiseI [intro?]:\n \"pairwise R S\" if \"\\x y. x \\ S \\ y \\ S \\ x \\ y \\ R x y\"\n by sorry\n\nlemma pairwiseD:\n \"R x y\" and \"R y x\"\n if \"pairwise R S\" \"x \\ S\" and \"y \\ S\" and \"x \\ y\"\n by sorry\n\nlemma pairwise_empty [simp]: \"pairwise P {}\"\n by sorry\n\nlemma pairwise_singleton [simp]: \"pairwise P {A}\"\n by sorry\n\nlemma pairwise_insert:\n \"pairwise r (insert x s) \\ (\\y. y \\ s \\ y \\ x \\ r x y \\ r y x) \\ pairwise r s\"\n by sorry\n\nlemma pairwise_subset: \"pairwise P S \\ T \\ S \\ pairwise P T\"\n by sorry\n\nlemma pairwise_mono: \"\\pairwise P A; \\x y. P x y \\ Q x y; B \\ A\\ \\ pairwise Q B\"\n by sorry\n\nlemma pairwise_imageI:\n \"pairwise P (f ` A)\"\n if \"\\x y. x \\ A \\ y \\ A \\ x \\ y \\ f x \\ f y \\ P (f x) (f y)\"\n by sorry\n\nlemma pairwise_image: \"pairwise r (f ` s) \\ pairwise (\\x y. (f x \\ f y) \\ r (f x) (f y)) s\"\n by sorry\n\ndefinition disjnt :: \"'a set \\ 'a set \\ bool\"\n where \"disjnt A B \\ A \\ B = {}\"\n\nlemma disjnt_self_iff_empty [simp]: \"disjnt S S \\ S = {}\"\n by sorry\n\nlemma disjnt_commute: \"disjnt A B = disjnt B A\"\n by sorry\n\nlemma disjnt_iff: \"disjnt A B \\ (\\x. \\ (x \\ A \\ x \\ B))\"\n by sorry\n\nlemma disjnt_sym: \"disjnt A B \\ disjnt B A\"\n by sorry\n\nlemma disjnt_empty1 [simp]: \"disjnt {} A\" and disjnt_empty2 [simp]: \"disjnt A {}\"\n by sorry\n\nlemma disjnt_insert1 [simp]: \"disjnt (insert a X) Y \\ a \\ Y \\ disjnt X Y\"\n by sorry\n\nlemma disjnt_insert2 [simp]: \"disjnt Y (insert a X) \\ a \\ Y \\ disjnt Y X\"\n by sorry\n\nlemma disjnt_subset1 : \"\\disjnt X Y; Z \\ X\\ \\ disjnt Z Y\"\n by sorry\n\nlemma disjnt_subset2 : \"\\disjnt X Y; Z \\ Y\\ \\ disjnt X Z\"\n by sorry\n\nlemma disjnt_Un1 [simp]: \"disjnt (A \\ B) C \\ disjnt A C \\ disjnt B C\"\n by sorry\n\nlemma disjnt_Un2 [simp]: \"disjnt C (A \\ B) \\ disjnt C A \\ disjnt C B\"\n by sorry\n\nlemma disjnt_Diff1: \"disjnt (X-Y) (U-V)\" and disjnt_Diff2: \"disjnt (U-V) (X-Y)\" if \"X \\ V\"\n by sorry\n\nlemma disjoint_image_subset: \"\\pairwise disjnt \\; \\X. X \\ \\ \\ f X \\ X\\ \\ pairwise disjnt (f `\\)\"\n by sorry\n\nlemma pairwise_disjnt_iff: \"pairwise disjnt \\ \\ (\\x. \\\\<^sub>\\\\<^sub>1 X. X \\ \\ \\ x \\ X)\"\n by sorry\n\nlemma disjnt_insert: \\<^marker>\\contributor \\Lars Hupel\\\\\n \\disjnt (insert x M) N\\ if \\x \\ N\\ \\disjnt M N\\\n by sorry\n\nlemma Int_emptyI: \"(\\x. x \\ A \\ x \\ B \\ False) \\ A \\ B = {}\"\n by sorry\n\nlemma in_image_insert_iff:\n assumes \"\\C. C \\ B \\ x \\ C\"\n shows \"A \\ insert x ` B \\ x \\ A \\ A - {x} \\ B\" (is \"?P \\ ?Q\")\n by sorry\n\nhide_const (open) member not_member\n\nlemmas equalityI = subset_antisym\nlemmas set_mp = subsetD\nlemmas set_rev_mp = rev_subsetD\n\nend" }, { "theorem_id": 43, "title": "052_the_number_of_subsets_of_a_set", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nmodule\n\npublic import Mathlib.Data.Finset.Card\npublic import Mathlib.Data.Finset.Lattice.Union\npublic import Mathlib.Data.Multiset.Powerset\npublic import Mathlib.Data.Set.Pairwise.Lattice\n\n/-!\n# The powerset of a finset\n-/\n\n@[expose] public section\n\n\nnamespace Finset\n\nopen Function Multiset\n\nvariable {α : Type*} {s t : Finset α}\n\n/-! ### powerset -/\n\n\nsection Powerset\n\n/-- When `s` is a finset, `s.powerset` is the finset of all subsets of `s` (seen as finsets). -/\ndef powerset (s : Finset α) : Finset (Finset α) :=\n ⟨(s.1.powerset.pmap Finset.mk) fun _t h => nodup_of_le (mem_powerset.1 h) s.nodup,\n s.nodup.powerset.pmap fun _a _ha _b _hb => congr_arg Finset.val⟩\n\n@[simp, grind =]\ntheorem mem_powerset {s t : Finset α} : s ∈ powerset t ↔ s ⊆ t := by sorry\ntheorem coe_powerset (s : Finset α) :\n (s.powerset : Set (Finset α)) = ((↑) : Finset α → Set α) ⁻¹' (s : Set α).powerset := by sorry\ntheorem empty_mem_powerset (s : Finset α) : ∅ ∈ powerset s := by simp\n\ntheorem mem_powerset_self (s : Finset α) : s ∈ powerset s := by simp\n\n@[aesop safe apply (rule_sets := [finsetNonempty])]\ntheorem powerset_nonempty (s : Finset α) : s.powerset.Nonempty :=\n ⟨∅, empty_mem_powerset _⟩\n\n@[simp]\ntheorem powerset_mono {s t : Finset α} : powerset s ⊆ powerset t ↔ s ⊆ t :=\n ⟨fun h => mem_powerset.1 <| h <| mem_powerset_self _, fun st _u h =>\n mem_powerset.2 <| Subset.trans (mem_powerset.1 h) st⟩\n\ntheorem powerset_injective : Injective (powerset : Finset α → Finset (Finset α)) :=\n .of_eq_imp_le (powerset_mono.1 ·.le)\n\n@[simp]\ntheorem powerset_inj : powerset s = powerset t ↔ s = t :=\n powerset_injective.eq_iff\n\n@[simp]\ntheorem powerset_empty : (∅ : Finset α).powerset = {∅} :=\n rfl\n\n@[simp]\ntheorem powerset_eq_singleton_empty : s.powerset = {∅} ↔ s = ∅ := by sorry\ntheorem image_injOn_powerset_of_injOn {β : Type*} [DecidableEq β] {f : α → β} (H : Set.InjOn f s) :\n Set.InjOn (α := Finset α) (·.image f) s.powerset := by sorry\ntheorem image_surjOn_powerset {β : Type*} [DecidableEq β] {f : α → β} :\n Set.SurjOn (α := Finset α) (·.image f) s.powerset (s.image f).powerset :=\n fun t ht => ⟨{ x ∈ s | f x ∈ t}, by grind⟩\n\ntheorem powerset_image {β : Type*} [DecidableEq β] {f : α → β} :\n (s.image f).powerset = s.powerset.image (·.image f) :=\n ext fun a => ⟨fun _ => mem_image.mpr ⟨{ x ∈ s | f x ∈ a}, by grind⟩, by grind⟩\n\n/-- **Number of Subsets of a Set** -/\n@[simp]\ntheorem card_powerset (s : Finset α) : card (powerset s) = 2 ^ card s :=\n (card_pmap _ _ _).trans (Multiset.card_powerset s.1)\n\ntheorem notMem_of_mem_powerset_of_notMem {s t : Finset α} {a : α} (ht : t ∈ s.powerset)\n (h : a ∉ s) : a ∉ t := by sorry\ntheorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :\n powerset (insert a s) = s.powerset ∪ s.powerset.image (insert a) := by sorry\nlemma pairwiseDisjoint_pair_insert [DecidableEq α] {a : α} (ha : a ∉ s) :\n (s.powerset : Set (Finset α)).PairwiseDisjoint fun t ↦ ({t, insert a t} : Set (Finset α)) := by sorry\ninstance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ t ⊆ s, Prop}\n [∀ (t) (h : t ⊆ s), Decidable (p t h)] : Decidable (∃ (t : _) (h : t ⊆ s), p t h) :=\n decidable_of_iff (∃ (t : _) (hs : t ∈ s.powerset), p t (mem_powerset.1 hs))\n ⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_powerset.2 hs, hp⟩⟩\n\n/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/\ninstance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ t ⊆ s, Prop}\n [∀ (t) (h : t ⊆ s), Decidable (p t h)] : Decidable (∀ (t) (h : t ⊆ s), p t h) :=\n decidable_of_iff (∀ (t) (h : t ∈ s.powerset), p t (mem_powerset.1 h))\n ⟨fun h t hs => h t (mem_powerset.2 hs), fun h _ _ => h _ _⟩\n\n/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/\ninstance decidableExistsOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}\n [∀ t, Decidable (p t)] : Decidable (∃ t ⊆ s, p t) :=\n decidable_of_iff (∃ (t : _) (_h : t ⊆ s), p t) <| by simp\n\n/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/\ninstance decidableForallOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}\n [∀ t, Decidable (p t)] : Decidable (∀ t ⊆ s, p t) :=\n decidable_of_iff (∀ (t : _) (_h : t ⊆ s), p t) <| by simp\n\nend Powerset\n\nsection SSubsets\n\nvariable [DecidableEq α]\n\n/-- For `s` a finset, `s.ssubsets` is the finset comprising strict subsets of `s`. -/\ndef ssubsets (s : Finset α) : Finset (Finset α) :=\n erase (powerset s) s\n\n@[simp, grind =]\ntheorem mem_ssubsets {s t : Finset α} : t ∈ s.ssubsets ↔ t ⊂ s := by sorry\ntheorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets := by sorry\ndef decidableExistsOfDecidableSSubsets {s : Finset α} {p : ∀ t ⊂ s, Prop}\n [∀ t h, Decidable (p t h)] : Decidable (∃ t h, p t h) :=\n decidable_of_iff (∃ (t : _) (hs : t ∈ s.ssubsets), p t (mem_ssubsets.1 hs))\n ⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_ssubsets.2 hs, hp⟩⟩\n\n/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for every ssubset. -/\ndef decidableForallOfDecidableSSubsets {s : Finset α} {p : ∀ t ⊂ s, Prop}\n [∀ t h, Decidable (p t h)] : Decidable (∀ t h, p t h) :=\n decidable_of_iff (∀ (t) (h : t ∈ s.ssubsets), p t (mem_ssubsets.1 h))\n ⟨fun h t hs => h t (mem_ssubsets.2 hs), fun h _ _ => h _ _⟩\n\n/-- A version of `Finset.decidableExistsOfDecidableSSubsets` with a non-dependent `p`.\nTypeclass inference cannot find `hu` here, so this is not an instance. -/\ndef decidableExistsOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}\n (hu : ∀ t ⊂ s, Decidable (p t)) : Decidable (∃ (t : _) (_h : t ⊂ s), p t) :=\n @Finset.decidableExistsOfDecidableSSubsets _ _ _ _ hu\n\n/-- A version of `Finset.decidableForallOfDecidableSSubsets` with a non-dependent `p`.\nTypeclass inference cannot find `hu` here, so this is not an instance. -/\ndef decidableForallOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}\n (hu : ∀ t ⊂ s, Decidable (p t)) : Decidable (∀ t ⊂ s, p t) :=\n @Finset.decidableForallOfDecidableSSubsets _ _ _ _ hu\n\nend SSubsets\n\nsection powersetCard\nvariable {n} {s t : Finset α}\n\n/-- Given an integer `n` and a finset `s`, then `powersetCard n s` is the finset of subsets of `s`\nof cardinality `n`. -/\ndef powersetCard (n : ℕ) (s : Finset α) : Finset (Finset α) :=\n ⟨((s.1.powersetCard n).pmap Finset.mk) fun _t h => nodup_of_le (mem_powersetCard.1 h).1 s.2,\n s.2.powersetCard.pmap fun _a _ha _b _hb => congr_arg Finset.val⟩\n\n@[simp, grind =] lemma mem_powersetCard : s ∈ powersetCard n t ↔ s ⊆ t ∧ card s = n := by sorry\ntheorem powersetCard_mono {n} {s t : Finset α} (h : s ⊆ t) : powersetCard n s ⊆ powersetCard n t :=\n fun _u h' => mem_powersetCard.2 <|\n And.imp (fun h₂ => Subset.trans h₂ h) id (mem_powersetCard.1 h')\n\n/-- **Formula for the Number of Combinations** -/\n@[simp]\ntheorem card_powersetCard (n : ℕ) (s : Finset α) :\n card (powersetCard n s) = Nat.choose (card s) n :=\n (card_pmap _ _ _).trans (Multiset.card_powersetCard n s.1)\n\n@[simp]\ntheorem powersetCard_zero (s : Finset α) : s.powersetCard 0 = {∅} := by sorry\nlemma powersetCard_empty_subsingleton (n : ℕ) :\n (powersetCard n (∅ : Finset α) : Set <| Finset α).Subsingleton := by sorry\ntheorem map_val_val_powersetCard (s : Finset α) (i : ℕ) :\n (s.powersetCard i).val.map Finset.val = s.1.powersetCard i := by sorry\ntheorem powersetCard_one (s : Finset α) :\n s.powersetCard 1 = s.map ⟨_, Finset.singleton_injective⟩ :=\n eq_of_veq <| Multiset.map_injective val_injective <| by simp [Multiset.powersetCard_one]\n\n@[simp]\nlemma powersetCard_eq_empty : powersetCard n s = ∅ ↔ s.card < n := by sorry\ntheorem powersetCard_eq_filter {n} {s : Finset α} :\n powersetCard n s = (powerset s).filter fun x => x.card = n := by sorry\ntheorem powersetCard_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h : x ∉ s) (n : ℕ) :\n powersetCard n.succ (insert x s) =\n powersetCard n.succ s ∪ (powersetCard n s).image (insert x) := by sorry\nlemma powersetCard_nonempty : (powersetCard n s).Nonempty ↔ n ≤ s.card := by sorry\ntheorem powersetCard_self (s : Finset α) : powersetCard s.card s = {s} := by sorry\ntheorem pairwise_disjoint_powersetCard (s : Finset α) :\n Pairwise fun i j => Disjoint (s.powersetCard i) (s.powersetCard j) := fun _i _j hij =>\n Finset.disjoint_left.mpr fun _x hi hj =>\n hij <| (mem_powersetCard.mp hi).2.symm.trans (mem_powersetCard.mp hj).2\n\ntheorem powerset_card_disjiUnion (s : Finset α) :\n Finset.powerset s =\n (range (s.card + 1)).disjiUnion (fun i => powersetCard i s)\n (s.pairwise_disjoint_powersetCard.set_pairwise _) := by sorry\ntheorem powerset_card_biUnion [DecidableEq (Finset α)] (s : Finset α) :\n Finset.powerset s = (range (s.card + 1)).biUnion fun i => powersetCard i s := by sorry\ntheorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :\n (powersetCard n.succ u).sup id = u := by sorry\ntheorem powersetCard_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α) :\n powersetCard n (s.map f) = (powersetCard n s).map (mapEmbedding f).toEmbedding :=\n ext fun t => by\n -- `le_eq_subset` is a dangerous lemma since it turns the type `↪o` into `(· ⊆ ·) ↪r (· ⊆ ·)`,\n -- which makes `simp` have trouble working with `mapEmbedding_apply`.\n simp only [mem_powersetCard, mem_map, RelEmbedding.coe_toEmbedding, mapEmbedding_apply]\n constructor\n · classical\n intro h\n have : map f (filter (fun x => (f x ∈ t)) s) = t := by grind\n refine ⟨_, ?_, this⟩\n rw [← card_map f, this, h.2]; simp\n · rintro ⟨a, ⟨has, rfl⟩, rfl⟩\n simp only [map_subset_map, has, card_map, and_self]\n\nend powersetCard\n\nend Finset\n" }, { "theorem_id": 43, "title": "052_the_number_of_subsets_of_a_set", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From HB Require Import structures.\nFrom mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat div seq.\nFrom mathcomp Require Import choice fintype finfun bigop.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nDeclare Scope set_scope.\n\nSection SetType.\n\nVariable T : finType.\n\nInductive set_type : predArgType := FinSet of {ffun pred T}.\nDefinition finfun_of_set A := let: FinSet f := A in f.\nDefinition set_of := set_type.\nIdentity Coercion type_of_set_of : set_of >-> set_type.\n\nDefinition set_isSub := Eval hnf in [isNew for finfun_of_set].\nHB.instance Definition _ := set_isSub.\nHB.instance Definition _ := [Finite of set_type by <:].\n\nEnd SetType.\n\nDelimit Scope set_scope with SET.\nBind Scope set_scope with set_type.\nBind Scope set_scope with set_of.\nOpen Scope set_scope.\nArguments set_of T%_type.\nArguments finfun_of_set {T} A%_SET.\n\nNotation \"{ 'set' T }\" := (set_of T) (format \"{ 'set' T }\") : type_scope.\n\nNotation \"A :=: B\" := (A = B :> {set _})\n (at level 70, no associativity, only parsing) : set_scope.\nNotation \"A :<>: B\" := (A <> B :> {set _})\n (at level 70, no associativity, only parsing) : set_scope.\nNotation \"A :==: B\" := (A == B :> {set _})\n (at level 70, no associativity, only parsing) : set_scope.\nNotation \"A :!=: B\" := (A != B :> {set _})\n (at level 70, no associativity, only parsing) : set_scope.\nNotation \"A :=P: B\" := (A =P B :> {set _})\n (at level 70, no associativity, only parsing) : set_scope.\n\nHB.lock\nDefinition finset (T : finType) (P : pred T) : {set T} := @FinSet T (finfun P).\nCanonical finset_unlock := Unlockable finset.unlock.\n\nHB.lock\nDefinition pred_of_set T (A : set_type T) : fin_pred_sort (predPredType T)\n:= val A.\nCanonical pred_of_set_unlock := Unlockable pred_of_set.unlock.\n\nNotation \"[ 'set' x : T | P ]\" := (finset (fun x : T => P%B))\n (x at level 99, only parsing) : set_scope.\nNotation \"[ 'set' x | P ]\" := [set x : _ | P]\n (P at level 99, format \"[ 'set' x | P ]\") : set_scope.\nNotation \"[ 'set' x 'in' A ]\" := [set x | x \\in A]\n (format \"[ 'set' x 'in' A ]\") : set_scope.\nNotation \"[ 'set' x : T 'in' A ]\" := [set x : T | x \\in A]\n (only parsing) : set_scope.\nNotation \"[ 'set' x : T | P & Q ]\" := [set x : T | P && Q]\n (only parsing) : set_scope.\nNotation \"[ 'set' x | P & Q ]\" := [set x | P && Q ]\n (P at level 99, format \"[ 'set' x | P & Q ]\") : set_scope.\nNotation \"[ 'set' x : T 'in' A | P ]\" := [set x : T | x \\in A & P]\n (only parsing) : set_scope.\nNotation \"[ 'set' x 'in' A | P ]\" := [set x | x \\in A & P]\n (format \"[ 'set' x 'in' A | P ]\") : set_scope.\nNotation \"[ 'set' x 'in' A | P & Q ]\" := [set x in A | P && Q]\n (format \"[ 'set' x 'in' A | P & Q ]\") : set_scope.\nNotation \"[ 'set' x : T 'in' A | P & Q ]\" := [set x : T in A | P && Q]\n (only parsing) : set_scope.\n\nNotation \"[ 'set' :: s ]\" := (finset [in pred_of_seq s])\n (format \"[ 'set' :: s ]\") : set_scope.\n\nCoercion pred_of_set: set_type >-> fin_pred_sort.\n\nCanonical set_predType T := @PredType _ (unkeyed (set_type T)) (@pred_of_set T).\n\nSection BasicSetTheory.\n\nVariable T : finType.\nImplicit Types (x : T) (A B : {set T}) (pA : pred T).\n\nHB.instance Definition _ := Finite.on {set T}.\n\nLemma in_set pA x : (x \\in finset pA) = pA x.\nProof.\nAdmitted.\nLet PPx x : x \\in D -> Px x \\in P := fun Dx => imset_f _ Dx.\n\nLemma equivalence_partitionP : partition P D.\nProof.\nAdmitted.\n\nLet sXP : {subset X <= cover P}.\nProof.\nAdmitted.\n\nLet trX : {in P, forall B, #|X :&: B| == 1}.\nProof.\nAdmitted.\n\nLemma setI_transversal_pblock x0 B :\n B \\in P -> X :&: B = [set transversal_repr x0 X B].\nProof.\nAdmitted.\n\nDefinition ftagged (T_gt0 : 0 < #|fprod T_|)\n (f : {ffun I -> {i : I & T_ i}}) (i : I) :=\n @untag I T_ (T_ i) (fprod_pick T_gt0 i) i id (f i).\n\nLemma ftaggedE t T_gt0 i : ftagged T_gt0 (fprod_fun t) i = t i.\nProof.\nAdmitted.\n\nEnd FProd.\n\nSection BigTag.\nVariables (R : Type) (idx : R) (op : Monoid.com_law idx).\nVariables (I : finType) (T_ : I -> finType).\n\nLemma big_tag_cond (Q_ : forall i, {pred T_ i})\n (P_ : forall i : I, T_ i -> R) (i : I) :\n \\big[op/idx]_(j in Q_ i) P_ i j =\n \\big[op/idx]_(j in tagged_with T_ i | untag true (Q_ i) j)\n untag idx (P_ i) j.\nProof.\nAdmitted.\n\nLemma big_tag (P_ : forall i : I, T_ i -> R) (i : I) :\n \\big[op/idx]_(j : T_ i) P_ i j =\n \\big[op/idx]_(j in tagged_with T_ i) untag idx (P_ i) j.\nProof.\nAdmitted.\n\nEnd BigTag.\n\nArguments big_tag_cond [R idx op I T_] _ _ _.\nArguments big_tag [R idx op I T_] _ _.\n\nSection BigFProd.\n Variables (R : Type) (zero one : R) (times : R -> R -> R).\n Variables (plus : Monoid.add_law zero times).\n Variables (I : finType) (T_ : I -> finType).\n Variables (P_ : forall i : I, {ffun T_ i -> R}).\n Let T := fprod T_.\n\n Lemma big_fprod_dep (Q : {pred {ffun I -> {i : I & (T_ i)}}}) :\n \\big[plus/zero]_(t : T | Q (fprod_fun t)) \\big[times/one]_(i : I) P_ i (t i) =\n \\big[plus/zero]_(g in family (tagged_with T_) | Q g)\n \\big[times/one]_(i : I) (untag zero (P_ i) (g i)).\nProof.\nAdmitted.\n\n Lemma big_fprod :\n \\big[plus/zero]_(t : T) \\big[times/one]_(i in I) P_ i (t i) =\n \\big[plus/zero]_(g in family (tagged_with T_))\n \\big[times/one]_(i : I) (untag zero (P_ i) (g i)).\nProof.\nAdmitted.\n\nEnd BigFProd." }, { "theorem_id": 44, "title": "054_königsberg_bridges_problem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "let edges = new_definition\n `edges(E:E->bool,V:V->bool,Ter:E->V->bool) = E`;;\n\nlet vertices = new_definition\n `vertices(E:E->bool,V:V->bool,Ter:E->V->bool) = V`;;\n\nlet termini = new_definition\n `termini(E:E->bool,V:V->bool,Ter:E->V->bool) = Ter`;;\n\nlet graph = new_definition\n `graph G <=>\n !e. e IN edges(G)\n ==> ?a b. a IN vertices(G) /\\ b IN vertices(G) /\\\n termini G e = {a,b}`;;\n\nlet TERMINI_IN_VERTICES = `!G e v. graph G /\\ e IN edges(G) /\\ v IN termini G e ==> v IN vertices G`;;\n\nlet connects = new_definition\n `connects G e (a,b) <=> termini G e = {a,b}`;;\n\nlet delete_edge = new_definition\n `delete_edge e (E,V,Ter) = (E DELETE e,V,Ter)`;;\n\nlet DELETE_EDGE_CLAUSES = `(!G. edges(delete_edge e G) = (edges G) DELETE e) /\\\n (!G. vertices(delete_edge e G) = vertices G) /\\\n (!G. termini(delete_edge e G) = termini G)`;;\n\nlet GRAPH_DELETE_EDGE = `!G e. graph G ==> graph(delete_edge e G)`;;\n\nlet locally_finite = new_definition\n `locally_finite G <=>\n !v. v IN vertices(G) ==> FINITE {e | e IN edges G /\\ v IN termini G e}`;;\n\nlet localdegree = new_definition\n `localdegree G v e =\n if termini G e = {v} then 2\n else if v IN termini G e then 1\n else 0`;;\n\nlet degree = new_definition\n `degree G v = nsum {e | e IN edges G /\\ v IN termini G e} (localdegree G v)`;;\n\nlet DEGREE_DELETE_EDGE = `!G e:E v:V.\n graph G /\\ locally_finite G /\\ e IN edges(G)\n ==> degree G v =\n if termini G e = {v} then degree (delete_edge e G) v + 2\n else if v IN termini G e then degree (delete_edge e G) v + 1\n else degree (delete_edge e G) v`;;\n\nlet eulerian_RULES,eulerian_INDUCT,eulerian_CASES = new_inductive_definition\n `(!G a. a IN vertices G /\\ edges G = {} ==> eulerian G [] (a,a)) /\\\n (!G a b c e es. e IN edges(G) /\\ connects G e (a,b) /\\\n eulerian (delete_edge e G) es (b,c)\n ==> eulerian G (CONS e es) (a,c))`;;\n\nlet EULERIAN_FINITE = `!G es ab. eulerian G es ab ==> FINITE (edges G)`;;\n\nlet EULERIAN_ODD_LEMMA = `!G:(E->bool)#(V->bool)#(E->V->bool) es ab.\n eulerian G es ab\n ==> graph G\n ==> FINITE(edges G) /\\\n !v. v IN vertices G\n ==> (ODD(degree G v) <=>\n ~(FST ab = SND ab) /\\ (v = FST ab \\/ v = SND ab))`;;\n\nlet EULERIAN_ODD = `!G es a b.\n graph G /\\ eulerian G es (a,b)\n ==> !v. v IN vertices G\n ==> (ODD(degree G v) <=> ~(a = b) /\\ (v = a \\/ v = b))`;;\n\nlet KOENIGSBERG = `!G. vertices(G) = {0,1,2,3} /\\\n edges(G) = {10,20,30,40,50,60,70} /\\\n termini G (10) = {0,1} /\\\n termini G (20) = {0,2} /\\\n termini G (30) = {0,3} /\\\n termini G (40) = {1,2} /\\\n termini G (50) = {1,2} /\\\n termini G (60) = {2,3} /\\\n termini G (70) = {2,3}\n ==> ~(?es a b. eulerian G es (a,b))`;;" }, { "theorem_id": 44, "title": "054_königsberg_bridges_problem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory KoenigsbergBridge imports MoreGraph\nbegin\n\nsection\\Definition of Eulerian trails and circuits\\\n\ndefinition (in valid_unMultigraph) is_Eulerian_trail:: \"'v\\('v,'w) path\\'v\\ bool\" where\n \"is_Eulerian_trail v ps v'\\ is_trail v ps v' \\ edges (rem_unPath ps G) = {}\"\n\ndefinition (in valid_unMultigraph) is_Eulerian_circuit:: \"'v \\ ('v,'w) path \\ 'v \\ bool\" where\n \"is_Eulerian_circuit v ps v'\\ (v=v') \\ (is_Eulerian_trail v ps v')\"\n\nsection\\Necessary conditions for Eulerian trails and circuits\\\n\nlemma (in valid_unMultigraph) euclerian_rev:\n \"is_Eulerian_trail v' (rev_path ps) v=is_Eulerian_trail v ps v' \"\n by sorry\n\ntheorem (in valid_unMultigraph) euclerian_cycle_ex:\n assumes \"is_Eulerian_circuit v ps v'\" \"finite V\" \"finite E\"\n shows \"\\v\\V. even (degree v G)\"\n by sorry\n\ntheorem (in valid_unMultigraph) euclerian_path_ex:\n assumes \"is_Eulerian_trail v ps v'\" \"finite V\" \"finite E\"\n shows \"(\\v\\V. even (degree v G)) \\ (num_of_odd_nodes G =2)\"\n by sorry\n\nsection\\Specific case of the Konigsberg Bridge Problem\\\n\ndatatype kon_node = a | b | c | d\n\ndatatype kon_bridge = ab1 | ab2 | ac1 | ac2 | ad1 | bd1 | cd1\n\ndefinition kon_graph :: \"(kon_node,kon_bridge) graph\" where\n \"kon_graph\\\\nodes={a,b,c,d},\n edges={(a,ab1,b), (b,ab1,a),\n (a,ab2,b), (b,ab2,a),\n (a,ac1,c), (c,ac1,a),\n (a,ac2,c), (c,ac2,a),\n (a,ad1,d), (d,ad1,a),\n (b,bd1,d), (d,bd1,b),\n (c,cd1,d), (d,cd1,c)} \\\"\n\ninstantiation kon_node :: enum\nbegin\ndefinition [simp]: \"enum_class.enum =[a,b,c,d]\"\ndefinition [simp]: \"enum_class.enum_all P \\ P a \\ P b \\ P c \\ P d\"\ndefinition [simp]:\"enum_class.enum_ex P \\ P a \\ P b \\ P c \\ P d\"\ninstance proof qed (auto,(case_tac x,auto)+)\nend\n\ninstantiation kon_bridge :: enum\nbegin\ndefinition [simp]:\"enum_class.enum =[ab1,ab2,ac1,ac2,ad1,cd1,bd1]\"\ndefinition [simp]:\"enum_class.enum_all P \\ P ab1 \\ P ab2 \\ P ac1 \\ P ac2 \\ P ad1 \\ P bd1\n \\ P cd1\"\ndefinition [simp]:\"enum_class.enum_ex P \\ P ab1 \\ P ab2 \\ P ac1 \\ P ac2 \\ P ad1 \\ P bd1\n \\ P cd1\"\ninstance proof qed (auto,(case_tac x,auto)+)\nend\n\ninterpretation kon_graph: valid_unMultigraph kon_graph\nproof (unfold_locales)\n show \"fst ` edges kon_graph \\ nodes kon_graph\" by eval\nnext\n show \"snd ` snd ` edges kon_graph \\ nodes kon_graph\" by eval\nnext\n have \" \\v w u'. ((v, w, u') \\ edges kon_graph) = ((u', w, v) \\ edges kon_graph)\"\n by eval\n thus \"\\v w u'. ((v, w, u') \\ edges kon_graph) = ((u', w, v) \\ edges kon_graph)\" by simp\nnext\n have \"\\v w. (v, w, v) \\ edges kon_graph\" by eval\n thus \"\\v w. (v, w, v) \\ edges kon_graph\" by simp\nqed\n\ntheorem \"\\kon_graph.is_Eulerian_trail v1 p v2\"\n by sorry\n\nsection\\Sufficient conditions for Eulerian trails and circuits\\\n\nlemma (in valid_unMultigraph) eulerian_cons:\n assumes\n \"valid_unMultigraph.is_Eulerian_trail (del_unEdge v0 w v1 G) v1 ps v2\"\n \"(v0,w,v1)\\ E\"\n shows \"is_Eulerian_trail v0 ((v0,w,v1)#ps) v2\"\n by sorry\n\nlemma (in valid_unMultigraph) eulerian_cons':\n assumes\n \"valid_unMultigraph.is_Eulerian_trail (del_unEdge v2 w v3 G) v1 ps v2\"\n \"(v2,w,v3)\\ E\"\n shows \"is_Eulerian_trail v1 (ps@[(v2,w,v3)]) v3\"\n by sorry\n\nlemma eulerian_split:\n assumes \"nodes G1 \\ nodes G2 = {}\" \"edges G1 \\ edges G2={}\"\n \"valid_unMultigraph G1\" \"valid_unMultigraph G2\"\n \"valid_unMultigraph.is_Eulerian_trail G1 v1 ps1 v1'\"\n \"valid_unMultigraph.is_Eulerian_trail G2 v2 ps2 v2'\"\n shows \"valid_unMultigraph.is_Eulerian_trail \\nodes=nodes G1 \\ nodes G2,\n edges=edges G1 \\ edges G2 \\ {(v1',w,v2),(v2,w,v1')}\\ v1 (ps1@(v1',w,v2)#ps2) v2'\"\n by sorry\n\nlemma (in valid_unMultigraph) eulerian_sufficient:\n assumes \"finite V\" \"finite E\" \"connected\" \"V\\{}\"\n shows \"num_of_odd_nodes G = 2 \\\n (\\v\\V.\\v'\\V.\\ps. odd(degree v G)\\odd(degree v' G)\\(v\\v')\\is_Eulerian_trail v ps v')\"\n and \"num_of_odd_nodes G=0 \\ (\\v\\V.\\ps. is_Eulerian_circuit v ps v)\"\n by sorry\nend" }, { "theorem_id": 44, "title": "054_königsberg_bridges_problem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2022 Kyle Miller. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kyle Miller\n-/\nimport Mathlib.Combinatorics.SimpleGraph.Trails\nimport Mathlib.Tactic.DeriveFintype\nimport Mathlib.Tactic.NormNum\n\n/-!\n# The Königsberg bridges problem\n\nWe show that a graph that represents the islands and mainlands of Königsberg and seven bridges\nbetween them has no Eulerian trail.\n-/\n\n\nnamespace Konigsberg\n\n/-- The vertices for the Königsberg graph; four vertices for the bodies of land and seven\nvertices for the bridges. -/\ninductive Verts : Type\n -- The islands and mainlands\n | V1 | V2 | V3 | V4\n -- The bridges\n | B1 | B2 | B3 | B4 | B5 | B6 | B7\n deriving DecidableEq, Fintype\n\nopen Verts\n\n/-- Each of the connections between the islands/mainlands and the bridges.\nThese are ordered pairs, but the data becomes symmetric in `Konigsberg.adj`. -/\ndef edges : List (Verts × Verts) :=\n [(V1, B1), (V1, B2), (V1, B3), (V1, B4), (V1, B5),\n (B1, V2), (B2, V2), (B3, V4), (B4, V3), (B5, V3),\n (V2, B6), (B6, V4),\n (V3, B7), (B7, V4)]\n\n/-- The adjacency relation for the Königsberg graph. -/\ndef adj (v w : Verts) : Bool := (v, w) ∈ edges || (w, v) ∈ edges\n\n/-- The Königsberg graph structure. While the Königsberg bridge problem\nis usually described using a multigraph, we use a \"mediant\" construction\nto transform it into a simple graph -- every edge in the multigraph is subdivided\ninto a path of two edges. This construction preserves whether a graph is Eulerian.\n\n(TODO: once mathlib has multigraphs, either prove the mediant construction preserves the\nEulerian property or switch this file to use multigraphs. -/\n@[simps]\ndef graph : SimpleGraph Verts where\n Adj v w := adj v w\n symm := by sorry\ninstance : DecidableRel graph.Adj := fun a b => inferInstanceAs <| Decidable (adj a b)\n\n/-- To speed up the proof, this is a cache of all the degrees of each vertex,\nproved in `Konigsberg.degree_eq_degree`. -/\ndef degree : Verts → ℕ\n | V1 => 5 | V2 => 3 | V3 => 3 | V4 => 3\n | B1 => 2 | B2 => 2 | B3 => 2 | B4 => 2 | B5 => 2 | B6 => 2 | B7 => 2\n\n@[simp]\nlemma degree_eq_degree (v : Verts) : graph.degree v = degree v := by cases v <;> rfl\n\nlemma not_even_degree_iff (w : Verts) : ¬Even (degree w) ↔ w = V1 ∨ w = V2 ∨ w = V3 ∨ w = V4 := by sorry\nlemma setOf_odd_degree_eq :\n {v | Odd (graph.degree v)} = {Verts.V1, Verts.V2, Verts.V3, Verts.V4} := by sorry\ntheorem not_isEulerian {u v : Verts} (p : graph.Walk u v) (h : p.IsEulerian) : False := by sorry\nend Konigsberg\n" }, { "theorem_id": 44, "title": "054_königsberg_bridges_problem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Arith.\nRequire Import List.\nRequire Import Permutation.\nImport ListNotations.\n\nDefinition normalize_direction : nat * nat -> nat * nat :=\n fun p => if fst p <=? snd p then p else (snd p, fst p).\n\nDefinition eulerian (E path : list (nat * nat)) :=\n Permutation\n (map normalize_direction E)\n (map normalize_direction path).\n\nInductive path : list (nat * nat) -> Prop :=\n | path_nil : path []\n | path_singleton x y : path [(x, y)]\n | path_cons x y z l :\n path ((y, z) :: l) ->\n path ((x, y) :: (y, z) :: l).\n\nFixpoint pathb l :=\n (match l with\n | [] => true\n | [(_, _)] => true\n | (x, y) :: (((y', z) :: _) as l) =>\n (y =? y') && pathb l\n end)%bool.\n\nLemma pathb_correct l : pathb l = true <-> path l.\nProof.\nAdmitted.\n\nFixpoint pathbdir (swapfirst : bool) l :=\n (match l with\n | [] => true\n | [(_, _)] => true\n | (x, y) :: (((z, t) :: _) as l) =>\n let xy := if swapfirst then x else y in\n ((xy =? z) && pathbdir false l) ||\n ((xy =? t) && pathbdir true l)\n end)%bool.\n\nLemma pathbdir_rewrite first x y z t l :\n pathbdir first ((x, y) :: (z, t) :: l) =\n ((((if first then x else y) =? z) && pathbdir false ((z, t) :: l))\n || ((if first then x else y) =? t) && pathbdir true ((z, t) :: l))%bool.\nProof.\nAdmitted.\n\nDefinition shouldswap p :=\n match p with\n | [] => true\n | (x, y) :: _ => negb (x <=? y)\n end.\n\nLemma pathbdir_correct p :\n pathb p = true ->\n pathbdir (shouldswap p) (map normalize_direction p) = true.\nProof.\nAdmitted.\n\nFixpoint remove1 {A} (eq_dec : forall x y, {x = y} + {x <> y}) (x : A) l : list A :=\n match l with\n | [] => []\n | y :: tl => if eq_dec x y then tl else y :: remove1 eq_dec x tl\n end.\n\nLemma permutation_remove1 {A} eq_dec (a : A) l l' :\n Permutation l l' ->\n Permutation (remove1 eq_dec a l) (remove1 eq_dec a l').\nProof.\nAdmitted.\n\nLemma pe : forall x y : nat * nat, {x = y} + {x <> y}.\nProof.\nAdmitted.\n\nFixpoint find x l :=\n match l with\n [] => False\n | y :: l => if pe x y then True else find x l\n end.\n\nLemma prune x l l' : Permutation (x :: l) l' -> find x l'.\nProof.\nAdmitted.\n\nLemma permutation_remove {A} eq_dec (a : A) l l' :\n Permutation (a :: l) l' ->\n Permutation l (remove1 eq_dec a l').\nProof.\nAdmitted.\n\nTheorem konigsberg_bridges :\n let E := [(0, 1); (0, 2); (0, 3); (1, 2); (1, 2); (2, 3); (2, 3)] in\n forall p, path p -> eulerian E p -> False.\nProof.\nAdmitted." }, { "theorem_id": 45, "title": "055_product_of_segments_of_chords", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/convex.ml\";;\n\nprioritize_real();;\n\nlet BETWEEN_THM = `between x (a,b) <=>\n ?u. &0 <= u /\\ u <= &1 /\\ x = u % a + (&1 - u) % b`;;\n\nlet length = new_definition\n `length(A:real^2,B:real^2) = norm(B - A)`;;\n\nlet lemma = `!x y. &0 <= x /\\ &0 <= y ==> (x pow 2 = y pow 2 <=> x = y)`;;\n\nlet NORM_CROSS = `norm(a) * norm(b) = norm(c) * norm(d) <=>\n (a dot a) * (b dot b) = (c dot c) * (d dot d)`;;\n\nlet SEGMENT_CHORDS = `!centre radius q r s t b.\n between b (q,r) /\\ between b (s,t) /\\\n length(q,centre) = radius /\\ length(r,centre) = radius /\\\n length(s,centre) = radius /\\ length(t,centre) = radius\n ==> length(q,b) * length(b,r) = length(s,b) * length(b,t)`;;" }, { "theorem_id": 45, "title": "055_product_of_segments_of_chords", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Intersecting Chord Theorem\\\n\ntheory Chord_Segments\nimports Triangle.Triangle\nbegin\n\nsubsection \\Preliminaries\\\n\nlemma betweenE_if_dist_leq:\n fixes A B X :: \"'a::euclidean_space\"\n assumes \"between (A, B) X\"\n assumes \"dist A X \\ dist B X\"\n obtains u where \"1 / 2 \\ u\" \"u \\ 1\" and \"X = u *\\<^sub>R A + (1 - u) *\\<^sub>R B\"\n by sorry\n\nlemma dist_geq_iff_midpoint_in_between:\n fixes A B X :: \"'a::euclidean_space\"\n assumes \"between (A, B) X\"\n shows \"dist A X \\ dist B X \\ between (X, B) (midpoint A B)\"\n by sorry\n\nsubsection \\Properties of Chord Segments\\\n\nlemma chord_property:\n fixes S C :: \"'a :: euclidean_space\"\n assumes \"dist C S = dist C T\"\n assumes \"between (S, T) X\"\n shows \"dist S X * dist X T = (dist C S) ^ 2 - (dist C X) ^ 2\"\n by sorry\n\ntheorem product_of_chord_segments:\n fixes S\\<^sub>1 T\\<^sub>1 S\\<^sub>2 T\\<^sub>2 X C :: \"'a :: euclidean_space\"\n assumes \"between (S\\<^sub>1, T\\<^sub>1) X\" \"between (S\\<^sub>2, T\\<^sub>2) X\"\n assumes \"dist C S\\<^sub>1 = r\" \"dist C T\\<^sub>1 = r\"\n assumes \"dist C S\\<^sub>2 = r\" \"dist C T\\<^sub>2 = r\"\n shows \"dist S\\<^sub>1 X * dist X T\\<^sub>1 = dist S\\<^sub>2 X * dist X T\\<^sub>2\"\n by sorry\n\nend" }, { "theorem_id": 45, "title": "055_product_of_segments_of_chords", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2021 Manuel Candales. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Manuel Candales, Benjamin Davidson, Li Jiale\n-/\nmodule\n\n\npublic import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine\npublic import Mathlib.Geometry.Euclidean.Sphere.Tangent\n\nimport Mathlib.Geometry.Euclidean.Angle.Sphere\nimport Mathlib.Geometry.Euclidean.Similarity\n\n/-!\n# Power of a point (intersecting chords and secants)\n\nThis file proves basic geometrical results about power of a point (intersecting chords and\nsecants) in spheres in real inner product spaces and Euclidean affine spaces.\n\n## Main definitions\n\n* `Sphere.power`: The power of a point with respect to a sphere.\n\n## Main theorems\n\n* `mul_dist_eq_mul_dist_of_cospherical_of_angle_eq_pi`: Intersecting Chords Theorem (Freek No. 55).\n* `mul_dist_eq_mul_dist_of_cospherical_of_angle_eq_zero`: Intersecting Secants Theorem.\n* `Sphere.mul_dist_eq_abs_power`: The product of distances equals the absolute value of power.\n* `Sphere.dist_sq_eq_mul_dist_of_tangent_and_secant`: Tangent-Secant Theorem.\n-/\n\n@[expose] public section\n\n\nopen Real EuclideanGeometry RealInnerProductSpace Real Module FiniteDimensional\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]\n\nnamespace InnerProductGeometry\n\n/-!\n### Geometrical results on spheres in real inner product spaces\n\nThis section develops some results on spheres in real inner product spaces,\nwhich are used to deduce corresponding results for Euclidean affine spaces.\n-/\n\n\ntheorem mul_norm_eq_abs_sub_sq_norm {x y z : V} (h₁ : ∃ k : ℝ, x = k • y)\n (h₃ : ‖z - y‖ = ‖z + y‖) : ‖x - y‖ * ‖x + y‖ = |‖z + y‖ ^ 2 - ‖z - x‖ ^ 2| := by sorry\nend InnerProductGeometry\n\nnamespace EuclideanGeometry\n\n/-!\n### Geometrical results on spheres in Euclidean affine spaces\n\nThis section develops some results on spheres in Euclidean affine spaces.\n-/\n\n\nopen InnerProductGeometry EuclideanGeometry\n\nvariable {P : Type*} [MetricSpace P] [NormedAddTorsor V P]\n\n/-- If `P` is a point on the line `AB` and `Q` is equidistant from `A` and `B`, then\n`AP * BP = abs (BQ ^ 2 - PQ ^ 2)`. -/\ntheorem mul_dist_eq_abs_sub_sq_dist {a b p q : P} (hp : p ∈ line[ℝ, a, b])\n (hq : dist a q = dist b q) : dist a p * dist b p = |dist b q ^ 2 - dist p q ^ 2| := by sorry\ntheorem mul_dist_eq_mul_dist_of_cospherical {a b c d p : P} (h : Cospherical ({a, b, c, d} : Set P))\n (hapb : p ∈ line[ℝ, a, b]) (hcpd : p ∈ line[ℝ, c, d]) :\n dist a p * dist b p = dist c p * dist d p := by sorry\ntheorem mul_dist_eq_mul_dist_of_cospherical_of_angle_eq_pi {a b c d p : P}\n (h : Cospherical ({a, b, c, d} : Set P)) (hapb : ∠ a p b = π) (hcpd : ∠ c p d = π) :\n dist a p * dist b p = dist c p * dist d p := by sorry\ntheorem cospherical_of_mul_dist_eq_mul_dist_of_angle_eq_pi {p₁ p₂ p₃ p₄ p : P}\n (h : dist p₁ p * dist p₂ p = dist p₃ p * dist p₄ p)\n (hp₁p₂ : ∠ p₁ p p₂ = π) (hp₃p₄ : ∠ p₃ p p₄ = π) (hn : ¬ Collinear ℝ ({p₁, p, p₃} : Set P)) :\n Cospherical ({p₁, p₂, p₃, p₄} : Set P) := by sorry\n #adaptation_note /-- Before https://github.com/leanprover/lean4/pull/13166\n (replacing grind's canonicalizer with a type-directed normalizer), `grind` closed this goal.\n It is not yet clear whether this is due to defeq abuse in Mathlib or a problem in the new\n canonicalizer; a minimization would help. The original proof was:\n `grind [Set.image_insert_eq, Set.image_singleton]` -/\n simpa [Set.image_insert_eq, Set.image_singleton] using Cospherical.subtype_val h_cospherical'\n have hf2 : Fact (finrank ℝ S.direction = 2) := ⟨by\n rw [hS, direction_affineSpan, t.independent.finrank_vectorSpan]\n simp⟩\n letI : Module.Oriented ℝ S.direction (Fin 2) :=\n ⟨Basis.orientation (finBasisOfFinrankEq _ _ hf2.out)⟩\n have hncol : ¬ Collinear ℝ {p₁', p', p₃'} := by sorry\ntheorem mul_dist_eq_mul_dist_of_cospherical_of_angle_eq_zero {a b c d p : P}\n (h : Cospherical ({a, b, c, d} : Set P)) (hab : a ≠ b) (hcd : c ≠ d) (hapb : ∠ a p b = 0)\n (hcpd : ∠ c p d = 0) : dist a p * dist b p = dist c p * dist d p := by sorry\nnamespace Sphere\n\n/-- The power of a point with respect to a sphere. For a point and a sphere,\nthis is defined as the square of the distance from the point to the center\nminus the square of the radius. This value is positive if the point is outside\nthe sphere, negative if inside, and zero if on the sphere. -/\ndef power (s : Sphere P) (p : P) : ℝ :=\n dist p s.center ^ 2 - s.radius ^ 2\n\n/-- A point lies on the sphere if and only if its power with respect to\nthe sphere is zero. -/\ntheorem power_eq_zero_iff_mem_sphere {s : Sphere P} {p : P} (hr : 0 ≤ s.radius) :\n s.power p = 0 ↔ p ∈ s := by sorry\ntheorem power_pos_iff_radius_lt_dist_center {s : Sphere P} {p : P} (hr : 0 ≤ s.radius) :\n 0 < s.power p ↔ s.radius < dist p s.center := by sorry\ntheorem power_neg_iff_dist_center_lt_radius {s : Sphere P} {p : P} (hr : 0 ≤ s.radius) :\n s.power p < 0 ↔ dist p s.center < s.radius := by sorry\ntheorem power_nonneg_iff_radius_le_dist_center {s : Sphere P} {p : P} (hr : 0 ≤ s.radius) :\n 0 ≤ s.power p ↔ s.radius ≤ dist p s.center := by sorry\ntheorem power_nonpos_iff_dist_center_le_radius {s : Sphere P} {p : P} (hr : 0 ≤ s.radius) :\n s.power p ≤ 0 ↔ dist p s.center ≤ s.radius := by sorry\ntheorem mul_dist_eq_abs_power {s : Sphere P} {p a b : P}\n (hp : p ∈ line[ℝ, a, b])\n (ha : a ∈ s) (hb : b ∈ s) :\n dist p a * dist p b = |s.power p| := by sorry\ntheorem mul_dist_eq_zero_of_mem_sphere {s : Sphere P} {p a b : P}\n (hp : p ∈ line[ℝ, a, b])\n (ha : a ∈ s) (hb : b ∈ s)\n (hp_on : p ∈ s) :\n dist p a * dist p b = 0 := by sorry\ntheorem mul_dist_eq_power_of_radius_le_dist_center {s : Sphere P} {p a b : P}\n (hr : 0 ≤ s.radius)\n (hp : p ∈ line[ℝ, a, b])\n (ha : a ∈ s) (hb : b ∈ s)\n (hle : s.radius ≤ dist p s.center) :\n dist p a * dist p b = s.power p := by sorry\ntheorem mul_dist_eq_neg_power_of_dist_center_le_radius {s : Sphere P} {p a b : P}\n (hr : 0 ≤ s.radius)\n (hp : p ∈ line[ℝ, a, b])\n (ha : a ∈ s) (hb : b ∈ s)\n (hle : dist p s.center ≤ s.radius) :\n dist p a * dist p b = -s.power p := by sorry\ntheorem dist_sq_eq_mul_dist_of_tangent_and_secant {a b t p : P} {s : Sphere P}\n (ha : a ∈ s) (hb : b ∈ s)\n (hp : p ∈ line[ℝ, a, b])\n (h_tangent : s.IsTangentAt t (line[ℝ, p, t])) :\n dist p t ^ 2 = dist p a * dist p b := by sorry\ntheorem IsTangentAt.power_eq_dist_sq {s : Sphere P} {t p : P}\n (h_tangent : s.IsTangentAt t (line[ℝ, p, t])) :\n s.power p = dist p t ^ 2 := by sorry\ntheorem isTangentAt_iff_dist_sq_eq_power {t p : P} {s : Sphere P} (ht : t ∈ s) :\n s.IsTangentAt t (line[ℝ, p, t]) ↔ dist p t ^ 2 = s.power p :=\n ⟨fun h ↦ h.power_eq_dist_sq.symm, fun h_dist_eq ↦ by\n have h_orth : ⟪p -ᵥ t, t -ᵥ s.center⟫ = 0 := by sorry\nend Sphere\n\nend EuclideanGeometry\n" }, { "theorem_id": 45, "title": "055_product_of_segments_of_chords", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From Stdlib Require Import List BinNat ZArith Zdivisibility Zmod QArith Rbase RNsatz.\n\nSection test.\n\nLemma nonconsecutive_equalities_to_goal (FR ep : Z) (IHp : FR = ep) a : (fst a * snd a + FR = fst a * snd a + ep)%Z.\nProof.\nAdmitted.\n\nLemma example3_Z : forall (x y z : Z), (\n x+y+z=0 ->\n x*y+x*z+y*z=0->\n x*y*z=0 -> x*x*x=0)%Z.\nProof.\nAdmitted.\n\nLemma example3_Zmod3 : forall (x y z : Zmod 3), (\n x+y+z=0 ->\n x*y+x*z+y*z=0->\n x*y*z=0 -> x^3=0)%Zmod.\nProof.\nAdmitted.\n\nLemma example3_Zmodp : forall p (x y z : Zmod p), Z.\nProof.\nAdmitted.\n\nLemma example3_Q : forall (x y z : Q), (\n x+y+z==0 ->\n x*y+x*z+y*z==0->\n x*y*z==0 -> x*x*x==0)%Q.\nProof.\nAdmitted.\n\nLemma example3_R : forall (x y z : R), (\n x+y+z=0 ->\n x*y+x*z+y*z=0->\n x*y*z=0 -> x*x*x=0)%R.\nProof.\nAdmitted.\n\nLemma example_contradiction_Zmod3 : forall (x : Zmod 3), (\n x = Zmod.\nProof.\nAdmitted.\n\nLemma example_contradiction_Zmodp : forall p (x : Zmod p), Z.\nProof.\nAdmitted.\n\nImport Integral_domain Algebra_syntax.\n\nContext {A:Type}`{Aid:Integral_domain A}.\n\nLemma example3_A : forall (x y z :A),\n x+y+z==0 ->\n x*y+x*z+y*z==0->\n x*y*z==0 -> x^3%Z==0.\nProof.\nAdmitted.\n\nLemma example4 : forall x y z u,\n x+y+z+u==0 ->\n x*y+x*z+x*u+y*z+y*u+z*u==0->\n x*y*z+x*y*u+x*z*u+y*z*u==0->\n x*y*z*u==0 -> x^4%Z==0.\nProof.\nAdmitted.\n\nLemma example5 : forall x y z u v,\n x+y+z+u+v==0 ->\n x*y+x*z+x*u+x*v+y*z+y*u+y*v+z*u+z*v+u*v==0->\n x*y*z+x*y*u+x*y*v+x*z*u+x*z*v+x*u*v+y*z*u+y*z*v+y*u*v+z*u*v==0->\n x*y*z*u+y*z*u*v+z*u*v*x+u*v*x*y+v*x*y*z==0 ->\n x*y*z*u*v==0 -> x^5%Z==0.\nProof.\nAdmitted.\n\nGoal forall x y:Z, x = y -> (x+0)%Z = (y*1+0)%Z.\nProof.\nAdmitted.\n\nGoal forall x y:R, x = y -> (x+0)%R = (y*1+0)%R.\nProof.\nAdmitted.\n\nGoal forall a b c x:R, a = b -> b = c -> (a*a)%R = (c*c)%R.\nProof.\nAdmitted.\n\nEnd test.\n\nSection Geometry.\nImport Algebra_syntax List.ListNotations.\n#[local] Open Scope R_scope.\n#[local] Coercion IZR : Z >-> R.\n\nRecord point:Type:={\n X:R;\n Y:R}.\n\nDefinition collinear(A B C:point):=\n (X A - X B)*(Y C - Y B)-(Y A - Y B)*(X C - X B)=0.\n\nDefinition parallel (A B C D:point):=\n ((X A)-(X B))*((Y C)-(Y D))=((Y A)-(Y B))*((X C)-(X D)).\n\nDefinition notparallel (A B C D:point)(x:R):=\n x*(((X A)-(X B))*((Y C)-(Y D))-((Y A)-(Y B))*((X C)-(X D)))=1.\n\nDefinition orthogonal (A B C D:point):=\n ((X A)-(X B))*((X C)-(X D))+((Y A)-(Y B))*((Y C)-(Y D))=0.\n\nDefinition equal2(A B:point):=\n (X A)=(X B) /\\ (Y A)=(Y B).\n\nDefinition equal3(A B:point):=\n ((X A)-(X B))^2%Z+((Y A)-(Y B))^2%Z = 0.\n\nDefinition nequal2(A B:point):=\n (X A)<>(X B) \\/ (Y A)<>(Y B).\n\nDefinition nequal3(A B:point):=\n not (((X A)-(X B))^2%Z+((Y A)-(Y B))^2%Z = 0).\n\nDefinition middle(A B I:point):=\n 2%R*(X I)=(X A)+(X B) /\\ 2%R*(Y I)=(Y A)+(Y B).\n\nDefinition distance2(A B:point):=\n (X B - X A)^2%Z + (Y B - Y A)^2%Z.\n\nDefinition samedistance2(A B C D:point):=\n (X B - X A)^2%Z + (Y B - Y A)^2%Z = (X D - X C)^2%Z + (Y D - Y C)^2%Z.\nDefinition determinant(A O B:point):=\n (X A - X O)*(Y B - Y O) - (Y A - Y O)*(X B - X O).\nDefinition scalarproduct(A O B:point):=\n (X A - X O)*(X B - X O) + (Y A - Y O)*(Y B - Y O).\nDefinition norm2(A O B:point):=\n ((X A - X O)^2%Z+(Y A - Y O)^2%Z)*((X B - X O)^2%Z+(Y B - Y O)^2%Z).\n\nDefinition equaldistance(A B C D:point):=\n ((X B) - (X A))^2%Z + ((Y B) - (Y A))^2%Z =\n ((X D) - (X C))^2%Z + ((Y D) - (Y C))^2%Z.\n\nDefinition equaltangente(A B C D E F:point):=\n let s1:= determinant A B C in\n let c1:= scalarproduct A B C in\n let s2:= determinant D E F in\n let c2:= scalarproduct D E F in\n s1 * c2 = s2 * c1.\n\nLtac cnf2 f :=\n match f with\n | ?A \\/ (?B /\\ ?C) =>\n let c1 := cnf2 (A\\/B) in\n let c2 := cnf2 (A\\/C) in constr:(c1/\\c2)\n | (?B /\\ ?C) \\/ ?A =>\n let c1 := cnf2 (B\\/A) in\n let c2 := cnf2 (C\\/A) in constr:(c1/\\c2)\n | (?A \\/ ?B) \\/ ?C =>\n let c1 := cnf2 (B\\/C) in cnf2 (A \\/ c1)\n | _ => f\n end\nwith cnf f :=\n match f with\n | ?A \\/ ?B =>\n let c1 := cnf A in\n let c2 := cnf B in\n cnf2 (c1 \\/ c2)\n | ?A /\\ ?B =>\n let c1 := cnf A in\n let c2 := cnf B in\n constr:(c1 /\\ c2)\n | _ => f\n end.\n\nLtac scnf :=\n match goal with\n | |- ?f => let c := cnf f in\n assert c;[repeat split| tauto]\n end.\n\nLtac disj_to_pol f :=\n match f with\n | ?a = ?b \\/ ?g => let p := disj_to_pol g in constr:((a - b)* p)\n | ?a = ?b => constr:(a - b)\n end.\n\nLemma fastnsatz1:forall x y:R, x - y = 0 -> x = y.\nProof.\nAdmitted.\n\nLtac fastnsatz:=\n try trivial; try apply fastnsatz1; try trivial; nsatz.\n\nLtac proof_pol_disj :=\n match goal with\n | |- ?g => let p := disj_to_pol g in\n let h := fresh \"hp\" in\n assert (h:p = 0);\n [idtac|\n prod_disj h p]\n | _ => idtac\n end\nwith prod_disj h p :=\n match goal with\n | |- ?a = ?b \\/ ?g =>\n match p with\n | ?q * ?p1 =>\n let h0 := fresh \"hp\" in\n let h1 := fresh \"hp\" in\n let h2 := fresh \"hp\" in\n assert (h0:a - b = 0 \\/ p1 = 0);\n [apply Rmult_integral; exact h|\n destruct h0 as [h1|h2];\n [left; fastnsatz|\n right; prod_disj h2 p1]]\n end\n | _ => fastnsatz\n end." }, { "theorem_id": 46, "title": "057_heron_s_formula", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/measure.ml\";;\n\nprioritize_real();;\n\nlet SQRT_ELIM_TAC =\n let sqrt_tm = `sqrt:real->real` in\n let is_sqrt tm = is_comb tm && rator tm = sqrt_tm in\n fun (asl,w) ->\n let stms = setify(find_terms is_sqrt w) in\n let gvs = map (genvar o type_of) stms in\n (MAP_EVERY (MP_TAC o C SPEC SQRT_POW_2 o rand) stms THEN\n EVERY (map2 (fun s v -> SPEC_TAC(s,v)) stms gvs)) (asl,w);;\n\nlet HERON = `!A B C:real^2.\n let a = dist(C,B)\n and b = dist(A,C)\n and c = dist(B,A) in\n let s = (a + b + c) / &2 in\n measure(convex hull {A,B,C}) = sqrt(s * (s - a) * (s - b) * (s - c))`;;" }, { "theorem_id": 46, "title": "057_heron_s_formula", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Basic Properties of Triangles\\\ntheory Triangle\nimports\n Angles\nbegin\n\ntext \\\n We prove a number of basic geometric properties of triangles. All theorems hold\n in any real inner product space.\n\\\nsubsection \\Thales' theorem\\\n\ntheorem thales:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"dist B (midpoint A C) = dist A C / 2\"\n shows \"orthogonal (A - B) (C - B)\"\n by sorry\n\nsubsection \\Sine and cosine laws\\\n\ntext \\\n The proof of the Law of Cosines follows trivially from the definition of the angle,\n the definition of the norm in vector spaces with an inner product and the bilinearity\n of the inner product.\n\\\n\nlemma cosine_law_vector:\n \"norm (u - v) ^ 2 = norm u ^ 2 + norm v ^ 2 - 2 * norm u * norm v * cos (vangle u v)\"\n by sorry\n\nlemma cosine_law_triangle:\n \"dist b c ^ 2 = dist a b ^ 2 + dist a c ^ 2 - 2 * dist a b * dist a c * cos (angle b a c)\"\n by sorry\n\ntext \\\n According to our definition, angles are always between $0$ and $\\pi$ and therefore,\n the sign of an angle is always non-negative. We can therefore look at\n $\\sin(\\alpha)^2$, which we can express in terms of $\\cos(\\alpha)$ using the\n identity $\\sin(\\alpha)^2 + \\cos(\\alpha)^2 = 1$. The remaining proof is then a\n trivial consequence of the definitions.\n\\\nlemma sine_law_triangle:\n \"sin (angle a b c) * dist b c = sin (angle b a c) * dist a c\" (is \"?A = ?B\")\n by sorry\n\ntext \\\n The following forms of the Law of Sines/Cosines are more convenient for eliminating\n sines/cosines from a goal completely.\n\\\n\nlemma cosine_law_triangle':\n \"2 * dist a b * dist a c * cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2)\"\n by sorry\n\nlemma cosine_law_triangle'':\n \"cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2) / (2 * dist a b * dist a c)\"\n by sorry\n\nlemma sine_law_triangle':\n \"b \\ c \\ sin (angle a b c) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nlemma sine_law_triangle'':\n \"b \\ c \\ sin (angle c b a) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nsubsection \\Sum of angles\\\n\ncontext\nbegin\n\nprivate lemma gather_squares: \"a * (a * b) = a^2 * (b :: real)\"\n by (simp_all add: power2_eq_square)\n\nprivate lemma eval_power: \"x ^ numeral n = x * x ^ pred_numeral n\"\n by (subst numeral_eq_Suc, subst power_Suc) simp\n\ntext \\\n The proof that the sum of the angles in a triangle is $\\pi$ is somewhat more\n involved. Following the HOL Light proof by John Harrison, we first prove\n that $\\cos(\\alpha + \\beta + \\gamma) = -1$ and $\\alpha + \\beta + \\gamma \\in [0;3\\pi)$,\n which then implies the theorem.\n\n The main work is proving $\\cos(\\alpha + \\beta + \\gamma)$. This is done using the\n addition theorems for the sine and cosine, then using the Laws of Sines to eliminate\n all $\\sin$ terms save $\\sin(\\gamma)^2$, which only appears squared in the remaining goal.\n We then use $\\sin(\\gamma)^2 = 1 - \\cos(\\gamma)^2$ to eliminate this term and apply\n the law of cosines to eliminate this term as well.\n\n The remaining goal is a non-linear equation containing only the length of the sides\n of the triangle. It can be shown by simple algebraic rewriting.\n\\\nlemma angle_sum_triangle:\n assumes \"a \\ b \\ b \\ c \\ a \\ c\"\n shows \"angle c a b + angle a b c + angle b c a = pi\"\n by sorry\n\nend\n\nsubsection \\Congruence Theorems\\\n\ntext \\\n If two triangles agree on two angles at a non-degenerate side, the third angle\n must also be equal.\n\\\nlemma similar_triangle_aa:\n assumes \"b1 \\ c1\" \"b2 \\ c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n shows \"angle b1 a1 c1 = angle b2 a2 c2\"\n by sorry\n\ntext \\\n A triangle is defined by its three angles and the lengths of three sides up to congruence.\n Two triangles are congruent if they have their angles are the same and their sides have\n the same length.\n\\\n\nlocale congruent_triangle =\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes sides': \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n and angles': \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\"\n \"angle a1 c1 b1 = angle a2 c2 b2\"\nbegin\n\nlemma sides:\n \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n \"dist b1 a1 = dist a2 b2\" \"dist c1 a1 = dist a2 c2\" \"dist c1 b1 = dist b2 c2\"\n \"dist a1 b1 = dist b2 a2\" \"dist a1 c1 = dist c2 a2\" \"dist b1 c1 = dist c2 b2\"\n \"dist b1 a1 = dist b2 a2\" \"dist c1 a1 = dist c2 a2\" \"dist c1 b1 = dist c2 b2\"\n by sorry\n\nlemma angles:\n \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\" \"angle a1 c1 b1 = angle a2 c2 b2\"\n \"angle c1 a1 b1 = angle b2 a2 c2\" \"angle c1 b1 a1 = angle a2 b2 c2\" \"angle b1 c1 a1 = angle a2 c2 b2\"\n \"angle b1 a1 c1 = angle c2 a2 b2\" \"angle a1 b1 c1 = angle c2 b2 a2\" \"angle a1 c1 b1 = angle b2 c2 a2\"\n \"angle c1 a1 b1 = angle c2 a2 b2\" \"angle c1 b1 a1 = angle c2 b2 a2\" \"angle b1 c1 a1 = angle b2 c2 a2\"\n by sorry\n\nend\n\nlemmas congruent_triangleD = congruent_triangle.sides congruent_triangle.angles\n\ntext \\\n Given two triangles that agree on a subset of its side lengths and angles that are\n sufficient to define a triangle uniquely up to congruence, one can conclude that they\n must also agree on all remaining quantities, i.e. that they are congruent.\n\n The following four congruence theorems state what constitutes such a uniquely-defining\n subset of quantities. Each theorem states in its name which quantities are required and\n in which order (clockwise or counter-clockwise): an ``s'' stands for a side,\n an ``a'' stands for an angle.\n\n The lemma ``congruent-triangleI-sas, for example, requires that two adjacent sides and the\n angle inbetween are the same in both triangles.\n\\\n\nlemma congruent_triangleI_sss:\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"dist a1 c1 = dist a2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sss = congruent_triangleD[OF congruent_triangleI_sss]\n\nlemma congruent_triangleI_sas:\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sas = congruent_triangleD[OF congruent_triangleI_sas]\n\nlemma congruent_triangleI_aas:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"\\collinear {a1,b1,c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_aas = congruent_triangleD[OF congruent_triangleI_aas]\n\nlemma congruent_triangleI_asa:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"angle b1 a1 c1 = angle b2 a2 c2\"\n assumes \"\\collinear {a1, b1, c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_asa = congruent_triangleD[OF congruent_triangleI_asa]\n\nsubsection \\Isosceles Triangle Theorem\\\n\ntext \\\n We now prove the Isosceles Triangle Theorem: in a triangle where two sides have\n the same length, the two angles that are adjacent to only one of the two sides\n must be equal.\n\\\nlemma isosceles_triangle:\n assumes \"dist a c = dist b c\"\n shows \"angle b a c = angle a b c\"\n by sorry\n\ntext \\\n For the non-degenerate case (i.e. the three points are not collinear), We also\n prove the converse.\n\\\nlemma isosceles_triangle_converse:\n assumes \"angle a b c = angle b a c\" \"\\collinear {a,b,c}\"\n shows \"dist a c = dist b c\"\n by sorry\n\nsubsection\\Contributions by Lukas Bulwahn\\\n \nlemma Pythagoras:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"orthogonal (A - C) (B - C)\"\n shows \"(dist B C) ^ 2 + (dist C A) ^ 2 = (dist A B) ^ 2\"\n by sorry\n\nlemma isosceles_triangle_orthogonal_on_midpoint:\n fixes A B C :: \"'a :: euclidean_space\"\n assumes \"dist C A = dist C B\"\n shows \"orthogonal (C - midpoint A B) (A - midpoint A B)\"\n by sorry\n\nend" }, { "theorem_id": 46, "title": "057_heron_s_formula", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2021 Matt Kempster. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Matt Kempster\n-/\nimport Mathlib.Geometry.Euclidean.Triangle\n\n/-!\n# Freek № 57: Heron's Formula\n\nThis file proves Theorem 57 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/),\nalso known as Heron's formula, which gives the area of a triangle based only on its three sides'\nlengths.\n\n## References\n\n* https://en.wikipedia.org/wiki/Herons_formula\n\n-/\n\n\nopen Real EuclideanGeometry\n\nopen scoped Real EuclideanGeometry\n\nnamespace Theorems100\n\nlocal notation \"√\" => Real.sqrt\n\nvariable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]\n [NormedAddTorsor V P]\n\n/-- **Heron's formula**: The area of a triangle with side lengths `a`, `b`, and `c` is\n `√(s * (s - a) * (s - b) * (s - c))` where `s = (a + b + c) / 2` is the semiperimeter.\n We show this by equating this formula to `a * b * sin γ`, where `γ` is the angle opposite\n the side `c`.\n-/\ntheorem heron {p₁ p₂ p₃ : P} (h1 : p₁ ≠ p₂) (h2 : p₃ ≠ p₂) :\n let a := dist p₁ p₂\n let b := dist p₃ p₂\n let c := dist p₁ p₃\n let s := (a + b + c) / 2\n 1 / 2 * a * b * sin (∠ p₁ p₂ p₃) = √(s * (s - a) * (s - b) * (s - c)) := by sorry\nend Theorems100\n" }, { "theorem_id": 46, "title": "057_heron_s_formula", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Export euclidean_constructions.\nRequire Export area_elimination_lemmas.\nRequire Export ratios_elimination_lemmas.\n\nLemma l_24_a : forall A B P D,\nCol A D B -> perp A B P D ->\nA<>B -> B<>D ->\n A**D / D**B = Py P A B / Py P B A.\nProof.\nAdmitted.\n\nLemma perp4_perp : forall A B P, \nperp A B P A -> Py P A B = 0.\nProof.\nAdmitted.\n\nLemma perp_not_eq_not_perp : forall A B P D, perp A B P D ->\nCol A D B ->\n A <> B -> B <> D -> A <> D -> \nPy P A B <> 0.\nProof.\nAdmitted.\n\nLemma l_24_b : forall A B P D,\nCol A D B -> perp A B P D ->\nA<>B -> \n A**D / A**B = Py P A B / (2 * A**B * A**B).\nProof.\nAdmitted.\n\nLemma l_24_c : forall A B P D,\nCol A D B -> perp A B P D ->\nA<>B -> \n D**B / A**B = Py P B A / (2 * A**B * A**B).\nProof.\nAdmitted.\n\nLemma l_24_c_on_foot : forall P U V Y,\non_foot Y P U V ->\nU**Y / U**V = Py P U V / Py U V U.\nProof.\nAdmitted.\n\nLemma per_area: forall A B C,\n per A B C -> \n 2 * 2 * S A B C * S A B C = A**B * A**B * B**C * B**C.\nProof.\nAdmitted.\n\nLemma per_col_eq : forall A B C,\n per A B C -> Col A B C -> A = B \\/ B = C.\nProof.\nAdmitted.\n\nLemma perp_col_perp : forall P Q B C,\n Q<>B ->\n per P Q B -> Col Q B C -> per P Q C.\nProof.\nAdmitted.\n\nLemma l_3_4 : forall A B C P,\n Col A B C -> Py P A C <> 0 ->\n Py P A B / Py P A C = A**B/ A**C.\nProof.\nAdmitted.\n\nRequire Export Classical.\n\nLemma per_dec : forall A B C,\n per A B C \\/ ~ per A B C.\nProof.\nAdmitted.\n\nLtac cases_per A B C := elim (per_dec A B C);intros.\n\nLemma l_3_4_b : forall A B C P,\n Col A B C ->\n Py P A B * A**C = Py P A C * A**B.\nProof.\nAdmitted.\n\nLemma l_28_b : forall A B U V Y,\nU <> V ->\nCol Y U V -> \nPy A B Y = U**Y/U**V * Py A B V + Y**V/U**V * Py A B U.\nProof.\nAdmitted.\n\nLemma l3_5_py : forall A B U V Y,\n U <> V ->\n Col Y U V -> \n Py A Y B = U**Y / U**V * Py A V B + Y**V/ U**V * Py A U B \n - (U**Y/ U**V) * (Y**V / U**V) * Py U V U.\nProof.\nAdmitted.\n\nLemma midpoint_ratio_1 : forall O B D,\nmid_point O B D -> B<>D -> B ** O / B ** D = 1/2.\nProof.\nAdmitted.\n\nLemma midpoint_ratio_2 : forall O B D,\nmid_point O B D -> B<>D -> O ** D / B ** D = 1/2.\nProof.\nAdmitted.\n\nLemma l_28_midpoint : forall O A B P Q,\n mid_point O A B ->\n 2 * Py O P Q = Py A P Q + Py B P Q.\nProof.\nAdmitted.\n\nLemma l_28_b_midpoint : forall O A B P Q,\n mid_point O A B ->\n 2 * Py P O Q = Py P A Q + Py P B Q - 1/ 2 * Py A B A.\nProof.\nAdmitted.\n\nLemma l_27_a : forall A B C D P Q, weak_3_parallelogram A B C D ->\nPy A P Q + Py C P Q = Py B P Q + Py D P Q.\nProof.\nAdmitted.\n\nLemma l_27_b : forall A B C D P Q, weak_3_parallelogram A B C D ->\nPy4 A P B Q = Py4 D P C Q.\nProof.\nAdmitted.\n\nLemma midpoint_is_midpoint: forall I A B, \n mid_point I A B -> A<>B -> is_midpoint I A B.\nProof.\nAdmitted.\n\nLemma midpoint_on_line_d: forall I A B, \n mid_point I A B -> A<>B -> on_line_d A I B (0-1).\nProof.\nAdmitted.\n\nLemma symmetric_point_unicity : forall O B C D, \n mid_point O B D ->\n mid_point O D C ->\n B=C.\nProof.\nAdmitted.\n\nLemma weak_3_parallelogram_parallel : forall A B C D,\n weak_3_parallelogram A B C D -> parallel B C A D.\nProof.\nAdmitted.\n\nLemma eq_half_eq_zero : forall x : F, x = 1/2 * x -> x=0.\nProof.\nAdmitted.\n\nLemma weak_3_parallelogram_eq_side : forall A B C D,\n weak_3_parallelogram A B C D -> B**C= A**D.\nProof.\nAdmitted.\n\nLemma l3_6 : forall A B C D, \n weak_3_parallelogram A B C D ->\n A**C * A**C + B**D * B**D = 2*A**B * A**B + 2*B**C*B**C.\nProof.\nAdmitted.\n\nLemma l3_6_b : forall A B C D, \n weak_3_parallelogram A B C D ->\n Py A B C = - Py B A D.\nProof.\nAdmitted.\n\nLemma l_27_c : forall A B C D P Q, weak_3_parallelogram A B C D ->\nPy P A Q + Py P C Q = Py P B Q + Py P D Q + 2 * Py B A D.\nProof.\nAdmitted.\n\nLemma l3_8_a : forall A B C D P, weak_3_parallelogram A B C D ->\nPy P A B = Py4 P D A C.\nProof.\nAdmitted.\n\nLemma l3_8_b : forall A B C D P, weak_3_parallelogram A B C D ->\nPy P A B = Py P D C - Py A D C.\nProof.\nAdmitted.\n\nLemma l_28_a : forall A B U V Y,\nCol Y U V -> U <> V ->\nS A B Y = U**Y/U**V * S A B V + Y**V/U**V * S A B U.\nProof.\nAdmitted.\n\nLemma on_foot_per : forall A B C F, \n on_foot F A B C ->\n per A F B.\nProof.\nAdmitted.\n\nLemma herron_qin : forall A B C,\nS A B C * S A B C = 1 / (2*2*2*2) * (Py A B A * Py A C A - Py B A C * Py B A C).\nProof.\nAdmitted.\n\nLemma l3_9_aux : forall B D P Q R S Y ,\n Col Y B D ->\n B<>D ->\n B ** Y = Q ** S ->\n weak_3_parallelogram B Y S Q ->\n Py4 P Q R S = Q ** S / B ** D * Py4 P B R D.\nProof.\nAdmitted.\n\nLemma l3_9 : forall P Q R S A B C D,\n parallel P R A C ->\n parallel Q S B D ->\n B<>D -> A<>C -> ~ perp A C B D ->\n Py4 P Q R S / Py4 A B C D = (P**R / A**C) * (Q**S / B**D).\nProof.\nAdmitted.\n\nLemma l3_10 : forall A B C D,\n parallel A B C D ->\n C<>D ->\n A**B/C**D = Py4 A C B D / - Py C D C.\nProof.\nAdmitted.\n\nLemma l3_10b : forall A B C D,\n parallel A B C D ->\n C<>D ->\n A**B/C**D = Py4 B C A D / Py C D C.\nProof.\nAdmitted.\n\nLemma perp_not_parallel : forall A B C D,\n perp A B C D ->\n A <> B -> C <> D ->\n ~ parallel A B C D.\nProof.\nAdmitted.\n\nLemma not_perp_to_itself : forall A B,\nA <> B ->~ perp A B A B.\nProof.\nAdmitted.\n\nLemma parallel_not_perp : forall A B C D,\n parallel A B C D ->\n A <> B -> C <> D ->\n ~ perp A B C D.\nProof.\nAdmitted.\n\nLemma l_25_a : forall A B P Q Y,\n P<>Q -> Q<>Y -> Py Q A B <> 0 ->\n on_inter_line_perp Y A P Q A B ->\n P**Y / Q**Y = Py P A B / Py Q A B.\nProof.\nAdmitted.\n\nLemma l_25_b : forall A B P Q Y,\n P<>Q -> Q<>Y -> Py Q A B <> 0 ->\n on_inter_line_perp Y A P Q A B ->\n P**Y / P**Q = Py P A B / Py4 P A Q B.\nProof.\nAdmitted.\n\nLemma l_25_c : forall A B P Q Y,\n P<>Q -> Q<>Y -> Py Q A B <> 0 ->\n on_inter_line_perp Y A P Q A B ->\n Q**Y / P**Q = Py Q A B / Py4 P A Q B.\nProof.\nAdmitted." }, { "theorem_id": 47, "title": "058_formula_for_the_number_of_combinations", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/binomial.ml\";;\n\nlet NUMBER_OF_COMBINATIONS = `!n m s:A->bool.\n s HAS_SIZE n\n ==> {t | t SUBSET s /\\ t HAS_SIZE m} HAS_SIZE binom(n,m)`;;\n\nlet NUMBER_OF_COMBINATIONS_EXPLICIT = `!n m s:A->bool.\n s HAS_SIZE n\n ==> {t | t SUBSET s /\\ t HAS_SIZE m} HAS_SIZE\n (if n < m then 0 else FACT(n) DIV (FACT(m) * FACT(n - m)))`;;" }, { "theorem_id": 47, "title": "058_formula_for_the_number_of_combinations", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Binomial Coefficients, Binomial Theorem, Inclusion-exclusion Principle\\\n\ntheory Binomial\n imports Presburger Factorial\nbegin\n\nsubsection \\Binomial coefficients\\\n\ntext \\This development is based on the work of Andy Gordon and Florian Kammueller.\\\n\ntext \\Combinatorial definition\\\n\ndefinition binomial :: \"nat \\ nat \\ nat\"\n where \"binomial n k = card {K\\Pow {0..choose\\ 64)\nend\n\nlemma binomial_right_mono:\n assumes \"m \\ n\" shows \"m choose k \\ n choose k\"\n by sorry\n\ntheorem n_subsets:\n assumes \"finite A\"\n shows \"card {B. B \\ A \\ card B = k} = card A choose k\"\n by sorry\n\ntext \\Recursive characterization\\\n\nlemma binomial_n_0 [simp]: \"n choose 0 = 1\"\n by sorry\n\nlemma binomial_0_Suc [simp]: \"0 choose Suc k = 0\"\n by sorry\n\nlemma binomial_Suc_Suc [simp]: \"Suc n choose Suc k = (n choose k) + (n choose Suc k)\"\n by sorry\n\nlemma binomial_eq_0: \"n < k \\ n choose k = 0\"\n by sorry\n\nlemma zero_less_binomial: \"k \\ n \\ n choose k > 0\"\n by sorry\n\nlemma binomial_eq_0_iff [simp]: \"n choose k = 0 \\ n < k\"\n by sorry\n\nlemma zero_less_binomial_iff [simp]: \"n choose k > 0 \\ k \\ n\"\n by sorry\n\nlemma binomial_n_n [simp]: \"n choose n = 1\"\n by sorry\n\nlemma binomial_Suc_n [simp]: \"Suc n choose n = Suc n\"\n by sorry\n\nlemma binomial_1 [simp]: \"n choose Suc 0 = n\"\n by sorry\n\nlemma choose_one: \"n choose 1 = n\" for n :: nat\n by sorry\n\nlemma choose_reduce_nat:\n \"0 < n \\ 0 < k \\\n n choose k = ((n - 1) choose (k - 1)) + ((n - 1) choose k)\"\n by sorry\n\nlemma Suc_times_binomial_eq: \"Suc n * (n choose k) = (Suc n choose Suc k) * Suc k\"\n by sorry\n\nlemma binomial_le_pow2: \"n choose k \\ 2^n\"\n by sorry\n\ntext \\The absorption property.\\\nlemma Suc_times_binomial: \"Suc k * (Suc n choose Suc k) = Suc n * (n choose k)\"\n by sorry\n\ntext \\This is the well-known version of absorption, but it's harder to use\n because of the need to reason about division.\\\nlemma binomial_Suc_Suc_eq_times: \"(Suc n choose Suc k) = (Suc n * (n choose k)) div Suc k\"\n by sorry\n\ntext \\Another version of absorption, with \\-1\\ instead of \\Suc\\.\\\nlemma times_binomial_minus1_eq: \"0 < k \\ k * (n choose k) = n * ((n - 1) choose (k - 1))\"\n by sorry\n\nsubsection \\The binomial theorem (courtesy of Tobias Nipkow):\\\n\ntext \\Avigad's version, generalized to any commutative ring\\\ntheorem (in comm_semiring_1) binomial_ring:\n \"(a + b :: 'a)^n = (\\k\\n. (of_nat (n choose k)) * a^k * b^(n-k))\"\n by sorry\n\ntext \\Original version for the naturals.\\\ncorollary binomial: \"(a + b :: nat)^n = (\\k\\n. (of_nat (n choose k)) * a^k * b^(n - k))\"\n by sorry\n\nlemma binomial_fact_lemma: \"k \\ n \\ fact k * fact (n - k) * (n choose k) = fact n\"\n by sorry\n\nlemma binomial_fact':\n assumes \"k \\ n\"\n shows \"n choose k = fact n div (fact k * fact (n - k))\"\n by sorry\n\nlemma binomial_fact:\n assumes kn: \"k \\ n\"\n shows \"(of_nat (n choose k) :: 'a::field_char_0) = fact n / (fact k * fact (n - k))\"\n by sorry\n\nlemma fact_binomial:\n assumes \"k \\ n\"\n shows \"fact k * of_nat (n choose k) = (fact n / fact (n - k) :: 'a::field_char_0)\"\n by sorry\n\nlemma binomial_fact_pow: \"(n choose s) * fact s \\ n^s\"\n by sorry\n\nlemma choose_two: \"n choose 2 = n * (n - 1) div 2\"\n by sorry\n\nlemma choose_row_sum: \"(\\k\\n. n choose k) = 2^n\"\n by sorry\n\nlemma sum_choose_lower: \"(\\k\\n. (r+k) choose k) = Suc (r+n) choose n\"\n by sorry\n\nlemma sum_choose_upper: \"(\\k\\n. k choose m) = Suc n choose Suc m\"\n by sorry\n\nlemma choose_alternating_sum:\n \"n > 0 \\ (\\i\\n. (-1)^i * of_nat (n choose i)) = (0 :: 'a::comm_ring_1)\"\n by sorry\n\nlemma choose_even_sum:\n assumes \"n > 0\"\n shows \"2 * (\\i\\n. if even i then of_nat (n choose i) else 0) = (2 ^ n :: 'a::comm_ring_1)\"\n by sorry\n\nlemma choose_odd_sum:\n assumes \"n > 0\"\n shows \"2 * (\\i\\n. if odd i then of_nat (n choose i) else 0) = (2 ^ n :: 'a::comm_ring_1)\"\n by sorry\n\ntext\\NW diagonal sum property\\\nlemma sum_choose_diagonal:\n assumes \"m \\ n\"\n shows \"(\\k\\m. (n - k) choose (m - k)) = Suc n choose m\"\n by sorry\n\nsubsection \\Generalized binomial coefficients\\\n\ndefinition gbinomial :: \"'a::{semidom_divide,semiring_char_0} \\ nat \\ 'a\" (infix \\gchoose\\ 64)\n where gbinomial_prod_rev: \"a gchoose k = (\\i=0..i. a - of_nat i) {0..k} div fact (Suc k)\"\n by sorry\n\nlemma gbinomial_1 [simp]: \"a gchoose 1 = a\"\n by sorry\n\nlemma gbinomial_Suc0 [simp]: \"a gchoose Suc 0 = a\"\n by sorry\n\nlemma gbinomial_0_left: \"0 gchoose k = (if k = 0 then 1 else 0)\"\n by sorry\n\nlemma gbinomial_mult_fact: \"fact k * (a gchoose k) = (\\i = 0..i = 0..Sign.add_const_constraint (\\<^const_name>\\gbinomial\\, SOME \\<^typ>\\'a::field_char_0 \\ nat \\ 'a\\)\\\n\nlemma gbinomial_mult_1:\n fixes a :: \"'a::field_char_0\"\n shows \"a * (a gchoose k) = of_nat k * (a gchoose k) + of_nat (Suc k) * (a gchoose (Suc k))\"\n (is \"?l = ?r\")\n by sorry\n\nlemma gbinomial_mult_1':\n \"(a gchoose k) * a = of_nat k * (a gchoose k) + of_nat (Suc k) * (a gchoose (Suc k))\"\n for a :: \"'a::field_char_0\"\n by sorry\n\nlemma gbinomial_Suc_Suc: \"(a + 1) gchoose (Suc k) = (a gchoose k) + (a gchoose (Suc k))\"\n for a :: \"'a::field_char_0\"\n by sorry\n\nlemma gbinomial_reduce_nat: \"0 < k \\ a gchoose k = (a-1 gchoose k-1) + (a-1 gchoose k)\"\n for a :: \"'a::field_char_0\"\n by sorry\n\nlemma gchoose_row_sum_weighted:\n \"(\\k = 0..m. (r gchoose k) * (r/2 - of_nat k)) = of_nat(Suc m) / 2 * (r gchoose (Suc m))\"\n for r :: \"'a::field_char_0\"\n by sorry\n\nlemma binomial_symmetric:\n assumes kn: \"k \\ n\"\n shows \"n choose k = n choose (n - k)\"\n by sorry\n\nlemma choose_rising_sum:\n \"(\\j\\m. ((n + j) choose n)) = ((n + m + 1) choose (n + 1))\"\n \"(\\j\\m. ((n + j) choose n)) = ((n + m + 1) choose m)\"\n by sorry\n\nlemma choose_linear_sum: \"(\\i\\n. i * (n choose i)) = n * 2 ^ (n - 1)\"\n by sorry\n\nlemma choose_alternating_linear_sum:\n assumes \"n \\ 1\"\n shows \"(\\i\\n. (-1)^i * of_nat i * of_nat (n choose i) :: 'a::comm_ring_1) = 0\"\n by sorry\n\nlemma vandermonde: \"(\\k\\r. (m choose k) * (n choose (r - k))) = (m + n) choose r\"\n by sorry\n\nlemma choose_square_sum: \"(\\k\\n. (n choose k)^2) = ((2*n) choose n)\"\n by sorry\n\nlemma pochhammer_binomial_sum:\n fixes a b :: \"'a::comm_ring_1\"\n shows \"pochhammer (a + b) n = (\\k\\n. of_nat (n choose k) * pochhammer a k * pochhammer b (n - k))\"\n by sorry\n\ntext \\Contributed by Manuel Eberl, generalised by LCP.\n Alternative definition of the binomial coefficient as \\<^term>\\\\i.\\\nlemma gbinomial_altdef_of_nat: \"a gchoose k = (\\i = 0.. a\"\n shows \"(a / of_nat k :: 'a) ^ k \\ a gchoose k\"\n by sorry\n\nlemma gbinomial_negated_upper: \"(a gchoose k) = (-1) ^ k * ((of_nat k - a - 1) gchoose k)\"\n by sorry\n\nlemma gbinomial_minus: \"((-a) gchoose k) = (-1) ^ k * ((a + of_nat k - 1) gchoose k)\"\n by sorry\n\nlemma Suc_times_gbinomial: \"of_nat (Suc k) * ((a + 1) gchoose (Suc k)) = (a + 1) * (a gchoose k)\"\n by sorry\n\nlemma gbinomial_factors: \"((a + 1) gchoose (Suc k)) = (a + 1) / of_nat (Suc k) * (a gchoose k)\"\n by sorry\n\nlemma gbinomial_rec: \"((a + 1) gchoose (Suc k)) = (a gchoose k) * ((a + 1) / of_nat (Suc k))\"\n by sorry\n\nlemma gbinomial_of_nat_symmetric: \"k \\ n \\ (of_nat n) gchoose k = (of_nat n) gchoose (n - k)\"\n by sorry\n\ntext \\The absorption identity (equation 5.5 \\<^cite>\\\\p.~157\\ in GKP_CM\\):\n\\[\n{r \\choose k} = \\frac{r}{k}{r - 1 \\choose k - 1},\\quad \\textnormal{integer } k \\neq 0.\n\\]\\\nlemma gbinomial_absorption': \"k > 0 \\ a gchoose k = (a / of_nat k) * (a - 1 gchoose (k - 1))\"\n by sorry\n\ntext \\The absorption identity is written in the following form to avoid\ndivision by $k$ (the lower index) and therefore remove the $k \\neq 0$\nrestriction \\<^cite>\\\\p.~157\\ in GKP_CM\\:\n\\[\nk{r \\choose k} = r{r - 1 \\choose k - 1}, \\quad \\textnormal{integer } k.\n\\]\\\nlemma gbinomial_absorption: \"of_nat (Suc k) * (a gchoose Suc k) = a * ((a - 1) gchoose k)\"\n by sorry\n\ntext \\The absorption identity for natural number binomial coefficients:\\\nlemma binomial_absorption: \"Suc k * (n choose Suc k) = n * ((n - 1) choose k)\"\n by sorry\n\ntext \\The absorption companion identity for natural number coefficients,\n following the proof by GKP \\<^cite>\\\\p.~157\\ in GKP_CM\\:\\\nlemma binomial_absorb_comp: \"(n - k) * (n choose k) = n * ((n - 1) choose k)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\ntext \\The generalised absorption companion identity:\\\nlemma gbinomial_absorb_comp: \"(a - of_nat k) * (a gchoose k) = a * ((a - 1) gchoose k)\"\n by sorry\n\nlemma gbinomial_addition_formula:\n \"a gchoose (Suc k) = ((a - 1) gchoose (Suc k)) + ((a - 1) gchoose k)\"\n by sorry\n\nlemma binomial_addition_formula:\n \"0 < n \\ n choose (Suc k) = ((n - 1) choose (Suc k)) + ((n - 1) choose k)\"\n by sorry\n\ntext \\\n Equation 5.9 of the reference material \\<^cite>\\\\p.~159\\ in GKP_CM\\ is a useful\n summation formula, operating on both indices:\n \\[\n \\sum\\limits_{k \\leq n}{r + k \\choose k} = {r + n + 1 \\choose n},\n \\quad \\textnormal{integer } n.\n \\]\n\\\nlemma gbinomial_parallel_sum: \"(\\k\\n. (a + of_nat k) gchoose k) = (a + of_nat n + 1) gchoose n\"\n by sorry\n\nsubsection \\Summation on the upper index\\\n\ntext \\\n Another summation formula is equation 5.10 of the reference material \\<^cite>\\\\p.~160\\ in GKP_CM\\,\n aptly named \\emph{summation on the upper index}:\\[\\sum_{0 \\leq k \\leq n} {k \\choose m} =\n {n + 1 \\choose m + 1}, \\quad \\textnormal{integers } m, n \\geq 0.\\]\n\\\nlemma gbinomial_sum_up_index:\n \"(\\j = 0..n. (of_nat j gchoose k) :: 'a::field_char_0) = (of_nat n + 1) gchoose (k + 1)\"\n by sorry\n\nlemma gbinomial_index_swap:\n \"((-1) ^ k) * ((- (of_nat n) - 1) gchoose k) = ((-1) ^ n) * ((- (of_nat k) - 1) gchoose n)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma gbinomial_sum_lower_neg: \"(\\k\\m. (a gchoose k) * (- 1) ^ k) = (- 1) ^ m * (a - 1 gchoose m)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma gbinomial_partial_row_sum:\n \"(\\k\\m. (a gchoose k) * ((a / 2) - of_nat k)) = ((of_nat m + 1)/2) * (a gchoose (m + 1))\"\n by sorry\n\nlemma sum_bounds_lt_plus1: \"(\\kk=1..mm. f k)\"\n by sorry\n\nlemma gbinomial_partial_sum_poly:\n \"(\\k\\m. (of_nat m + a gchoose k) * x^k * y^(m-k)) =\n (\\k\\m. (-a gchoose k) * (-x)^k * (x + y)^(m-k))\"\n (is \"?lhs m = ?rhs m\")\n by sorry\n\nlemma gbinomial_partial_sum_poly_xpos:\n \"(\\k\\m. (of_nat m + a gchoose k) * x^k * y^(m-k)) =\n (\\k\\m. (of_nat k + a - 1 gchoose k) * x^k * (x + y)^(m-k))\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma binomial_r_part_sum: \"(\\k\\m. (2 * m + 1 choose k)) = 2 ^ (2 * m)\"\n by sorry\n\nlemma gbinomial_r_part_sum: \"(\\k\\m. (2 * (of_nat m) + 1 gchoose k)) = 2 ^ (2 * m)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma gbinomial_sum_nat_pow2:\n \"(\\k\\m. (of_nat (m + k) gchoose k :: 'a::field_char_0) / 2 ^ k) = 2 ^ m\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma gbinomial_trinomial_revision:\n assumes \"k \\ m\"\n shows \"(a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))\"\n by sorry\n\ntext \\Versions of the theorems above for the natural-number version of \"choose\"\\\nlemma binomial_altdef_of_nat:\n \"k \\ n \\ of_nat (n choose k) = (\\i = 0.. n \\ (of_nat n / of_nat k :: 'a) ^ k \\ of_nat (n choose k)\"\n for k n :: nat and x :: \"'a::linordered_field\"\n by sorry\n\nlemma binomial_le_pow:\n assumes \"r \\ n\"\n shows \"n choose r \\ n ^ r\"\n by sorry\n\nlemma choose_dvd:\n assumes \"k \\ n\" shows \"fact k * fact (n - k) dvd (fact n)\"\n by sorry\n\nlemma fact_fact_dvd_fact:\n \"fact k * fact n dvd (fact (k + n))\"\n by sorry\n\nlemma choose_mult_lemma:\n \"((m + r + k) choose (m + k)) * ((m + k) choose k) = ((m + r + k) choose k) * ((m + r) choose m)\"\n (is \"?lhs = _\")\n by sorry\n\ntext \\The \"Subset of a Subset\" identity.\\\nlemma choose_mult:\n \"k \\ m \\ m \\ n \\ (n choose m) * (m choose k) = (n choose k) * ((n - k) choose (m - k))\"\n by sorry\n\nlemma of_nat_binomial_eq_mult_binomial_Suc:\n assumes \"k \\ n\"\n shows \"(of_nat :: (nat \\ ('a :: field_char_0))) (n choose k) = of_nat (n + 1 - k) / of_nat (n + 1) * of_nat (Suc n choose k)\"\n by sorry\n\nsubsection \\More on Binomial Coefficients\\\n\ntext \\The number of nat lists of length \\m\\ summing to \\N\\ is \\<^term>\\(N + m - 1) choose N\\:\\\nlemma card_length_sum_list_rec:\n assumes \"m \\ 1\"\n shows \"card {l::nat list. length l = m \\ sum_list l = N} =\n card {l. length l = (m - 1) \\ sum_list l = N} +\n card {l. length l = m \\ sum_list l + 1 = N}\"\n (is \"card ?C = card ?A + card ?B\")\n by sorry\n\nlemma card_length_sum_list: \"card {l::nat list. size l = m \\ sum_list l = N} = (N + m - 1) choose N\"\n \\ \\by Holden Lee, tidied by Tobias Nipkow\\\n by sorry\n\nlemma card_disjoint_shuffles:\n assumes \"set xs \\ set ys = {}\"\n shows \"card (shuffles xs ys) = (length xs + length ys) choose length xs\"\n by sorry\n\nlemma Suc_times_binomial_add: \"Suc a * (Suc (a + b) choose Suc a) = Suc b * (Suc (a + b) choose a)\"\n \\ \\by Lukas Bulwahn\\\n by sorry\n\nsubsection \\Inclusion-exclusion principle\\\n\ntext \\Ported from HOL Light by lcp\\\n\nlemma Inter_over_Union:\n \"\\ {\\ (\\ x) |x. x \\ S} = \\ {\\ (G ` S) |G. \\x\\S. G x \\ \\ x}\" \n by sorry\n\nlemma subset_insert_lemma:\n \"{T. T \\ (insert a S) \\ P T} = {T. T \\ S \\ P T} \\ {insert a T |T. T \\ S \\ P(insert a T)}\" (is \"?L=?R\")\n by sorry\n\ntext\\Versions for additive real functions, where the additivity applies only to some\n specific subsets (e.g. cardinality of finite sets, measurable sets with bounded measure.\n (From HOL Light)\\\n\nlocale Incl_Excl =\n fixes P :: \"'a set \\ bool\" and f :: \"'a set \\ 'b::ring_1\"\n assumes disj_add: \"\\P S; P T; disjnt S T\\ \\ f(S \\ T) = f S + f T\"\n and empty: \"P{}\"\n and Int: \"\\P S; P T\\ \\ P(S \\ T)\"\n and Un: \"\\P S; P T\\ \\ P(S \\ T)\"\n and Diff: \"\\P S; P T\\ \\ P(S - T)\"\n\nbegin\n\nlemma f_empty [simp]: \"f{} = 0\"\n by sorry\n\nlemma f_Un_Int: \"\\P S; P T\\ \\ f(S \\ T) + f(S \\ T) = f S + f T\"\n by sorry\n\nlemma restricted_indexed:\n assumes \"finite A\" and X: \"\\a. a \\ A \\ P(X a)\"\n shows \"f(\\(X ` A)) = (\\B | B \\ A \\ B \\ {}. (- 1) ^ (card B + 1) * f (\\ (X ` B)))\"\n by sorry\n\nlemma restricted:\n assumes \"finite A\" \"\\a. a \\ A \\ P a\"\n shows \"f(\\ A) = (\\B | B \\ A \\ B \\ {}. (- 1) ^ (card B + 1) * f (\\ B))\"\n by sorry\n\nend\n\nsubsection\\Versions for unrestrictedly additive functions\\\n\nlemma Incl_Excl_UN:\n fixes f :: \"'a set \\ 'b::ring_1\"\n assumes \"\\S T. disjnt S T \\ f(S \\ T) = f S + f T\" \"finite A\"\n shows \"f(\\(G ` A)) = (\\B | B \\ A \\ B \\ {}. (-1) ^ (card B + 1) * f (\\ (G ` B)))\"\n by sorry\n\nlemma Incl_Excl_Union:\n fixes f :: \"'a set \\ 'b::ring_1\"\n assumes \"\\S T. disjnt S T \\ f(S \\ T) = f S + f T\" \"finite A\"\n shows \"f(\\ A) = (\\B | B \\ A \\ B \\ {}. (- 1) ^ (card B + 1) * f (\\ B))\"\n by sorry\n\ntext \\The famous inclusion-exclusion formula for the cardinality of a union\\\nlemma int_card_UNION:\n assumes \"finite A\" \"\\K. K \\ A \\ finite K\"\n shows \"int (card (\\A)) = (\\I | I \\ A \\ I \\ {}. (- 1) ^ (card I + 1) * int (card (\\I)))\"\n by sorry" }, { "theorem_id": 47, "title": "058_formula_for_the_number_of_combinations", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nmodule\n\npublic import Mathlib.Data.Finset.Card\npublic import Mathlib.Data.Finset.Lattice.Union\npublic import Mathlib.Data.Multiset.Powerset\npublic import Mathlib.Data.Set.Pairwise.Lattice\n\n/-!\n# The powerset of a finset\n-/\n\n@[expose] public section\n\n\nnamespace Finset\n\nopen Function Multiset\n\nvariable {α : Type*} {s t : Finset α}\n\n/-! ### powerset -/\n\n\nsection Powerset\n\n/-- When `s` is a finset, `s.powerset` is the finset of all subsets of `s` (seen as finsets). -/\ndef powerset (s : Finset α) : Finset (Finset α) :=\n ⟨(s.1.powerset.pmap Finset.mk) fun _t h => nodup_of_le (mem_powerset.1 h) s.nodup,\n s.nodup.powerset.pmap fun _a _ha _b _hb => congr_arg Finset.val⟩\n\n@[simp, grind =]\ntheorem mem_powerset {s t : Finset α} : s ∈ powerset t ↔ s ⊆ t := by sorry\ntheorem coe_powerset (s : Finset α) :\n (s.powerset : Set (Finset α)) = ((↑) : Finset α → Set α) ⁻¹' (s : Set α).powerset := by sorry\ntheorem empty_mem_powerset (s : Finset α) : ∅ ∈ powerset s := by simp\n\ntheorem mem_powerset_self (s : Finset α) : s ∈ powerset s := by simp\n\n@[aesop safe apply (rule_sets := [finsetNonempty])]\ntheorem powerset_nonempty (s : Finset α) : s.powerset.Nonempty :=\n ⟨∅, empty_mem_powerset _⟩\n\n@[simp]\ntheorem powerset_mono {s t : Finset α} : powerset s ⊆ powerset t ↔ s ⊆ t :=\n ⟨fun h => mem_powerset.1 <| h <| mem_powerset_self _, fun st _u h =>\n mem_powerset.2 <| Subset.trans (mem_powerset.1 h) st⟩\n\ntheorem powerset_injective : Injective (powerset : Finset α → Finset (Finset α)) :=\n .of_eq_imp_le (powerset_mono.1 ·.le)\n\n@[simp]\ntheorem powerset_inj : powerset s = powerset t ↔ s = t :=\n powerset_injective.eq_iff\n\n@[simp]\ntheorem powerset_empty : (∅ : Finset α).powerset = {∅} :=\n rfl\n\n@[simp]\ntheorem powerset_eq_singleton_empty : s.powerset = {∅} ↔ s = ∅ := by sorry\ntheorem image_injOn_powerset_of_injOn {β : Type*} [DecidableEq β] {f : α → β} (H : Set.InjOn f s) :\n Set.InjOn (α := Finset α) (·.image f) s.powerset := by sorry\ntheorem image_surjOn_powerset {β : Type*} [DecidableEq β] {f : α → β} :\n Set.SurjOn (α := Finset α) (·.image f) s.powerset (s.image f).powerset :=\n fun t ht => ⟨{ x ∈ s | f x ∈ t}, by grind⟩\n\ntheorem powerset_image {β : Type*} [DecidableEq β] {f : α → β} :\n (s.image f).powerset = s.powerset.image (·.image f) :=\n ext fun a => ⟨fun _ => mem_image.mpr ⟨{ x ∈ s | f x ∈ a}, by grind⟩, by grind⟩\n\n/-- **Number of Subsets of a Set** -/\n@[simp]\ntheorem card_powerset (s : Finset α) : card (powerset s) = 2 ^ card s :=\n (card_pmap _ _ _).trans (Multiset.card_powerset s.1)\n\ntheorem notMem_of_mem_powerset_of_notMem {s t : Finset α} {a : α} (ht : t ∈ s.powerset)\n (h : a ∉ s) : a ∉ t := by sorry\ntheorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :\n powerset (insert a s) = s.powerset ∪ s.powerset.image (insert a) := by sorry\nlemma pairwiseDisjoint_pair_insert [DecidableEq α] {a : α} (ha : a ∉ s) :\n (s.powerset : Set (Finset α)).PairwiseDisjoint fun t ↦ ({t, insert a t} : Set (Finset α)) := by sorry\ninstance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ t ⊆ s, Prop}\n [∀ (t) (h : t ⊆ s), Decidable (p t h)] : Decidable (∃ (t : _) (h : t ⊆ s), p t h) :=\n decidable_of_iff (∃ (t : _) (hs : t ∈ s.powerset), p t (mem_powerset.1 hs))\n ⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_powerset.2 hs, hp⟩⟩\n\n/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/\ninstance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ t ⊆ s, Prop}\n [∀ (t) (h : t ⊆ s), Decidable (p t h)] : Decidable (∀ (t) (h : t ⊆ s), p t h) :=\n decidable_of_iff (∀ (t) (h : t ∈ s.powerset), p t (mem_powerset.1 h))\n ⟨fun h t hs => h t (mem_powerset.2 hs), fun h _ _ => h _ _⟩\n\n/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/\ninstance decidableExistsOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}\n [∀ t, Decidable (p t)] : Decidable (∃ t ⊆ s, p t) :=\n decidable_of_iff (∃ (t : _) (_h : t ⊆ s), p t) <| by simp\n\n/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/\ninstance decidableForallOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}\n [∀ t, Decidable (p t)] : Decidable (∀ t ⊆ s, p t) :=\n decidable_of_iff (∀ (t : _) (_h : t ⊆ s), p t) <| by simp\n\nend Powerset\n\nsection SSubsets\n\nvariable [DecidableEq α]\n\n/-- For `s` a finset, `s.ssubsets` is the finset comprising strict subsets of `s`. -/\ndef ssubsets (s : Finset α) : Finset (Finset α) :=\n erase (powerset s) s\n\n@[simp, grind =]\ntheorem mem_ssubsets {s t : Finset α} : t ∈ s.ssubsets ↔ t ⊂ s := by sorry\ntheorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets := by sorry\ndef decidableExistsOfDecidableSSubsets {s : Finset α} {p : ∀ t ⊂ s, Prop}\n [∀ t h, Decidable (p t h)] : Decidable (∃ t h, p t h) :=\n decidable_of_iff (∃ (t : _) (hs : t ∈ s.ssubsets), p t (mem_ssubsets.1 hs))\n ⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_ssubsets.2 hs, hp⟩⟩\n\n/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for every ssubset. -/\ndef decidableForallOfDecidableSSubsets {s : Finset α} {p : ∀ t ⊂ s, Prop}\n [∀ t h, Decidable (p t h)] : Decidable (∀ t h, p t h) :=\n decidable_of_iff (∀ (t) (h : t ∈ s.ssubsets), p t (mem_ssubsets.1 h))\n ⟨fun h t hs => h t (mem_ssubsets.2 hs), fun h _ _ => h _ _⟩\n\n/-- A version of `Finset.decidableExistsOfDecidableSSubsets` with a non-dependent `p`.\nTypeclass inference cannot find `hu` here, so this is not an instance. -/\ndef decidableExistsOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}\n (hu : ∀ t ⊂ s, Decidable (p t)) : Decidable (∃ (t : _) (_h : t ⊂ s), p t) :=\n @Finset.decidableExistsOfDecidableSSubsets _ _ _ _ hu\n\n/-- A version of `Finset.decidableForallOfDecidableSSubsets` with a non-dependent `p`.\nTypeclass inference cannot find `hu` here, so this is not an instance. -/\ndef decidableForallOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}\n (hu : ∀ t ⊂ s, Decidable (p t)) : Decidable (∀ t ⊂ s, p t) :=\n @Finset.decidableForallOfDecidableSSubsets _ _ _ _ hu\n\nend SSubsets\n\nsection powersetCard\nvariable {n} {s t : Finset α}\n\n/-- Given an integer `n` and a finset `s`, then `powersetCard n s` is the finset of subsets of `s`\nof cardinality `n`. -/\ndef powersetCard (n : ℕ) (s : Finset α) : Finset (Finset α) :=\n ⟨((s.1.powersetCard n).pmap Finset.mk) fun _t h => nodup_of_le (mem_powersetCard.1 h).1 s.2,\n s.2.powersetCard.pmap fun _a _ha _b _hb => congr_arg Finset.val⟩\n\n@[simp, grind =] lemma mem_powersetCard : s ∈ powersetCard n t ↔ s ⊆ t ∧ card s = n := by sorry\ntheorem powersetCard_mono {n} {s t : Finset α} (h : s ⊆ t) : powersetCard n s ⊆ powersetCard n t :=\n fun _u h' => mem_powersetCard.2 <|\n And.imp (fun h₂ => Subset.trans h₂ h) id (mem_powersetCard.1 h')\n\n/-- **Formula for the Number of Combinations** -/\n@[simp]\ntheorem card_powersetCard (n : ℕ) (s : Finset α) :\n card (powersetCard n s) = Nat.choose (card s) n :=\n (card_pmap _ _ _).trans (Multiset.card_powersetCard n s.1)\n\n@[simp]\ntheorem powersetCard_zero (s : Finset α) : s.powersetCard 0 = {∅} := by sorry\nlemma powersetCard_empty_subsingleton (n : ℕ) :\n (powersetCard n (∅ : Finset α) : Set <| Finset α).Subsingleton := by sorry\ntheorem map_val_val_powersetCard (s : Finset α) (i : ℕ) :\n (s.powersetCard i).val.map Finset.val = s.1.powersetCard i := by sorry\ntheorem powersetCard_one (s : Finset α) :\n s.powersetCard 1 = s.map ⟨_, Finset.singleton_injective⟩ :=\n eq_of_veq <| Multiset.map_injective val_injective <| by simp [Multiset.powersetCard_one]\n\n@[simp]\nlemma powersetCard_eq_empty : powersetCard n s = ∅ ↔ s.card < n := by sorry\ntheorem powersetCard_eq_filter {n} {s : Finset α} :\n powersetCard n s = (powerset s).filter fun x => x.card = n := by sorry\ntheorem powersetCard_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h : x ∉ s) (n : ℕ) :\n powersetCard n.succ (insert x s) =\n powersetCard n.succ s ∪ (powersetCard n s).image (insert x) := by sorry\nlemma powersetCard_nonempty : (powersetCard n s).Nonempty ↔ n ≤ s.card := by sorry\ntheorem powersetCard_self (s : Finset α) : powersetCard s.card s = {s} := by sorry\ntheorem pairwise_disjoint_powersetCard (s : Finset α) :\n Pairwise fun i j => Disjoint (s.powersetCard i) (s.powersetCard j) := fun _i _j hij =>\n Finset.disjoint_left.mpr fun _x hi hj =>\n hij <| (mem_powersetCard.mp hi).2.symm.trans (mem_powersetCard.mp hj).2\n\ntheorem powerset_card_disjiUnion (s : Finset α) :\n Finset.powerset s =\n (range (s.card + 1)).disjiUnion (fun i => powersetCard i s)\n (s.pairwise_disjoint_powersetCard.set_pairwise _) := by sorry\ntheorem powerset_card_biUnion [DecidableEq (Finset α)] (s : Finset α) :\n Finset.powerset s = (range (s.card + 1)).biUnion fun i => powersetCard i s := by sorry\ntheorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :\n (powersetCard n.succ u).sup id = u := by sorry\ntheorem powersetCard_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α) :\n powersetCard n (s.map f) = (powersetCard n s).map (mapEmbedding f).toEmbedding :=\n ext fun t => by\n -- `le_eq_subset` is a dangerous lemma since it turns the type `↪o` into `(· ⊆ ·) ↪r (· ⊆ ·)`,\n -- which makes `simp` have trouble working with `mapEmbedding_apply`.\n simp only [mem_powersetCard, mem_map, RelEmbedding.coe_toEmbedding, mapEmbedding_apply]\n constructor\n · classical\n intro h\n have : map f (filter (fun x => (f x ∈ t)) s) = t := by grind\n refine ⟨_, ?_, this⟩\n rw [← card_map f, this, h.2]; simp\n · rintro ⟨a, ⟨has, rfl⟩, rfl⟩\n simp only [map_subset_map, has, card_map, and_self]\n\nend powersetCard\n\nend Finset\n" }, { "theorem_id": 47, "title": "058_formula_for_the_number_of_combinations", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import FSets MapFunction.\nRequire Import Arith EqNat Euclid ArithRing ZArith.\nSet Implicit Arguments.\nUnset Standard Proposition Elimination Names.\nProof.\nAdmitted.\n\nLemma binomial_rec : forall n k, k<=n -> \n (binomial n k)*(fact k * fact (n-k)) = fact n.\nProof.\nAdmitted.\n\nLemma fact_pos : forall k, fact k > 0.\nProof.\nAdmitted.\n\nLemma binomial_den_pos : forall n k, fact k * fact (n-k) > 0.\nProof.\nAdmitted.\n\nDefinition binomial' n k := \n let (q,_) := quotient (fact k * fact (n-k)) (binomial_den_pos n k) (fact n)\n in q.\n\nLemma binomial_alt : forall n k, k<=n -> \n binomial n k = binomial' n k.\nProof.\nAdmitted.\n\nModule PowerSet (M:S).\n\nModule MM := FSetList.Make M.\n\nModule MM' := MapFunction.MapFunction MM.\n\nModule P := FSetProperties.Properties M.\nModule P' := FSetProperties.OrdProperties M.\nModule F := P.FM.\nModule PEP := FSetEqProperties.EqProperties MM.\nModule PP := PEP.MP.\nModule FF := PP.FM.\nModule ME := OrderedTypeFacts M.E.\n\nInfix \"[=]\" := M.Equal (at level 70, no associativity).\nInfix \"[==]\" := MM.Equal (at level 70, no associativity).\n\nDefinition powerset s := \n M.fold \n (fun (x:M.elt)(ss:MM.t) => MM.union ss (MM'.map (M.add x) ss)) \n s \n (MM.singleton M.empty).\n\nLemma map_add : forall s s' x, MM.\nProof.\nAdmitted.\n\nLemma compat_op_pow :\n compat_op M.\nProof.\nAdmitted.\nHint Resolve compat_op_pow : set.\n\nLemma singleton_empty : forall s, MM.\nProof.\nAdmitted.\n\nLemma powerset_base : forall s, M.\nProof.\nAdmitted.\n\nLemma powerset_step : forall s1 s2 x, P'.\nProof.\nAdmitted.\n\nLemma powerset_is_powerset: \n forall s s', MM.\nProof.\nAdmitted.\n\nLemma powerset_cardinal: \n forall s, MM.\nProof.\nAdmitted.\n\nDefinition powerset_k s k := \n MM.filter (fun s => beq_nat (M.cardinal s) k) (powerset s).\n\nLemma powerset_k_is_powerset_k : forall k s s', \n MM.\nProof.\nAdmitted.\n\nLemma powerset_k_cardinal : forall s k, \n MM.\nProof.\nAdmitted.\n\nDefinition powerset_k' s := \n M.fold \n (fun (x:M.elt)(ff:nat->MM.t)(k:nat) => match k with \n | O => ff 0\n | S k' => MM.union (ff k) (MM'.map (M.add x) (ff k'))\n end) \n s \n (fun k => if k then MM.singleton M.empty else MM.empty).\n\nLemma powerset_k'_is_powerset_k : \n forall s s' k, MM.\nProof.\nAdmitted.\n\nLemma powerset_k_alt : \n forall s k, powerset_k' s k [==] powerset_k s k.\nProof.\nAdmitted.\n\nEnd PowerSet.\n\nOpen Scope positive_scope.\n\nModule P := FSetList.Make Positive_as_OT.\nModule PS := PowerSet P.\nModule PP := PS.MM.\n\nFixpoint interval (n:nat) {struct n} : P.t := match n with \n | O => P.empty\n | S n => P.add (P_of_succ_nat n) (interval n)\n end.\n\nEval vm_compute in P.elements (interval 10).\n\nDefinition powerset_5 := PS.powerset (interval 5).\n\nEval vm_compute in map P.elements (PP.elements powerset_5).\n\nDefinition subsets_size2_in5 := PS.powerset_k' (interval 5) 2. \n\nEval vm_compute in map P.elements (PP.elements subsets_size2_in5)." }, { "theorem_id": 48, "title": "060_bézout_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";;\n\nlet egcd = define\n `egcd(m,n) = if m = 0 then n\n else if n = 0 then m\n else if m <= n then egcd(m,n - m)\n else egcd(m - n,n)`;;\n\nlet EGCD_INVARIANT = `!m n d. d divides egcd(m,n) <=> d divides m /\\ d divides n`;;\n\nlet EGCD_GCD = `!m n. egcd(m,n) = gcd(m,n)`;;\n\nlet EGCD = `!a b. (egcd (a,b) divides a /\\ egcd (a,b) divides b) /\\\n (!e. e divides a /\\ e divides b ==> e divides egcd (a,b))`;;" }, { "theorem_id": 48, "title": "060_bézout_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Greatest common divisor and least common multiple\\\n\ntheory GCD\n imports Groups_List Code_Numeral\nbegin\n\nsubsection \\Abstract bounded quasi semilattices as common foundation\\\n\nlocale bounded_quasi_semilattice = abel_semigroup +\n fixes top :: 'a (\\\\<^bold>\\\\) and bot :: 'a (\\\\<^bold>\\\\)\n and normalize :: \"'a \\ 'a\"\n assumes idem_normalize [simp]: \"a \\<^bold>* a = normalize a\"\n and normalize_left_idem [simp]: \"normalize a \\<^bold>* b = a \\<^bold>* b\"\n and normalize_idem [simp]: \"normalize (a \\<^bold>* b) = a \\<^bold>* b\"\n and normalize_top [simp]: \"normalize \\<^bold>\\ = \\<^bold>\\\"\n and normalize_bottom [simp]: \"normalize \\<^bold>\\ = \\<^bold>\\\"\n and top_left_normalize [simp]: \"\\<^bold>\\ \\<^bold>* a = normalize a\"\n and bottom_left_bottom [simp]: \"\\<^bold>\\ \\<^bold>* a = \\<^bold>\\\"\nbegin\n\nlemma left_idem [simp]:\n \"a \\<^bold>* (a \\<^bold>* b) = a \\<^bold>* b\"\n by sorry\n\nlemma right_idem [simp]:\n \"(a \\<^bold>* b) \\<^bold>* b = a \\<^bold>* b\"\n by sorry\n\nlemma comp_fun_idem: \"comp_fun_idem f\"\n by sorry\n\ninterpretation comp_fun_idem f\n by (fact comp_fun_idem)\n\nlemma top_right_normalize [simp]:\n \"a \\<^bold>* \\<^bold>\\ = normalize a\"\n by sorry\n\nlemma bottom_right_bottom [simp]:\n \"a \\<^bold>* \\<^bold>\\ = \\<^bold>\\\"\n by sorry\n\nlemma normalize_right_idem [simp]:\n \"a \\<^bold>* normalize b = a \\<^bold>* b\"\n by sorry\n\nend\n\nlocale bounded_quasi_semilattice_set = bounded_quasi_semilattice\nbegin\n\ninterpretation comp_fun_idem f\n by (fact comp_fun_idem)\n\ndefinition F :: \"'a set \\ 'a\"\nwhere\n eq_fold: \"F A = (if finite A then Finite_Set.fold f \\<^bold>\\ A else \\<^bold>\\)\"\n\nlemma infinite [simp]:\n \"infinite A \\ F A = \\<^bold>\\\"\n by sorry\n\nlemma set_eq_fold [code]:\n \"F (set xs) = fold f xs \\<^bold>\\\"\n by sorry\n\nlemma empty [simp]:\n \"F {} = \\<^bold>\\\"\n by sorry\n\nlemma insert [simp]:\n \"F (insert a A) = a \\<^bold>* F A\"\n by sorry\n\nlemma normalize [simp]:\n \"normalize (F A) = F A\"\n by sorry\n\nlemma in_idem:\n assumes \"a \\ A\"\n shows \"a \\<^bold>* F A = F A\"\n by sorry\n\nlemma union:\n \"F (A \\ B) = F A \\<^bold>* F B\"\n by sorry\n\nlemma remove:\n assumes \"a \\ A\"\n shows \"F A = a \\<^bold>* F (A - {a})\"\n by sorry\n\nlemma insert_remove:\n \"F (insert a A) = a \\<^bold>* F (A - {a})\"\n by sorry\n\nlemma subset:\n assumes \"B \\ A\"\n shows \"F B \\<^bold>* F A = F A\"\n by sorry\n\nend\n\nsubsection \\Abstract GCD and LCM\\\n\nclass gcd = zero + one + dvd +\n fixes gcd :: \"'a \\ 'a \\ 'a\"\n and lcm :: \"'a \\ 'a \\ 'a\"\n\nclass Gcd = gcd +\n fixes Gcd :: \"'a set \\ 'a\"\n and Lcm :: \"'a set \\ 'a\"\n\nsyntax\n \"_GCD1\" :: \"pttrns \\ 'b \\ 'b\" (\\(\\indent=3 notation=\\binder GCD\\\\GCD _./ _)\\ [0, 10] 10)\n \"_GCD\" :: \"pttrn \\ 'a set \\ 'b \\ 'b\" (\\(\\indent=3 notation=\\binder GCD\\\\GCD _\\_./ _)\\ [0, 0, 10] 10)\n \"_LCM1\" :: \"pttrns \\ 'b \\ 'b\" (\\(\\indent=3 notation=\\binder LCM\\\\LCM _./ _)\\ [0, 10] 10)\n \"_LCM\" :: \"pttrn \\ 'a set \\ 'b \\ 'b\" (\\(\\indent=3 notation=\\binder LCM\\\\LCM _\\_./ _)\\ [0, 0, 10] 10)\n\nsyntax_consts\n \"_GCD1\" \"_GCD\" \\ Gcd and\n \"_LCM1\" \"_LCM\" \\ Lcm\n\ntranslations\n \"GCD x y. f\" \\ \"GCD x. GCD y. f\"\n \"GCD x. f\" \\ \"CONST Gcd (CONST range (\\x. f))\"\n \"GCD x\\A. f\" \\ \"CONST Gcd ((\\x. f) ` A)\"\n \"LCM x y. f\" \\ \"LCM x. LCM y. f\"\n \"LCM x. f\" \\ \"CONST Lcm (CONST range (\\x. f))\"\n \"LCM x\\A. f\" \\ \"CONST Lcm ((\\x. f) ` A)\"\n\nclass semiring_gcd = normalization_semidom + gcd +\n assumes gcd_dvd1 [iff]: \"gcd a b dvd a\"\n and gcd_dvd2 [iff]: \"gcd a b dvd b\"\n and gcd_greatest: \"c dvd a \\ c dvd b \\ c dvd gcd a b\"\n and normalize_gcd [simp]: \"normalize (gcd a b) = gcd a b\"\n and lcm_gcd: \"lcm a b = normalize (a * b div gcd a b)\"\nbegin\n\nlemma gcd_greatest_iff [simp]: \"a dvd gcd b c \\ a dvd b \\ a dvd c\"\n by sorry\n\nlemma gcd_dvdI1: \"a dvd c \\ gcd a b dvd c\"\n by sorry\n\nlemma gcd_dvdI2: \"b dvd c \\ gcd a b dvd c\"\n by sorry\n\nlemma dvd_gcdD1: \"a dvd gcd b c \\ a dvd b\"\n by sorry\n\nlemma dvd_gcdD2: \"a dvd gcd b c \\ a dvd c\"\n by sorry\n\nlemma gcd_0_left [simp]: \"gcd 0 a = normalize a\"\n by sorry\n\nlemma gcd_0_right [simp]: \"gcd a 0 = normalize a\"\n by sorry\n\nlemma gcd_eq_0_iff [simp]: \"gcd a b = 0 \\ a = 0 \\ b = 0\"\n (is \"?P \\ ?Q\")\n by sorry\n\nlemma unit_factor_gcd: \"unit_factor (gcd a b) = (if a = 0 \\ b = 0 then 0 else 1)\"\n by sorry\n\nlemma is_unit_gcd_iff [simp]:\n \"is_unit (gcd a b) \\ gcd a b = 1\"\n by sorry\n\nsublocale gcd: abel_semigroup gcd\nproof\n fix a b c\n show \"gcd a b = gcd b a\"\n by (rule associated_eqI) simp_all\n from gcd_dvd1 have \"gcd (gcd a b) c dvd a\"\n by (rule dvd_trans) simp\n moreover from gcd_dvd1 have \"gcd (gcd a b) c dvd b\"\n by (rule dvd_trans) simp\n ultimately have P1: \"gcd (gcd a b) c dvd gcd a (gcd b c)\"\n by (auto intro!: gcd_greatest)\n from gcd_dvd2 have \"gcd a (gcd b c) dvd b\"\n by (rule dvd_trans) simp\n moreover from gcd_dvd2 have \"gcd a (gcd b c) dvd c\"\n by (rule dvd_trans) simp\n ultimately have P2: \"gcd a (gcd b c) dvd gcd (gcd a b) c\"\n by (auto intro!: gcd_greatest)\n from P1 P2 show \"gcd (gcd a b) c = gcd a (gcd b c)\"\n by (rule associated_eqI) simp_all\nqed\n\nsublocale gcd: bounded_quasi_semilattice gcd 0 1 normalize\nproof\n show \"gcd a a = normalize a\" for a\n proof -\n have \"a dvd gcd a a\"\n by (rule gcd_greatest) simp_all\n then show ?thesis\n by (auto intro: associated_eqI)\n qed\n show \"gcd (normalize a) b = gcd a b\" for a b\n using gcd_dvd1 [of \"normalize a\" b]\n by (auto intro: associated_eqI)\n show \"gcd 1 a = 1\" for a\n by (rule associated_eqI) simp_all\nqed simp_all\n\nlemma gcd_self: \"gcd a a = normalize a\"\n by sorry\n\nlemma gcd_left_idem: \"gcd a (gcd a b) = gcd a b\"\n by sorry\n\nlemma gcd_right_idem: \"gcd (gcd a b) b = gcd a b\"\n by sorry\n\nlemma gcdI:\n assumes \"c dvd a\" and \"c dvd b\"\n and greatest: \"\\d. d dvd a \\ d dvd b \\ d dvd c\"\n and \"normalize c = c\"\n shows \"c = gcd a b\"\n by sorry\n\nlemma gcd_unique:\n \"d dvd a \\ d dvd b \\ normalize d = d \\ (\\e. e dvd a \\ e dvd b \\ e dvd d) \\ d = gcd a b\"\n by sorry\n\nlemma gcd_dvd_prod: \"gcd a b dvd k * b\"\n by sorry\n\nlemma gcd_proj2_if_dvd: \"b dvd a \\ gcd a b = normalize b\"\n by sorry\n\nlemma gcd_proj1_if_dvd: \"a dvd b \\ gcd a b = normalize a\"\n by sorry\n\nlemma gcd_proj1_iff: \"gcd m n = normalize m \\ m dvd n\"\n by sorry\n\nlemma gcd_proj2_iff: \"gcd m n = normalize n \\ n dvd m\"\n by sorry\n\nlemma gcd_mult_left: \"gcd (c * a) (c * b) = normalize (c * gcd a b)\"\n by sorry\n\nlemma gcd_mult_right: \"gcd (a * c) (b * c) = normalize (gcd b a * c)\"\n by sorry\n\nlemma dvd_lcm1 [iff]: \"a dvd lcm a b\"\n by sorry\n\nlemma dvd_lcm2 [iff]: \"b dvd lcm a b\"\n by sorry\n\nlemma dvd_lcmI1: \"a dvd b \\ a dvd lcm b c\"\n by sorry\n\nlemma dvd_lcmI2: \"a dvd c \\ a dvd lcm b c\"\n by sorry\n\nlemma lcm_dvdD1: \"lcm a b dvd c \\ a dvd c\"\n by sorry\n\nlemma lcm_dvdD2: \"lcm a b dvd c \\ b dvd c\"\n by sorry\n\nlemma lcm_least:\n assumes \"a dvd c\" and \"b dvd c\"\n shows \"lcm a b dvd c\"\n by sorry\n\nlemma lcm_least_iff [simp]: \"lcm a b dvd c \\ a dvd c \\ b dvd c\"\n by sorry\n\nlemma normalize_lcm [simp]: \"normalize (lcm a b) = lcm a b\"\n by sorry\n\nlemma lcm_0_left [simp]: \"lcm 0 a = 0\"\n by sorry\n\nlemma lcm_0_right [simp]: \"lcm a 0 = 0\"\n by sorry\n\nlemma lcm_eq_0_iff: \"lcm a b = 0 \\ a = 0 \\ b = 0\"\n (is \"?P \\ ?Q\")\n by sorry\n\nlemma zero_eq_lcm_iff: \"0 = lcm a b \\ a = 0 \\ b = 0\"\n by sorry\n\nlemma lcm_eq_1_iff [simp]: \"lcm a b = 1 \\ is_unit a \\ is_unit b\"\n by sorry\n\nlemma unit_factor_lcm: \"unit_factor (lcm a b) = (if a = 0 \\ b = 0 then 0 else 1)\"\n by sorry\n\nsublocale lcm: abel_semigroup lcm\nproof\n fix a b c\n show \"lcm a b = lcm b a\"\n by (simp add: lcm_gcd ac_simps normalize_mult dvd_normalize_div)\n have \"lcm (lcm a b) c dvd lcm a (lcm b c)\"\n and \"lcm a (lcm b c) dvd lcm (lcm a b) c\"\n by (auto intro: lcm_least\n dvd_trans [of b \"lcm b c\" \"lcm a (lcm b c)\"]\n dvd_trans [of c \"lcm b c\" \"lcm a (lcm b c)\"]\n dvd_trans [of a \"lcm a b\" \"lcm (lcm a b) c\"]\n dvd_trans [of b \"lcm a b\" \"lcm (lcm a b) c\"])\n then show \"lcm (lcm a b) c = lcm a (lcm b c)\"\n by (rule associated_eqI) simp_all\nqed\n\nsublocale lcm: bounded_quasi_semilattice lcm 1 0 normalize\nproof\n show \"lcm a a = normalize a\" for a\n proof -\n have \"lcm a a dvd a\"\n by (rule lcm_least) simp_all\n then show ?thesis\n by (auto intro: associated_eqI)\n qed\n show \"lcm (normalize a) b = lcm a b\" for a b\n using dvd_lcm1 [of \"normalize a\" b] unfolding normalize_dvd_iff\n by (auto intro: associated_eqI)\n show \"lcm 1 a = normalize a\" for a\n by (rule associated_eqI) simp_all\nqed simp_all\n\nlemma lcm_self: \"lcm a a = normalize a\"\n by sorry\n\nlemma lcm_left_idem: \"lcm a (lcm a b) = lcm a b\"\n by sorry\n\nlemma lcm_right_idem: \"lcm (lcm a b) b = lcm a b\"\n by sorry\n\nlemma gcd_lcm:\n assumes \"a \\ 0\" and \"b \\ 0\"\n shows \"gcd a b = normalize (a * b div lcm a b)\"\n by sorry\n\nlemma lcm_1_left: \"lcm 1 a = normalize a\"\n by sorry\n\nlemma lcm_1_right: \"lcm a 1 = normalize a\"\n by sorry\n\nlemma lcm_mult_left: \"lcm (c * a) (c * b) = normalize (c * lcm a b)\"\n by sorry\n\nlemma lcm_mult_right: \"lcm (a * c) (b * c) = normalize (lcm b a * c)\"\n by sorry\n\nlemma lcm_mult_unit1: \"is_unit a \\ lcm (b * a) c = lcm b c\"\n by sorry\n\nlemma lcm_mult_unit2: \"is_unit a \\ lcm b (c * a) = lcm b c\"\n by sorry\n\nlemma lcm_div_unit1:\n \"is_unit a \\ lcm (b div a) c = lcm b c\"\n by sorry\n\nlemma lcm_div_unit2: \"is_unit a \\ lcm b (c div a) = lcm b c\"\n by sorry\n\nlemma normalize_lcm_left: \"lcm (normalize a) b = lcm a b\"\n by sorry\n\nlemma normalize_lcm_right: \"lcm a (normalize b) = lcm a b\"\n by sorry\n\nlemma comp_fun_idem_gcd: \"comp_fun_idem gcd\"\n by sorry\n\nlemma comp_fun_idem_lcm: \"comp_fun_idem lcm\"\n by sorry\n\nlemma gcd_dvd_antisym: \"gcd a b dvd gcd c d \\ gcd c d dvd gcd a b \\ gcd a b = gcd c d\"\n by sorry\n\ndeclare unit_factor_lcm [simp]\n\nlemma lcmI:\n assumes \"a dvd c\" and \"b dvd c\" and \"\\d. a dvd d \\ b dvd d \\ c dvd d\"\n and \"normalize c = c\"\n shows \"c = lcm a b\"\n by sorry\n\nlemma gcd_dvd_lcm [simp]: \"gcd a b dvd lcm a b\"\n by sorry\n\nlemmas lcm_0 = lcm_0_right\n\nlemma lcm_unique:\n \"a dvd d \\ b dvd d \\ normalize d = d \\ (\\e. a dvd e \\ b dvd e \\ d dvd e) \\ d = lcm a b\"\n by sorry\n\nlemma lcm_proj1_if_dvd:\n assumes \"b dvd a\" shows \"lcm a b = normalize a\"\n by sorry\n\nlemma lcm_proj2_if_dvd: \"a dvd b \\ lcm a b = normalize b\"\n by sorry\n\nlemma lcm_proj1_iff: \"lcm m n = normalize m \\ n dvd m\"\n by sorry\n\nlemma lcm_proj2_iff: \"lcm m n = normalize n \\ m dvd n\"\n by sorry\n\nlemma gcd_mono: \"a dvd c \\ b dvd d \\ gcd a b dvd gcd c d\"\n by sorry\n\nlemma lcm_mono: \"a dvd c \\ b dvd d \\ lcm a b dvd lcm c d\"\n by sorry\n\nlemma dvd_productE:\n assumes \"p dvd a * b\"\n obtains x y where \"p = x * y\" \"x dvd a\" \"y dvd b\"\n by sorry\n\nlemma gcd_mult_unit1: \n assumes \"is_unit a\" shows \"gcd (b * a) c = gcd b c\"\n by sorry\n\nlemma gcd_mult_unit2: \"is_unit a \\ gcd b (c * a) = gcd b c\"\n by sorry\n\nlemma gcd_div_unit1: \"is_unit a \\ gcd (b div a) c = gcd b c\"\n by sorry\n\nlemma gcd_div_unit2: \"is_unit a \\ gcd b (c div a) = gcd b c\"\n by sorry\n\nlemma normalize_gcd_left: \"gcd (normalize a) b = gcd a b\"\n by sorry\n\nlemma normalize_gcd_right: \"gcd a (normalize b) = gcd a b\"\n by sorry\n\nlemma gcd_add1 [simp]: \"gcd (m + n) n = gcd m n\"\n by sorry\n\nlemma gcd_add2 [simp]: \"gcd m (m + n) = gcd m n\"\n by sorry\n\nlemma gcd_add_mult: \"gcd m (k * m + n) = gcd m n\"\n by sorry\n\nend\n\nclass ring_gcd = comm_ring_1 + semiring_gcd\nbegin\n\nlemma gcd_neg1 [simp]: \"gcd (-a) b = gcd a b\"\n by sorry\n\nlemma gcd_neg2 [simp]: \"gcd a (-b) = gcd a b\"\n by sorry\n\nlemma gcd_neg_numeral_1 [simp]: \"gcd (- numeral n) a = gcd (numeral n) a\"\n by sorry\n\nlemma gcd_neg_numeral_2 [simp]: \"gcd a (- numeral n) = gcd a (numeral n)\"\n by sorry\n\nlemma gcd_diff1: \"gcd (m - n) n = gcd m n\"\n by sorry\n\nlemma gcd_diff2: \"gcd (n - m) n = gcd m n\"\n by sorry\n\nlemma lcm_neg1 [simp]: \"lcm (-a) b = lcm a b\"\n by sorry\n\nlemma lcm_neg2 [simp]: \"lcm a (-b) = lcm a b\"\n by sorry\n\nlemma lcm_neg_numeral_1 [simp]: \"lcm (- numeral n) a = lcm (numeral n) a\"\n by sorry\n\nlemma lcm_neg_numeral_2 [simp]: \"lcm a (- numeral n) = lcm a (numeral n)\"\n by sorry\n\nend\n\nclass semiring_Gcd = semiring_gcd + Gcd +\n assumes Gcd_dvd: \"a \\ A \\ Gcd A dvd a\"\n and Gcd_greatest: \"(\\b. b \\ A \\ a dvd b) \\ a dvd Gcd A\"\n and normalize_Gcd [simp]: \"normalize (Gcd A) = Gcd A\"\n assumes dvd_Lcm: \"a \\ A \\ a dvd Lcm A\"\n and Lcm_least: \"(\\b. b \\ A \\ b dvd a) \\ Lcm A dvd a\"\n and normalize_Lcm [simp]: \"normalize (Lcm A) = Lcm A\"\nbegin\n\nlemma Lcm_Gcd: \"Lcm A = Gcd {b. \\a\\A. a dvd b}\"\n by sorry\n\nlemma Gcd_Lcm: \"Gcd A = Lcm {b. \\a\\A. b dvd a}\"\n by sorry\n\nlemma Gcd_empty [simp]: \"Gcd {} = 0\"\n by sorry\n\nlemma Lcm_empty [simp]: \"Lcm {} = 1\"\n by sorry\n\nlemma Gcd_insert [simp]: \"Gcd (insert a A) = gcd a (Gcd A)\"\n by sorry\n\nlemma Lcm_insert [simp]: \"Lcm (insert a A) = lcm a (Lcm A)\"\n by sorry\n\nlemma LcmI:\n assumes \"\\a. a \\ A \\ a dvd b\"\n and \"\\c. (\\a. a \\ A \\ a dvd c) \\ b dvd c\"\n and \"normalize b = b\"\n shows \"b = Lcm A\"\n by sorry\n\nlemma Lcm_subset: \"A \\ B \\ Lcm A dvd Lcm B\"\n by sorry\n\nlemma Lcm_Un: \"Lcm (A \\ B) = lcm (Lcm A) (Lcm B)\"\n by sorry\n\nlemma Gcd_0_iff [simp]: \"Gcd A = 0 \\ A \\ {0}\"\n (is \"?P \\ ?Q\")\n by sorry\n\nlemma Lcm_1_iff [simp]: \"Lcm A = 1 \\ (\\a\\A. is_unit a)\"\n (is \"?P \\ ?Q\")\n by sorry\n\nlemma unit_factor_Lcm: \"unit_factor (Lcm A) = (if Lcm A = 0 then 0 else 1)\"\n by sorry\n\nlemma unit_factor_Gcd: \"unit_factor (Gcd A) = (if Gcd A = 0 then 0 else 1)\"\n by sorry\n\nlemma GcdI:\n assumes \"\\a. a \\ A \\ b dvd a\"\n and \"\\c. (\\a. a \\ A \\ c dvd a) \\ c dvd b\"\n and \"normalize b = b\"\n shows \"b = Gcd A\"\n by sorry\n\nlemma Gcd_eq_1_I:\n assumes \"is_unit a\" and \"a \\ A\"\n shows \"Gcd A = 1\"\n by sorry\n\nlemma Lcm_eq_0_I:\n assumes \"0 \\ A\"\n shows \"Lcm A = 0\"\n by sorry\n\nlemma Gcd_UNIV [simp]: \"Gcd UNIV = 1\"\n by sorry\n\nlemma Lcm_UNIV [simp]: \"Lcm UNIV = 0\"\n by sorry\n\nlemma Lcm_0_iff:\n assumes \"finite A\"\n shows \"Lcm A = 0 \\ 0 \\ A\"\n by sorry\n\nlemma Gcd_image_normalize [simp]: \"Gcd (normalize ` A) = Gcd A\"\n by sorry\n\nlemma Gcd_eqI:\n assumes \"normalize a = a\"\n assumes \"\\b. b \\ A \\ a dvd b\"\n and \"\\c. (\\b. b \\ A \\ c dvd b) \\ c dvd a\"\n shows \"Gcd A = a\"\n by sorry\n\nlemma dvd_GcdD: \"x dvd Gcd A \\ y \\ A \\ x dvd y\"\n by sorry\n\nlemma dvd_Gcd_iff: \"x dvd Gcd A \\ (\\y\\A. x dvd y)\"\n by sorry\n\nlemma Gcd_mult: \"Gcd (" }, { "theorem_id": 48, "title": "060_bézout_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Guy Leroy. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sangwoo Jo (aka Jason), Guy Leroy, Johannes Hölzl, Mario Carneiro\n-/\nmodule\n\npublic import Mathlib.Algebra.GroupWithZero.Semiconj\npublic import Mathlib.Algebra.Group.Commute.Units\npublic import Mathlib.Data.Set.Operations\npublic import Mathlib.Order.Basic\npublic import Mathlib.Order.Bounds.Defs\npublic import Mathlib.Algebra.Group.Int.Defs\npublic import Mathlib.Algebra.Divisibility.Basic\npublic import Mathlib.Algebra.Group.Nat.Defs\n\n/-!\n# Extended GCD and divisibility over ℤ\n\n## Main definitions\n\n* Given `x y : ℕ`, `xgcd x y` computes the pair of integers `(a, b)` such that\n `gcd x y = x * a + y * b`. `gcdA x y` and `gcdB x y` are defined to be `a` and `b`,\n respectively.\n\n## Main statements\n\n* `gcd_eq_gcd_ab`: Bézout's lemma, given `x y : ℕ`, `gcd x y = x * gcdA x y + y * gcdB x y`.\n\n## Tags\n\nBézout's lemma, Bezout's lemma\n-/\n\n@[expose] public section\n\n/-! ### Extended Euclidean algorithm -/\n\n\nnamespace Nat\n\n/-- Helper function for the extended GCD algorithm (`Nat.xgcd`). -/\ndef xgcdAux : ℕ → ℤ → ℤ → ℕ → ℤ → ℤ → ℕ × ℤ × ℤ :=\n Nat.strongRec' fun n ih s t r' s' t' ↦ match n with\n | 0 => (r', s', t')\n | succ k =>\n let q := r' / succ k\n ih (r' % succ k) (mod_lt _ <| (succ_pos _).gt) (s' - q * s) (t' - q * t) (succ k) s t\n\n@[simp]\ntheorem xgcd_zero_left {s t r' s' t'} : xgcdAux 0 s t r' s' t' = (r', s', t') := rfl\n\ntheorem xgcdAux_rec {r s t r' s' t'} (h : 0 < r) :\n xgcdAux r s t r' s' t' = xgcdAux (r' % r) (s' - r' / r * s) (t' - r' / r * t) r s t := by sorry\ndef xgcd (x y : ℕ) : ℤ × ℤ :=\n (xgcdAux x 1 0 y 0 1).2\n\n/-- The extended GCD `a` value in the equation `gcd x y = x * a + y * b`. -/\ndef gcdA (x y : ℕ) : ℤ :=\n (xgcd x y).1\n\n/-- The extended GCD `b` value in the equation `gcd x y = x * a + y * b`. -/\ndef gcdB (x y : ℕ) : ℤ :=\n (xgcd x y).2\n\n@[simp]\ntheorem gcdA_zero_left {s : ℕ} : gcdA 0 s = 0 := rfl\n\n@[simp]\ntheorem gcdB_zero_left {s : ℕ} : gcdB 0 s = 1 := rfl\n\n@[simp]\ntheorem gcdA_zero_right {s : ℕ} (h : s ≠ 0) : gcdA s 0 = 1 := by sorry\ntheorem gcdB_zero_right {s : ℕ} (h : s ≠ 0) : gcdB s 0 = 0 := by sorry\ntheorem xgcdAux_fst (x y) : ∀ s t s' t', (xgcdAux x s t y s' t').1 = gcd x y :=\n gcd.induction x y (by simp) fun x y h IH s t s' t' => by\n simp only [h, xgcdAux_rec, IH]\n rw [← gcd_rec]\n\ntheorem xgcdAux_val (x y) : xgcdAux x 1 0 y 0 1 = (gcd x y, xgcd x y) := by sorry\ntheorem xgcd_val (x y) : xgcd x y = (gcdA x y, gcdB x y) := by sorry\nvariable (x y : ℕ)\n\nprivate def P : ℕ × ℤ × ℤ → Prop\n | (r, s, t) => (r : ℤ) = x * s + y * t\n\nprivate theorem xgcdAux_P {r r'} :\n ∀ {s t s' t'}, P x y (r, s, t) → P x y (r', s', t') → P x y (xgcdAux r s t r' s' t') := by sorry\ntheorem gcd_eq_gcd_ab : (gcd x y : ℤ) = x * gcdA x y + y * gcdB x y := by sorry\nend\n\ntheorem exists_mul_mod_eq_gcd {k n : ℕ} (hk : gcd n k < k) : ∃ m < k, n * m % k = gcd n k := by sorry\ntheorem exists_mul_mod_eq_one_of_coprime {k n : ℕ} (hkn : Coprime n k) (hk : 1 < k) :\n ∃ m < k, n * m % k = 1 := by sorry\ntheorem exists_mul_mod_eq_of_coprime {k n : ℕ} (r : ℕ) (hkn : Coprime n k) (hk : k ≠ 0) :\n ∃ m < k, n * m % k = r % k := by sorry\nend Nat\n\n/-! ### Divisibility over ℤ -/\n\n\nnamespace Int\n\ntheorem gcd_def (i j : ℤ) : gcd i j = Nat.gcd i.natAbs j.natAbs := rfl\n\n/-- The extended GCD `a` value in the equation `gcd x y = x * a + y * b`. -/\ndef gcdA : ℤ → ℤ → ℤ\n | ofNat m, n => m.gcdA n.natAbs\n | -[m+1], n => -m.succ.gcdA n.natAbs\n\n/-- The extended GCD `b` value in the equation `gcd x y = x * a + y * b`. -/\ndef gcdB : ℤ → ℤ → ℤ\n | m, ofNat n => m.natAbs.gcdB n\n | m, -[n+1] => -m.natAbs.gcdB n.succ\n\n/-- **Bézout's lemma** -/\ntheorem gcd_eq_gcd_ab : ∀ x y : ℤ, (gcd x y : ℤ) = x * gcdA x y + y * gcdB x y := by sorry\ntheorem lcm_def (i j : ℤ) : lcm i j = Nat.lcm (natAbs i) (natAbs j) :=\n rfl\n\nalias gcd_div := gcd_ediv\nalias gcd_div_gcd_div_gcd := gcd_ediv_gcd_ediv_gcd\n\n/-- If `gcd a (m * n) = 1`, then `gcd a m = 1`. -/\ntheorem gcd_eq_one_of_gcd_mul_right_eq_one_left {a : ℤ} {m n : ℕ} (h : a.gcd (m * n) = 1) :\n a.gcd m = 1 :=\n Nat.dvd_one.mp <| h ▸ gcd_dvd_gcd_mul_right_right a m n\n\n/-- If `gcd a (m * n) = 1`, then `gcd a n = 1`. -/\ntheorem gcd_eq_one_of_gcd_mul_right_eq_one_right {a : ℤ} {m n : ℕ} (h : a.gcd (m * n) = 1) :\n a.gcd n = 1 :=\n Nat.dvd_one.mp <| h ▸ gcd_dvd_gcd_mul_left_right a n m\n\ntheorem ne_zero_of_gcd {x y : ℤ} (hc : gcd x y ≠ 0) : x ≠ 0 ∨ y ≠ 0 := by sorry\ntheorem exists_gcd_one {m n : ℤ} (H : 0 < gcd m n) :\n ∃ m' n' : ℤ, gcd m' n' = 1 ∧ m = m' * gcd m n ∧ n = n' * gcd m n :=\n ⟨_, _, gcd_div_gcd_div_gcd H, (Int.ediv_mul_cancel (gcd_dvd_left ..)).symm,\n (Int.ediv_mul_cancel (gcd_dvd_right ..)).symm⟩\n\ntheorem exists_gcd_one' {m n : ℤ} (H : 0 < gcd m n) :\n ∃ (g : ℕ) (m' n' : ℤ), 0 < g ∧ gcd m' n' = 1 ∧ m = m' * g ∧ n = n' * g :=\n let ⟨m', n', h⟩ := exists_gcd_one H\n ⟨_, m', n', H, h⟩\n\ntheorem gcd_dvd_iff {a b : ℤ} {n : ℕ} : gcd a b ∣ n ↔ ∃ x y : ℤ, ↑n = a * x + b * y := by sorry\ntheorem gcd_greatest {a b d : ℤ} (hd_pos : 0 ≤ d) (hda : d ∣ a) (hdb : d ∣ b)\n (hd : ∀ e : ℤ, e ∣ a → e ∣ b → e ∣ d) : d = gcd a b :=\n dvd_antisymm hd_pos (natCast_nonneg (gcd a b)) (dvd_coe_gcd hda hdb)\n (hd _ (gcd_dvd_left ..) (gcd_dvd_right ..))\n\n/-- Euclid's lemma: if `a ∣ b * c` and `gcd a c = 1` then `a ∣ b`.\nCompare with `IsCoprime.dvd_of_dvd_mul_left` and\n`UniqueFactorizationMonoid.dvd_of_dvd_mul_left_of_no_prime_factors` -/\ntheorem dvd_of_dvd_mul_left_of_gcd_one {a b c : ℤ} (habc : a ∣ b * c) (hab : gcd a c = 1) :\n a ∣ b := by sorry\ntheorem dvd_of_dvd_mul_right_of_gcd_one {a b c : ℤ} (habc : a ∣ b * c) (hab : gcd a b = 1) :\n a ∣ c := by sorry\ntheorem gcd_least_linear {a b : ℤ} (ha : a ≠ 0) :\n IsLeast { n : ℕ | 0 < n ∧ ∃ x y : ℤ, ↑n = a * x + b * y } (a.gcd b) := by sorry\nend Int\n\nsection Monoid\nvariable {M : Type*} [Monoid M] {a : M} {m n : ℕ}\n\n@[to_additive (attr := simp) gcd_nsmul_eq_zero]\nlemma pow_gcd_eq_one : a ^ m.gcd n = 1 ↔ a ^ m = 1 ∧ a ^ n = 1 where\n mp hmn := by sorry\nlemma pow_eq_one_iff_of_coprime (hmn : m.Coprime n) : a ^ m = 1 ∧ a ^ n = 1 ↔ a = 1 := by sorry\nend Monoid\n\nsection Group\nvariable {M : Type*} [Group M] {a : M} {m n : ℤ}\n\n@[to_additive (attr := simp) intGCD_nsmul_eq_zero]\nlemma pow_intGCD_eq_one : a ^ m.gcd n = 1 ↔ a ^ m = 1 ∧ a ^ n = 1 := by sorry\nend Group\n\nvariable {α : Type*}\n\nsection GroupWithZero\nvariable [GroupWithZero α] {a b : α} {m n : ℕ}\n\nprotected lemma Commute.pow_eq_pow_iff_of_coprime (hab : Commute a b) (hmn : m.Coprime n) :\n a ^ m = b ^ n ↔ ∃ c, a = c ^ n ∧ b = c ^ m := by sorry\nend GroupWithZero\n\nsection CommGroupWithZero\nvariable [CommGroupWithZero α] {a b : α} {m n : ℕ}\n\nlemma pow_eq_pow_iff_of_coprime (hmn : m.Coprime n) : a ^ m = b ^ n ↔ ∃ c, a = c ^ n ∧ b = c ^ m :=\n (Commute.all _ _).pow_eq_pow_iff_of_coprime hmn\n\nlemma pow_mem_range_pow_of_coprime (hmn : m.Coprime n) (a : α) :\n a ^ m ∈ Set.range (· ^ n : α → α) ↔ a ∈ Set.range (· ^ n : α → α) := by sorry\nend CommGroupWithZero\n" }, { "theorem_id": 48, "title": "060_bézout_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "#[local] Set Warnings \"-deprecated-library-file,-deprecated-reference,-deprecated-syntactic-definition\".\n\nFrom Stdlib Require Import ZArith_base.\nFrom Stdlib Require Import ZArithRing.\nFrom Stdlib Require Import Zcomplements.\nFrom Stdlib Require Import Zdiv.\nFrom Stdlib Require Import Zdivisibility.\nFrom Stdlib Require Import Wf_nat.\nFrom Stdlib Require Import Lia Cring Ncring_tac.\n\nOpen Scope Z_scope.\n\n#[local] Ltac Tauto.intuition_solver ::= auto with zarith.\n\n#[deprecated(use=ex_intro, since=\"Stdlib 9.1\")]\nDefinition Zdivide_intro a b q (H:b=q*a) : Z.divide a b := ex_intro _ q H.\n\n#[deprecated(use=Z.divide_1_l, since=\"Stdlib 9.1\")]\nNotation Zone_divide := Z.divide_1_l (only parsing).\n#[deprecated(use=Z.divide_0_r, since=\"Stdlib 9.1\")]\nNotation Zdivide_0 := Z.divide_0_r (only parsing).\n#[deprecated(use=Z.mul_divide_mono_l, since=\"Stdlib 9.1\")]\nNotation Zmult_divide_compat_l := Z.mul_divide_mono_l (only parsing).\n#[deprecated(use=Z.mul_divide_mono_r, since=\"Stdlib 9.1\")]\nNotation Zmult_divide_compat_r := Z.mul_divide_mono_r (only parsing).\n#[deprecated(use=Z.divide_add_r, since=\"Stdlib 9.1\")]\nNotation Zdivide_plus_r := Z.divide_add_r (only parsing).\n#[deprecated(use=Z.divide_sub_r, since=\"Stdlib 9.1\")]\nNotation Zdivide_minus_l := Z.divide_sub_r (only parsing).\n#[deprecated(use=Z.divide_mul_l, since=\"Stdlib 9.1\")]\nNotation Zdivide_mult_l := Z.divide_mul_l (only parsing).\n#[deprecated(use=Z.divide_mul_r, since=\"Stdlib 9.1\")]\nNotation Zdivide_mult_r := Z.divide_mul_r (only parsing).\n#[deprecated(use=Z.divide_factor_l, since=\"Stdlib 9.1\")]\nNotation Zdivide_factor_r := Z.divide_factor_l (only parsing).\n#[deprecated(use=Z.divide_factor_r, since=\"Stdlib 9.1\")]\nNotation Zdivide_factor_l := Z.divide_factor_r (only parsing).\n\n#[deprecated(use=Z.divide_opp_r, since=\"Stdlib 9.1\")]\nLemma Zdivide_opp_r a b : (a | b) -> (a | - b).\nProof.\nAdmitted.\n\n#[deprecated(since=\"Stdlib 9.1\")]\nDefinition prime_dec_aux:\n forall p m,\n { forall n, 1 < n < m -> rel_prime n p } +\n { exists n, 1 < n < m /\\ ~ rel_prime n p }.\nProof.\nAdmitted.\n\nDefinition prime_dec: forall p, { prime p }+{ ~ prime p }.\nProof.\nAdmitted.\n\nTheorem not_prime_divide:\n forall p, 1 < p -> ~ prime p -> exists n, 1 < n < p /\\ (n | p).\nProof.\nAdmitted." }, { "theorem_id": 49, "title": "061_theorem_of_ceva", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/convex.ml\";;\nneeds \"Examples/sos.ml\";;\n\nprioritize_real();;\n\nlet BETWEEN_THM = `between x (a,b) <=>\n ?u. &0 <= u /\\ u <= &1 /\\ x = u % a + (&1 - u) % b`;;\n\nlet NORM_CROSS = `norm(a) * norm(b) * norm(c) = norm(d) * norm(e) * norm(f) <=>\n (a dot a) * (b dot b) * (c dot c) = (d dot d) * (e dot e) * (f dot f)`;;\n\nlet COLLINEAR = `!a b c:real^2.\n collinear {a:real^2,b,c} <=>\n ((a$1 - b$1) * (b$2 - c$2) = (a$2 - b$2) * (b$1 - c$1))`;;\n\nlet CEVA_WEAK = `!A B C X Y Z P:real^2.\n ~(collinear {A,B,C}) /\\\n between X (B,C) /\\ between Y (A,C) /\\ between Z (A,B) /\\\n between P (A,X) /\\ between P (B,Y) /\\ between P (C,Z)\n ==> dist(B,X) * dist(C,Y) * dist(A,Z) =\n dist(X,C) * dist(Y,A) * dist(Z,B)`;;\n\nlet CEVA = `!A B C X Y Z:real^2.\n ~(collinear {A,B,C}) /\\\n between X (B,C) /\\ between Y (C,A) /\\ between Z (A,B)\n ==> (dist(B,X) * dist(C,Y) * dist(A,Z) =\n dist(X,C) * dist(Y,A) * dist(Z,B) <=>\n (?P. between P (A,X) /\\ between P (B,Y) /\\ between P (C,Z)))`;;\n\nlet BETWEEN_SYM = `!u v w. between v (u,w) <=> between v (w,u)`;;\n\nlet BETWEEN_METRICAL = `!u v w:real^N. between v (u,w) <=> dist(u,v) + dist(v,w) = dist(u,w)`;;" }, { "theorem_id": 49, "title": "061_theorem_of_ceva", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory Ceva\nimports\n Triangle.Triangle\nbegin\n\ndefinition\\<^marker>\\tag important\\ Triangle_area :: \"'a::real_inner \\ 'a \\ 'a \\ real\"\n where \"Triangle_area x y z = abs(sin (angle x y z)) * dist x y * dist y z\"\n\nlemma Triangle_area_per1 : \"Triangle_area a b c = Triangle_area b c a\"\n by sorry\n\nlemma Triangle_area_per2 : \"Triangle_area a b c = Triangle_area b a c\"\n by sorry\n\nlemma collinear_angle: \n fixes a b c :: \"'a::euclidean_space\"\n shows \"collinear {a, b, c} \\ a \\ b \\ b \\ c \\ angle a b c \\ {0, pi}\"\n by sorry\n\nlemma Triangle_area_0 : \n fixes c :: \"'a::euclidean_space\"\n shows \"Triangle_area a b c = 0 \\ collinear {a,b,c}\"\n by sorry\n\nlemma Angle_longer_side : \n fixes a :: \"'a :: euclidean_space\"\n assumes Col : \"between (b,d) c\"\n assumes NeqBC : \"b \\ c\"\n shows \"angle a b c = angle a b d\"\n by sorry\n\nlemma Triangle_area_comb :\n fixes c :: \"'a::euclidean_space\"\n assumes Col : \"between (b,c) m\"\n shows \"Triangle_area a b m + Triangle_area a c m = Triangle_area a b c\"\n by sorry\n\nlemma Triangle_area_cal :\n fixes a :: \"'a::euclidean_space\"\n assumes Col : \"collinear {a,m,b}\"\n shows \"\\ k. dist a m * k = Triangle_area a c m \\ dist b m * k = Triangle_area b c m\"\n by sorry\n\nlemma Triangle_area_comb_alt :\n fixes a :: \"'a::euclidean_space\"\n assumes Col1 : \"collinear {a,m,b}\"\n assumes Col2 : \"collinear {c,k,m}\"\n shows Goal : \"\\ h. dist a m * h = Triangle_area a c k \\ dist b m * h = Triangle_area b c k\"\n by sorry\n\nlemma Cevas : \n fixes a :: \"'a::euclidean_space\"\n assumes MidCol : \"collinear {a,k,d} \\ collinear {b,k,e} \\ collinear {c,k,f}\"\n assumes TriCol : \"collinear {a,f,b} \\ collinear {a,e,c} \\ collinear {b,d,c}\"\n assumes Triangle : \"\\ collinear {a,b,c}\"\n shows \"dist a f * dist b d * dist c e = dist f b * dist d c * dist e a\"\n by sorry\n\nend" }, { "theorem_id": 49, "title": "061_theorem_of_ceva", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2025 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers\n-/\nmodule\n\npublic import Mathlib.Analysis.Normed.Affine.AddTorsor\npublic import Mathlib.LinearAlgebra.AffineSpace.Ceva\n\n/-!\n# Ceva's theorem.\n\nThis file proves various versions of Ceva's theorem in a `NormedAddTorsor`.\n\n## References\n\n* https://en.wikipedia.org/wiki/Ceva%27s_theorem\n\n-/\n\n@[expose] public section\n\n\nopen scoped Affine\n\nvariable {𝕜 V P : Type*} [SeminormedAddCommGroup V] [NormedField 𝕜] [NormedSpace 𝕜 V]\n\nnamespace Affine.Triangle\n\nvariable [PseudoMetricSpace P] [NormedAddTorsor V P] in\n/-- **Ceva's theorem** for a triangle, expressed in terms of multiplying distances. -/\nlemma prod_dist_eq_prod_dist_of_mem_line_of_mem_line {t : Triangle 𝕜 P} {p : Fin 3 → P} {p' : P}\n (hp : ∀ i : Fin 3, p i ∈ line[𝕜, t.points (i + 1), t.points (i + 2)])\n (hp' : ∀ i : Fin 3, p' ∈ line[𝕜, t.points i, p i]) :\n ∏ i, dist (t.points (i + 1)) (p i) = ∏ i, dist (p i) (t.points (i + 2)) := by sorry\nvariable [MetricSpace P] [NormedAddTorsor V P] in\n/-- **Ceva's theorem** for a triangle, expressed using division of distances. -/\nlemma prod_dist_div_dist_eq_one_of_mem_line_of_mem_line {t : Triangle 𝕜 P} {p : Fin 3 → P} {p' : P}\n (hp0 : ∀ i, p i ≠ t.points (i + 2))\n (hp : ∀ i : Fin 3, p i ∈ line[𝕜, t.points (i + 1), t.points (i + 2)])\n (hp' : ∀ i : Fin 3, p' ∈ line[𝕜, t.points i, p i]) :\n ∏ i, dist (t.points (i + 1)) (p i) / dist (p i) (t.points (i + 2)) = 1 := by sorry\nend Affine.Triangle\n" }, { "theorem_id": 49, "title": "061_theorem_of_ceva", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import area_method.\n\nLemma l3_43 : forall O A B X Y C D P Q R T r,\n mratio C A B r ->\n mratio D A B (0-r) ->\n inter_ll P O A X Y ->\n inter_ll Q O B X Y ->\n inter_ll R O C X Y ->\n inter_ll T O D X Y ->\n parallel P R R Q ->\n R<>Q ->\n parallel T P T Q ->\n T<>Q ->\n P<>T ->\n P<>R ->\n ~ Col P X Y ->\n harmonic P Q R T.\nProof.\nAdmitted.\n\nTheorem Ceva :\n forall A B C D E F G P : Point,\n inter_ll D B C A P ->\n inter_ll E A C B P ->\n inter_ll F A B C P ->\n F <> B ->\n D <> C ->\n E <> A ->\n parallel A F F B ->\n parallel B D D C ->\n parallel C E E A -> \n (A ** F / F ** B) * (B ** D / D ** C) * (C ** E / E ** A) = 1.\nProof.\nAdmitted.\n\nLemma l6_217 : forall A B C D E F G H,\nis_midpoint E A B ->\nis_midpoint F B C ->\nis_midpoint G C D ->\nis_midpoint H D A ->\nparallel H E G F ->\nG<>F ->\nE<>H ->\n~ Col E D A ->\nH**E / G**F = 1.\nProof.\nAdmitted.\n\nTheorem Menelaus :\n forall A B C X Y D E F : Point,\n inter_ll D B C X Y ->\n inter_ll E A C X Y ->\n inter_ll F A B X Y ->\n F <> B -> \n D <> C ->\n E <> A ->\n parallel A F F B ->\n parallel B D D C ->\n parallel C E E A -> \n (A ** F / F ** B) * (B ** D / D ** C) * (C ** E / E ** A) = - (1).\nProof.\nAdmitted.\n\nTheorem Pascal :\n forall A B C A' B' C' : Point, A<>C' -> \n on_line C A B -> \n on_parallel B' A B A' -> \n on_inter_line_parallel C' A A' B' C A' -> \n parallel B C' B' C.\nProof.\nAdmitted.\n\nTheorem Desargues :\n forall A B C X A' B' C' : Point, A' <>C' -> A' <> B' ->\n on_line A' X A ->\n on_inter_line_parallel B' A' X B A B -> \n on_inter_line_parallel C' A' X C A C ->\n parallel B C B' C'.\nProof.\nAdmitted.\n\nTheorem ex1_6auto :\nforall A B C D E F G P : Point,\n inter_ll D B C A P ->\n inter_ll E A C B P ->\n inter_ll F A B C P ->\n A <> D ->\n B <> E ->\n C <> F ->\n parallel P D A D ->\n parallel P E B E ->\n parallel P F C F -> \n P ** D / A ** D + P ** E / B ** E + P ** F / C ** F = 1.\nProof.\nAdmitted.\n\nTheorem th2_41 :\n forall A B C D P Q M : Point,\n on_line C A P ->\n on_inter_line_parallel D C B P A B ->\n inter_ll Q A D B C -> \n inter_ll M A B P Q -> \n B <> M -> \n parallel A M B M -> \n C<>D ->\n A ** M / B ** M = - (1).\nProof.\nAdmitted.\n\nTheorem Prop51Hartsshorne :\n forall A B C D E : Point, \n is_midpoint D A B -> \n is_midpoint E A C -> \n parallel D E B C.\nProof.\nAdmitted.\n\nTheorem is_midpoint_A :\n forall A B C A' B' : Point, \n is_midpoint A' B C -> \n is_midpoint B' A C -> \n parallel A' B' A B.\nProof.\nAdmitted.\n\nTheorem Prop51Hartsshornebis :\n forall A B C D E : Point,\n ~ Col D A C ->\n ~ Col A B C ->\n is_midpoint D A B ->\n is_midpoint E A C -> \n parallel D E B C -> \n B <> C -> \n D ** E / B ** C = 1 / 2.\nProof.\nAdmitted.\n\nTheorem th6_40_Centroid :\n forall A B C E F O : Point,\n is_midpoint F A B ->\n is_midpoint E B C -> \n inter_ll O A E C F -> \n O <> E -> \n parallel A O O E -> \n A ** O / O ** E = 2.\nProof.\nAdmitted.\n\nTheorem Prop54Hartsshorne :\n forall A B C D E F G : Point,\n is_midpoint D A B ->\n is_midpoint E A C -> \n is_midpoint F B C -> \n inter_ll G E B C D -> \n Col A G F.\nProof.\nAdmitted.\n\nTheorem Exo55Hartsshorne : \n forall A B C D I J K L,\n is_midpoint I A B -> \n is_midpoint J B C -> \n is_midpoint K C D -> \n is_midpoint L D A -> \n parallel I J K L /\\ parallel I L J K.\nProof.\nAdmitted.\n\nTheorem th6_42 :\n forall A B C L M N P K : Point,\n is_midpoint M A B ->\n is_midpoint N A C ->\n is_midpoint K B C ->\n is_midpoint L A K -> \n on_inter_parallel_parallel P A C M K B N -> \n P<>A ->\n (2 + 2) * S A K P = (1 + 2) * S A B C.\nProof.\nAdmitted.\n\nTheorem th6_43 :\n forall A B C F N K : Point,\n is_midpoint F A B ->\n is_midpoint N C F ->\n inter_ll K B C A N ->\n K <> C ->\n parallel B K K C ->\n B ** K / K ** C = 2.\nProof.\nAdmitted.\n\nTheorem Conversemenelaus :\n forall (A B C D E G : Point) (r1 r2 : F),\n mratio D B C r1 ->\n mratio E C A r2 ->\n inter_ll G D E A B ->\n G <> A ->\n parallel B G G A ->\n B ** G / G ** A = - r1 * r2.\nProof.\nAdmitted.\n\nTheorem MenelausQuadri :\n forall A B C D X Y A1 B1 C1 D1 : Point,\n inter_ll A1 A B X Y ->\n inter_ll B1 B C X Y ->\n inter_ll C1 C D X Y ->\n inter_ll D1 A D X Y ->\n B <> A1 ->\n C <> B1 ->\n D <> C1 ->\n A <> D1 ->\n parallel A A1 B A1 ->\n parallel B B1 C B1 ->\n parallel C C1 D C1 ->\n parallel D D1 A D1 ->\n A ** A1 / B ** A1 * (B ** B1 / C ** B1 * (C ** C1 / D ** C1 * (D ** D1 / A ** D1))) =\n 1.\nProof.\nAdmitted.\n\nTheorem ConverseMenelauseQuadri :\n forall (A B C D A1 B1 C1 D1 : Point) (r1 r2 : F),\n mratio B1 B C r1 ->\n mratio C1 C D r2 ->\n inter_ll D1 D A B1 C1 ->\n inter_ll A1 A B B1 C1 ->\n A1 <> A ->\n D1 <> A ->\n parallel B A1 A1 A ->\n parallel D D1 D1 A -> B ** A1 / A1 ** A = r1 * (r2 * (D ** D1 / D1 ** A)).\nProof.\nAdmitted.\n\nTheorem th6_6 :\n forall A B C L M N O : Point,\n inter_ll L B C A O ->\n inter_ll N B A C O ->\n inter_ll M A C B O ->\n A <> L ->\n B <> M ->\n C <> N ->\n parallel O L A L ->\n parallel O M B M ->\n parallel O N C N -> O ** L / A ** L + O ** M / B ** M + O ** N / C ** N = 1.\nProof.\nAdmitted.\n\nTheorem th6_7 :\n forall A B C L M N O : Point,\n inter_ll L B C A O ->\n inter_ll N B A C O ->\n inter_ll M A C B O ->\n S A M L * (S B N M * S C L N) = S A N L * (S B L M * S C N M).\nProof.\nAdmitted.\n\nTheorem th6_256_1 :\n forall (A B C D P Q R S : Point) (r1 r2 : F),\n on_parallel_d D A B C 1 ->\n on_line_d S D A r2 ->\n on_line_d P A B r1 -> \n on_line_d R C D r1 -> \n on_line_d Q B C r2 ->\n P <> S -> \n parallel Q R P S.\nProof.\nAdmitted.\n\nTheorem th6_257 :\n forall (A B C D P Q R S : Point) (r1 r2 : F),\n on_parallel_d D A B C 1 ->\n on_line_d S D A r2 ->\n on_line_d P A B r1 ->\n on_line_d R C D r1 ->\n on_line_d Q B C r2 ->\n S4 P Q R S = (2 * (r2 * r1) - r2 - r1 + 1) * S4 A B C D.\nProof.\nAdmitted.\n\nTheorem gauss_line :\n forall A0 A1 A2 A3 X Y M1 M2 M3 : Point,\n inter_ll X A0 A3 A1 A2 ->\n inter_ll Y A2 A3 A1 A0 ->\n is_midpoint M1 A1 A3 ->\n is_midpoint M2 A0 A2 ->\n is_midpoint M3 X Y -> \n S A0 A1 A2 <> 0 ->\n Col M1 M2 M3.\nProof.\nAdmitted." }, { "theorem_id": 50, "title": "063_cantor_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "let CANTOR_THM_INJ = `~(?f:(A->bool)->A. (!x y. f(x) = f(y) ==> x = y))`;;\n\nlet CANTOR_THM_SURJ = `~(?f:A->(A->bool). !s. ?x. f x = s)`;;\n\nlet CANTOR = `!s:A->bool. s <_c {t | t SUBSET s}`;;\n\nlet CANTOR_THM_INJ' = `~(?f:(A->bool)->A. (!x y. f(x) = f(y) ==> x = y))`;;\n\nlet CANTOR_LAWVERE = `!h:A->(A->B).\n (!f:A->B. ?x:A. h(x) = f) ==> !n:B->B. ?x. n(x) = x`;;\n\nlet CANTOR = `!f:A->(A->bool). ~(!s. ?x. f x = s)`;;\n\nlet CANTOR_TAYLOR = `!f:(A->bool)->A. ~(!x y. f(x) = f(y) ==> x = y)`;;\n\nlet SURJECTIVE_COMPOSE = `(!y. ?x. f(x) = y) /\\ (!z. ?y. g(y) = z)\n ==> (!z. ?x. (g o f) x = z)`;;\n\nlet INJECTIVE_SURJECTIVE_PREIMAGE = `!f:A->B. (!x y. f(x) = f(y) ==> x = y) ==> !t. ?s. {x | f(x) IN s} = t`;;\n\nlet CANTOR_JOHNSTONE = `!i:B->S f:B->S->bool.\n ~((!x y. i(x) = i(y) ==> x = y) /\\ (!s. ?z. f(z) = s))`;;" }, { "theorem_id": 50, "title": "063_cantor_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Set theory for higher-order logic\\\n\ntheory Set\n imports Lattices Boolean_Algebras\nbegin\n\nsubsection \\Sets as predicates\\\n\ntypedecl 'a set\n\naxiomatization Collect :: \"('a \\ bool) \\ 'a set\" \\ \\comprehension\\\n and member :: \"'a \\ 'a set \\ bool\" \\ \\membership\\\n where mem_Collect_eq [iff, code_unfold]: \"member a (Collect P) = P a\"\n and Collect_mem_eq [simp, code_unfold]: \"Collect (\\x. member x A) = A\"\n\nnotation\n member (\\'(\\')\\) and\n member (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50)\n\nabbreviation not_member\n where \"not_member x A \\ \\ (x \\ A)\" \\ \\non-membership\\\nnotation\n not_member (\\'(\\')\\) and\n not_member (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50)\n\nopen_bundle member_ASCII_syntax\nbegin\nnotation (ASCII)\n member (\\'(:')\\) and\n member (\\(\\notation=\\infix :\\\\_/ : _)\\ [51, 51] 50) and\n not_member (\\'(~:')\\) and\n not_member (\\(\\notation=\\infix ~:\\\\_/ ~: _)\\ [51, 51] 50)\nend\n\ntext \\Set comprehensions\\\n\nsyntax\n \"_Coll\" :: \"pttrn \\ bool \\ 'a set\" (\\(\\indent=1 notation=\\mixfix set comprehension\\\\{_./ _})\\)\nsyntax_consts\n \"_Coll\" \\ Collect\ntranslations\n \"{x. P}\" \\ \"CONST Collect (\\x. P)\"\n\nsyntax (ASCII)\n \"_Collect\" :: \"pttrn \\ 'a set \\ bool \\ 'a set\" (\\(\\indent=1 notation=\\mixfix set comprehension\\\\{(_/: _)./ _})\\)\nsyntax\n \"_Collect\" :: \"pttrn \\ 'a set \\ bool \\ 'a set\" (\\(\\indent=1 notation=\\mixfix set comprehension\\\\{(_/ \\ _)./ _})\\)\ntranslations\n \"{p:A. P}\" \\ \"CONST Collect (\\p. p \\ A \\ P)\"\n\nML \\\n fun Collect_binder_tr' c [Abs (x, T, t), Const (\\<^const_syntax>\\Collect\\, _) $ Abs (y, _, P)] =\n if x = y then\n let\n val x' = Syntax_Trans.mark_bound_body (x, T);\n val t' = subst_bound (x', t);\n val P' = subst_bound (x', P);\n in Syntax.const c $ Syntax_Trans.mark_bound_abs (x, T) $ P' $ t' end\n else raise Match\n | Collect_binder_tr' _ _ = raise Match\n\\\n\nlemma CollectI: \"P a \\ a \\ {x. P x}\"\n by sorry\n\nlemma CollectD: \"a \\ {x. P x} \\ P a\"\n by sorry\n\nlemma Collect_cong: \"(\\x. P x = Q x) \\ {x. P x} = {x. Q x}\"\n by sorry\n\ntext \\\n Simproc for pulling \\x = t\\ in \\{x. \\ \\ x = t \\ \\}\\\n to the front (and similarly for \\t = x\\):\n\\\n\nsimproc_setup defined_Collect (\"{x. P x \\ Q x}\") = \\\n K (Quantifier1.rearrange_Collect\n (fn ctxt =>\n resolve_tac ctxt @{thms Collect_cong} 1 THEN\n resolve_tac ctxt @{thms iffI} 1 THEN\n ALLGOALS\n (EVERY' [REPEAT_DETERM o eresolve_tac ctxt @{thms conjE},\n DEPTH_SOLVE_1 o (assume_tac ctxt ORELSE' resolve_tac ctxt @{thms conjI})])))\n\\\n\nlemmas CollectE = CollectD [elim_format]\n\nlemma set_eqI:\n assumes \"\\x. x \\ A \\ x \\ B\"\n shows \"A = B\"\n by sorry\n\nlemma set_eq_iff: \"A = B \\ (\\x. x \\ A \\ x \\ B)\"\n by sorry\n\nlemma Collect_eqI:\n assumes \"\\x. P x = Q x\"\n shows \"Collect P = Collect Q\"\n by sorry\n\ntext \\Lifting of predicate class instances\\\n\ninstantiation set :: (type) boolean_algebra\nbegin\n\ndefinition less_eq_set\n where \"A \\ B \\ (\\x. member x A) \\ (\\x. member x B)\"\n\ndefinition less_set\n where \"A < B \\ (\\x. member x A) < (\\x. member x B)\"\n\ndefinition inf_set\n where \"A \\ B = Collect ((\\x. member x A) \\ (\\x. member x B))\"\n\ndefinition sup_set\n where \"A \\ B = Collect ((\\x. member x A) \\ (\\x. member x B))\"\n\ndefinition bot_set\n where \"\\ = Collect \\\"\n\ndefinition top_set\n where \"\\ = Collect \\\"\n\ndefinition uminus_set\n where \"- A = Collect (- (\\x. member x A))\"\n\ndefinition minus_set\n where \"A - B = Collect ((\\x. member x A) - (\\x. member x B))\"\n\ninstance\n by standard\n (simp_all add: less_eq_set_def less_set_def inf_set_def sup_set_def\n bot_set_def top_set_def uminus_set_def minus_set_def\n less_le_not_le sup_inf_distrib1 diff_eq set_eqI fun_eq_iff\n del: inf_apply sup_apply bot_apply top_apply minus_apply uminus_apply)\n\nend\n\ntext \\Set enumerations\\\n\nabbreviation empty :: \"'a set\" (\\{}\\)\n where \"{} \\ bot\"\n\ndefinition insert :: \"'a \\ 'a set \\ 'a set\"\n where insert_compr: \"insert a B = {x. x = a \\ x \\ B}\"\n\nopen_bundle set_enumeration_syntax\nbegin\n\nsyntax\n \"_Finset\" :: \"args \\ 'a set\" (\\(\\indent=1 notation=\\mixfix set enumeration\\\\{_})\\)\nsyntax_consts\n \"_Finset\" \\ insert\ntranslations\n \"{x, xs}\" \\ \"CONST insert x {xs}\"\n \"{x}\" \\ \"CONST insert x {}\"\n\nend\n\nsubsection \\Subsets and bounded quantifiers\\\n\nabbreviation subset :: \"'a set \\ 'a set \\ bool\"\n where \"subset \\ less\"\n\nabbreviation subset_eq :: \"'a set \\ 'a set \\ bool\"\n where \"subset_eq \\ less_eq\"\n\nnotation\n subset (\\'(\\')\\) and\n subset (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50) and\n subset_eq (\\'(\\')\\) and\n subset_eq (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50)\n\nabbreviation (input)\n supset :: \"'a set \\ 'a set \\ bool\" where\n \"supset \\ greater\"\n\nabbreviation (input)\n supset_eq :: \"'a set \\ 'a set \\ bool\" where\n \"supset_eq \\ greater_eq\"\n\nnotation\n supset (\\'(\\')\\) and\n supset (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50) and\n supset_eq (\\'(\\')\\) and\n supset_eq (\\(\\notation=\\infix \\\\\\_/ \\ _)\\ [51, 51] 50)\n\nnotation (ASCII output)\n subset (\\'(<')\\) and\n subset (\\(\\notation=\\infix <\\\\_/ < _)\\ [51, 51] 50) and\n subset_eq (\\'(<=')\\) and\n subset_eq (\\(\\notation=\\infix <=\\\\_/ <= _)\\ [51, 51] 50)\n\ndefinition Ball :: \"'a set \\ ('a \\ bool) \\ bool\"\n where \"Ball A P \\ (\\x. x \\ A \\ P x)\" \\ \\bounded universal quantifiers\\\n\ndefinition Bex :: \"'a set \\ ('a \\ bool) \\ bool\"\n where \"Bex A P \\ (\\x. x \\ A \\ P x)\" \\ \\bounded existential quantifiers\\\n\nsyntax (ASCII)\n \"_Ball\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder ALL :\\\\ALL (_/:_)./ _)\\ [0, 0, 10] 10)\n \"_Bex\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder EX :\\\\EX (_/:_)./ _)\\ [0, 0, 10] 10)\n \"_Bex1\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder EX! :\\\\EX! (_/:_)./ _)\\ [0, 0, 10] 10)\n \"_Bleast\" :: \"id \\ 'a set \\ bool \\ 'a\" (\\(\\indent=3 notation=\\binder LEAST :\\\\LEAST (_/:_)./ _)\\ [0, 0, 10] 10)\n\nsyntax (input)\n \"_Ball\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder ! :\\\\! (_/:_)./ _)\\ [0, 0, 10] 10)\n \"_Bex\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder ? :\\\\? (_/:_)./ _)\\ [0, 0, 10] 10)\n \"_Bex1\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder ?! :\\\\?! (_/:_)./ _)\\ [0, 0, 10] 10)\n\nsyntax\n \"_Ball\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\(_/\\_)./ _)\\ [0, 0, 10] 10)\n \"_Bex\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\(_/\\_)./ _)\\ [0, 0, 10] 10)\n \"_Bex1\" :: \"pttrn \\ 'a set \\ bool \\ bool\" (\\(\\indent=3 notation=\\binder \\!\\\\\\!(_/\\_)./ _)\\ [0, 0, 10] 10)\n \"_Bleast\" :: \"id \\ 'a set \\ bool \\ 'a\" (\\(\\indent=3 notation=\\binder LEAST\\\\LEAST(_/\\_)./ _)\\ [0, 0, 10] 10)\n\nsyntax_consts\n \"_Ball\" \\ Ball and\n \"_Bex\" \\ Bex and\n \"_Bex1\" \\ Ex1 and\n \"_Bleast\" \\ Least\n\ntranslations\n \"\\x\\A. P\" \\ \"CONST Ball A (\\x. P)\"\n \"\\x\\A. P\" \\ \"CONST Bex A (\\x. P)\"\n \"\\!x\\A. P\" \\ \"\\!x. x \\ A \\ P\"\n \"LEAST x:A. P\" \\ \"LEAST x. x \\ A \\ P\"\n\nsyntax (ASCII output)\n \"_setlessAll\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder ALL\\\\ALL _<_./ _)\\ [0, 0, 10] 10)\n \"_setlessEx\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder EX\\\\EX _<_./ _)\\ [0, 0, 10] 10)\n \"_setleAll\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder ALL\\\\ALL _<=_./ _)\\ [0, 0, 10] 10)\n \"_setleEx\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder EX\\\\EX _<=_./ _)\\ [0, 0, 10] 10)\n \"_setleEx1\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder EX!\\\\EX! _<=_./ _)\\ [0, 0, 10] 10)\n\nsyntax\n \"_setlessAll\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\_\\_./ _)\\ [0, 0, 10] 10)\n \"_setlessEx\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\_\\_./ _)\\ [0, 0, 10] 10)\n \"_setleAll\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\_\\_./ _)\\ [0, 0, 10] 10)\n \"_setleEx\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder \\\\\\\\_\\_./ _)\\ [0, 0, 10] 10)\n \"_setleEx1\" :: \"[idt, 'a, bool] \\ bool\" (\\(\\indent=3 notation=\\binder \\!\\\\\\!_\\_./ _)\\ [0, 0, 10] 10)\n\nsyntax_consts\n \"_setlessAll\" \"_setleAll\" \\ All and\n \"_setlessEx\" \"_setleEx\" \\ Ex and\n \"_setleEx1\" \\ Ex1\n\ntranslations\n \"\\A\\B. P\" \\ \"\\A. A \\ B \\ P\"\n \"\\A\\B. P\" \\ \"\\A. A \\ B \\ P\"\n \"\\A\\B. P\" \\ \"\\A. A \\ B \\ P\"\n \"\\A\\B. P\" \\ \"\\A. A \\ B \\ P\"\n \"\\!A\\B. P\" \\ \"\\!A. A \\ B \\ P\"\n\nprint_translation \\\n let\n val All_binder = Mixfix.binder_name \\<^const_syntax>\\All\\;\n val Ex_binder = Mixfix.binder_name \\<^const_syntax>\\Ex\\;\n val impl = \\<^const_syntax>\\HOL.implies\\;\n val conj = \\<^const_syntax>\\HOL.conj\\;\n val sbset = \\<^const_syntax>\\subset\\;\n val sbset_eq = \\<^const_syntax>\\subset_eq\\;\n\n val trans =\n [((All_binder, impl, sbset), \\<^syntax_const>\\_setlessAll\\),\n ((All_binder, impl, sbset_eq), \\<^syntax_const>\\_setleAll\\),\n ((Ex_binder, conj, sbset), \\<^syntax_const>\\_setlessEx\\),\n ((Ex_binder, conj, sbset_eq), \\<^syntax_const>\\_setleEx\\)];\n\n fun mk v (v', T) c n P =\n if v = v' andalso not (Term.exists_subterm (fn Free (x, _) => x = v | _ => false) n)\n then Syntax.const c $ Syntax_Trans.mark_bound_body (v', T) $ n $ P\n else raise Match;\n\n fun tr' q = (q, fn _ =>\n (fn [Const (\\<^syntax_const>\\_bound\\, _) $ Free (v, \\<^Type>\\set _\\),\n Const (c, _) $\n (Const (d, _) $ (Const (\\<^syntax_const>\\_bound\\, _) $ Free (v', T)) $ n) $ P] =>\n (case AList.lookup (=) trans (q, c, d) of\n NONE => raise Match\n | SOME l => mk v (v', T) l n P)\n | _ => raise Match));\n in\n [tr' All_binder, tr' Ex_binder]\n end\n\\\n\ntext \\\n \\<^medskip>\n Translate between \\{e | x1\\xn. P}\\ and \\{u. \\x1\\xn. u = e \\ P}\\;\n \\{y. \\x1\\xn. y = e \\ P}\\ is only translated if \\[0..n] \\ bvs e\\.\n\\\n\nsyntax\n \"_Setcompr\" :: \"'a \\ idts \\ bool \\ 'a set\"\n (\\(\\indent=1 notation=\\mixfix set comprehension\\\\{_ |/_./ _})\\)\nsyntax_consts\n \"_Setcompr\" \\ Collect\n\nparse_translation \\\n let\n val ex_tr = snd (Syntax_Trans.mk_binder_tr (\"EX \", \\<^const_syntax>\\Ex\\));\n\n fun nvars (Const (\\<^syntax_const>\\_idts\\, _) $ _ $ idts) = nvars idts + 1\n | nvars _ = 1;\n\n fun setcompr_tr ctxt [e, idts, b] =\n let\n val eq = Syntax.const \\<^const_syntax>\\HOL.eq\\ $ Bound (nvars idts) $ e;\n val P = Syntax.const \\<^const_syntax>\\HOL.conj\\ $ eq $ b;\n val exP = ex_tr ctxt [idts, P];\n in Syntax.const \\<^const_syntax>\\Collect\\ $ absdummy dummyT exP end;\n\n in [(\\<^syntax_const>\\_Setcompr\\, setcompr_tr)] end\n\\\n\ntyped_print_translation \\\n [(\\<^const_syntax>\\Ball\\, Syntax_Trans.preserve_binder_abs2_tr' \\<^syntax_const>\\_Ball\\),\n (\\<^const_syntax>\\Bex\\, Syntax_Trans.preserve_binder_abs2_tr' \\<^syntax_const>\\_Bex\\)]\n\\ \\ \\to avoid eta-contraction of body\\\n\nprint_translation \\\nlet\n val ex_tr' = snd (Syntax_Trans.mk_binder_tr' (\\<^const_syntax>\\Ex\\, \"DUMMY\"));\n\n fun setcompr_tr' ctxt [Abs (abs as (_, _, P))] =\n let\n fun check (Const (\\<^const_syntax>\\Ex\\, _) $ Abs (_, _, P), n) = check (P, n + 1)\n | check (Const (\\<^const_syntax>\\HOL.conj\\, _) $\n (Const (\\<^const_syntax>\\HOL.eq\\, _) $ Bound m $ e) $ P, n) =\n n > 0 andalso m = n andalso not (loose_bvar1 (P, n)) andalso\n subset (=) (0 upto (n - 1), add_loose_bnos (e, 0, []))\n | check _ = false;\n\n fun tr' (_ $ abs) =\n let val _ $ idts $ (_ $ (_ $ _ $ e) $ Q) = ex_tr' ctxt [abs]\n in Syntax.const \\<^syntax_const>\\_Setcompr\\ $ e $ idts $ Q end;\n in\n if check (P, 0) then tr' P\n else\n let\n val (x as _ $ Free(xN, _), t) = Syntax_Trans.atomic_abs_tr' ctxt abs;\n val M = Syntax.const \\<^syntax_const>\\_Coll\\ $ x $ t;\n in\n case t of\n Const (\\<^const_syntax>\\HOL.conj\\, _) $\n (Const (\\<^const_syntax>\\Set.member\\, _) $\n (Const (\\<^syntax_const>\\_bound\\, _) $ Free (yN, _)) $ A) $ P =>\n if xN = yN then Syntax.const \\<^syntax_const>\\_Collect\\ $ x $ A $ P else M\n | _ => M\n end\n end;\n in [(\\<^const_syntax>\\Collect\\, setcompr_tr')] end\n\\\n\nsimproc_setup defined_Bex (\"\\x\\A. P x \\ Q x\") = \\\n K (Quantifier1.rearrange_Bex (fn ctxt => unfold_tac ctxt @{thms Bex_def}))\n\\\n\nsimproc_setup defined_All (\"\\x\\A. P x \\ Q x\") = \\\n K (Quantifier1.rearrange_Ball (fn ctxt => unfold_tac ctxt @{thms Ball_def}))\n\\\n\nlemma ballI [intro!]: \"(\\x. x \\ A \\ P x) \\ \\x\\A. P x\"\n by sorry\n\nlemmas strip = impI allI ballI\n\nlemma bspec [dest?]: \"\\x\\A. P x \\ x \\ A \\ P x\"\n by sorry\n\ntext \\Gives better instantiation for bound:\\\nsetup \\\n map_theory_claset (fn ctxt =>\n ctxt addbefore (\"bspec\", fn ctxt' => dresolve_tac ctxt' @{thms bspec} THEN' assume_tac ctxt'))\n\\\n\nML \\\nstructure Simpdata =\nstruct\n open Simpdata;\n val mksimps_pairs = [(\\<^const_name>\\Ball\\, @{thms bspec})] @ mksimps_pairs;\nend;\n\nopen Simpdata;\n\\\n\ndeclaration \\fn _ => Simplifier.map_simpset (Simplifier.set_mksimps (mksimps mksimps_pairs))\\\n\nlemma ballE [elim]: \"\\x\\A. P x \\ (P x \\ Q) \\ (x \\ A \\ Q) \\ Q\"\n by sorry\n\nlemma bexI [intro]: \"P x \\ x \\ A \\ \\x\\A. P x\"\n \\ \\Normally the best argument order: \\P x\\ constrains the choice of \\x \\ A\\.\\\n by sorry\n\nlemma rev_bexI [intro?]: \"x \\ A \\ P x \\ \\x\\A. P x\"\n \\ \\The best argument order when there is only one \\x \\ A\\.\\\n by sorry\n\nlemma bexCI: \"(\\x\\A. \\ P x \\ P a) \\ a \\ A \\ \\x\\A. P x\"\n by sorry\n\nlemma bexE [elim!]: \"\\x\\A. P x \\ (\\x. x \\ A \\ P x \\ Q) \\ Q\"\n by sorry\n\nlemma ball_triv [simp]: \"(\\x\\A. P) \\ ((\\x. x \\ A) \\ P)\"\n \\ \\trivial rewrite rule.\\\n by sorry\n\nlemma bex_triv [simp]: \"(\\x\\A. P) \\ ((\\x. x \\ A) \\ P)\"\n \\ \\Dual form for existentials.\\\n by sorry\n\nlemma bex_triv_one_point1 [simp]: \"(\\x\\A. x = a) \\ a \\ A\"\n by sorry\n\nlemma bex_triv_one_point2 [simp]: \"(\\x\\A. a = x) \\ a \\ A\"\n by sorry\n\nlemma bex_one_point1 [simp]: \"(\\x\\A. x = a \\ P x) \\ a \\ A \\ P a\"\n by sorry\n\nlemma bex_one_point2 [simp]: \"(\\x\\A. a = x \\ P x) \\ a \\ A \\ P a\"\n by sorry\n\nlemma ball_one_point1 [simp]: \"(\\x\\A. x = a \\ P x) \\ (a \\ A \\ P a)\"\n by sorry\n\nlemma ball_one_point2 [simp]: \"(\\x\\A. a = x \\ P x) \\ (a \\ A \\ P a)\"\n by sorry\n\nlemma ball_conj_distrib: \"(\\x\\A. P x \\ Q x) \\ (\\x\\A. P x) \\ (\\x\\A. Q x)\"\n by sorry\n\nlemma bex_disj_distrib: \"(\\x\\A. P x \\ Q x) \\ (\\x\\A. P x) \\ (\\x\\A. Q x)\"\n by sorry\n\ntext \\Congruence rules\\\n\nlemma ball_cong:\n \"\\ A = B; \\x. x \\ B \\ P x \\ Q x \\ \\\n (\\x\\A. P x) \\ (\\x\\B. Q x)\"\n by sorry\n\nlemma ball_cong_simp [cong]:\n \"\\ A = B; \\x. x \\ B =simp=> P x \\ Q x \\ \\\n (\\x\\A. P x) \\ (\\x\\B. Q x)\"\n by sorry\n\nlemma bex_cong:\n \"\\ A = B; \\x. x \\ B \\ P x \\ Q x \\ \\\n (\\x\\A. P x) \\ (\\x\\B. Q x)\"\n by sorry\n\nlemma bex_cong_simp [cong]:\n \"\\ A = B; \\x. x \\ B =simp=> P x \\ Q x \\ \\\n (\\x\\A. P x) \\ (\\x\\B. Q x)\"\n by sorry\n\nlemma bex1_def: \"(\\!x\\X. P x) \\ (\\x\\X. P x) \\ (\\x\\X. \\y\\X. P x \\ P y \\ x = y)\"\n by sorry\n\nsubsection \\Basic operations\\\n\nsubsubsection \\Subsets\\\n\nlemma subsetI [intro!]: \"(\\x. x \\ A \\ x \\ B) \\ A \\ B\"\n by sorry\n\ntext \\\n \\<^medskip>\n Map the type \\'a set \\ anything\\ to just \\'a\\; for overloading constants\n whose first argument has type \\'a set\\.\n\\\n\nlemma subsetD [elim, intro?]: \"A \\ B \\ c \\ A \\ c \\ B\"\n by sorry\n\nlemma rev_subsetD [intro?,no_atp]: \"c \\ A \\ A \\ B \\ c \\ B\"\n \\ \\The same, with reversed premises for use with @{method erule} -- cf. @{thm rev_mp}.\\\n by sorry\n\nlemma subsetCE [elim,no_atp]: \"A \\ B \\ (c \\ A \\ P) \\ (c \\ B \\ P) \\ P\"\n \\ \\Classical elimination rule.\\\n by sorry\n\nlemma subset_eq: \"A \\ B \\ (\\x\\A. x \\ B)\"\n by sorry\n\nlemma contra_subsetD [no_atp]: \"A \\ B \\ c \\ B \\ c \\ A\"\n by sorry\n\nlemma subset_refl: \"A \\ A\"\n by sorry\n\nlemma subset_trans: \"A \\ B \\ B \\ C \\ A \\ C\"\n by sorry\n\nlemma subset_not_subset_eq [code]: \"A \\ B \\ A \\ B \\ \\ B \\ A\"\n by sorry\n\nlemma eq_mem_trans: \"a = b \\ b \\ A \\ a \\ A\"\n by sorry\n\nlemmas basic_trans_rules [trans] =\n order_trans_rules rev_subsetD subsetD eq_mem_trans\n\nsubsubsection \\Equality\\\n\nlemma subset_antisym [intro!]: \"A \\ B \\ B \\ A \\ A = B\"\n \\ \\Anti-symmetry of the subset relation.\\\n by sorry\n\ntext \\\\<^medskip> Equality rules from ZF set theory -- are they appropriate here?\\\n\nlemma equalityD1: \"A = B \\ A \\ B\"\n by sorry\n\nlemma equalityD2: \"A = B \\ B \\ A\"\n by sorry\n\ntext \\\n \\<^medskip>\n Be careful when adding this to the claset as \\subset_empty\\ is in the\n simpset: \\<^prop>\\A = {}\\ goes to \\<^prop>\\{} \\ A\\ and \\<^prop>\\A \\ {}\\\n and then back to \\<^prop>\\A = {}\\!\n\\\n\nlemma equalityE: \"A = B \\ (A \\ B \\ B \\ A \\ P) \\ P\"\n by sorry\n\nlemma equalityCE [elim]: \"A = B \\ (c \\ A \\ c \\ B \\ P) \\ (c \\ A \\ c \\ B \\ P) \\ P\"\n by sorry\n\nlemma eqset_imp_iff: \"A = B \\ x \\ A \\ x \\ B\"\n by sorry\n\nlemma eqelem_imp_iff: \"x = y \\ x \\ A \\ y \\ A\"\n by sorry\n\nsubsubsection \\The empty set\\\n\nlemma empty_def: \"{} = {x. False}\"\n by sorry\n\nlemma empty_iff [simp]: \"c \\ {} \\ False\"\n by sorry\n\nlemma emptyE [elim!]: \"a \\ {} \\ P\"\n by sorry\n\nlemma empty_subsetI [iff]: \"{} \\ A\"\n \\ \\One effect is to delete the ASSUMPTION \\<^prop>\\{} \\ A\\\\\n by sorry\n\nlemma equals0I: \"(\\y. y \\ A \\ False) \\ A = {}\"\n by sorry\n\nlemma equals0D: \"A = {} \\ a \\ A\"\n \\ \\Use for reasoning about disjointness: \\A \\ B = {}\\\\\n by sorry\n\nlemma ball_empty [simp]: \"Ball {} P \\ True\"\n by sorry\n\nlemma bex_empty [simp]: \"Bex {} P \\ False\"\n by sorry\n\nsubsubsection \\The universal set -- UNIV\\\n\nabbreviation UNIV :: \"'a set\"\n where \"UNIV \\ top\"\n\nlemma UNIV_def: \"UNIV = {x. True}\"\n by sorry\n\nlemma UNIV_I [simp]: \"x \\ UNIV\"\n by sorry\n\ndeclare UNIV_I [intro] \\ \\unsafe makes it less likely to cause problems\\\n\nlemma UNIV_witness [intro?]: \"\\x. x \\ UNIV\"\n by sorry\n\nlemma subset_UNIV: \"A \\ UNIV\"\n by sorry\n\ntext \\\n \\<^medskip>\n Eta-contracting these two rules (to remove \\P\\) causes them\n to be ignored because of their interaction with congruence rules.\n\\\n\nlemma ball_UNIV [simp]: \"Ball UNIV P \\ All P\"\n by sorry\n\nlemma bex_UNIV [simp]: \"Bex UNIV P \\ Ex P\"\n by sorry\n\nlemma UNIV_eq_I: \"(\\x. x \\ A) \\ UNIV = A\"\n by sorry\n\nlemma UNIV_not_empty [iff]: \"UNIV \\ {}\"\n by sorry\n\nlemma empty_not_UNIV[simp]: \"{} \\ UNIV\"\n by sorry\n\nsubsubsection \\The Powerset operator -- Pow\\\n\ndefinition Pow :: \"'a set \\ 'a set set\"\n where Pow_def: \"Pow A = {B. B \\ A}\"\n\nlemma Pow_iff [iff]: \"A \\ Pow B \\ A \\ B\"\n by sorry\n\nlemma PowI: \"A \\ B \\ A \\ Pow B\"\n by sorry\n\nlemma PowD: \"A \\ Pow B \\ A \\ B\"\n by sorry\n\nlemma Pow_bottom: \"{} \\ Pow B\"\n by sorry\n\nlemma Pow_top: \"A \\ Pow A\"\n by sorry\n\nlemma Pow_not_empty: \"Pow A \\ {}\"\n by sorry\n\nsubsubsection \\Set complement\\\n\nlemma Compl_iff [simp]: \"c \\ - A \\ c \\ A\"\n by sorry\n\nlemma ComplI [intro!]: \"(c \\ A \\ False) \\ c \\ - A\"\n by sorry\n\ntext \\\n \\<^medskip>\n This form, with negated conclusion, works well with the Classical prover.\n Negated assumptions behave like formulae on the right side of the\n notional turnstile \\dots\n\\\n\nlemma ComplD [dest!]: \"c \\ - A \\ c \\ A\"\n by sorry\n\nlemmas ComplE = ComplD [elim_format]\n\nlemma Compl_eq: \"- A = {x. \\ x \\ A}\"\n by sorry\n\nsubsubsection \\Binary intersection\\\n\nabbreviation inter :: \"'a set \\ 'a set \\ 'a set\" (infixl \\\\\\ 70)\n where \"(\\) \\ inf\"\n\nnotation (ASCII)\n inter (infixl \\Int\\ 70)\n\nlemma Int_def: \"A \\ B = {x. x \\ A \\ x \\ B}\"\n by sorry\n\nlemma Int_iff [simp]: \"c \\ A \\ B \\ c \\ A \\ c \\ B\"\n by sorry\n\nlemma IntI [intro!]: \"c \\ A \\ c \\ B \\ c \\ A \\ B\"\n by sorry\n\nlemma IntD1: \"c \\ A \\ B \\ c \\ A\"\n by sorry\n\nlemma IntD2: \"c \\ A \\ B \\ c \\ B\"\n by sorry\n\nlemma IntE [elim!]: \"c \\ A \\ B \\ (c \\ A \\ c \\ B \\ P) \\ P\"\n by sorry\n\nsubsubsection \\Binary union\\\n\nabbreviation union :: \"'a set \\ 'a set \\ 'a set\" (infixl \\\\\\ 65)\n where \"union \\ sup\"\n\nnotation (ASCII)\n union (infixl \\Un\\ 65)\n\nlemma Un_def: \"A \\ B = {x. x \\ A \\ x \\ B}\"\n by sorry\n\nlemma Un_iff [simp]: \"c \\ A \\ B \\ c \\ A \\ c \\ B\"\n by sorry\n\nlemma UnI1 [elim?]: \"c \\ A \\ c \\ A \\ B\"\n by sorry\n\nlemma UnI2 [elim?]: \"c \\ B \\ c \\ A \\ B\"\n by sorry\n\ntext \\\\<^medskip> Classical introduction rule: no commitment to \\A\\ vs. \\B\\.\\\nlemma UnCI [intro!]: \"(c \\ B \\ c \\ A) \\ c \\ A \\ B\"\n by sorry\n\nlemma UnE [elim!]: \"c \\ A \\ B \\ (c \\ A \\ P) \\ (c \\ B \\ P) \\ P\"\n by sorry\n\nlemma insert_def: \"insert a B = {x. x = a} \\ B\"\n by sorry\n\nsubsubsection \\Set difference\\\n\ntext \\The minius-sign syntax continues to be accepted\\\nabbreviation set_difference :: \"['a set, 'a set] \\ 'a set\" \n (infixl \"\\\" 65) where \"A \\ B \\ A-B\"\n\nlemma Diff_iff [simp]: \"c \\ A - B \\ c \\ A \\ c \\ B\"\n by sorry\n\nlemma DiffI [intro!]: \"c \\ A \\ c \\ B \\ c \\ A - B\"\n by sorry\n\nlemma DiffD1: \"c \\ A - B \\ c \\ A\"\n by sorry\n\nlemma DiffD2: \"c \\ A - B \\ c \\ B \\ P\"\n by sorry\n\nlemma DiffE [elim!]: \"c \\ A - B \\ (c \\ A \\ c \\ B \\ P) \\ P\"\n by sorry\n\nlemma set_diff_eq: \"A - B = {x. x \\ A \\ x \\ B}\"\n by sorry\n\nlemma Compl_eq_Diff_UNIV: \"- A = (UNIV - A)\"\n by sorry\n\nabbreviation sym_diff :: \"'a set \\ 'a set \\ 'a set\" where\n \"sym_diff A B \\ ((A - B) \\ (B-A))\"\n\nsubsubsection \\Augmenting a set -- \\<^const>\\insert\\\\\n\nlemma insert_iff [simp]: \"a \\ insert b A \\ a = b \\ a \\ A\"\n by sorry\n\nlemma insertI1: \"a \\ insert a B\"\n by sorry\n\nlemma insertI2: \"a \\ B \\ a \\ insert b B\"\n by sorry\n\nlemma insertE [elim!]: \"a \\ insert b A \\ (a = b \\ P) \\ (a \\ A \\ P) \\ P\"\n by sorry\n\nlemma insertCI [intro!]: \"(a \\ B \\ a = b) \\ a \\ insert b B\"\n \\ \\Classical introduction rule.\\\n by sorry\n\nlemma subset_insert_iff: \"A \\ insert x B \\ (if x \\ A then A - {x} \\ B else A \\ B)\"\n by sorry\n\nlemma set_insert:\n assumes \"x \\ A\"\n obtains B where \"A = insert x B\" and \"x \\ B\"\n by sorry\n\nlemma insert_ident: \"x \\ A \\ x \\ B \\ insert x A = insert x B \\ A = B\"\n by sorry\n\nlemma insert_eq_iff:\n assumes \"a \\ A\" \"b \\ B\"\n shows \"insert a A = insert b B \\\n (if a = b then A = B else \\C. A = insert b C \\ b \\ C \\ B = insert a C \\ a \\ C)\"\n (is \"?L \\ ?R\")\n by sorry\n\nlemma insert_UNIV[simp]: \"insert x UNIV = UNIV\"\n by sorry\n\nsubsubsection \\Singletons, using insert\\\n\nlemma singletonI [intro!]: \"a \\ {a}\"\n \\ \\Redundant? But unlike \\insertCI\\, it proves the subgoal immediately!\\\n by sorry\n\nlemma singletonD [dest!]: \"b \\ {a} \\ b = a\"\n by sorry\n\nlemmas singletonE = singletonD [elim_format]\n\nlemma singleton_iff: \"b \\ {a} \\ b = a\"\n by sorry\n\nlemma singleton_inject [dest!]: \"{a} = {b} \\ a = b\"\n by sorry\n\nlemma singleton_insert_inj_eq [iff]: \"{b} = insert a A \\ a = b \\ A \\ {b}\"\n by sorry\n\nlemma singleton_insert_inj_eq' [iff]: \"insert a A = {b} \\ a = b \\ A \\ {b}\"\n by sorry\n\nlemma subset_singletonD: \"A \\ {x} \\ A = {} \\ A = {x}\"\n by sorry\n\nlemma subset_singleton_iff: \"X \\ {a} \\ X = {} \\ X = {a}\"\n by sorry\n\nlemma subset_singleton_iff_Uniq: \"(\\a. A \\ {a}) \\ (\\\\<^sub>\\\\<^sub>1x. x \\ A)\"\n by sorry\n\nlemma singleton_conv [simp]: \"{x. x = a} = {a}\"\n by sorry\n\nlemma singleton_conv2 [simp]: \"{x. a = x} = {a}\"\n by sorry\n\nlemma Diff_single_insert: \"A - {x} \\ B \\ A \\ insert x B\"\n by sorry\n\nlemma subset_Diff_insert: \"A \\ B - insert x C \\ A \\ B - C \\ x \\ A\"\n by sorry\n\nlemma doubleton_eq_iff: \"{a, b} = {c, d} \\ a = c \\ b = d \\ a = d \\ b = c\"\n by sorry\n\nlemma Un_singleton_iff: \"A \\ B = {x} \\ A = {} \\ B = {x} \\ A = {x} \\ B = {} \\ A = {x} \\ B = {x}\"\n by sorry\n\nlemma singleton_Un_iff: \"{x} = A \\ B \\ A = {} \\ B = {x} \\ A = {x} \\ B = {} \\ A = {x} \\ B = {x}\"\n by sorry\n\nsubsubsection \\Image of a set under a function\\\n\ntext \\Frequently \\b\\ does not have the syntactic form of \\f x\\.\\\n\ndefinition image :: \"('a \\ 'b) \\ 'a set \\ 'b set\" (infixr \\`\\ 90)\n where \"f ` A = {y. \\x\\A. y = f x}\"\n\nlemma image_eqI [simp, intro]: \"b = f x \\ x \\ A \\ b \\ f ` A\"\n by sorry\n\nlemma imageI: \"x \\ A \\ f x \\ f ` A\"\n by sorry\n\nlemma rev_image_eqI: \"x \\ A \\ b = f x \\ b \\ f ` A\"\n \\ \\This version's more effective when we already have the required \\x\\.\\\n by sorry\n\nlemma imageE [elim!]:\n assumes \"b \\ (\\x. f x) ` A\" \\ \\The eta-expansion gives variable-name preservation.\\\n obtains x where \"b = f x\" and \"x \\ A\"\n by sorry\n\nlemma Compr_image_eq: \"{x \\ f ` A. P x} = f ` {x \\ A. P (f x)}\"\n by sorry\n\nlemma image_Un: \"f ` (A \\ B) = f ` A \\ f ` B\"\n by sorry\n\nlemma image_iff: \"z \\ f ` A \\ (\\x\\A. z = f x)\"\n by sorry\n\nlemma image_subsetI: \"(\\x. x \\ A \\ f x \\ B) \\ f ` A \\ B\"\n \\ \\Replaces the three steps \\subsetI\\, \\imageE\\,\n \\hypsubst\\, but breaks too many existing proofs.\\\n by sorry\n\nlemma image_subset_iff: \"f ` A \\ B \\ (\\x\\A. f x \\ B)\"\n \\ \\This rewrite rule would confuse users if made default.\\\n by sorry\n\nlemma subset_imageE:\n assumes \"B \\ f ` A\"\n obtains C where \"C \\ A\" and \"B = f ` C\"\n by sorry\n\nlemma subset_image_iff: \"B \\ f ` A \\ (\\AA\\A. B = f ` AA)\"\n by sorry\n\nlemma image_ident [simp]: \"(\\x. x) ` Y = Y\"\n by sorry\n\nlemma image_empty [simp]: \"f ` {} = {}\"\n by sorry\n\nlemma image_insert [simp]: \"f ` insert a B = insert (f a) (f ` B)\"\n by sorry\n\nlemma image_constant: \"x \\ A \\ (\\x. c) ` A = {c}\"\n by sorry\n\nlemma image_constant_conv: \"(\\x. c) ` A = (if A = {} then {} else {c})\"\n by sorry\n\nlemma image_image: \"f ` (g ` A) = (\\x. f (g x)) ` A\"\n by sorry\n\nlemma insert_image [simp]: \"x \\ A \\ insert (f x) (f ` A) = f ` A\"\n by sorry\n\nlemma image_is_empty [iff]: \"f ` A = {} \\ A = {}\"\n by sorry\n\nlemma empty_is_image [iff]: \"{} = f ` A \\ A = {}\"\n by sorry\n\nlemma image_Collect: \"f ` {x. P x} = {f x | x. P x}\"\n \\ \\NOT suitable as a default simp rule: the RHS isn't simpler than the LHS,\n with its implicit quantifier and conjunction. Also image enjoys better\n equational properties than does the RHS.\\\n by sorry\n\nlemma if_image_distrib [simp]:\n \"(\\x. if P x then f x else g x) ` S = f ` (S \\ {x. P x}) \\ g ` (S \\ {x. \\ P x})\"\n by sorry\n\nlemma image_cong:\n \"f ` M = g ` N\" if \"M = N\" \"\\x. x \\ N \\ f x = g x\"\n by sorry\n\nlemma image_cong_simp [cong]:\n \"f ` M = g ` N\" if \"M = N\" \"\\x. x \\ N =simp=> f x = g x\"\n by sorry\n\nlemma image_Int_subset: \"f ` (A \\ B) \\ f ` A \\ f ` B\"\n by sorry\n\nlemma image_diff_subset: \"f ` A - f ` B \\ f ` (A - B)\"\n by sorry\n\nlemma Setcompr_eq_image: \"{f x |x. x \\ A} = f ` A\"\n by sorry\n\nlemma setcompr_eq_image: \"{f x |x. P x} = f ` {x. P x}\"\n by sorry\n\nlemma ball_imageD: \"\\x\\f ` A. P x \\ \\x\\A. P (f x)\"\n by sorry\n\nlemma bex_imageD: \"\\x\\f ` A. P x \\ \\x\\A. P (f x)\"\n by sorry\n\nlemma image_add_0 [simp]: \"(+) (0::'a::comm_monoid_add) ` S = S\"\n by sorry\n\ntheorem Cantors_theorem: \"\\f. f ` A = Pow A\"\n by sorry\n\ntext \\\\<^medskip> Range of a function -- just an abbreviation for image!\\\n\nabbreviation range :: \"('a \\ 'b) \\ 'b set\" \\ \\of function\\\n where \"range f \\ f ` UNIV\"\n\nlemma range_eqI: \"b = f x \\ b \\ range f\"\n by sorry\n\nlemma rangeI: \"f x \\ range f\"\n by sorry\n\nlemma rangeE [elim?]: \"b \\ range (\\x. f x) \\ (\\x. b = f x \\ P) \\ P\"\n by sorry\n\nlemma range_subsetD: \"range f \\ B \\ f i \\ B\"\n by sorry\n\nlemma full_SetCompr_eq: \"{u. \\x. u = f x} = range f\"\n by sorry\n\nlemma range_composition: \"range (\\x. f (g x)) = f ` range g\"\n by sorry\n\nlemma range_constant [simp]: \"range (\\_. x) = {x}\"\n by sorry\n\nlemma range_eq_singletonD: \"range f = {a} \\ f x = a\"\n by sorry\n\nsubsubsection \\Some rules with \\if\\\\\n\ntext \\Elimination of \\{x. \\ \\ x = t \\ \\}\\.\\\n\nlemma Collect_conv_if: \"{x. x = a \\ P x} = (if P a then {a} else {})\"\n by sorry\n\nlemma Collect_conv_if2: \"{x. a = x \\ P x} = (if P a then {a} else {})\"\n by sorry\n\ntext \\\n Rewrite rules for boolean case-splitting: faster than \\if_split [split]\\.\n\\\n\nlemma if_split_eq1: \"(if Q then x else y) = b \\ (Q \\ x = b) \\ (\\ Q \\ y = b)\"\n by sorry\n\nlemma if_split_eq2: \"a = (if Q then x else y) \\ (Q \\ a = x) \\ (\\ Q \\ a = y)\"\n by sorry\n\ntext \\\n Split ifs on either side of the membership relation.\n Not for \\[simp]\\ -- can cause goals to blow up!\n\\\n\nlemma if_split_mem1: \"(if Q then x else y) \\ b \\ (Q \\ x \\ b) \\ (\\ Q \\ y \\ b)\"\n by sorry\n\nlemma if_split_mem2: \"(a \\ (if Q then x else y)) \\ (Q \\ a \\ x) \\ (\\ Q \\ a \\ y)\"\n by sorry\n\nlemmas split_ifs = if_bool_eq_conj if_split_eq1 if_split_eq2 if_split_mem1 if_split_mem2\n\nsubsection \\Further operations and lemmas\\\n\nsubsubsection \\The ``proper subset'' relation\\\n\nlemma psubsetI [intro!]: \"A \\ B \\ A \\ B \\ A \\ B\"\n by sorry\n\nlemma psubsetE [elim!]: \"A \\ B \\ (A \\ B \\ \\ B \\ A \\ R) \\ R\"\n by sorry\n\nlemma psubset_insert_iff:\n \"A \\ insert x B \\ (if x \\ B then A \\ B else if x \\ A then A - {x} \\ B else A \\ B)\"\n by sorry\n\nlemma psubset_eq: \"A \\ B \\ A \\ B \\ A \\ B\"\n by sorry\n\nlemma psubset_imp_subset: \"A \\ B \\ A \\ B\"\n by sorry\n\nlemma psubset_trans: \"A \\ B \\ B \\ C \\ A \\ C\"\n by sorry\n\nlemma psubsetD: \"A \\ B \\ c \\ A \\ c \\ B\"\n by sorry\n\nlemma psubset_subset_trans: \"A \\ B \\ B \\ C \\ A \\ C\"\n by sorry\n\nlemma subset_psubset_trans: \"A \\ B \\ B \\ C \\ A \\ C\"\n by sorry\n\nlemma psubset_imp_ex_mem: \"A \\ B \\ \\b. b \\ B - A\"\n by sorry\n\nlemma atomize_ball: \"(\\x. x \\ A \\ P x) \\ Trueprop (\\x\\A. P x)\"\n by sorry\n\nlemmas [symmetric, rulify] = atomize_ball\n and [symmetric, defn] = atomize_ball\n\nlemma image_Pow_mono: \"f ` A \\ B \\ image f ` Pow A \\ Pow B\"\n by sorry\n\nlemma image_Pow_surj: \"f ` A = B \\ image f ` Pow A = Pow B\"\n by sorry\n\nsubsubsection \\Derived rules involving subsets.\\\n\ntext \\\\insert\\.\\\n\nlemma subset_insertI: \"B \\ insert a B\"\n by sorry\n\nlemma subset_insertI2: \"A \\ B \\ A \\ insert b B\"\n by sorry\n\nlemma subset_insert: \"x \\ A \\ A \\ insert x B \\ A \\ B\"\n by sorry\n\ntext \\\\<^medskip> Finite Union -- the least upper bound of two sets.\\\n\nlemma Un_upper1: \"A \\ A \\ B\"\n by sorry\n\nlemma Un_upper2: \"B \\ A \\ B\"\n by sorry\n\nlemma Un_least: \"A \\ C \\ B \\ C \\ A \\ B \\ C\"\n by sorry\n\ntext \\\\<^medskip> Finite Intersection -- the greatest lower bound of two sets.\\\n\nlemma Int_lower1: \"A \\ B \\ A\"\n by sorry\n\nlemma Int_lower2: \"A \\ B \\ B\"\n by sorry\n\nlemma Int_greatest: \"C \\ A \\ C \\ B \\ C \\ A \\ B\"\n by sorry\n\ntext \\\\<^medskip> Set difference.\\\n\nlemma Diff_subset[simp]: \"A - B \\ A\"\n by sorry\n\nlemma Diff_subset_conv: \"A - B \\ C \\ A \\ B \\ C\"\n by sorry\n\nsubsubsection \\Equalities involving union, intersection, inclusion, etc.\\\n\ntext \\\\{}\\.\\\n\nlemma Collect_const [simp]: \"{s. P} = (if P then UNIV else {})\"\n \\ \\supersedes \\Collect_False_empty\\\\\n by sorry\n\nlemma subset_empty [simp]: \"A \\ {} \\ A = {}\"\n by sorry\n\nlemma not_psubset_empty [iff]: \"\\ (A < {})\"\n by sorry\n\nlemma Collect_subset [simp]: \"{x\\A. P x} \\ A\" by auto\n\nlemma Collect_empty_eq [simp]: \"Collect P = {} \\ (\\x. \\ P x)\"\n by sorry\n\nlemma empty_Collect_eq [simp]: \"{} = Collect P \\ (\\x. \\ P x)\"\n by sorry\n\nlemma Collect_neg_eq: \"{x. \\ P x} = - {x. P x}\"\n by sorry\n\nlemma Collect_disj_eq: \"{x. P x \\ Q x} = {x. P x} \\ {x. Q x}\"\n by sorry\n\nlemma Collect_imp_eq: \"{x. P x \\ Q x} = - {x. P x} \\ {x. Q x}\"\n by sorry\n\nlemma Collect_conj_eq: \"{x. P x \\ Q x} = {x. P x} \\ {x. Q x}\"\n by sorry\n\nlemma Collect_conj_eq2: \"{x \\ A. P x \\ Q x} = {x \\ A. P x} \\ {x \\ A. Q x}\"\n by sorry\n\nlemma Collect_mono_iff: \"Collect P \\ Collect Q \\ (\\x. P x \\ Q x)\"\n by sorry\n\ntext \\\\<^medskip> \\insert\\.\\\n\nlemma insert_is_Un: \"insert a A = {a} \\ A\"\n \\ \\NOT SUITABLE FOR REWRITING since \\{a} \\ insert a {}\\\\\n by sorry\n\nlemma insert_not_empty [simp]: \"insert a A \\ {}\"\n and empty_not_insert [simp]: \"{} \\ insert a A\"\n by sorry\n\nlemma insert_absorb: \"a \\ A \\ insert a A = A\"\n \\ \\\\[simp]\\ causes recursive calls when there are nested inserts\\\n \\ \\with \\<^emph>\\quadratic\\ running time\\\n by sorry\n\nlemma insert_absorb2 [simp]: \"insert x (insert x A) = insert x A\"\n by sorry\n\nlemma insert_commute: \"insert x (insert y A) = insert y (insert x A)\"\n by sorry\n\nlemma insert_subset [simp]: \"insert x A \\ B \\ x \\ B \\ A \\ B\"\n by sorry\n\nlemma mk_disjoint_insert: \"a \\ A \\ \\B. A = insert a B \\ a \\ B\"\n \\ \\use new \\B\\ rather than \\A - {a}\\ to avoid infinite unfolding\\\n by sorry\n\nlemma insert_Collect: \"insert a (Collect P) = {u. u \\ a \\ P u}\"\n by sorry\n\nlemma insert_inter_insert [simp]: \"insert a A \\ insert a B = insert a (A \\ B)\"\n by sorry\n\nlemma insert_disjoint [simp]:\n \"insert a A \\ B = {} \\ a \\ B \\ A \\ B = {}\"\n \"{} = insert a A \\ B \\ a \\ B \\ {} = A \\ B\"\n by sorry\n\nlemma disjoint_insert [simp]:\n \"B \\ insert a A = {} \\ a \\ B \\ B \\ A = {}\"\n \"{} = A \\ insert b B \\ b \\ A \\ {} = A \\ B\"\n by sorry\n\ntext \\\\<^medskip> \\Int\\\\\n\nlemma Int_absorb: \"A \\ A = A\"\n by sorry\n\nlemma Int_left_absorb: \"A \\ (A \\ B) = A \\ B\"\n by sorry\n\nlemma Int_commute: \"A \\ B = B \\ A\"\n by sorry\n\nlemma Int_left_commute: \"A \\ (B \\ C) = B \\ (A \\ C)\"\n by sorry\n\nlemma Int_assoc: \"(A \\ B) \\ C = A \\ (B \\ C)\"\n by sorry\n\nlemmas Int_ac = Int_assoc Int_left_absorb Int_commute Int_left_commute\n \\ \\Intersection is an AC-operator\\\n\nlemma Int_absorb1: \"B \\ A \\ A \\ B = B\"\n by sorry\n\nlemma Int_absorb2: \"A \\ B \\ A \\ B = A\"\n by sorry\n\nlemma Int_empty_left: \"{} \\ B = {}\"\n by sorry\n\nlemma Int_empty_right: \"A \\ {} = {}\"\n by sorry\n\nlemma disjoint_eq_subset_Compl: \"A \\ B = {} \\ A \\ - B\"\n by sorry\n\nlemma disjoint_iff: \"A \\ B = {} \\ (\\x. x\\A \\ x \\ B)\"\n by sorry\n\nlemma disjoint_iff_not_equal: \"A \\ B = {} \\ (\\x\\A. \\y\\B. x \\ y)\"\n by sorry\n\nlemma Int_UNIV_left: \"UNIV \\ B = B\"\n by sorry\n\nlemma Int_UNIV_right: \"A \\ UNIV = A\"\n by sorry\n\nlemma Int_Un_distrib: \"A \\ (B \\ C) = (A \\ B) \\ (A \\ C)\"\n by sorry\n\nlemma Int_Un_distrib2: \"(B \\ C) \\ A = (B \\ A) \\ (C \\ A)\"\n by sorry\n\nlemma Int_UNIV: \"A \\ B = UNIV \\ A = UNIV \\ B = UNIV\"\n by sorry\n\nlemma Int_subset_iff: \"C \\ A \\ B \\ C \\ A \\ C \\ B\"\n by sorry\n\nlemma Int_Collect: \"x \\ A \\ {x. P x} \\ x \\ A \\ P x\"\n by sorry\n\ntext \\\\<^medskip> \\Un\\.\\\n\nlemma Un_absorb: \"A \\ A = A\"\n by sorry\n\nlemma Un_left_absorb: \"A \\ (A \\ B) = A \\ B\"\n by sorry\n\nlemma Un_commute: \"A \\ B = B \\ A\"\n by sorry\n\nlemma Un_left_commute: \"A \\ (B \\ C) = B \\ (A \\ C)\"\n by sorry\n\nlemma Un_assoc: \"(A \\ B) \\ C = A \\ (B \\ C)\"\n by sorry\n\nlemmas Un_ac = Un_assoc Un_left_absorb Un_commute Un_left_commute\n \\ \\Union is an AC-operator\\\n\nlemma Un_absorb1: \"A \\ B \\ A \\ B = B\"\n by sorry\n\nlemma Un_absorb2: \"B \\ A \\ A \\ B = A\"\n by sorry\n\nlemma Un_empty_left: \"{} \\ B = B\"\n by sorry\n\nlemma Un_empty_right: \"A \\ {} = A\"\n by sorry\n\nlemma Un_UNIV_left: \"UNIV \\ B = UNIV\"\n by sorry\n\nlemma Un_UNIV_right: \"A \\ UNIV = UNIV\"\n by sorry\n\nlemma Un_insert_left [simp]: \"(insert a B) \\ C = insert a (B \\ C)\"\n by sorry\n\nlemma Un_insert_right [simp]: \"A \\ (insert a B) = insert a (A \\ B)\"\n by sorry\n\nlemma Int_insert_left: \"(insert a B) \\ C = (if a \\ C then insert a (B \\ C) else B \\ C)\"\n by sorry\n\nlemma Int_insert_left_if0 [simp]: \"a \\ C \\ (insert a B) \\ C = B \\ C\"\n by sorry\n\nlemma Int_insert_left_if1 [simp]: \"a \\ C \\ (insert a B) \\ C = insert a (B \\ C)\"\n by sorry\n\nlemma Int_insert_right: \"A \\ (insert a B) = (if a \\ A then insert a (A \\ B) else A \\ B)\"\n by sorry\n\nlemma Int_insert_right_if0 [simp]: \"a \\ A \\ A \\ (insert a B) = A \\ B\"\n by sorry\n\nlemma Int_insert_right_if1 [simp]: \"a \\ A \\ A \\ (insert a B) = insert a (A \\ B)\"\n by sorry\n\nlemma Un_Int_distrib: \"A \\ (B \\ C) = (A \\ B) \\ (A \\ C)\"\n by sorry\n\nlemma Un_Int_distrib2: \"(B \\ C) \\ A = (B \\ A) \\ (C \\ A)\"\n by sorry\n\nlemma Un_Int_crazy: \"(A \\ B) \\ (B \\ C) \\ (C \\ A) = (A \\ B) \\ (B \\ C) \\ (C \\ A)\"\n by sorry\n\nlemma subset_Un_eq: \"A \\ B \\ A \\ B = B\"\n by sorry\n\nlemma Un_empty [iff]: \"A \\ B = {} \\ A = {} \\ B = {}\"\n by sorry\n\nlemma Un_subset_iff: \"A \\ B \\ C \\ A \\ C \\ B \\ C\"\n by sorry\n\nlemma Un_Diff_Int: \"(A - B) \\ (A \\ B) = A\"\n by sorry\n\nlemma Diff_Int2: \"A \\ C - B \\ C = A \\ C - B\"\n by sorry\n\nlemma subset_UnE:\n assumes \"C \\ A \\ B\"\n obtains A' B' where \"A' \\ A\" \"B' \\ B\" \"C = A' \\ B'\"\n by sorry\n\nlemma Un_Int_eq [simp]: \"(S \\ T) \\ S = S\" \"(S \\ T) \\ T = T\" \"S \\ (S \\ T) = S\" \"T \\ (S \\ T) = T\"\n by sorry\n\nlemma Int_Un_eq [simp]: \"(S \\ T) \\ S = S\" \"(S \\ T) \\ T = T\" \"S \\ (S \\ T) = S\" \"T \\ (S \\ T) = T\"\n by sorry\n\ntext \\\\<^medskip> Set complement\\\n\nlemma Compl_disjoint [simp]: \"A \\ - A = {}\"\n by sorry\n\nlemma Compl_disjoint2 [simp]: \"- A \\ A = {}\"\n by sorry\n\nlemma Compl_partition: \"A \\ - A = UNIV\"\n by sorry\n\nlemma Compl_partition2: \"- A \\ A = UNIV\"\n by sorry\n\nlemma double_complement: \"- (-A) = A\" for A :: \"'a set\"\n by sorry\n\nlemma Compl_Un: \"- (A \\ B) = (- A) \\ (- B)\"\n by sorry\n\nlemma Compl_Int: \"- (A \\ B) = (- A) \\ (- B)\"\n by sorry\n\nlemma subset_Compl_self_eq: \"A \\ - A \\ A = {}\"\n by sorry\n\nlemma Un_Int_assoc_eq: \"(A \\ B) \\ C = A \\ (B \\ C) \\ C \\ A\"\n \\ \\Halmos, Naive Set Theory, page 16.\\\n by sorry\n\nlemma Compl_UNIV_eq: \"- UNIV = {}\"\n by sorry\n\nlemma Compl_empty_eq: \"- {} = UNIV\"\n by sorry\n\nlemma Compl_subset_Compl_iff [iff]: \"- A \\ - B \\ B \\ A\"\n by sorry\n\nlemma Compl_eq_Compl_iff [iff]: \"- A = - B \\ A = B\"\n for A B :: \"'a set\"\n by sorry\n\nlemma Compl_insert: \"- insert x A = (- A) - {x}\"\n by sorry\n\ntext \\\\<^medskip> Bounded quantifiers.\n\n The following are not added to the default simpset because\n (a) they duplicate the body and (b) there are no similar rules for \\Int\\.\n\\\n\nlemma ball_Un: \"(\\x \\ A \\ B. P x) \\ (\\x\\A. P x) \\ (\\x\\B. P x)\"\n by sorry\n\nlemma bex_Un: \"(\\x \\ A \\ B. P x) \\ (\\x\\A. P x) \\ (\\x\\B. P x)\"\n by sorry\n\ntext \\\\<^medskip> Set difference.\\\n\nlemma Diff_eq: \"A - B = A \\ (- B)\"\n by sorry\n\nlemma Diff_eq_empty_iff: \"A - B = {} \\ A \\ B\"\n by sorry\n\nlemma Diff_cancel [simp]: \"A - A = {}\"\n by sorry\n\nlemma Diff_idemp [simp]: \"(A - B) - B = A - B\"\n for A B :: \"'a set\"\n by sorry\n\nlemma Diff_triv: \"A \\ B = {} \\ A - B = A\"\n by sorry\n\nlemma empty_Diff [simp]: \"{} - A = {}\"\n by sorry\n\nlemma Diff_empty [simp]: \"A - {} = A\"\n by sorry\n\nlemma Diff_UNIV [simp]: \"A - UNIV = {}\"\n by sorry\n\nlemma Diff_insert0 [simp]: \"x \\ A \\ A - insert x B = A - B\"\n by sorry\n\nlemma Diff_insert: \"A - insert a B = A - B - {a}\"\n \\ \\NOT SUITABLE FOR REWRITING since \\{a} \\ insert a 0\\\\\n by sorry\n\nlemma Diff_insert2: \"A - insert a B = A - {a} - B\"\n \\ \\NOT SUITABLE FOR REWRITING since \\{a} \\ insert a 0\\\\\n by sorry\n\nlemma insert_Diff_if: \"insert x A - B = (if x \\ B then A - B else insert x (A - B))\"\n by sorry\n\nlemma insert_Diff1 [simp]: \"x \\ B \\ insert x A - B = A - B\"\n by sorry\n\nlemma insert_Diff_single[simp]: \"insert a (A - {a}) = insert a A\"\n by sorry\n\nlemma insert_Diff: \"a \\ A \\ insert a (A - {a}) = A\"\n by sorry\n\nlemma Diff_insert_absorb: \"x \\ A \\ (insert x A) - {x} = A\"\n by sorry\n\nlemma Diff_disjoint [simp]: \"A \\ (B - A) = {}\"\n by sorry\n\nlemma Diff_partition: \"A \\ B \\ A \\ (B - A) = B\"\n by sorry\n\nlemma double_diff: \"A \\ B \\ B \\ C \\ B - (C - A) = A\"\n by sorry\n\nlemma Un_Diff_cancel [simp]: \"A \\ (B - A) = A \\ B\"\n by sorry\n\nlemma Un_Diff_cancel2 [simp]: \"(B - A) \\ A = B \\ A\"\n by sorry\n\nlemma Diff_Un: \"A - (B \\ C) = (A - B) \\ (A - C)\"\n by sorry\n\nlemma Diff_Int: \"A - (B \\ C) = (A - B) \\ (A - C)\"\n by sorry\n\nlemma Diff_Diff_Int: \"A - (A - B) = A \\ B\"\n by sorry\n\nlemma Un_Diff: \"(A \\ B) - C = (A - C) \\ (B - C)\"\n by sorry\n\nlemma Int_Diff: \"(A \\ B) - C = A \\ (B - C)\"\n by sorry\n\nlemma Diff_Int_distrib: \"C \\ (A - B) = (C \\ A) - (C \\ B)\"\n by sorry\n\nlemma Diff_Int_distrib2: \"(A - B) \\ C = (A \\ C) - (B \\ C)\"\n by sorry\n\nlemma Diff_Compl [simp]: \"A - (- B) = A \\ B\"\n by sorry\n\nlemma Compl_Diff_eq [simp]: \"- (A - B) = - A \\ B\"\n by sorry\n\nlemma subset_Compl_singleton [simp]: \"A \\ - {b} \\ b \\ A\"\n by sorry\n\ntext \\\\<^medskip> Quantification over type \\<^typ>\\bool\\.\\\n\nlemma bool_induct: \"P True \\ P False \\ P x\"\n by sorry\n\nlemma all_bool_eq: \"(\\b. P b) \\ P True \\ P False\"\n by sorry\n\nlemma bool_contrapos: \"P x \\ \\ P False \\ P True\"\n by sorry\n\nlemma ex_bool_eq: \"(\\b. P b) \\ P True \\ P False\"\n by sorry\n\nlemma UNIV_bool: \"UNIV = {False, True}\"\n by sorry\n\ntext \\\\<^medskip> \\Pow\\\\\n\nlemma Pow_empty [simp]: \"Pow {} = {{}}\"\n by sorry\n\nlemma Pow_singleton_iff [simp]: \"Pow X = {Y} \\ X = {} \\ Y = {}\"\n by sorry\n\nlemma Pow_insert: \"Pow (insert a A) = Pow A \\ (insert a ` Pow A)\"\n by sorry\n\nlemma Pow_Compl: \"Pow (- A) = {- B | B. A \\ Pow B}\"\n by sorry\n\nlemma Pow_UNIV [simp]: \"Pow UNIV = UNIV\"\n by sorry\n\nlemma Un_Pow_subset: \"Pow A \\ Pow B \\ Pow (A \\ B)\"\n by sorry\n\nlemma Pow_Int_eq [simp]: \"Pow (A \\ B) = Pow A \\ Pow B\"\n by sorry\n\ntext \\\\<^medskip> Miscellany.\\\n\nlemma Int_Diff_disjoint: \"A \\ B \\ (A - B) = {}\"\n by sorry\n\nlemma Int_Diff_Un: \"A \\ B \\ (A - B) = A\"\n by sorry\n\nlemma set_eq_subset: \"A = B \\ A \\ B \\ B \\ A\"\n by sorry\n\nlemma subset_iff: \"A \\ B \\ (\\t. t \\ A \\ t \\ B)\"\n by sorry\n\nlemma subset_iff_psubset_eq: \"A \\ B \\ A \\ B \\ A = B\"\n by sorry\n\nlemma all_not_in_conv [simp]: \"(\\x. x \\ A) \\ A = {}\"\n by sorry\n\nlemma ex_in_conv: \"(\\x. x \\ A) \\ A \\ {}\"\n by sorry\n\nlemma ball_simps [simp, no_atp]:\n \"\\A P Q. (\\x\\A. P x \\ Q) \\ ((\\x\\A. P x) \\ Q)\"\n \"\\A P Q. (\\x\\A. P \\ Q x) \\ (P \\ (\\x\\A. Q x))\"\n \"\\A P Q. (\\x\\A. P \\ Q x) \\ (P \\ (\\x\\A. Q x))\"\n \"\\A P Q. (\\x\\A. P x \\ Q) \\ ((\\x\\A. P x) \\ Q)\"\n \"\\P. (\\x\\{}. P x) \\ True\"\n \"\\P. (\\x\\UNIV. P x) \\ (\\x. P x)\"\n \"\\a B P. (\\x\\insert a B. P x) \\ (P a \\ (\\x\\B. P x))\"\n \"\\P Q. (\\x\\Collect Q. P x) \\ (\\x. Q x \\ P x)\"\n \"\\A P f. (\\x\\f`A. P x) \\ (\\x\\A. P (f x))\"\n \"\\A P. (\\ (\\x\\A. P x)) \\ (\\x\\A. \\ P x)\"\n by sorry\n\nlemma bex_simps [simp, no_atp]:\n \"\\A P Q. (\\x\\A. P x \\ Q) \\ ((\\x\\A. P x) \\ Q)\"\n \"\\A P Q. (\\x\\A. P \\ Q x) \\ (P \\ (\\x\\A. Q x))\"\n \"\\P. (\\x\\{}. P x) \\ False\"\n \"\\P. (\\x\\UNIV. P x) \\ (\\x. P x)\"\n \"\\a B P. (\\x\\insert a B. P x) \\ (P a \\ (\\x\\B. P x))\"\n \"\\P Q. (\\x\\Collect Q. P x) \\ (\\x. Q x \\ P x)\"\n \"\\A P f. (\\x\\f`A. P x) \\ (\\x\\A. P (f x))\"\n \"\\A P. (\\(\\x\\A. P x)) \\ (\\x\\A. \\ P x)\"\n by sorry\n\nlemma ex_image_cong_iff [simp, no_atp]:\n \"(\\x. x\\f`A) \\ A \\ {}\" \"(\\x. x\\f`A \\ P x) \\ (\\x\\A. P (f x))\"\n by sorry\n\nsubsubsection \\Monotonicity of various operations\\\n\nlemma image_mono: \"A \\ B \\ f ` A \\ f ` B\"\n by sorry\n\nlemma Pow_mono: \"A \\ B \\ Pow A \\ Pow B\"\n by sorry\n\nlemma insert_mono: \"C \\ D \\ insert a C \\ insert a D\"\n by sorry\n\nlemma Un_mono: \"A \\ C \\ B \\ D \\ A \\ B \\ C \\ D\"\n by sorry\n\nlemma Int_mono: \"A \\ C \\ B \\ D \\ A \\ B \\ C \\ D\"\n by sorry\n\nlemma Diff_mono: \"A \\ C \\ D \\ B \\ A - B \\ C - D\"\n by sorry\n\nlemma Compl_anti_mono: \"A \\ B \\ - B \\ - A\"\n by sorry\n\ntext \\\\<^medskip> Monotonicity of implications.\\\n\nlemma in_mono: \"A \\ B \\ x \\ A \\ x \\ B\"\n by sorry\n\nlemma conj_mono: \"P1 \\ Q1 \\ P2 \\ Q2 \\ (P1 \\ P2) \\ (Q1 \\ Q2)\"\n by sorry\n\nlemma disj_mono: \"P1 \\ Q1 \\ P2 \\ Q2 \\ (P1 \\ P2) \\ (Q1 \\ Q2)\"\n by sorry\n\nlemma imp_mono: \"Q1 \\ P1 \\ P2 \\ Q2 \\ (P1 \\ P2) \\ (Q1 \\ Q2)\"\n by sorry\n\nlemma imp_refl: \"P \\ P\" ..\n\nlemma not_mono: \"Q \\ P \\ \\ P \\ \\ Q\"\n by sorry\n\nlemma ex_mono: \"(\\x. P x \\ Q x) \\ (\\x. P x) \\ (\\x. Q x)\"\n by sorry\n\nlemma all_mono: \"(\\x. P x \\ Q x) \\ (\\x. P x) \\ (\\x. Q x)\"\n by sorry\n\nlemma Collect_mono: \"(\\x. P x \\ Q x) \\ Collect P \\ Collect Q\"\n by sorry\n\nlemma Int_Collect_mono: \"A \\ B \\ (\\x. x \\ A \\ P x \\ Q x) \\ A \\ Collect P \\ B \\ Collect Q\"\n by sorry\n\nlemmas basic_monos =\n subset_refl imp_refl disj_mono conj_mono ex_mono Collect_mono in_mono\n\nlemma eq_to_mono: \"a = b \\ c = d \\ b \\ d \\ a \\ c\"\n by sorry\n\nsubsubsection \\Inverse image of a function\\\n\ndefinition vimage :: \"('a \\ 'b) \\ 'b set \\ 'a set\" (infixr \\-`\\ 90)\n where \"f -` B \\ {x. f x \\ B}\"\n\nlemma vimage_eq [simp]: \"a \\ f -` B \\ f a \\ B\"\n by sorry\n\nlemma vimage_singleton_eq: \"a \\ f -` {b} \\ f a = b\"\n by sorry\n\nlemma vimageI [intro]: \"f a = b \\ b \\ B \\ a \\ f -` B\"\n by sorry\n\nlemma vimageI2: \"f a \\ A \\ a \\ f -` A\"\n by sorry\n\nlemma vimageE [elim!]: \"a \\ f -` B \\ (\\x. f a = x \\ x \\ B \\ P) \\ P\"\n by sorry\n\nlemma vimageD: \"a \\ f -` A \\ f a \\ A\"\n by sorry\n\nlemma vimage_empty [simp]: \"f -` {} = {}\"\n by sorry\n\nlemma vimage_Compl: \"f -` (- A) = - (f -` A)\"\n by sorry\n\nlemma vimage_Un [simp]: \"f -` (A \\ B) = (f -` A) \\ (f -` B)\"\n by sorry\n\nlemma vimage_Int [simp]: \"f -` (A \\ B) = (f -` A) \\ (f -` B)\"\n by sorry\n\nlemma vimage_Collect_eq [simp]: \"f -` Collect P = {y. P (f y)}\"\n by sorry\n\nlemma vimage_Collect: \"(\\x. P (f x) = Q x) \\ f -` (Collect P) = Collect Q\"\n by sorry\n\nlemma vimage_insert: \"f -` (insert a B) = (f -` {a}) \\ (f -` B)\"\n \\ \\NOT suitable for rewriting because of the recurrence of \\{a}\\.\\\n by sorry\n\nlemma vimage_Diff: \"f -` (A - B) = (f -` A) - (f -` B)\"\n by sorry\n\nlemma vimage_UNIV [simp]: \"f -` UNIV = UNIV\"\n by sorry\n\nlemma vimage_mono: \"A \\ B \\ f -` A \\ f -` B\"\n \\ \\monotonicity\\\n by sorry\n\nlemma vimage_image_eq: \"f -` (f ` A) = {y. \\x\\A. f x = f y}\"\n by sorry\n\nlemma image_vimage_subset: \"f ` (f -` A) \\ A\"\n by sorry\n\nlemma image_vimage_eq [simp]: \"f ` (f -` A) = A \\ range f\"\n by sorry\n\nlemma image_subset_iff_subset_vimage: \"f ` A \\ B \\ A \\ f -` B\"\n by sorry\n\nlemma subset_vimage_iff: \"A \\ f -` B \\ (\\x\\A. f x \\ B)\"\n by sorry\n\nlemma vimage_const [simp]: \"((\\x. c) -` A) = (if c \\ A then UNIV else {})\"\n by sorry\n\nlemma vimage_if [simp]: \"((\\x. if x \\ B then c else d) -` A) =\n (if c \\ A then (if d \\ A then UNIV else B)\n else if d \\ A then - B else {})\"\n by sorry\n\nlemma vimage_inter_cong: \"(\\ w. w \\ S \\ f w = g w) \\ f -` y \\ S = g -` y \\ S\"\n by sorry\n\nlemma vimage_ident [simp]: \"(\\x. x) -` Y = Y\"\n by sorry\n\nsubsubsection \\Singleton sets\\\n\ndefinition is_singleton :: \"'a set \\ bool\"\n where \"is_singleton A \\ (\\x. A = {x})\"\n\nlemma is_singletonI [simp, intro!]: \"is_singleton {x}\"\n by sorry\n\nlemma is_singletonI': \"A \\ {} \\ (\\x y. x \\ A \\ y \\ A \\ x = y) \\ is_singleton A\"\n by sorry\n\nlemma is_singletonE: \"is_singleton A \\ (\\x. A = {x} \\ P) \\ P\"\n by sorry\n\nlemma is_singleton_iff_ex1:\n \\is_singleton A \\ (\\!x. x \\ A)\\\n by sorry\n\nsubsubsection \\Getting the contents of a singleton set\\\n\ndefinition the_elem :: \"'a set \\ 'a\"\n where \"the_elem X = (THE x. X = {x})\"\n\nlemma the_elem_eq [simp]: \"the_elem {x} = x\"\n by sorry\n\nlemma is_singleton_the_elem: \"is_singleton A \\ A = {the_elem A}\"\n by sorry\n\nlemma the_elem_image_unique:\n assumes \"A \\ {}\"\n and *: \"\\y. y \\ A \\ f y = a\"\n shows \"the_elem (f ` A) = a\"\n by sorry\n\nsubsubsection \\Monad operation\\\n\ndefinition bind :: \"'a set \\ ('a \\ 'b set) \\ 'b set\"\n where \"bind A f = {x. \\B \\ f`A. x \\ B}\"\n\nhide_const (open) bind\n\nlemma bind_bind: \"Set.bind (Set.bind A B) C = Set.bind A (\\x. Set.bind (B x) C)\"\n for A :: \"'a set\"\n by sorry\n\nlemma empty_bind [simp]: \"Set.bind {} f = {}\"\n by sorry\n\nlemma nonempty_bind_const: \"A \\ {} \\ Set.bind A (\\_. B) = B\"\n by sorry\n\nlemma bind_const: \"Set.bind A (\\_. B) = (if A = {} then {} else B)\"\n by sorry\n\nlemma bind_singleton_conv_image: \"Set.bind A (\\x. {f x}) = f ` A\"\n by sorry\n\nsubsubsection \\Operations for execution\\\n\ntext \\\n Use those operations only for generating executable / efficient code.\n Otherwise use the RHSs directly.\n\\\n\ncontext\nbegin\n\nqualified definition is_empty :: \"'a set \\ bool\" \\ \\only for code generation\\\n where is_empty_iff [code_abbrev, simp]: \"is_empty A \\ A = {}\"\n\nqualified definition remove :: \"'a \\ 'a set \\ 'a set\" \\ \\only for code generation\\\n where remove_eq [code_abbrev, simp]: \"remove x A = A - {x}\"\n\nqualified definition filter :: \"('a \\ bool) \\ 'a set \\ 'a set\" \\ \\only for code generation\\\n where filter_eq [code_abbrev, simp]: \"filter P A = {a \\ A. P a}\"\n\nqualified definition can_select :: \"('a \\ bool) \\ 'a set \\ bool\" \\ \\only for code generation\\\n where can_select_iff [code_abbrev, simp]: \"can_select P A = (\\!x\\A. P x)\"\n\nqualified lemma can_select_iff_is_singleton:\n \\Set.can_select P A \\ is_singleton (Set.filter P A)\\\n by (simp add: is_singleton_iff_ex1)\n\nend\n\ninstantiation set :: (equal) equal\nbegin\n\ndefinition \"HOL.equal A B \\ A \\ B \\ B \\ A\"\n\ninstance\n by standard (auto simp add: equal_set_def)\n\nend\n\ntext \\Misc\\\n\ndefinition pairwise :: \"('a \\ 'a \\ bool) \\ 'a set \\ bool\"\n where \"pairwise R S \\ (\\x \\ S. \\y \\ S. x \\ y \\ R x y)\"\n\nlemma pairwise_alt: \"pairwise R S \\ (\\x\\S. \\y\\S-{x}. R x y)\"\n by sorry\n\nlemma pairwise_trivial [simp]: \"pairwise (\\i j. j \\ i) I\"\n by sorry\n\nlemma pairwiseI [intro?]:\n \"pairwise R S\" if \"\\x y. x \\ S \\ y \\ S \\ x \\ y \\ R x y\"\n by sorry\n\nlemma pairwiseD:\n \"R x y\" and \"R y x\"\n if \"pairwise R S\" \"x \\ S\" and \"y \\ S\" and \"x \\ y\"\n by sorry\n\nlemma pairwise_empty [simp]: \"pairwise P {}\"\n by sorry\n\nlemma pairwise_singleton [simp]: \"pairwise P {A}\"\n by sorry\n\nlemma pairwise_insert:\n \"pairwise r (insert x s) \\ (\\y. y \\ s \\ y \\ x \\ r x y \\ r y x) \\ pairwise r s\"\n by sorry\n\nlemma pairwise_subset: \"pairwise P S \\ T \\ S \\ pairwise P T\"\n by sorry\n\nlemma pairwise_mono: \"\\pairwise P A; \\x y. P x y \\ Q x y; B \\ A\\ \\ pairwise Q B\"\n by sorry\n\nlemma pairwise_imageI:\n \"pairwise P (f ` A)\"\n if \"\\x y. x \\ A \\ y \\ A \\ x \\ y \\ f x \\ f y \\ P (f x) (f y)\"\n by sorry\n\nlemma pairwise_image: \"pairwise r (f ` s) \\ pairwise (\\x y. (f x \\ f y) \\ r (f x) (f y)) s\"\n by sorry\n\ndefinition disjnt :: \"'a set \\ 'a set \\ bool\"\n where \"disjnt A B \\ A \\ B = {}\"\n\nlemma disjnt_self_iff_empty [simp]: \"disjnt S S \\ S = {}\"\n by sorry\n\nlemma disjnt_commute: \"disjnt A B = disjnt B A\"\n by sorry\n\nlemma disjnt_iff: \"disjnt A B \\ (\\x. \\ (x \\ A \\ x \\ B))\"\n by sorry\n\nlemma disjnt_sym: \"disjnt A B \\ disjnt B A\"\n by sorry\n\nlemma disjnt_empty1 [simp]: \"disjnt {} A\" and disjnt_empty2 [simp]: \"disjnt A {}\"\n by sorry\n\nlemma disjnt_insert1 [simp]: \"disjnt (insert a X) Y \\ a \\ Y \\ disjnt X Y\"\n by sorry\n\nlemma disjnt_insert2 [simp]: \"disjnt Y (insert a X) \\ a \\ Y \\ disjnt Y X\"\n by sorry\n\nlemma disjnt_subset1 : \"\\disjnt X Y; Z \\ X\\ \\ disjnt Z Y\"\n by sorry\n\nlemma disjnt_subset2 : \"\\disjnt X Y; Z \\ Y\\ \\ disjnt X Z\"\n by sorry\n\nlemma disjnt_Un1 [simp]: \"disjnt (A \\ B) C \\ disjnt A C \\ disjnt B C\"\n by sorry\n\nlemma disjnt_Un2 [simp]: \"disjnt C (A \\ B) \\ disjnt C A \\ disjnt C B\"\n by sorry\n\nlemma disjnt_Diff1: \"disjnt (X-Y) (U-V)\" and disjnt_Diff2: \"disjnt (U-V) (X-Y)\" if \"X \\ V\"\n by sorry\n\nlemma disjoint_image_subset: \"\\pairwise disjnt \\; \\X. X \\ \\ \\ f X \\ X\\ \\ pairwise disjnt (f `\\)\"\n by sorry\n\nlemma pairwise_disjnt_iff: \"pairwise disjnt \\ \\ (\\x. \\\\<^sub>\\\\<^sub>1 X. X \\ \\ \\ x \\ X)\"\n by sorry\n\nlemma disjnt_insert: \\<^marker>\\contributor \\Lars Hupel\\\\\n \\disjnt (insert x M) N\\ if \\x \\ N\\ \\disjnt M N\\\n by sorry\n\nlemma Int_emptyI: \"(\\x. x \\ A \\ x \\ B \\ False) \\ A \\ B = {}\"\n by sorry\n\nlemma in_image_insert_iff:\n assumes \"\\C. C \\ B \\ x \\ C\"\n shows \"A \\ insert x ` B \\ x \\ A \\ A - {x} \\ B\" (is \"?P \\ ?Q\")\n by sorry\n\nhide_const (open) member not_member\n\nlemmas equalityI = subset_antisym\nlemmas set_mp = subsetD\nlemmas set_rev_mp = rev_subsetD\n\nend" }, { "theorem_id": 50, "title": "063_cantor_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2016 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nmodule\n\npublic import Mathlib.Data.Set.Defs\npublic import Mathlib.Logic.Basic\npublic import Mathlib.Logic.Function.Defs\npublic import Mathlib.Logic.ExistsUnique\npublic import Mathlib.Logic.Nonempty\npublic import Mathlib.Logic.Nontrivial.Defs\npublic import Batteries.Tactic.Init\npublic import Mathlib.Order.Defs.Unbundled\n\nimport Mathlib.Tactic.Attr.Register\n\n/-!\n# Miscellaneous function constructions and lemmas\n-/\n\n@[expose] public section\n\nopen Function\n\nuniverse u v w x\n\nnamespace Function\n\nsection\n\nvariable {α β γ : Sort*} {f : α → β}\n\n/-- Evaluate a function at an argument. Useful if you want to talk about the partially applied\n `Function.eval x : (∀ x, β x) → β x`. -/\n@[reducible, simp] def eval {β : α → Sort*} (x : α) (f : ∀ x, β x) : β x := f x\n\ntheorem eval_apply {β : α → Sort*} (x : α) (f : ∀ x, β x) : eval x f = f x :=\n rfl\n\ntheorem const_def {y : β} : (fun _ : α ↦ y) = const α y :=\n rfl\n\ntheorem const_injective [Nonempty α] : Injective (const α : β → α → β) := fun _ _ h ↦\n let ⟨x⟩ := ‹Nonempty α›\n congr_fun h x\n\n@[simp]\ntheorem const_inj [Nonempty α] {y₁ y₂ : β} : const α y₁ = const α y₂ ↔ y₁ = y₂ :=\n ⟨fun h ↦ const_injective h, fun h ↦ h ▸ rfl⟩\n\ntheorem onFun_apply (f : β → β → γ) (g : α → β) (a b : α) : onFun f g a b = f (g a) (g b) :=\n rfl\n\nlemma hfunext {α α' : Sort u} {β : α → Sort v} {β' : α' → Sort v} {f : ∀ a, β a} {f' : ∀ a, β' a}\n (hα : α = α') (h : ∀ a a', a ≍ a' → f a ≍ f' a') : f ≍ f' := by sorry\ntheorem ne_iff {β : α → Sort*} {f₁ f₂ : ∀ a, β a} : f₁ ≠ f₂ ↔ ∃ a, f₁ a ≠ f₂ a :=\n funext_iff.not.trans not_forall\n\nlemma funext_iff_of_subsingleton [Subsingleton α] {g : α → β} (x y : α) :\n f x = g y ↔ f = g := by sorry\ntheorem swap_lt {α} [LT α] : swap (· < · : α → α → _) = (· > ·) := rfl\ntheorem swap_le {α} [LE α] : swap (· ≤ · : α → α → _) = (· ≥ ·) := rfl\ntheorem swap_gt {α} [LT α] : swap (· > · : α → α → _) = (· < ·) := rfl\ntheorem swap_ge {α} [LE α] : swap (· ≥ · : α → α → _) = (· ≤ ·) := rfl\n\nprotected theorem Bijective.injective {f : α → β} (hf : Bijective f) : Injective f := hf.1\nprotected theorem Bijective.surjective {f : α → β} (hf : Bijective f) : Surjective f := hf.2\n\ntheorem not_injective_iff : ¬ Injective f ↔ ∃ a b, f a = f b ∧ a ≠ b := by sorry\ntheorem Injective.of_comp {g : γ → α} (I : Injective (f ∘ g)) : Injective g :=\n fun _ _ h ↦ I <| congr_arg f h\n\n@[simp]\ntheorem Injective.of_comp_iff (hf : Injective f) (g : γ → α) :\n Injective (f ∘ g) ↔ Injective g :=\n ⟨Injective.of_comp, hf.comp⟩\n\ntheorem Injective.of_comp_right {g : γ → α} (I : Injective (f ∘ g)) (hg : Surjective g) :\n Injective f := fun x y h ↦ by\n obtain ⟨x, rfl⟩ := hg x\n obtain ⟨y, rfl⟩ := hg y\n exact congr_arg g (I h)\n\ntheorem Surjective.bijective₂_of_injective {g : γ → α} (hf : Surjective f) (hg : Surjective g)\n (I : Injective (f ∘ g)) : Bijective f ∧ Bijective g :=\n ⟨⟨I.of_comp_right hg, hf⟩, I.of_comp, hg⟩\n\n@[simp]\ntheorem Injective.of_comp_iff' (f : α → β) {g : γ → α} (hg : Bijective g) :\n Injective (f ∘ g) ↔ Injective f :=\n ⟨fun I ↦ I.of_comp_right hg.2, fun h ↦ h.comp hg.injective⟩\n\ntheorem Injective.piMap {ι : Sort*} {α β : ι → Sort*} {f : ∀ i, α i → β i}\n (hf : ∀ i, Injective (f i)) : Injective (Pi.map f) := fun _ _ h ↦\n funext fun i ↦ hf i <| congrFun h _\n\n/-- Composition by an injective function on the left is itself injective. -/\ntheorem Injective.comp_left {g : β → γ} (hg : Injective g) : Injective (g ∘ · : (α → β) → α → γ) :=\n .piMap fun _ ↦ hg\n\ntheorem injective_comp_left_iff [Nonempty α] {g : β → γ} :\n Injective (g ∘ · : (α → β) → α → γ) ↔ Injective g :=\n ⟨fun h b₁ b₂ eq ↦ Nonempty.elim ‹_›\n (congr_fun <| h (a₁ := fun _ ↦ b₁) (a₂ := fun _ ↦ b₂) <| funext fun _ ↦ eq), (·.comp_left)⟩\n\n@[nontriviality] theorem injective_of_subsingleton [Subsingleton α] (f : α → β) : Injective f :=\n fun _ _ _ ↦ Subsingleton.elim _ _\n\n@[nontriviality] theorem bijective_of_subsingleton [Subsingleton α] (f : α → α) : Bijective f :=\n ⟨injective_of_subsingleton f, fun a ↦ ⟨a, Subsingleton.elim ..⟩⟩\n\nlemma Injective.dite (p : α → Prop) [DecidablePred p]\n {f : {a : α // p a} → β} {f' : {a : α // ¬ p a} → β}\n (hf : Injective f) (hf' : Injective f')\n (im_disj : ∀ {x x' : α} {hx : p x} {hx' : ¬ p x'}, f ⟨x, hx⟩ ≠ f' ⟨x', hx'⟩) :\n Function.Injective (fun x ↦ if h : p x then f ⟨x, h⟩ else f' ⟨x, h⟩) := fun x₁ x₂ h => by\n grind\n\ntheorem Surjective.of_comp {g : γ → α} (S : Surjective (f ∘ g)) : Surjective f := fun y ↦\n let ⟨x, h⟩ := S y\n ⟨g x, h⟩\n\n@[simp]\ntheorem Surjective.of_comp_iff (f : α → β) {g : γ → α} (hg : Surjective g) :\n Surjective (f ∘ g) ↔ Surjective f :=\n ⟨Surjective.of_comp, fun h ↦ h.comp hg⟩\n\ntheorem Surjective.of_comp_left {g : γ → α} (S : Surjective (f ∘ g)) (hf : Injective f) :\n Surjective g := fun a ↦ let ⟨c, hc⟩ := S (f a); ⟨c, hf hc⟩\n\ntheorem Injective.bijective₂_of_surjective {g : γ → α} (hf : Injective f) (hg : Injective g)\n (S : Surjective (f ∘ g)) : Bijective f ∧ Bijective g :=\n ⟨⟨hf, S.of_comp⟩, hg, S.of_comp_left hf⟩\n\n@[simp]\ntheorem Surjective.of_comp_iff' (hf : Bijective f) (g : γ → α) :\n Surjective (f ∘ g) ↔ Surjective g :=\n ⟨fun S ↦ S.of_comp_left hf.1, hf.surjective.comp⟩\n\ninstance decidableEqPFun (p : Prop) [Decidable p] (α : p → Type*) [∀ hp, DecidableEq (α hp)] :\n DecidableEq (∀ hp, α hp)\n | f, g => decidable_of_iff (∀ hp, f hp = g hp) funext_iff.symm\n\nprotected theorem Surjective.forall (hf : Surjective f) {p : β → Prop} :\n (∀ y, p y) ↔ ∀ x, p (f x) :=\n ⟨fun h x ↦ h (f x), fun h y ↦\n let ⟨x, hx⟩ := hf y\n hx ▸ h x⟩\n\nprotected theorem Surjective.forall₂ (hf : Surjective f) {p : β → β → Prop} :\n (∀ y₁ y₂, p y₁ y₂) ↔ ∀ x₁ x₂, p (f x₁) (f x₂) :=\n hf.forall.trans <| forall_congr' fun _ ↦ hf.forall\n\nprotected theorem Surjective.forall₃ (hf : Surjective f) {p : β → β → β → Prop} :\n (∀ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∀ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=\n hf.forall.trans <| forall_congr' fun _ ↦ hf.forall₂\n\nprotected theorem Surjective.exists (hf : Surjective f) {p : β → Prop} :\n (∃ y, p y) ↔ ∃ x, p (f x) :=\n ⟨fun ⟨y, hy⟩ ↦\n let ⟨x, hx⟩ := hf y\n ⟨x, hx.symm ▸ hy⟩,\n fun ⟨x, hx⟩ ↦ ⟨f x, hx⟩⟩\n\nprotected theorem Surjective.exists₂ (hf : Surjective f) {p : β → β → Prop} :\n (∃ y₁ y₂, p y₁ y₂) ↔ ∃ x₁ x₂, p (f x₁) (f x₂) :=\n hf.exists.trans <| exists_congr fun _ ↦ hf.exists\n\nprotected theorem Surjective.exists₃ (hf : Surjective f) {p : β → β → β → Prop} :\n (∃ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∃ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=\n hf.exists.trans <| exists_congr fun _ ↦ hf.exists₂\n\ntheorem Surjective.injective_comp_right (hf : Surjective f) : Injective fun g : β → γ ↦ g ∘ f :=\n fun _ _ h ↦ funext <| hf.forall.2 <| congr_fun h\n\ntheorem injective_comp_right_iff_surjective {γ : Type*} [Nontrivial γ] :\n Injective (fun g : β → γ ↦ g ∘ f) ↔ Surjective f := by sorry\ntheorem surjective_of_right_cancellable_Prop (h : ∀ g₁ g₂ : β → Prop, g₁ ∘ f = g₂ ∘ f → g₁ = g₂) :\n Surjective f :=\n injective_comp_right_iff_surjective.mp h\n\ntheorem bijective_iff_existsUnique (f : α → β) : Bijective f ↔ ∀ b : β, ∃! a : α, f a = b :=\n ⟨fun hf b ↦\n let ⟨a, ha⟩ := hf.surjective b\n ⟨a, ha, fun _ ha' ↦ hf.injective (ha'.trans ha.symm)⟩,\n fun he ↦ ⟨fun {_a a'} h ↦ (he (f a')).unique h rfl, fun b ↦ (he b).exists⟩⟩\n\n/-- Shorthand for using projection notation with `Function.bijective_iff_existsUnique`. -/\nprotected theorem Bijective.existsUnique {f : α → β} (hf : Bijective f) (b : β) :\n ∃! a : α, f a = b :=\n (bijective_iff_existsUnique f).mp hf b\n\ntheorem Bijective.existsUnique_iff {f : α → β} (hf : Bijective f) {p : β → Prop} :\n (∃! y, p y) ↔ ∃! x, p (f x) :=\n ⟨fun ⟨y, hpy, hy⟩ ↦\n let ⟨x, hx⟩ := hf.surjective y\n ⟨x, by simpa [hx], fun z (hz : p (f z)) ↦ hf.injective <| hx.symm ▸ hy _ hz⟩,\n fun ⟨x, hpx, hx⟩ ↦\n ⟨f x, hpx, fun y hy ↦\n let ⟨z, hz⟩ := hf.surjective y\n hz ▸ congr_arg f (hx _ (by simpa [hz]))⟩⟩\n\ntheorem Bijective.of_comp_iff (f : α → β) {g : γ → α} (hg : Bijective g) :\n Bijective (f ∘ g) ↔ Bijective f :=\n and_congr (Injective.of_comp_iff' _ hg) (Surjective.of_comp_iff _ hg.surjective)\n\ntheorem Bijective.of_comp_iff' {f : α → β} (hf : Bijective f) (g : γ → α) :\n Function.Bijective (f ∘ g) ↔ Function.Bijective g :=\n and_congr (Injective.of_comp_iff hf.injective _) (Surjective.of_comp_iff' hf _)\n\n/-- If `f : α → α → β` is surjective, then every endofunction on `β` has a fixed point.\nThis is an instance of Lawvere's fixed-point theorem applied to the category of types\nand functions. It is the diagonal argument underlying `cantor_surjective` and\n`cantor_injective`. -/\ntheorem exists_fixed_point_of_surjective {α β : Type*} (f : α → α → β)\n (hf : Surjective f) (g : β → β) : ∃ x, g x = x :=\n let ⟨a, ha⟩ := hf fun a => g (f a a)\n ⟨f a a, (congr_fun ha a).symm⟩\n\n/-- **Cantor's diagonal argument** implies that there are no surjective functions from `α`\nto `Set α`. -/\ntheorem cantor_surjective {α} (f : α → Set α) : ¬Surjective f := fun h =>\n let ⟨_, hx⟩ := exists_fixed_point_of_surjective f h (¬·)\n not_iff_self (iff_of_eq hx)\n\n/-- **Cantor's diagonal argument** implies that there are no injective functions from `Set α`\nto `α`. -/\ntheorem cantor_injective {α : Type*} (f : Set α → α) : ¬Injective f := by sorry\ntheorem not_surjective_Type {α : Type u} (f : α → Type max u v) : ¬Surjective f := by sorry\ndef IsPartialInv {α β} (f : α → β) (g : β → Option α) : Prop :=\n ∀ x y, g y = some x ↔ f x = y\n\ntheorem IsPartialInv.eq {α β} {f : α → β} {g} (H : IsPartialInv f g) (x) : g (f x) = some x :=\n (H _ _).2 rfl\n\ntheorem IsPartialInv.get_eq {α β} {f : α → β} {g} (H : IsPartialInv f g) (x) (h : g x |>.isSome) :\n f (g x |>.get h) = x :=\n (H _ _).1 (Option.eq_some_of_isSome h)\n\ntheorem IsPartialInv.surjective_getD {α β} {f : α → β} {g} (H : IsPartialInv f g) (x) :\n Function.Surjective (g · |>.getD x) :=\n fun y => ⟨f y, by simp [H.eq]⟩\n\n@[deprecated (since := \"2026-03-11\")] alias isPartialInv_left := IsPartialInv.eq\n\ntheorem IsPartialInv.injective {α β} {f : α → β} {g} (H : IsPartialInv f g) :\n Injective f := fun _ _ h ↦\n Option.some.inj <| ((H _ _).2 h).symm.trans ((H _ _).2 rfl)\n\n@[deprecated (since := \"2026-03-11\")] alias injective_of_isPartialInv := IsPartialInv.injective\n\ntheorem injective_of_isPartialInv_right {α β} {f : α → β} {g} (H : IsPartialInv f g) (x y b)\n (h₁ : b ∈ g x) (h₂ : b ∈ g y) : x = y :=\n ((H _ _).1 h₁).symm.trans ((H _ _).1 h₂)\n\ntheorem IsPartialInv.comp {α β γ} {f : α → β} {g : β → Option α} {h : β → γ} {i : γ → Option β}\n (hf : IsPartialInv f g) (hh : IsPartialInv h i) :\n IsPartialInv (h ∘ f) (i · |>.bind g) := by sorry\nlemma LeftInverse.eq {g : β → α} {f : α → β} (h : LeftInverse g f) (x : α) : g (f x) = x := h x\n\nlemma RightInverse.eq {g : β → α} {f : α → β} (h : RightInverse g f) (x : β) : f (g x) = x := h x\n\ntheorem LeftInverse.comp_eq_id {f : α → β} {g : β → α} (h : LeftInverse f g) : f ∘ g = id :=\n funext h\n\ntheorem leftInverse_iff_comp {f : α → β} {g : β → α} : LeftInverse f g ↔ f ∘ g = id :=\n ⟨LeftInverse.comp_eq_id, congr_fun⟩\n\ntheorem RightInverse.comp_eq_id {f : α → β} {g : β → α} (h : RightInverse f g) : g ∘ f = id :=\n funext h\n\ntheorem rightInverse_iff_comp {f : α → β} {g : β → α} : RightInverse f g ↔ g ∘ f = id :=\n ⟨RightInverse.comp_eq_id, congr_fun⟩\n\ntheorem LeftInverse.comp {f : α → β} {g : β → α} {h : β → γ} {i : γ → β} (hf : LeftInverse f g)\n (hh : LeftInverse h i) : LeftInverse (h ∘ f) (g ∘ i) :=\n fun a ↦ show h (f (g (i a))) = a by rw [hf (i a), hh a]\n\ntheorem RightInverse.comp {f : α → β} {g : β → α} {h : β → γ} {i : γ → β} (hf : RightInverse f g)\n (hh : RightInverse h i) : RightInverse (h ∘ f) (g ∘ i) :=\n LeftInverse.comp hh hf\n\ntheorem LeftInverse.rightInverse {f : α → β} {g : β → α} (h : LeftInverse g f) : RightInverse f g :=\n h\n\ntheorem RightInverse.leftInverse {f : α → β} {g : β → α} (h : RightInverse g f) : LeftInverse f g :=\n h\n\ntheorem LeftInverse.surjective {f : α → β} {g : β → α} (h : LeftInverse f g) : Surjective f :=\n h.rightInverse.surjective\n\ntheorem RightInverse.injective {f : α → β} {g : β → α} (h : RightInverse f g) : Injective f :=\n h.leftInverse.injective\n\ntheorem LeftInverse.rightInverse_of_injective {f : α → β} {g : β → α} (h : LeftInverse f g)\n (hf : Injective f) : RightInverse f g :=\n fun x ↦ hf <| h (f x)\n\ntheorem LeftInverse.rightInverse_of_surjective {f : α → β} {g : β → α} (h : LeftInverse f g)\n (hg : Surjective g) : RightInverse f g :=\n fun x ↦ let ⟨y, hy⟩ := hg x; hy ▸ congr_arg g (h y)\n\ntheorem RightInverse.leftInverse_of_surjective {f : α → β} {g : β → α} :\n RightInverse f g → Surjective f → LeftInverse f g :=\n LeftInverse.rightInverse_of_surjective\n\ntheorem RightInverse.leftInverse_of_injective {f : α → β} {g : β → α} :\n RightInverse f g → Injective g → LeftInverse f g :=\n LeftInverse.rightInverse_of_injective\n\ntheorem LeftInverse.eq_rightInverse {f : α → β} {g₁ g₂ : β → α} (h₁ : LeftInverse g₁ f)\n (h₂ : RightInverse g₂ f) : g₁ = g₂ :=\n calc\n g₁ = g₁ ∘ f ∘ g₂ := by rw [h₂.comp_eq_id, comp_id]\n _ = g₂ := by rw [← comp_assoc, h₁.comp_eq_id, id_comp]\n\n/-- We can use choice to construct explicitly a partial inverse for\n a given injective function `f`. -/\nnoncomputable def partialInv {α β} (f : α → β) (b : β) : Option α :=\n open scoped Classical in\n if h : ∃ a, f a = b then some (Classical.choose h) else none\n\ntheorem Injective.isPartialInv {α β} {f : α → β} (I : Injective f) : IsPartialInv f (partialInv f) := by sorry\n open scoped Classical in\n have hpi : partialInv f b = if h : ∃ a, f a = b then some (Classical.choose h) else none :=\n rfl\n if h' : ∃ a, f a = b\n then by rw [hpi, dif_pos h'] at h\n injection h with h\n subst h\n apply Classical.choose_spec h'\n else by rw [hpi, dif_neg h'] at h; contradiction,\n fun e => e ▸ have h : ∃ a', f a' = f a := ⟨_, rfl⟩\n (dif_pos h).trans (congr_arg _ (I <| Classical.choose_spec h))⟩\n\n@[deprecated (since := \"2026-03-11\")] alias partialInv_of_injective := Injective.isPartialInv\n\ntheorem partialInv_left {α β} {f : α → β} (I : Injective f) : ∀ x, partialInv f (f x) = some x :=\n I.isPartialInv.eq\n\nend\n\nsection InvFun\n\nvariable {α β : Sort*} [Nonempty α] {f : α → β} {b : β}\n\n/-- The inverse of a function (which is a left inverse if `f` is injective\n and a right inverse if `f` is surjective). -/\n-- Explicit Sort so that `α` isn't inferred to be Prop via `exists_prop_decidable`\nnoncomputable def invFun {α : Sort u} {β} [Nonempty α] (f : α → β) : β → α :=\n open scoped Classical in\n fun y ↦ if h : (∃ x, f x = y) then h.choose else Classical.arbitrary α\n\ntheorem invFun_eq (h : ∃ a, f a = b) : f (invFun f b) = b := by sorry\ntheorem apply_invFun_apply {α β : Type*} {f : α → β} {a : α} :\n f (@invFun _ _ ⟨a⟩ f (f a)) = f a :=\n @invFun_eq _ _ ⟨a⟩ _ _ ⟨_, rfl⟩\n\ntheorem invFun_neg (h : ¬∃ a, f a = b) : invFun f b = Classical.choice ‹_› :=\n dif_neg h\n\ntheorem invFun_eq_of_injective_of_rightInverse {g : β → α} (hf : Injective f)\n (hg : RightInverse g f) : invFun f = g :=\n funext fun b ↦\n hf\n (by\n rw [hg b]\n exact invFun_eq ⟨g b, hg b⟩)\n\ntheorem rightInverse_invFun (hf : Surjective f) : RightInverse (invFun f) f :=\n fun b ↦ invFun_eq <| hf b\n\ntheorem leftInverse_invFun (hf : Injective f) : LeftInverse (invFun f) f :=\n fun b ↦ hf <| invFun_eq ⟨b, rfl⟩\n\ntheorem invFun_surjective (hf : Injective f) : Surjective (invFun f) :=\n (leftInverse_invFun hf).surjective\n\ntheorem invFun_comp (hf : Injective f) : invFun f ∘ f = id :=\n funext <| leftInverse_invFun hf\n\ntheorem Injective.hasLeftInverse (hf : Injective f) : HasLeftInverse f :=\n ⟨invFun f, leftInverse_invFun hf⟩\n\ntheorem injective_iff_hasLeftInverse : Injective f ↔ HasLeftInverse f :=\n ⟨Injective.hasLeftInverse, HasLeftInverse.injective⟩\n\nend InvFun\n\nsection SurjInv\n\nvariable {α : Sort u} {β : Sort v} {γ : Sort w} {f : α → β}\n\n/-- The inverse of a surjective function. (Unlike `invFun`, this does not require\n `α` to be inhabited.) -/\nnoncomputable def surjInv {f : α → β} (h : Surjective f) (b : β) : α :=\n Classical.choose (h b)\n\ntheorem surjInv_eq (h : Surjective f) (b) : f (surjInv h b) = b :=\n Classical.choose_spec (h b)\n\n@[simp]\nlemma comp_surjInv (hf : f.Surjective) : f ∘ f.surjInv hf = id :=\n funext (Function.surjInv_eq _)\n\ntheorem rightInverse_surjInv (hf : Surjective f) : RightInverse (surjInv hf) f :=\n surjInv_eq hf\n\ntheorem leftInverse_surjInv (hf : Bijective f) : LeftInverse (surjInv hf.2) f :=\n rightInverse_of_injective_of_leftInverse hf.1 (rightInverse_surjInv hf.2)\n\ntheorem Surjective.hasRightInverse (hf : Surjective f) : HasRightInverse f :=\n ⟨_, rightInverse_surjInv hf⟩\n\ntheorem surjective_iff_hasRightInverse : Surjective f ↔ HasRightInverse f :=\n ⟨Surjective.hasRightInverse, HasRightInverse.surjective⟩\n\ntheorem bijective_iff_has_inverse : Bijective f ↔ ∃ g, LeftInverse g f ∧ RightInverse g f :=\n ⟨fun hf ↦ ⟨_, leftInverse_surjInv hf, rightInverse_surjInv hf.2⟩, fun ⟨_, gl, gr⟩ ↦\n ⟨gl.injective, gr.surjective⟩⟩\n\ntheorem injective_surjInv (h : Surjective f) : Injective (surjInv h) :=\n (rightInverse_surjInv h).injective\n\ntheorem surjective_to_subsingleton [na : Nonempty α] [Subsingleton β] (f : α → β) :\n Surjective f :=\n fun _ ↦ let ⟨a⟩ := na; ⟨a, Subsingleton.elim _ _⟩\n\ntheorem Surjective.piMap {ι : Sort*} {α β : ι → Sort*} {f : ∀ i, α i → β i}\n (hf : ∀ i, Surjective (f i)) : Surjective (Pi.map f) := fun g ↦\n ⟨fun i ↦ surjInv (hf i) (g i), funext fun _ ↦ rightInverse_surjInv _ _⟩\n\n/-- Composition by a surjective function on the left is itself surjective. -/\ntheorem Surjective.comp_left {g : β → γ} (hg : Surjective g) :\n Surjective (g ∘ · : (α → β) → α → γ) :=\n .piMap fun _ ↦ hg\n\ntheorem surjective_comp_left_iff [Nonempty α] {g : β → γ} :\n Surjective (g ∘ · : (α → β) → α → γ) ↔ Surjective g := by sorry\ntheorem Bijective.piMap {ι : Sort*} {α β : ι → Sort*} {f : ∀ i, α i → β i}\n (hf : ∀ i, Bijective (f i)) : Bijective (Pi.map f) :=\n ⟨.piMap fun i ↦ (hf i).1, .piMap fun i ↦ (hf i).2⟩\n\n/-- Composition by a bijective function on the left is itself bijective. -/\ntheorem Bijective.comp_left {g : β → γ} (hg : Bijective g) :\n Bijective (g ∘ · : (α → β) → α → γ) :=\n ⟨hg.injective.comp_left, hg.surjective.comp_left⟩\n\nend SurjInv\n\nsection Update\n\nvariable {α : Sort u} {β : α → Sort v} {α' : Sort w} [DecidableEq α]\n {f : (a : α) → β a} {a : α} {b : β a}\n\n\n/-- Replacing the value of a function at a given point by a given value. -/\n@[grind]\ndef update (f : ∀ a, β a) (a' : α) (v : β a') (a : α) : β a :=\n if h : a = a' then Eq.ndrec v h.symm else f a\n\n@[simp]\ntheorem update_self (a : α) (v : β a) (f : ∀ a, β a) : update f a v a = v :=\n dif_pos rfl\n\n@[simp]\ntheorem update_of_ne {a a' : α} (h : a ≠ a') (v : β a') (f : ∀ a, β a) : update f a' v a = f a :=\n dif_neg h\n\n/-- On non-dependent functions, `Function.update` can be expressed as an `ite` -/\ntheorem update_apply {β : Sort*} (f : α → β) (a' : α) (b : β) (a : α) :\n update f a' b a = if a = a' then b else f a := by sorry\ntheorem update_eq_const_of_subsingleton [Subsingleton α] (a : α) (v : α') (f : α → α') :\n update f a v = const α v :=\n funext fun a' ↦ Subsingleton.elim a a' ▸ update_self ..\n\ntheorem surjective_eval {α : Sort u} {β : α → Sort v} [h : ∀ a, Nonempty (β a)] (a : α) :\n Surjective (eval a : (∀ a, β a) → β a) := fun b ↦\n ⟨@update _ _ (Classical.decEq α) (fun a ↦ (h a).some) a b,\n @update_self _ _ (Classical.decEq α) _ _ _⟩\n\ntheorem update_injective (f : ∀ a, β a) (a' : α) : Injective (update f a') := fun v v' h ↦ by\n have := congr_fun h a'\n rwa [update_self, update_self] at this\n\nlemma forall_update_iff (f : ∀ a, β a) {a : α} {b : β a} (p : ∀ a, β a → Prop) :\n (∀ x, p x (update f a b x)) ↔ p a b ∧ ∀ x, x ≠ a → p x (f x) := by sorry\ntheorem exists_update_iff (f : ∀ a, β a) {a : α} {b : β a} (p : ∀ a, β a → Prop) :\n (∃ x, p x (update f a b x)) ↔ p a b ∨ ∃ x ≠ a, p x (f x) := by sorry\ntheorem update_eq_iff {a : α} {b : β a} {f g : ∀ a, β a} :\n update f a b = g ↔ b = g a ∧ ∀ x ≠ a, f x = g x :=\n funext_iff.trans <| forall_update_iff _ fun x y ↦ y = g x\n\ntheorem eq_update_iff {a : α} {b : β a} {f g : ∀ a, β a} :\n g = update f a b ↔ g a = b ∧ ∀ x ≠ a, g x = f x :=\n funext_iff.trans <| forall_update_iff _ fun x y ↦ g x = y\n\n@[simp] lemma update_eq_self_iff : update f a b = f ↔ b = f a := by simp [update_eq_iff]\n\n@[simp] lemma eq_update_self_iff : f = update f a b ↔ f a = b := by simp [eq_update_iff]\n\nlemma ne_update_self_iff : f ≠ update f a b ↔ f a ≠ b := eq_update_self_iff.not\n\nlemma update_ne_self_iff : update f a b ≠ f ↔ b ≠ f a := update_eq_self_iff.not\n\n@[simp]\ntheorem update_eq_self (a : α) (f : ∀ a, β a) : update f a (f a) = f :=\n update_eq_iff.2 ⟨rfl, fun _ _ ↦ rfl⟩\n\ntheorem update_comp_eq_of_forall_ne' {α'} (g : ∀ a, β a) {f : α' → α} {i : α} (a : β i)\n (h : ∀ x, f x ≠ i) : (fun j ↦ (update g i a) (f j)) = fun j ↦ g (f j) :=\n funext fun _ ↦ update_of_ne (h _) _ _\n\nvariable [DecidableEq α']\n\n/-- Non-dependent version of `Function.update_comp_eq_of_forall_ne'` -/\ntheorem update_comp_eq_of_forall_ne {α β : Sort*} (g : α' → β) {f : α → α'} {i : α'} (a : β)\n (h : ∀ x, f x ≠ i) : update g i a ∘ f = g ∘ f :=\n update_comp_eq_of_forall_ne' g a h\n\ntheorem update_comp_eq_of_injective' (g : ∀ a, β a) {f : α' → α} (hf : Function.Injective f)\n (i : α') (a : β (f i)) : (fun j ↦ update g (f i) a (f j)) = update (fun i ↦ g (f i)) i a :=\n eq_update_iff.2 ⟨update_self .., fun _ hj ↦ update_of_ne (hf.ne hj) _ _⟩\n\ntheorem update_apply_of_injective\n (g : ∀ a, β a) {f : α' → α} (hf : Function.Injective f)\n (i : α') (a : β (f i)) (j : α') :\n update g (f i) a (f j) = update (fun i ↦ g (f i)) i a j :=\n congr_fun (update_comp_eq_of_injective' g hf i a) j\n\n/-- Non-dependent version of `Function.update_comp_eq_of_injective'` -/\ntheorem update_comp_eq_of_injective {β : Sort*} (g : α' → β) {f : α → α'}\n (hf : Function.Injective f) (i : α) (a : β) :\n Function.update g (f i) a ∘ f = Function.update (g ∘ f) i a :=\n update_comp_eq_of_injective' g hf i a\n\n/-- Recursors can be pushed inside `Function.update`.\n\nThe `ctor` argument should be a one-argument constructor like `Sum.inl`,\nand `recursor` should be an inductive recursor partially applied in all but that constructor,\nsuch as `(Sum.rec · g)`.\n\nIn future, we should build some automation to generate applications like `Option.rec_update` for all\ninductive types. -/\n@[nolint unusedArguments]\nlemma rec_update {ι κ : Sort*} {α : κ → Sort*} [DecidableEq ι] [DecidableEq κ]\n {ctor : ι → κ} (_ : Function.Injective ctor)\n (recursor : ((i : ι) → α (ctor i)) → ((i : κ) → α i))\n (h : ∀ f i, recursor f (ctor i) = f i)\n (h2 : ∀ f₁ f₂ k, (∀ i, ctor i ≠ k) → recursor f₁ k = recursor f₂ k)\n (f : (i : ι) → α (ctor i)) (i : ι) (x : α (ctor i)) :\n recursor (update f i x) = update (recursor f) (ctor i) x := by sorry\nlemma _root_.Option.rec_update {α : Type*} {β : Option α → Sort*} [DecidableEq α]\n (f : β none) (g : ∀ a, β (.some a)) (a : α) (x : β (.some a)) :\n Option.rec f (update g a x) = update (Option.rec f g) (.some a) x :=\n Function.rec_update (@Option.some.inj _) (Option.rec f) (fun _ _ => rfl) (fun := by sorry\ntheorem apply_update {ι : Sort*} [DecidableEq ι] {α β : ι → Sort*} (f : ∀ i, α i → β i)\n (g : ∀ i, α i) (i : ι) (v : α i) (j : ι) :\n f j (update g i v j) = update (fun k ↦ f k (g k)) i (f i v) j := by sorry\ntheorem apply_update₂ {ι : Sort*} [DecidableEq ι] {α β γ : ι → Sort*} (f : ∀ i, α i → β i → γ i)\n (g : ∀ i, α i) (h : ∀ i, β i) (i : ι) (v : α i) (w : β i) (j : ι) :\n f j (update g i v j) (update h i w j) = update (fun k ↦ f k (g k) (h k)) i (f i v w) j := by sorry\ntheorem pred_update (P : ∀ ⦃a⦄, β a → Prop) (f : ∀ a, β a) (a' : α) (v : β a') (a : α) :\n P (update f a' v a) ↔ a = a' ∧ P v ∨ a ≠ a' ∧ P (f a) := by sorry\ntheorem comp_update {α' : Sort*} {β : Sort*} (f : α' → β) (g : α → α') (i : α) (v : α') :\n f ∘ update g i v = update (f ∘ g) i (f v) :=\n funext <| apply_update _ _ _ _\n\ntheorem update_comm {α} [DecidableEq α] {β : α → Sort*} {a b : α} (h : a ≠ b) (v : β a) (w : β b)\n (f : ∀ a, β a) : update (update f a v) b w = update (update f b w) a v := by sorry\ntheorem update_idem {α} [DecidableEq α] {β : α → Sort*} {a : α} (v w : β a) (f : ∀ a, β a) :\n update (update f a v) a w = update f a w := by sorry\ntheorem _root_.Pi.map_update {ι : Sort*} [DecidableEq ι] {α β : ι → Sort*}\n {f : ∀ i, α i → β i}\n (g : ∀ i, α i) (i : ι) (a : α i) :\n Pi.map f (Function.update g i a) = Function.update (Pi.map f g) i (f i a) := by sorry\ntheorem _root_.Pi.map_injective\n {ι : Sort*} {α β : ι → Sort*} [∀ i, Nonempty (α i)] {f : ∀ i, α i → β i} :\n Injective (Pi.map f) ↔ ∀ i, Injective (f i) where\n mp h i x y hxy := by sorry\nend Update\n\nnoncomputable section Extend\n\nvariable {α β γ : Sort*} {f : α → β}\n\n/-- Extension of a function `g : α → γ` along a function `f : α → β`.\n\nFor every `a : α`, `f a` is sent to `g a`. `f` might not be surjective, so we use an auxiliary\nfunction `j : β → γ` by sending `b : β` not in the range of `f` to `j b`. If you do not care about\nthe behavior outside the range, `j` can be used as a junk value by setting it to be `0` or\n`Classical.arbitrary` (assuming `γ` is nonempty).\n\nThis definition is mathematically meaningful only when `f a₁ = f a₂ → g a₁ = g a₂` (spelled\n`g.FactorsThrough f`). In particular this holds if `f` is injective.\n\nA typical use case is extending a function from a subtype to the entire type. If you wish to extend\n`g : {b : β // p b} → γ` to a function `β → γ`, you should use `Function.extend Subtype.val g j`. -/\ndef extend (f : α → β) (g : α → γ) (j : β → γ) : β → γ := fun b ↦\n open scoped Classical in\n if h : ∃ a, f a = b then g (Classical.choose h) else j b\n\n/-- g factors through f : `f a = f b → g a = g b` -/\ndef FactorsThrough (g : α → γ) (f : α → β) : Prop :=\n ∀ ⦃a b⦄, f a = f b → g a = g b\n\ntheorem extend_def (f : α → β) (g : α → γ) (e' : β → γ) (b : β) [Decidable (∃ a, f a = b)] :\n extend f g e' b = if h : ∃ a, f a = b then g (Classical.choose h) else e' b := by sorry\nlemma Injective.factorsThrough (hf : Injective f) (g : α → γ) : g.FactorsThrough f :=\n fun _ _ h => congr_arg g (hf h)\n\nlemma FactorsThrough.extend_apply {g : α → γ} (hf : g.FactorsThrough f) (e' : β → γ) (a : α) :\n extend f g e' (f a) = g a := by sorry\ntheorem Injective.extend_apply (hf : Injective f) (g : α → γ) (e' : β → γ) (a : α) :\n extend f g e' (f a) = g a :=\n (hf.factorsThrough g).extend_apply e' a\n\n@[simp]\ntheorem extend_apply' (g : α → γ) (e' : β → γ) (b : β) (hb : ¬∃ a, f a = b) :\n extend f g e' b = e' b := by sorry\ntheorem extend_id (g : α → γ) (e' : α → γ) :\n extend id g e' = g :=\n funext <| injective_id.extend_apply g _\n\ntheorem Injective.extend_comp {α₁ α₂ α₃ : Sort*} {f₁₂ : α₁ → α₂} (h₁₂ : Function.Injective f₁₂)\n {f₂₃ : α₂ → α₃} (h₂₃ : Function.Injective f₂₃) (g : α₁ → γ) (e' : α₃ → γ) :\n extend (f₂₃ ∘ f₁₂) g e' = extend f₂₃ (extend f₁₂ g (e' ∘ f₂₃)) e' := by sorry\nlemma factorsThrough_iff (g : α → γ) [Nonempty γ] : g.FactorsThrough f ↔ ∃ (e : β → γ), g = e ∘ f :=\n ⟨fun hf => ⟨extend f g (const β (Classical.arbitrary γ)),\n funext (fun x => by simp only [comp_apply, hf.extend_apply])⟩,\n fun h _ _ hf => by rw [Classical.choose_spec h, comp_apply, comp_apply, hf]⟩\n\nlemma apply_extend {δ} {g : α → γ} (F : γ → δ) (f : α → β) (e' : β → γ) (b : β) :\n F (extend f g e' b) = extend f (F ∘ g) (F ∘ e') b :=\n open scoped Classical in apply_dite F _ _ _\n\ntheorem extend_injective (hf : Injective f) (e' : β → γ) : Injective fun g ↦ extend f g e' := by sorry\nlemma FactorsThrough.extend_comp {g : α → γ} (e' : β → γ) (hf : FactorsThrough g f) :\n extend f g e' ∘ f = g :=\n funext fun a => hf.extend_apply e' a\n\n@[simp]\nlemma extend_const (f : α → β) (c : γ) : extend f (fun _ ↦ c) (fun _ ↦ c) = fun _ ↦ c :=\n funext fun _ ↦ open scoped Classical in ite_id _\n\n@[simp]\ntheorem extend_comp (hf : Injective f) (g : α → γ) (e' : β → γ) : extend f g e' ∘ f = g :=\n funext fun a ↦ hf.extend_apply g e' a\n\ntheorem Injective.surjective_comp_right' (hf : Injective f) (g₀ : β → γ) :\n Surjective fun g : β → γ ↦ g ∘ f :=\n fun g ↦ ⟨extend f g g₀, Function.extend_comp hf _ _⟩\n\ntheorem Injective.surjective_comp_right [Nonempty γ] (hf : Injective f) :\n Surjective fun g : β → γ ↦ g ∘ f :=\n hf.surjective_comp_right' fun _ ↦ Classical.choice ‹_›\n\ntheorem surjective_comp_right_iff_injective {γ : Type*} [Nontrivial γ] :\n Surjective (fun g : β → γ ↦ g ∘ f) ↔ Injective f := by sorry\ntheorem Bijective.comp_right (hf : Bijective f) : Bijective fun g : β → γ ↦ g ∘ f :=\n ⟨hf.surjective.injective_comp_right, fun g ↦\n ⟨g ∘ surjInv hf.surjective,\n by simp only [comp_assoc g _ f, (leftInverse_surjInv hf).comp_eq_id, comp_id]⟩⟩\n\nend Extend\n\nnamespace FactorsThrough\n\nprotected theorem rfl {α β : Sort*} {f : α → β} : FactorsThrough f f := fun _ _ ↦ id\n\ntheorem comp_left {α β γ δ : Sort*} {f : α → β} {g : α → γ} (h : FactorsThrough g f) (g' : γ → δ) :\n FactorsThrough (g' ∘ g) f := fun _x _y hxy ↦\n congr_arg g' (h hxy)\n\ntheorem comp_right {α β γ δ : Sort*} {f : α → β} {g : α → γ} (h : FactorsThrough g f) (g' : δ → α) :\n FactorsThrough (g ∘ g') (f ∘ g') := fun _x _y hxy ↦\n h hxy\n\nend FactorsThrough\n\nsection CurryAndUncurry\n\ntheorem uncurry_def {α β γ} (f : α → β → γ) : uncurry f = fun p ↦ f p.1 p.2 :=\n rfl\n\ntheorem uncurry_injective {α β γ} : Function.Injective (uncurry : (α → β → γ) → _) :=\n LeftInverse.injective curry_uncurry\n\ntheorem curry_injective {α β γ} : Function.Injective (curry : (α × β → γ) → _) :=\n LeftInverse.injective uncurry_curry\n\ntheorem uncurry_flip {α β γ} (f : α → β → γ) : uncurry (flip f) = uncurry f ∘ Prod.swap :=\n rfl\n\ntheorem flip_curry {α β γ} (f : α × β → γ) : flip (curry f) = curry (f ∘ Prod.swap) :=\n rfl\n\ntheorem curry_update {α α' β : Type*} [DecidableEq α] [DecidableEq α']\n (f : α × α' → β) (aa' : α × α') (b : β) :\n curry (Function.update f aa' b) =\n Function.update (curry f) aa'.1 (Function.update (curry f aa'.1) aa'.2 b) := by sorry\ntheorem uncurry_update_update {α α' β : Type*} [DecidableEq α] [DecidableEq α']\n (f : α → α' → β) (a : α) (a' : α') (b : β) :\n uncurry (Function.update f a (Function.update (f a) a' b)) =\n Function.update (uncurry f) (a, a') b := by sorry\nend CurryAndUncurry\n\nsection Bicomp\n\nvariable {α β γ δ ε : Type*}\n\n/-- Compose a binary function `f` with a pair of unary functions `g` and `h`.\nIf both arguments of `f` have the same type and `g = h`, then `bicompl f g g = f on g`. -/\ndef bicompl (f : γ → δ → ε) (g : α → γ) (h : β → δ) (a b) :=\n f (g a) (h b)\n\n/-- Compose a unary function `f` with a binary function `g`. -/\ndef bicompr (f : γ → δ) (g : α → β → γ) (a b) :=\n f (g a b)\n\n-- Suggested local notation:\nlocal notation f \" ∘₂ \" g => bicompr f g\n\ntheorem uncurry_bicompr (f : α → β → γ) (g : γ → δ) : uncurry (g ∘₂ f) = g ∘ uncurry f :=\n rfl\n\ntheorem uncurry_bicompl (f : γ → δ → ε) (g : α → γ) (h : β → δ) :\n uncurry (bicompl f g h) = uncurry f ∘ Prod.map g h :=\n rfl\n\nend Bicomp\n\nsection Uncurry\n\nvariable {α β γ δ : Type*}\n\n/-- Records a way to turn an element of `α` into a function from `β` to `γ`. The most generic use\nis to recursively uncurry. For instance `f : α → β → γ → δ` will be turned into\n`↿f : α × β × γ → δ`. One can also add instances for bundled maps. -/\nclass HasUncurry (α : Type*) (β : outParam Type*) (γ : outParam Type*) where\n /-- Uncurrying operator. The most generic use is to recursively uncurry. For instance\n `f : α → β → γ → δ` will be turned into `↿f : α × β × γ → δ`. One can also add instances\n for bundled maps. -/\n uncurry : α → β → γ\n\n@[inherit_doc] prefix:max \"↿\" => HasUncurry.uncurry\n\ninstance hasUncurryBase : HasUncurry (α → β) α β :=\n ⟨id⟩\n\ninstance hasUncurryInduction [HasUncurry β γ δ] : HasUncurry (α → β) (α × γ) δ :=\n ⟨fun f p ↦ ↿(f p.1) p.2⟩\n\nend Uncurry\n\n/-- A function is involutive, if `f ∘ f = id`. -/\ndef Involutive {α} (f : α → α) : Prop :=\n ∀ x, f (f x) = x\n\ntheorem _root_.Bool.involutive_not : Involutive not :=\n Bool.not_not\n\nnamespace Involutive\n\nvariable {α : Sort u} {f : α → α} (h : Involutive f)\n\ninclude h\n\n@[simp]\ntheorem comp_self : f ∘ f = id :=\n funext h\n\nprotected theorem leftInverse : LeftInverse f f := h\n\ntheorem leftInverse_iff {g : α → α} :\n g.LeftInverse f ↔ g = f :=\n ⟨fun hg ↦ funext fun x ↦ by rw [← h x, hg, h], fun he ↦ he ▸ h.leftInverse⟩\n\nprotected theorem rightInverse : RightInverse f f := h\n\nprotected theorem injective : Injective f := h.leftInverse.injective\n\nprotected theorem surjective : Surjective f := fun x ↦ ⟨f x, h x⟩\n\nprotected theorem bijective : Bijective f := ⟨h.injective, h.surjective⟩\n\n/-- Involuting an `ite` of an involuted value `x : α` negates the `Prop` condition in the `ite`. -/\nprotected theorem ite_not (P : Prop) [Decidable P] (x : α) :\n f (ite P x (f x)) = ite (¬P) x (f x) := by rw [apply_ite f, h, ite_not]\n\n/-- An involution commutes across an equality. Compare to `Function.Injective.eq_iff`. -/\nprotected theorem eq_iff {x y : α} : f x = y ↔ x = f y :=\n h.injective.eq_iff' (h y)\n\nend Involutive\n\nlemma not_involutive : Involutive Not := fun _ ↦ propext not_not\nlemma not_injective : Injective Not := not_involutive.injective\nlemma not_surjective : Surjective Not := not_involutive.surjective\nlemma not_bijective : Bijective Not := not_involutive.bijective\n\n@[simp]\nlemma symmetric_apply_eq_iff {α : Sort*} {f : α → α} : Symmetric (f · = ·) ↔ Involutive f := by sorry\ndef Injective2 {α β γ : Sort*} (f : α → β → γ) : Prop :=\n ∀ ⦃a₁ a₂ b₁ b₂⦄, f a₁ b₁ = f a₂ b₂ → a₁ = a₂ ∧ b₁ = b₂\n\nnamespace Injective2\n\nvariable {α β γ : Sort*} {f : α → β → γ}\n\n/-- A binary injective function is injective when only the left argument varies. -/\nprotected theorem left (hf : Injective2 f) (b : β) : Function.Injective fun a ↦ f a b :=\n fun _ _ h ↦ (hf h).left\n\n/-- A binary injective function is injective when only the right argument varies. -/\nprotected theorem right (hf : Injective2 f) (a : α) : Function.Injective (f a) :=\n fun _ _ h ↦ (hf h).right\n\nprotected theorem uncurry {α β γ : Type*} {f : α → β → γ} (hf : Injective2 f) :\n Function.Injective (uncurry f) :=\n fun ⟨_, _⟩ ⟨_, _⟩ h ↦ (hf h).elim (congr_arg₂ _)\n\n/-- As a map from the left argument to a unary function, `f` is injective. -/\ntheorem left' (hf : Injective2 f) [Nonempty β] : Function.Injective f := fun _ _ h ↦\n let ⟨b⟩ := ‹Nonempty β›\n hf.left b <| (congr_fun h b :)\n\n/-- As a map from the right argument to a unary function, `f` is injective. -/\ntheorem right' (hf : Injective2 f) [Nonempty α] : Function.Injective fun b a ↦ f a b :=\n fun _ _ h ↦\n let ⟨a⟩ := ‹Nonempty α›\n hf.right a <| (congr_fun h a :)\n\ntheorem eq_iff (hf : Injective2 f) {a₁ a₂ b₁ b₂} : f a₁ b₁ = f a₂ b₂ ↔ a₁ = a₂ ∧ b₁ = b₂ :=\n ⟨fun h ↦ hf h, fun ⟨h1, h2⟩ ↦ congr_arg₂ f h1 h2⟩\n\nend Injective2\n\nsection Sometimes\n\n/-- `sometimes f` evaluates to some value of `f`, if it exists. This function is especially\ninteresting in the case where `α` is a proposition, in which case `f` is necessarily a\nconstant function, so that `sometimes f = f a` for all `a`. -/\nnoncomputable def sometimes {α β} [Nonempty β] (f : α → β) : β :=\n open scoped Classical in\n if h : Nonempty α then f (Classical.choice h) else Classical.choice ‹_›\n\ntheorem sometimes_eq {p : Prop} {α} [Nonempty α] (f : p → α) (a : p) : sometimes f = f a :=\n dif_pos ⟨a⟩\n\ntheorem sometimes_spec {p : Prop} {α} [Nonempty α] (P : α → Prop) (f : p → α) (a : p)\n (h : P (f a)) : P (sometimes f) := by sorry\nend Sometimes\n\nend Function\n\nvariable {α β : Sort*}\n\n/-- A relation `r : α → β → Prop` is \"function-like\"\n(for each `a` there exists a unique `b` such that `r a b`)\nif and only if it is `(f · = ·)` for some function `f`. -/\nlemma forall_existsUnique_iff {r : α → β → Prop} :\n (∀ a, ∃! b, r a b) ↔ ∃ f : α → β, ∀ {a b}, r a b ↔ f a = b := by sorry\nlemma forall_existsUnique_iff' {r : α → β → Prop} :\n (∀ a, ∃! b, r a b) ↔ ∃ f : α → β, r = (f · = ·) := by sorry\ndef Set.piecewise {α : Type u} {β : α → Sort v} (s : Set α) (f g : ∀ i, β i)\n [∀ j, Decidable (j ∈ s)] : ∀ i, β i :=\n fun i ↦ if i ∈ s then f i else g i\n\n\n/-! ### Bijectivity of `Eq.rec`, `Eq.mp`, `Eq.mpr`, and `cast` -/\n\ntheorem eq_rec_on_bijective {C : α → Sort*} :\n ∀ {a a' : α} (h : a = a'), Function.Bijective (@Eq.ndrec _ _ C · _ h) := by sorry\ntheorem eq_mp_bijective {α β : Sort _} (h : α = β) : Function.Bijective (Eq.mp h) := by sorry\ntheorem eq_mpr_bijective {α β : Sort _} (h : α = β) : Function.Bijective (Eq.mpr h) := by sorry\ntheorem cast_bijective {α β : Sort _} (h : α = β) : Function.Bijective (cast h) := by sorry\ntheorem eq_rec_inj {a a' : α} (h : a = a') {C : α → Type*} (x y : C a) :\n (Eq.ndrec x h : C a') = Eq.ndrec y h ↔ x = y :=\n (eq_rec_on_bijective h).injective.eq_iff\n\n@[simp]\ntheorem cast_inj {α β : Type u} (h : α = β) {x y : α} : cast h x = cast h y ↔ x = y :=\n (cast_bijective h).injective.eq_iff\n\ntheorem Function.LeftInverse.eq_rec_eq {γ : β → Sort v} {f : α → β} {g : β → α}\n (h : Function.LeftInverse g f) (C : ∀ a : α, γ (f a)) (a : α) :\n -- TODO: mathlib3 uses `(congr_arg f (h a)).rec (C (g (f a)))` for LHS\n @Eq.rec β (f (g (f a))) (fun x _ ↦ γ x) (C (g (f a))) (f a) (congr_arg f (h a)) = C a :=\n eq_of_heq <| (eqRec_heq _ _).trans <| by rw [h]\n\ntheorem Function.LeftInverse.eq_rec_on_eq {γ : β → Sort v} {f : α → β} {g : β → α}\n (h : Function.LeftInverse g f) (C : ∀ a : α, γ (f a)) (a : α) :\n -- TODO: mathlib3 uses `(congr_arg f (h a)).recOn (C (g (f a)))` for LHS\n @Eq.recOn β (f (g (f a))) (fun x _ ↦ γ x) (f a) (congr_arg f (h a)) (C (g (f a))) = C a :=\n h.eq_rec_eq _ _\n\ntheorem Function.LeftInverse.cast_eq {γ : β → Sort v} {f : α → β} {g : β → α}\n (h : Function.LeftInverse g f) (C : ∀ a : α, γ (f a)) (a : α) :\n cast (congr_arg (fun a ↦ γ (f a)) (h a)) (C (g (f a))) = C a := by sorry\ndef Set.SeparatesPoints {α β : Type*} (A : Set (α → β)) : Prop :=\n ∀ ⦃x y : α⦄, x ≠ y → ∃ f ∈ A, (f x : β) ≠ f y\n\ntheorem InvImage.equivalence {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β)\n (h : Equivalence r) : Equivalence (InvImage r f) :=\n ⟨fun _ ↦ h.1 _, h.symm, h.trans⟩\n\ninstance {α β : Type*} {r : α → β → Prop} {x : α × β} [Decidable (r x.1 x.2)] :\n Decidable (uncurry r x) :=\n ‹Decidable _›\n\ninstance {α β : Type*} {r : α × β → Prop} {a : α} {b : β} [Decidable (r (a, b))] :\n Decidable (curry r a b) :=\n ‹Decidable _›\n\nnamespace Pi\n\nvariable {ι : Type*}\n\n@[simp] theorem map_id {α : ι → Type*} : Pi.map (fun i => @id (α i)) = id := rfl\n\n@[simp] theorem map_id' {α : ι → Type*} : Pi.map (fun i (a : α i) => a) = fun x ↦ x := rfl\n\ntheorem map_comp_map {α β γ : ι → Type*} (f : ∀ i, α i → β i) (g : ∀ i, β i → γ i) :\n Pi.map g ∘ Pi.map f = Pi.map fun i => g i ∘ f i :=\n rfl\n\nend Pi\n" }, { "theorem_id": 50, "title": "063_cantor_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From Stdlib Require Export Ensembles.\nFrom Stdlib Require Export Relations_1.\nFrom Stdlib Require Export Relations_1_facts.\nFrom Stdlib Require Export Partial_Order.\nFrom Stdlib Require Export Cpo.\n\nSection The_power_set_partial_order.\nVariable U : Type.\n\nInductive Power_set (A:Ensemble U) : Ensemble (Ensemble U) :=\n Definition_of_Power_set :\n forall X:Ensemble U, Included U X A -> In (Ensemble U) (Power_set A) X.\n#[local]\nHint Resolve Definition_of_Power_set : core.\n\nTheorem Empty_set_minimal : forall X:Ensemble U, Included U (Empty_set U) X.\nProof.\nAdmitted.\n#[local]\nHint Unfold Power_set_PO : core.\n\nTheorem Strict_Rel_is_Strict_Included :\n same_relation (Ensemble U) (Strict_Included U)\n (Strict_Rel_of (Ensemble U) (Power_set_PO (Full_set U))).\nProof.\nAdmitted.\n#[local]\nHint Resolve Strict_Rel_Transitive Strict_Rel_is_Strict_Included : core.\n\nLemma Strict_inclusion_is_transitive_with_inclusion :\n forall x y z:Ensemble U,\n Strict_Included U x y -> Included U y z -> Strict_Included U x z.\nProof.\nAdmitted.\n\nLemma Strict_inclusion_is_transitive_with_inclusion_left :\n forall x y z:Ensemble U,\n Included U x y -> Strict_Included U y z -> Strict_Included U x z.\nProof.\nAdmitted.\n\nLemma Strict_inclusion_is_transitive :\n Transitive (Ensemble U) (Strict_Included U).\nProof.\nAdmitted.\n\nTheorem Empty_set_is_Bottom :\n forall A:Ensemble U, Bottom (Ensemble U) (Power_set_PO A) (Empty_set U).\nProof.\nAdmitted.\n#[local]\nHint Resolve Empty_set_is_Bottom : core.\n\nTheorem Union_minimal :\n forall a b X:Ensemble U,\n Included U a X -> Included U b X -> Included U (Union U a b) X.\nProof.\nAdmitted.\n#[local]\nHint Resolve Union_minimal : core.\n\nTheorem Intersection_maximal :\n forall a b X:Ensemble U,\n Included U X a -> Included U X b -> Included U X (Intersection U a b).\nProof.\nAdmitted.\n\nTheorem Union_increases_l : forall a b:Ensemble U, Included U a (Union U a b).\nProof.\nAdmitted.\n\nTheorem Union_increases_r : forall a b:Ensemble U, Included U b (Union U a b).\nProof.\nAdmitted.\n\nTheorem Intersection_decreases_l :\n forall a b:Ensemble U, Included U (Intersection U a b) a.\nProof.\nAdmitted.\n\nTheorem Intersection_decreases_r :\n forall a b:Ensemble U, Included U (Intersection U a b) b.\nProof.\nAdmitted.\n#[local]\nHint Resolve Union_increases_l Union_increases_r Intersection_decreases_l\n Intersection_decreases_r : core.\n\nTheorem Union_is_Lub :\n forall A a b:Ensemble U,\n Included U a A ->\n Included U b A ->\n Lub (Ensemble U) (Power_set_PO A) (Couple (Ensemble U) a b) (Union U a b).\nProof.\nAdmitted.\n\nTheorem Intersection_is_Glb :\n forall A a b:Ensemble U,\n Included U a A ->\n Included U b A ->\n Glb (Ensemble U) (Power_set_PO A) (Couple (Ensemble U) a b)\n (Intersection U a b).\nProof.\nAdmitted.\n\nEnd The_power_set_partial_order.\n\n#[global]\nHint Resolve Empty_set_minimal: sets.\n#[global]\nHint Resolve Power_set_Inhabited: sets.\n#[global]\nHint Resolve Inclusion_is_an_order: sets.\n#[global]\nHint Resolve Inclusion_is_transitive: sets.\n#[global]\nHint Resolve Union_minimal: sets.\n#[global]\nHint Resolve Union_increases_l: sets.\n#[global]\nHint Resolve Union_increases_r: sets.\n#[global]\nHint Resolve Intersection_decreases_l: sets.\n#[global]\nHint Resolve Intersection_decreases_r: sets.\n#[global]\nHint Resolve Empty_set_is_Bottom: sets.\n#[global]\nHint Resolve Strict_inclusion_is_transitive: sets." }, { "theorem_id": 51, "title": "064_l_hôpital_s_rule", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/analysis.ml\";;\n\noverride_interface (\"-->\",`(tends_real_real)`);;\n\nprioritize_real();;\n\nlet MVT2 = `!f g a b.\n a < b /\\\n (!x. a <= x /\\ x <= b ==> f contl x /\\ g contl x) /\\\n (!x. a < x /\\ x < b ==> f differentiable x /\\ g differentiable x)\n ==> ?z f' g'. a < z /\\ z < b /\\ (f diffl f') z /\\ (g diffl g') z /\\\n (f b - f a) * g' = (g b - g a) * f'`;;\n\nlet LHOPITAL_WEAK = `!f g f' g' c L d.\n &0 < d /\\\n (!x. &0 < abs(x - c) /\\ abs(x - c) < d\n ==> (f diffl f'(x)) x /\\ (g diffl g'(x)) x /\\ ~(g'(x) = &0)) /\\\n f(c) = &0 /\\ g(c) = &0 /\\ (f --> &0) c /\\ (g --> &0) c /\\\n ((\\x. f'(x) / g'(x)) --> L) c\n ==> ((\\x. f(x) / g(x)) --> L) c`;;\n\nlet LHOPITAL = `!f g f' g' c L d.\n &0 < d /\\\n (!x. &0 < abs(x - c) /\\ abs(x - c) < d\n ==> (f diffl f'(x)) x /\\ (g diffl g'(x)) x /\\ ~(g'(x) = &0)) /\\\n (f --> &0) c /\\ (g --> &0) c /\\ ((\\x. f'(x) / g'(x)) --> L) c\n ==> ((\\x. f(x) / g(x)) --> L) c`;;" }, { "theorem_id": 51, "title": "064_l_hôpital_s_rule", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Derivative\\\n\ntheory Derivative\n imports\n Bounded_Linear_Function\n Line_Segment\n Convex_Euclidean_Space\nbegin\n\ndeclare bounded_linear_inner_left [intro]\n\ndeclare has_derivative_bounded_linear[dest]\n\nsubsection \\Derivatives\\\n\nlemma has_derivative_add_const:\n \"(f has_derivative f') net \\ ((\\x. f x + c) has_derivative f') net\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Derivative with composed bilinear function\\\n\ntext \\More explicit epsilon-delta forms.\\\n\nproposition has_derivative_within':\n \"(f has_derivative f')(at x within s) \\\n bounded_linear f' \\\n (\\e>0. \\d>0. \\x'\\s. 0 < norm (x' - x) \\ norm (x' - x) < d \\\n norm (f x' - f x - f'(x' - x)) / norm (x' - x) < e)\"\n by sorry\n\nlemma has_derivative_at':\n \"(f has_derivative f') (at x) \n \\ bounded_linear f' \\\n (\\e>0. \\d>0. \\x'. 0 < norm (x' - x) \\ norm (x' - x) < d \\\n norm (f x' - f x - f'(x' - x)) / norm (x' - x) < e)\"\n by sorry\n\nlemma has_derivative_componentwise_within:\n \"(f has_derivative f') (at a within S) \\\n (\\i \\ Basis. ((\\x. f x \\ i) has_derivative (\\x. f' x \\ i)) (at a within S))\"\n by sorry\n\nlemma has_derivative_at_withinI:\n \"(f has_derivative f') (at x) \\ (f has_derivative f') (at x within s)\"\n by sorry\n\nlemma has_derivative_right:\n fixes f :: \"real \\ real\"\n and y :: \"real\"\n shows \"(f has_derivative (" }, { "theorem_id": 51, "title": "064_l_hôpital_s_rule", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n-/\nmodule\n\npublic import Mathlib.Analysis.Calculus.Deriv.Inv\npublic import Mathlib.Analysis.Calculus.Deriv.MeanValue\n\n/-!\n# L'Hôpital's rule for 0/0 indeterminate forms\n\nIn this file, we prove several forms of \"L'Hôpital's rule\" for computing 0/0\nindeterminate forms. The proof of `HasDerivAt.lhopital_zero_right_on_Ioo`\nis based on the one given in the corresponding\n[Wikibooks](https://en.wikibooks.org/wiki/Calculus/L%27H%C3%B4pital%27s_Rule)\nchapter, and all other statements are derived from this one by composing by\ncarefully chosen functions.\n\nNote that the filter `f'/g'` tends to isn't required to be one of `𝓝 a`,\n`atTop` or `atBot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `ℝ`.\n\nEach statement is available in a `HasDerivAt` form and a `deriv` form, which\nis denoted by each statement being in either the `HasDerivAt` or the `deriv`\nnamespace.\n\n## Tags\n\nL'Hôpital's rule, L'Hopital's rule\n-/\n\npublic section\n\n\nopen Filter Set\n\nopen scoped Filter Topology Pointwise\n\nvariable {a b : ℝ} {l : Filter ℝ} {f f' g g' : ℝ → ℝ}\n\n/-!\n## Interval-based versions\n\nWe start by proving statements where all conditions (derivability, `g' ≠ 0`) have\nto be satisfied on an explicitly-provided interval.\n-/\n\n\nnamespace HasDerivAt\n\ntheorem lhopital_zero_right_on_Ioo (hab : a < b) (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x)\n (hgg' : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x) (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n (hfa : Tendsto f (𝓝[>] a) (𝓝 0)) (hga : Tendsto g (𝓝[>] a) (𝓝 0))\n (hdiv : Tendsto (fun x => f' x / g' x) (𝓝[>] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[>] a) l := by sorry\ntheorem lhopital_zero_right_on_Ico (hab : a < b) (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x)\n (hgg' : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x) (hcf : ContinuousOn f (Ico a b))\n (hcg : ContinuousOn g (Ico a b)) (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0) (hfa : f a = 0) (hga : g a = 0)\n (hdiv : Tendsto (fun x => f' x / g' x) (𝓝[>] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[>] a) l := by sorry\ntheorem lhopital_zero_left_on_Ioo (hab : a < b) (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x)\n (hgg' : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x) (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n (hfb : Tendsto f (𝓝[<] b) (𝓝 0)) (hgb : Tendsto g (𝓝[<] b) (𝓝 0))\n (hdiv : Tendsto (fun x => f' x / g' x) (𝓝[<] b) l) :\n Tendsto (fun x => f x / g x) (𝓝[<] b) l := by sorry\ntheorem lhopital_zero_left_on_Ioc (hab : a < b) (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x)\n (hgg' : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x) (hcf : ContinuousOn f (Ioc a b))\n (hcg : ContinuousOn g (Ioc a b)) (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0) (hfb : f b = 0) (hgb : g b = 0)\n (hdiv : Tendsto (fun x => f' x / g' x) (𝓝[<] b) l) :\n Tendsto (fun x => f x / g x) (𝓝[<] b) l := by sorry\ntheorem lhopital_zero_atTop_on_Ioi (hff' : ∀ x ∈ Ioi a, HasDerivAt f (f' x) x)\n (hgg' : ∀ x ∈ Ioi a, HasDerivAt g (g' x) x) (hg' : ∀ x ∈ Ioi a, g' x ≠ 0)\n (hftop : Tendsto f atTop (𝓝 0)) (hgtop : Tendsto g atTop (𝓝 0))\n (hdiv : Tendsto (fun x => f' x / g' x) atTop l) : Tendsto (fun x => f x / g x) atTop l := by sorry\ntheorem lhopital_zero_atBot_on_Iio (hff' : ∀ x ∈ Iio a, HasDerivAt f (f' x) x)\n (hgg' : ∀ x ∈ Iio a, HasDerivAt g (g' x) x) (hg' : ∀ x ∈ Iio a, g' x ≠ 0)\n (hfbot : Tendsto f atBot (𝓝 0)) (hgbot : Tendsto g atBot (𝓝 0))\n (hdiv : Tendsto (fun x => f' x / g' x) atBot l) : Tendsto (fun x => f x / g x) atBot l := by sorry\nend HasDerivAt\n\nnamespace deriv\n\ntheorem lhopital_zero_right_on_Ioo (hab : a < b) (hdf : DifferentiableOn ℝ f (Ioo a b))\n (hg' : ∀ x ∈ Ioo a b, deriv g x ≠ 0) (hfa : Tendsto f (𝓝[>] a) (𝓝 0))\n (hga : Tendsto g (𝓝[>] a) (𝓝 0))\n (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[>] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[>] a) l := by sorry\ntheorem lhopital_zero_right_on_Ico (hab : a < b) (hdf : DifferentiableOn ℝ f (Ioo a b))\n (hcf : ContinuousOn f (Ico a b)) (hcg : ContinuousOn g (Ico a b))\n (hg' : ∀ x ∈ Ioo a b, (deriv g) x ≠ 0) (hfa : f a = 0) (hga : g a = 0)\n (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[>] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[>] a) l := by sorry\ntheorem lhopital_zero_left_on_Ioo (hab : a < b) (hdf : DifferentiableOn ℝ f (Ioo a b))\n (hg' : ∀ x ∈ Ioo a b, (deriv g) x ≠ 0) (hfb : Tendsto f (𝓝[<] b) (𝓝 0))\n (hgb : Tendsto g (𝓝[<] b) (𝓝 0))\n (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[<] b) l) :\n Tendsto (fun x => f x / g x) (𝓝[<] b) l := by sorry\ntheorem lhopital_zero_atTop_on_Ioi (hdf : DifferentiableOn ℝ f (Ioi a))\n (hg' : ∀ x ∈ Ioi a, (deriv g) x ≠ 0) (hftop : Tendsto f atTop (𝓝 0))\n (hgtop : Tendsto g atTop (𝓝 0)) (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) atTop l) :\n Tendsto (fun x => f x / g x) atTop l := by sorry\ntheorem lhopital_zero_atBot_on_Iio (hdf : DifferentiableOn ℝ f (Iio a))\n (hg' : ∀ x ∈ Iio a, (deriv g) x ≠ 0) (hfbot : Tendsto f atBot (𝓝 0))\n (hgbot : Tendsto g atBot (𝓝 0)) (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) atBot l) :\n Tendsto (fun x => f x / g x) atBot l := by sorry\nend deriv\n\n/-!\n## Generic versions\n\nThe following statements no longer any explicit interval, as they only require\nconditions holding eventually.\n-/\n\n\nnamespace HasDerivAt\n\n/-- L'Hôpital's rule for approaching a real from the right, `HasDerivAt` version -/\ntheorem lhopital_zero_nhdsGT (hff' : ∀ᶠ x in 𝓝[>] a, HasDerivAt f (f' x) x)\n (hgg' : ∀ᶠ x in 𝓝[>] a, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in 𝓝[>] a, g' x ≠ 0)\n (hfa : Tendsto f (𝓝[>] a) (𝓝 0)) (hga : Tendsto g (𝓝[>] a) (𝓝 0))\n (hdiv : Tendsto (fun x => f' x / g' x) (𝓝[>] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[>] a) l := by sorry\ntheorem lhopital_zero_nhdsLT (hff' : ∀ᶠ x in 𝓝[<] a, HasDerivAt f (f' x) x)\n (hgg' : ∀ᶠ x in 𝓝[<] a, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in 𝓝[<] a, g' x ≠ 0)\n (hfa : Tendsto f (𝓝[<] a) (𝓝 0)) (hga : Tendsto g (𝓝[<] a) (𝓝 0))\n (hdiv : Tendsto (fun x => f' x / g' x) (𝓝[<] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[<] a) l := by sorry\ntheorem lhopital_zero_nhdsNE (hff' : ∀ᶠ x in 𝓝[≠] a, HasDerivAt f (f' x) x)\n (hgg' : ∀ᶠ x in 𝓝[≠] a, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in 𝓝[≠] a, g' x ≠ 0)\n (hfa : Tendsto f (𝓝[≠] a) (𝓝 0)) (hga : Tendsto g (𝓝[≠] a) (𝓝 0))\n (hdiv : Tendsto (fun x => f' x / g' x) (𝓝[≠] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[≠] a) l := by sorry\ntheorem _root_.HasDerivWithinAt.lhopital_zero_nhdsWithin_convex {s : Set ℝ} (hs : Convex ℝ s)\n (hff' : ∀ᶠ x in 𝓝[s \\ {a}] a, HasDerivWithinAt f (f' x) (s \\ {a}) x)\n (hgg' : ∀ᶠ x in 𝓝[s \\ {a}] a, HasDerivWithinAt g (g' x) (s \\ {a}) x)\n (hg' : ∀ᶠ x in 𝓝[s \\ {a}] a, g' x ≠ 0)\n (hfa : Tendsto f (𝓝[s \\ {a}] a) (𝓝 0)) (hga : Tendsto g (𝓝[s \\ {a}] a) (𝓝 0))\n (hdiv : Tendsto (fun x ↦ f' x / g' x) (𝓝[s \\ {a}] a) l) :\n Tendsto (fun x ↦ f x / g x) (𝓝[s \\ {a}] a) l := .of_neBot_imp fun has => by\n replace has := closure_mono diff_subset (mem_closure_iff_nhdsWithin_neBot.2 has)\n have h := hs.diff_singleton_eventually_mem_nhds a\n replace hff' := h.mp <| hff'.mono fun _ h ↦ h.hasDerivAt\n replace hgg' := h.mp <| hgg'.mono fun _ h ↦ h.hasDerivAt\n rcases eq_empty_or_nonempty (s ∩ Iio a) with hs_Iio | hs_Iio\n <;> rcases eq_empty_or_nonempty (s ∩ Ioi a) with hs_Ioi | hs_Ioi\n · simp [diff_eq, ← Iio_union_Ioi, inter_union_distrib_left, hs_Iio, hs_Ioi]\n · simp_rw [hs.nhdsWithin_diff_eq_nhdsGT has hs_Iio hs_Ioi] at *\n exact lhopital_zero_nhdsGT hff' hgg' hg' hfa hga hdiv\n · simp_rw [hs.nhdsWithin_diff_eq_nhdsLT has hs_Iio hs_Ioi] at *\n exact lhopital_zero_nhdsLT hff' hgg' hg' hfa hga hdiv\n · simp_rw [hs.nhdsWithin_diff_eq_nhdsNE has hs_Iio hs_Ioi] at *\n exact lhopital_zero_nhdsNE hff' hgg' hg' hfa hga hdiv\n\n/-- **L'Hôpital's rule** for approaching a real, `HasDerivAt` version -/\ntheorem lhopital_zero_nhds (hff' : ∀ᶠ x in 𝓝 a, HasDerivAt f (f' x) x)\n (hgg' : ∀ᶠ x in 𝓝 a, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in 𝓝 a, g' x ≠ 0)\n (hfa : Tendsto f (𝓝 a) (𝓝 0)) (hga : Tendsto g (𝓝 a) (𝓝 0))\n (hdiv : Tendsto (fun x => f' x / g' x) (𝓝 a) l) : Tendsto (fun x => f x / g x) (𝓝[≠] a) l := by sorry\ntheorem lhopital_zero_atTop (hff' : ∀ᶠ x in atTop, HasDerivAt f (f' x) x)\n (hgg' : ∀ᶠ x in atTop, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in atTop, g' x ≠ 0)\n (hftop : Tendsto f atTop (𝓝 0)) (hgtop : Tendsto g atTop (𝓝 0))\n (hdiv : Tendsto (fun x => f' x / g' x) atTop l) : Tendsto (fun x => f x / g x) atTop l := by sorry\ntheorem lhopital_zero_atBot (hff' : ∀ᶠ x in atBot, HasDerivAt f (f' x) x)\n (hgg' : ∀ᶠ x in atBot, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in atBot, g' x ≠ 0)\n (hfbot : Tendsto f atBot (𝓝 0)) (hgbot : Tendsto g atBot (𝓝 0))\n (hdiv : Tendsto (fun x => f' x / g' x) atBot l) : Tendsto (fun x => f x / g x) atBot l := by sorry\nend HasDerivAt\n\nnamespace derivWithin\n\n/-- **L'Hôpital's rule** for approaching a real from within a convex set, `derivWithin` version -/\ntheorem lhopital_zero_nhdsWithin_convex {s : Set ℝ} (hs : Convex ℝ s)\n (hdf : ∀ᶠ x in 𝓝[s \\ {a}] a, DifferentiableWithinAt ℝ f (s \\ {a}) x)\n (hg' : ∀ᶠ x in 𝓝[s \\ {a}] a, derivWithin g (s \\ {a}) x ≠ 0)\n (hfa : Tendsto f (𝓝[s \\ {a}] a) (𝓝 0)) (hga : Tendsto g (𝓝[s \\ {a}] a) (𝓝 0))\n (hdiv : Tendsto (fun x => derivWithin f (s \\ {a}) x / derivWithin g (s \\ {a}) x)\n (𝓝[s \\ {a}] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[s \\ {a}] a) l := by sorry\nend derivWithin\n\nnamespace deriv\n\n/-- **L'Hôpital's rule** for approaching a real from within a convex set, `deriv` version -/\ntheorem lhopital_zero_nhdsWithin_convex {s : Set ℝ} (hs : Convex ℝ s)\n (hdf : ∀ᶠ x in 𝓝[s \\ {a}] a, DifferentiableAt ℝ f x) (hg' : ∀ᶠ x in 𝓝[s \\ {a}] a, deriv g x ≠ 0)\n (hfa : Tendsto f (𝓝[s \\ {a}] a) (𝓝 0)) (hga : Tendsto g (𝓝[s \\ {a}] a) (𝓝 0))\n (hdiv : Tendsto (fun x => deriv f x / deriv g x) (𝓝[s \\ {a}] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[s \\ {a}] a) l := by sorry\ntheorem lhopital_zero_nhdsGT (hdf : ∀ᶠ x in 𝓝[>] a, DifferentiableAt ℝ f x)\n (hg' : ∀ᶠ x in 𝓝[>] a, deriv g x ≠ 0) (hfa : Tendsto f (𝓝[>] a) (𝓝 0))\n (hga : Tendsto g (𝓝[>] a) (𝓝 0))\n (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[>] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[>] a) l := by sorry\ntheorem lhopital_zero_nhdsLT (hdf : ∀ᶠ x in 𝓝[<] a, DifferentiableAt ℝ f x)\n (hg' : ∀ᶠ x in 𝓝[<] a, deriv g x ≠ 0) (hfa : Tendsto f (𝓝[<] a) (𝓝 0))\n (hga : Tendsto g (𝓝[<] a) (𝓝 0))\n (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[<] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[<] a) l := by sorry\ntheorem lhopital_zero_nhdsNE (hdf : ∀ᶠ x in 𝓝[≠] a, DifferentiableAt ℝ f x)\n (hg' : ∀ᶠ x in 𝓝[≠] a, deriv g x ≠ 0) (hfa : Tendsto f (𝓝[≠] a) (𝓝 0))\n (hga : Tendsto g (𝓝[≠] a) (𝓝 0))\n (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[≠] a) l) :\n Tendsto (fun x => f x / g x) (𝓝[≠] a) l := by sorry\ntheorem lhopital_zero_nhds (hdf : ∀ᶠ x in 𝓝 a, DifferentiableAt ℝ f x)\n (hg' : ∀ᶠ x in 𝓝 a, deriv g x ≠ 0) (hfa : Tendsto f (𝓝 a) (𝓝 0)) (hga : Tendsto g (𝓝 a) (𝓝 0))\n (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝 a) l) :\n Tendsto (fun x => f x / g x) (𝓝[≠] a) l := by sorry\ntheorem lhopital_zero_atTop (hdf : ∀ᶠ x : ℝ in atTop, DifferentiableAt ℝ f x)\n (hg' : ∀ᶠ x : ℝ in atTop, deriv g x ≠ 0) (hftop : Tendsto f atTop (𝓝 0))\n (hgtop : Tendsto g atTop (𝓝 0)) (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) atTop l) :\n Tendsto (fun x => f x / g x) atTop l := by sorry\ntheorem lhopital_zero_atBot (hdf : ∀ᶠ x : ℝ in atBot, DifferentiableAt ℝ f x)\n (hg' : ∀ᶠ x : ℝ in atBot, deriv g x ≠ 0) (hfbot : Tendsto f atBot (𝓝 0))\n (hgbot : Tendsto g atBot (𝓝 0)) (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) atBot l) :\n Tendsto (fun x => f x / g x) atBot l := by sorry\nend deriv\n" }, { "theorem_id": 51, "title": "064_l_hôpital_s_rule", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Lra.\nRequire Import Rfunction_classes_def.\nRequire Import Cauchy_lipschitz. \nRequire Import Rextensionality.\nOpen Scope R_scope.\n\nDefinition derivable_on_interval a b (Hab : a < b) f :=\n forall x, open_interval a b x -> derivable_pt f x.\nProof.\nAdmitted.\n\nLemma limit_div_pos_inv : forall f a b, limit_div_neg (fun x => - f x) (open_interval a b) a ->\n limit_div_pos f (open_interval a b) a.\nProof.\nAdmitted.\n\nLemma limit_div_neg_inv : forall f a b, limit_div_pos (fun x => - f x) (open_interval a b) a ->\n limit_div_neg f (open_interval a b) a.\nProof.\nAdmitted.\n\nLemma limit_div_neg_ext : forall f g (I : R -> Prop) a, (forall x, I x -> f x = g x) ->\n limit_div_neg f I a -> limit_div_neg g I a.\nProof.\nAdmitted.\n\nLemma limit_div_pos_ext : forall f g (I : R -> Prop) a, (forall x, I x -> f x = g x) ->\n limit_div_pos f I a -> limit_div_pos g I a.\nProof.\nAdmitted.\n\nLemma limit_div_pos_open : forall a b b' f, \n open_interval a b b' -> limit_div_pos f (open_interval a b') a -> limit_div_pos f (open_interval a b) a.\nProof.\nAdmitted.\n\nLemma limit_div_neg_open : forall a b b' f, \n open_interval a b b' -> limit_div_neg f (open_interval a b') a -> limit_div_neg f (open_interval a b) a.\nProof.\nAdmitted.\n\nLemma limit_div_pos_opp : forall a b g, limit_div_pos g (open_interval a b) b -> \n limit_div_pos (fun x : R => g (- x)) (open_interval (- b) (- a)) (- b).\nProof.\nAdmitted.\n\nLemma limit_div_neg_opp : forall a b g, limit_div_neg g (open_interval a b) b -> \n limit_div_neg (fun x : R => g (- x)) (open_interval (- b) (- a)) (- b).\nProof.\nAdmitted.\n\nLemma limit_div_pos_imp :\nforall (f : R -> R) (D D1 : R -> Prop) (l : R),\n (forall x0 : R, D1 x0 -> D x0) -> limit_div_pos f D l -> limit_div_pos f D1 l.\nProof.\nAdmitted.\n\nLemma limit_div_neg_imp :\nforall (f : R -> R) (D D1 : R -> Prop) (l : R),\n (forall x0 : R, D1 x0 -> D x0) -> limit_div_neg f D l -> limit_div_neg f D1 l.\nProof.\nAdmitted.\n\nLemma limit_div_pos_comp_Ropp : \n forall (g : R -> R) (a b : R),\n limit_div_pos g (open_interval (-a) (-b)) (-a) -> \n limit_div_pos (comp g (fun x => -x)) (open_interval b a) a.\nProof.\nAdmitted.\n\nLemma limit_div_pos_comp_Ropp_l : \n forall (g : R -> R) (a b : R),\n limit_div_pos g (open_interval (-a) (-b)) (-b) -> \n limit_div_pos (comp g (fun x => -x)) (open_interval b a) b.\nProof.\nAdmitted.\n\nLemma limit_div_neg_comp_Ropp : \n forall (g : R -> R) (a b : R),\n limit_div_neg g (open_interval (-a) (-b)) (-a) -> \n limit_div_neg (comp g (fun x => -x)) (open_interval b a) a.\nProof.\nAdmitted.\n\nLemma limit_div_neg_comp_Ropp_l : \n forall (g : R -> R) (a b : R),\n limit_div_neg g (open_interval (-a) (-b)) (-b) -> \n limit_div_neg (comp g (fun x => -x)) (open_interval b a) b.\nProof.\nAdmitted.\n\nEnd Definitions.\n\nLemma derive_pt_comp_Ropp : forall a b f x (Df : forall x, open_interval a b x -> derivable_pt f x) \n(Df' : forall x, open_interval (-b) (-a) x -> derivable_pt (fun x0 => f (- x0)) x) \n (H1 : open_interval (-b) (-a) x) (H2 : open_interval a b (-x)), - derive_pt f (- x) (Df (- x) H2) =\n derive_pt (fun x0 : R => f (- x0)) x (Df' x H1).\nProof.\nAdmitted.\n\nSection FirstGenHopital.\n\nVariables f g : R -> R.\nProof.\nAdmitted.\n\nLemma f_a_zero : f a = 0.\nProof.\nAdmitted.\n\nLemma g_a_zero : g a = 0.\nProof.\nAdmitted.\n\nTheorem Hopital_g0_Lfin_right : limit1_in (fun x => f x / g x) (open_interval a b) L a.\nProof.\nAdmitted.\n\nEnd FirstGenHopital.\n\nSection FirstGenHopital_left.\n\nVariables f g : R -> R.\nProof.\nAdmitted.\n\nEnd FirstGenHopital_left.\n\nSection SndGenHopital.\n\nVariables f g : R -> R.\nVariables a b L : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_pos g (open_interval a b) a).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall eps, eps > 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x a < alp -> \n R_dist (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen)) L < eps)).\n\nLemma open_lemma : forall a b c, a < b -> c > 0 -> open_interval a b (a + Rmin ((b - a) /2) c).\nProof.\nAdmitted.\n\nLemma g_not_zero : exists a', open_interval a b a' /\\ forall x, open_interval a a' x -> g x <> 0.\nProof.\nAdmitted.\n\nLemma MVT_unusable : forall a', open_interval a b a' -> \n forall x y : R,\n open_interval a a' x ->\n open_interval a a' y ->\n x < y ->\n exists c : R,\n exists Hopenc : open_interval a b c,\n (f y - f x) * derive_pt g c (Dg c Hopenc) =\n derive_pt f c (Df c Hopenc) * (g y - g x) /\\ \n x < c < y.\nProof.\nAdmitted.\n\nTheorem Hopital_gpinf_Lfin_right : limit1_in (fun x => f x / g x) (open_interval a b) L a.\nProof.\nAdmitted.\n\nEnd SndGenHopital.\n\nSection SndGenHopital_left.\n\nVariables f g : R -> R.\nVariables a b L : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_pos g (open_interval a b) b).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall eps, eps > 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x b < alp -> \n R_dist (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen)) L < eps)).\n\nTheorem Hopital_gpinf_Lfin_left : limit1_in (fun x => f x / g x) (open_interval a b) L b.\nProof.\nAdmitted.\n\nEnd SndGenHopital_left.\n\nSection SndGenHopitalposneg.\n\nLemma g_not_zero2 : forall g a b, b > a -> limit_div_neg g (open_interval a b) a -> \n exists a', open_interval a b a' /\\ forall x, open_interval a a' x -> g x <> 0.\nProof.\nAdmitted.\n\nLemma limit1_in_open : forall f L a b c, open_interval a b c -> \n limit1_in f (open_interval a c) L a ->\n limit1_in f (open_interval a b) L a.\nProof.\nAdmitted.\n\nLemma limit_div_neg_open1 : forall f a b c, open_interval a b c -> \n limit_div_neg f (open_interval a b) a ->\n limit_div_neg f (open_interval a c) a.\nProof.\nAdmitted.\n\nLemma Hopital_gninf_Lfin_right\n : forall (f g : R -> R) (a b L : R),\n a < b ->\n forall (Df : forall x : R, open_interval a b x -> derivable_pt f x)\n (Dg : forall x : R, open_interval a b x -> derivable_pt g x),\n (forall x : R, a <= x <= b -> continuity_pt f x) ->\n (forall x : R, a <= x <= b -> continuity_pt g x) ->\n limit_div_neg g (open_interval a b) a ->\n (forall (x : R) (Hopen : open_interval a b x),\n derive_pt g x (Dg x Hopen) <> 0) ->\n (forall eps : R,\n eps > 0 ->\n exists alp : R,\n alp > 0 /\\\n (forall (x : R) (Hopen : open_interval a b x),\n R_dist x a < alp ->\n R_dist (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen)) L <\n eps)) ->\n limit1_in (fun x : R => f x / g x) (open_interval a b) L a.\nProof.\nAdmitted.\n\nEnd SndGenHopitalposneg.\n\nSection SndGenHopitalposneg_left.\n\nLemma Hopital_gninf_Lfin_left\n : forall (f g : R -> R) (a b L : R),\n a < b ->\n forall (Df : forall x : R, open_interval a b x -> derivable_pt f x)\n (Dg : forall x : R, open_interval a b x -> derivable_pt g x),\n (forall x : R, a <= x <= b -> continuity_pt f x) ->\n (forall x : R, a <= x <= b -> continuity_pt g x) ->\n limit_div_neg g (open_interval a b) b ->\n (forall (x : R) (Hopen : open_interval a b x),\n derive_pt g x (Dg x Hopen) <> 0) ->\n (forall eps : R,\n eps > 0 ->\n exists alp : R,\n alp > 0 /\\\n (forall (x : R) (Hopen : open_interval a b x),\n R_dist x b < alp ->\n R_dist (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen)) L <\n eps)) ->\n limit1_in (fun x : R => f x / g x) (open_interval a b) L b.\nProof.\nAdmitted.\n\nEnd SndGenHopitalposneg_left.\n\nSection InfiniteLimiteHopital_pos.\n\nVariables f g : R -> R.\nProof.\nAdmitted.\n\nEnd InfiniteLimiteHopital_pos.\n\nSection InfiniteLimiteHopital_pos_left.\n\nVariables f g : R -> R.\nProof.\nAdmitted.\n\nEnd InfiniteLimiteHopital_pos_left.\n\nSection InfiniteLimiteHopital_neg.\n\nVariables f g : R -> R.\nProof.\nAdmitted.\n\nEnd InfiniteLimiteHopital_neg.\n\nSection InfiniteLimiteHopital_neg_left.\n\nVariables f g : R -> R.\nProof.\nAdmitted.\n\nEnd InfiniteLimiteHopital_neg_left.\n\nSection Hopital_infinite_pos.\n\nVariables f g : R -> R.\nVariables a b : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_pos g (open_interval a b) a).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall m, m > 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x a < alp -> \n (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen) > m))).\n\nTheorem Hopital_gpinf_Lpinf_right : limit_div_pos (fun x => f x / g x) (open_interval a b) a.\nProof.\nAdmitted.\n\nEnd Hopital_infinite_pos.\n\nSection Hopital_infinite_pos_left.\n\nVariables f g : R -> R.\nVariables a b : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_pos g (open_interval a b) b).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall m, m > 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x b < alp -> \n (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen) > m))).\n\nTheorem Hopital_gpinf_Lpinf_left : limit_div_pos (fun x => f x / g x) (open_interval a b) b.\nProof.\nAdmitted.\n\nEnd Hopital_infinite_pos_left.\n\nSection Hopital_infinite_neg.\n\nVariables f g : R -> R.\nVariables a b : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_pos g (open_interval a b) a).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall m, m > 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x a < alp -> \n (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen) < -m))).\n\nTheorem Hopital_gpinf_Lninf_right : limit_div_neg (fun x => f x / g x) (open_interval a b) a.\nProof.\nAdmitted.\n \nEnd Hopital_infinite_neg.\n\nSection Hopital_infinite_neg_left.\n\nVariables f g : R -> R.\nVariables a b : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_pos g (open_interval a b) b).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall m, m > 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x b < alp -> \n (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen) < -m))).\n\nTheorem Hopital_gpinf_Lninf_left : limit_div_neg (fun x => f x / g x) (open_interval a b) b.\nProof.\nAdmitted.\n\nEnd Hopital_infinite_neg_left.\n\nSection Useless.\n\nVariables f g : R -> R.\nVariables a b : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_neg g (open_interval a b) a).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall m, m > 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x a < alp -> \n (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen) > m))).\n\nHypothesis (g_not_0 : forall x (Hopen: open_interval a b x), g x <> 0).\n\nTheorem Hopital_infinite_inf_neg_lpos_useless : limit_div_pos (fun x => f x / g x) (open_interval a b) a.\nProof.\nAdmitted.\n\nEnd Useless.\n\nSection Hopital_infinite_neg_pos.\n\nVariables f g : R -> R.\nVariables a b : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_neg g (open_interval a b) a).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall m, m > 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x a < alp -> \n (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen) > m))).\n\nLemma new_bound : exists b', (forall x, open_interval a b' x -> g x <> 0) /\\ open_interval a b b'.\nProof.\nAdmitted.\n\nTheorem Hopital_gninf_Lpinf_right : limit_div_pos (fun x => f x / g x) (open_interval a b) a.\nProof.\nAdmitted.\n\nEnd Hopital_infinite_neg_pos.\n\nSection Hopital_infinite_neg_pos_left.\n\nVariables f g : R -> R.\nVariables a b : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_neg g (open_interval a b) b).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall m, m > 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x b < alp -> \n (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen) > m))).\n\nTheorem Hopital_gninf_Lpinf_left : limit_div_pos (fun x => f x / g x) (open_interval a b) b.\nProof.\nAdmitted.\n\nEnd Hopital_infinite_neg_pos_left.\n\nSection Hopital_infinite_pos_g.\n\nVariables f g : R -> R.\nVariables a b : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_neg g (open_interval a b) a).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall m, m < 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x a < alp -> \n (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen) < m))).\n\nTheorem Hopital_gninf_Lninf_right : limit_div_neg (fun x => f x / g x) (open_interval a b) a.\nProof.\nAdmitted.\n\nEnd Hopital_infinite_pos_g.\n\nSection Hopital_infinite_pos_g_left.\n\nVariables f g : R -> R.\nVariables a b : R.\n\nHypothesis Hab : a < b.\nHypotheses (Df : forall x, open_interval a b x -> derivable_pt f x) \n (Dg : forall x, open_interval a b x -> derivable_pt g x).\nHypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)\n (Cg : forall x, a <= x <= b -> continuity_pt g x).\n\nHypothesis (Zg : limit_div_neg g (open_interval a b) b).\n\nHypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).\nHypothesis (Hlimder : forall m, m < 0 ->\n exists alp, \n alp > 0 /\\\n (forall x (Hopen : open_interval a b x), R_dist x b < alp -> \n (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen) < m))).\n\nTheorem Hopital_gninf_Lninf_left : limit_div_neg (fun x => f x / g x) (open_interval a b) b.\nProof.\nAdmitted.\n\nEnd Hopital_infinite_pos_g_left." }, { "theorem_id": 52, "title": "065_isosceles_triangle_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/geom.ml\";;\n\nlet ISOSCELES_TRIANGLE_THEOREM = `!A B C:real^N. dist(A,C) = dist(B,C) ==> angle(C,A,B) = angle(A,B,C)`;;\n\nlet ISOSCELES_TRIANGLE_CONVERSE = `!A B C:real^N. angle(C,A,B) = angle(A,B,C) /\\ ~(collinear {A,B,C})\n ==> dist(A,C) = dist(B,C)`;;\n\nlet lemma = `!A B C D:real^N.\n between D (A,B)\n ==> (orthogonal (A - B) (C - D) <=>\n angle(A,D,C) = pi / &2 /\\ angle(B,D,C) = pi / &2)`;;\n\nlet ISOSCELES_TRIANGLE_1 = `!A B C D:real^N.\n dist(A,C) = dist(B,C) /\\ D = midpoint(A,B)\n ==> angle(A,C,D) = angle(B,C,D)`;;\n\nlet ISOSCELES_TRIANGLE_2 = `!A B C D:real^N.\n between D (A,B) /\\\n dist(A,C) = dist(B,C) /\\ angle(A,C,D) = angle(B,C,D)\n ==> orthogonal (A - B) (C - D)`;;\n\nlet ISOSCELES_TRIANGLE_3 = `!A B C D:real^N.\n between D (A,B) /\\\n dist(A,C) = dist(B,C) /\\ orthogonal (A - B) (C - D)\n ==> D = midpoint(A,B)`;;\n\nlet ISOSCELES_TRIANGLE_4 = `!A B C D:real^N.\n D = midpoint(A,B) /\\ orthogonal (A - B) (C - D)\n ==> dist(A,C) = dist(B,C)`;;\n\nlet ISOSCELES_TRIANGLE_5 = `!A B C D:real^N.\n ~collinear{D,C,A} /\\ between D (A,B) /\\\n angle(A,C,D) = angle(B,C,D) /\\ orthogonal (A - B) (C - D)\n ==> dist(A,C) = dist(B,C)`;;\n\nlet ISOSCELES_TRIANGLE_6 = `!A B C D:real^N.\n ~collinear{D,C,A} /\\ D = midpoint(A,B) /\\ angle(A,C,D) = angle(B,C,D)\n ==> dist(A,C) = dist(B,C)`;;" }, { "theorem_id": 52, "title": "065_isosceles_triangle_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Basic Properties of Triangles\\\ntheory Triangle\nimports\n Angles\nbegin\n\ntext \\\n We prove a number of basic geometric properties of triangles. All theorems hold\n in any real inner product space.\n\\\nsubsection \\Thales' theorem\\\n\ntheorem thales:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"dist B (midpoint A C) = dist A C / 2\"\n shows \"orthogonal (A - B) (C - B)\"\n by sorry\n\nsubsection \\Sine and cosine laws\\\n\ntext \\\n The proof of the Law of Cosines follows trivially from the definition of the angle,\n the definition of the norm in vector spaces with an inner product and the bilinearity\n of the inner product.\n\\\n\nlemma cosine_law_vector:\n \"norm (u - v) ^ 2 = norm u ^ 2 + norm v ^ 2 - 2 * norm u * norm v * cos (vangle u v)\"\n by sorry\n\nlemma cosine_law_triangle:\n \"dist b c ^ 2 = dist a b ^ 2 + dist a c ^ 2 - 2 * dist a b * dist a c * cos (angle b a c)\"\n by sorry\n\ntext \\\n According to our definition, angles are always between $0$ and $\\pi$ and therefore,\n the sign of an angle is always non-negative. We can therefore look at\n $\\sin(\\alpha)^2$, which we can express in terms of $\\cos(\\alpha)$ using the\n identity $\\sin(\\alpha)^2 + \\cos(\\alpha)^2 = 1$. The remaining proof is then a\n trivial consequence of the definitions.\n\\\nlemma sine_law_triangle:\n \"sin (angle a b c) * dist b c = sin (angle b a c) * dist a c\" (is \"?A = ?B\")\n by sorry\n\ntext \\\n The following forms of the Law of Sines/Cosines are more convenient for eliminating\n sines/cosines from a goal completely.\n\\\n\nlemma cosine_law_triangle':\n \"2 * dist a b * dist a c * cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2)\"\n by sorry\n\nlemma cosine_law_triangle'':\n \"cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2) / (2 * dist a b * dist a c)\"\n by sorry\n\nlemma sine_law_triangle':\n \"b \\ c \\ sin (angle a b c) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nlemma sine_law_triangle'':\n \"b \\ c \\ sin (angle c b a) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nsubsection \\Sum of angles\\\n\ncontext\nbegin\n\nprivate lemma gather_squares: \"a * (a * b) = a^2 * (b :: real)\"\n by (simp_all add: power2_eq_square)\n\nprivate lemma eval_power: \"x ^ numeral n = x * x ^ pred_numeral n\"\n by (subst numeral_eq_Suc, subst power_Suc) simp\n\ntext \\\n The proof that the sum of the angles in a triangle is $\\pi$ is somewhat more\n involved. Following the HOL Light proof by John Harrison, we first prove\n that $\\cos(\\alpha + \\beta + \\gamma) = -1$ and $\\alpha + \\beta + \\gamma \\in [0;3\\pi)$,\n which then implies the theorem.\n\n The main work is proving $\\cos(\\alpha + \\beta + \\gamma)$. This is done using the\n addition theorems for the sine and cosine, then using the Laws of Sines to eliminate\n all $\\sin$ terms save $\\sin(\\gamma)^2$, which only appears squared in the remaining goal.\n We then use $\\sin(\\gamma)^2 = 1 - \\cos(\\gamma)^2$ to eliminate this term and apply\n the law of cosines to eliminate this term as well.\n\n The remaining goal is a non-linear equation containing only the length of the sides\n of the triangle. It can be shown by simple algebraic rewriting.\n\\\nlemma angle_sum_triangle:\n assumes \"a \\ b \\ b \\ c \\ a \\ c\"\n shows \"angle c a b + angle a b c + angle b c a = pi\"\n by sorry\n\nend\n\nsubsection \\Congruence Theorems\\\n\ntext \\\n If two triangles agree on two angles at a non-degenerate side, the third angle\n must also be equal.\n\\\nlemma similar_triangle_aa:\n assumes \"b1 \\ c1\" \"b2 \\ c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n shows \"angle b1 a1 c1 = angle b2 a2 c2\"\n by sorry\n\ntext \\\n A triangle is defined by its three angles and the lengths of three sides up to congruence.\n Two triangles are congruent if they have their angles are the same and their sides have\n the same length.\n\\\n\nlocale congruent_triangle =\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes sides': \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n and angles': \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\"\n \"angle a1 c1 b1 = angle a2 c2 b2\"\nbegin\n\nlemma sides:\n \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n \"dist b1 a1 = dist a2 b2\" \"dist c1 a1 = dist a2 c2\" \"dist c1 b1 = dist b2 c2\"\n \"dist a1 b1 = dist b2 a2\" \"dist a1 c1 = dist c2 a2\" \"dist b1 c1 = dist c2 b2\"\n \"dist b1 a1 = dist b2 a2\" \"dist c1 a1 = dist c2 a2\" \"dist c1 b1 = dist c2 b2\"\n by sorry\n\nlemma angles:\n \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\" \"angle a1 c1 b1 = angle a2 c2 b2\"\n \"angle c1 a1 b1 = angle b2 a2 c2\" \"angle c1 b1 a1 = angle a2 b2 c2\" \"angle b1 c1 a1 = angle a2 c2 b2\"\n \"angle b1 a1 c1 = angle c2 a2 b2\" \"angle a1 b1 c1 = angle c2 b2 a2\" \"angle a1 c1 b1 = angle b2 c2 a2\"\n \"angle c1 a1 b1 = angle c2 a2 b2\" \"angle c1 b1 a1 = angle c2 b2 a2\" \"angle b1 c1 a1 = angle b2 c2 a2\"\n by sorry\n\nend\n\nlemmas congruent_triangleD = congruent_triangle.sides congruent_triangle.angles\n\ntext \\\n Given two triangles that agree on a subset of its side lengths and angles that are\n sufficient to define a triangle uniquely up to congruence, one can conclude that they\n must also agree on all remaining quantities, i.e. that they are congruent.\n\n The following four congruence theorems state what constitutes such a uniquely-defining\n subset of quantities. Each theorem states in its name which quantities are required and\n in which order (clockwise or counter-clockwise): an ``s'' stands for a side,\n an ``a'' stands for an angle.\n\n The lemma ``congruent-triangleI-sas, for example, requires that two adjacent sides and the\n angle inbetween are the same in both triangles.\n\\\n\nlemma congruent_triangleI_sss:\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"dist a1 c1 = dist a2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sss = congruent_triangleD[OF congruent_triangleI_sss]\n\nlemma congruent_triangleI_sas:\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sas = congruent_triangleD[OF congruent_triangleI_sas]\n\nlemma congruent_triangleI_aas:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"\\collinear {a1,b1,c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_aas = congruent_triangleD[OF congruent_triangleI_aas]\n\nlemma congruent_triangleI_asa:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"angle b1 a1 c1 = angle b2 a2 c2\"\n assumes \"\\collinear {a1, b1, c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_asa = congruent_triangleD[OF congruent_triangleI_asa]\n\nsubsection \\Isosceles Triangle Theorem\\\n\ntext \\\n We now prove the Isosceles Triangle Theorem: in a triangle where two sides have\n the same length, the two angles that are adjacent to only one of the two sides\n must be equal.\n\\\nlemma isosceles_triangle:\n assumes \"dist a c = dist b c\"\n shows \"angle b a c = angle a b c\"\n by sorry\n\ntext \\\n For the non-degenerate case (i.e. the three points are not collinear), We also\n prove the converse.\n\\\nlemma isosceles_triangle_converse:\n assumes \"angle a b c = angle b a c\" \"\\collinear {a,b,c}\"\n shows \"dist a c = dist b c\"\n by sorry\n\nsubsection\\Contributions by Lukas Bulwahn\\\n \nlemma Pythagoras:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"orthogonal (A - C) (B - C)\"\n shows \"(dist B C) ^ 2 + (dist C A) ^ 2 = (dist A B) ^ 2\"\n by sorry\n\nlemma isosceles_triangle_orthogonal_on_midpoint:\n fixes A B C :: \"'a :: euclidean_space\"\n assumes \"dist C A = dist C B\"\n shows \"orthogonal (C - midpoint A B) (A - midpoint A B)\"\n by sorry\n\nend" }, { "theorem_id": 52, "title": "065_isosceles_triangle_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Manuel Candales\n-/\nmodule\n\npublic import Mathlib.Analysis.Normed.Affine.AddTorsor\npublic import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine\npublic import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine\npublic import Mathlib.Tactic.IntervalCases\n\n/-!\n# Triangles\n\nThis file proves basic geometrical results about distances and angles\nin (possibly degenerate) triangles in real inner product spaces and\nEuclidean affine spaces. More specialized results, and results\ndeveloped for simplices in general rather than just for triangles, are\nin separate files. Definitions and results that make sense in more\ngeneral affine spaces rather than just in the Euclidean case go under\n`LinearAlgebra.AffineSpace`.\n\n## Implementation notes\n\nResults in this file are generally given in a form with only those\nnon-degeneracy conditions needed for the particular result, rather\nthan requiring affine independence of the points of a triangle\nunnecessarily.\n\n## References\n\n* https://en.wikipedia.org/wiki/Law_of_cosines\n* https://en.wikipedia.org/wiki/Pons_asinorum\n* https://en.wikipedia.org/wiki/Sum_of_angles_of_a_triangle\n* https://en.wikipedia.org/wiki/Law_of_sines\n\n-/\n\npublic section\n\nnoncomputable section\n\nopen scoped CharZero Real RealInnerProductSpace\n\nnamespace InnerProductGeometry\n\n/-!\n### Geometrical results on triangles in real inner product spaces\n\nThis section develops some results on (possibly degenerate) triangles\nin real inner product spaces, where those definitions and results can\nmost conveniently be developed in terms of vectors and then used to\ndeduce corresponding results for Euclidean affine spaces.\n-/\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]\n\n/-- **Law of cosines** (cosine rule), vector angle form. -/\ntheorem norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle (x y : V) :\n ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ - 2 * ‖x‖ * ‖y‖ * Real.cos (angle x y) := by sorry\ntheorem sin_angle_mul_norm_eq_sin_angle_mul_norm (x y : V) :\n Real.sin (angle x y) * ‖x‖ = Real.sin (angle y (x - y)) * ‖x - y‖ := by sorry\ntheorem sin_angle_div_norm_eq_sin_angle_div_norm (x y : V) (hx : x ≠ 0) (hxy : x - y ≠ 0) :\n Real.sin (angle x y) / ‖x - y‖ = Real.sin (angle y (x - y)) / ‖x‖ := by sorry\ntheorem angle_sub_eq_angle_sub_rev_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) :\n angle x (x - y) = angle y (y - x) := by sorry\ntheorem norm_eq_of_angle_sub_eq_angle_sub_rev_of_angle_ne_pi {x y : V}\n (h : angle x (x - y) = angle y (y - x)) (hpi : angle x y ≠ π) : ‖x‖ = ‖y‖ := by sorry\ntheorem angle_eq_angle_add_add_angle_add (x : V) {y : V} (hy : y ≠ 0) :\n angle x y = angle x (x + y) + angle y (x + y) := by sorry\ntheorem angle_add_angle_sub_add_angle_sub_eq_pi (x : V) {y : V} (hy : y ≠ 0) :\n angle x y + angle x (x - y) + angle y (y - x) = π := by sorry\nend InnerProductGeometry\n\nnamespace Orientation\n\nopen Module InnerProductGeometry\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [Fact (finrank ℝ V = 2)]\nvariable (o : Orientation ℝ V (Fin 2))\n\n/-- **Converse of pons asinorum**, oriented vector angle form (given equality of angles mod `π`). -/\ntheorem norm_eq_of_two_zsmul_oangle_sub_eq {x y : V}\n (h : (2 : ℤ) • o.oangle x (x - y) = (2 : ℤ) • o.oangle (y - x) y) (h0 : o.oangle x y ≠ 0)\n (hpi : o.oangle x y ≠ π) : ‖x‖ = ‖y‖ := by sorry\nend Orientation\n\nnamespace EuclideanGeometry\n\n/-!\n### Geometrical results on triangles in Euclidean affine spaces\n\nThis section develops some geometrical definitions and results on\n(possibly degenerate) triangles in Euclidean affine spaces.\n-/\n\nopen InnerProductGeometry\nopen scoped EuclideanGeometry\n\nvariable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]\n [NormedAddTorsor V P]\n\n/-- **Law of cosines** (cosine rule), angle-at-point form. -/\ntheorem dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle (p₁ p₂ p₃ : P) :\n dist p₁ p₃ * dist p₁ p₃ = dist p₁ p₂ * dist p₁ p₂ + dist p₃ p₂ * dist p₃ p₂ -\n 2 * dist p₁ p₂ * dist p₃ p₂ * Real.cos (∠ p₁ p₂ p₃) := by sorry\ntheorem sin_angle_mul_dist_eq_sin_angle_mul_dist (p₁ p₂ p₃ : P) :\n Real.sin (∠ p₁ p₂ p₃) * dist p₂ p₃ = Real.sin (∠ p₃ p₁ p₂) * dist p₃ p₁ := by sorry\ntheorem sin_angle_div_dist_eq_sin_angle_div_dist {p₁ p₂ p₃ : P} (h23 : p₂ ≠ p₃) (h31 : p₃ ≠ p₁) :\n Real.sin (∠ p₁ p₂ p₃) / dist p₃ p₁ = Real.sin (∠ p₃ p₁ p₂) / dist p₂ p₃ := by sorry\ntheorem dist_eq_dist_mul_sin_angle_div_sin_angle {p₁ p₂ p₃ : P}\n (h : ¬Collinear ℝ ({p₁, p₂, p₃} : Set P)) :\n dist p₁ p₂ = dist p₃ p₁ * Real.sin (∠ p₂ p₃ p₁) / Real.sin (∠ p₁ p₂ p₃) := by sorry\ntheorem angle_eq_angle_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dist p₁ p₃) :\n ∠ p₁ p₂ p₃ = ∠ p₁ p₃ p₂ := by sorry\ntheorem dist_eq_of_angle_eq_angle_of_angle_ne_pi {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = ∠ p₁ p₃ p₂)\n (hpi : ∠ p₂ p₁ p₃ ≠ π) : dist p₁ p₂ = dist p₁ p₃ := by sorry\ntheorem dist_eq_of_two_zsmul_oangle_eq [Module.Oriented ℝ V (Fin 2)]\n [Fact (Module.finrank ℝ V = 2)] {p₁ p₂ p₃ : P} (h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₂ p₃ p₁)\n (h0 : ∡ p₃ p₁ p₂ ≠ 0) (hpi : ∡ p₃ p₁ p₂ ≠ π) : dist p₁ p₂ = dist p₁ p₃ := by sorry\ntheorem angle_add_angle_add_angle_eq_pi {p₁ p₂ : P} (p₃ : P) (h : p₂ ≠ p₁) :\n ∠ p₁ p₂ p₃ + ∠ p₂ p₃ p₁ + ∠ p₃ p₁ p₂ = π := by sorry\ntheorem exterior_angle_eq_angle_add_angle {p₁ p₂ p₃ : P} (p : P) (h : Sbtw ℝ p p₁ p₂) :\n ∠ p₃ p₁ p = ∠ p₁ p₃ p₂ + ∠ p₃ p₂ p₁ := by sorry\ntheorem oangle_add_oangle_add_oangle_eq_pi [Module.Oriented ℝ V (Fin 2)]\n [Fact (Module.finrank ℝ V = 2)] {p₁ p₂ p₃ : P} (h21 : p₂ ≠ p₁) (h32 : p₃ ≠ p₂)\n (h13 : p₁ ≠ p₃) : ∡ p₁ p₂ p₃ + ∡ p₂ p₃ p₁ + ∡ p₃ p₁ p₂ = π := by sorry\nlemma angle_add_of_ne_of_ne {a b c p : P} (hb : a ≠ b) (hc : a ≠ c) (hp : Wbtw ℝ b p c) :\n ∠ b a p + ∠ p a c = ∠ b a c := by sorry\ntheorem dist_sq_mul_dist_add_dist_sq_mul_dist (a b c p : P) (h : ∠ b p c = π) :\n dist a b ^ 2 * dist c p + dist a c ^ 2 * dist b p =\n dist b c * (dist a p ^ 2 + dist b p * dist c p) := by sorry\ntheorem dist_sq_add_dist_sq_eq_two_mul_dist_midpoint_sq_add_half_dist_sq (a b c : P) :\n dist a b ^ 2 + dist a c ^ 2 = 2 * (dist a (midpoint ℝ b c) ^ 2 + (dist b c / 2) ^ 2) := by sorry\ntheorem dist_mul_of_eq_angle_of_dist_mul (a b c a' b' c' : P) (r : ℝ) (h : ∠ a' b' c' = ∠ a b c)\n (hab : dist a' b' = r * dist a b) (hcb : dist c' b' = r * dist c b) :\n dist a' c' = r * dist a c := by sorry\ntheorem dist_lt_of_angle_lt {a b c : P} (h : ¬Collinear ℝ ({a, b, c} : Set P)) :\n ∠ a c b < ∠ a b c → dist a b < dist a c := by sorry\ntheorem angle_lt_iff_dist_lt {a b c : P} (h : ¬Collinear ℝ ({a, b, c} : Set P)) :\n ∠ a c b < ∠ a b c ↔ dist a b < dist a c := by sorry\ntheorem angle_le_iff_dist_le {a b c : P} (h : ¬Collinear ℝ ({a, b, c} : Set P)) :\n ∠ a c b ≤ ∠ a b c ↔ dist a b ≤ dist a c := by sorry\nlemma pi_div_three_le_angle_of_le_of_le {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₂ p₃ p₁ ≤ ∠ p₁ p₂ p₃)\n (h₃₁₂ : ∠ p₃ p₁ p₂ ≤ ∠ p₁ p₂ p₃) : π / 3 ≤ ∠ p₁ p₂ p₃ := by sorry\nlemma pi_div_three_lt_angle_of_le_of_le_of_ne {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₂ p₃ p₁ ≤ ∠ p₁ p₂ p₃)\n (h₃₁₂ : ∠ p₃ p₁ p₂ ≤ ∠ p₁ p₂ p₃)\n (hne : ∠ p₁ p₂ p₃ ≠ ∠ p₂ p₃ p₁ ∨ ∠ p₁ p₂ p₃ ≠ ∠ p₃ p₁ p₂ ∨ ∠ p₂ p₃ p₁ ≠ ∠ p₃ p₁ p₂) :\n π / 3 < ∠ p₁ p₂ p₃ := by sorry\nlemma angle_le_pi_div_three_of_le_of_le {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₁ p₂ p₃ ≤ ∠ p₂ p₃ p₁)\n (h₃₁₂ : ∠ p₁ p₂ p₃ ≤ ∠ p₃ p₁ p₂) (hnd : p₁ ≠ p₂ ∨ p₁ ≠ p₃ ∨ p₂ ≠ p₃) :\n ∠ p₁ p₂ p₃ ≤ π / 3 := by sorry\nlemma angle_lt_pi_div_three_of_le_of_le_of_ne {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₁ p₂ p₃ ≤ ∠ p₂ p₃ p₁)\n (h₃₁₂ : ∠ p₁ p₂ p₃ ≤ ∠ p₃ p₁ p₂)\n (hne : ∠ p₁ p₂ p₃ ≠ ∠ p₂ p₃ p₁ ∨ ∠ p₁ p₂ p₃ ≠ ∠ p₃ p₁ p₂ ∨ ∠ p₂ p₃ p₁ ≠ ∠ p₃ p₁ p₂) :\n ∠ p₁ p₂ p₃ < π / 3 := by sorry\nend EuclideanGeometry\n" }, { "theorem_id": 52, "title": "065_isosceles_triangle_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From HighSchoolGeometry Require Export mediatrice.\nSet Implicit Arguments.\nUnset Strict Implicit.\n \nDefinition isocele (A B C : PO) : Prop := distance A B = distance A C.\n \nLemma isocele_permute : forall A B C : PO, isocele A B C -> isocele A C B.\nProof.\nAdmitted.\n#[export] Hint Immediate isocele_permute: geo.\n \nLemma isocele_mediatrice :\n forall A B C : PO, isocele A B C -> mediatrice B C A.\nProof.\nAdmitted.\n \nLemma mediatrice_isocele :\n forall A B C : PO, mediatrice B C A -> isocele A B C.\nProof.\nAdmitted.\n \nLemma mediane_hauteur_isocele :\n forall A B C I : PO,\n I = milieu B C -> orthogonal (vec B C) (vec I A) -> isocele A B C.\nProof.\nAdmitted.\n \nLemma mediane_isocele_hauteur :\n forall A B C I : PO,\n I = milieu B C -> isocele A B C -> orthogonal (vec I A) (vec B C).\nProof.\nAdmitted.\n \nLemma hauteur_isocele_mediane :\n forall A B C I : PO,\n B <> C ->\n orthogonal (vec B C) (vec I A) ->\n isocele A B C -> alignes B C I -> I = milieu B C.\nProof.\nAdmitted.\n \nLemma isocele_mediane_bissectrice :\n forall A B C I : PO,\n A <> I ->\n B <> C ->\n I = milieu B C ->\n isocele A B C -> cons_AV (vec A B) (vec A I) = cons_AV (vec A I) (vec A C).\nProof.\nAdmitted.\n \nLemma isocele_angles_base :\n forall A B C : PO,\n A <> B ->\n A <> C ->\n B <> C ->\n isocele A B C -> cons_AV (vec B C) (vec B A) = cons_AV (vec C A) (vec C B).\nProof.\nAdmitted.\n \nLemma diametre_rectangle :\n forall A B C C' : PO,\n A <> B ->\n C' = milieu A B ->\n distance C' C = distance C' A -> orthogonal (vec C A) (vec C B).\nProof.\nAdmitted." }, { "theorem_id": 53, "title": "066_sum_of_a_geometric_series", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "let dest_neg_imp tm =\n try dest_imp tm with Failure _ ->\n try (dest_neg tm,mk_const(\"F\",[]))\n with Failure _ -> failwith \"dest_neg_imp\";;\n\nlet (CONV_OF_RCONV: conv -> conv) =\n let rec get_bv tm =\n if is_abs tm then bndvar tm\n else if is_comb tm then try get_bv (rand tm)\n with Failure _ -> get_bv (rator tm)\n else failwith \"\" in\n fun conv tm ->\n let v = get_bv tm in\n let th1 = conv tm in\n let th2 = ONCE_DEPTH_CONV (GEN_ALPHA_CONV v) (rhs(concl th1)) in\n TRANS th1 th2;;\n\nlet (CONV_OF_THM: thm -> conv) =\n CONV_OF_RCONV o REWR_CONV;;\n\nlet (X_FUN_EQ_CONV:term->conv) =\n fun v -> (REWR_CONV FUN_EQ_THM) THENC GEN_ALPHA_CONV v;;\n\nlet (FUN_EQ_CONV:conv) =\n fun tm ->\n let vars = frees tm in\n let op,[ty1;ty2] = dest_type(type_of (lhs tm)) in\n if op = \"fun\"\n then let varnm =\n if (is_vartype ty1) then \"x\" else\n hd(explode(fst(dest_type ty1))) in\n let x = variant vars (mk_var(varnm,ty1)) in\n X_FUN_EQ_CONV x tm\n else failwith \"FUN_EQ_CONV\";;\n\nlet (SINGLE_DEPTH_CONV:conv->conv) =\n let rec SINGLE_DEPTH_CONV conv tm =\n try conv tm with Failure _ ->\n (SUB_CONV (SINGLE_DEPTH_CONV conv) THENC (TRY_CONV conv)) tm in\n SINGLE_DEPTH_CONV;;\n\nlet (OLD_SKOLEM_CONV:conv) =\n SINGLE_DEPTH_CONV (REWR_CONV SKOLEM_THM);;\n\nlet (X_SKOLEM_CONV:term->conv) =\n fun v -> OLD_SKOLEM_CONV THENC GEN_ALPHA_CONV v;;\n\nlet EXISTS_UNIQUE_CONV tm =\n let v = bndvar(rand tm) in\n let th1 = REWR_CONV EXISTS_UNIQUE_THM tm in\n let tm1 = rhs(concl th1) in\n let vars = frees tm1 in\n let v = variant vars v in\n let v' = variant (v::vars) v in\n let th2 =\n (LAND_CONV(GEN_ALPHA_CONV v) THENC\n RAND_CONV(BINDER_CONV(GEN_ALPHA_CONV v') THENC\n GEN_ALPHA_CONV v)) tm1 in\n TRANS th1 th2;;\n\nlet NOT_FORALL_CONV = CONV_OF_THM NOT_FORALL_THM;;\n\nlet NOT_EXISTS_CONV = CONV_OF_THM NOT_EXISTS_THM;;\n\nlet RIGHT_IMP_EXISTS_CONV = CONV_OF_THM RIGHT_IMP_EXISTS_THM;;\n\nlet FORALL_IMP_CONV = CONV_OF_RCONV\n (REWR_CONV TRIV_FORALL_IMP_THM ORELSEC\n REWR_CONV RIGHT_FORALL_IMP_THM ORELSEC\n REWR_CONV LEFT_FORALL_IMP_THM);;\n\nlet EXISTS_AND_CONV = CONV_OF_RCONV\n (REWR_CONV TRIV_EXISTS_AND_THM ORELSEC\n REWR_CONV LEFT_EXISTS_AND_THM ORELSEC\n REWR_CONV RIGHT_EXISTS_AND_THM);;\n\nlet LEFT_IMP_EXISTS_CONV = CONV_OF_THM LEFT_IMP_EXISTS_THM;;\n\nlet LEFT_AND_EXISTS_CONV tm =\n let v = bndvar(rand(rand(rator tm))) in\n (REWR_CONV LEFT_AND_EXISTS_THM THENC TRY_CONV (GEN_ALPHA_CONV v)) tm;;\n\nlet RIGHT_AND_EXISTS_CONV =\n CONV_OF_THM RIGHT_AND_EXISTS_THM;;\n\nlet AND_FORALL_CONV = CONV_OF_THM AND_FORALL_THM;;\n\nlet F_IMP = TAUT `!t. ~t ==> t ==> F`;;\n\nlet LEFT_AND_OVER_OR = TAUT\n `!t1 t2 t3. t1 /\\ (t2 \\/ t3) <=> t1 /\\ t2 \\/ t1 /\\ t3`;;\n\nlet RIGHT_AND_OVER_OR = TAUT\n `!t1 t2 t3. (t2 \\/ t3) /\\ t1 <=> t2 /\\ t1 \\/ t3 /\\ t1`;;\n\nlet INST_TY_TERM(substl,insttyl) th = INST substl (INST_TYPE insttyl th);;\n\nlet NOT_MP thi th =\n try MP thi th with Failure _ ->\n try let t = dest_neg (concl thi) in\n MP(MP (SPEC t F_IMP) thi) th\n with Failure _ -> failwith \"NOT_MP\";;\n\nlet MK_ABS qth =\n try let ov = bndvar(rand(concl qth)) in\n let bv,rth = SPEC_VAR qth in\n let sth = ABS bv rth in\n let cnv = ALPHA_CONV ov in\n CONV_RULE(BINOP_CONV cnv) sth\n with Failure _ -> failwith \"MK_ABS\";;\n\nlet HALF_MK_ABS th =\n try let th1 = MK_ABS th in\n CONV_RULE(LAND_CONV ETA_CONV) th1\n with Failure _ -> failwith \"HALF_MK_ABS\";;\n\nlet SUBST thl pat th =\n let eqs,vs = unzip thl in\n let gvs = map (genvar o type_of) vs in\n let gpat = subst (zip gvs vs) pat in\n let ls,rs = unzip (map (dest_eq o concl) eqs) in\n let ths = map (ASSUME o mk_eq) (zip gvs rs) in\n let th1 = ASSUME gpat in\n let th2 = SUBS ths th1 in\n let th3 = itlist DISCH (map concl ths) (DISCH gpat th2) in\n let th4 = INST (zip ls gvs) th3 in\n MP (rev_itlist (C MP) eqs th4) th;;\n\nprioritize_num();;\n\nlet LESS_EQUAL_ANTISYM = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL LE_ANTISYM)));;\nlet NOT_LESS_0 = GEN_ALL(EQF_ELIM(SPEC_ALL(CONJUNCT1 LT)));;\nlet LESS_LEMMA1 = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL(CONJUNCT2 LT))));;\nlet LESS_SUC_REFL = ARITH_RULE `!n. n < SUC n`;;\nlet LESS_EQ_SUC_REFL = ARITH_RULE `!n. n <= SUC n`;;\nlet LESS_EQUAL_ADD = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL LE_EXISTS)));;\nlet LESS_EQ_IMP_LESS_SUC = GEN_ALL(snd(EQ_IMP_RULE(SPEC_ALL LT_SUC_LE)));;\nlet LESS_MONO_ADD = GEN_ALL(snd(EQ_IMP_RULE(SPEC_ALL LT_ADD_RCANCEL)));;\nlet LESS_SUC = ARITH_RULE `!m n. m < n ==> m < (SUC n)`;;\nlet LESS_ADD_1 = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL\n (REWRITE_RULE[ADD1] LT_EXISTS))));;\nlet SUC_SUB1 = ARITH_RULE `!m. SUC m - 1 = m`;;\nlet LESS_ADD_SUC = ARITH_RULE `!m n. m < m + SUC n`;;\nlet OR_LESS = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL LE_SUC_LT)));;\nlet NOT_SUC_LESS_EQ = ARITH_RULE `!n m. ~(SUC n <= m) <=> m <= n`;;\nlet LESS_LESS_CASES = ARITH_RULE `!m n. (m = n) \\/ m < n \\/ n < m`;;\nlet SUB_SUB = `!b c. c <= b ==> (!a. a - (b - c) = (a + c) - b)`;;\nlet LESS_CASES_IMP = ARITH_RULE `!m n. ~(m < n) /\\ ~(m = n) ==> n < m`;;\nlet SUB_LESS_EQ = ARITH_RULE `!n m. (n - m) <= n`;;\nlet SUB_EQ_EQ_0 = ARITH_RULE `!m n. (m - n = m) <=> (m = 0) \\/ (n = 0)`;;\nlet SUB_LEFT_LESS_EQ =\n ARITH_RULE `!m n p. m <= (n - p) <=> (m + p) <= n \\/ m <= 0`;;\nlet SUB_LEFT_GREATER_EQ = ARITH_RULE `!m n p. m >= (n - p) <=> (m + p) >= n`;;\nlet LESS_0_CASES = ARITH_RULE `!m. (0 = m) \\/ 0 < m`;;\nlet LESS_OR = ARITH_RULE `!m n. m < n ==> (SUC m) <= n`;;\nlet SUB_OLD = `(!m. 0 - m = 0) /\\\n (!m n. (SUC m) - n = (if m < n then 0 else SUC(m - n)))`;;\n\nlet SYM_CANON_CONV sym fn =\n REWR_CONV sym o\n check (not o fn o ((snd o dest_comb) F_F I) o dest_comb);;\n\nlet (IMP_SUBST_TAC:thm_tactic) =\n fun th (asl,w) ->\n let tms = find_terms (can (PART_MATCH (lhs o snd o dest_imp) th)) w in\n let tm1 = hd (sort free_in tms) in\n let th1 = PART_MATCH (lhs o snd o dest_imp) th tm1 in\n let (a,(l,r)) = (I F_F dest_eq) (dest_imp (concl th1)) in\n let gv = genvar (type_of l) in\n let pat = subst[gv,l] w in\n null_meta,\n [(asl,a); (asl,subst[(r,gv)] pat)],\n fun i [t1;t2] -> SUBST[(SYM(MP th1 t1),gv)] pat t2;;\n\nlet EXT_CONV = SYM o uncurry X_FUN_EQ_CONV o\n (I F_F (mk_eq o (rator F_F rator) o dest_eq)) o dest_forall;;\n\nlet EQUAL_TAC = REPEAT(FIRST [AP_TERM_TAC; AP_THM_TAC; ABS_TAC]);;\n\nlet X_BETA_CONV v tm =\n SYM(BETA_CONV(mk_comb(mk_abs(v,tm),v)));;\n\nlet EXACT_CONV =\n ONCE_DEPTH_CONV o FIRST_CONV o\n map (fun t -> K t o check((=)(lhs(concl t))));;\n\nlet HABS_CONV tm =\n let v,bod = dest_abs tm in\n let hop,pl = strip_comb bod in\n let eql = rev(map (X_BETA_CONV v) pl) in\n ABS v (itlist (C(curry MK_COMB)) eql (REFL hop));;\n\nlet EXPAND_TAC s = FIRST_ASSUM(SUBST1_TAC o SYM o\n check((=) s o fst o dest_var o rhs o concl)) THEN BETA_TAC;;\n\nprioritize_real();;\n\nlet real_le = `!x y. x <= y <=> ~(y < x)`;;\n\nlet REAL_10 = REAL_ARITH `~(&1 = &0)`;;\n\nlet REAL_LDISTRIB = REAL_ADD_LDISTRIB;;\n\nlet REAL_LT_IADD = REAL_ARITH `!x y z. y < z ==> x + y < x + z`;;\n\nlet REAL_MUL_RID = `!x. x * &1 = x`;;\n\nlet REAL_MUL_RINV = `!x. ~(x = &0) ==> (x * (inv x) = &1)`;;\n\nlet REAL_RDISTRIB = `!x y z. (x + y) * z = (x * z) + (y * z)`;;\n\nlet REAL_EQ_LADD = `!x y z. (x + y = x + z) <=> (y = z)`;;\n\nlet REAL_EQ_RADD = `!x y z. (x + z = y + z) <=> (x = y)`;;\n\nlet REAL_ADD_LID_UNIQ = `!x y. (x + y = y) <=> (x = &0)`;;\n\nlet REAL_ADD_RID_UNIQ = `!x y. (x + y = x) <=> (y = &0)`;;\n\nlet REAL_LNEG_UNIQ = `!x y. (x + y = &0) <=> (x = --y)`;;\n\nlet REAL_RNEG_UNIQ = `!x y. (x + y = &0) <=> (y = --x)`;;\n\nlet REAL_NEG_ADD = `!x y. --(x + y) = (--x) + (--y)`;;\n\nlet REAL_MUL_LZERO = `!x. &0 * x = &0`;;\n\nlet REAL_MUL_RZERO = `!x. x * &0 = &0`;;\n\nlet REAL_NEG_LMUL = `!x y. --(x * y) = (--x) * y`;;\n\nlet REAL_NEG_RMUL = `!x y. --(x * y) = x * (--y)`;;\n\nlet REAL_NEG_NEG = `!x. --(--x) = x`;;\n\nlet REAL_NEG_MUL2 = `!x y. (--x) * (--y) = x * y`;;\n\nlet REAL_LT_LADD = `!x y z. (x + y) < (x + z) <=> y < z`;;\n\nlet REAL_LT_RADD = `!x y z. (x + z) < (y + z) <=> x < y`;;\n\nlet REAL_NOT_LT = `!x y. ~(x < y) <=> y <= x`;;\n\nlet REAL_LT_ANTISYM = `!x y. ~(x < y /\\ y < x)`;;\n\nlet REAL_LT_GT = `!x y. x < y ==> ~(y < x)`;;\n\nlet REAL_NOT_LE = `!x y. ~(x <= y) <=> y < x`;;\n\nlet REAL_LE_TOTAL = `!x y. x <= y \\/ y <= x`;;\n\nlet REAL_LE_REFL = `!x. x <= x`;;\n\nlet REAL_LE_LT = `!x y. x <= y <=> x < y \\/ (x = y)`;;\n\nlet REAL_LT_LE = `!x y. x < y <=> x <= y /\\ ~(x = y)`;;\n\nlet REAL_LT_IMP_LE = `!x y. x < y ==> x <= y`;;\n\nlet REAL_LTE_TRANS = `!x y z. x < y /\\ y <= z ==> x < z`;;\n\nlet REAL_LE_TRANS = `!x y z. x <= y /\\ y <= z ==> x <= z`;;\n\nlet REAL_NEG_LT0 = `!x. (--x) < &0 <=> &0 < x`;;\n\nlet REAL_NEG_GT0 = `!x. &0 < (--x) <=> x < &0`;;\n\nlet REAL_NEG_LE0 = `!x. (--x) <= &0 <=> &0 <= x`;;\n\nlet REAL_NEG_GE0 = `!x. &0 <= (--x) <=> x <= &0`;;\n\nlet REAL_LT_NEGTOTAL = `!x. (x = &0) \\/ (&0 < x) \\/ (&0 < --x)`;;\n\nlet REAL_LE_NEGTOTAL = `!x. &0 <= x \\/ &0 <= --x`;;\n\nlet REAL_LE_MUL = `!x y. &0 <= x /\\ &0 <= y ==> &0 <= (x * y)`;;\n\nlet REAL_LE_SQUARE = `!x. &0 <= x * x`;;\n\nlet REAL_LT_01 = `&0 < &1`;;\n\nlet REAL_LE_LADD = `!x y z. (x + y) <= (x + z) <=> y <= z`;;\n\nlet REAL_LE_RADD = `!x y z. (x + z) <= (y + z) <=> x <= y`;;\n\nlet REAL_LT_ADD2 = `!w x y z. w < x /\\ y < z ==> (w + y) < (x + z)`;;\n\nlet REAL_LT_ADD = `!x y. &0 < x /\\ &0 < y ==> &0 < (x + y)`;;\n\nlet REAL_LT_ADDNEG = `!x y z. y < (x + (--z)) <=> (y + z) < x`;;\n\nlet REAL_LT_ADDNEG2 = `!x y z. (x + (--y)) < z <=> x < (z + y)`;;\n\nlet REAL_LT_ADD1 = `!x y. x <= y ==> x < (y + &1)`;;\n\nlet REAL_SUB_ADD = `!x y. (x - y) + y = x`;;\n\nlet REAL_SUB_ADD2 = `!x y. y + (x - y) = x`;;\n\nlet REAL_SUB_REFL = `!x. x - x = &0`;;\n\nlet REAL_SUB_0 = `!x y. (x - y = &0) <=> (x = y)`;;\n\nlet REAL_LE_DOUBLE = `!x. &0 <= x + x <=> &0 <= x`;;\n\nlet REAL_LE_NEGL = `!x. (--x <= x) <=> (&0 <= x)`;;\n\nlet REAL_LE_NEGR = `!x. (x <= --x) <=> (x <= &0)`;;\n\nlet REAL_NEG_EQ0 = `!x. (--x = &0) <=> (x = &0)`;;\n\nlet REAL_NEG_0 = `--(&0) = &0`;;\n\nlet REAL_NEG_SUB = `!x y. --(x - y) = y - x`;;\n\nlet REAL_SUB_LT = `!x y. &0 < x - y <=> y < x`;;\n\nlet REAL_SUB_LE = `!x y. &0 <= (x - y) <=> y <= x`;;\n\nlet REAL_EQ_LMUL = `!x y z. (x * y = x * z) <=> (x = &0) \\/ (y = z)`;;\n\nlet REAL_EQ_RMUL = `!x y z. (x * z = y * z) <=> (z = &0) \\/ (x = y)`;;\n\nlet REAL_SUB_LDISTRIB = `!x y z. x * (y - z) = (x * y) - (x * z)`;;\n\nlet REAL_SUB_RDISTRIB = `!x y z. (x - y) * z = (x * z) - (y * z)`;;\n\nlet REAL_NEG_EQ = `!x y. (--x = y) <=> (x = --y)`;;\n\nlet REAL_NEG_MINUS1 = `!x. --x = (--(&1)) * x`;;\n\nlet REAL_INV_NZ = `!x. ~(x = &0) ==> ~(inv x = &0)`;;\n\nlet REAL_INVINV = `!x. ~(x = &0) ==> (inv (inv x) = x)`;;\n\nlet REAL_LT_IMP_NE = `!x y. x < y ==> ~(x = y)`;;\n\nlet REAL_INV_POS = `!x. &0 < x ==> &0 < inv x`;;\n\nlet REAL_LT_LMUL_0 = `!x y. &0 < x ==> (&0 < (x * y) <=> &0 < y)`;;\n\nlet REAL_LT_RMUL_0 = `!x y. &0 < y ==> (&0 < (x * y) <=> &0 < x)`;;\n\nlet REAL_LT_LMUL_EQ = `!x y z. &0 < x ==> ((x * y) < (x * z) <=> y < z)`;;\n\nlet REAL_LT_RMUL_EQ = `!x y z. &0 < z ==> ((x * z) < (y * z) <=> x < y)`;;\n\nlet REAL_LT_RMUL_IMP = `!x y z. x < y /\\ &0 < z ==> (x * z) < (y * z)`;;\n\nlet REAL_LT_LMUL_IMP = `!x y z. y < z /\\ &0 < x ==> (x * y) < (x * z)`;;\n\nlet REAL_LINV_UNIQ = `!x y. (x * y = &1) ==> (x = inv y)`;;\n\nlet REAL_RINV_UNIQ = `!x y. (x * y = &1) ==> (y = inv x)`;;\n\nlet REAL_NEG_INV = `!x. ~(x = &0) ==> (--(inv x) = inv(--x))`;;\n\nlet REAL_INV_1OVER = `!x. inv x = &1 / x`;;\n\nlet REAL = `!n. &(SUC n) = &n + &1`;;\n\nlet REAL_POS = `!n. &0 <= &n`;;\n\nlet REAL_LE = `!m n. &m <= &n <=> m <= n`;;\n\nlet REAL_LT = `!m n. &m < &n <=> m < n`;;\n\nlet REAL_INJ = `!m n. (&m = &n) <=> (m = n)`;;\n\nlet REAL_ADD = `!m n. &m + &n = &(m + n)`;;\n\nlet REAL_MUL = `!m n. &m * &n = &(m * n)`;;\n\nlet REAL_INV1 = `inv(&1) = &1`;;\n\nlet REAL_DIV_LZERO = `!x. &0 / x = &0`;;\n\nlet REAL_LT_NZ = `!n. ~(&n = &0) <=> (&0 < &n)`;;\n\nlet REAL_NZ_IMP_LT = `!n. ~(n = 0) ==> &0 < &n`;;\n\nlet REAL_LT_RDIV_0 = `!y z. &0 < z ==> (&0 < (y / z) <=> &0 < y)`;;\n\nlet REAL_LT_RDIV = `!x y z. &0 < z ==> ((x / z) < (y / z) <=> x < y)`;;\n\nlet REAL_LT_FRACTION_0 = `!n d. ~(n = 0) ==> (&0 < (d / &n) <=> &0 < d)`;;\n\nlet REAL_LT_MULTIPLE = `!n d. 1 < n ==> (d < (&n * d) <=> &0 < d)`;;\n\nlet REAL_LT_FRACTION = `!n d. (1 < n) ==> ((d / &n) < d <=> &0 < d)`;;\n\nlet REAL_LT_HALF1 = `!d. &0 < (d / &2) <=> &0 < d`;;\n\nlet REAL_LT_HALF2 = `!d. (d / &2) < d <=> &0 < d`;;\n\nlet REAL_DOUBLE = `!x. x + x = &2 * x`;;\n\nlet REAL_HALF_DOUBLE = `!x. (x / &2) + (x / &2) = x`;;\n\nlet REAL_SUB_SUB = `!x y. (x - y) - x = --y`;;\n\nlet REAL_LT_ADD_SUB = `!x y z. (x + y) < z <=> x < (z - y)`;;\n\nlet REAL_LT_SUB_RADD = `!x y z. (x - y) < z <=> x < z + y`;;\n\nlet REAL_LT_SUB_LADD = `!x y z. x < (y - z) <=> (x + z) < y`;;\n\nlet REAL_LE_SUB_LADD = `!x y z. x <= (y - z) <=> (x + z) <= y`;;\n\nlet REAL_LE_SUB_RADD = `!x y z. (x - y) <= z <=> x <= z + y`;;\n\nlet REAL_LT_NEG2 = `!x y. --x < --y <=> y < x`;;\n\nlet REAL_LE_NEG2 = `!x y. --x <= --y <=> y <= x`;;\n\nlet REAL_SUB_LZERO = `!x. &0 - x = --x`;;\n\nlet REAL_SUB_RZERO = `!x. x - &0 = x`;;\n\nlet REAL_LTE_ADD2 = `!w x y z. w < x /\\ y <= z ==> (w + y) < (x + z)`;;\n\nlet REAL_LTE_ADD = `!x y. &0 < x /\\ &0 <= y ==> &0 < (x + y)`;;\n\nlet REAL_LT_MUL2_ALT = `!x1 x2 y1 y2. &0 <= x1 /\\ &0 <= y1 /\\ x1 < x2 /\\ y1 < y2 ==>\n (x1 * y1) < (x2 * y2)`;;\n\nlet REAL_SUB_LNEG = `!x y. (--x) - y = --(x + y)`;;\n\nlet REAL_SUB_RNEG = `!x y. x - (--y) = x + y`;;\n\nlet REAL_SUB_NEG2 = `!x y. (--x) - (--y) = y - x`;;\n\nlet REAL_SUB_TRIANGLE = `!a b c. (a - b) + (b - c) = a - c`;;\n\nlet REAL_INV_MUL_WEAK = `!x y. ~(x = &0) /\\ ~(y = &0) ==>\n (inv(x * y) = inv(x) * inv(y))`;;\n\nlet REAL_LE_LMUL_LOCAL = `!x y z. &0 < x ==> ((x * y) <= (x * z) <=> y <= z)`;;\n\nlet REAL_LE_RMUL_EQ = `!x y z. &0 < z ==> ((x * z) <= (y * z) <=> x <= y)`;;\n\nlet REAL_SUB_INV2 = `!x y. ~(x = &0) /\\ ~(y = &0) ==>\n (inv(x) - inv(y) = (y - x) / (x * y))`;;\n\nlet REAL_SUB_SUB2 = `!x y. x - (x - y) = y`;;\n\nlet REAL_MEAN = `!x y. x < y ==> ?z. x < z /\\ z < y`;;\n\nlet REAL_EQ_LMUL2 = `!x y z. ~(x = &0) ==> ((y = z) <=> (x * y = x * z))`;;\n\nlet REAL_LE_MUL2V = `!x1 x2 y1 y2.\n (& 0) <= x1 /\\ (& 0) <= y1 /\\ x1 <= x2 /\\ y1 <= y2 ==>\n (x1 * y1) <= (x2 * y2)`;;\n\nlet REAL_LE_LDIV = `!x y z. &0 < x /\\ y <= (z * x) ==> (y / x) <= z`;;\n\nlet REAL_LE_RDIV = `!x y z. &0 < x /\\ (y * x) <= z ==> y <= (z / x)`;;\n\nlet REAL_LT_1 = `!x y. &0 <= x /\\ x < y ==> (x / y) < &1`;;\n\nlet REAL_LE_LMUL_IMP = `!x y z. &0 <= x /\\ y <= z ==> (x * y) <= (x * z)`;;\n\nlet REAL_LE_RMUL_IMP = `!x y z. &0 <= x /\\ y <= z ==> (y * x) <= (z * x)`;;\n\nlet REAL_INV_LT1 = `!x. &0 < x /\\ x < &1 ==> &1 < inv(x)`;;\n\nlet REAL_LT_IMP_NZ = `!x. &0 < x ==> ~(x = &0)`;;\n\nlet REAL_EQ_RMUL_IMP = `!x y z. ~(z = &0) /\\ (x * z = y * z) ==> (x = y)`;;\n\nlet REAL_EQ_LMUL_IMP = `!x y z. ~(x = &0) /\\ (x * y = x * z) ==> (y = z)`;;\n\nlet REAL_FACT_NZ = `!n. ~(&(FACT n) = &0)`;;\n\nlet REAL_POSSQ = `!x. &0 < (x * x) <=> ~(x = &0)`;;\n\nlet REAL_SUMSQ = `!x y. ((x * x) + (y * y) = &0) <=> (x = &0) /\\ (y = &0)`;;\n\nlet REAL_EQ_NEG = `!x y. (--x = --y) <=> (x = y)`;;\n\nlet REAL_DIV_MUL2 = `!x z. ~(x = &0) /\\ ~(z = &0) ==> !y. y / z = (x * y) / (x * z)`;;\n\nlet REAL_MIDDLE1 = `!a b. a <= b ==> a <= (a + b) / &2`;;\n\nlet REAL_MIDDLE2 = `!a b. a <= b ==> ((a + b) / &2) <= b`;;\n\nlet ABS_ZERO = `!x. (abs(x) = &0) <=> (x = &0)`;;\n\nlet ABS_0 = `abs(&0) = &0`;;\n\nlet ABS_1 = `abs(&1) = &1`;;\n\nlet ABS_NEG = `!x. abs(--x) = abs(x)`;;\n\nlet ABS_TRIANGLE = `!x y. abs(x + y) <= abs(x) + abs(y)`;;\n\nlet ABS_POS = `!x. &0 <= abs(x)`;;\n\nlet ABS_MUL = `!x y. abs(x * y) = abs(x) * abs(y)`;;\n\nlet ABS_LT_MUL2 = `!w x y z. abs(w) < y /\\ abs(x) < z ==> abs(w * x) < (y * z)`;;\n\nlet ABS_SUB = `!x y. abs(x - y) = abs(y - x)`;;\n\nlet ABS_NZ = `!x. ~(x = &0) <=> &0 < abs(x)`;;\n\nlet ABS_INV = `!x. ~(x = &0) ==> (abs(inv x) = inv(abs(x)))`;;\n\nlet ABS_ABS = `!x. abs(abs(x)) = abs(x)`;;\n\nlet ABS_LE = `!x. x <= abs(x)`;;\n\nlet ABS_REFL = `!x. (abs(x) = x) <=> &0 <= x`;;\n\nlet ABS_N = `!n. abs(&n) = &n`;;\n\nlet ABS_BETWEEN = `!x y d. &0 < d /\\ ((x - d) < y) /\\ (y < (x + d)) <=> abs(y - x) < d`;;\n\nlet ABS_BOUND = `!x y d. abs(x - y) < d ==> y < (x + d)`;;\n\nlet ABS_STILLNZ = `!x y. abs(x - y) < abs(y) ==> ~(x = &0)`;;\n\nlet ABS_CASES = `!x. (x = &0) \\/ &0 < abs(x)`;;\n\nlet ABS_BETWEEN1 = `!x y z. x < z /\\ (abs(y - x)) < (z - x) ==> y < z`;;\n\nlet ABS_SIGN = `!x y. abs(x - y) < y ==> &0 < x`;;\n\nlet ABS_SIGN2 = `!x y. abs(x - y) < --y ==> x < &0`;;\n\nlet ABS_DIV = `!y. ~(y = &0) ==> !x. abs(x / y) = abs(x) / abs(y)`;;\n\nlet ABS_CIRCLE = `!x y h. abs(h) < (abs(y) - abs(x)) ==> abs(x + h) < abs(y)`;;\n\nlet REAL_SUB_ABS = `!x y. (abs(x) - abs(y)) <= abs(x - y)`;;\n\nlet ABS_SUB_ABS = `!x y. abs(abs(x) - abs(y)) <= abs(x - y)`;;\n\nlet ABS_BETWEEN2 = `!x0 x y0 y. x0 < y0 /\\ abs(x - x0) < (y0 - x0) / &2 /\\\n abs(y - y0) < (y0 - x0) / &2\n ==> x < y`;;\n\nlet ABS_BOUNDS = `!x k. abs(x) <= k <=> --k <= x /\\ x <= k`;;\n\nlet pow = real_pow;;\n\nlet POW_0 = `!n. &0 pow (SUC n) = &0`;;\n\nlet POW_NZ = `!c n. ~(c = &0) ==> ~(c pow n = &0)`;;\n\nlet POW_INV = `!c n. ~(c = &0) ==> (inv(c pow n) = (inv c) pow n)`;;\n\nlet POW_ABS = `!c n. abs(c) pow n = abs(c pow n)`;;\n\nlet POW_PLUS1 = `!e n. &0 < e ==> (&1 + (&n * e)) <= (&1 + e) pow n`;;\n\nlet POW_ADD = `!c m n. c pow (m + n) = (c pow m) * (c pow n)`;;\n\nlet POW_1 = `!x. x pow 1 = x`;;\n\nlet POW_2 = `!x. x pow 2 = x * x`;;\n\nlet POW_POS = `!x n. &0 <= x ==> &0 <= (x pow n)`;;\n\nlet POW_LE = `!n x y. &0 <= x /\\ x <= y ==> (x pow n) <= (y pow n)`;;\n\nlet POW_M1 = `!n. abs((--(&1)) pow n) = &1`;;\n\nlet POW_MUL = `!n x y. (x * y) pow n = (x pow n) * (y pow n)`;;\n\nlet REAL_LE_SQUARE_POW = `!x. &0 <= x pow 2`;;\n\nlet ABS_POW2 = `!x. abs(x pow 2) = x pow 2`;;\n\nlet REAL_LE1_POW2 = `!x. &1 <= x ==> &1 <= (x pow 2)`;;\n\nlet REAL_LT1_POW2 = `!x. &1 < x ==> &1 < (x pow 2)`;;\n\nlet POW_POS_LT = `!x n. &0 < x ==> &0 < (x pow (SUC n))`;;\n\nlet POW_2_LE1 = `!n. &1 <= &2 pow n`;;\n\nlet POW_2_LT = `!n. &n < &2 pow n`;;\n\nlet POW_MINUS1 = `!n. (--(&1)) pow (2 * n) = &1`;;\n\nlet REAL_SUP_EXISTS = `!P. (?x. P x) /\\ (?z. !x. P x ==> x < z) ==>\n (?s. !y. (?x. P x /\\ y < x) <=> y < s)`;;\n\nlet sup_def = new_definition\n `sup s = @a. (!x. x IN s ==> x <= a) /\\\n (!b. (!x. x IN s ==> x <= b) ==> a <= b)`;;\n\nlet sup = `sup P = @s. !y. (?x. P x /\\ y < x) <=> y < s`;;\n\nlet REAL_SUP = `!P. (?x. P x) /\\ (?z. !x. P x ==> x < z) ==>\n (!y. (?x. P x /\\ y < x) <=> y < sup P)`;;\n\nlet REAL_SUP_UBOUND = `!P. (?x. P x) /\\ (?z. !x. P x ==> x < z) ==>\n (!y. P y ==> y <= sup P)`;;\n\nlet SETOK_LE_LT = `!P. (?x. P x) /\\ (?z. !x. P x ==> x <= z) <=>\n (?x. P x) /\\ (?z. !x. P x ==> x < z)`;;\n\nlet REAL_SUP_LE = `!P. (?x. P x) /\\ (?z. !x. P x ==> x <= z) ==>\n (!y. (?x. P x /\\ y < x) <=> y < sup P)`;;\n\nlet REAL_SUP_UBOUND_LE = `!P. (?x. P x) /\\ (?z. !x. P x ==> x <= z) ==>\n (!y. P y ==> y <= sup P)`;;\n\nlet REAL_ARCH_SIMPLE = `!x. ?n. x <= &n`;;\n\nlet REAL_ARCH = `!x. &0 < x ==> !y. ?n. y < &n * x`;;\n\nlet REAL_ARCH_LEAST = `!y. &0 < y ==> !x. &0 <= x ==>\n ?n. (&n * y) <= x /\\ x < (&(SUC n) * y)`;;\n\nlet REAL_POW_LBOUND = `!x n. &0 <= x ==> &1 + &n * x <= (&1 + x) pow n`;;\n\nlet REAL_ARCH_POW = `!x y. &1 < x ==> ?n. y < x pow n`;;\n\nlet REAL_ARCH_POW2 = `!x. ?n. x < &2 pow n`;;\n\nprioritize_real();;\n\nmake_overloadable \"sum\" `:A->(B->real)->real`;;\n\noverload_interface(\"sum\",`sum:(A->bool)->(A->real)->real`);;\noverload_interface(\"sum\",`psum:(num#num)->(num->real)->real`);;\n\nlet sum_EXISTS = `?sum. (!f n. sum(n,0) f = &0) /\\\n (!f m n. sum(n,SUC m) f = sum(n,m) f + f(n + m))`;;\n\nlet sum_DEF = new_specification [\"psum\"] sum_EXISTS;;\n\nlet sum = `(sum(n,0) f = &0) /\\\n (sum(n,SUC m) f = sum(n,m) f + f(n + m))`;;\n\nlet PSUM_SUM = `!f m n. sum(m,n) f = sum {i | m <= i /\\ i < m + n} f`;;\n\nlet PSUM_SUM_NUMSEG = `!f m n. ~(m = 0 /\\ n = 0) ==> sum(m,n) f = sum(m..(m+n)-1) f`;;\n\nlet SUM_TWO = `!f n p. sum(0,n) f + sum(n,p) f = sum(0,n + p) f`;;\n\nlet SUM_DIFF = `!f m n. sum(m,n) f = sum(0,m + n) f - sum(0,m) f`;;\n\nlet ABS_SUM = `!f m n. abs(sum(m,n) f) <= sum(m,n) (\\n. abs(f n))`;;\n\nlet SUM_LE = `!f g m n. (!r. m <= r /\\ r < n + m ==> f(r) <= g(r))\n ==> (sum(m,n) f <= sum(m,n) g)`;;\n\nlet SUM_EQ = `!f g m n. (!r. m <= r /\\ r < (n + m) ==> (f(r) = g(r)))\n ==> (sum(m,n) f = sum(m,n) g)`;;\n\nlet SUM_POS = `!f. (!n. &0 <= f(n)) ==> !m n. &0 <= sum(m,n) f`;;\n\nlet SUM_POS_GEN = `!f m n.\n (!n. m <= n ==> &0 <= f(n))\n ==> &0 <= sum(m,n) f`;;\n\nlet SUM_ABS = `!f m n. abs(sum(m,n) (\\m. abs(f m))) = sum(m,n) (\\m. abs(f m))`;;\n\nlet SUM_ABS_LE = `!f m n. abs(sum(m,n) f) <= sum(m,n)(\\n. abs(f n))`;;\n\nlet SUM_ZERO = `!f N. (!n. n >= N ==> (f(n) = &0)) ==>\n (!m n. m >= N ==> (sum(m,n) f = &0))`;;\n\nlet SUM_ADD = `!f g m n. sum(m,n) (\\n. f(n) + g(n)) = sum(m,n) f + sum(m,n) g`;;\n\nlet SUM_CMUL = `!f c m n. sum(m,n) (\\n. c * f(n)) = c * sum(m,n) f`;;\n\nlet SUM_NEG = `!f n d. sum(n,d) (\\n. --(f n)) = --(sum(n,d) f)`;;\n\nlet SUM_SUB = `!f g m n. sum(m,n)(\\n. (f n) - (g n)) = sum(m,n) f - sum(m,n) g`;;\n\nlet SUM_SUBST = `!f g m n. (!p. m <= p /\\ p < (m + n) ==> (f p = g p))\n ==> (sum(m,n) f = sum(m,n) g)`;;\n\nlet SUM_NSUB = `!n f c. sum(0,n) f - (&n * c) = sum(0,n)(\\p. f(p) - c)`;;\n\nlet SUM_BOUND = `!f K m n. (!p. m <= p /\\ p < (m + n) ==> (f(p) <= K))\n ==> (sum(m,n) f <= (&n * K))`;;\n\nlet SUM_GROUP = `!n k f. sum(0,n)(\\m. sum(m * k,k) f) = sum(0,n * k) f`;;\n\nlet SUM_1 = `!f n. sum(n,1) f = f(n)`;;\n\nlet SUM_2 = `!f n. sum(n,2) f = f(n) + f(n + 1)`;;\n\nlet SUM_OFFSET = `!f n k. sum(0,n)(\\m. f(m + k)) = sum(0,n + k) f - sum(0,k) f`;;\n\nlet SUM_REINDEX = `!f m k n. sum(m + k,n) f = sum(m,n)(\\r. f(r + k))`;;\n\nlet SUM_0 = `!m n. sum(m,n)(\\r. &0) = &0`;;\n\nlet SUM_CANCEL = `!f n d. sum(n,d) (\\n. f(SUC n) - f(n)) = f(n + d) - f(n)`;;\n\nlet SUM_HORNER = `!f n x. sum(0,SUC n)(\\i. f(i) * x pow i) =\n f(0) + x * sum(0,n)(\\i. f(SUC i) * x pow i)`;;\n\nlet SUM_CONST = `!c n. sum(0,n) (\\m. c) = &n * c`;;\n\nlet SUM_SPLIT = `!f n p. sum(m,n) f + sum(m + n,p) f = sum(m,n + p) f`;;\n\nlet SUM_SWAP = `!f m1 n1 m2 n2.\n sum(m1,n1) (\\a. sum(m2,n2) (\\b. f a b)) =\n sum(m2,n2) (\\b. sum(m1,n1) (\\a. f a b))`;;\n\nlet SUM_EQ_0 = `(!r. m <= r /\\ r < m + n ==> (f(r) = &0)) ==> (sum(m,n) f = &0)`;;\n\nlet SUM_MORETERMS_EQ = `!m n p.\n n <= p /\\ (!r. m + n <= r /\\ r < m + p ==> (f(r) = &0))\n ==> (sum(m,p) f = sum(m,n) f)`;;\n\nlet SUM_DIFFERENCES_EQ = `!m n p.\n n <= p /\\ (!r. m + n <= r /\\ r < m + p ==> (f(r) = g(r)))\n ==> (sum(m,p) f - sum(m,n) f = sum(m,p) g - sum(m,n) g)`;;\n\nlet REAL_SUM_CONV =\n let sum_tm = `sum` in\n let pth = `sum(0,1) f = f 0`;;\nparse_as_infix(\"re_intersect\",(17,\"right\"));;\nparse_as_infix(\"re_subset\",(12,\"right\"));;\n\nlet re_Union = new_definition(\n `re_Union S = \\x:A. ?s. S s /\\ s x`);;\n\nlet re_union = new_definition(\n `P re_union Q = \\x:A. P x \\/ Q x`);;\n\nlet re_intersect = new_definition\n `P re_intersect Q = \\x:A. P x /\\ Q x`;;\n\nlet re_null = new_definition(\n `re_null = \\x:A. F`);;\n\nlet re_universe = new_definition(\n `re_universe = \\x:A. T`);;\n\nlet re_subset = new_definition(\n `P re_subset Q <=> !x:A. P x ==> Q x`);;\n\nlet re_compl = new_definition(\n `re_compl S = \\x:A. ~(S x)`);;\n\nlet SUBSETA_REFL = `!S:A->bool. S re_subset S`;;\n\nlet COMPL_MEM = `!S:A->bool. !x. S x <=> ~(re_compl S x)`;;\n\nlet SUBSETA_ANTISYM = `!P:A->bool. !Q. P re_subset Q /\\ Q re_subset P <=> (P = Q)`;;\n\nlet SUBSETA_TRANS = `!P:A->bool. !Q R. P re_subset Q /\\ Q re_subset R ==> P re_subset R`;;\n\nlet istopology = new_definition(\n `!L:(A->bool)->bool. istopology L <=>\n L re_null /\\\n L re_universe /\\\n (!a b. L a /\\ L b ==> L (a re_intersect b)) /\\\n (!P. P re_subset L ==> L (re_Union P))`);;\n\nlet topology_tybij = new_type_definition \"topology\" (\"topology\",\"open\")\n (prove(`?t:(A->bool)->bool. istopology t`,\n EXISTS_TAC `re_universe:(A->bool)->bool` THEN\n REWRITE_TAC[istopology; re_universe]));;\n\nlet TOPOLOGY = `!L:(A)topology. open(L) re_null /\\\n open(L) re_universe /\\\n (!x y. open(L) x /\\ open(L) y ==> open(L) (x re_intersect y)) /\\\n (!P. P re_subset (open L) ==> open(L) (re_Union P))`;;\n\nlet TOPOLOGY_UNION = `!L:(A)topology. !P. P re_subset (open L) ==> open(L) (re_Union P)`;;\n\nlet neigh = new_definition(\n `neigh(top)(N,(x:A)) = ?P. open(top) P /\\ P re_subset N /\\ P x`);;\n\nlet OPEN_OWN_NEIGH = `!S top. !x:A. open(top) S /\\ S x ==> neigh(top)(S,x)`;;\n\nlet OPEN_UNOPEN = `!S top. open(top) S <=>\n (re_Union (\\P:A->bool. open(top) P /\\ P re_subset S) = S)`;;\n\nlet OPEN_SUBOPEN = `!S top. open(top) S <=>\n !x:A. S x ==> ?P. P x /\\ open(top) P /\\ P re_subset S`;;\n\nlet OPEN_NEIGH = `!S top. open(top) S = !x:A. S x ==> ?N. neigh(top)(N,x) /\\ N re_subset S`;;\n\nlet closed = new_definition(\n `closed(L:(A)topology) S = open(L)(re_compl S)`);;\n\nlet limpt = new_definition(\n `limpt(top) x S <=>\n !N:A->bool. neigh(top)(N,x) ==> ?y. ~(x = y) /\\ S y /\\ N y`);;\n\nlet CLOSED_LIMPT = `!top S. closed(top) S <=> (!x:A. limpt(top) x S ==> S x)`;;\n\nlet ismet = new_definition(\n `ismet (m:A#A->real) <=> (!x y. (m(x,y) = &0) <=> (x = y)) /\\\n (!x y z. m(y,z) <= m(x,y) + m(x,z))`);;\n\nlet metric_tybij = new_type_definition \"metric\" (\"metric\",\"mdist\")\n (prove(`?m:(A#A->real). ismet m`,\n EXISTS_TAC `\\((x:A),(y:A)). if x = y then &0 else &1` THEN\n REWRITE_TAC[ismet] THEN\n CONV_TAC(ONCE_DEPTH_CONV GEN_BETA_CONV) THEN\n CONJ_TAC THEN REPEAT GEN_TAC THENL\n [BOOL_CASES_TAC `x:A = y` THEN REWRITE_TAC[REAL_10];\n REPEAT COND_CASES_TAC THEN\n ASM_REWRITE_TAC[REAL_ADD_LID; REAL_ADD_RID; REAL_LE_REFL; REAL_LE_01]\n THEN GEN_REWRITE_TAC LAND_CONV [GSYM REAL_ADD_LID] THEN\n TRY(MATCH_MP_TAC REAL_LE_ADD2) THEN\n REWRITE_TAC[REAL_LE_01; REAL_LE_REFL] THEN\n FIRST_ASSUM(UNDISCH_TAC o check is_neg o concl) THEN\n EVERY_ASSUM(SUBST1_TAC o SYM) THEN REWRITE_TAC[]]));;\n\nlet METRIC_ISMET = `!m:(A)metric. ismet (mdist m)`;;\n\nlet METRIC_ZERO = `!m:(A)metric. !x y. ((mdist m)(x,y) = &0) <=> (x = y)`;;\n\nlet METRIC_SAME = `!m:(A)metric. !x. (mdist m)(x,x) = &0`;;\n\nlet METRIC_POS = `!m:(A)metric. !x y. &0 <= (mdist m)(x,y)`;;\n\nlet METRIC_SYM = `!m:(A)metric. !x y. (mdist m)(x,y) = (mdist m)(y,x)`;;\n\nlet METRIC_TRIANGLE = `!m:(A)metric. !x y z. (mdist m)(x,z) <= (mdist m)(x,y) + (mdist m)(y,z)`;;\n\nlet METRIC_NZ = `!m:(A)metric. !x y. ~(x = y) ==> &0 < (mdist m)(x,y)`;;\n\nlet mtop = new_definition(\n `!m:(A)metric. mtop m =\n topology(\\S. !x. S x ==> ?e. &0 < e /\\ (!y. (mdist m)(x,y) < e ==> S y))`);;\n\nlet mtop_istopology = `!m:(A)metric. istopology\n (\\S. !x. S x ==> ?e. &0 < e /\\ (!y. (mdist m)(x,y) < e ==> S y))`;;\n\nlet MTOP_OPEN = `!m:(A)metric. open(mtop m) S <=>\n (!x. S x ==> ?e. &0 < e /\\ (!y. (mdist m(x,y)) < e ==> S y))`;;\n\nlet ball = new_definition(\n `!m:(A)metric. !x e. ball(m)(x,e) = \\y. (mdist m)(x,y) < e`);;\n\nlet BALL_OPEN = `!m:(A)metric. !x e. &0 < e ==> open(mtop(m))(ball(m)(x,e))`;;\n\nlet BALL_NEIGH = `!m:(A)metric. !x e. &0 < e ==> neigh(mtop(m))(ball(m)(x,e),x)`;;\n\nlet MTOP_LIMPT = `!m:(A)metric. !x S. limpt(mtop m) x S <=>\n !e. &0 < e ==> ?y. ~(x = y) /\\ S y /\\ (mdist m)(x,y) < e`;;\n\nlet ISMET_R1 = `ismet (\\(x,y). abs(y - x))`;;\n\nlet mr1 = new_definition(\n `mr1 = metric(\\(x,y). abs(y - x))`);;\n\nlet MR1_DEF = `!x y. (mdist mr1)(x,y) = abs(y - x)`;;\n\nlet MR1_ADD = `!x d. (mdist mr1)(x,x+d) = abs(d)`;;\n\nlet MR1_SUB = `!x d. (mdist mr1)(x,x-d) = abs(d)`;;\n\nlet MR1_ADD_LE = `!x d. &0 <= d ==> ((mdist mr1)(x,x+d) = d)`;;\n\nlet MR1_SUB_LE = `!x d. &0 <= d ==> ((mdist mr1)(x,x-d) = d)`;;\n\nlet MR1_ADD_LT = `!x d. &0 < d ==> ((mdist mr1)(x,x+d) = d)`;;\n\nlet MR1_SUB_LT = `!x d. &0 < d ==> ((mdist mr1)(x,x-d) = d)`;;\n\nlet MR1_BETWEEN1 = `!x y z. x < z /\\ (mdist mr1)(x,y) < (z - x) ==> y < z`;;\n\nlet MR1_LIMPT = `!x. limpt(mtop mr1) x re_universe`;;\n\nparse_as_infix (\"tends\",(12,\"right\"));;\n\nlet dorder = new_definition(\n `dorder (g:A->A->bool) <=>\n !x y. g x x /\\ g y y ==> ?z. g z z /\\ (!w. g w z ==> g w x /\\ g w y)`);;\n\nlet tends = new_definition\n `(s tends l)(top,g) <=>\n !N:A->bool. neigh(top)(N,l) ==>\n ?n:B. g n n /\\ !m:B. g m n ==> N(s m)`;;\n\nlet bounded = new_definition(\n `bounded((m:(A)metric),(g:B->B->bool)) f <=>\n ?k x N. g N N /\\ (!n. g n N ==> (mdist m)(f(n),x) < k)`);;\n\nlet tendsto = new_definition(\n `tendsto((m:(A)metric),x) y z <=>\n &0 < (mdist m)(x,y) /\\ (mdist m)(x,y) <= (mdist m)(x,z)`);;\n\nparse_as_infix(\"-->\",(12,\"right\"));;\n\noverride_interface (\"-->\",`(tends)`);;\n\nlet DORDER_LEMMA = `!g:A->A->bool.\n dorder g ==>\n !P Q. (?n. g n n /\\ (!m. g m n ==> P m)) /\\\n (?n. g n n /\\ (!m. g m n ==> Q m))\n ==> (?n. g n n /\\ (!m. g m n ==> P m /\\ Q m))`;;\n\nlet DORDER_THEN tac th =\n let [t1;t2] = map (rand o rand o body o rand) (conjuncts(concl th)) in\n let dog = (rator o rator o rand o rator o body) t1 in\n let thl = map ((uncurry X_BETA_CONV) o (I F_F rand) o dest_abs) [t1;t2] in\n let th1 = CONV_RULE(EXACT_CONV thl) th in\n let th2 = MATCH_MP DORDER_LEMMA (ASSUME (list_mk_icomb \"dorder\" [dog])) in\n let th3 = MATCH_MP th2 th1 in\n let th4 = CONV_RULE(EXACT_CONV(map SYM thl)) th3 in\n tac th4;;\n\nlet DORDER_NGE = `dorder ((>=) :num->num->bool)`;;\n\nlet DORDER_TENDSTO = `!m:(A)metric. !x. dorder(tendsto(m,x))`;;\n\nlet MTOP_TENDS = `!d g. !x:B->A. !x0. (x --> x0)(mtop(d),g) <=>\n !e. &0 < e ==> ?n. g n n /\\ !m. g m n ==> mdist(d)(x(m),x0) < e`;;\n\nlet MTOP_TENDS_UNIQ = `!g d. dorder (g:B->B->bool) ==>\n (x --> x0)(mtop(d),g) /\\ (x --> x1)(mtop(d),g) ==> (x0:A = x1)`;;\n\nlet SEQ_TENDS = `!d:(A)metric. !x x0. (x --> x0)(mtop(d), (>=) :num->num->bool) <=>\n !e. &0 < e ==> ?N. !n. n >= N ==> mdist(d)(x(n),x0) < e`;;\n\nlet LIM_TENDS = `!m1:(A)metric. !m2:(B)metric. !f x0 y0.\n limpt(mtop m1) x0 re_universe ==>\n ((f --> y0)(mtop(m2),tendsto(m1,x0)) <=>\n !e. &0 < e ==>\n ?d. &0 < d /\\ !x. &0 < (mdist m1)(x,x0) /\\ (mdist m1)(x,x0) <= d\n ==> (mdist m2)(f(x),y0) < e)`;;\n\nlet LIM_TENDS2 = `!m1:(A)metric. !m2:(B)metric. !f x0 y0.\n limpt(mtop m1) x0 re_universe ==>\n ((f --> y0)(mtop(m2),tendsto(m1,x0)) <=>\n !e. &0 < e ==>\n ?d. &0 < d /\\ !x. &0 < (mdist m1)(x,x0) /\\ (mdist m1)(x,x0) < d ==>\n (mdist m2)(f(x),y0) < e)`;;\n\nlet MR1_BOUNDED = `!(g:A->A->bool) f. bounded(mr1,g) f <=>\n ?k N. g N N /\\ (!n. g n N ==> abs(f n) < k)`;;\n\nlet NET_NULL = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) <=> ((\\n. x(n) - x0) --> &0)(mtop(mr1),g)`;;\n\nlet NET_CONV_BOUNDED = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) ==> bounded(mr1,g) x`;;\n\nlet NET_CONV_NZ = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) /\\ ~(x0 = &0) ==>\n ?N. g N N /\\ (!n. g n N ==> ~(x n = &0))`;;\n\nlet NET_CONV_IBOUNDED = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) /\\ ~(x0 = &0) ==>\n bounded(mr1,g) (\\n. inv(x n))`;;\n\nlet NET_NULL_ADD = `!g:A->A->bool. dorder g ==>\n !x y. (x --> &0)(mtop(mr1),g) /\\ (y --> &0)(mtop(mr1),g) ==>\n ((\\n. x(n) + y(n)) --> &0)(mtop(mr1),g)`;;\n\nlet NET_NULL_MUL = `!g:A->A->bool. dorder g ==>\n !x y. bounded(mr1,g) x /\\ (y --> &0)(mtop(mr1),g) ==>\n ((\\n. x(n) * y(n)) --> &0)(mtop(mr1),g)`;;\n\nlet NET_NULL_CMUL = `!g:A->A->bool. !k x.\n (x --> &0)(mtop(mr1),g) ==> ((\\n. k * x(n)) --> &0)(mtop(mr1),g)`;;\n\nlet NET_ADD = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ (y --> y0)(mtop(mr1),g)\n ==> ((\\n. x(n) + y(n)) --> (x0 + y0))(mtop(mr1),g)`;;\n\nlet NET_NEG = `!g:A->A->bool x x0.\n dorder g\n ==> ((x --> x0)(mtop(mr1),g) <=>\n ((\\n. --(x n)) --> --x0)(mtop(mr1),g))`;;\n\nlet NET_SUB = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ (y --> y0)(mtop(mr1),g)\n ==> ((\\n. x(n) - y(n)) --> (x0 - y0))(mtop(mr1),g)`;;\n\nlet NET_MUL = `!g:A->A->bool x y x0 y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ (y --> y0)(mtop(mr1),g)\n ==> ((\\n. x(n) * y(n)) --> (x0 * y0))(mtop(mr1),g)`;;\n\nlet NET_INV = `!g:A->A->bool x x0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ ~(x0 = &0)\n ==> ((\\n. inv(x(n))) --> inv x0)(mtop(mr1),g)`;;\n\nlet NET_DIV = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\\n (y --> y0)(mtop(mr1),g) /\\ ~(y0 = &0)\n ==> ((\\n. x(n) / y(n)) --> (x0 / y0))(mtop(mr1),g)`;;\n\nlet NET_ABS = `!x x0. (x --> x0)(mtop(mr1),g) ==>\n ((\\n:A. abs(x n)) --> abs(x0))(mtop(mr1),g)`;;\n\nlet NET_SUM = `!g. dorder g /\\\n ((\\x. &0) --> &0)(mtop(mr1),g)\n ==> !m n. (!r. m <= r /\\ r < m + n ==> (f r --> l r)(mtop(mr1),g))\n ==> ((\\x. sum(m,n) (\\r. f r x)) --> sum(m,n) l)\n (mtop(mr1),g)`;;\n\nlet NET_LE = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\\n (y --> y0)(mtop(mr1),g) /\\\n (?N. g N N /\\ !n. g n N ==> x(n) <= y(n))\n ==> x0 <= y0`;;\n\nparse_as_infix (\"tends_num_real\",(12,\"right\"));;\n\nparse_as_infix (\"sums\",(12,\"right\"));;\n\nlet tends_num_real = new_definition(\n `x tends_num_real x0 <=> (x tends x0)(mtop(mr1), (>=) :num->num->bool)`);;\n\noverride_interface (\"-->\",`(tends_num_real)`);;\n\nlet SEQ = `!x x0. (x --> x0) <=>\n !e. &0 < e ==> ?N. !n. n >= N ==> abs(x(n) - x0) < e`;;\n\nlet SEQ_CONST = `!k. (\\x. k) --> k`;;\n\nlet SEQ_ADD = `!x x0 y y0. x --> x0 /\\ y --> y0 ==> (\\n. x(n) + y(n)) --> (x0 + y0)`;;\n\nlet SEQ_MUL = `!x x0 y y0. x --> x0 /\\ y --> y0 ==> (\\n. x(n) * y(n)) --> (x0 * y0)`;;\n\nlet SEQ_NEG = `!x x0. x --> x0 <=> (\\n. --(x n)) --> --x0`;;\n\nlet SEQ_INV = `!x x0. x --> x0 /\\ ~(x0 = &0) ==> (\\n. inv(x n)) --> inv x0`;;\n\nlet SEQ_SUB = `!x x0 y y0. x --> x0 /\\ y --> y0 ==> (\\n. x(n) - y(n)) --> (x0 - y0)`;;\n\nlet SEQ_DIV = `!x x0 y y0. x --> x0 /\\ y --> y0 /\\ ~(y0 = &0) ==>\n (\\n. x(n) / y(n)) --> (x0 / y0)`;;\n\nlet SEQ_UNIQ = `!x x1 x2. x --> x1 /\\ x --> x2 ==> (x1 = x2)`;;\n\nlet SEQ_NULL = `!s l. s --> l <=> (\\n. s(n) - l) --> &0`;;\n\nlet SEQ_SUM = `!f l m n.\n (!r. m <= r /\\ r < m + n ==> f r --> l r)\n ==> (\\k. sum(m,n) (\\r. f r k)) --> sum(m,n) l`;;\n\nlet SEQ_TRANSFORM = `!s t l N. (!n. N <= n ==> (s n = t n)) /\\ s --> l ==> t --> l`;;\n\nlet convergent = new_definition(\n `convergent f <=> ?l. f --> l`);;\n\nlet cauchy = new_definition(\n `cauchy f <=> !e. &0 < e ==>\n ?N:num. !m n. m >= N /\\ n >= N ==> abs(f(m) - f(n)) < e`);;\n\nlet lim = new_definition(\n `lim f = @l. f --> l`);;\n\nlet SEQ_LIM = `!f. convergent f <=> (f --> lim f)`;;\n\nlet subseq = new_definition(\n `subseq (f:num->num) <=> !m n. m < n ==> (f m) < (f n)`);;\n\nlet SUBSEQ_SUC = `!f. subseq f <=> !n. f(n) < f(SUC n)`;;\n\nlet mono = new_definition(\n `mono (f:num->real) <=>\n (!m n. m <= n ==> f(m) <= f(n)) \\/\n (!m n. m <= n ==> f(m) >= f(n))`);;\n\nlet MONO_SUC = `!f. mono f <=> (!n. f(SUC n) >= f(n)) \\/ (!n. f(SUC n) <= f(n))`;;\n\nlet MAX_LEMMA = `!s N. ?k. !n:num. n < N ==> abs(s n) < k`;;\n\nlet SEQ_BOUNDED = `!s. bounded(mr1, (>=)) s <=> ?k. !n:num. abs(s n) < k`;;\n\nlet SEQ_BOUNDED_2 = `!f k K. (!n:num. k <= f(n) /\\ f(n) <= K) ==> bounded(mr1, (>=)) f`;;\n\nlet SEQ_CBOUNDED = `!f. cauchy f ==> bounded(mr1, (>=)) f`;;\n\nlet SEQ_ICONV = `!f. bounded(mr1, (>=)) f /\\ (!m n. m >= n ==> f(m) >= f(n))\n ==> convergent f`;;\n\nlet SEQ_NEG_CONV = `!f. convergent f <=> convergent (\\n. --(f n))`;;\n\nlet SEQ_NEG_BOUNDED = `!f. bounded(mr1, (>=))(\\n:num. --(f n)) <=> bounded(mr1, (>=)) f`;;\n\nlet SEQ_BCONV = `!f. bounded(mr1, (>=)) f /\\ mono f ==> convergent f`;;\n\nlet SEQ_MONOSUB = `!s:num->real. ?f. subseq f /\\ mono(\\n.s(f n))`;;\n\nlet SEQ_SBOUNDED = `!s (f:num->num). bounded(mr1, (>=)) s ==> bounded(mr1, (>=)) (\\n. s(f n))`;;\n\nlet SEQ_SUBLE = `!f n. subseq f ==> n <= f(n)`;;\n\nlet SEQ_DIRECT = `!f. subseq f ==> !N1 N2. ?n. n >= N1 /\\ f(n) >= N2`;;\n\nlet SEQ_CAUCHY = `!f. cauchy f <=> convergent f`;;\n\nlet SEQ_LE = `!f g l m. f --> l /\\ g --> m /\\ (?N. !n. n >= N ==> f(n) <= g(n))\n ==> l <= m`;;\n\nlet SEQ_LE_0 = `!f g. f --> &0 /\\ (?N. !n. n >= N ==> abs(g n) <= abs(f n))\n ==> g --> &0`;;\n\nlet SEQ_SUC = `!f l. f --> l <=> (\\n. f(SUC n)) --> l`;;\n\nlet SEQ_ABS = `!f. (\\n. abs(f n)) --> &0 <=> f --> &0`;;\n\nlet SEQ_ABS_IMP = `!f l. f --> l ==> (\\n. abs(f n)) --> abs(l)`;;\n\nlet SEQ_INV0 = `!f. (!y. ?N. !n. n >= N ==> f(n) > y)\n ==> (\\n. inv(f n)) --> &0`;;\n\nlet SEQ_POWER_ABS = `!c. abs(c) < &1 ==> (\\n. abs(c) pow n) --> &0`;;\n\nlet SEQ_POWER = `!c. abs(c) < &1 ==> (\\n. c pow n) --> &0`;;\n\nlet SEQ_HARMONIC = `!a. (\\n. a / &n) --> &0`;;\n\nlet SEQ_SUBSEQ = `!f l. f --> l ==> !a b. ~(a = 0) ==> (\\n. f(a * n + b)) --> l`;;\n\nlet SEQ_POW = `!f l. (f --> l) ==> !n. (\\i. f(i) pow n) --> l pow n`;;\n\nlet NEST_LEMMA = `!f g. (!n. f(SUC n) >= f(n)) /\\\n (!n. g(SUC n) <= g(n)) /\\\n (!n. f(n) <= g(n)) ==>\n ?l m. l <= m /\\ ((!n. f(n) <= l) /\\ f --> l) /\\\n ((!n. m <= g(n)) /\\ g --> m)`;;\n\nlet NEST_LEMMA_UNIQ = `!f g. (!n. f(SUC n) >= f(n)) /\\\n (!n. g(SUC n) <= g(n)) /\\\n (!n. f(n) <= g(n)) /\\\n (\\n. f(n) - g(n)) --> &0 ==>\n ?l. ((!n. f(n) <= l) /\\ f --> l) /\\\n ((!n. l <= g(n)) /\\ g --> l)`;;\n\nlet BOLZANO_LEMMA = `!P. (!a b c. a <= b /\\ b <= c /\\ P(a,b) /\\ P(b,c) ==> P(a,c)) /\\\n (!x. ?d. &0 < d /\\ !a b. a <= x /\\ x <= b /\\ (b - a) < d ==> P(a,b))\n ==> !a b. a <= b ==> P(a,b)`;;\n\nlet BOLZANO_LEMMA_ALT = `!P. (!a b c. a <= b /\\ b <= c /\\ P a b /\\ P b c ==> P a c) /\\\n (!x. ?d. &0 < d /\\ (!a b. a <= x /\\ x <= b /\\ b - a < d ==> P a b))\n ==> !a b. a <= b ==> P a b`;;\n\nlet sums = new_definition\n `f sums s <=> (\\n. sum(0,n) f) --> s`;;\n\nlet summable = new_definition(\n `summable f <=> ?s. f sums s`);;\n\nlet suminf = new_definition(\n `suminf f = @s. f sums s`);;\n\nlet SUM_SUMMABLE = `!f l. f sums l ==> summable f`;;\n\nlet SUMMABLE_SUM = `!f. summable f ==> f sums (suminf f)`;;\n\nlet SUM_UNIQ = `!f x. f sums x ==> (x = suminf f)`;;\n\nlet SER_UNIQ = `!f x y. f sums x /\\ f sums y ==> (x = y)`;;\n\nlet SER_0 = `!f n. (!m. n <= m ==> (f(m) = &0)) ==>\n f sums (sum(0,n) f)`;;\n\nlet SER_POS_LE = `!f n. summable f /\\ (!m. n <= m ==> &0 <= f(m))\n ==> sum(0,n) f <= suminf f`;;\n\nlet SER_POS_LT = `!f n. summable f /\\ (!m. n <= m ==> &0 < f(m))\n ==> sum(0,n) f < suminf f`;;\n\nlet SER_GROUP = `!f k. summable f /\\ 0 < k ==>\n (\\n. sum(n * k,k) f) sums (suminf f)`;;\n\nlet SER_PAIR = `!f. summable f ==> (\\n. sum(2 * n,2) f) sums (suminf f)`;;\n\nlet SER_OFFSET = `!f. summable f ==> !k. (\\n. f(n + k)) sums (suminf f - sum(0,k) f)`;;\n\nlet SER_OFFSET_REV = `!f k. summable(\\n. f(n + k)) ==>\n f sums (sum(0,k) f) + suminf (\\n. f(n + k))`;;\n\nlet SER_POS_LT_PAIR = `!f n. summable f /\\\n (!d. &0 < (f(n + (2 * d))) +\n f(n + ((2 * d) + 1)))\n ==> sum(0,n) f < suminf f`;;\n\nlet SER_ADD = `!x x0 y y0. x sums x0 /\\ y sums y0 ==> (\\n. x(n) + y(n)) sums (x0 + y0)`;;\n\nlet SER_CMUL = `!x x0 c. x sums x0 ==> (\\n. c * x(n)) sums (c * x0)`;;\n\nlet SER_NEG = `!x x0. x sums x0 ==> (\\n. --(x n)) sums --x0`;;\n\nlet SER_SUB = `!x x0 y y0. x sums x0 /\\ y sums y0 ==> (\\n. x(n) - y(n)) sums (x0 - y0)`;;\n\nlet SER_CDIV = `!x x0 c. x sums x0 ==> (\\n. x(n) / c) sums (x0 / c)`;;\n\nlet SER_CAUCHY = `!f. summable f <=>\n !e. &0 < e ==> ?N. !m n. m >= N ==> abs(sum(m,n) f) < e`;;\n\nlet SER_ZERO = `!f. summable f ==> f --> &0`;;\n\nlet SER_COMPAR = `!f g. (?N. !n. n >= N ==> abs(f(n)) <= g(n)) /\\ summable g ==>\n summable f`;;\n\nlet SER_COMPARA = `!f g. (?N. !n. n >= N ==> abs(f(n)) <= g(n)) /\\ summable g ==>\n summable (\\k. abs(f k))`;;\n\nlet SER_LE = `!f g. (!n. f(n) <= g(n)) /\\ summable f /\\ summable g\n ==> suminf f <= suminf g`;;\n\nlet SER_LE2 = `!f g. (!n. abs(f n) <= g(n)) /\\ summable g ==>\n summable f /\\ suminf f <= suminf g`;;\n\nlet SER_ACONV = `!f. summable (\\n. abs(f n)) ==> summable f`;;\n\nlet SER_ABS = `!f. summable(\\n. abs(f n)) ==> abs(suminf f) <= suminf(\\n. abs(f n))`;;\n\nlet GP_FINITE = `!x. ~(x = &1) ==>\n !n. (sum(0,n) (\\n. x pow n) = ((x pow n) - &1) / (x - &1))`;;\n\nlet GP = `!x. abs(x) < &1 ==> (\\n. x pow n) sums inv(&1 - x)`;;\n\nlet ABS_NEG_LEMMA = `!c x y. c <= &0 ==> abs(x) <= c * abs(y) ==> (x = &0)`;;\n\nlet SER_RATIO = `!f c N. c < &1 /\\\n (!n. n >= N ==> abs(f(SUC n)) <= c * abs(f(n))) ==>\n summable f`;;\n\nlet SEQ_TRUNCATION = `!f l n b.\n f sums l /\\ (!m. abs(sum(n,m) f) <= b)\n ==> abs(l - sum(0,n) f) <= b`;;\n\nparse_as_infix (\"tends_real_real\",(12,\"right\"));;\n\nparse_as_infix (\"diffl\",(12,\"right\"));;\nparse_as_infix (\"contl\",(12,\"right\"));;\nparse_as_infix (\"differentiable\",(12,\"right\"));;\n\nlet tends_real_real = new_definition\n `(f tends_real_real l)(x0) <=>\n (f tends l)(mtop(mr1),tendsto(mr1,x0))`;;\n\noverride_interface (\"-->\",`(tends_real_real)`);;\n\nlet LIM = `!f y0 x0. (f --> y0)(x0) <=>\n !e. &0 < e ==>\n ?d. &0 < d /\\ !x. &0 < abs(x - x0) /\\ abs(x - x0) < d ==>\n abs(f(x) - y0) < e`;;\n\nlet LIM_CONST = `!k x. ((\\x. k) --> k)(x)`;;\n\nlet LIM_ADD = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) ==>\n ((\\x. f(x) + g(x)) --> (l + m))(x)`;;\n\nlet LIM_MUL = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) ==>\n ((\\x. f(x) * g(x)) --> (l * m))(x)`;;\n\nlet LIM_NEG = `!f l. (f --> l)(x) <=> ((\\x. --(f(x))) --> --l)(x)`;;\n\nlet LIM_INV = `!f l. (f --> l)(x) /\\ ~(l = &0) ==>\n ((\\x. inv(f(x))) --> inv l)(x)`;;\n\nlet LIM_SUB = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) ==>\n ((\\x. f(x) - g(x)) --> (l - m))(x)`;;\n\nlet LIM_DIV = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) /\\ ~(m = &0) ==>\n ((\\x. f(x) / g(x)) --> (l / m))(x)`;;\n\nlet LIM_NULL = `!f l x. (f --> l)(x) <=> ((\\x. f(x) - l) --> &0)(x)`;;\n\nlet LIM_SUM = `!f l m n x.\n (!r. m <= r /\\ r < m + n ==> (f r --> l r)(x))\n ==> ((\\x. sum(m,n) (\\r. f r x)) --> sum(m,n) l)(x)`;;\n\nlet LIM_X = `!x0. ((\\x. x) --> x0)(x0)`;;\n\nlet LIM_UNIQ = `!f l m x. (f --> l)(x) /\\ (f --> m)(x) ==> (l = m)`;;\n\nlet LIM_EQUAL = `!f g l x0. (!x. ~(x = x0) ==> (f x = g x)) ==>\n ((f --> l)(x0) <=> (g --> l)(x0))`;;\n\nlet LIM_TRANSFORM = `!f g x0 l. ((\\x. f(x) - g(x)) --> &0)(x0) /\\ (g --> l)(x0)\n ==> (f --> l)(x0)`;;\n\nlet diffl = new_definition\n `(f diffl l)(x) <=> ((\\h. (f(x+h) - f(x)) / h) --> l)(&0)`;;\n\nlet contl = new_definition\n `f contl x <=> ((\\h. f(x + h)) --> f(x))(&0)`;;\n\nlet differentiable = new_definition\n `f differentiable x <=> ?l. (f diffl l)(x)`;;\n\nlet DIFF_UNIQ = `!f l m x. (f diffl l)(x) /\\ (f diffl m)(x) ==> (l = m)`;;\n\nlet DIFF_CONT = `!f l x. (f diffl l)(x) ==> f contl x`;;\n\nlet CONTL_LIM = `!f x. f contl x <=> (f --> f(x))(x)`;;\n\nlet CONT_X = `!x. (\\x. x) contl x`;;\n\nlet CONT_CONST = `!x. (\\x. k) contl x`;;\n\nlet CONT_ADD = `!x. f contl x /\\ g contl x ==> (\\x. f(x) + g(x)) contl x`;;\n\nlet CONT_MUL = `!x. f contl x /\\ g contl x ==> (\\x. f(x) * g(x)) contl x`;;\n\nlet CONT_NEG = `!x. f contl x ==> (\\x. --(f(x))) contl x`;;\n\nlet CONT_INV = `!x. f contl x /\\ ~(f x = &0) ==> (\\x. inv(f(x))) contl x`;;\n\nlet CONT_SUB = `!x. f contl x /\\ g contl x ==> (\\x. f(x) - g(x)) contl x`;;\n\nlet CONT_DIV = `!x. f contl x /\\ g contl x /\\ ~(g x = &0) ==>\n (\\x. f(x) / g(x)) contl x`;;\n\nlet CONT_ABS = `!f x. f contl x ==> (\\x. abs(f x)) contl x`;;\n\nlet CONT_COMPOSE = `!f g x. f contl x /\\ g contl (f x) ==> (\\x. g(f x)) contl x`;;\n\nlet IVT = `!f a b y. a <= b /\\\n (f(a) <= y /\\ y <= f(b)) /\\\n (!x. a <= x /\\ x <= b ==> f contl x)\n ==> (?x. a <= x /\\ x <= b /\\ (f(x) = y))`;;\n\nlet IVT2 = `!f a b y. (a <= b) /\\ (f(b) <= y /\\ y <= f(a)) /\\\n (!x. a <= x /\\ x <= b ==> f contl x) ==>\n ?x. a <= x /\\ x <= b /\\ (f(x) = y)`;;\n\nlet DIFF_CONST = `!k x. ((\\x. k) diffl &0)(x)`;;\n\nlet DIFF_ADD = `!f g l m x. (f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) + g(x)) diffl (l + m))(x)`;;\n\nlet DIFF_MUL = `!f g l m x. (f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) * g(x)) diffl ((l * g(x)) + (m * f(x))))(x)`;;\n\nlet DIFF_CMUL = `!f c l x. (f diffl l)(x) ==> ((\\x. c * f(x)) diffl (c * l))(x)`;;\n\nlet DIFF_NEG = `!f l x. (f diffl l)(x) ==> ((\\x. --(f x)) diffl --l)(x)`;;\n\nlet DIFF_SUB = `!f g l m x. (f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) - g(x)) diffl (l - m))(x)`;;\n\nlet DIFF_CARAT = `!f l x. (f diffl l)(x) <=>\n ?g. (!z. f(z) - f(x) = g(z) * (z - x)) /\\ g contl x /\\ (g(x) = l)`;;\n\nlet DIFF_CHAIN = `!f g l m x.\n (f diffl l)(g x) /\\ (g diffl m)(x) ==> ((\\x. f(g x)) diffl (l * m))(x)`;;\n\nlet DIFF_X = `!x. ((\\x. x) diffl &1)(x)`;;\n\nlet DIFF_POW = `!n x. ((\\x. x pow n) diffl (&n * (x pow (n - 1))))(x)`;;\n\nlet DIFF_XM1 = `!x. ~(x = &0) ==> ((\\x. inv(x)) diffl (--(inv(x) pow 2)))(x)`;;\n\nlet DIFF_INV = `!f l x. (f diffl l)(x) /\\ ~(f(x) = &0) ==>\n ((\\x. inv(f x)) diffl --(l / (f(x) pow 2)))(x)`;;\n\nlet DIFF_DIV = `!f g l m. (f diffl l)(x) /\\ (g diffl m)(x) /\\ ~(g(x) = &0) ==>\n ((\\x. f(x) / g(x)) diffl (((l * g(x)) - (m * f(x))) / (g(x) pow 2)))(x)`;;\n\nlet DIFF_SUM = `!f f' m n x. (!r. m <= r /\\ r < (m + n)\n ==> ((\\x. f r x) diffl (f' r x))(x))\n ==> ((\\x. sum(m,n)(\\n. f n x)) diffl (sum(m,n) (\\r. f' r x)))(x)`;;\n\nlet CONT_BOUNDED = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. !x. a <= x /\\ x <= b ==> f(x) <= M`;;\n\nlet CONT_BOUNDED_ABS = `!f a b. (!x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. !x. a <= x /\\ x <= b ==> abs(f(x)) <= M`;;\n\nlet CONT_HASSUP = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. (!x. a <= x /\\ x <= b ==> f(x) <= M) /\\\n (!N. N < M ==> ?x. a <= x /\\ x <= b /\\ N < f(x))`;;\n\nlet CONT_ATTAINS = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. (!x. a <= x /\\ x <= b ==> f(x) <= M) /\\\n (?x. a <= x /\\ x <= b /\\ (f(x) = M))`;;\n\nlet CONT_ATTAINS2 = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. (!x. a <= x /\\ x <= b ==> M <= f(x)) /\\\n (?x. a <= x /\\ x <= b /\\ (f(x) = M))`;;\n\nlet CONT_ATTAINS_ALL = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?L M. (!x. a <= x /\\ x <= b ==> L <= f(x) /\\ f(x) <= M) /\\\n !y. L <= y /\\ y <= M ==> ?x. a <= x /\\ x <= b /\\ (f(x) = y)`;;\n\nlet DIFF_LINC = `!f x l. (f diffl l)(x) /\\ &0 < l ==>\n ?d. &0 < d /\\ !h. &0 < h /\\ h < d ==> f(x) < f(x + h)`;;\n\nlet DIFF_LDEC = `!f x l. (f diffl l)(x) /\\ l < &0 ==>\n ?d. &0 < d /\\ !h. &0 < h /\\ h < d ==> f(x) < f(x - h)`;;\n\nlet DIFF_LMAX = `!f x l. (f diffl l)(x) /\\\n (?d. &0 < d /\\ (!y. abs(x - y) < d ==> f(y) <= f(x))) ==> (l = &0)`;;\n\nlet DIFF_LMIN = `!f x l. (f diffl l)(x) /\\\n (?d. &0 < d /\\ (!y. abs(x - y) < d ==> f(x) <= f(y))) ==> (l = &0)`;;\n\nlet DIFF_LCONST = `!f x l. (f diffl l)(x) /\\\n (?d. &0 < d /\\ (!y. abs(x - y) < d ==> (f(y) = f(x)))) ==> (l = &0)`;;\n\nlet INTERVAL_LEMMA_LT = `!a b x. a < x /\\ x < b ==>\n ?d. &0 < d /\\ !y. abs(x - y) < d ==> a < y /\\ y < b`;;\n\nlet INTERVAL_LEMMA = `!a b x. a < x /\\ x < b ==>\n ?d. &0 < d /\\ !y. abs(x - y) < d ==> a <= y /\\ y <= b`;;\n\nlet ROLLE = `!f a b. a < b /\\\n (f(a) = f(b)) /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> f differentiable x)\n ==> ?z. a < z /\\ z < b /\\ (f diffl &0)(z)`;;\n\nlet MVT_LEMMA = `!(f:real->real) a b.\n (\\x. f(x) - (((f(b) - f(a)) / (b - a)) * x))(a) =\n (\\x. f(x) - (((f(b) - f(a)) / (b - a)) * x))(b)`;;\n\nlet MVT = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> f differentiable x)\n ==> ?l z. a < z /\\ z < b /\\ (f diffl l)(z) /\\\n (f(b) - f(a) = (b - a) * l)`;;\n\nlet MVT_ALT = `!f f' a b.\n a < b /\\ (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x))\n ==> ?z. a < z /\\ z < b /\\ (f b - f a = (b - a) * f'(z))`;;\n\nlet DIFF_ISCONST_END = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> (f diffl &0)(x))\n ==> (f b = f a)`;;\n\nlet DIFF_ISCONST = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> (f diffl &0)(x))\n ==> !x. a <= x /\\ x <= b ==> (f x = f a)`;;\n\nlet DIFF_ISCONST_END_SIMPLE = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl &0)(x))\n ==> (f b = f a)`;;\n\nlet DIFF_ISCONST_ALL = `!f x y. (!x. (f diffl &0)(x)) ==> (f(x) = f(y))`;;\n\nlet INTERVAL_ABS = REAL_ARITH\n `!x z d. (x - d) <= z /\\ z <= (x + d) <=> abs(z - x) <= d`;;\n\nlet CONT_INJ_LEMMA = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) ==>\n ~(!z. abs(z - x) <= d ==> f(z) <= f(x))`;;\n\nlet CONT_INJ_LEMMA2 = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) ==>\n ~(!z. abs(z - x) <= d ==> f(x) <= f(z))`;;\n\nlet CONT_INJ_RANGE = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) ==>\n ?e. &0 < e /\\\n (!y. abs(y - f(x)) <= e ==> ?z. abs(z - x) <= d /\\ (f z = y))`;;\n\nlet CONT_INVERSE = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z)\n ==> g contl (f x)`;;\n\nlet DIFF_INVERSE = `!f g l x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) /\\\n (f diffl l)(x) /\\\n ~(l = &0)\n ==> (g diffl (inv l))(f x)`;;\n\nlet DIFF_INVERSE_LT = `!f g l x d. &0 < d /\\\n (!z. abs(z - x) < d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) < d ==> f contl z) /\\\n (f diffl l)(x) /\\\n ~(l = &0)\n ==> (g diffl (inv l))(f x)`;;\n\nlet IVT_DERIVATIVE_0 = `!f f' a b.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n f'(a) > &0 /\\ f'(b) < &0\n ==> ?z. a < z /\\ z < b /\\ (f'(z) = &0)`;;\n\nlet IVT_DERIVATIVE_POS = `!f f' a b y.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n f'(a) > y /\\ f'(b) < y\n ==> ?z. a < z /\\ z < b /\\ (f'(z) = y)`;;\n\nlet IVT_DERIVATIVE_NEG = `!f f' a b y.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n f'(a) < y /\\ f'(b) > y\n ==> ?z. a < z /\\ z < b /\\ (f'(z) = y)`;;\n\nlet SEQ_CONT_UNIFORM = `!s f x0. (!e. &0 < e\n ==> ?N d. &0 < d /\\\n !x n. abs(x - x0) < d /\\ n >= N\n ==> abs(s n x - f(x)) < e) /\\\n (?N:num. !n. n >= N ==> (s n) contl x0)\n ==> f contl x0`;;\n\nlet SER_COMPARA_UNIFORM = `!s x0 g.\n (?N d. &0 < d /\\\n !n x. abs(x - x0) < d /\\ n >= N\n ==> abs(s x n) <= g n) /\\ summable g\n ==> ?f d. &0 < d /\\\n !e. &0 < e\n ==> ?N. !x n. abs(x - x0) < d /\\ n >= N\n ==> abs(sum(0,n) (s x) - f(x)) < e`;;\n\nlet SER_COMPARA_UNIFORM_WEAK = `!s x0 g.\n (?N d. &0 < d /\\\n !n x. abs(x - x0) < d /\\ n >= N\n ==> abs(s x n) <= g n) /\\ summable g\n ==> ?f. !e. &0 < e\n ==> ?N d. &0 < d /\\\n !x n. abs(x - x0) < d /\\ n >= N\n ==> abs(sum(0,n) (s x) - f(x)) < e`;;\n\nlet CONTL = `!f x. f contl x <=>\n !e. &0 < e ==> ?d. &0 < d /\\ !x'. abs(x' - x) < d\n ==> abs(f(x') - f(x)) < e`;;\n\nlet CONTL_SEQ = `!f x l. f contl l /\\ x tends_num_real l\n\n ==> (\\n. f(x n)) tends_num_real f(l)`;;\n\nlet SUP_INTERVAL = `!P a b.\n (?x. a <= x /\\ x <= b /\\ P x)\n ==> ?s. a <= s /\\ s <= b /\\\n !y. y < s <=> (?x. a <= x /\\ x <= b /\\ P x /\\ y < x)`;;\n\nlet CONT_UNIFORM = `!f a b. a <= b /\\ (!x. a <= x /\\ x <= b ==> f contl x)\n ==> !e. &0 < e ==> ?d. &0 < d /\\\n !x y. a <= x /\\ x <= b /\\\n a <= y /\\ y <= b /\\\n abs(x - y) < d\n ==> abs(f(x) - f(y)) < e`;;\n\nlet CONT_UNIFORM_STRONG = `!f a b. (!x. a <= x /\\ x <= b ==> f contl x)\n ==> !e. &0 < e\n ==> ?d. &0 < d /\\\n !x y. (a <= x /\\ x <= b \\/ a <= y /\\ y <= b) /\\\n abs(x - y) < d\n ==> abs(f(x) - f(y)) < e`;;\n\nremove_interface \"-->\";;" }, { "theorem_id": 53, "title": "066_sum_of_a_geometric_series", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Complex Transcendental Functions\\\n\ntext\\By John Harrison et al. Ported from HOL Light by L C Paulson (2015)\\\n\ntheory Complex_Transcendental\nimports\n Complex_Analysis_Basics Summation_Tests \"HOL-Library.Periodic_Fun\"\nbegin\n\nsubsection\\Möbius transformations\\\n\ndefinition\\<^marker>\\tag important\\ \"moebius a b c d \\ (\\z. (a*z+b) / (c*z+d :: 'a :: field))\"\n\ntheorem moebius_inverse:\n assumes \"a * d \\ b * c\" \"c * z + d \\ 0\"\n shows \"moebius d (-b) (-c) a (moebius a b c d z) = z\"\n by sorry\n\nlemma moebius_inverse':\n assumes \"a * d \\ b * c\" \"c * z - a \\ 0\"\n shows \"moebius a b c d (moebius d (-b) (-c) a z) = z\"\n by sorry\n\nlemma cmod_add_real_less:\n assumes \"Im z \\ 0\" \"r\\0\"\n shows \"cmod (z + r) < cmod z + \\r\\\"\n by sorry\n\nlemma cmod_diff_real_less: \"Im z \\ 0 \\ x\\0 \\ cmod (z - x) < cmod z + \\x\\\"\n by sorry\n\nlemma cmod_square_less_1_plus:\n assumes \"Im z = 0 \\ \\Re z\\ < 1\"\n shows \"(cmod z)\\<^sup>2 < 1 + cmod (1 - z\\<^sup>2)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\The Exponential Function\\\n\nlemma exp_npi_numeral: \"exp (\\ * pi * Num.numeral n) = (-1) ^ Num.numeral n\"\n by sorry\n\nlemma norm_exp_i_times [simp]: \"norm (exp(\\ * of_real y)) = 1\"\n by sorry\n\nlemma norm_exp_imaginary: \"norm(exp z) = 1 \\ Re z = 0\"\n by sorry\n\nlemma field_differentiable_within_exp: \"exp field_differentiable (at z within s)\"\n by sorry\n\nlemma continuous_within_exp:\n fixes z::\"'a::{real_normed_field,banach}\"\n shows \"continuous (at z within s) exp\"\n by sorry\n\nlemma holomorphic_on_exp [holomorphic_intros]: \"exp holomorphic_on s\"\n by sorry\n\nlemma holomorphic_on_exp' [holomorphic_intros]:\n \"f holomorphic_on s \\ (\\x. exp (f x)) holomorphic_on s\"\n by sorry\n\nlemma exp_analytic_on [analytic_intros]:\n assumes \"f analytic_on A\"\n shows \"(\\z. exp (f z)) analytic_on A\"\n by sorry\n\nlemma\n assumes \"\\w. w \\ A \\ exp (f w) = w\"\n assumes \"f holomorphic_on A\" \"z \\ A\" \"open A\"\n shows deriv_complex_logarithm: \"deriv f z = 1 / z\"\n and has_field_derivative_complex_logarithm: \"(f has_field_derivative 1 / z) (at z)\"\n by sorry\n \nsubsection\\Euler and de Moivre formulas\\\n\ntext\\The sine series times \\<^term>\\i\\\\\nlemma sin_i_eq: \"(\\n. (\\ * sin_coeff n) * z^n) sums (\\ * sin z)\"\n by sorry\n\ntheorem exp_Euler: \"exp(\\ * z) = cos(z) + \\ * sin(z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ exp_minus_Euler: \"exp(-(\\ * z)) = cos(z) - \\ * sin(z)\"\n by sorry\n\nlemma sin_exp_eq: \"sin z = (exp(\\ * z) - exp(-(\\ * z))) / (2*\\)\"\n by sorry\n\nlemma sin_exp_eq': \"sin z = \\ * (exp(-(\\ * z)) - exp(\\ * z)) / 2\"\n by sorry\n\nlemma cos_exp_eq: \"cos z = (exp(\\ * z) + exp(-(\\ * z))) / 2\"\n by sorry\n\ntheorem Euler: \"exp(z) = of_real(exp(Re z)) *\n (of_real(cos(Im z)) + \\ * of_real(sin(Im z)))\"\n by sorry\n\nlemma Re_sin: \"Re(sin z) = sin(Re z) * (exp(Im z) + exp(-(Im z))) / 2\"\n by sorry\n\nlemma Im_sin: \"Im(sin z) = cos(Re z) * (exp(Im z) - exp(-(Im z))) / 2\"\n by sorry\n\nlemma Re_cos: \"Re(cos z) = cos(Re z) * (exp(Im z) + exp(-(Im z))) / 2\"\n by sorry\n\nlemma Im_cos: \"Im(cos z) = sin(Re z) * (exp(-(Im z)) - exp(Im z)) / 2\"\n by sorry\n\nlemma Re_sin_pos: \"0 < Re z \\ Re z < pi \\ Re (sin z) > 0\"\n by sorry\n\nlemma Im_sin_nonneg: \"Re z = 0 \\ 0 \\ Im z \\ 0 \\ Im (sin z)\"\n by sorry\n\nlemma Im_sin_nonneg2: \"Re z = pi \\ Im z \\ 0 \\ 0 \\ Im (sin z)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relationships between real and complex trigonometric and hyperbolic functions\\\n\nlemma real_sin_eq [simp]: \"Re(sin(of_real x)) = sin x\"\n by sorry\n\nlemma real_cos_eq [simp]: \"Re(cos(of_real x)) = cos x\"\n by sorry\n\nlemma DeMoivre: \"(cos z + \\ * sin z) ^ n = cos(n * z) + \\ * sin(n * z)\"\n by sorry\n\nlemma exp_cnj: \"cnj (exp z) = exp (cnj z)\"\n by sorry\n\nlemma cnj_sin: \"cnj(sin z) = sin(cnj z)\"\n by sorry\n\nlemma cnj_cos: \"cnj(cos z) = cos(cnj z)\"\n by sorry\n\nlemma field_differentiable_at_sin: \"sin field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_sin: \"sin field_differentiable (at z within S)\"\n by sorry\n\nlemma field_differentiable_at_cos: \"cos field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_cos: \"cos field_differentiable (at z within S)\"\n by sorry\n\nlemma holomorphic_on_sin: \"sin holomorphic_on S\"\n by sorry\n\nlemma holomorphic_on_cos: \"cos holomorphic_on S\"\n by sorry\n\nlemma holomorphic_on_sin' [holomorphic_intros]:\n assumes \"f holomorphic_on A\"\n shows \"(\\x. sin (f x)) holomorphic_on A\"\n by sorry\n\nlemma holomorphic_on_cos' [holomorphic_intros]:\n assumes \"f holomorphic_on A\"\n shows \"(\\x. cos (f x)) holomorphic_on A\"\n by sorry\n\nlemma analytic_on_sin [analytic_intros]: \"f analytic_on A \\ (\\w. sin (f w)) analytic_on A\"\n and analytic_on_cos [analytic_intros]: \"f analytic_on A \\ (\\w. cos (f w)) analytic_on A\"\n and analytic_on_sinh [analytic_intros]: \"f analytic_on A \\ (\\w. sinh (f w)) analytic_on A\"\n and analytic_on_cosh [analytic_intros]: \"f analytic_on A \\ (\\w. cosh (f w)) analytic_on A\"\n by sorry\n\nlemma analytic_on_tan [analytic_intros]:\n \"f analytic_on A \\ (\\z. z \\ A \\ cos (f z) \\ 0) \\ (\\w. tan (f w)) analytic_on A\"\n and analytic_on_cot [analytic_intros]:\n \"f analytic_on A \\ (\\z. z \\ A \\ sin (f z) \\ 0) \\ (\\w. cot (f w)) analytic_on A\"\n and analytic_on_tanh [analytic_intros]:\n \"f analytic_on A \\ (\\z. z \\ A \\ cosh (f z) \\ 0) \\ (\\w. tanh (f w)) analytic_on A\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\More on the Polar Representation of Complex Numbers\\\n\nlemma exp_Complex: \"exp(Complex r t) = of_real(exp r) * Complex (cos t) (sin t)\"\n by sorry\n\nlemma exp_eq_1: \"exp z = 1 \\ Re(z) = 0 \\ (\\n::int. Im(z) = of_int (2 * n) * pi)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma exp_eq: \"exp w = exp z \\ (\\n::int. w = z + (of_int (2 * n) * pi) * \\)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma exp_complex_eqI: \"\\Im w - Im z\\ < 2*pi \\ exp w = exp z \\ w = z\"\n by sorry\n\nlemma exp_integer_2pi:\n assumes \"n \\ \\\"\n shows \"exp((2 * n * pi) * \\) = 1\"\n by sorry\n\nlemma exp_plus_2pin [simp]: \"exp (z + \\ * (of_int n * (of_real pi * 2))) = exp z\"\n by sorry\n\nlemma exp_2pi_1_int [simp]: \"exp (\\ * (of_int j * (of_real pi * 2))) = 1\"\n by sorry\n\nlemma exp_2pi_1_nat [simp]: \"exp (\\ * (of_nat j * (of_real pi * 2))) = 1\"\n by sorry\n\nlemma exp_integer_2pi_plus1:\n assumes \"n \\ \\\"\n shows \"exp(((2 * n + 1) * pi) * \\) = - 1\"\n by sorry\n\nlemma inj_on_exp_pi:\n fixes z::complex shows \"inj_on exp (ball z pi)\"\n by sorry\n\nlemma cmod_add_squared:\n fixes r1 r2::real\n shows \"(cmod (r1 * exp (\\ * \\1) + r2 * exp (\\ * \\2)))\\<^sup>2 = r1\\<^sup>2 + r2\\<^sup>2 + 2 * r1 * r2 * cos (\\1 - \\2)\" (is \"(cmod (?z1 + ?z2))\\<^sup>2 = ?rhs\")\n by sorry\n\nlemma cmod_diff_squared:\n fixes r1 r2::real\n shows \"(cmod (r1 * exp (\\ * \\1) - r2 * exp (\\ * \\2)))\\<^sup>2 = r1\\<^sup>2 + r2\\<^sup>2 - 2*r1*r2*cos (\\1 - \\2)\" \n by sorry\n\nlemma polar_convergence:\n fixes R::real\n assumes \"\\j. r j > 0\" \"R > 0\"\n shows \"((\\j. r j * exp (\\ * \\ j)) \\ (R * exp (\\ * \\))) \\\n (r \\ R) \\ (\\k. (\\j. \\ j - of_int (k j) * (2 * pi)) \\ \\)\" (is \"(?z \\ ?Z) = ?rhs\")\n by sorry\n\nlemma exp_i_ne_1:\n assumes \"0 < x\" \"x < 2*pi\"\n shows \"exp(\\ * of_real x) \\ 1\"\n by sorry\n\nlemma sin_eq_0:\n fixes z::complex\n shows \"sin z = 0 \\ (\\n::int. z = of_real(n * pi))\"\n by sorry\n\nlemma cos_eq_0:\n fixes z::complex\n shows \"cos z = 0 \\ (\\n::int. z = complex_of_real(n * pi) + of_real pi/2)\"\n by sorry\n\nlemma cos_eq_1:\n fixes z::complex\n shows \"cos z = 1 \\ (\\n::int. z = complex_of_real(2 * n * pi))\"\n by sorry\n\nlemma csin_eq_1:\n fixes z::complex\n shows \"sin z = 1 \\ (\\n::int. z = of_real(2 * n * pi) + of_real pi/2)\"\n by sorry\n\nlemma csin_eq_minus1:\n fixes z::complex\n shows \"sin z = -1 \\ (\\n::int. z = complex_of_real(2 * n * pi) + 3/2*pi)\"\n (is \"_ = ?rhs\")\n by sorry\n\nlemma ccos_eq_minus1:\n fixes z::complex\n shows \"cos z = -1 \\ (\\n::int. z = complex_of_real(2 * n * pi) + pi)\"\n by sorry\n\nlemma sin_eq_1: \"sin x = 1 \\ (\\n::int. x = (2 * n + 1 / 2) * pi)\"\n (is \"_ = ?rhs\")\n by sorry\n\nlemma sin_eq_minus1: \"sin x = -1 \\ (\\n::int. x = (2*n + 3/2) * pi)\" (is \"_ = ?rhs\")\n by sorry\n\nlemma cos_eq_minus1: \"cos x = -1 \\ (\\n::int. x = (2*n + 1) * pi)\"\n (is \"_ = ?rhs\")\n by sorry\n\nlemma cos_gt_neg1:\n assumes \"(t::real) \\ {-pi<.. -1\"\n by sorry\n\nlemma dist_exp_i_1: \"norm(exp(\\ * of_real t) - 1) = 2 * \\sin(t / 2)\\\"\n by sorry\n\nlemma sin_cx_2pi [simp]: \"\\z = of_int m; even m\\ \\ sin (z * complex_of_real pi) = 0\"\n by sorry\n\nlemma cos_cx_2pi [simp]: \"\\z = of_int m; even m\\ \\ cos (z * complex_of_real pi) = 1\"\n by sorry\n\nlemma complex_sin_eq:\n fixes w :: complex\n shows \"sin w = sin z \\ (\\n \\ \\. w = z + of_real(2*n*pi) \\ w = -z + of_real((2*n + 1)*pi))\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma complex_cos_eq:\n fixes w :: complex\n shows \"cos w = cos z \\ (\\n \\ \\. w = z + of_real(2*n*pi) \\ w = -z + of_real(2*n*pi))\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma sin_eq:\n \"sin x = sin y \\ (\\n \\ \\. x = y + 2*n*pi \\ x = -y + (2*n + 1)*pi)\"\n by sorry\n\nlemma cos_eq:\n \"cos x = cos y \\ (\\n \\ \\. x = y + 2*n*pi \\ x = -y + 2*n*pi)\"\n by sorry\n\nlemma sinh_complex:\n fixes z :: complex\n shows \"(exp z - inverse (exp z)) / 2 = -\\ * sin(\\ * z)\"\n by sorry\n\nlemma sin_i_times:\n fixes z :: complex\n shows \"sin(\\ * z) = \\ * ((exp z - inverse (exp z)) / 2)\"\n by sorry\n\nlemma sinh_real:\n fixes x :: real\n shows \"of_real((exp x - inverse (exp x)) / 2) = -\\ * sin(\\ * of_real x)\"\n by sorry\n\nlemma cosh_complex:\n fixes z :: complex\n shows \"(exp z + inverse (exp z)) / 2 = cos(\\ * z)\"\n by sorry\n\nlemma cosh_real:\n fixes x :: real\n shows \"of_real((exp x + inverse (exp x)) / 2) = cos(\\ * of_real x)\"\n by sorry\n\nlemmas cos_i_times = cosh_complex [symmetric]\n\nlemma norm_cos_squared:\n \"norm(cos z) ^ 2 = cos(Re z) ^ 2 + (exp(Im z) - inverse(exp(Im z))) ^ 2 / 4\"\n by sorry\n\nlemma norm_sin_squared:\n \"norm(sin z) ^ 2 = (exp(2 * Im z) + inverse(exp(2 * Im z)) - 2 * cos(2 * Re z)) / 4\"\n by sorry\n\nlemma exp_uminus_Im: \"exp (- Im z) \\ exp (cmod z)\"\n by sorry\n\nlemma norm_cos_le:\n fixes z::complex\n shows \"norm(cos z) \\ exp(norm z)\"\n by sorry\n\nlemma norm_cos_plus1_le:\n fixes z::complex\n shows \"norm(1 + cos z) \\ 2 * exp(norm z)\"\n by sorry\n\nlemma sinh_conv_sin: \"sinh z = -\\ * sin (\\*z)\"\n by sorry\n\nlemma cosh_conv_cos: \"cosh z = cos (\\*z)\"\n by sorry\n\nlemma tanh_conv_tan: \"tanh z = -\\ * tan (\\*z)\"\n by sorry\n\nlemma sin_conv_sinh: \"sin z = -\\ * sinh (\\*z)\"\n by sorry\n\nlemma cos_conv_cosh: \"cos z = cosh (\\*z)\"\n by sorry\n\nlemma tan_conv_tanh: \"tan z = -\\ * tanh (\\*z)\"\n by sorry\n\nlemma sinh_complex_eq_iff:\n \"sinh (z :: complex) = sinh w \\\n (\\n\\\\. z = w - 2 * \\ * of_real n * of_real pi \\\n z = -(2 * complex_of_real n + 1) * \\ * complex_of_real pi - w)\" (is \"_ = ?rhs\")\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Taylor series for complex exponential, sine and cosine\\\n\ndeclare power_Suc [simp del]\n\nlemma Taylor_exp_field:\n fixes z::\"'a::{banach,real_normed_field}\"\n shows \"norm (exp z - (\\i\\n. z ^ i / fact i)) \\ exp (norm z) * (norm z ^ Suc n) / fact n\"\n by sorry\n\ntext \\For complex @{term z}, a tighter bound than in the previous result\\\nlemma Taylor_exp:\n \"norm(exp z - (\\k\\n. z ^ k / (fact k))) \\ exp\\Re z\\ * (norm z) ^ (Suc n) / (fact n)\"\n by sorry\n\nlemma\n assumes \"0 \\ u\" \"u \\ 1\"\n shows cmod_sin_le_exp: \"cmod (sin (u *\\<^sub>R z)) \\ exp \\Im z\\\"\n and cmod_cos_le_exp: \"cmod (cos (u *\\<^sub>R z)) \\ exp \\Im z\\\"\n by sorry\n\nlemma Taylor_sin:\n \"norm(sin z - (\\k\\n. complex_of_real (sin_coeff k) * z ^ k))\n \\ exp\\Im z\\ * (norm z) ^ (Suc n) / (fact n)\"\n by sorry\n\nlemma Taylor_cos:\n \"norm(cos z - (\\k\\n. complex_of_real (cos_coeff k) * z ^ k))\n \\ exp\\Im z\\ * (norm z) ^ Suc n / (fact n)\"\n by sorry\n\ndeclare power_Suc [simp]\n\ntext\\32-bit Approximation to e\\\nlemma e_approx_32: \"\\exp(1) - 5837465777 / 2147483648\\ \\ (inverse(2 ^ 32)::real)\"\n by sorry\n\nlemma e_less_272: \"exp 1 < (272/100::real)\"\n by sorry\n\nlemma ln_272_gt_1: \"ln (272/100) > (1::real)\"\n by sorry\n\ntext\\Apparently redundant. But many arguments involve integers.\\\nlemma ln3_gt_1: \"ln 3 > (1::real)\"\n by sorry\n\nsubsection\\The argument of a complex number (HOL Light version)\\\n\ndefinition\\<^marker>\\tag important\\ is_Arg :: \"[complex,real] \\ bool\"\n where \"is_Arg z r \\ z = of_real(norm z) * exp(\\ * of_real r)\"\n\ndefinition\\<^marker>\\tag important\\ Arg2pi :: \"complex \\ real\"\n where \"Arg2pi z \\ if z = 0 then 0 else THE t. 0 \\ t \\ t < 2*pi \\ is_Arg z t\"\n\nlemma is_Arg_2pi_iff: \"is_Arg z (r + of_int k * (2 * pi)) \\ is_Arg z r\"\n by sorry\n\nlemma is_Arg_eqI:\n assumes \"is_Arg z r\" and \"is_Arg z s\" and \"abs (r-s) < 2*pi\" and \"z \\ 0\"\n shows \"r = s\"\n by sorry\n\ntext\\This function returns the angle of a complex number from its representation in polar coordinates.\nDue to periodicity, its range is arbitrary. \\<^term>\\Arg2pi\\ follows HOL Light in adopting the interval \\[0,2\\)\\.\nBut we have the same periodicity issue with logarithms, and it is usual to adopt the same interval\nfor the complex logarithm and argument functions. Further on down, we shall define both functions for the interval \\(-\\,\\]\\.\nThe present version is provided for compatibility.\\\n\nlemma Arg2pi_0 [simp]: \"Arg2pi(0) = 0\"\n by sorry\n\nlemma Arg2pi_unique_lemma:\n assumes \"is_Arg z t\"\n and \"is_Arg z t'\"\n and \"0 \\ t\" \"t < 2*pi\"\n and \"0 \\ t'\" \"t' < 2*pi\"\n and \"z \\ 0\"\n shows \"t' = t\"\n by sorry\n\nlemma Arg2pi: \"0 \\ Arg2pi z \\ Arg2pi z < 2*pi \\ is_Arg z (Arg2pi z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\\n shows Arg2pi_ge_0: \"0 \\ Arg2pi z\"\n and Arg2pi_lt_2pi: \"Arg2pi z < 2*pi\"\n and Arg2pi_eq: \"z = of_real(norm z) * exp(\\ * of_real(Arg2pi z))\"\n by sorry\n\nlemma complex_norm_eq_1_exp: \"norm z = 1 \\ exp(\\ * of_real (Arg2pi z)) = z\"\n by sorry\n\nlemma Arg2pi_unique: \"\\of_real r * exp(\\ * of_real a) = z; 0 < r; 0 \\ a; a < 2*pi\\ \\ Arg2pi z = a\"\n by sorry\n\nlemma cos_Arg2pi: \"cmod z * cos (Arg2pi z) = Re z\" and sin_Arg2pi: \"cmod z * sin (Arg2pi z) = Im z\"\n by sorry\n\nlemma Arg2pi_minus:\n assumes \"z \\ 0\" shows \"Arg2pi (-z) = (if Arg2pi z < pi then Arg2pi z + pi else Arg2pi z - pi)\"\n by sorry\n\nlemma Arg2pi_times_of_real [simp]:\n assumes \"0 < r\" shows \"Arg2pi (of_real r * z) = Arg2pi z\"\n by sorry\n\nlemma Arg2pi_times_of_real2 [simp]: \"0 < r \\ Arg2pi (z * of_real r) = Arg2pi z\"\n by sorry\n\nlemma Arg2pi_divide_of_real [simp]: \"0 < r \\ Arg2pi (z / of_real r) = Arg2pi z\"\n by sorry\n\nlemma Arg2pi_le_pi: \"Arg2pi z \\ pi \\ 0 \\ Im z\"\n by sorry\n\nlemma Arg2pi_lt_pi: \"0 < Arg2pi z \\ Arg2pi z < pi \\ 0 < Im z\"\n by sorry\n\nlemma Arg2pi_eq_0: \"Arg2pi z = 0 \\ z \\ \\ \\ 0 \\ Re z\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Arg2pi_gt_0:\n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"Arg2pi z > 0\"\n by sorry\n\nlemma Arg2pi_eq_pi: \"Arg2pi z = pi \\ z \\ \\ \\ Re z < 0\"\n by sorry\n\nlemma Arg2pi_eq_0_pi: \"Arg2pi z = 0 \\ Arg2pi z = pi \\ z \\ \\\"\n by sorry\n\nlemma Arg2pi_of_real: \"Arg2pi (of_real r) = (if r<0 then pi else 0)\"\n by sorry\n\nlemma Arg2pi_real: \"z \\ \\ \\ Arg2pi z = (if 0 \\ Re z then 0 else pi)\"\n by sorry\n\nlemma Arg2pi_inverse: \"Arg2pi(inverse z) = (if z \\ \\ then Arg2pi z else 2*pi - Arg2pi z)\"\n by sorry\n\nlemma Arg2pi_eq_iff:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg2pi w = Arg2pi z \\ (\\x. 0 < x \\ w = of_real x * z)\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma Arg2pi_inverse_eq_0: \"Arg2pi(inverse z) = 0 \\ Arg2pi z = 0\"\n by sorry\n\nlemma Arg2pi_divide:\n assumes \"w \\ 0\" \"z \\ 0\" \"Arg2pi w \\ Arg2pi z\"\n shows \"Arg2pi(z / w) = Arg2pi z - Arg2pi w\"\n by sorry\n\nlemma Arg2pi_le_div_sum:\n assumes \"w \\ 0\" \"z \\ 0\" \"Arg2pi w \\ Arg2pi z\"\n shows \"Arg2pi z = Arg2pi w + Arg2pi(z / w)\"\n by sorry\n\nlemma Arg2pi_le_div_sum_eq:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg2pi w \\ Arg2pi z \\ Arg2pi z = Arg2pi w + Arg2pi(z / w)\"\n by sorry\n\nlemma Arg2pi_diff:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg2pi w - Arg2pi z = (if Arg2pi z \\ Arg2pi w then Arg2pi(w / z) else Arg2pi(w/z) - 2*pi)\"\n by sorry\n\nlemma Arg2pi_add:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg2pi w + Arg2pi z = (if Arg2pi w + Arg2pi z < 2*pi then Arg2pi(w * z) else Arg2pi(w * z) + 2*pi)\"\n by sorry\n\nlemma Arg2pi_times:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg2pi (w * z) = (if Arg2pi w + Arg2pi z < 2*pi then Arg2pi w + Arg2pi z\n else (Arg2pi w + Arg2pi z) - 2*pi)\"\n by sorry\n\nlemma Arg2pi_cnj_eq_inverse:\n assumes \"z \\ 0\" shows \"Arg2pi (cnj z) = Arg2pi (inverse z)\"\n by sorry\n\nlemma Arg2pi_cnj: \"Arg2pi(cnj z) = (if z \\ \\ then Arg2pi z else 2*pi - Arg2pi z)\"\n by sorry\n\nlemma Arg2pi_exp: \"0 \\ Im z \\ Im z < 2*pi \\ Arg2pi(exp z) = Im z\"\n by sorry\n\nlemma complex_split_polar:\n obtains r a::real where \"z = complex_of_real r * (cos a + \\ * sin a)\" \"0 \\ r\" \"0 \\ a\" \"a < 2*pi\"\n by sorry\n\nlemma Re_Im_le_cmod: \"Im w * sin \\ + Re w * cos \\ \\ cmod w\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Analytic properties of tangent function\\\n\nlemma cnj_tan: \"cnj(tan z) = tan(cnj z)\"\n by sorry\n\nlemma field_differentiable_at_tan: \"cos z \\ 0 \\ tan field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_tan: \"cos z \\ 0\n \\ tan field_differentiable (at z within s)\"\n by sorry\n\nlemma continuous_within_tan: \"cos z \\ 0 \\ continuous (at z within s) tan\"\n by sorry\n\nlemma continuous_on_tan [continuous_intros]: \"(\\z. z \\ s \\ cos z \\ 0) \\ continuous_on s tan\"\n by sorry\n\nlemma holomorphic_on_tan: \"(\\z. z \\ s \\ cos z \\ 0) \\ tan holomorphic_on s\"\n by sorry\n\nsubsection\\The principal branch of the Complex logarithm\\\n\ninstantiation complex :: ln\nbegin\n\ndefinition\\<^marker>\\tag important\\ ln_complex :: \"complex \\ complex\"\n where \"ln_complex \\ \\z. THE w. exp w = z & -pi < Im(w) & Im(w) \\ pi\"\n\ntext\\NOTE: within this scope, the constant Ln is not yet available!\\\nlemma\n assumes \"z \\ 0\"\n shows exp_Ln [simp]: \"exp(ln z) = z\"\n and mpi_less_Im_Ln: \"-pi < Im(ln z)\"\n and Im_Ln_le_pi: \"Im(ln z) \\ pi\"\n by sorry\n\nlemma Ln_exp [simp]:\n assumes \"-pi < Im(z)\" \"Im(z) \\ pi\"\n shows \"ln(exp z) = z\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relation to Real Logarithm\\\n\nlemma Ln_of_real:\n assumes \"0 < z\"\n shows \"ln(of_real z::complex) = of_real(ln z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_in_Reals [simp]: \"z \\ \\ \\ Re z > 0 \\ ln z \\ \\\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Im_Ln_of_real [simp]: \"r > 0 \\ Im (ln (of_real r)) = 0\"\n by sorry\n\nlemma cmod_Ln_Reals [simp]: \"z \\ \\ \\ 0 < Re z \\ cmod (ln z) = norm (ln (Re z))\"\n by sorry\n\nlemma Ln_Reals_eq: \"\\x \\ \\; Re x > 0\\ \\ ln x = of_real (ln (Re x))\"\n by sorry\n\nlemma Ln_1 [simp]: \"ln 1 = (0::complex)\"\n by sorry\n\nlemma Ln_eq_zero_iff [simp]: \"x \\ \\\\<^sub>\\\\<^sub>0 \\ ln x = 0 \\ x = 1\" for x::complex\n by sorry\n\ninstance\n by intro_classes (rule ln_complex_def Ln_1)\n\nend\n\nabbreviation Ln :: \"complex \\ complex\"\n where \"Ln \\ ln\"\n\nlemma Ln_eq_iff: \"w \\ 0 \\ z \\ 0 \\ (Ln w = Ln z \\ w = z)\"\n by sorry\n\nlemma Ln_unique: \"exp(z) = w \\ -pi < Im(z) \\ Im(z) \\ pi \\ Ln w = z\"\n by sorry\n\nlemma Re_Ln [simp]: \"z \\ 0 \\ Re(Ln z) = ln(norm z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ ln_cmod_le:\n assumes z: \"z \\ 0\"\n shows \"ln (cmod z) \\ cmod (Ln z)\"\n by sorry\n\nproposition\\<^marker>\\tag unimportant\\ exists_complex_root:\n fixes z :: complex\n assumes \"n \\ 0\" obtains w where \"z = w ^ n\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ exists_complex_root_nonzero:\n fixes z::complex\n assumes \"z \\ 0\" \"n \\ 0\"\n obtains w where \"w \\ 0\" \"z = w ^ n\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Derivative of Ln away from the branch cut\\\n\nlemma Im_Ln_less_pi: \n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"shows \"Im (Ln z) < pi\"\n by sorry\n\nlemma has_field_derivative_Ln: \n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"(Ln has_field_derivative inverse(z)) (at z)\"\n by sorry\n\ndeclare has_field_derivative_Ln [derivative_intros]\ndeclare has_field_derivative_Ln [THEN DERIV_chain2, derivative_intros]\n\nlemma field_differentiable_at_Ln: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ Ln field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_Ln: \"z \\ \\\\<^sub>\\\\<^sub>0\n \\ Ln field_differentiable (at z within S)\"\n by sorry\n\nlemma continuous_at_Ln: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ continuous (at z) Ln\"\n by sorry\n\nlemma isCont_Ln' [simp,continuous_intros]:\n \"\\isCont f z; f z \\ \\\\<^sub>\\\\<^sub>0\\ \\ isCont (\\x. Ln (f x)) z\"\n by sorry\n\nlemma continuous_within_Ln [continuous_intros]: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ continuous (at z within S) Ln\"\n by sorry\n\nlemma continuous_on_Ln [continuous_intros]: \"(\\z. z \\ S \\ z \\ \\\\<^sub>\\\\<^sub>0) \\ continuous_on S Ln\"\n by sorry\n\nlemma continuous_on_Ln' [continuous_intros]:\n \"continuous_on S f \\ (\\z. z \\ S \\ f z \\ \\\\<^sub>\\\\<^sub>0) \\ continuous_on S (\\x. Ln (f x))\"\n by sorry\n\nlemma holomorphic_on_Ln [holomorphic_intros]: \"S \\ \\\\<^sub>\\\\<^sub>0 = {} \\ Ln holomorphic_on S\"\n by sorry\n\nlemma holomorphic_on_Ln' [holomorphic_intros]:\n \"(\\z. z \\ A \\ f z \\ \\\\<^sub>\\\\<^sub>0) \\ f holomorphic_on A \\ (\\z. Ln (f z)) holomorphic_on A\"\n by sorry\n\nlemma analytic_on_ln [analytic_intros]:\n assumes \"f analytic_on A\" \"f ` A \\ \\\\<^sub>\\\\<^sub>0 = {}\"\n shows \"(\\w. ln (f w)) analytic_on A\"\n by sorry\n\nlemma tendsto_Ln [tendsto_intros]:\n assumes \"(f \\ L) F\" \"L \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"((\\x. Ln (f x)) \\ Ln L) F\"\n by sorry\n\nlemma divide_ln_mono:\n fixes x y::real\n assumes \"3 \\ x\" \"x \\ y\"\n shows \"x / ln x \\ y / ln y\"\n by sorry\n\ntheorem Ln_series:\n fixes z :: complex\n assumes \"norm z < 1\"\n shows \"(\\n. (-1)^Suc n / of_nat n * z^n) sums ln (1 + z)\" (is \"(\\n. ?f n * z^n) sums _\")\n by sorry\n\nlemma Ln_series': \"cmod z < 1 \\ (\\n. - ((-z)^n) / of_nat n) sums ln (1 + z)\"\n by sorry\n\nlemma ln_series':\n fixes x::real\n assumes \"\\x\\ < 1\"\n shows \"(\\n. - ((-x)^n) / of_nat n) sums ln (1 + x)\"\n by sorry\n\nlemma Ln_approx_linear:\n fixes z :: complex\n assumes \"norm z < 1\"\n shows \"norm (ln (1 + z) - z) \\ norm z^2 / (1 - norm z)\"\n by sorry\n\nlemma norm_Ln_le:\n fixes z :: complex\n assumes \"norm z < 1/2\"\n shows \"norm (Ln(1+z)) \\ 2 * norm z\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Quadrant-type results for Ln\\\n\nlemma cos_lt_zero_pi: \"pi/2 < x \\ x < 3*pi/2 \\ cos x < 0\"\n by sorry\n\nlemma Re_Ln_pos_le:\n assumes \"z \\ 0\"\n shows \"\\Im(Ln z)\\ \\ pi/2 \\ 0 \\ Re(z)\"\n by sorry\n\nlemma Re_Ln_pos_lt:\n assumes \"z \\ 0\"\n shows \"\\Im(Ln z)\\ < pi/2 \\ 0 < Re(z)\"\n by sorry\n\nlemma Im_Ln_pos_le:\n assumes \"z \\ 0\"\n shows \"0 \\ Im(Ln z) \\ Im(Ln z) \\ pi \\ 0 \\ Im(z)\"\n by sorry\n\nlemma Im_Ln_pos_lt:\n assumes \"z \\ 0\"\n shows \"0 < Im(Ln z) \\ Im(Ln z) < pi \\ 0 < Im(z)\"\n by sorry\n\nlemma Re_Ln_pos_lt_imp: \"0 < Re(z) \\ \\Im(Ln z)\\ < pi/2\"\n by sorry\n\nlemma Im_Ln_pos_lt_imp: \"0 < Im(z) \\ 0 < Im(Ln z) \\ Im(Ln z) < pi\"\n by sorry\n\ntext\\A reference to the set of positive real numbers\\\nlemma Im_Ln_eq_0: \"z \\ 0 \\ (Im(Ln z) = 0 \\ 0 < Re(z) \\ Im(z) = 0)\"\n by sorry\n\nlemma Im_Ln_eq_pi: \"z \\ 0 \\ (Im(Ln z) = pi \\ Re(z) < 0 \\ Im(z) = 0)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\More Properties of Ln\\\n\nlemma cnj_Ln: assumes \"z \\ \\\\<^sub>\\\\<^sub>0\" shows \"cnj(Ln z) = Ln(cnj z)\"\n by sorry\n\nlemma Ln_inverse: assumes \"z \\ \\\\<^sub>\\\\<^sub>0\" shows \"Ln(inverse z) = -(Ln z)\"\n by sorry\n\nlemma Ln_minus1 [simp]: \"Ln(-1) = \\ * pi\"\n by sorry\n\nlemma Ln_ii [simp]: \"Ln \\ = \\ * of_real pi/2\"\n by sorry\n\nlemma Ln_minus_ii [simp]: \"Ln(-\\) = - (\\ * pi/2)\"\n by sorry\n\nlemma Ln_times:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Ln(w * z) =\n (if Im(Ln w + Ln z) \\ -pi then (Ln(w) + Ln(z)) + \\ * of_real(2*pi)\n else if Im(Ln w + Ln z) > pi then (Ln(w) + Ln(z)) - \\ * of_real(2*pi)\n else Ln(w) + Ln(z))\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_times_simple:\n \"\\w \\ 0; z \\ 0; -pi < Im(Ln w) + Im(Ln z); Im(Ln w) + Im(Ln z) \\ pi\\\n \\ Ln(w * z) = Ln(w) + Ln(z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_times_of_real:\n \"\\r > 0; z \\ 0\\ \\ Ln(of_real r * z) = ln r + Ln(z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_times_of_nat:\n \"\\r > 0; z \\ 0\\ \\ Ln(of_nat r * z :: complex) = ln (of_nat r) + Ln(z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_times_Reals:\n \"\\r \\ Reals; Re r > 0; z \\ 0\\ \\ Ln(r * z) = ln (Re r) + Ln(z)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_divide_of_real:\n \"\\r > 0; z \\ 0\\ \\ Ln(z / of_real r) = Ln(z) - ln r\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Ln_prod:\n fixes f :: \"'a \\ complex\"\n assumes \"finite A\" \"\\x. x \\ A \\ f x \\ 0\"\n shows \"\\n. Ln (prod f A) = (\\x \\ A. Ln (f x) + (of_int (n x) * (2 * pi)) * \\)\"\n by sorry\n\nlemma Ln_minus:\n assumes \"z \\ 0\"\n shows \"Ln(-z) = (if Im(z) \\ 0 \\ \\(Re(z) < 0 \\ Im(z) = 0)\n then Ln(z) + \\ * pi\n else Ln(z) - \\ * pi)\" \n by sorry\n\nlemma Ln_inverse_if:\n assumes \"z \\ 0\"\n shows \"Ln (inverse z) = (if z \\ \\\\<^sub>\\\\<^sub>0 then -(Ln z) + \\ * 2 * complex_of_real pi else -(Ln z))\"\n by sorry\n\nlemma Ln_times_ii:\n assumes \"z \\ 0\"\n shows \"Ln(\\ * z) = (if 0 \\ Re(z) | Im(z) < 0\n then Ln(z) + \\ * of_real pi/2\n else Ln(z) - \\ * of_real(3 * pi/2))\"\n by sorry\n\nlemma Ln_of_nat [simp]: \"0 < n \\ Ln (of_nat n) = of_real (ln (of_nat n))\"\n by sorry\n\nlemma Ln_of_nat_over_of_nat:\n assumes \"m > 0\" \"n > 0\"\n shows \"Ln (of_nat m / of_nat n) = of_real (ln (of_nat m) - ln (of_nat n))\"\n by sorry\n\nlemma norm_Ln_times_le:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"cmod (Ln(w * z)) \\ cmod (Ln(w) + Ln(z))\"\n by sorry\n\ncorollary norm_Ln_prod_le:\n fixes f :: \"'a \\ complex\"\n assumes \"\\x. x \\ A \\ f x \\ 0\"\n shows \"cmod (Ln (prod f A)) \\ (\\x \\ A. cmod (Ln (f x)))\"\n by sorry\n\nlemma norm_Ln_exp_le: \"norm (Ln (exp z)) \\ norm z\"\n by sorry\n\nlemma Ln_cis: \"x \\ {-pi<..pi} \\ Ln (cis x) = x * \\\"\n by sorry\n\nlemma Ln_rcis:\n assumes \"r > 0\" \"x \\ {-pi<..pi}\"\n shows \"Ln (rcis r x) = Complex (ln r) x\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Uniform convergence and products\\\n\nlemma uniformly_convergent_on_prod_aux:\n fixes f :: \"nat \\ complex \\ complex\"\n assumes norm_f: \"\\n x. x \\ A \\ norm (f n x) < 1\"\n assumes cont: \"\\n. continuous_on A (f n)\"\n assumes conv: \"uniformly_convergent_on A (\\N x. \\nN x. \\nTheorem 17.6 by Bak and Newman, Complex Analysis [roughly]\\\nlemma uniformly_convergent_on_prod:\n fixes f :: \"nat \\ complex \\ complex\"\n assumes cont: \"\\n. continuous_on A (f n)\"\n assumes A: \"compact A\"\n assumes conv_sum: \"uniformly_convergent_on A (\\N x. \\nN x. \\n complex \\ complex\"\n assumes cont: \"\\n. continuous_on A (f n)\"\n assumes A: \"compact A\"\n assumes conv_sum: \"uniformly_convergent_on A (\\N x. \\nN x. \\nProp 17.6 of Bak and Newman, Complex Analysis, p. 243. \n Only this version is for the reals. Can the two proofs be consolidated?\\\nlemma uniformly_convergent_on_prod_real:\n fixes u :: \"nat \\ real \\ real\"\n assumes contu: \"\\k. continuous_on K (u k)\" \n and uconv: \"uniformly_convergent_on K (\\n x. \\ku k x\\)\"\n and K: \"compact K\"\n shows \"uniformly_convergent_on K (\\n x. \\kThe Argument of a Complex Number\\\n\ntext\\Unlike in HOL Light, it's defined for the same interval as the complex logarithm: \\(-\\,\\]\\.\\\n\nlemma Arg_eq_Im_Ln:\n assumes \"z \\ 0\" shows \"Arg z = Im (Ln z)\"\n by sorry\n\ntext \\The 1990s definition of argument coincides with the more recent one\\\nlemma\\<^marker>\\tag important\\ Arg_def:\n shows \"Arg z = (if z = 0 then 0 else Im (Ln z))\"\n by sorry\n\nlemma Arg_of_real [simp]: \"Arg (of_real r) = (if r<0 then pi else 0)\"\n by sorry\n\nlemma mpi_less_Arg: \"-pi < Arg z\" and Arg_le_pi: \"Arg z \\ pi\"\n by sorry\n\nlemma Arg_eq: \n assumes \"z \\ 0\"\n shows \"z = of_real(norm z) * exp(\\ * Arg z)\"\n by sorry\n\nlemma is_Arg_Arg: \"z \\ 0 \\ is_Arg z (Arg z)\"\n by sorry\n\nlemma Argument_exists:\n assumes \"z \\ 0\" and R: \"R = {r-pi<..r+pi}\"\n obtains s where \"is_Arg z s\" \"s\\R\"\n by sorry\n\nlemma Argument_exists_unique:\n assumes \"z \\ 0\" and R: \"R = {r-pi<..r+pi}\"\n obtains s where \"is_Arg z s\" \"s\\R\" \"\\t. \\is_Arg z t; t\\R\\ \\ s=t\"\n by sorry\n\nlemma Argument_Ex1:\n assumes \"z \\ 0\" and R: \"R = {r-pi<..r+pi}\"\n shows \"\\!s. is_Arg z s \\ s \\ R\"\n by sorry\n\nlemma Arg_divide:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"is_Arg (z / w) (Arg z - Arg w)\"\n by sorry\n\nlemma Arg_unique_lemma:\n assumes \"is_Arg z t\" \"is_Arg z t'\"\n and \"- pi < t\" \"t \\ pi\"\n and \"- pi < t'\" \"t' \\ pi\"\n and \"z \\ 0\"\n shows \"t' = t\"\n by sorry\n\nlemma complex_norm_eq_1_exp_eq: \"norm z = 1 \\ exp(\\ * (Arg z)) = z\"\n by sorry\n\nlemma Arg_unique: \"\\of_real r * exp(\\ * a) = z; 0 < r; -pi < a; a \\ pi\\ \\ Arg z = a\"\n by sorry\n\nlemma Arg_minus:\n assumes \"z \\ 0\"\n shows \"Arg (-z) = (if Arg z \\ 0 then Arg z + pi else Arg z - pi)\"\n by sorry\n\nlemma Arg_1 [simp]: \"Arg 1 = 0\"\n by sorry\n\nlemma Arg_numeral [simp]: \"Arg (numeral n) = 0\"\n by sorry\n \nlemma Arg_times_of_real [simp]:\n assumes \"0 < r\" shows \"Arg (of_real r * z) = Arg z\"\n by sorry\n\nlemma Arg_times_of_real2 [simp]: \"0 < r \\ Arg (z * of_real r) = Arg z\"\n by sorry\n\nlemma Arg_divide_of_real [simp]: \"0 < r \\ Arg (z / of_real r) = Arg z\"\n by sorry\n\nlemma Arg_less_0: \"0 \\ Arg z \\ 0 \\ Im z\"\n by sorry\n\ntext \\converse fails because the argument can equal $\\pi$.\\ \nlemma Arg_uminus: \"Arg z < 0 \\ Arg (-z) > 0\"\n by sorry\n\nlemma Arg_eq_pi: \"Arg z = pi \\ Re z < 0 \\ Im z = 0\"\n by sorry\n\nlemma Arg_lt_pi: \"0 < Arg z \\ Arg z < pi \\ 0 < Im z\"\n by sorry\n\nlemma Arg_eq_0: \"Arg z = 0 \\ z \\ \\ \\ 0 \\ Re z\"\n by sorry\n\nlemma Arg_neg_iff: \"Arg x < 0 \\ Im x < 0\"\n by sorry\n\nlemma Arg_pos_iff: \"Arg x > 0 \\ Im x > 0 \\ (Im x = 0 \\ Re x < 0)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Arg_ne_0: assumes \"z \\ \\\\<^sub>\\\\<^sub>0\" shows \"Arg z \\ 0\"\n by sorry\n\nlemma Arg_eq_pi_iff: \"Arg z = pi \\ z \\ \\ \\ Re z < 0\"\n by sorry\n\nlemma Arg_eq_0_iff: \"Arg z = 0 \\ z \\ \\ \\ Re z \\ 0\"\n by sorry\n\nlemma Arg_eq_0_pi: \"Arg z = 0 \\ Arg z = pi \\ z \\ \\\"\n by sorry\n\nlemma Arg_real: \"z \\ \\ \\ Arg z = (if 0 \\ Re z then 0 else pi)\"\n by sorry\n\nlemma Arg_inverse: \"Arg(inverse z) = (if z \\ \\ then Arg z else - Arg z)\"\n by sorry\n\nlemma Arg_eq_iff:\n assumes \"w \\ 0\" \"z \\ 0\"\n shows \"Arg w = Arg z \\ (\\x. 0 < x \\ w = of_real x * z)\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma Arg_inverse_eq_0: \"Arg(inverse z) = 0 \\ Arg z = 0\"\n by sorry\n\nlemma Arg_cnj_eq_inverse: \"z\\0 \\ Arg (cnj z) = Arg (inverse z)\"\n by sorry\n\nlemma Arg_cnj: \"Arg(cnj z) = (if z \\ \\ then Arg z else - Arg z)\"\n by sorry\n\nlemma Arg_exp: \"-pi < Im z \\ Im z \\ pi \\ Arg(exp z) = Im z\"\n by sorry\n\nlemma Arg_cis: \"x \\ {-pi<..pi} \\ Arg (cis x) = x\"\n by sorry\n\nlemma Arg_rcis: \"x \\ {-pi<..pi} \\ r > 0 \\ Arg (rcis r x) = x\"\n by sorry\n\nlemma Ln_Arg: \"z\\0 \\ Ln(z) = ln(norm z) + \\ * Arg(z)\"\n by sorry\n\nlemma Ln_of_real':\n assumes \"x \\ 0\"\n shows \"Ln (of_real x) = of_real (ln \\x\\) + (if x < 0 then pi else 0) * \\\"\n by sorry\n\nlemma continuous_at_Arg:\n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"continuous (at z) Arg\"\n by sorry\n\nlemma continuous_within_Arg: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ continuous (at z within S) Arg\"\n by sorry\n\nlemma continuous_on_Arg: \"continuous_on (-\\\\<^sub>\\\\<^sub>0) Arg\"\n by sorry\n\nlemma continuous_on_Arg' [continuous_intros]:\n assumes \"continuous_on A f\" \"\\z. z \\ A \\ f z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"continuous_on A (\\x. Arg (f x))\"\n by sorry\n\nlemma tendsto_Arg [tendsto_intros]:\n assumes \"(f \\ z) F\" \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"((\\x. Arg (f x)) \\ Arg z) F\"\n by sorry\n\nlemma Arg_Re_pos: \"\\Arg z\\ < pi / 2 \\ Re z > 0 \\ z = 0\"\n by sorry\n\nlemma Arg_Re_nonneg: \"\\Arg z\\ \\ pi / 2 \\ Re z \\ 0\"\n by sorry\n\nlemma Arg_times:\n assumes \"Arg z + Arg w \\ {-pi<..pi}\" \"z \\ 0\" \"w \\ 0\"\n shows \"Arg (z * w) = Arg z + Arg w\"\n by sorry\n\nlemma Arg_unique': \"r > 0 \\ \\ \\ {-pi<..pi} \\ x = rcis r \\ \\ Arg x = \\\"\n by sorry\n\nlemma Arg_times':\n assumes \"w \\ 0\" \"z \\ 0\"\n defines \"x \\ Arg w + Arg z\"\n shows \"Arg (w * z) = x + (if x \\ {-pi<..pi} then 0 else if x > pi then -2*pi else 2*pi)\"\n by sorry\n\nlemma Arg_divide':\n assumes [simp]: \"z \\ 0\" \"w \\ 0\"\n shows \"Arg (z / w) = Arg z - Arg w +\n (if Arg z - Arg w > pi then -2 * pi else if Arg z - Arg w \\ -pi then 2 * pi else 0)\"\n (is \"_ = ?rhs\")\n by sorry\n \nsubsection\\The Unwinding Number and the Ln product Formula\\\n\ntext\\Note that in this special case the unwinding number is -1, 0 or 1. But it's always an integer.\\\n\nlemma is_Arg_exp_Im: \"is_Arg (exp z) (Im z)\"\n by sorry\n\nlemma is_Arg_exp_diff_2pi:\n assumes \"is_Arg (exp z) \\\"\n shows \"\\k. Im z - of_int k * (2 * pi) = \\\"\n by sorry\n\nlemma Arg_exp_diff_2pi: \"\\k. Im z - of_int k * (2 * pi) = Arg (exp z)\"\n by sorry\n\nlemma unwinding_in_Ints: \"(z - Ln(exp z)) / (of_real(2*pi) * \\) \\ \\\"\n by sorry\n\ndefinition\\<^marker>\\tag important\\ unwinding :: \"complex \\ int\" where\n \"unwinding z \\ THE k. of_int k = (z - Ln(exp z)) / (of_real(2*pi) * \\)\"\n\nlemma unwinding: \"of_int (unwinding z) = (z - Ln(exp z)) / (of_real(2*pi) * \\)\"\n by sorry\n\nlemma unwinding_2pi: \"(2*pi) * \\ * unwinding(z) = z - Ln(exp z)\"\n by sorry\n\nlemma Ln_times_unwinding:\n \"w \\ 0 \\ z \\ 0 \\ Ln(w * z) = Ln(w) + Ln(z) - (2*pi) * \\ * unwinding(Ln w + Ln z)\"\n by sorry\n\nlemma arg_conv_arctan:\n assumes \"Re z > 0\"\n shows \"Arg z = arctan (Im z / Re z)\"\n by sorry\n\nsubsection \\Characterisation of @{term \"Im (Ln z)\"} (Wenda Li)\\\n\nlemma Im_Ln_eq_pi_half:\n \"z \\ 0 \\ (Im(Ln z) = pi/2 \\ 0 < Im(z) \\ Re(z) = 0)\"\n \"z \\ 0 \\ (Im(Ln z) = -pi/2 \\ Im(z) < 0 \\ Re(z) = 0)\"\n by sorry\n\nlemma Im_Ln_eq:\n assumes \"z\\0\"\n shows \"Im (Ln z) = (if Re z\\0 then\n if Re z>0 then\n arctan (Im z/Re z)\n else if Im z\\0 then\n arctan (Im z/Re z) + pi\n else\n arctan (Im z/Re z) - pi\n else\n if Im z>0 then pi/2 else -pi/2)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relation between Ln and Arg2pi, and hence continuity of Arg2pi\\\n\nlemma Arg2pi_Ln: \"0 < Arg2pi z \\ Arg2pi z = Im(Ln(-z)) + pi\"\n by sorry\n\nlemma continuous_at_Arg2pi:\n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"continuous (at z) Arg2pi\"\n by sorry\n\ntext\\Relation between Arg2pi and arctangent in upper halfplane\\\nlemma Arg2pi_arctan_upperhalf:\n assumes \"0 < Im z\"\n shows \"Arg2pi z = pi/2 - arctan(Re z / Im z)\"\n by sorry\n\nlemma Arg2pi_eq_Im_Ln:\n assumes \"0 \\ Im z\" \"0 < Re z\"\n shows \"Arg2pi z = Im (Ln z)\"\n by sorry\n\nlemma continuous_within_upperhalf_Arg2pi:\n assumes \"z \\ 0\"\n shows \"continuous (at z within {z. 0 \\ Im z}) Arg2pi\"\n by sorry\n\nlemma continuous_on_upperhalf_Arg2pi: \"continuous_on ({z. 0 \\ Im z} - {0}) Arg2pi\"\n by sorry\n\nlemma open_Arg2pi2pi_less_Int:\n assumes \"0 \\ s\" \"t \\ 2*pi\"\n shows \"open ({y. s < Arg2pi y} \\ {y. Arg2pi y < t})\"\n by sorry\n\nlemma open_Arg2pi2pi_gt: \"open {z. t < Arg2pi z}\"\n by sorry\n\nlemma closed_Arg2pi2pi_le: \"closed {z. Arg2pi z \\ t}\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Complex Powers\\\n\nlemma powr_to_1 [simp]: \"z powr 1 = (z::complex)\"\n by sorry\n\nlemma powr_nat:\n fixes n::nat and z::complex shows \"z powr n = (if z = 0 then 0 else z^n)\"\n by sorry\n\nlemma powr_nat': \"(z :: complex) \\ 0 \\ n \\ 0 \\ z powr of_nat n = z ^ n\"\n by sorry\n\nlemma norm_powr_complex: \"norm (x powr y) = norm x powr Re y * exp (-Im y * Arg x)\"\n by sorry\n\nlemma norm_powr_real: \"w \\ \\ \\ 0 < Re w \\ norm(w powr z) = exp(Re z * ln(Re w))\"\n by sorry\n\nlemma norm_powr_real_powr:\n \"w \\ \\ \\ 0 \\ Re w \\ cmod (w powr z) = Re w powr Re z\"\n by sorry\n\nlemma norm_powr_real_powr': \"w \\ \\ \\ norm (z powr w) = norm z powr Re w\"\n by sorry\n\nlemma powr_complexpow [simp]:\n fixes x::complex shows \"x \\ 0 \\ x powr (of_nat n) = x^n\"\n by sorry\n\nlemma powr_complexnumeral [simp]:\n fixes x::complex shows \"x powr (numeral n) = x ^ (numeral n)\"\n by sorry\n\nlemma powr_times_real_left:\n assumes \"x \\ \\\" \"Re x \\ 0\"\n shows \"(x * y) powr z = x powr z * y powr z\"\n by sorry\n\nlemma cnj_powr:\n assumes \"Im a = 0 \\ Re a \\ 0\"\n shows \"cnj (a powr b) = cnj a powr cnj b\"\n by sorry\n\nlemma powr_real_real:\n assumes \"w \\ \\\" \"z \\ \\\" \"0 < Re w\"\n shows \"w powr z = exp(Re z * ln(Re w))\"\n by sorry\n\nlemma powr_of_real:\n fixes x::real and y::real\n shows \"0 \\ x \\ of_real x powr (of_real y::complex) = of_real (x powr y)\"\n by sorry\n\nlemma powr_of_int:\n fixes z::complex and n::int\n assumes \"z\\(0::complex)\"\n shows \"z powr of_int n = (if n\\0 then z^nat n else inverse (z^nat (-n)))\"\n by sorry\n\nlemma complex_powr_of_int: \"z \\ 0 \\ n \\ 0 \\ z powr of_int n = (z :: complex) powi n\"\n by sorry\n\nlemma powr_of_neg_real:\n fixes x::real and y::real\n assumes \"x<0\"\n shows \"(complex_of_real x) powr (complex_of_real y) = of_real (\\x\\ powr y) * exp (\\ * pi * y)\"\n by sorry\n\nlemma powr_of_real_if:\n fixes x::real and y::real\n shows \"complex_of_real x powr (complex_of_real y) = \n (if x<0 then of_real (\\x\\ powr y) * exp (\\ * pi * y) else of_real (x powr y))\"\n by sorry\n\nlemma powr_Reals_eq: \"\\x \\ \\; y \\ \\; Re x \\ 0\\ \\ x powr y = of_real (Re x powr Re y)\"\n by sorry\n\nlemma norm_powr_real_mono:\n \"\\w \\ \\; 1 < Re w\\ \\ cmod(w powr z1) \\ cmod(w powr z2) \\ Re z1 \\ Re z2\"\n by sorry\n\nlemma powr_times_real:\n \"\\x \\ \\; y \\ \\; 0 \\ Re x; 0 \\ Re y\\ \\ (x * y) powr z = x powr z * y powr z\"\n by sorry\n\nlemma Re_powr_le: \"r \\ \\\\<^sub>\\\\<^sub>0 \\ Re (r powr z) \\ Re r powr Re z\"\n by sorry\n\nlemma\n fixes w::complex\n assumes \"w \\ \\\\<^sub>\\\\<^sub>0\" \"z \\ \\\"\n shows Reals_powr [simp]: \"w powr z \\ \\\" and nonneg_Reals_powr [simp]: \"w powr z \\ \\\\<^sub>\\\\<^sub>0\"\n by sorry\n\nlemma exp_powr_complex:\n fixes x::complex \n assumes \"-pi < Im(x)\" \"Im(x) \\ pi\"\n shows \"exp x powr y = exp (x*y)\"\n by sorry\n\nlemma powr_neg_real_complex:\n fixes w::complex\n shows \"(- of_real x) powr w = (-1) powr (of_real (sgn x) * w) * of_real x powr w\"\n by sorry\n\nlemma has_field_derivative_powr:\n fixes z :: complex\n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"((\\z. z powr s) has_field_derivative (s * z powr (s - 1))) (at z)\"\n by sorry\n\ndeclare has_field_derivative_powr[THEN DERIV_chain2, derivative_intros]\n\nlemma has_field_derivative_powr_of_int:\n fixes z :: complex\n assumes gderiv: \"(g has_field_derivative gd) (at z within S)\" and \"g z \\ 0\"\n shows \"((\\z. g z powr of_int n) has_field_derivative (n * g z powr (of_int n - 1) * gd)) (at z within S)\"\n by sorry\n\nlemma field_differentiable_powr_of_int:\n fixes z :: complex\n assumes \"g field_differentiable (at z within S)\" and \"g z \\ 0\"\n shows \"(\\z. g z powr of_int n) field_differentiable (at z within S)\"\n by sorry\n\nlemma holomorphic_on_powr_of_int [holomorphic_intros]:\n assumes \"f holomorphic_on S\" and \"\\z. z\\S \\ f z \\ 0\"\n shows \"(\\z. (f z) powr of_int n) holomorphic_on S\"\n by sorry\n\nlemma has_field_derivative_powr_right [derivative_intros]:\n \"w \\ 0 \\ ((\\z. w powr z) has_field_derivative Ln w * w powr z) (at z)\"\n by sorry\n\nlemma field_differentiable_powr_right [derivative_intros]:\n fixes w::complex\n shows \"w \\ 0 \\ (\\z. w powr z) field_differentiable (at z)\"\n by sorry\n\nlemma holomorphic_on_powr_right [holomorphic_intros]:\n assumes \"f holomorphic_on S\"\n shows \"(\\z. w powr (f z)) holomorphic_on S\"\n by sorry\n\nlemma holomorphic_on_divide_gen [holomorphic_intros]:\n assumes \"f holomorphic_on S\" \"g holomorphic_on S\" and \"\\z z'. \\z \\ S; z' \\ S\\ \\ g z = 0 \\ g z' = 0\"\n shows \"(\\z. f z / g z) holomorphic_on S\"\n by sorry\n\nlemma tendsto_powr_complex:\n fixes f g :: \"_ \\ complex\"\n assumes a: \"a \\ \\\\<^sub>\\\\<^sub>0\"\n assumes f: \"(f \\ a) F\" and g: \"(g \\ b) F\"\n shows \"((\\z. f z powr g z) \\ a powr b) F\"\n by sorry\n\nlemma tendsto_powr_complex_0:\n fixes f g :: \"'a \\ complex\"\n assumes f: \"(f \\ 0) F\" and g: \"(g \\ b) F\" and b: \"Re b > 0\"\n shows \"((\\z. f z powr g z) \\ 0) F\"\n by sorry\n\nlemma tendsto_powr_complex' [tendsto_intros]:\n fixes f g :: \"_ \\ complex\"\n assumes \"a \\ \\\\<^sub>\\\\<^sub>0 \\ (a = 0 \\ Re b > 0)\" and \"(f \\ a) F\" \"(g \\ b) F\"\n shows \"((\\z. f z powr g z) \\ a powr b) F\"\n by sorry\n\nlemma tendsto_neg_powr_complex_of_real:\n assumes \"filterlim f at_top F\" and \"Re s < 0\"\n shows \"((\\x. complex_of_real (f x) powr s) \\ 0) F\"\n by sorry\n\nlemma tendsto_neg_powr_complex_of_nat:\n assumes \"filterlim f at_top F\" and \"Re s < 0\"\n shows \"((\\x. of_nat (f x) powr s) \\ 0) F\"\n by sorry\n\nlemma continuous_powr_complex [continuous_intros]: \n assumes \"continuous F f\" \"continuous F g\"\n assumes \"Re (f (netlimit F)) \\ 0 \\ Im (f (netlimit F)) \\ 0\"\n assumes \"f (netlimit F) = 0 \\ Re (g (netlimit F)) > 0\"\n shows \"continuous F (\\z. f z powr g z :: complex)\"\n by sorry\n\nlemma continuous_powr_real [continuous_intros]: \n assumes \"continuous F f\" \"continuous F g\"\n assumes \"f (netlimit F) = 0 \\ g (netlimit F) > 0 \\ (\\\\<^sub>F z in F. 0 \\ f z)\"\n shows \"continuous F (\\z. f z powr g z :: real)\"\n by sorry\n\nlemma isCont_powr_complex [continuous_intros]:\n assumes \"f z \\ \\\\<^sub>\\\\<^sub>0\" \"isCont f z\" \"isCont g z\"\n shows \"isCont (\\z. f z powr g z :: complex) z\"\n by sorry\n\nlemma continuous_on_powr_complex [continuous_intros]:\n assumes \"A \\ {z. Re (f z) \\ 0 \\ Im (f z) \\ 0}\"\n assumes \"\\z. z \\ A \\ f z = 0 \\ Re (g z) > 0\"\n assumes \"continuous_on A f\" \"continuous_on A g\"\n shows \"continuous_on A (\\z. f z powr g z)\"\n by sorry\n\nlemma analytic_on_powr [analytic_intros]:\n assumes \"f analytic_on X\" \"g analytic_on X\" \"\\x. x \\ X \\ f x \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"(\\x. f x powr g x) analytic_on X\"\n by sorry\n\nlemma holomorphic_on_powr [holomorphic_intros]:\n assumes \"f holomorphic_on X\" \"g holomorphic_on X\" \"\\x. x \\ X \\ f x \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"(\\x. f x powr g x) holomorphic_on X\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Some Limits involving Logarithms\\\n\nlemma lim_Ln_over_power:\n fixes s::complex\n assumes \"0 < Re s\"\n shows \"(\\n. Ln (of_nat n) / of_nat n powr s) \\ 0\"\n by sorry\n\nlemma lim_Ln_over_n: \"((\\n. Ln(of_nat n) / of_nat n) \\ 0) sequentially\"\n by sorry\n\nlemma lim_ln_over_power:\n fixes s :: real\n assumes \"0 < s\"\n shows \"(\\n. ln (real n) / real n powr s) \\ 0\"\n by sorry\n\nlemma lim_ln_over_n [tendsto_intros]: \"((\\n. ln(real_of_nat n) / of_nat n) \\ 0) sequentially\"\n by sorry\n\nlemma lim_log_over_n [tendsto_intros]:\n \"(\\n. log k n/n) \\ 0\"\n by sorry\n\nlemma lim_1_over_complex_power:\n assumes \"0 < Re s\"\n shows \"(\\n. 1 / of_nat n powr s) \\ 0\"\n by sorry\n\nlemma lim_1_over_real_power:\n fixes s :: real\n assumes \"0 < s\"\n shows \"((\\n. 1 / (of_nat n powr s)) \\ 0) sequentially\"\n by sorry\n\nlemma lim_1_over_Ln: \"(\\n. 1 / Ln (complex_of_nat n)) \\ 0\"\n by sorry\n\nlemma lim_1_over_ln: \"(\\n. 1 / ln (real n)) \\ 0\"\n by sorry\n\nlemma lim_ln1_over_ln: \"(\\n. ln(Suc n) / ln n) \\ 1\"\n by sorry\n\nlemma lim_ln_over_ln1: \"(\\n. ln n / ln(Suc n)) \\ 1\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relation between Square Root and exp/ln, hence its derivative\\\n\nlemma csqrt_exp_Ln:\n assumes \"z \\ 0\"\n shows \"csqrt z = exp(Ln z / 2)\"\n by sorry\n\nlemma csqrt_in_nonpos_Reals_iff [simp]: \"csqrt z \\ \\\\<^sub>\\\\<^sub>0 \\ z = 0\"\n by sorry\n\nlemma Im_csqrt_eq_0_iff: \"Im (csqrt z) = 0 \\ z \\ \\\\<^sub>\\\\<^sub>0\"\n by sorry\n\nlemma csqrt_conv_powr: \"csqrt z = z powr (1/2)\"\n by sorry\n\nlemma csqrt_mult:\n assumes \"Arg z + Arg w \\ {-pi<..pi}\"\n shows \"csqrt (z * w) = csqrt z * csqrt w\"\n by sorry\n\nlemma Arg_csqrt [simp]: \"Arg (csqrt z) = Arg z / 2\"\n by sorry\n\nlemma csqrt_inverse:\n \"z \\ \\\\<^sub>\\\\<^sub>0 \\ csqrt (inverse z) = inverse (csqrt z)\"\n by sorry\n\nlemma cnj_csqrt: \"z \\ \\\\<^sub>\\\\<^sub>0 \\ cnj(csqrt z) = csqrt(cnj z)\"\n by sorry\n\nlemma has_field_derivative_csqrt:\n assumes \"z \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"(csqrt has_field_derivative inverse(2 * csqrt z)) (at z)\"\n by sorry\n\nlemma has_field_derivative_csqrt' [derivative_intros]:\n assumes \"(f has_field_derivative f') (at x within A)\" \"f x \\ \\\\<^sub>\\\\<^sub>0\"\n shows \"((\\x. csqrt (f x)) has_field_derivative (f' / (2 * csqrt (f x)))) (at x within A)\"\n by sorry\n\nlemma field_differentiable_at_csqrt:\n \"z \\ \\\\<^sub>\\\\<^sub>0 \\ csqrt field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_csqrt:\n \"z \\ \\\\<^sub>\\\\<^sub>0 \\ csqrt field_differentiable (at z within s)\"\n by sorry\n\nlemma continuous_at_csqrt:\n \"z \\ \\\\<^sub>\\\\<^sub>0 \\ continuous (at z) csqrt\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ isCont_csqrt' [simp]:\n \"\\isCont f z; f z \\ \\\\<^sub>\\\\<^sub>0\\ \\ isCont (\\x. csqrt (f x)) z\"\n by sorry\n\nlemma continuous_within_csqrt:\n \"z \\ \\\\<^sub>\\\\<^sub>0 \\ continuous (at z within s) csqrt\"\n by sorry\n\nlemma continuous_on_csqrt [continuous_intros]:\n \"continuous_on (-\\\\<^sub>\\\\<^sub>0) csqrt\"\n by sorry\n\nlemma holomorphic_on_csqrt [holomorphic_intros]: \"csqrt holomorphic_on -\\\\<^sub>\\\\<^sub>0\"\n by sorry\n\nlemma holomorphic_on_csqrt' [holomorphic_intros]:\n \"f holomorphic_on A \\ (\\z. z \\ A \\ f z \\ \\\\<^sub>\\\\<^sub>0) \\ (\\z. csqrt (f z)) holomorphic_on A\"\n by sorry\n\nlemma analytic_on_csqrt [analytic_intros]: \"csqrt analytic_on -\\\\<^sub>\\\\<^sub>0\"\n by sorry\n\nlemma analytic_on_csqrt' [analytic_intros]:\n \"f analytic_on A \\ (\\z. z \\ A \\ f z \\ \\\\<^sub>\\\\<^sub>0) \\ (\\z. csqrt (f z)) analytic_on A\"\n by sorry\n\nlemma continuous_within_closed_nontrivial:\n \"closed s \\ a \\ s ==> continuous (at a within s) f\"\n by sorry\n\nlemma continuous_within_csqrt_posreal:\n \"continuous (at z within (\\ \\ {w. 0 \\ Re(w)})) csqrt\"\n by sorry\n\nsubsection\\Complex arctangent\\\n\ntext\\The branch cut gives standard bounds in the real case.\\\n\ndefinition\\<^marker>\\tag important\\ Arctan :: \"complex \\ complex\" where\n \"Arctan \\ \\z. (\\/2) * Ln((1 - \\*z) / (1 + \\*z))\"\n\nlemma Arctan_def_moebius: \"Arctan z = \\/2 * Ln (moebius (-\\) 1 \\ 1 z)\"\n by sorry\n\nlemma Ln_conv_Arctan:\n assumes \"z \\ -1\"\n shows \"Ln z = -2*\\ * Arctan (moebius 1 (- 1) (- \\) (- \\) z)\"\n by sorry\n\nlemma Arctan_0 [simp]: \"Arctan 0 = 0\"\n by sorry\n\nlemma Im_complex_div_lemma: \"Im((1 - \\*z) / (1 + \\*z)) = 0 \\ Re z = 0\"\n by sorry\n\nlemma Re_complex_div_lemma: \"0 < Re((1 - \\*z) / (1 + \\*z)) \\ norm z < 1\"\n by sorry\n\nlemma tan_Arctan:\n assumes \"z\\<^sup>2 \\ -1\"\n shows [simp]: \"tan(Arctan z) = z\"\n by sorry\n\nlemma Arctan_tan [simp]:\n assumes \"\\Re z\\ < pi/2\"\n shows \"Arctan(tan z) = z\"\n by sorry\n\nlemma\n assumes \"Re z = 0 \\ \\Im z\\ < 1\"\n shows Re_Arctan_bounds: \"\\Re(Arctan z)\\ < pi/2\"\n and has_field_derivative_Arctan: \"(Arctan has_field_derivative inverse(1 + z\\<^sup>2)) (at z)\"\n by sorry\n\nlemma field_differentiable_at_Arctan: \"(Re z = 0 \\ \\Im z\\ < 1) \\ Arctan field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_Arctan:\n \"(Re z = 0 \\ \\Im z\\ < 1) \\ Arctan field_differentiable (at z within s)\"\n by sorry\n\ndeclare has_field_derivative_Arctan [derivative_intros]\ndeclare has_field_derivative_Arctan [THEN DERIV_chain2, derivative_intros]\n\nlemma continuous_at_Arctan:\n \"(Re z = 0 \\ \\Im z\\ < 1) \\ continuous (at z) Arctan\"\n by sorry\n\nlemma continuous_within_Arctan:\n \"(Re z = 0 \\ \\Im z\\ < 1) \\ continuous (at z within s) Arctan\"\n by sorry\n\nlemma continuous_on_Arctan [continuous_intros]:\n \"(\\z. z \\ s \\ Re z = 0 \\ \\Im z\\ < 1) \\ continuous_on s Arctan\"\n by sorry\n\nlemma holomorphic_on_Arctan:\n \"(\\z. z \\ s \\ Re z = 0 \\ \\Im z\\ < 1) \\ Arctan holomorphic_on s\"\n by sorry\n\ntheorem Arctan_series:\n assumes z: \"norm (z :: complex) < 1\"\n defines \"g \\ \\n. if odd n then -\\*\\^n / n else 0\"\n defines \"h \\ \\z n. (-1)^n / of_nat (2*n+1) * (z::complex)^(2*n+1)\"\n shows \"(\\n. g n * z^n) sums Arctan z\"\n and \"h z sums Arctan z\"\n by sorry\n\ntext \\A quickly-converging series for the logarithm, based on the arctangent.\\\ntheorem ln_series_quadratic:\n assumes x: \"x > (0::real)\"\n shows \"(\\n. (2*((x - 1) / (x + 1)) ^ (2*n+1) / of_nat (2*n+1))) sums ln x\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Real arctangent\\\n\nlemma Im_Arctan_of_real [simp]: \"Im (Arctan (of_real x)) = 0\"\n by sorry\n\nlemma arctan_eq_Re_Arctan: \"arctan x = Re (Arctan (of_real x))\"\n by sorry\n\nlemma Arctan_of_real: \"Arctan (of_real x) = of_real (arctan x)\"\n by sorry\n\nlemma Arctan_in_Reals [simp]: \"z \\ \\ \\ Arctan z \\ \\\"\n by sorry\n\ndeclare arctan_one [simp]\n\nlemma arctan_less_pi4_pos: \"x < 1 \\ arctan x < pi/4\"\n by sorry\n\nlemma arctan_less_pi4_neg: \"-1 < x \\ -(pi/4) < arctan x\"\n by sorry\n\nlemma arctan_less_pi4: \"\\x\\ < 1 \\ \\arctan x\\ < pi/4\"\n by sorry\n\nlemma arctan_le_pi4: \"\\x\\ \\ 1 \\ \\arctan x\\ \\ pi/4\"\n by sorry\n\nlemma abs_arctan: \"\\arctan x\\ = arctan \\x\\\"\n by sorry\n\nlemma arctan_add_raw:\n assumes \"\\arctan x + arctan y\\ < pi/2\"\n shows \"arctan x + arctan y = arctan((x + y) / (1 - x * y))\"\n by sorry\n\nlemma arctan_inverse:\n \"0 < x \\arctan(inverse x) = pi/2 - arctan x\"\n by sorry\n\nlemma arctan_add_small:\n assumes \"\\x * y\\ < 1\"\n shows \"(arctan x + arctan y = arctan((x + y) / (1 - x * y)))\"\n by sorry\n\nlemma abs_arctan_le:\n fixes x::real shows \"\\arctan x\\ \\ \\x\\\"\n by sorry\n\nlemma arctan_le_self: \"0 \\ x \\ arctan x \\ x\"\n by sorry\n\nlemma abs_tan_ge: \"\\x\\ < pi/2 \\ \\x\\ \\ \\tan x\\\"\n by sorry\n\nlemma arctan_bounds:\n assumes \"0 \\ x\" \"x < 1\"\n shows arctan_lower_bound:\n \"(\\k<2 * n. (- 1) ^ k * (1 / real (k * 2 + 1) * x ^ (k * 2 + 1))) \\ arctan x\" (is \"(\\k<_. _ * ?a k) \\ _\")\n and arctan_upper_bound:\n \"arctan x \\ (\\k<2 * n + 1. (- 1) ^ k * (1 / real (k * 2 + 1) * x ^ (k * 2 + 1)))\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Bounds on pi using real arctangent\\\n\nlemma pi_machin: \"pi = 16 * arctan (1 / 5) - 4 * arctan (1 / 239)\"\n by sorry\n\nlemma pi_approx: \"3.141592653588 \\ pi\" \"pi \\ 3.1415926535899\"\n by sorry\n\nlemma pi_gt3: \"pi > 3\"\n by sorry\n\nsubsection\\Inverse Sine\\\n\ndefinition\\<^marker>\\tag important\\ Arcsin :: \"complex \\ complex\" where\n \"Arcsin \\ \\z. -\\ * Ln(\\ * z + csqrt(1 - z\\<^sup>2))\"\n\nlemma Arcsin_body_lemma: \"\\ * z + csqrt(1 - z\\<^sup>2) \\ 0\"\n by sorry\n\nlemma Arcsin_range_lemma: \"\\Re z\\ < 1 \\ 0 < Re(\\ * z + csqrt(1 - z\\<^sup>2))\"\n by sorry\n\nlemma Re_Arcsin: \"Re(Arcsin z) = Im (Ln (\\ * z + csqrt(1 - z\\<^sup>2)))\"\n by sorry\n\nlemma Im_Arcsin: \"Im(Arcsin z) = - ln (cmod (\\ * z + csqrt (1 - z\\<^sup>2)))\"\n by sorry\n\nlemma one_minus_z2_notin_nonpos_Reals:\n assumes \"Im z = 0 \\ \\Re z\\ < 1\"\n shows \"1 - z\\<^sup>2 \\ \\\\<^sub>\\\\<^sub>0\"\n by sorry\n\nlemma isCont_Arcsin_lemma:\n assumes le0: \"Re (\\ * z + csqrt (1 - z\\<^sup>2)) \\ 0\" and \"(Im z = 0 \\ \\Re z\\ < 1)\"\n shows False\n by sorry\n\nlemma isCont_Arcsin:\n assumes \"(Im z = 0 \\ \\Re z\\ < 1)\"\n shows \"isCont Arcsin z\"\n by sorry\n\nlemma isCont_Arcsin' [simp]:\n shows \"isCont f z \\ (Im (f z) = 0 \\ \\Re (f z)\\ < 1) \\ isCont (\\x. Arcsin (f x)) z\"\n by sorry\n\nlemma sin_Arcsin [simp]: \"sin(Arcsin z) = z\"\n by sorry\n\nlemma Re_eq_pihalf_lemma:\n \"\\Re z\\ = pi/2 \\ Im z = 0 \\\n Re ((exp (\\*z) + inverse (exp (\\*z))) / 2) = 0 \\ 0 \\ Im ((exp (\\*z) + inverse (exp (\\*z))) / 2)\"\n by sorry\n\nlemma Re_less_pihalf_lemma:\n assumes \"\\Re z\\ < pi / 2\"\n shows \"0 < Re ((exp (\\*z) + inverse (exp (\\*z))) / 2)\"\n by sorry\n\nlemma Arcsin_sin:\n assumes \"\\Re z\\ < pi/2 \\ (\\Re z\\ = pi/2 \\ Im z = 0)\"\n shows \"Arcsin(sin z) = z\"\n by sorry\n\nlemma Arcsin_unique:\n \"\\sin z = w; \\Re z\\ < pi/2 \\ (\\Re z\\ = pi/2 \\ Im z = 0)\\ \\ Arcsin w = z\"\n by sorry\n\nlemma Arcsin_0 [simp]: \"Arcsin 0 = 0\"\n by sorry\n\nlemma Arcsin_1 [simp]: \"Arcsin 1 = pi/2\"\n by sorry\n\nlemma Arcsin_minus_1 [simp]: \"Arcsin(-1) = - (pi/2)\"\n by sorry\n\nlemma has_field_derivative_Arcsin:\n assumes \"Im z = 0 \\ \\Re z\\ < 1\"\n shows \"(Arcsin has_field_derivative inverse(cos(Arcsin z))) (at z)\"\n by sorry\n\ndeclare has_field_derivative_Arcsin [derivative_intros]\ndeclare has_field_derivative_Arcsin [THEN DERIV_chain2, derivative_intros]\n\nlemma field_differentiable_at_Arcsin:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ Arcsin field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_Arcsin:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ Arcsin field_differentiable (at z within s)\"\n by sorry\n\nlemma continuous_within_Arcsin:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ continuous (at z within s) Arcsin\"\n by sorry\n\nlemma continuous_on_Arcsin [continuous_intros]:\n \"(\\z. z \\ s \\ Im z = 0 \\ \\Re z\\ < 1) \\ continuous_on s Arcsin\"\n by sorry\n\nlemma holomorphic_on_Arcsin: \"(\\z. z \\ s \\ Im z = 0 \\ \\Re z\\ < 1) \\ Arcsin holomorphic_on s\"\n by sorry\n\nsubsection\\Inverse Cosine\\\n\ndefinition\\<^marker>\\tag important\\ Arccos :: \"complex \\ complex\" where\n \"Arccos \\ \\z. -\\ * Ln(z + \\ * csqrt(1 - z\\<^sup>2))\"\n\nlemma Arccos_range_lemma: \"\\Re z\\ < 1 \\ 0 < Im(z + \\ * csqrt(1 - z\\<^sup>2))\"\n by sorry\n\nlemma Arccos_body_lemma: \"z + \\ * csqrt(1 - z\\<^sup>2) \\ 0\"\n by sorry\n\nlemma Re_Arccos: \"Re(Arccos z) = Im (Ln (z + \\ * csqrt(1 - z\\<^sup>2)))\"\n by sorry\n\nlemma Im_Arccos: \"Im(Arccos z) = - ln (cmod (z + \\ * csqrt (1 - z\\<^sup>2)))\"\n by sorry\n\ntext\\A very tricky argument to find!\\\nlemma isCont_Arccos_lemma:\n assumes eq0: \"Im (z + \\ * csqrt (1 - z\\<^sup>2)) = 0\" and \"Im z = 0 \\ \\Re z\\ < 1\"\n shows False\n by sorry\n\nlemma isCont_Arccos:\n assumes \"(Im z = 0 \\ \\Re z\\ < 1)\"\n shows \"isCont Arccos z\"\n by sorry\n\nlemma isCont_Arccos' [simp]:\n \"isCont f z \\ (Im (f z) = 0 \\ \\Re (f z)\\ < 1) \\ isCont (\\x. Arccos (f x)) z\"\n by sorry\n\nlemma cos_Arccos [simp]: \"cos(Arccos z) = z\"\n by sorry\n\nlemma Arccos_cos:\n assumes \"0 < Re z \\ Re z < pi \\\n Re z = 0 \\ 0 \\ Im z \\\n Re z = pi \\ Im z \\ 0\"\n shows \"Arccos(cos z) = z\"\n by sorry\n\nlemma Arccos_unique:\n \"\\cos z = w;\n 0 < Re z \\ Re z < pi \\\n Re z = 0 \\ 0 \\ Im z \\\n Re z = pi \\ Im z \\ 0\\ \\ Arccos w = z\"\n by sorry\n\nlemma Arccos_0 [simp]: \"Arccos 0 = pi/2\"\n by sorry\n\nlemma Arccos_1 [simp]: \"Arccos 1 = 0\"\n by sorry\n\nlemma Arccos_minus1: \"Arccos(-1) = pi\"\n by sorry\n\nlemma has_field_derivative_Arccos:\n assumes \"(Im z = 0 \\ \\Re z\\ < 1)\"\n shows \"(Arccos has_field_derivative - inverse(sin(Arccos z))) (at z)\"\n by sorry\n\ndeclare has_field_derivative_Arcsin [derivative_intros]\ndeclare has_field_derivative_Arcsin [THEN DERIV_chain2, derivative_intros]\n\nlemma field_differentiable_at_Arccos:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ Arccos field_differentiable at z\"\n by sorry\n\nlemma field_differentiable_within_Arccos:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ Arccos field_differentiable (at z within s)\"\n by sorry\n\nlemma continuous_within_Arccos:\n \"(Im z = 0 \\ \\Re z\\ < 1) \\ continuous (at z within s) Arccos\"\n by sorry\n\nlemma continuous_on_Arccos [continuous_intros]:\n \"(\\z. z \\ s \\ Im z = 0 \\ \\Re z\\ < 1) \\ continuous_on s Arccos\"\n by sorry\n\nlemma holomorphic_on_Arccos: \"(\\z. z \\ s \\ Im z = 0 \\ \\Re z\\ < 1) \\ Arccos holomorphic_on s\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Upper and Lower Bounds for Inverse Sine and Cosine\\\n\nlemma Arcsin_bounds: \"\\Re z\\ < 1 \\ \\Re(Arcsin z)\\ < pi/2\"\n by sorry\n\nlemma Arccos_bounds: \"\\Re z\\ < 1 \\ 0 < Re(Arccos z) \\ Re(Arccos z) < pi\"\n by sorry\n\nlemma Re_Arccos_bounds: \"-pi < Re(Arccos z) \\ Re(Arccos z) \\ pi\"\n by sorry\n\nlemma Re_Arccos_bound: \"\\Re(Arccos z)\\ \\ pi\"\n by sorry\n\nlemma Im_Arccos_bound: \"\\Im (Arccos w)\\ \\ cmod w\"\n by sorry\n\nlemma Re_Arcsin_bounds: \"-pi < Re(Arcsin z) & Re(Arcsin z) \\ pi\"\n by sorry\n\nlemma Re_Arcsin_bound: \"\\Re(Arcsin z)\\ \\ pi\"\n by sorry\n\nlemma norm_Arccos_bounded:\n fixes w :: complex\n shows \"norm (Arccos w) \\ pi + norm w\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Interrelations between Arcsin and Arccos\\\n\nlemma cos_Arcsin_nonzero: \"z\\<^sup>2 \\ 1 \\cos(Arcsin z) \\ 0\"\n by sorry\n\nlemma sin_Arccos_nonzero: \"z\\<^sup>2 \\ 1 \\sin(Arccos z) \\ 0\"\n by sorry\n\nlemma cos_sin_csqrt:\n assumes \"0 < cos(Re z) \\ cos(Re z) = 0 \\ Im z * sin(Re z) \\ 0\"\n shows \"cos z = csqrt(1 - (sin z)\\<^sup>2)\"\n by sorry\n\nlemma sin_cos_csqrt:\n assumes \"0 < sin(Re z) \\ sin(Re z) = 0 \\ 0 \\ Im z * cos(Re z)\"\n shows \"sin z = csqrt(1 - (cos z)\\<^sup>2)\"\n by sorry\n\nlemma Arcsin_Arccos_csqrt_pos:\n \"(0 < Re z \\ Re z = 0 \\ 0 \\ Im z) \\ Arcsin z = Arccos(csqrt(1 - z\\<^sup>2))\"\n by sorry\n\nlemma Arccos_Arcsin_csqrt_pos:\n \"(0 < Re z \\ Re z = 0 \\ 0 \\ Im z) \\ Arccos z = Arcsin(csqrt(1 - z\\<^sup>2))\"\n by sorry\n\nlemma sin_Arccos:\n \"0 < Re z \\ Re z = 0 \\ 0 \\ Im z \\ sin(Arccos z) = csqrt(1 - z\\<^sup>2)\"\n by sorry\n\nlemma cos_Arcsin:\n \"0 < Re z \\ Re z = 0 \\ 0 \\ Im z \\ cos(Arcsin z) = csqrt(1 - z\\<^sup>2)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relationship with Arcsin on the Real Numbers\\\n\nlemma of_real_arcsin: \"\\x\\ \\ 1 \\ of_real(arcsin x) = Arcsin(of_real x)\"\n by sorry\n\nlemma Im_Arcsin_of_real: \"\\x\\ \\ 1 \\ Im (Arcsin (of_real x)) = 0\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Arcsin_in_Reals [simp]: \"z \\ \\ \\ \\Re z\\ \\ 1 \\ Arcsin z \\ \\\"\n by sorry\n\nlemma arcsin_eq_Re_Arcsin: \"\\x\\ \\ 1 \\ arcsin x = Re (Arcsin (of_real x))\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relationship with Arccos on the Real Numbers\\\n\nlemma of_real_arccos: \"\\x\\ \\ 1 \\ of_real(arccos x) = Arccos(of_real x)\"\n by sorry\n\nlemma Im_Arccos_of_real: \"\\x\\ \\ 1 \\ Im (Arccos (of_real x)) = 0\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Arccos_in_Reals [simp]: \"z \\ \\ \\ \\Re z\\ \\ 1 \\ Arccos z \\ \\\"\n by sorry\n\nlemma arccos_eq_Re_Arccos: \"\\x\\ \\ 1 \\ arccos x = Re (Arccos (of_real x))\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Continuity results for arcsin and arccos\\\n\nlemma continuous_on_Arcsin_real [continuous_intros]:\n \"continuous_on {w \\ \\. \\Re w\\ \\ 1} Arcsin\"\n by sorry\n\nlemma continuous_within_Arcsin_real:\n \"continuous (at z within {w \\ \\. \\Re w\\ \\ 1}) Arcsin\"\n by sorry\n\nlemma continuous_on_Arccos_real:\n \"continuous_on {w \\ \\. \\Re w\\ \\ 1} Arccos\"\n by sorry\n\nlemma continuous_within_Arccos_real:\n \"continuous (at z within {w \\ \\. \\Re w\\ \\ 1}) Arccos\"\n by sorry\n\nlemma sinh_ln_complex: \"x \\ 0 \\ sinh (ln x :: complex) = (x - inverse x) / 2\"\n by sorry\n\nlemma cosh_ln_complex: \"x \\ 0 \\ cosh (ln x :: complex) = (x + inverse x) / 2\"\n by sorry\n\nlemma tanh_ln_complex: \"x \\ 0 \\ tanh (ln x :: complex) = (x ^ 2 - 1) / (x ^ 2 + 1)\"\n by sorry\n\nsubsection\\Roots of unity\\\n\ntheorem complex_root_unity:\n fixes j::nat\n assumes \"n \\ 0\"\n shows \"exp(2 * of_real pi * \\ * of_nat j / of_nat n)^n = 1\"\n by sorry\n\nlemma complex_root_unity_eq:\n fixes j::nat and k::nat\n assumes \"1 \\ n\"\n shows \"(exp(2 * of_real pi * \\ * of_nat j / of_nat n) = exp(2 * of_real pi * \\ * of_nat k / of_nat n)\n \\ j mod n = k mod n)\"\n by sorry\n\ncorollary bij_betw_roots_unity:\n \"bij_betw (\\j. exp(2 * of_real pi * \\ * of_nat j / of_nat n))\n {.. * of_nat j / of_nat n) | j. j < n}\"\n by sorry\n\nlemma complex_root_unity_eq_1:\n fixes j::nat and k::nat\n assumes \"1 \\ n\"\n shows \"exp(2 * of_real pi * \\ * of_nat j / of_nat n) = 1 \\ n dvd j\"\n by sorry\n\nlemma finite_complex_roots_unity_explicit:\n \"finite {exp(2 * of_real pi * \\ * of_nat j / of_nat n) | j::nat. j < n}\"\n by sorry\n\nlemma card_complex_roots_unity_explicit:\n \"card {exp(2 * of_real pi * \\ * of_nat j / of_nat n) | j::nat. j < n} = n\"\n by sorry\n\nlemma complex_roots_unity:\n assumes \"1 \\ n\"\n shows \"{z::complex. z^n = 1} = {exp(2 * of_real pi * \\ * of_nat j / of_nat n) | j. j < n}\"\n by sorry\n\nlemma card_complex_roots_unity: \"1 \\ n \\ card {z::complex. z^n = 1} = n\"\n by sorry\n\nlemma complex_not_root_unity:\n \"1 \\ n \\ \\u::complex. norm u = 1 \\ u^n \\ 1\"\n by sorry\n\nsubsection \\Normalisation of angles\\\n\ntext \\\n The following operation normalises an angle $\\varphi$, i.e.\\ returns the unique\n $\\psi$ in the range $(-\\pi, \\pi]$ such that\n $\\varphi\\equiv\\psi\\hskip.5em(\\text{mod}\\ 2\\pi)$.\n This is the same convention used by the \\<^const>\\Arg\\ function.\n\\\ndefinition normalize_angle :: \"real \\ real\" where\n \"normalize_angle x = x - \\x / (2 * pi) - 1 / 2\\ * (2 * pi)\"\n\nlemma normalize_angle_id [simp]:\n assumes \"x \\ {-pi<..pi}\"\n shows \"normalize_angle x = x\"\n by sorry\n\nlemma normalize_angle_normalized: \"normalize_angle x \\ {-pi<..pi}\"\n by sorry\n\nlemma cis_normalize_angle [simp]: \"cis (normalize_angle x) = cis x\"\n by sorry\n\nlemma rcis_normalize_angle [simp]: \"rcis r (normalize_angle x) = rcis r x\"\n by sorry\n\nlemma normalize_angle_lbound [intro]: \"normalize_angle x > -pi\"\n and normalize_angle_ubound [intro]: \"normalize_angle x \\ pi\"\n by sorry\n\nlemma normalize_angle_idem [simp]: \"normalize_angle (normalize_angle x) = normalize_angle x\"\n by sorry\n\nlemma Arg_rcis': \"r > 0 \\ Arg (rcis r \\) = normalize_angle \\\"\n by sorry\n\nsubsection \\Convexity of circular sectors in the complex plane\\\n\ntext \\\n In this section we will show that if we have two non-zero points $w$ and $z$ in the complex plane\n whose arguments differ by less than $\\pi$, then the argument of any point on the line connecting\n $w$ and $z$ lies between the arguments of $w$ and $z$. Moreover, the norm of any such point is\n no greater than the norms of $w$ and $z$.\n\n Geometrically, this means that if we have a sector around the origin with a central angle\n less than $\\pi$ (minus the origin itself) then that region is convex.\n\\\n\nlemma Arg_closed_segment_aux1:\n assumes \"x \\ 0\" \"y \\ 0\" \"Re x > 0\" \"Re x = Re y\"\n assumes \"z \\ closed_segment x y\"\n shows \"Arg z \\ closed_segment (Arg x) (Arg y)\"\n by sorry\n\nlemma Arg_closed_segment_aux1':\n fixes r1 r2 \\1 \\2 :: real\n defines \"x \\ rcis r1 \\1\" and \"y \\ rcis r2 \\2\"\n assumes \"z \\ closed_segment x y\"\n assumes \"r1 > 0\" \"r2 > 0\" \"Re x = Re y\" \"Re x \\ 0\" \"Re x = 0 \\ Im x * Im y > 0\"\n assumes \"dist \\1 \\2 < pi\"\n obtains r \\ where \"r \\ {0<..max r1 r2}\" \"\\ \\ closed_segment \\1 \\2\" \"z = rcis r \\\"\n by sorry\n\nlemma Arg_closed_segment':\n fixes r1 r2 \\1 \\2 :: real\n defines \"x \\ rcis r1 \\1\" and \"y \\ rcis r2 \\2\"\n assumes \"r1 > 0\" \"r2 > 0\" \"dist \\1 \\2 < pi\" \"z \\ closed_segment x y\"\n obtains r \\ where \"r \\ {0<..max r1 r2}\" \"\\ \\ closed_segment \\1 \\2\" \"z = rcis r \\\"\n by sorry\n\nlemma Arg_closed_segment:\n assumes \"x \\ 0\" \"y \\ 0\" \"dist (Arg x) (Arg y) < pi\" \"z \\ closed_segment x y\"\n shows \"Arg z \\ closed_segment (Arg x) (Arg y)\"\n by sorry\n\nsubsection \\Complex cones\\\n\ntext \\\n We introduce the following notation to describe the set of all complex numbers of the form\n $c e^{ix}$ where $c\\geq 0$ and $x\\in [a, b]$.\n\\\ndefinition complex_cone :: \"real \\ real \\ complex set\" where\n \"complex_cone a b = (\\(r,a). rcis r a) ` ({0..} \\ closed_segment a b)\"\n\nlemma in_complex_cone_iff: \"z \\ complex_cone a b \\ (\\x\\closed_segment a b. z = rcis (norm z) x)\"\n by sorry\n\nlemma zero_in_complex_cone [simp, intro]: \"0 \\ complex_cone a b\"\n by sorry\n\nlemma in_complex_cone_iff_Arg: \n assumes \"a \\ {-pi<..pi}\" \"b \\ {-pi<..pi}\"\n shows \"z \\ complex_cone a b \\ z = 0 \\ Arg z \\ closed_segment a b\"\n by sorry\n\nlemma complex_cone_rotate: \"complex_cone (c + a) (c + b) = " }, { "theorem_id": 53, "title": "066_sum_of_a_geometric_series", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2019 Neil Strickland. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Neil Strickland\n-/\nmodule\n\npublic import Mathlib.Algebra.Field.Basic\npublic import Mathlib.Algebra.Ring.GeomSum\n\n/-!\n# Partial sums of geometric series in a field\n\nThis file determines the values of the geometric series $\\sum_{i=0}^{n-1} x^i$ and\n$\\sum_{i=0}^{n-1} x^i y^{n-1-i}$ and variants thereof.\n\n## Main statements\n\n* `geom_sum_Ico` proves that $\\sum_{i=m}^{n-1} x^i=\\frac{x^n-x^m}{x-1}$ in a division ring.\n* `geom_sum₂_Ico` proves that $\\sum_{i=m}^{n-1} x^iy^{n - 1 - i}=\\frac{x^n-y^{n-m}x^m}{x-y}$\n in a field.\n\nSeveral variants are recorded, generalising in particular to the case of a division ring in\nwhich `x` and `y` commute.\n-/\n\npublic section\n\nassert_not_exists IsOrderedRing\n\nvariable {R K : Type*}\n\nopen Finset MulOpposite\n\nsection DivisionRing\nvariable [DivisionRing K] {x y : K}\n\nprotected theorem Commute.geom_sum₂ (h' : Commute x y) (h : x ≠ y)\n (n : ℕ) : ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i) = (x ^ n - y ^ n) / (x - y) := by sorry\ntheorem geom_sum_eq (h : x ≠ 1) (n : ℕ) : ∑ i ∈ range n, x ^ i = (x ^ n - 1) / (x - 1) := by sorry\nlemma geom_sum_Ico (hx : x ≠ 1) {m n : ℕ} (hmn : m ≤ n) :\n ∑ i ∈ Finset.Ico m n, x ^ i = (x ^ n - x ^ m) / (x - 1) := by sorry\nlemma geom_sum_Ico' (hx : x ≠ 1) {m n : ℕ} (hmn : m ≤ n) :\n ∑ i ∈ Finset.Ico m n, x ^ i = (x ^ m - x ^ n) / (1 - x) := by sorry\nlemma geom_sum_inv (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :\n ∑ i ∈ range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by sorry\nend DivisionRing\n\nsection Field\nvariable [Field K] {x y : K}\n\nlemma geom₂_sum (h : x ≠ y) (n : ℕ) :\n ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i) = (x ^ n - y ^ n) / (x - y) :=\n (Commute.all x y).geom_sum₂ h n\n\nlemma geom_sum₂_Ico (hxy : x ≠ y) {m n : ℕ} (hmn : m ≤ n) :\n (∑ i ∈ Finset.Ico m n, x ^ i * y ^ (n - 1 - i)) = (x ^ n - y ^ (n - m) * x ^ m) / (x - y) :=\n (Commute.all x y).geom_sum₂_Ico hxy hmn\n\nend Field\n" }, { "theorem_id": 53, "title": "066_sum_of_a_geometric_series", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Export CoRN.ftc.FunctSeries.\nRequire Export CoRN.ftc.MoreFunctions.\n\nSection Definitions.\n\nVariable J : interval.\nVariable f : nat -> PartIR.\nVariable F : PartIR.\n\nHypothesis contf : forall n : nat, Continuous J (f n).\nHypothesis contF : Continuous J F.\n\nDefinition Cauchy_fun_seq_IR := forall a b Hab (Hinc : included (compact a b Hab) J),\n Cauchy_fun_seq _ _ _ f (fun n => included_imp_Continuous _ _ (contf n) _ _ _ Hinc).\n\nDefinition conv_fun_seq_IR := forall a b Hab (Hinc : included (Compact Hab) J),\n conv_fun_seq a b Hab f (fun n => included_imp_Continuous _ _ (contf n) _ _ _ Hinc).\n\nDefinition conv_fun_seq'_IR := forall a b Hab (Hinc : included (Compact Hab) J),\n conv_fun_seq' a b Hab f F\n (fun n => included_imp_Continuous _ _ (contf n) _ _ _ Hinc)\n (included_imp_Continuous _ _ contF _ _ _ Hinc).\n\nDefinition Cauchy_fun_seq2_IR := forall a b Hab (Hinc : included (compact a b Hab) J),\n Cauchy_fun_seq2 _ _ _ f (fun n => included_imp_Continuous _ _ (contf n) _ _ _ Hinc).\n\nLemma conv_Cauchy_fun_seq'_IR : conv_fun_seq'_IR -> Cauchy_fun_seq_IR.\nProof.\nAdmitted.\n\nLemma Cauchy_fun_seq_Lim_char : forall a b Hab (Hinc : included (Compact Hab) J),\n Feq (Compact Hab) Cauchy_fun_seq_Lim_IR\n (Cauchy_fun_seq_Lim _ _ _ _ _ (conv a b Hab Hinc)).\nProof.\nAdmitted.\n\nLemma FSeries_Sum_char : forall a b Hab (Hinc : included (Compact Hab) J),\n Feq (Compact Hab) FSeries_Sum (Fun_Series_Sum (H a b Hab Hinc)).\nProof.\nAdmitted.\n\nEnd Series_Definitions.\n\nArguments FSeries_Sum [J f].\n\nSection More_Series_Definitions.\n\nVariable J : interval.\nVariable f : nat -> PartIR.\n\nDefinition fun_series_abs_convergent_IR :=\n fun_series_convergent_IR J (fun n => FAbs (f n)).\n\nEnd More_Series_Definitions.\n\nSection Convergence_Results.\n\nVariable J : interval.\nVariable f : nat -> PartIR.\n\nLemma FSeries_conv : forall (convF : fun_series_convergent_IR J f) H H',\n conv_fun_seq'_IR J (fun n => FSum0 n f) (FSeries_Sum convF) H H'.\nProof.\nAdmitted.\n\nLemma convergent_imp_inc : fun_series_convergent_IR J f -> forall n, included J (Dom (f n)).\nProof.\nAdmitted.\n\nLemma convergent_imp_Continuous : fun_series_convergent_IR J f -> forall n,\n Continuous J (f n).\nProof.\nAdmitted.\n\nLemma Continuous_FSeries_Sum : forall H, Continuous J (FSeries_Sum (J:=J) (f:=f) H).\nProof.\nAdmitted.\n\nEnd Convergence_Results.\n\n#[global]\nHint Resolve convergent_imp_inc: included.\n#[global]\nHint Resolve convergent_imp_Continuous Continuous_FSeries_Sum: continuous.\n\nSection Operations.\n\nVariable J : interval.\n\nLemma conv_fun_const_series_IR : forall x : nat -> IR, convergent x ->\n fun_series_convergent_IR J (fun n => [-C-] (x n)).\nProof.\nAdmitted.\n\nLemma fun_const_series_Sum_IR : forall y H\n (H' : fun_series_convergent_IR J (fun n => [-C-] (y n))) x Hx, FSeries_Sum H' x Hx [=] series_sum y H.\nProof.\nAdmitted.\n\nLemma conv_zero_fun_series_IR : fun_series_convergent_IR J (fun n => [-C-][0]).\nProof.\nAdmitted.\n\nLemma FSeries_Sum_zero_IR : forall (H : fun_series_convergent_IR J (fun n => [-C-][0]))\n x Hx, FSeries_Sum H x Hx [=] [0].\nProof.\nAdmitted.\n\nVariables f g : nat -> PartIR.\n\nLemma fun_series_convergent_wd_IR : (forall n, Feq J (f n) (g n)) ->\n fun_series_convergent_IR J f -> fun_series_convergent_IR J g.\nProof.\nAdmitted.\n\nHypothesis convF : fun_series_convergent_IR J f.\nHypothesis convG : fun_series_convergent_IR J g.\n\nLemma FSeries_Sum_wd' : (forall n, Feq J (f n) (g n)) -> Feq J (FSeries_Sum convF) (FSeries_Sum convG).\nProof.\nAdmitted.\n\nLemma FSeries_Sum_plus_conv : fun_series_convergent_IR J (fun n => f n{+}g n).\nProof.\nAdmitted.\n\nLemma FSeries_Sum_plus : forall H : fun_series_convergent_IR J (fun n => f n{+}g n),\n Feq J (FSeries_Sum H) (FSeries_Sum convF{+}FSeries_Sum convG).\nProof.\nAdmitted.\n\nLemma FSeries_Sum_inv_conv : fun_series_convergent_IR J (fun n => {--} (f n)).\nProof.\nAdmitted.\n\nLemma FSeries_Sum_inv : forall H : fun_series_convergent_IR J (fun n => {--} (f n)),\n Feq J (FSeries_Sum H) {--} (FSeries_Sum convF).\nProof.\nAdmitted.\n\nLemma FSeries_Sum_minus_conv : fun_series_convergent_IR J (fun n => f n{-}g n).\nProof.\nAdmitted.\n\nLemma FSeries_Sum_minus : forall H : fun_series_convergent_IR J (fun n => f n{-}g n),\n Feq J (FSeries_Sum H) (FSeries_Sum convF{-}FSeries_Sum convG).\nProof.\nAdmitted.\n\nVariable c : IR.\nVariable H : PartIR.\nHypothesis contH : Continuous J H.\n\nLemma FSeries_Sum_scal_conv : fun_series_convergent_IR J (fun n => H{*}f n).\nProof.\nAdmitted.\n\nLemma FSeries_Sum_scal : forall H' : fun_series_convergent_IR J (fun n => H{*}f n),\n Feq J (FSeries_Sum H') (H{*}FSeries_Sum convF).\nProof.\nAdmitted.\n\nEnd Operations.\n\nSection Convergence_Criteria.\n\nVariable J : interval.\nVariable f : nat -> PartIR.\nHypothesis contF : forall n, Continuous J (f n).\n\nLemma fun_str_comparison_IR : forall g : nat -> PartIR, fun_series_convergent_IR J g ->\n {k : nat | forall n, k <= n -> forall x, J x -> forall Hx Hx', AbsIR (f n x Hx) [<=] g n x Hx'} ->\n fun_series_convergent_IR J f.\nProof.\nAdmitted.\n\nLemma fun_comparison_IR : forall g : nat -> PartIR, fun_series_convergent_IR J g ->\n (forall n x, J x -> forall Hx Hx', AbsIR (f n x Hx) [<=] g n x Hx') ->\n fun_series_convergent_IR J f.\nProof.\nAdmitted.\n\nLemma abs_imp_conv_IR : fun_series_abs_convergent_IR J f ->\n fun_series_convergent_IR J f.\nProof.\nAdmitted.\n\nLemma fun_ratio_test_conv_IR : {N : nat | {c : IR | c [<] [1] | [0] [<=] c /\\ (forall x,\n J x -> forall n, N <= n -> forall Hx Hx', AbsIR (f (S n) x Hx') [<=] c[*]AbsIR (f n x Hx))}} ->\n fun_series_convergent_IR J f.\nProof.\nAdmitted.\n\nEnd Convergence_Criteria.\n\nSection Power_Series.\n\nLemma fun_power_series_conv_IR : fun_series_convergent_IR (olor ([--][1]) [1]) (fun (i:nat) => Fid IR{^}i).\nProof.\nAdmitted.\n\nEnd Power_Series.\n\nSection Insert_Series.\n\nVariable J : interval.\nVariable f : nat -> PartIR.\nHypothesis convF : fun_series_convergent_IR J f.\n\nDefinition insert_series n : PartIR :=\n match n with\n | O => [-C-][0]\n | S p => f p\n end.\n\nLemma insert_series_cont : forall n, Continuous J (insert_series n).\nProof.\nAdmitted.\n\nLemma insert_series_sum_char : forall n x Hx Hx',\n fun_seq_part_sum f n x Hx [=] fun_seq_part_sum insert_series (S n) x Hx'.\nProof.\nAdmitted.\n\nLemma insert_series_conv : fun_series_convergent_IR J insert_series.\nProof.\nAdmitted.\n\nLemma insert_series_sum : Feq J (FSeries_Sum convF) (FSeries_Sum insert_series_conv).\nProof.\nAdmitted.\n\nEnd Insert_Series." }, { "theorem_id": 54, "title": "069_greatest_common_divisor_algorithm", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";;\n\nlet egcd = define\n `egcd(m,n) = if m = 0 then n\n else if n = 0 then m\n else if m <= n then egcd(m,n - m)\n else egcd(m - n,n)`;;\n\nlet EGCD_INVARIANT = `!m n d. d divides egcd(m,n) <=> d divides m /\\ d divides n`;;\n\nlet EGCD_GCD = `!m n. egcd(m,n) = gcd(m,n)`;;\n\nlet EGCD = `!a b. (egcd (a,b) divides a /\\ egcd (a,b) divides b) /\\\n (!e. e divides a /\\ e divides b ==> e divides egcd (a,b))`;;" }, { "theorem_id": 54, "title": "069_greatest_common_divisor_algorithm", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Greatest common divisor and least common multiple\\\n\ntheory GCD\n imports Groups_List Code_Numeral\nbegin\n\nsubsection \\Abstract bounded quasi semilattices as common foundation\\\n\nlocale bounded_quasi_semilattice = abel_semigroup +\n fixes top :: 'a (\\\\<^bold>\\\\) and bot :: 'a (\\\\<^bold>\\\\)\n and normalize :: \"'a \\ 'a\"\n assumes idem_normalize [simp]: \"a \\<^bold>* a = normalize a\"\n and normalize_left_idem [simp]: \"normalize a \\<^bold>* b = a \\<^bold>* b\"\n and normalize_idem [simp]: \"normalize (a \\<^bold>* b) = a \\<^bold>* b\"\n and normalize_top [simp]: \"normalize \\<^bold>\\ = \\<^bold>\\\"\n and normalize_bottom [simp]: \"normalize \\<^bold>\\ = \\<^bold>\\\"\n and top_left_normalize [simp]: \"\\<^bold>\\ \\<^bold>* a = normalize a\"\n and bottom_left_bottom [simp]: \"\\<^bold>\\ \\<^bold>* a = \\<^bold>\\\"\nbegin\n\nlemma left_idem [simp]:\n \"a \\<^bold>* (a \\<^bold>* b) = a \\<^bold>* b\"\n by sorry\n\nlemma right_idem [simp]:\n \"(a \\<^bold>* b) \\<^bold>* b = a \\<^bold>* b\"\n by sorry\n\nlemma comp_fun_idem: \"comp_fun_idem f\"\n by sorry\n\ninterpretation comp_fun_idem f\n by (fact comp_fun_idem)\n\nlemma top_right_normalize [simp]:\n \"a \\<^bold>* \\<^bold>\\ = normalize a\"\n by sorry\n\nlemma bottom_right_bottom [simp]:\n \"a \\<^bold>* \\<^bold>\\ = \\<^bold>\\\"\n by sorry\n\nlemma normalize_right_idem [simp]:\n \"a \\<^bold>* normalize b = a \\<^bold>* b\"\n by sorry\n\nend\n\nlocale bounded_quasi_semilattice_set = bounded_quasi_semilattice\nbegin\n\ninterpretation comp_fun_idem f\n by (fact comp_fun_idem)\n\ndefinition F :: \"'a set \\ 'a\"\nwhere\n eq_fold: \"F A = (if finite A then Finite_Set.fold f \\<^bold>\\ A else \\<^bold>\\)\"\n\nlemma infinite [simp]:\n \"infinite A \\ F A = \\<^bold>\\\"\n by sorry\n\nlemma set_eq_fold [code]:\n \"F (set xs) = fold f xs \\<^bold>\\\"\n by sorry\n\nlemma empty [simp]:\n \"F {} = \\<^bold>\\\"\n by sorry\n\nlemma insert [simp]:\n \"F (insert a A) = a \\<^bold>* F A\"\n by sorry\n\nlemma normalize [simp]:\n \"normalize (F A) = F A\"\n by sorry\n\nlemma in_idem:\n assumes \"a \\ A\"\n shows \"a \\<^bold>* F A = F A\"\n by sorry\n\nlemma union:\n \"F (A \\ B) = F A \\<^bold>* F B\"\n by sorry\n\nlemma remove:\n assumes \"a \\ A\"\n shows \"F A = a \\<^bold>* F (A - {a})\"\n by sorry\n\nlemma insert_remove:\n \"F (insert a A) = a \\<^bold>* F (A - {a})\"\n by sorry\n\nlemma subset:\n assumes \"B \\ A\"\n shows \"F B \\<^bold>* F A = F A\"\n by sorry\n\nend\n\nsubsection \\Abstract GCD and LCM\\\n\nclass gcd = zero + one + dvd +\n fixes gcd :: \"'a \\ 'a \\ 'a\"\n and lcm :: \"'a \\ 'a \\ 'a\"\n\nclass Gcd = gcd +\n fixes Gcd :: \"'a set \\ 'a\"\n and Lcm :: \"'a set \\ 'a\"\n\nsyntax\n \"_GCD1\" :: \"pttrns \\ 'b \\ 'b\" (\\(\\indent=3 notation=\\binder GCD\\\\GCD _./ _)\\ [0, 10] 10)\n \"_GCD\" :: \"pttrn \\ 'a set \\ 'b \\ 'b\" (\\(\\indent=3 notation=\\binder GCD\\\\GCD _\\_./ _)\\ [0, 0, 10] 10)\n \"_LCM1\" :: \"pttrns \\ 'b \\ 'b\" (\\(\\indent=3 notation=\\binder LCM\\\\LCM _./ _)\\ [0, 10] 10)\n \"_LCM\" :: \"pttrn \\ 'a set \\ 'b \\ 'b\" (\\(\\indent=3 notation=\\binder LCM\\\\LCM _\\_./ _)\\ [0, 0, 10] 10)\n\nsyntax_consts\n \"_GCD1\" \"_GCD\" \\ Gcd and\n \"_LCM1\" \"_LCM\" \\ Lcm\n\ntranslations\n \"GCD x y. f\" \\ \"GCD x. GCD y. f\"\n \"GCD x. f\" \\ \"CONST Gcd (CONST range (\\x. f))\"\n \"GCD x\\A. f\" \\ \"CONST Gcd ((\\x. f) ` A)\"\n \"LCM x y. f\" \\ \"LCM x. LCM y. f\"\n \"LCM x. f\" \\ \"CONST Lcm (CONST range (\\x. f))\"\n \"LCM x\\A. f\" \\ \"CONST Lcm ((\\x. f) ` A)\"\n\nclass semiring_gcd = normalization_semidom + gcd +\n assumes gcd_dvd1 [iff]: \"gcd a b dvd a\"\n and gcd_dvd2 [iff]: \"gcd a b dvd b\"\n and gcd_greatest: \"c dvd a \\ c dvd b \\ c dvd gcd a b\"\n and normalize_gcd [simp]: \"normalize (gcd a b) = gcd a b\"\n and lcm_gcd: \"lcm a b = normalize (a * b div gcd a b)\"\nbegin\n\nlemma gcd_greatest_iff [simp]: \"a dvd gcd b c \\ a dvd b \\ a dvd c\"\n by sorry\n\nlemma gcd_dvdI1: \"a dvd c \\ gcd a b dvd c\"\n by sorry\n\nlemma gcd_dvdI2: \"b dvd c \\ gcd a b dvd c\"\n by sorry\n\nlemma dvd_gcdD1: \"a dvd gcd b c \\ a dvd b\"\n by sorry\n\nlemma dvd_gcdD2: \"a dvd gcd b c \\ a dvd c\"\n by sorry\n\nlemma gcd_0_left [simp]: \"gcd 0 a = normalize a\"\n by sorry\n\nlemma gcd_0_right [simp]: \"gcd a 0 = normalize a\"\n by sorry\n\nlemma gcd_eq_0_iff [simp]: \"gcd a b = 0 \\ a = 0 \\ b = 0\"\n (is \"?P \\ ?Q\")\n by sorry\n\nlemma unit_factor_gcd: \"unit_factor (gcd a b) = (if a = 0 \\ b = 0 then 0 else 1)\"\n by sorry\n\nlemma is_unit_gcd_iff [simp]:\n \"is_unit (gcd a b) \\ gcd a b = 1\"\n by sorry\n\nsublocale gcd: abel_semigroup gcd\nproof\n fix a b c\n show \"gcd a b = gcd b a\"\n by (rule associated_eqI) simp_all\n from gcd_dvd1 have \"gcd (gcd a b) c dvd a\"\n by (rule dvd_trans) simp\n moreover from gcd_dvd1 have \"gcd (gcd a b) c dvd b\"\n by (rule dvd_trans) simp\n ultimately have P1: \"gcd (gcd a b) c dvd gcd a (gcd b c)\"\n by (auto intro!: gcd_greatest)\n from gcd_dvd2 have \"gcd a (gcd b c) dvd b\"\n by (rule dvd_trans) simp\n moreover from gcd_dvd2 have \"gcd a (gcd b c) dvd c\"\n by (rule dvd_trans) simp\n ultimately have P2: \"gcd a (gcd b c) dvd gcd (gcd a b) c\"\n by (auto intro!: gcd_greatest)\n from P1 P2 show \"gcd (gcd a b) c = gcd a (gcd b c)\"\n by (rule associated_eqI) simp_all\nqed\n\nsublocale gcd: bounded_quasi_semilattice gcd 0 1 normalize\nproof\n show \"gcd a a = normalize a\" for a\n proof -\n have \"a dvd gcd a a\"\n by (rule gcd_greatest) simp_all\n then show ?thesis\n by (auto intro: associated_eqI)\n qed\n show \"gcd (normalize a) b = gcd a b\" for a b\n using gcd_dvd1 [of \"normalize a\" b]\n by (auto intro: associated_eqI)\n show \"gcd 1 a = 1\" for a\n by (rule associated_eqI) simp_all\nqed simp_all\n\nlemma gcd_self: \"gcd a a = normalize a\"\n by sorry\n\nlemma gcd_left_idem: \"gcd a (gcd a b) = gcd a b\"\n by sorry\n\nlemma gcd_right_idem: \"gcd (gcd a b) b = gcd a b\"\n by sorry\n\nlemma gcdI:\n assumes \"c dvd a\" and \"c dvd b\"\n and greatest: \"\\d. d dvd a \\ d dvd b \\ d dvd c\"\n and \"normalize c = c\"\n shows \"c = gcd a b\"\n by sorry\n\nlemma gcd_unique:\n \"d dvd a \\ d dvd b \\ normalize d = d \\ (\\e. e dvd a \\ e dvd b \\ e dvd d) \\ d = gcd a b\"\n by sorry\n\nlemma gcd_dvd_prod: \"gcd a b dvd k * b\"\n by sorry\n\nlemma gcd_proj2_if_dvd: \"b dvd a \\ gcd a b = normalize b\"\n by sorry\n\nlemma gcd_proj1_if_dvd: \"a dvd b \\ gcd a b = normalize a\"\n by sorry\n\nlemma gcd_proj1_iff: \"gcd m n = normalize m \\ m dvd n\"\n by sorry\n\nlemma gcd_proj2_iff: \"gcd m n = normalize n \\ n dvd m\"\n by sorry\n\nlemma gcd_mult_left: \"gcd (c * a) (c * b) = normalize (c * gcd a b)\"\n by sorry\n\nlemma gcd_mult_right: \"gcd (a * c) (b * c) = normalize (gcd b a * c)\"\n by sorry\n\nlemma dvd_lcm1 [iff]: \"a dvd lcm a b\"\n by sorry\n\nlemma dvd_lcm2 [iff]: \"b dvd lcm a b\"\n by sorry\n\nlemma dvd_lcmI1: \"a dvd b \\ a dvd lcm b c\"\n by sorry\n\nlemma dvd_lcmI2: \"a dvd c \\ a dvd lcm b c\"\n by sorry\n\nlemma lcm_dvdD1: \"lcm a b dvd c \\ a dvd c\"\n by sorry\n\nlemma lcm_dvdD2: \"lcm a b dvd c \\ b dvd c\"\n by sorry\n\nlemma lcm_least:\n assumes \"a dvd c\" and \"b dvd c\"\n shows \"lcm a b dvd c\"\n by sorry\n\nlemma lcm_least_iff [simp]: \"lcm a b dvd c \\ a dvd c \\ b dvd c\"\n by sorry\n\nlemma normalize_lcm [simp]: \"normalize (lcm a b) = lcm a b\"\n by sorry\n\nlemma lcm_0_left [simp]: \"lcm 0 a = 0\"\n by sorry\n\nlemma lcm_0_right [simp]: \"lcm a 0 = 0\"\n by sorry\n\nlemma lcm_eq_0_iff: \"lcm a b = 0 \\ a = 0 \\ b = 0\"\n (is \"?P \\ ?Q\")\n by sorry\n\nlemma zero_eq_lcm_iff: \"0 = lcm a b \\ a = 0 \\ b = 0\"\n by sorry\n\nlemma lcm_eq_1_iff [simp]: \"lcm a b = 1 \\ is_unit a \\ is_unit b\"\n by sorry\n\nlemma unit_factor_lcm: \"unit_factor (lcm a b) = (if a = 0 \\ b = 0 then 0 else 1)\"\n by sorry\n\nsublocale lcm: abel_semigroup lcm\nproof\n fix a b c\n show \"lcm a b = lcm b a\"\n by (simp add: lcm_gcd ac_simps normalize_mult dvd_normalize_div)\n have \"lcm (lcm a b) c dvd lcm a (lcm b c)\"\n and \"lcm a (lcm b c) dvd lcm (lcm a b) c\"\n by (auto intro: lcm_least\n dvd_trans [of b \"lcm b c\" \"lcm a (lcm b c)\"]\n dvd_trans [of c \"lcm b c\" \"lcm a (lcm b c)\"]\n dvd_trans [of a \"lcm a b\" \"lcm (lcm a b) c\"]\n dvd_trans [of b \"lcm a b\" \"lcm (lcm a b) c\"])\n then show \"lcm (lcm a b) c = lcm a (lcm b c)\"\n by (rule associated_eqI) simp_all\nqed\n\nsublocale lcm: bounded_quasi_semilattice lcm 1 0 normalize\nproof\n show \"lcm a a = normalize a\" for a\n proof -\n have \"lcm a a dvd a\"\n by (rule lcm_least) simp_all\n then show ?thesis\n by (auto intro: associated_eqI)\n qed\n show \"lcm (normalize a) b = lcm a b\" for a b\n using dvd_lcm1 [of \"normalize a\" b] unfolding normalize_dvd_iff\n by (auto intro: associated_eqI)\n show \"lcm 1 a = normalize a\" for a\n by (rule associated_eqI) simp_all\nqed simp_all\n\nlemma lcm_self: \"lcm a a = normalize a\"\n by sorry\n\nlemma lcm_left_idem: \"lcm a (lcm a b) = lcm a b\"\n by sorry\n\nlemma lcm_right_idem: \"lcm (lcm a b) b = lcm a b\"\n by sorry\n\nlemma gcd_lcm:\n assumes \"a \\ 0\" and \"b \\ 0\"\n shows \"gcd a b = normalize (a * b div lcm a b)\"\n by sorry\n\nlemma lcm_1_left: \"lcm 1 a = normalize a\"\n by sorry\n\nlemma lcm_1_right: \"lcm a 1 = normalize a\"\n by sorry\n\nlemma lcm_mult_left: \"lcm (c * a) (c * b) = normalize (c * lcm a b)\"\n by sorry\n\nlemma lcm_mult_right: \"lcm (a * c) (b * c) = normalize (lcm b a * c)\"\n by sorry\n\nlemma lcm_mult_unit1: \"is_unit a \\ lcm (b * a) c = lcm b c\"\n by sorry\n\nlemma lcm_mult_unit2: \"is_unit a \\ lcm b (c * a) = lcm b c\"\n by sorry\n\nlemma lcm_div_unit1:\n \"is_unit a \\ lcm (b div a) c = lcm b c\"\n by sorry\n\nlemma lcm_div_unit2: \"is_unit a \\ lcm b (c div a) = lcm b c\"\n by sorry\n\nlemma normalize_lcm_left: \"lcm (normalize a) b = lcm a b\"\n by sorry\n\nlemma normalize_lcm_right: \"lcm a (normalize b) = lcm a b\"\n by sorry\n\nlemma comp_fun_idem_gcd: \"comp_fun_idem gcd\"\n by sorry\n\nlemma comp_fun_idem_lcm: \"comp_fun_idem lcm\"\n by sorry\n\nlemma gcd_dvd_antisym: \"gcd a b dvd gcd c d \\ gcd c d dvd gcd a b \\ gcd a b = gcd c d\"\n by sorry\n\ndeclare unit_factor_lcm [simp]\n\nlemma lcmI:\n assumes \"a dvd c\" and \"b dvd c\" and \"\\d. a dvd d \\ b dvd d \\ c dvd d\"\n and \"normalize c = c\"\n shows \"c = lcm a b\"\n by sorry\n\nlemma gcd_dvd_lcm [simp]: \"gcd a b dvd lcm a b\"\n by sorry\n\nlemmas lcm_0 = lcm_0_right\n\nlemma lcm_unique:\n \"a dvd d \\ b dvd d \\ normalize d = d \\ (\\e. a dvd e \\ b dvd e \\ d dvd e) \\ d = lcm a b\"\n by sorry\n\nlemma lcm_proj1_if_dvd:\n assumes \"b dvd a\" shows \"lcm a b = normalize a\"\n by sorry\n\nlemma lcm_proj2_if_dvd: \"a dvd b \\ lcm a b = normalize b\"\n by sorry\n\nlemma lcm_proj1_iff: \"lcm m n = normalize m \\ n dvd m\"\n by sorry\n\nlemma lcm_proj2_iff: \"lcm m n = normalize n \\ m dvd n\"\n by sorry\n\nlemma gcd_mono: \"a dvd c \\ b dvd d \\ gcd a b dvd gcd c d\"\n by sorry\n\nlemma lcm_mono: \"a dvd c \\ b dvd d \\ lcm a b dvd lcm c d\"\n by sorry\n\nlemma dvd_productE:\n assumes \"p dvd a * b\"\n obtains x y where \"p = x * y\" \"x dvd a\" \"y dvd b\"\n by sorry\n\nlemma gcd_mult_unit1: \n assumes \"is_unit a\" shows \"gcd (b * a) c = gcd b c\"\n by sorry\n\nlemma gcd_mult_unit2: \"is_unit a \\ gcd b (c * a) = gcd b c\"\n by sorry\n\nlemma gcd_div_unit1: \"is_unit a \\ gcd (b div a) c = gcd b c\"\n by sorry\n\nlemma gcd_div_unit2: \"is_unit a \\ gcd b (c div a) = gcd b c\"\n by sorry\n\nlemma normalize_gcd_left: \"gcd (normalize a) b = gcd a b\"\n by sorry\n\nlemma normalize_gcd_right: \"gcd a (normalize b) = gcd a b\"\n by sorry\n\nlemma gcd_add1 [simp]: \"gcd (m + n) n = gcd m n\"\n by sorry\n\nlemma gcd_add2 [simp]: \"gcd m (m + n) = gcd m n\"\n by sorry\n\nlemma gcd_add_mult: \"gcd m (k * m + n) = gcd m n\"\n by sorry\n\nend\n\nclass ring_gcd = comm_ring_1 + semiring_gcd\nbegin\n\nlemma gcd_neg1 [simp]: \"gcd (-a) b = gcd a b\"\n by sorry\n\nlemma gcd_neg2 [simp]: \"gcd a (-b) = gcd a b\"\n by sorry\n\nlemma gcd_neg_numeral_1 [simp]: \"gcd (- numeral n) a = gcd (numeral n) a\"\n by sorry\n\nlemma gcd_neg_numeral_2 [simp]: \"gcd a (- numeral n) = gcd a (numeral n)\"\n by sorry\n\nlemma gcd_diff1: \"gcd (m - n) n = gcd m n\"\n by sorry\n\nlemma gcd_diff2: \"gcd (n - m) n = gcd m n\"\n by sorry\n\nlemma lcm_neg1 [simp]: \"lcm (-a) b = lcm a b\"\n by sorry\n\nlemma lcm_neg2 [simp]: \"lcm a (-b) = lcm a b\"\n by sorry\n\nlemma lcm_neg_numeral_1 [simp]: \"lcm (- numeral n) a = lcm (numeral n) a\"\n by sorry\n\nlemma lcm_neg_numeral_2 [simp]: \"lcm a (- numeral n) = lcm a (numeral n)\"\n by sorry\n\nend\n\nclass semiring_Gcd = semiring_gcd + Gcd +\n assumes Gcd_dvd: \"a \\ A \\ Gcd A dvd a\"\n and Gcd_greatest: \"(\\b. b \\ A \\ a dvd b) \\ a dvd Gcd A\"\n and normalize_Gcd [simp]: \"normalize (Gcd A) = Gcd A\"\n assumes dvd_Lcm: \"a \\ A \\ a dvd Lcm A\"\n and Lcm_least: \"(\\b. b \\ A \\ b dvd a) \\ Lcm A dvd a\"\n and normalize_Lcm [simp]: \"normalize (Lcm A) = Lcm A\"\nbegin\n\nlemma Lcm_Gcd: \"Lcm A = Gcd {b. \\a\\A. a dvd b}\"\n by sorry\n\nlemma Gcd_Lcm: \"Gcd A = Lcm {b. \\a\\A. b dvd a}\"\n by sorry\n\nlemma Gcd_empty [simp]: \"Gcd {} = 0\"\n by sorry\n\nlemma Lcm_empty [simp]: \"Lcm {} = 1\"\n by sorry\n\nlemma Gcd_insert [simp]: \"Gcd (insert a A) = gcd a (Gcd A)\"\n by sorry\n\nlemma Lcm_insert [simp]: \"Lcm (insert a A) = lcm a (Lcm A)\"\n by sorry\n\nlemma LcmI:\n assumes \"\\a. a \\ A \\ a dvd b\"\n and \"\\c. (\\a. a \\ A \\ a dvd c) \\ b dvd c\"\n and \"normalize b = b\"\n shows \"b = Lcm A\"\n by sorry\n\nlemma Lcm_subset: \"A \\ B \\ Lcm A dvd Lcm B\"\n by sorry\n\nlemma Lcm_Un: \"Lcm (A \\ B) = lcm (Lcm A) (Lcm B)\"\n by sorry\n\nlemma Gcd_0_iff [simp]: \"Gcd A = 0 \\ A \\ {0}\"\n (is \"?P \\ ?Q\")\n by sorry\n\nlemma Lcm_1_iff [simp]: \"Lcm A = 1 \\ (\\a\\A. is_unit a)\"\n (is \"?P \\ ?Q\")\n by sorry\n\nlemma unit_factor_Lcm: \"unit_factor (Lcm A) = (if Lcm A = 0 then 0 else 1)\"\n by sorry\n\nlemma unit_factor_Gcd: \"unit_factor (Gcd A) = (if Gcd A = 0 then 0 else 1)\"\n by sorry\n\nlemma GcdI:\n assumes \"\\a. a \\ A \\ b dvd a\"\n and \"\\c. (\\a. a \\ A \\ c dvd a) \\ c dvd b\"\n and \"normalize b = b\"\n shows \"b = Gcd A\"\n by sorry\n\nlemma Gcd_eq_1_I:\n assumes \"is_unit a\" and \"a \\ A\"\n shows \"Gcd A = 1\"\n by sorry\n\nlemma Lcm_eq_0_I:\n assumes \"0 \\ A\"\n shows \"Lcm A = 0\"\n by sorry\n\nlemma Gcd_UNIV [simp]: \"Gcd UNIV = 1\"\n by sorry\n\nlemma Lcm_UNIV [simp]: \"Lcm UNIV = 0\"\n by sorry\n\nlemma Lcm_0_iff:\n assumes \"finite A\"\n shows \"Lcm A = 0 \\ 0 \\ A\"\n by sorry\n\nlemma Gcd_image_normalize [simp]: \"Gcd (normalize ` A) = Gcd A\"\n by sorry\n\nlemma Gcd_eqI:\n assumes \"normalize a = a\"\n assumes \"\\b. b \\ A \\ a dvd b\"\n and \"\\c. (\\b. b \\ A \\ c dvd b) \\ c dvd a\"\n shows \"Gcd A = a\"\n by sorry\n\nlemma dvd_GcdD: \"x dvd Gcd A \\ y \\ A \\ x dvd y\"\n by sorry\n\nlemma dvd_Gcd_iff: \"x dvd Gcd A \\ (\\y\\A. x dvd y)\"\n by sorry\n\nlemma Gcd_mult: \"Gcd (" }, { "theorem_id": 54, "title": "069_greatest_common_divisor_algorithm", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Louis Carlin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Louis Carlin, Mario Carneiro\n-/\nmodule\n\npublic import Mathlib.Algebra.Ring.Defs\npublic import Mathlib.Order.RelClasses\n\n/-!\n# Euclidean domains\n\nThis file introduces Euclidean domains and provides the extended Euclidean algorithm. To be precise,\na slightly more general version is provided which is sometimes called a transfinite Euclidean domain\nand differs in the fact that the degree function need not take values in `ℕ` but can take values in\nany well-ordered set. Transfinite Euclidean domains were introduced by Motzkin and examples which\ndon't satisfy the classical notion were provided independently by Hiblot and Nagata.\n\n## Main definitions\n\n* `EuclideanDomain`: Defines Euclidean domain with functions `quotient` and `remainder`. Instances\n of `Div` and `Mod` are provided, so that one can write `a = b * (a / b) + a % b`.\n* `gcd`: defines the greatest common divisors of two elements of a Euclidean domain.\n* `xgcd`: given two elements `a b : R`, `xgcd a b` defines the pair `(x, y)` such that\n `x * a + y * b = gcd a b`.\n* `lcm`: defines the lowest common multiple of two elements `a` and `b` of a Euclidean domain as\n `a * b / (gcd a b)`\n\n## Main statements\n\nSee `Algebra.EuclideanDomain.Basic` for most of the theorems about Euclidean domains,\nincluding Bézout's lemma.\n\nSee `Algebra.EuclideanDomain.Instances` for the fact that `ℤ` is a Euclidean domain,\nas is any field.\n\n## Notation\n\n`≺` denotes the well-founded relation on the Euclidean domain, e.g. in the example of the polynomial\nring over a field, `p ≺ q` for polynomials `p` and `q` if and only if the degree of `p` is less than\nthe degree of `q`.\n\n## Implementation details\n\nInstead of working with a valuation, `EuclideanDomain` is implemented with the existence of a well\nfounded relation `r` on the integral domain `R`, which in the example of `ℤ` would correspond to\nsetting `i ≺ j` for integers `i` and `j` if the absolute value of `i` is smaller than the absolute\nvalue of `j`.\n\n## References\n\n* [Th. Motzkin, *The Euclidean algorithm*][MR32592]\n* [J.-J. Hiblot, *Des anneaux euclidiens dont le plus petit algorithme n'est pas à valeurs finies*]\n [MR399081]\n* [M. Nagata, *On Euclid algorithm*][MR541021]\n\n\n## Tags\n\nEuclidean domain, transfinite Euclidean domain, Bézout's lemma\n-/\n\n@[expose] public section\n\nuniverse u\n\n/-- A `EuclideanDomain` is a non-trivial commutative ring with a division and a remainder,\n satisfying `b * (a / b) + a % b = a`.\n The definition of a Euclidean domain usually includes a valuation function `R → ℕ`.\n This definition is slightly generalised to include a well-founded relation\n `r` with the property that `r (a % b) b`, instead of a valuation. -/\nclass EuclideanDomain (R : Type u) extends CommRing R, Nontrivial R where\n /-- A division function (denoted `/`) on `R`.\n This satisfies the property `b * (a / b) + a % b = a`, where `%` denotes `remainder`. -/\n protected quotient : R → R → R\n /-- Division by zero should always give zero by convention. -/\n protected quotient_zero : ∀ a, quotient a 0 = 0\n /-- A remainder function (denoted `%`) on `R`.\n This satisfies the property `b * (a / b) + a % b = a`, where `/` denotes `quotient`. -/\n protected remainder : R → R → R\n /-- The property that links the quotient and remainder functions.\n This allows us to compute GCDs and LCMs. -/\n protected quotient_mul_add_remainder_eq : ∀ a b, b * quotient a b + remainder a b = a\n /-- A well-founded relation on `R`, satisfying `r (a % b) b`.\n This ensures that the GCD algorithm always terminates. -/\n protected r : R → R → Prop\n /-- The relation `r` must be well-founded.\n This ensures that the GCD algorithm always terminates. -/\n r_wellFounded : WellFounded r\n /-- The relation `r` satisfies `r (a % b) b`. -/\n protected remainder_lt : ∀ (a) {b}, b ≠ 0 → r (remainder a b) b\n /-- An additional constraint on `r`. -/\n mul_left_not_lt : ∀ (a) {b}, b ≠ 0 → ¬r (a * b) a\n\nnamespace EuclideanDomain\n\nvariable {R : Type u} [EuclideanDomain R]\n\n/-- Abbreviated notation for the well-founded relation `r` in a Euclidean domain. -/\nlocal infixl:50 \" ≺ \" => EuclideanDomain.r\n\nlocal instance wellFoundedRelation : WellFoundedRelation R where\n rel := EuclideanDomain.r\n wf := r_wellFounded\n\ninstance isWellFounded : IsWellFounded R (· ≺ ·) where\n wf := r_wellFounded\n\n-- see Note [lower instance priority]\ninstance (priority := 70) : Div R :=\n ⟨EuclideanDomain.quotient⟩\n\n-- see Note [lower instance priority]\ninstance (priority := 70) : Mod R :=\n ⟨EuclideanDomain.remainder⟩\n\ntheorem div_add_mod (a b : R) : b * (a / b) + a % b = a :=\n EuclideanDomain.quotient_mul_add_remainder_eq _ _\n\ntheorem mod_add_div (a b : R) : a % b + b * (a / b) = a :=\n (add_comm _ _).trans (div_add_mod _ _)\n\ntheorem mod_add_div' (m k : R) : m % k + m / k * k = m := by sorry\ntheorem div_add_mod' (m k : R) : m / k * k + m % k = m := by sorry\ntheorem mod_lt : ∀ (a) {b : R}, b ≠ 0 → a % b ≺ b :=\n EuclideanDomain.remainder_lt\n\ntheorem mul_right_not_lt {a : R} (b) (h : a ≠ 0) : ¬a * b ≺ b := by sorry\ntheorem mod_zero (a : R) : a % 0 = a := by simpa only [zero_mul, zero_add] using div_add_mod a 0\n\ntheorem lt_one (a : R) : a ≺ (1 : R) → a = 0 :=\n haveI := Classical.dec\n not_imp_not.1 fun h => by simpa only [one_mul] using mul_left_not_lt 1 h\n\n@[simp]\ntheorem div_zero (a : R) : a / 0 = 0 :=\n EuclideanDomain.quotient_zero a\n\nsection\n\n@[elab_as_elim]\ntheorem GCD.induction {P : R → R → Prop} (a b : R) (H0 : ∀ x, P 0 x)\n (H1 : ∀ a b, a ≠ 0 → P (b % a) a → P a b) : P a b := by sorry\nend\n\nsection GCD\n\nvariable [DecidableEq R]\n\n/-- `gcd a b` is a (non-unique) element such that `gcd a b ∣ a` `gcd a b ∣ b`, and for\n any element `c` such that `c ∣ a` and `c ∣ b`, then `c ∣ gcd a b` -/\ndef gcd (a b : R) : R :=\n if a0 : a = 0 then b\n else\n have _ := mod_lt b a0\n gcd (b % a) a\ntermination_by a\n\n@[simp]\ntheorem gcd_zero_left (a : R) : gcd 0 a = a := by sorry\ndef xgcdAux (r s t r' s' t' : R) : R × R × R :=\n if _hr : r = 0 then (r', s', t')\n else\n let q := r' / r\n have _ := mod_lt r' _hr\n xgcdAux (r' % r) (s' - q * s) (t' - q * t) r s t\ntermination_by r\n\n@[simp]\ntheorem xgcd_zero_left {s t r' s' t' : R} : xgcdAux 0 s t r' s' t' = (r', s', t') := by sorry\ntheorem xgcdAux_rec {r s t r' s' t' : R} (h : r ≠ 0) :\n xgcdAux r s t r' s' t' = xgcdAux (r' % r) (s' - r' / r * s) (t' - r' / r * t) r s t := by sorry\ndef xgcd (x y : R) : R × R :=\n (xgcdAux x 1 0 y 0 1).2\n\n/-- The extended GCD `a` value in the equation `gcd x y = x * a + y * b`. -/\ndef gcdA (x y : R) : R :=\n (xgcd x y).1\n\n/-- The extended GCD `b` value in the equation `gcd x y = x * a + y * b`. -/\ndef gcdB (x y : R) : R :=\n (xgcd x y).2\n\n@[simp]\ntheorem gcdA_zero_left {s : R} : gcdA 0 s = 0 := by sorry\ntheorem gcdB_zero_left {s : R} : gcdB 0 s = 1 := by sorry\ntheorem xgcd_val (x y : R) : xgcd x y = (gcdA x y, gcdB x y) :=\n rfl\n\nend GCD\n\nsection LCM\n\nvariable [DecidableEq R]\n\n/-- `lcm a b` is a (non-unique) element such that `a ∣ lcm a b` `b ∣ lcm a b`, and for\n any element `c` such that `a ∣ c` and `b ∣ c`, then `lcm a b ∣ c` -/\ndef lcm (x y : R) : R :=\n x * y / gcd x y\n\nend LCM\n\nend EuclideanDomain\n" }, { "theorem_id": 54, "title": "069_greatest_common_divisor_algorithm", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "#[local] Set Warnings \"-deprecated-library-file,-deprecated-reference,-deprecated-syntactic-definition\".\n\nFrom Stdlib Require Import ZArith_base.\nFrom Stdlib Require Import ZArithRing.\nFrom Stdlib Require Import Zcomplements.\nFrom Stdlib Require Import Zdiv.\nFrom Stdlib Require Import Zdivisibility.\nFrom Stdlib Require Import Wf_nat.\nFrom Stdlib Require Import Lia Cring Ncring_tac.\n\nOpen Scope Z_scope.\n\n#[local] Ltac Tauto.intuition_solver ::= auto with zarith.\n\n#[deprecated(use=ex_intro, since=\"Stdlib 9.1\")]\nDefinition Zdivide_intro a b q (H:b=q*a) : Z.divide a b := ex_intro _ q H.\n\n#[deprecated(use=Z.divide_1_l, since=\"Stdlib 9.1\")]\nNotation Zone_divide := Z.divide_1_l (only parsing).\n#[deprecated(use=Z.divide_0_r, since=\"Stdlib 9.1\")]\nNotation Zdivide_0 := Z.divide_0_r (only parsing).\n#[deprecated(use=Z.mul_divide_mono_l, since=\"Stdlib 9.1\")]\nNotation Zmult_divide_compat_l := Z.mul_divide_mono_l (only parsing).\n#[deprecated(use=Z.mul_divide_mono_r, since=\"Stdlib 9.1\")]\nNotation Zmult_divide_compat_r := Z.mul_divide_mono_r (only parsing).\n#[deprecated(use=Z.divide_add_r, since=\"Stdlib 9.1\")]\nNotation Zdivide_plus_r := Z.divide_add_r (only parsing).\n#[deprecated(use=Z.divide_sub_r, since=\"Stdlib 9.1\")]\nNotation Zdivide_minus_l := Z.divide_sub_r (only parsing).\n#[deprecated(use=Z.divide_mul_l, since=\"Stdlib 9.1\")]\nNotation Zdivide_mult_l := Z.divide_mul_l (only parsing).\n#[deprecated(use=Z.divide_mul_r, since=\"Stdlib 9.1\")]\nNotation Zdivide_mult_r := Z.divide_mul_r (only parsing).\n#[deprecated(use=Z.divide_factor_l, since=\"Stdlib 9.1\")]\nNotation Zdivide_factor_r := Z.divide_factor_l (only parsing).\n#[deprecated(use=Z.divide_factor_r, since=\"Stdlib 9.1\")]\nNotation Zdivide_factor_l := Z.divide_factor_r (only parsing).\n\n#[deprecated(use=Z.divide_opp_r, since=\"Stdlib 9.1\")]\nLemma Zdivide_opp_r a b : (a | b) -> (a | - b).\nProof.\nAdmitted.\n\n#[deprecated(since=\"Stdlib 9.1\")]\nDefinition prime_dec_aux:\n forall p m,\n { forall n, 1 < n < m -> rel_prime n p } +\n { exists n, 1 < n < m /\\ ~ rel_prime n p }.\nProof.\nAdmitted.\n\nDefinition prime_dec: forall p, { prime p }+{ ~ prime p }.\nProof.\nAdmitted.\n\nTheorem not_prime_divide:\n forall p, 1 < p -> ~ prime p -> exists n, 1 < n < p /\\ (n | p).\nProof.\nAdmitted." }, { "theorem_id": 55, "title": "070_the_perfect_number_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";;\n\nprioritize_num();;\n\nlet sigma = new_definition\n `sigma(n) = if n = 0 then 0 else nsum {d | d divides n} (\\i. i)`;;\n\nlet perfect = new_definition\n `perfect n <=> ~(n = 0) /\\ sigma(n) = 2 * n`;;\n\nlet ODD_POW2_MINUS1 = `!k. ~(k = 0) ==> ODD(2 EXP k - 1)`;;\n\nlet EVEN_ODD_DECOMP = `!n. ~(n = 0) ==> ?r s. ODD s /\\ n = 2 EXP r * s`;;\n\nlet FINITE_DIVISORS = `!n. ~(n = 0) ==> FINITE {d | d divides n}`;;\n\nlet MULT_EQ_COPRIME = `!a b x y. a * b = x * y /\\ coprime(a,x)\n ==> ?d. y = a * d /\\ b = x * d`;;\n\nlet COPRIME_ODD_POW2 = `!k n. ODD(n) ==> coprime(2 EXP k,n)`;;\n\nlet MULT_NSUM = `!s t. FINITE s /\\ FINITE t\n ==> nsum s f * nsum t g =\n nsum {(x:A,y:B) | x IN s /\\ y IN t} (\\(x,y). f(x) * g(y))`;;\n\nlet SIGMA_0 = `sigma 0 = 0`;;\n\nlet SIGMA_1 = `sigma(1) = 1`;;\n\nlet SIGMA_LBOUND = `!n. 1 < n ==> n + 1 <= sigma(n)`;;\n\nlet SIGMA_MULT = `!a b. 1 < a /\\ 1 < b ==> 1 + b + a * b <= sigma(a * b)`;;\n\nlet SIGMA_PRIME = `!p. prime(p) ==> sigma(p) = p + 1`;;\n\nlet SIGMA_PRIME_EQ = `!p. prime(p) <=> sigma(p) = p + 1`;;\n\nlet SIGMA_POW2 = `!k. sigma(2 EXP k) = 2 EXP (k + 1) - 1`;;\n\nlet SIGMA_MULTIPLICATIVE = `!a b. coprime(a,b) ==> sigma(a * b) = sigma(a) * sigma(b)`;;\n\nlet PERFECT_EUCLID = `!k. prime(2 EXP k - 1) ==> perfect(2 EXP (k - 1) * (2 EXP k - 1))`;;\n\nlet PERFECT_EULER = `!n. EVEN(n) /\\ perfect(n)\n ==> ?k. prime(2 EXP k - 1) /\\ n = 2 EXP (k - 1) * (2 EXP k - 1)`;;" }, { "theorem_id": 55, "title": "070_the_perfect_number_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section\\Perfect Number Theorem\\\n\ntheory Perfect\nimports Sigma\nbegin\n\ndefinition perfect :: \"nat => bool\" where\n \"perfect m \\ m>0 \\ 2*m = sigma m\"\n\ntheorem perfect_number_theorem:\n assumes even: \"even m\" and perfect: \"perfect m\"\n shows \"\\ n . m = 2^n*(2^(n+1) - 1) \\ prime ((2::nat)^(n+1) - 1)\"\n by sorry\n\ntheorem Euclid_book9_prop36:\n assumes p: \"prime (2^(n+1) - (1::nat))\"\n shows \"perfect (2 ^ n * (2 ^ (n + 1) - 1))\"\n by sorry\n\nend\n" }, { "theorem_id": 55, "title": "070_the_perfect_number_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Aaron Anderson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Aaron Anderson\n-/\nimport Mathlib.NumberTheory.ArithmeticFunction.Misc\nimport Mathlib.NumberTheory.LucasLehmer\nimport Mathlib.Tactic.NormNum.Prime\n\n/-!\n# Perfect Numbers\n\nThis file proves Theorem 70 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/).\n\nThe theorem characterizes even perfect numbers.\n\nEuclid proved that if `2 ^ (k + 1) - 1` is prime (these primes are known as Mersenne primes),\n then `2 ^ k * (2 ^ (k + 1) - 1)` is perfect.\n\nEuler proved the converse, that if `n` is even and perfect, then there exists `k` such that\n `n = 2 ^ k * (2 ^ (k + 1) - 1)` and `2 ^ (k + 1) - 1` is prime.\n\n## References\nhttps://en.wikipedia.org/wiki/Euclid%E2%80%93Euler_theorem\n-/\n\n\nnamespace Theorems100\n\nnamespace Nat\n\nopen ArithmeticFunction Finset\n\n-- access notation `σ`\nopen scoped sigma\n\ntheorem sigma_two_pow_eq_mersenne_succ (k : ℕ) : σ 1 (2 ^ k) = mersenne (k + 1) := by sorry\ntheorem perfect_two_pow_mul_mersenne_of_prime (k : ℕ) (pr : (mersenne (k + 1)).Prime) :\n Nat.Perfect (2 ^ k * mersenne (k + 1)) := by sorry\ntheorem ne_zero_of_prime_mersenne (k : ℕ) (pr : (mersenne (k + 1)).Prime) : k ≠ 0 := by sorry\ntheorem even_two_pow_mul_mersenne_of_prime (k : ℕ) (pr : (mersenne (k + 1)).Prime) :\n Even (2 ^ k * mersenne (k + 1)) := by simp [ne_zero_of_prime_mersenne k pr, parity_simps]\n\ntheorem eq_two_pow_mul_odd {n : ℕ} (hpos : 0 < n) : ∃ k m : ℕ, n = 2 ^ k * m ∧ ¬Even m := by sorry\ntheorem eq_two_pow_mul_prime_mersenne_of_even_perfect {n : ℕ} (ev : Even n) (perf : Nat.Perfect n) :\n ∃ k : ℕ, Nat.Prime (mersenne (k + 1)) ∧ n = 2 ^ k * mersenne (k + 1) := by sorry\ntheorem even_and_perfect_iff {n : ℕ} :\n Even n ∧ Nat.Perfect n ↔ ∃ k : ℕ, Nat.Prime (mersenne (k + 1)) ∧\n n = 2 ^ k * mersenne (k + 1) := by sorry\nend Nat\n\nend Theorems100\n" }, { "theorem_id": 55, "title": "070_the_perfect_number_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From mathcomp Require Import all_ssreflect.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nLemma prime_decomp_ind (P: nat -> Prop) (P0: P 0) (P1: P 1)\n (Pprime: forall p k, prime p -> k > 0 -> P (p^k))\n (Pmul: forall a b, P a -> P b -> coprime a b -> (P (a*b))) c: P c.\nProof.\nAdmitted.\n\nProposition gcdnM a b c: (a > 0) -> (coprime a b) ->\n gcdn (a*b) c = (gcdn a c)*(gcdn b c).\nProof.\nAdmitted.\n\nLemma div_gcdnE a b c (apos: a > 0): (coprime a b) ->\n reflect (c = (gcdn a c)*(gcdn b c)) (c %| a*b).\nProof.\nAdmitted.\n\nDefinition div_pair a b d:= (gcdn a d, gcdn b d).\nDefinition div_prod (d: nat*nat):= d.1*d.2.\n\nLemma div2_to_div a b (apos: a > 0) (bpos: b > 0): coprime a b ->\n map div_prod (allpairs pair (divisors a) (divisors b)) =i\n divisors (a*b).\nProof.\nAdmitted.\n\nLemma cpr_divl a b c: c%|a -> (coprime a b) -> (coprime c b).\nProof.\nAdmitted.\n\nLemma cpr_divr a b c: c%|b -> (coprime a b) -> (coprime a c).\nProof.\nAdmitted.\n\nLemma cpr_mult_projl a b c d: (coprime a d) -> (coprime b c) ->\n a*b = c*d -> b = d.\nProof.\nAdmitted.\n\nLemma cpr_mult_projr a b c d: (coprime a d) -> (coprime b c) ->\n a*b = c*d -> a = c.\nProof.\nAdmitted.\n\nLemma div2_to_divPerm a b (apos: a > 0) (bpos: b > 0): coprime a b ->\n perm_eq\n (map div_prod (allpairs pair (divisors a) (divisors b)))\n (divisors (a*b)).\nProof.\nAdmitted.\n\nLemma prime_div p k (kgt0: k > 0): prime p ->\n prime_decomp (p^k) = [:: (p, k)].\nProof.\nAdmitted.\n\nLemma div_primeX p k: prime p ->\n divisors (p^k) = [seq p^i | i <- iota 0 k.\nProof.\nAdmitted.\n\nDefinition multiplicative f := forall a b, (coprime a b) ->\n f (a*b) = (f a)*(f b).\nDefinition dirichlet_conv (f g: nat -> nat) n :=\n if n > 0 then \\sum_(d <- divisors n) (f d)*(g (n%/d)) else 0.\n \nDefinition sigma := dirichlet_conv (fun n => n) (fun n => 1).\nDefinition perfect p := sigma p = 2 * p.\nDefinition mersenne p := (prime p)/\\(exists k, p = 2^k - 1).\n\nTheorem dirichletM f g (f_cdt : multiplicative f) (g_cdt : multiplicative g) :\n (multiplicative (dirichlet_conv f g)).\nProof.\nAdmitted.\n\nTheorem geoSum p n m: (p > 1) ->\n \\sum_(i <- (iota m n)) p^i = (p^(m+n) - p^m)%/(p-1).\nProof.\nAdmitted.\n\nCorollary sigmaM: multiplicative sigma.\nProof.\nAdmitted.\n\nProposition sigmaX p n: prime p -> n > 0 ->\n sigma (p^n) = (p^n.\nProof.\nAdmitted.\n\nCorollary sigmaX1 p: prime p -> sigma p = p+1.\nProof.\nAdmitted.\n\nLemma remK (T: eqType) (x y: T) s: y != x -> y \\in s -> y \\in rem x s.\nProof.\nAdmitted.\n\nProposition sigma_geqn N: N > 1 -> sigma N >= N+1.\nProof.\nAdmitted.\n\nProposition sigmapS p: sigma p = p+1 -> prime p.\nProof.\nAdmitted.\n\nProposition sigma_geqdvd2 p k l: p > 1 -> k!=1 -> p!=k ->\n (k)*(l) = p -> sigma p >= 1+k+p.\nProof.\nAdmitted.\n\nTheorem EuclidT p: prime (2^p-1) -> perfect (2^(p-1)*(2^p-1)).\nProof.\nAdmitted.\n\nTheorem EulerT p: perfect p -> 2%|p -> p > 0 ->\n exists n, (p = (2^n-1)*2^n.\nProof.\nAdmitted." }, { "theorem_id": 56, "title": "071_order_of_a_subgroup__lagrange_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "loadt \"Library/prime.ml\";;\n\nlet group = new_definition\n `group(g,( ** ),i,(e:A)) <=>\n (e IN g) /\\ (!x. x IN g ==> i(x) IN g) /\\\n (!x y. x IN g /\\ y IN g ==> (x ** y) IN g) /\\\n (!x y z. x IN g /\\ y IN g /\\ z IN g ==> (x ** (y ** z) = (x ** y) ** z)) /\\\n (!x. x IN g ==> (x ** e = x) /\\ (e ** x = x)) /\\\n (!x. x IN g ==> (x ** i(x) = e) /\\ (i(x) ** x = e))`;;\n\nlet subgroup = new_definition\n `subgroup h (g,( ** ),i,(e:A)) <=> h SUBSET g /\\ group(h,( ** ),i,e)`;;\n\nlet GROUP_LAGRANGE_COSETS = `!g h ( ** ) i e.\n group (g,( ** ),i,e:A) /\\ subgroup h (g,( ** ),i,e) /\\ FINITE g\n ==> ?q. (CARD(g) = CARD(q) * CARD(h)) /\\\n (!b. b IN g ==> ?a x. a IN q /\\ x IN h /\\ (b = a ** x))`;;\n\nlet GROUP_LAGRANGE = `!g h ( ** ) i e.\n group (g,( ** ),i,e:A) /\\ subgroup h (g,( ** ),i,e) /\\ FINITE g\n ==> (CARD h) divides (CARD g)`;;" }, { "theorem_id": 56, "title": "071_order_of_a_subgroup__lagrange_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory Group\nimports Complete_Lattice \"HOL-Library.FuncSet\"\nbegin\n\nsection \\Monoids and Groups\\\n\nsubsection \\Definitions\\\n\ntext \\\n Definitions follow \\<^cite>\\\"Jacobson:1985\"\\.\n\\\n\nrecord 'a monoid = \"'a partial_object\" +\n mult :: \"['a, 'a] \\ 'a\" (infixl \\\\\\\\ 70)\n one :: 'a (\\\\\\\\)\n\ndefinition m_inv :: \"('a, 'b) monoid_scheme => 'a => 'a\"\n where \"m_inv G x = (THE y. y \\ carrier G \\ x \\\\<^bsub>G\\<^esub> y = \\\\<^bsub>G\\<^esub> \\ y \\\\<^bsub>G\\<^esub> x = \\\\<^bsub>G\\<^esub>)\"\n\nopen_bundle m_inv_syntax\nbegin\nnotation m_inv (\\(\\open_block notation=\\prefix inv\\\\inv\\ _)\\ [81] 80)\nend\n\ndefinition\n Units :: \"_ => 'a set\"\n \\ \\The set of invertible elements\\\n where \"Units G = {y. y \\ carrier G \\ (\\x \\ carrier G. x \\\\<^bsub>G\\<^esub> y = \\\\<^bsub>G\\<^esub> \\ y \\\\<^bsub>G\\<^esub> x = \\\\<^bsub>G\\<^esub>)}\"\n\nlocale monoid =\n fixes G (structure)\n assumes m_closed [intro, simp]:\n \"\\x \\ carrier G; y \\ carrier G\\ \\ x \\ y \\ carrier G\"\n and m_assoc:\n \"\\x \\ carrier G; y \\ carrier G; z \\ carrier G\\\n \\ (x \\ y) \\ z = x \\ (y \\ z)\"\n and one_closed [intro, simp]: \"\\ \\ carrier G\"\n and l_one [simp]: \"x \\ carrier G \\ \\ \\ x = x\"\n and r_one [simp]: \"x \\ carrier G \\ x \\ \\ = x\"\n\nlemma monoidI:\n fixes G (structure)\n assumes m_closed:\n \"!!x y. [| x \\ carrier G; y \\ carrier G |] ==> x \\ y \\ carrier G\"\n and one_closed: \"\\ \\ carrier G\"\n and m_assoc:\n \"!!x y z. [| x \\ carrier G; y \\ carrier G; z \\ carrier G |] ==>\n (x \\ y) \\ z = x \\ (y \\ z)\"\n and l_one: \"!!x. x \\ carrier G ==> \\ \\ x = x\"\n and r_one: \"!!x. x \\ carrier G ==> x \\ \\ = x\"\n shows \"monoid G\"\n by sorry\n\nlemma (in monoid) Units_closed [dest]:\n \"x \\ Units G ==> x \\ carrier G\"\n by sorry\n\nlemma (in monoid) one_unique:\n assumes \"u \\ carrier G\"\n and \"\\x. x \\ carrier G \\ u \\ x = x\"\n shows \"u = \\\"\n by sorry\n\nlemma (in monoid) inv_unique:\n assumes eq: \"y \\ x = \\\" \"x \\ y' = \\\"\n and G: \"x \\ carrier G\" \"y \\ carrier G\" \"y' \\ carrier G\"\n shows \"y = y'\"\n by sorry\n\nlemma (in monoid) Units_m_closed [simp, intro]:\n assumes x: \"x \\ Units G\" and y: \"y \\ Units G\"\n shows \"x \\ y \\ Units G\"\n by sorry\n\nlemma (in monoid) Units_one_closed [intro, simp]:\n \"\\ \\ Units G\"\n by sorry\n\nlemma (in monoid) Units_inv_closed [intro, simp]:\n \"x \\ Units G ==> inv x \\ carrier G\"\n by sorry\n\nlemma (in monoid) Units_l_inv_ex:\n \"x \\ Units G ==> \\y \\ carrier G. y \\ x = \\\"\n by sorry\n\nlemma (in monoid) Units_r_inv_ex:\n \"x \\ Units G ==> \\y \\ carrier G. x \\ y = \\\"\n by sorry\n\nlemma (in monoid) Units_l_inv [simp]:\n \"x \\ Units G ==> inv x \\ x = \\\"\n by sorry\n\nlemma (in monoid) Units_r_inv [simp]:\n \"x \\ Units G ==> x \\ inv x = \\\"\n by sorry\n\nlemma (in monoid) inv_one [simp]:\n \"inv \\ = \\\"\n by sorry\n\nlemma (in monoid) Units_inv_Units [intro, simp]:\n \"x \\ Units G ==> inv x \\ Units G\"\n by sorry\n\nlemma (in monoid) Units_l_cancel [simp]:\n \"[| x \\ Units G; y \\ carrier G; z \\ carrier G |] ==>\n (x \\ y = x \\ z) = (y = z)\"\n by sorry\n\nlemma (in monoid) Units_inv_inv [simp]:\n \"x \\ Units G ==> inv (inv x) = x\"\n by sorry\n\nlemma (in monoid) inv_inj_on_Units:\n \"inj_on (m_inv G) (Units G)\"\n by sorry\n\nlemma (in monoid) Units_inv_comm:\n assumes inv: \"x \\ y = \\\"\n and G: \"x \\ Units G\" \"y \\ Units G\"\n shows \"y \\ x = \\\"\n by sorry\n\nlemma (in monoid) carrier_not_empty: \"carrier G \\ {}\"\n by sorry\n\nsubsection \\Groups\\\n\ntext \\\n A group is a monoid all of whose elements are invertible.\n\\\n\nlocale group = monoid +\n assumes Units: \"carrier G <= Units G\"\n\nlemma (in group) is_group [iff]: \"group G\" by (rule group_axioms)\n\nlemma (in group) is_monoid [iff]: \"monoid G\"\n by sorry\n\ntheorem groupI:\n fixes G (structure)\n assumes m_closed [simp]:\n \"!!x y. [| x \\ carrier G; y \\ carrier G |] ==> x \\ y \\ carrier G\"\n and one_closed [simp]: \"\\ \\ carrier G\"\n and m_assoc:\n \"!!x y z. [| x \\ carrier G; y \\ carrier G; z \\ carrier G |] ==>\n (x \\ y) \\ z = x \\ (y \\ z)\"\n and l_one [simp]: \"!!x. x \\ carrier G ==> \\ \\ x = x\"\n and l_inv_ex: \"!!x. x \\ carrier G ==> \\y \\ carrier G. y \\ x = \\\"\n shows \"group G\"\n by sorry\n\nlemma (in monoid) group_l_invI:\n assumes l_inv_ex:\n \"!!x. x \\ carrier G ==> \\y \\ carrier G. y \\ x = \\\"\n shows \"group G\"\n by sorry\n\nlemma (in group) Units_eq [simp]:\n \"Units G = carrier G\"\n by sorry\n\nlemma (in group) inv_closed [intro, simp]:\n \"x \\ carrier G ==> inv x \\ carrier G\"\n by sorry\n\nlemma (in group) l_inv_ex [simp]:\n \"x \\ carrier G ==> \\y \\ carrier G. y \\ x = \\\"\n by sorry\n\nlemma (in group) r_inv_ex [simp]:\n \"x \\ carrier G ==> \\y \\ carrier G. x \\ y = \\\"\n by sorry\n\nlemma (in group) l_inv [simp]:\n \"x \\ carrier G ==> inv x \\ x = \\\"\n by sorry\n\nsubsection \\Cancellation Laws and Basic Properties\\\n\nlemma (in group) inv_eq_1_iff [simp]:\n assumes \"x \\ carrier G\" shows \"inv\\<^bsub>G\\<^esub> x = \\\\<^bsub>G\\<^esub> \\ x = \\\\<^bsub>G\\<^esub>\"\n by sorry\n\nlemma (in group) r_inv [simp]:\n \"x \\ carrier G ==> x \\ inv x = \\\"\n by sorry\n\nlemma (in group) right_cancel [simp]:\n \"[| x \\ carrier G; y \\ carrier G; z \\ carrier G |] ==>\n (y \\ x = z \\ x) = (y = z)\"\n by sorry\n\nlemma (in group) inv_inv [simp]:\n \"x \\ carrier G ==> inv (inv x) = x\"\n by sorry\n\nlemma (in group) inv_inj:\n \"inj_on (m_inv G) (carrier G)\"\n by sorry\n\nlemma (in group) inv_mult_group:\n \"[| x \\ carrier G; y \\ carrier G |] ==> inv (x \\ y) = inv y \\ inv x\"\n by sorry\n\nlemma (in group) inv_comm:\n \"[| x \\ y = \\; x \\ carrier G; y \\ carrier G |] ==> y \\ x = \\\"\n by sorry\n\nlemma (in group) inv_equality:\n \"[|y \\ x = \\; x \\ carrier G; y \\ carrier G|] ==> inv x = y\"\n by sorry\n\nlemma (in group) inv_solve_left:\n \"\\ a \\ carrier G; b \\ carrier G; c \\ carrier G \\ \\ a = inv b \\ c \\ c = b \\ a\"\n by sorry\n\nlemma (in group) inv_solve_left':\n \"\\ a \\ carrier G; b \\ carrier G; c \\ carrier G \\ \\ inv b \\ c = a \\ c = b \\ a\"\n by sorry\n\nlemma (in group) inv_solve_right:\n \"\\ a \\ carrier G; b \\ carrier G; c \\ carrier G \\ \\ a = b \\ inv c \\ b = a \\ c\"\n by sorry\n\nlemma (in group) inv_solve_right':\n \"\\a \\ carrier G; b \\ carrier G; c \\ carrier G\\ \\ b \\ inv c = a \\ b = a \\ c\"\n by sorry\n \nsubsection \\Power\\\n\nconsts\n pow :: \"[('a, 'm) monoid_scheme, 'a, 'b::semiring_1] => 'a\" (infixr \\[^]\\\\ 75)\n\noverloading nat_pow == \"pow :: [_, 'a, nat] => 'a\"\nbegin\n definition \"nat_pow G a n = rec_nat \\\\<^bsub>G\\<^esub> (%u b. b \\\\<^bsub>G\\<^esub> a) n\"\nend\n\nlemma (in monoid) nat_pow_closed [intro, simp]:\n \"x \\ carrier G ==> x [^] (n::nat) \\ carrier G\"\n by sorry\n\nlemma (in monoid) nat_pow_0 [simp]:\n \"x [^] (0::nat) = \\\"\n by sorry\n\nlemma (in monoid) nat_pow_Suc [simp]:\n \"x [^] (Suc n) = x [^] n \\ x\"\n by sorry\n\nlemma (in monoid) nat_pow_one [simp]:\n \"\\ [^] (n::nat) = \\\"\n by sorry\n\nlemma (in monoid) nat_pow_mult:\n \"x \\ carrier G ==> x [^] (n::nat) \\ x [^] m = x [^] (n + m)\"\n by sorry\n\nlemma (in monoid) nat_pow_comm:\n \"x \\ carrier G \\ (x [^] (n::nat)) \\ (x [^] (m :: nat)) = (x [^] m) \\ (x [^] n)\"\n by sorry\n\nlemma (in monoid) nat_pow_Suc2:\n \"x \\ carrier G \\ x [^] (Suc n) = x \\ (x [^] n)\"\n by sorry\n\nlemma (in monoid) nat_pow_pow:\n \"x \\ carrier G ==> (x [^] n) [^] m = x [^] (n * m::nat)\"\n by sorry\n\nlemma (in monoid) nat_pow_consistent:\n \"x [^] (n :: nat) = x [^]\\<^bsub>(G \\ carrier := H \\)\\<^esub> n\"\n by sorry\n\nlemma nat_pow_0 [simp]: \"x [^]\\<^bsub>G\\<^esub> (0::nat) = \\\\<^bsub>G\\<^esub>\"\n by sorry\n\nlemma nat_pow_Suc [simp]: \"x [^]\\<^bsub>G\\<^esub> (Suc n) = (x [^]\\<^bsub>G\\<^esub> n)\\\\<^bsub>G\\<^esub> x\"\n by sorry\n\nlemma (in group) nat_pow_inv:\n assumes \"x \\ carrier G\" shows \"(inv x) [^] (i :: nat) = inv (x [^] i)\"\n by sorry\n\noverloading int_pow == \"pow :: [_, 'a, int] => 'a\"\nbegin\n definition \"int_pow G a z =\n (let p = rec_nat \\\\<^bsub>G\\<^esub> (%u b. b \\\\<^bsub>G\\<^esub> a)\n in if z < 0 then inv\\<^bsub>G\\<^esub> (p (nat (-z))) else p (nat z))\"\nend\n\nlemma int_pow_int: \"x [^]\\<^bsub>G\\<^esub> (int n) = x [^]\\<^bsub>G\\<^esub> n\"\n by sorry\n\nlemma pow_nat:\n assumes \"i\\0\"\n shows \"x [^]\\<^bsub>G\\<^esub> nat i = x [^]\\<^bsub>G\\<^esub> i\"\n by sorry\n\nlemma int_pow_0 [simp]: \"x [^]\\<^bsub>G\\<^esub> (0::int) = \\\\<^bsub>G\\<^esub>\"\n by sorry\n\nlemma int_pow_def2: \"a [^]\\<^bsub>G\\<^esub> z =\n (if z < 0 then inv\\<^bsub>G\\<^esub> (a [^]\\<^bsub>G\\<^esub> (nat (-z))) else a [^]\\<^bsub>G\\<^esub> (nat z))\"\n by sorry\n\nlemma (in group) int_pow_one [simp]:\n \"\\ [^] (z::int) = \\\"\n by sorry\n\nlemma (in group) int_pow_closed [intro, simp]:\n \"x \\ carrier G ==> x [^] (i::int) \\ carrier G\"\n by sorry\n\nlemma (in group) int_pow_1 [simp]:\n \"x \\ carrier G \\ x [^] (1::int) = x\"\n by sorry\n\nlemma (in group) int_pow_neg:\n \"x \\ carrier G \\ x [^] (-i::int) = inv (x [^] i)\"\n by sorry\n\nlemma (in group) int_pow_neg_int: \"x \\ carrier G \\ x [^] -(int n) = inv (x [^] n)\"\n by sorry\n\nlemma (in group) int_pow_mult:\n assumes \"x \\ carrier G\" shows \"x [^] (i + j::int) = x [^] i \\ x [^] j\"\n by sorry\n\nlemma (in group) int_pow_inv:\n \"x \\ carrier G \\ (inv x) [^] (i :: int) = inv (x [^] i)\"\n by sorry\n\nlemma (in group) int_pow_pow:\n assumes \"x \\ carrier G\"\n shows \"(x [^] (n :: int)) [^] (m :: int) = x [^] (n * m :: int)\"\n by sorry\n\nlemma (in group) int_pow_diff:\n \"x \\ carrier G \\ x [^] (n - m :: int) = x [^] n \\ inv (x [^] m)\"\n by sorry\n\nlemma (in group) inj_on_multc: \"c \\ carrier G \\ inj_on (\\x. x \\ c) (carrier G)\"\n by sorry\n\nlemma (in group) inj_on_cmult: \"c \\ carrier G \\ inj_on (\\x. c \\ x) (carrier G)\"\n by sorry\n\nlemma (in monoid) group_commutes_pow:\n fixes n::nat\n shows \"\\x \\ y = y \\ x; x \\ carrier G; y \\ carrier G\\ \\ x [^] n \\ y = y \\ x [^] n\"\n by sorry\n\nlemma (in monoid) pow_mult_distrib:\n assumes eq: \"x \\ y = y \\ x\" and xy: \"x \\ carrier G\" \"y \\ carrier G\"\n shows \"(x \\ y) [^] (n::nat) = x [^] n \\ y [^] n\"\n by sorry\n\nlemma (in group) int_pow_mult_distrib:\n assumes eq: \"x \\ y = y \\ x\" and xy: \"x \\ carrier G\" \"y \\ carrier G\"\n shows \"(x \\ y) [^] (i::int) = x [^] i \\ y [^] i\"\n by sorry\n\nlemma (in group) pow_eq_div2:\n fixes m n :: nat\n assumes x_car: \"x \\ carrier G\"\n assumes pow_eq: \"x [^] m = x [^] n\"\n shows \"x [^] (m - n) = \\\"\n by sorry\n\nsubsection \\Submonoids\\\n\nlocale submonoid = \\<^marker>\\contributor \\Martin Baillon\\\\\n fixes H and G (structure)\n assumes subset: \"H \\ carrier G\"\n and m_closed [intro, simp]: \"\\x \\ H; y \\ H\\ \\ x \\ y \\ H\"\n and one_closed [simp]: \"\\ \\ H\"\n\nlemma (in submonoid) is_submonoid: \\<^marker>\\contributor \\Martin Baillon\\\\\n \"submonoid H G\" by (rule submonoid_axioms)\n\nlemma (in submonoid) mem_carrier [simp]: \\<^marker>\\contributor \\Martin Baillon\\\\\n \"x \\ H \\ x \\ carrier G\"\n by sorry\n\nlemma (in submonoid) submonoid_is_monoid [intro]: \\<^marker>\\contributor \\Martin Baillon\\\\\n assumes \"monoid G\"\n shows \"monoid (G\\carrier := H\\)\"\n by sorry\n\nlemma submonoid_nonempty: \\<^marker>\\contributor \\Martin Baillon\\\\\n \"~ submonoid {} G\"\n by sorry\n\nlemma (in submonoid) finite_monoid_imp_card_positive: \\<^marker>\\contributor \\Martin Baillon\\\\\n \"finite (carrier G) ==> 0 < card H\"\n by sorry\n\nlemma (in monoid) monoid_incl_imp_submonoid : \\<^marker>\\contributor \\Martin Baillon\\\\\n assumes \"H \\ carrier G\"\nand \"monoid (G\\carrier := H\\)\"\nshows \"submonoid H G\"\n by sorry\n\nlemma (in monoid) inv_unique': \\<^marker>\\contributor \\Martin Baillon\\\\\n assumes \"x \\ carrier G\" \"y \\ carrier G\"\n shows \"\\ x \\ y = \\; y \\ x = \\ \\ \\ y = inv x\"\n by sorry\n\nlemma (in monoid) m_inv_monoid_consistent: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"x \\ Units (G \\ carrier := H \\)\" and \"submonoid H G\"\n shows \"inv\\<^bsub>(G \\ carrier := H \\)\\<^esub> x = inv x\"\n by sorry\n\nsubsection \\Subgroups\\\n\nlocale subgroup =\n fixes H and G (structure)\n assumes subset: \"H \\ carrier G\"\n and m_closed [intro, simp]: \"\\x \\ H; y \\ H\\ \\ x \\ y \\ H\"\n and one_closed [simp]: \"\\ \\ H\"\n and m_inv_closed [intro,simp]: \"x \\ H \\ inv x \\ H\"\n\nlemma (in subgroup) is_subgroup:\n \"subgroup H G\" by (rule subgroup_axioms)\n\ndeclare (in subgroup) group.intro [intro]\n\nlemma (in subgroup) mem_carrier [simp]:\n \"x \\ H \\ x \\ carrier G\"\n by sorry\n\nlemma (in subgroup) subgroup_is_group [intro]:\n assumes \"group G\"\n shows \"group (G\\carrier := H\\)\"\n by sorry\n\nlemma (in group) triv_subgroup: \"subgroup {\\} G\"\n by sorry\n\nlemma subgroup_is_submonoid:\n assumes \"subgroup H G\" shows \"submonoid H G\"\n by sorry\n\nlemma (in group) subgroup_Units:\n assumes \"subgroup H G\" shows \"H \\ Units (G \\ carrier := H \\)\"\n by sorry\n\nlemma (in group) m_inv_consistent [simp]:\n assumes \"subgroup H G\" \"x \\ H\"\n shows \"inv\\<^bsub>(G \\ carrier := H \\)\\<^esub> x = inv x\"\n by sorry\n\nlemma (in group) int_pow_consistent: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"subgroup H G\" \"x \\ H\"\n shows \"x [^] (n :: int) = x [^]\\<^bsub>(G \\ carrier := H \\)\\<^esub> n\"\n by sorry\n\ntext \\\n Since \\<^term>\\H\\ is nonempty, it contains some element \\<^term>\\x\\. Since\n it is closed under inverse, it contains \\inv x\\. Since\n it is closed under product, it contains \\x \\ inv x = \\\\.\n\\\n\nlemma (in group) one_in_subset:\n \"\\H \\ carrier G; H \\ {}; \\a \\ H. inv a \\ H; \\a\\H. \\b\\H. a \\ b \\ H\\\n \\ \\ \\ H\"\n by sorry\n\ntext \\A characterization of subgroups: closed, non-empty subset.\\\n\nlemma (in group) subgroupI:\n assumes subset: \"H \\ carrier G\" and non_empty: \"H \\ {}\"\n and inv: \"!!a. a \\ H \\ inv a \\ H\"\n and mult: \"!!a b. \\a \\ H; b \\ H\\ \\ a \\ b \\ H\"\n shows \"subgroup H G\"\n by sorry\n\nlemma (in group) subgroupE:\n assumes \"subgroup H G\"\n shows \"H \\ carrier G\"\n and \"H \\ {}\"\n and \"\\a. a \\ H \\ inv a \\ H\"\n and \"\\a b. \\ a \\ H; b \\ H \\ \\ a \\ b \\ H\"\n by sorry\n\ndeclare monoid.one_closed [iff] group.inv_closed [simp]\n monoid.l_one [simp] monoid.r_one [simp] group.inv_inv [simp]\n\nlemma subgroup_nonempty:\n \"\\ subgroup {} G\"\n by sorry\n\nlemma (in subgroup) finite_imp_card_positive: \"finite (carrier G) \\ 0 < card H\"\n by sorry\n\nlemma (in subgroup) subgroup_is_submonoid : \\<^marker>\\contributor \\Martin Baillon\\\\\n \"submonoid H G\"\n by sorry\n\nlemma (in group) submonoid_subgroupI : \\<^marker>\\contributor \\Martin Baillon\\\\\n assumes \"submonoid H G\"\n and \"\\a. a \\ H \\ inv a \\ H\"\n shows \"subgroup H G\"\n by sorry\n\nlemma (in group) group_incl_imp_subgroup: \\<^marker>\\contributor \\Martin Baillon\\\\\n assumes \"H \\ carrier G\"\n and \"group (G\\carrier := H\\)\"\n shows \"subgroup H G\"\n by sorry\n\nsubsection \\Direct Products\\\n\ndefinition\n DirProd :: \"_ \\ _ \\ ('a \\ 'b) monoid\" (infixr \\\\\\\\ 80) where\n \"G \\\\ H =\n \\carrier = carrier G \\ carrier H,\n mult = (\\(g, h) (g', h'). (g \\\\<^bsub>G\\<^esub> g', h \\\\<^bsub>H\\<^esub> h')),\n one = (\\\\<^bsub>G\\<^esub>, \\\\<^bsub>H\\<^esub>)\\\"\n\nlemma DirProd_monoid:\n assumes \"monoid G\" and \"monoid H\"\n shows \"monoid (G \\\\ H)\"\n by sorry\n\ntext\\Does not use the previous result because it's easier just to use auto.\\\nlemma DirProd_group:\n assumes \"group G\" and \"group H\"\n shows \"group (G \\\\ H)\"\n by sorry\n\nlemma carrier_DirProd [simp]: \"carrier (G \\\\ H) = carrier G \\ carrier H\"\n by sorry\n\nlemma one_DirProd [simp]: \"\\\\<^bsub>G \\\\ H\\<^esub> = (\\\\<^bsub>G\\<^esub>, \\\\<^bsub>H\\<^esub>)\"\n by sorry\n\nlemma mult_DirProd [simp]: \"(g, h) \\\\<^bsub>(G \\\\ H)\\<^esub> (g', h') = (g \\\\<^bsub>G\\<^esub> g', h \\\\<^bsub>H\\<^esub> h')\"\n by sorry\n\nlemma mult_DirProd': \"x \\\\<^bsub>(G \\\\ H)\\<^esub> y = (fst x \\\\<^bsub>G\\<^esub> fst y, snd x \\\\<^bsub>H\\<^esub> snd y)\"\n by sorry\n\nlemma DirProd_assoc: \"(G \\\\ H \\\\ I) = (G \\\\ (H \\\\ I))\"\n by sorry\n\nlemma inv_DirProd [simp]:\n assumes \"group G\" and \"group H\"\n assumes g: \"g \\ carrier G\"\n and h: \"h \\ carrier H\"\n shows \"m_inv (G \\\\ H) (g, h) = (inv\\<^bsub>G\\<^esub> g, inv\\<^bsub>H\\<^esub> h)\"\n by sorry\n\nlemma DirProd_subgroups :\n assumes \"group G\"\n and \"subgroup H G\"\n and \"group K\"\n and \"subgroup I K\"\n shows \"subgroup (H \\ I) (G \\\\ K)\"\n by sorry\n\nsubsection \\Homomorphisms (mono and epi) and Isomorphisms\\\n\ndefinition\n hom :: \"_ => _ => ('a => 'b) set\" where\n \"hom G H =\n {h. h \\ carrier G \\ carrier H \\\n (\\x \\ carrier G. \\y \\ carrier G. h (x \\\\<^bsub>G\\<^esub> y) = h x \\\\<^bsub>H\\<^esub> h y)}\"\n\nlemma homI:\n \"\\\\x. x \\ carrier G \\ h x \\ carrier H;\n \\x y. \\x \\ carrier G; y \\ carrier G\\ \\ h (x \\\\<^bsub>G\\<^esub> y) = h x \\\\<^bsub>H\\<^esub> h y\\ \\ h \\ hom G H\"\n by sorry\n\nlemma hom_carrier: \"h \\ hom G H \\ h ` carrier G \\ carrier H\"\n by sorry\n\nlemma hom_in_carrier: \"\\h \\ hom G H; x \\ carrier G\\ \\ h x \\ carrier H\"\n by sorry\n\nlemma hom_compose:\n \"\\ f \\ hom G H; g \\ hom H I \\ \\ g \\ f \\ hom G I\"\n by sorry\n\nlemma (in group) hom_restrict:\n assumes \"h \\ hom G H\" and \"\\g. g \\ carrier G \\ h g = t g\" shows \"t \\ hom G H\"\n by sorry\n\nlemma (in group) hom_compose:\n \"[|h \\ hom G H; i \\ hom H I|] ==> compose (carrier G) i h \\ hom G I\"\n by sorry\n\nlemma (in group) restrict_hom_iff [simp]:\n \"(\\x. if x \\ carrier G then f x else g x) \\ hom G H \\ f \\ hom G H\"\n by sorry\n\ndefinition iso :: \"_ => _ => ('a => 'b) set\"\n where \"iso G H = {h. h \\ hom G H \\ bij_betw h (carrier G) (carrier H)}\"\n\ndefinition is_iso :: \"_ \\ _ \\ bool\" (infixr \\\\\\ 60)\n where \"G \\ H = (iso G H \\ {})\"\n\ndefinition mon where \"mon G H = {f \\ hom G H. inj_on f (carrier G)}\"\n\ndefinition epi where \"epi G H = {f \\ hom G H. f ` (carrier G) = carrier H}\"\n\nlemma isoI:\n \"\\h \\ hom G H; bij_betw h (carrier G) (carrier H)\\ \\ h \\ iso G H\"\n by sorry\n\nlemma is_isoI: \"h \\ iso G H \\ G \\ H\"\n by sorry\n\nlemma epi_iff_subset:\n \"f \\ epi G G' \\ f \\ hom G G' \\ carrier G' \\ f ` carrier G\"\n by sorry\n\nlemma iso_iff_mon_epi: \"f \\ iso G H \\ f \\ mon G H \\ f \\ epi G H\"\n by sorry\n\nlemma iso_set_refl: \"(\\x. x) \\ iso G G\"\n by sorry\n\nlemma id_iso: \"id \\ iso G G\"\n by sorry\n\ncorollary iso_refl [simp]: \"G \\ G\"\n by sorry\n\nlemma iso_iff:\n \"h \\ iso G H \\ h \\ hom G H \\ h ` (carrier G) = carrier H \\ inj_on h (carrier G)\"\n by sorry\n\nlemma iso_imp_homomorphism:\n \"h \\ iso G H \\ h \\ hom G H\"\n by sorry\n\nlemma trivial_hom:\n \"group H \\ (\\x. one H) \\ hom G H\"\n by sorry\n\nlemma (in group) hom_eq:\n assumes \"f \\ hom G H\" \"\\x. x \\ carrier G \\ f' x = f x\"\n shows \"f' \\ hom G H\"\n by sorry\n\nlemma (in group) iso_eq:\n assumes \"f \\ iso G H\" \"\\x. x \\ carrier G \\ f' x = f x\"\n shows \"f' \\ iso G H\"\n by sorry\n\nlemma (in group) iso_set_sym:\n assumes \"h \\ iso G H\"\n shows \"inv_into (carrier G) h \\ iso H G\"\n by sorry\n\ncorollary (in group) iso_sym: \"G \\ H \\ H \\ G\"\n by sorry\n\nlemma iso_set_trans:\n \"\\h \\ Group.iso G H; i \\ Group.iso H I\\ \\ i \\ h \\ Group.iso G I\"\n by sorry\n\ncorollary iso_trans [trans]: \"\\G \\ H ; H \\ I\\ \\ G \\ I\"\n by sorry\n\nlemma iso_same_card: \"G \\ H \\ card (carrier G) = card (carrier H)\"\n by sorry\n\nlemma iso_finite: \"G \\ H \\ finite(carrier G) \\ finite(carrier H)\"\n by sorry\n\nlemma mon_compose:\n \"\\f \\ mon G H; g \\ mon H K\\ \\ (g \\ f) \\ mon G K\"\n by sorry\n\nlemma mon_compose_rev:\n \"\\f \\ hom G H; g \\ hom H K; (g \\ f) \\ mon G K\\ \\ f \\ mon G H\"\n by sorry\n\nlemma epi_compose:\n \"\\f \\ epi G H; g \\ epi H K\\ \\ (g \\ f) \\ epi G K\"\n by sorry\n\nlemma epi_compose_rev:\n \"\\f \\ hom G H; g \\ hom H K; (g \\ f) \\ epi G K\\ \\ g \\ epi H K\"\n by sorry\n\nlemma iso_compose_rev:\n \"\\f \\ hom G H; g \\ hom H K; (g \\ f) \\ iso G K\\ \\ f \\ mon G H \\ g \\ epi H K\"\n by sorry\n\nlemma epi_iso_compose_rev:\n assumes \"f \\ epi G H\" \"g \\ hom H K\" \"(g \\ f) \\ iso G K\"\n shows \"f \\ iso G H \\ g \\ iso H K\"\n by sorry\n\nlemma mon_left_invertible:\n \"\\f \\ hom G H; \\x. x \\ carrier G \\ g(f x) = x\\ \\ f \\ mon G H\"\n by sorry\n\nlemma epi_right_invertible:\n \"\\g \\ hom H G; f \\ carrier G \\ carrier H; \\x. x \\ carrier G \\ g(f x) = x\\ \\ g \\ epi H G\"\n by sorry\n\nlemma (in monoid) hom_imp_img_monoid: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"h \\ hom G H\"\n shows \"monoid (H \\ carrier := h ` (carrier G), one := h \\\\<^bsub>G\\<^esub> \\)\" (is \"monoid ?h_img\")\n by sorry\n\nlemma (in group) hom_imp_img_group: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"h \\ hom G H\"\n shows \"group (H \\ carrier := h ` (carrier G), one := h \\\\<^bsub>G\\<^esub> \\)\" (is \"group ?h_img\")\n by sorry\n\nlemma (in group) iso_imp_group: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"G \\ H\" and \"monoid H\"\n shows \"group H\"\n by sorry\n\ncorollary (in group) iso_imp_img_group: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"h \\ iso G H\"\n shows \"group (H \\ one := h \\ \\)\"\n by sorry\n\nsubsubsection \\HOL Light's concept of an isomorphism pair\\\n\ndefinition group_isomorphisms\n where\n \"group_isomorphisms G H f g \\\n f \\ hom G H \\ g \\ hom H G \\\n (\\x \\ carrier G. g(f x) = x) \\\n (\\y \\ carrier H. f(g y) = y)\"\n\nlemma group_isomorphisms_sym: \"group_isomorphisms G H f g \\ group_isomorphisms H G g f\"\n by sorry\n\nlemma group_isomorphisms_imp_iso: \"group_isomorphisms G H f g \\ f \\ iso G H\"\n by sorry\n\nlemma (in group) iso_iff_group_isomorphisms:\n \"f \\ iso G H \\ (\\g. group_isomorphisms G H f g)\"\n by sorry\n\nsubsubsection \\Involving direct products\\\n\nlemma DirProd_commute_iso_set:\n shows \"(\\(x,y). (y,x)) \\ iso (G \\\\ H) (H \\\\ G)\"\n by sorry\n\ncorollary DirProd_commute_iso :\n\"(G \\\\ H) \\ (H \\\\ G)\"\n by sorry\n\nlemma DirProd_assoc_iso_set:\n shows \"(\\(x,y,z). (x,(y,z))) \\ iso (G \\\\ H \\\\ I) (G \\\\ (H \\\\ I))\"\n by sorry\n\nlemma (in group) DirProd_iso_set_trans:\n assumes \"g \\ iso G G2\"\n and \"h \\ iso H I\"\n shows \"(\\(x,y). (g x, h y)) \\ iso (G \\\\ H) (G2 \\\\ I)\"\n by sorry\n\ncorollary (in group) DirProd_iso_trans :\n assumes \"G \\ G2\" and \"H \\ I\"\n shows \"G \\\\ H \\ G2 \\\\ I\"\n by sorry\n\nlemma hom_pairwise: \"f \\ hom G (DirProd H K) \\ (fst \\ f) \\ hom G H \\ (snd \\ f) \\ hom G K\"\n by sorry\n\nlemma hom_paired:\n \"(\\x. (f x,g x)) \\ hom G (DirProd H K) \\ f \\ hom G H \\ g \\ hom G K\"\n by sorry\n\nlemma hom_paired2:\n assumes \"group G\" \"group H\"\n shows \"(\\(x,y). (f x,g y)) \\ hom (DirProd G H) (DirProd G' H') \\ f \\ hom G G' \\ g \\ hom H H'\"\n by sorry\n\nlemma iso_paired2:\n assumes \"group G\" \"group H\"\n shows \"(\\(x,y). (f x,g y)) \\ iso (DirProd G H) (DirProd G' H') \\ f \\ iso G G' \\ g \\ iso H H'\"\n by sorry\n\nlemma hom_of_fst:\n assumes \"group H\"\n shows \"(f \\ fst) \\ hom (DirProd G H) K \\ f \\ hom G K\"\n by sorry\n\nlemma hom_of_snd:\n assumes \"group G\"\n shows \"(f \\ snd) \\ hom (DirProd G H) K \\ f \\ hom H K\"\n by sorry\n\nsubsection\\The locale for a homomorphism between two groups\\\n\ntext\\Basis for homomorphism proofs: we assume two groups \\<^term>\\G\\ and\n \\<^term>\\H\\, with a homomorphism \\<^term>\\h\\ between them\\\nlocale group_hom = G?: group G + H?: group H for G (structure) and H (structure) +\n fixes h\n assumes homh [simp]: \"h \\ hom G H\"\n\ndeclare group_hom.homh [simp]\n\nlemma (in group_hom) hom_mult [simp]:\n \"[| x \\ carrier G; y \\ carrier G |] ==> h (x \\\\<^bsub>G\\<^esub> y) = h x \\\\<^bsub>H\\<^esub> h y\"\n by sorry\n\nlemma (in group_hom) hom_closed [simp]:\n \"x \\ carrier G ==> h x \\ carrier H\"\n by sorry\n\nlemma (in group_hom) one_closed: \"h \\ \\ carrier H\"\n by sorry\n\nlemma (in group_hom) hom_one [simp]: \"h \\ = \\\\<^bsub>H\\<^esub>\"\n by sorry\n\nlemma hom_one:\n assumes \"h \\ hom G H\" \"group G\" \"group H\"\n shows \"h (one G) = one H\"\n by sorry\n\nlemma hom_mult:\n \"\\h \\ hom G H; x \\ carrier G; y \\ carrier G\\ \\ h (x \\\\<^bsub>G\\<^esub> y) = h x \\\\<^bsub>H\\<^esub> h y\"\n by sorry\n\nlemma (in group_hom) inv_closed [simp]:\n \"x \\ carrier G ==> h (inv x) \\ carrier H\"\n by sorry\n\nlemma (in group_hom) hom_inv [simp]:\n assumes \"x \\ carrier G\" shows \"h (inv x) = inv\\<^bsub>H\\<^esub> (h x)\"\n by sorry\n\nlemma (in group) int_pow_is_hom: \\<^marker>\\contributor \\Joachim Breitner\\\\\n \"x \\ carrier G \\ (([^]) x) \\ hom \\ carrier = UNIV, mult = (+), one = 0::int \\ G \"\n by sorry\n\nlemma (in group_hom) img_is_subgroup: \"subgroup (h ` (carrier G)) H\" \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n by sorry\n\nlemma (in group_hom) subgroup_img_is_subgroup: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"subgroup I G\"\n shows \"subgroup (h ` I) H\"\n by sorry\n\nlemma (in subgroup) iso_subgroup: \\<^marker>\\contributor \\Jakob von Raumer\\\\\n assumes \"group G\" \"group F\"\n assumes \"\\ \\ iso G F\"\n shows \"subgroup (\\ ` H) F\"\n by sorry\n\nlemma (in group_hom) induced_group_hom: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"subgroup I G\"\n shows \"group_hom (G \\ carrier := I \\) (H \\ carrier := h ` I \\) h\"\n by sorry\n\ntext \\An isomorphism restricts to an isomorphism of subgroups.\\\n\nlemma iso_restrict:\n assumes \"\\ \\ iso G F\"\n assumes groups: \"group G\" \"group F\"\n assumes HG: \"subgroup H G\"\n shows \"(restrict \\ H) \\ iso (G\\carrier := H\\) (F\\carrier := \\ ` H\\)\"\n by sorry\n\nlemma (in group) canonical_inj_is_hom: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"subgroup H G\"\n shows \"group_hom (G \\ carrier := H \\) G id\"\n by sorry\n\nlemma (in group_hom) hom_nat_pow: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n \"x \\ carrier G \\ h (x [^] (n :: nat)) = (h x) [^]\\<^bsub>H\\<^esub> n\"\n by sorry\n\nlemma (in group_hom) hom_int_pow: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n \"x \\ carrier G \\ h (x [^] (n :: int)) = (h x) [^]\\<^bsub>H\\<^esub> n\"\n by sorry\n\nlemma hom_nat_pow:\n \"\\h \\ hom G H; x \\ carrier G; group G; group H\\ \\ h (x [^]\\<^bsub>G\\<^esub> (n :: nat)) = (h x) [^]\\<^bsub>H\\<^esub> n\"\n by sorry\n\nlemma hom_int_pow:\n \"\\h \\ hom G H; x \\ carrier G; group G; group H\\ \\ h (x [^]\\<^bsub>G\\<^esub> (n :: int)) = (h x) [^]\\<^bsub>H\\<^esub> n\"\n by sorry\n\nsubsection \\Commutative Structures\\\n\ntext \\\n Naming convention: multiplicative structures that are commutative\n are called \\emph{commutative}, additive structures are called\n \\emph{Abelian}.\n\\\n\nlocale comm_monoid = monoid +\n assumes m_comm: \"\\x \\ carrier G; y \\ carrier G\\ \\ x \\ y = y \\ x\"\n\nlemma (in comm_monoid) m_lcomm:\n \"\\x \\ carrier G; y \\ carrier G; z \\ carrier G\\ \\\n x \\ (y \\ z) = y \\ (x \\ z)\"\n by sorry\n\nlemmas (in comm_monoid) m_ac = m_assoc m_comm m_lcomm\n\nlemma comm_monoidI:\n fixes G (structure)\n assumes m_closed:\n \"!!x y. [| x \\ carrier G; y \\ carrier G |] ==> x \\ y \\ carrier G\"\n and one_closed: \"\\ \\ carrier G\"\n and m_assoc:\n \"!!x y z. [| x \\ carrier G; y \\ carrier G; z \\ carrier G |] ==>\n (x \\ y) \\ z = x \\ (y \\ z)\"\n and l_one: \"!!x. x \\ carrier G ==> \\ \\ x = x\"\n and m_comm:\n \"!!x y. [| x \\ carrier G; y \\ carrier G |] ==> x \\ y = y \\ x\"\n shows \"comm_monoid G\"\n by sorry\n\nlemma (in monoid) monoid_comm_monoidI:\n assumes m_comm:\n \"!!x y. [| x \\ carrier G; y \\ carrier G |] ==> x \\ y = y \\ x\"\n shows \"comm_monoid G\"\n by sorry\n\nlemma (in comm_monoid) submonoid_is_comm_monoid :\n assumes \"submonoid H G\"\n shows \"comm_monoid (G\\carrier := H\\)\"\n by sorry\n\nlocale comm_group = comm_monoid + group\n\nlemma (in group) group_comm_groupI:\n assumes m_comm: \"!!x y. [| x \\ carrier G; y \\ carrier G |] ==> x \\ y = y \\ x\"\n shows \"comm_group G\"\n by sorry\n\nlemma comm_groupI:\n fixes G (structure)\n assumes m_closed:\n \"!!x y. [| x \\ carrier G; y \\ carrier G |] ==> x \\ y \\ carrier G\"\n and one_closed: \"\\ \\ carrier G\"\n and m_assoc:\n \"!!x y z. [| x \\ carrier G; y \\ carrier G; z \\ carrier G |] ==>\n (x \\ y) \\ z = x \\ (y \\ z)\"\n and m_comm:\n \"!!x y. [| x \\ carrier G; y \\ carrier G |] ==> x \\ y = y \\ x\"\n and l_one: \"!!x. x \\ carrier G ==> \\ \\ x = x\"\n and l_inv_ex: \"!!x. x \\ carrier G ==> \\y \\ carrier G. y \\ x = \\\"\n shows \"comm_group G\"\n by sorry\n\nlemma comm_groupE:\n fixes G (structure)\n assumes \"comm_group G\"\n shows \"\\x y. \\ x \\ carrier G; y \\ carrier G \\ \\ x \\ y \\ carrier G\"\n and \"\\ \\ carrier G\"\n and \"\\x y z. \\ x \\ carrier G; y \\ carrier G; z \\ carrier G \\ \\ (x \\ y) \\ z = x \\ (y \\ z)\"\n and \"\\x y. \\ x \\ carrier G; y \\ carrier G \\ \\ x \\ y = y \\ x\"\n and \"\\x. x \\ carrier G \\ \\ \\ x = x\"\n and \"\\x. x \\ carrier G \\ \\y \\ carrier G. y \\ x = \\\"\n by sorry\n\nlemma (in comm_group) inv_mult:\n \"[| x \\ carrier G; y \\ carrier G |] ==> inv (x \\ y) = inv x \\ inv y\"\n by sorry\n\nlemma (in comm_monoid) nat_pow_distrib:\n fixes n::nat\n assumes \"x \\ carrier G\" \"y \\ carrier G\"\n shows \"(x \\ y) [^] n = x [^] n \\ y [^] n\"\n by sorry\n\nlemma (in comm_group) int_pow_distrib:\n assumes \"x \\ carrier G\" \"y \\ carrier G\"\n shows \"(x \\ y) [^] (i::int) = x [^] i \\ y [^] i\"\n by sorry\n\nlemma (in comm_monoid) hom_imp_img_comm_monoid: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"h \\ hom G H\"\n shows \"comm_monoid (H \\ carrier := h ` (carrier G), one := h \\\\<^bsub>G\\<^esub> \\)\" (is \"comm_monoid ?h_img\")\n by sorry\n\nlemma (in comm_group) hom_group_mult:\n assumes \"f \\ hom H G\" \"g \\ hom H G\"\n shows \"(\\x. f x \\\\<^bsub>G\\<^esub> g x) \\ hom H G\"\n by sorry\n\nlemma (in comm_group) hom_imp_img_comm_group: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"h \\ hom G H\"\n shows \"comm_group (H \\ carrier := h ` (carrier G), one := h \\\\<^bsub>G\\<^esub> \\)\"\n by sorry\n\nlemma (in comm_group) iso_imp_img_comm_group: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"h \\ iso G H\"\n shows \"comm_group (H \\ one := h \\\\<^bsub>G\\<^esub> \\)\"\n by sorry\n\nlemma (in comm_group) iso_imp_comm_group: \\<^marker>\\contributor \\Paulo Emílio de Vilhena\\\\\n assumes \"G \\ H\" \"monoid H\"\n shows \"comm_group H\"\n by sorry\n\nlemma (in group) incl_subgroup:\n assumes \"subgroup J G\"\n and \"subgroup I (G\\carrier:=J\\)\"\n shows \"subgroup I G\" unfolding subgroup_def\n by sorry\n\nlemma (in group) subgroup_incl:\n assumes \"subgroup I G\" and \"subgroup J G\" and \"I \\ J\"\n shows \"subgroup I (G \\ carrier := J \\)\"\n by sorry\n\nsubsection \\The Lattice of Subgroups of a Group\\\n\ntext_raw \\\\label{sec:subgroup-lattice}\\\n\ntheorem (in group) subgroups_partial_order:\n \"partial_order \\carrier = {H. subgroup H G}, eq = (=), le = (\\)\\\"\n by sorry\n\nlemma (in group) subgroup_self:\n \"subgroup (carrier G) G\"\n by sorry\n\nlemma (in group) subgroup_imp_group:\n \"subgroup H G ==> group (G\\carrier := H\\)\"\n by sorry\n\nlemma (in group) subgroup_mult_equality:\n \"\\ subgroup H G; h1 \\ H; h2 \\ H \\ \\ h1 \\\\<^bsub>G \\ carrier := H \\\\<^esub> h2 = h1 \\ h2\"\n by sorry\n\ntheorem (in group) subgroups_Inter:\n assumes subgr: \"(\\H. H \\ A \\ subgroup H G)\"\n and not_empty: \"A \\ {}\"\n shows \"subgroup (\\A) G\"\n by sorry\n\nlemma (in group) subgroups_Inter_pair :\n assumes \"subgroup I G\" \"subgroup J G\" shows \"subgroup (I\\J) G\" \n by sorry\n\ntheorem (in group) subgroups_complete_lattice:\n \"complete_lattice \\carrier = {H. subgroup H G}, eq = (=), le = (\\)\\\"\n (is \"complete_lattice ?L\")\n by sorry\n\nsubsection\\The units in any monoid give rise to a group\\\n\ntext \\Thanks to Jeremy Avigad. The file Residues.thy provides some infrastructure to use\n facts about the unit group within the ring locale.\n\\\n\ndefinition units_of :: \"('a, 'b) monoid_scheme \\ 'a monoid\"\n where \"units_of G =\n \\carrier = Units G, Group.monoid.mult = Group.monoid.mult G, one = one G\\\"\n\nlemma (in monoid) units_group: \"group (units_of G)\"\n by sorry\n\nlemma (in comm_monoid) units_comm_group: \"comm_group (units_of G)\"\n by sorry\n\nlemma units_of_carrier: \"carrier (units_of G) = Units G\"\n by sorry\n\nlemma units_of_mult: \"mult (units_of G) = mult G\"\n by sorry\n\nlemma units_of_one: \"one (units_of G) = one G\"\n by sorry\n\nlemma (in monoid) units_of_inv:\n assumes \"x \\ Units G\"\n shows \"m_inv (units_of G) x = m_inv G x\"\n by sorry\n\nlemma units_of_units [simp] : \"Units (units_of G) = Units G\"\n by sorry\n\nlemma (in group) surj_const_mult: \"a \\ carrier G \\ (\\x. a \\ x) ` carrier G = carrier G\"\n by sorry\n\nlemma (in group) l_cancel_one [simp]: \"x \\ carrier G \\ a \\ carrier G \\ x \\ a = x \\ a = one G\"\n by sorry\n\nlemma (in group) r_cancel_one [simp]: \"x \\ carrier G \\ a \\ carrier G \\ a \\ x = x \\ a = one G\"\n by sorry\n\nlemma (in group) l_cancel_one' [simp]: \"x \\ carrier G \\ a \\ carrier G \\ x = x \\ a \\ a = one G\"\n by sorry\n\nlemma (in group) r_cancel_one' [simp]: \"x \\ carrier G \\ a \\ carrier G \\ x = a \\ x \\ a = one G\"\n by sorry\n\ndeclare pow_nat [simp] \n\nend" }, { "theorem_id": 56, "title": "071_order_of_a_subgroup__lagrange_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Mitchell Rowett. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mitchell Rowett, Kim Morrison\n-/\nmodule\n\npublic import Mathlib.GroupTheory.Coset.Basic\npublic import Mathlib.SetTheory.Cardinal.Finite\n\n/-!\n# Lagrange's theorem: the order of a subgroup divides the order of the group.\n\n* `Subgroup.card_subgroup_dvd_card`: Lagrange's theorem (for multiplicative groups);\n there is an analogous version for additive groups\n\n-/\n\n@[expose] public section\n\nassert_not_exists Field\n\nopen scoped Pointwise\n\nvariable {α : Type*} [Group α] {s : Subgroup α}\n\nnamespace QuotientGroup\n\n@[to_additive]\ninstance fintype [Fintype α] (s : Subgroup α) [DecidableRel (leftRel s).r] : Fintype (α ⧸ s) :=\n Quotient.fintype (leftRel s)\n\n@[to_additive]\ninstance (priority := 100) finite [Finite α] : Finite (α ⧸ s) :=\n Quotient.finite _\n\n@[to_additive]\ninstance fintypeQuotientRightRel [Fintype (α ⧸ s)] :\n Fintype (Quotient (QuotientGroup.rightRel s)) :=\n .ofEquiv (α ⧸ s) (QuotientGroup.quotientRightRelEquivQuotientLeftRel s).symm\n\nvariable (s) in\n@[to_additive]\nlemma card_quotient_rightRel [Fintype (α ⧸ s)] :\n Fintype.card (Quotient (QuotientGroup.rightRel s)) = Fintype.card (α ⧸ s) :=\n Fintype.ofEquiv_card (QuotientGroup.quotientRightRelEquivQuotientLeftRel s).symm\n\nend QuotientGroup\n\nnamespace Subgroup\n\n@[to_additive AddSubgroup.card_eq_card_quotient_mul_card_addSubgroup]\ntheorem card_eq_card_quotient_mul_card_subgroup (s : Subgroup α) :\n Nat.card α = Nat.card (α ⧸ s) * Nat.card s := by sorry\nlemma card_mul_eq_card_subgroup_mul_card_quotient (s : Subgroup α) (t : Set α) :\n Nat.card (t * s : Set α) = Nat.card s * Nat.card (t.image (↑) : Set (α ⧸ s)) := by sorry\ntheorem card_subgroup_dvd_card (s : Subgroup α) : Nat.card s ∣ Nat.card α := by sorry\ntheorem card_quotient_dvd_card (s : Subgroup α) : Nat.card (α ⧸ s) ∣ Nat.card α := by sorry\nvariable {H : Type*} [Group H]\n\n@[to_additive]\ntheorem card_dvd_of_injective (f : α →* H) (hf : Function.Injective f) :\n Nat.card α ∣ Nat.card H := by sorry\ntheorem card_dvd_of_le {H K : Subgroup α} (hHK : H ≤ K) : Nat.card H ∣ Nat.card K :=\n card_dvd_of_injective (inclusion hHK) (inclusion_injective hHK)\n\n@[to_additive]\ntheorem card_comap_dvd_of_injective (K : Subgroup H) (f : α →* H)\n (hf : Function.Injective f) : Nat.card (K.comap f) ∣ Nat.card K :=\n calc Nat.card (K.comap f) = Nat.card ((K.comap f).map f) :=\n Nat.card_congr (equivMapOfInjective _ _ hf).toEquiv\n _ ∣ Nat.card K := card_dvd_of_le (map_comap_le _ _)\n\nend Subgroup\n" }, { "theorem_id": 56, "title": "071_order_of_a_subgroup__lagrange_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From HB Require Import structures.\nFrom mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice.\nFrom mathcomp Require Import fintype div path tuple bigop prime finset.\nFrom mathcomp Require Export monoid.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nDeclare Scope Group_scope.\n\nDelimit Scope Group_scope with G.\n\nModule GroupScope.\nOpen Scope group_scope.\nEnd GroupScope.\nLocal Open Scope group_scope.\n\nReserved Notation \"[ ~ x1 , x2 , .. , xn ]\"\n (format \"'[ ' [ ~ x1 , '/' x2 , '/' .. , '/' xn ] ']'\").\nReserved Notation \"[ 1 gT ]\" (format \"[ 1 gT ]\").\nReserved Notation \"[ 1 ]\" (format \"[ 1 ]\").\nReserved Notation \"[ 'subg' G ]\" (format \"[ 'subg' G ]\").\n#[warning=\"-postfix-notation-not-level-1\"]\nReserved Notation \"A ^#\" (at level 3, format \"A ^#\").\n\nReserved Notation \"A :^ x\" (at level 35, right associativity).\nReserved Notation \"x ^: B\" (at level 35, right associativity).\nReserved Notation \"A :^: B\" (at level 35, right associativity).\nReserved Notation \"#| B : A |\" (A at level 99, format \"#| B : A |\").\nReserved Notation \"''N' ( A )\" (format \"''N' ( A )\").\nReserved Notation \"''N_' G ( A )\" (G at level 2, format \"''N_' G ( A )\").\nReserved Notation \"A <| B\" (at level 70, no associativity).\nReserved Notation \"A <*> B\" (at level 40, left associativity).\nReserved Notation \"[ ~: A1 , A2 , .. , An ]\"\n (format \"[ ~: '[' A1 , '/' A2 , '/' .. , '/' An ']' ]\").\nReserved Notation \"[ 'max' A 'of' G | gP ]\"\n (format \"[ '[hv' 'max' A 'of' G '/ ' | gP ']' ]\").\nReserved Notation \"[ 'max' G | gP ]\"\n (format \"[ '[hv' 'max' G '/ ' | gP ']' ]\").\nReserved Notation \"[ 'max' A 'of' G | gP & gQ ]\"\n (format \"[ '[hv' 'max' A 'of' G '/ ' | gP '/ ' & gQ ']' ]\").\nReserved Notation \"[ 'max' G | gP & gQ ]\"\n (format \"[ '[hv' 'max' G '/ ' | gP '/ ' & gQ ']' ]\").\nReserved Notation \"[ 'min' A 'of' G | gP ]\"\n (format \"[ '[hv' 'min' A 'of' G '/ ' | gP ']' ]\").\nReserved Notation \"[ 'min' G | gP ]\"\n (format \"[ '[hv' 'min' G '/ ' | gP ']' ]\").\nReserved Notation \"[ 'min' A 'of' G | gP & gQ ]\"\n (format \"[ '[hv' 'min' A 'of' G '/ ' | gP '/ ' & gQ ']' ]\").\nReserved Notation \"[ 'min' G | gP & gQ ]\"\n (format \"[ '[hv' 'min' G '/ ' | gP '/ ' & gQ ']' ]\").\n\nModule isMulBaseGroup.\n#[deprecated(since=\"mathcomp 2.5.0\", use=isStarMonoid.Build)]\nNotation Build G := (isStarMonoid.Build G) (only parsing).\nEnd isMulBaseGroup.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=isStarMonoid)]\nNotation isMulBaseGroup G := (isStarMonoid G) (only parsing).\n\nModule BaseFinGroup_isGroup.\n#[deprecated(since=\"mathcomp 2.5.0\", use=StarMonoid_isGroup.Build)]\nNotation Build G := (StarMonoid_isGroup.Build G) (only parsing).\nEnd BaseFinGroup_isGroup.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=StarMonoid_isGroup)]\nNotation BaseFinGroup_isGroup G := (StarMonoid_isGroup G) (only parsing).\n\n#[arg_sort, short(type=\"finStarMonoidType\")]\nHB.structure Definition FinStarMonoid := { G of StarMonoid G & Finite G }.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=finStarMonoidType)]\nNotation baseFinGroupType := finStarMonoidType (only parsing).\n\nModule BaseFinGroup.\n#[deprecated(since=\"mathcomp 2.5.0\", use=FinStarMonoid.sort)]\nNotation sort := (FinStarMonoid.sort) (only parsing).\n#[deprecated(since=\"mathcomp 2.5.0\", use=FinStarMonoid.arg_sort)]\nNotation arg_sort := (FinStarMonoid.arg_sort) (only parsing).\n#[deprecated(since=\"mathcomp 2.5.0\", use=FinStarMonoid.on)]\nNotation on M := (FinStarMonoid.on M) (only parsing).\n#[deprecated(since=\"mathcomp 2.5.0\", use=FinStarMonoid.copy)]\nNotation copy M N := (FinStarMonoid.copy M N) (only parsing).\n#[deprecated(since=\"mathcomp 2.5.0\", use=FinStarMonoid.clone)]\nNotation clone M N := (FinStarMonoid.clone M N) (only parsing).\nEnd BaseFinGroup.\n\n#[deprecated(since=\"mathcomp 2.4.0\", use=FinStarMonoid)]\nNotation BaseFinGroup R := (FinStarMonoid R) (only parsing).\n\nModule FinStarMonoidExports.\nBind Scope group_scope with FinStarMonoid.arg_sort.\nBind Scope group_scope with FinStarMonoid.sort.\nEnd FinStarMonoidExports.\nHB.export FinStarMonoidExports.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=one)]\nNotation oneg := one (only parsing).\n#[deprecated(since=\"mathcomp 2.5.0\", use=mul)]\nNotation mulg := mul (only parsing).\n#[deprecated(since=\"mathcomp 2.5.0\", use=inv)]\nNotation invg := inv (only parsing).\n#[deprecated(since=\"mathcomp 2.5.0\", use=natexp)]\nNotation expgn := natexp (only parsing).\n\n#[short(type=\"finGroupType\")]\nHB.structure Definition FinGroup :=\n { G of Group G & Finite G }.\n\nModule FinGroupExports.\nBind Scope group_scope with FinGroup.sort.\nEnd FinGroupExports.\nHB.export FinGroupExports.\n\nHB.factory Record Finite_isGroup G & Finite G := {\n mul : G -> G -> G;\n one : G;\n inv : G -> G;\n mulgA : associative mul;\n mul1g : left_id one mul;\n mulVg : left_inverse one inv mul;\n}.\n\nModule isMulGroup.\n#[deprecated(since=\"mathcomp 2.5.0\", use=Finite_isGroup.Build)]\nNotation Build G := (Finite_isGroup.Build G) (only parsing).\nEnd isMulGroup.\n#[deprecated(since=\"mathcomp 2.5.0\", use=Finite_isGroup)]\nNotation isMulGroup G := (Finite_isGroup G) (only parsing).\n\nHB.builders Context G & Finite_isGroup G.\n\nNotation \"1\" := one.\nInfix \"*\" := mul.\nNotation \"x ^-1\" := (inv x).\n\nLemma invgK : involutive inv.\nProof.\nAdmitted.\n\nLemma invMg : {morph inv : x y / x * y >-> y * x}.\nProof.\nAdmitted.\n\nHB.instance Definition _ :=\n isStarMonoid.Build G mulgA mul1g invgK invMg.\nHB.instance Definition _ := StarMonoid_isGroup.Build G mulVg.\n\nHB.end.\n\n#[compress_coercions]\nHB.instance Definition _ (T : finStarMonoidType) :\n Finite (FinStarMonoid.arg_sort T) := Finite.class T.\n\nNotation conjg := conjg (only parsing).\nNotation commg := commg (only parsing).\nNotation mulgA := mulgA (only parsing).\nNotation mul1g := mul1g (only parsing).\nNotation invgK := invgK (only parsing).\nNotation invMg := invgM (only parsing).\nNotation invg_inj := invg_inj (only parsing).\nNotation eq_invg_sym := eqg_invLR (only parsing).\nNotation invg1 := invg1 (only parsing).\nNotation eq_invg1 := invg_eq1 (only parsing).\nNotation mulg1 := mulg1 (only parsing).\nNotation expgnE := expgnE (only parsing).\nNotation expg0 := expg0 (only parsing).\nNotation expg1 := expg1 (only parsing).\nNotation expg1n := expg1n (only parsing).\nNotation expgD := expgnDr (only parsing).\nNotation expgSr := expgSr (only parsing).\nNotation expgM := expgnA (only parsing).\nNotation expgAC := expgnAC (only parsing).\nNotation commute := commute (only parsing).\nNotation commute_refl := commute_refl (only parsing).\nNotation commute_sym := commute_sym (only parsing).\nNotation commute1 := commute1 (only parsing).\nNotation commuteM := commuteM (only parsing).\nNotation commuteX := commuteX (only parsing).\nNotation commuteX2 := commuteX2 (only parsing).\nNotation expgVn := expVgn (only parsing).\nNotation expgMn := expgMn (only parsing).\nNotation mulVg := mulVg (only parsing).\nNotation mulgV := mulgV (only parsing).\nNotation mulKg := mulKg (only parsing).\nNotation mulKVg := mulVKg (only parsing).\nNotation mulgI := mulgI (only parsing).\nNotation mulgK := mulgK (only parsing).\nNotation mulgKV := mulgVK (only parsing).\nLemma eq_invg_mul (T : finGroupType) x y : (x^-1 == y :> T) = (x * y == 1).\nProof.\nAdmitted.\nLemma eq_mulgV1 (T : finGroupType) x y : (x == y) = (x * y^-1 == 1 :> T).\nProof.\nAdmitted.\nLemma eq_mulVg1 (T : finGroupType) x y : (x == y) = (x^-1 * y == 1 :> T).\nProof.\nAdmitted.\nNotation commuteV := commuteV (only parsing).\nNotation conjgE := conjgE (only parsing).\nNotation conjgC := conjgC (only parsing).\nNotation conjgCV := conjgCV (only parsing).\nNotation conjg1 := conjg1 (only parsing).\nNotation conj1g := conj1g (only parsing).\nNotation conjMg := conjMg (only parsing).\nNotation conjgM := conjgM (only parsing).\nNotation conjVg := conjVg (only parsing).\nNotation conjJg := conjJg (only parsing).\nNotation conjXg := conjXg (only parsing).\nNotation conjgK := conjgK (only parsing).\nNotation conjgKV := conjgKV (only parsing).\nNotation conjg_inj := conjg_inj (only parsing).\nNotation conjg_eq1 := conjg_eq1 (only parsing).\nNotation conjg_prod := conjg_prod (only parsing).\nNotation commgEl := commgEl (only parsing).\nNotation commgEr := commgEr (only parsing).\nNotation commgC := commgC (only parsing).\nNotation commgCV := commgCV (only parsing).\nNotation conjRg := conjRg (only parsing).\nNotation invg_comm := invgR (only parsing).\nNotation commgP := commgP (only parsing).\nNotation conjg_fixP := conjg_fixP (only parsing).\nNotation commg1_sym := commg1_sym (only parsing).\nNotation commg1 := commg1 (only parsing).\nNotation comm1g := comm1g (only parsing).\nNotation commgg := commgg (only parsing).\nNotation commgXg := commgXg (only parsing).\nNotation commgVg := commgVg (only parsing).\nNotation commgXVg := commgXVg (only parsing).\n\nSection Repr.\n\nVariable gT : finStarMonoidType.\nImplicit Type A : {set gT}.\n\nDefinition repr A := if 1 \\in A then 1 else odflt 1 [pick x in A].\n\nLemma mem_repr A x : x \\in A -> repr A \\in A.\nProof.\nAdmitted.\n\nLemma card_mem_repr A : #|A| > 0 -> repr A \\in A.\nProof.\nAdmitted.\n\nLemma repr_set1 x : repr [set x] = x.\nProof.\nAdmitted.\n\nLemma repr_set0 : repr set0 = 1.\nProof.\nAdmitted.\n\nEnd Repr.\n\nArguments mem_repr [gT A].\n\nSection BaseSetMulDef.\n\nVariable gT : finStarMonoidType.\nImplicit Types A B : {set gT}.\n\nDefinition set_mulg A B := mul @2: (A, B).\nDefinition set_invg A := inv @^-1: A.\n\nLemma set_mul1g : left_id [set 1] set_mulg.\nProof.\nAdmitted.\n\nLemma set_mulgA : associative set_mulg.\nProof.\nAdmitted.\n\nLemma set_invgK : involutive set_invg.\nProof.\nAdmitted.\n\nLemma set_invgM : {morph set_invg : A B / set_mulg A B >-> set_mulg B A}.\nProof.\nAdmitted.\n\nHB.instance Definition set_base_group := isStarMonoid.Build (set_type gT)\n set_mulgA set_mul1g set_invgK set_invgM.\nHB.instance Definition _ : isStarMonoid {set gT} := set_base_group.\n\nEnd BaseSetMulDef.\n\nModule GroupSet.\nDefinition sort (gT : finStarMonoidType) := {set gT}.\nEnd GroupSet.\nIdentity Coercion GroupSet_of_sort : GroupSet.sort >-> set_of.\n\nModule Type GroupSetFinStarMonoidSig.\nDefinition sort (gT : finStarMonoidType) := FinStarMonoid.arg_sort {set gT}.\nEnd GroupSetFinStarMonoidSig.\n\nModule MakeGroupSetFinStarMonoid (Gset_base : GroupSetFinStarMonoidSig).\nIdentity Coercion of_sort : Gset_base.sort >-> FinStarMonoid.arg_sort.\nEnd MakeGroupSetFinStarMonoid.\n\nModule Export GroupSetFinStarMonoid := MakeGroupSetFinStarMonoid GroupSet.\n\nModule Type GroupSetMagmaSig.\nDefinition sort (gT : finStarMonoidType) := Magma.sort {set gT}.\nEnd GroupSetMagmaSig.\n\nModule MakeGroupSetMagma (Gset_base : GroupSetMagmaSig).\nIdentity Coercion of_sort : Gset_base.sort >-> Magma.sort.\nEnd MakeGroupSetMagma.\n\nModule Export GroupSetMagma := MakeGroupSetMagma GroupSet.\n\nModule Type GroupSetBaseGroupSig.\nDefinition sort (gT : finStarMonoidType) := BaseGroup.sort {set gT}.\nEnd GroupSetBaseGroupSig.\n\nModule MakeGroupSetBaseGroup (Gset_base : GroupSetBaseGroupSig).\nIdentity Coercion of_sort : Gset_base.sort >-> BaseGroup.sort.\nEnd MakeGroupSetBaseGroup.\n\nModule Export GroupSetBaseGroup := MakeGroupSetBaseGroup GroupSet.\n\nHB.instance Definition _ gT : Finite (GroupSet.sort gT) :=\n Finite.class {set gT}.\n\nSection GroupSetMulDef.\n\nVariable gT : finGroupType.\nImplicit Types A B : {set gT}.\nImplicit Type x y : gT.\n\nDefinition lcoset A x := mul x @: A.\nDefinition rcoset A x := mul^~ x @: A.\nDefinition lcosets A B := lcoset A @: B.\nDefinition rcosets A B := rcoset A @: B.\nDefinition indexg B A := #|rcosets A B|.\n\nDefinition conjugate A x := conjg^~ x @: A.\nDefinition conjugates A B := conjugate A @: B.\nDefinition class x B := conjg x @: B.\nDefinition classes A := class^~ A @: A.\nDefinition class_support A B := conjg @2: (A, B).\n\nDefinition commg_set A B := commg @2: (A, B).\n\nDefinition normaliser A := [set x | conjugate A x \\subset A].\nDefinition centraliser A := \\bigcap_(x in A) normaliser [set x].\nDefinition abelian A := A \\subset centraliser A.\nDefinition normal A B := (A \\subset B) && (B \\subset normaliser A).\n\nDefinition normalised A := forall x, conjugate A x = A.\nDefinition centralises x A := forall y, y \\in A -> commute x y.\nDefinition centralised A := forall x, centralises x A.\n\nEnd GroupSetMulDef.\n\nArguments lcoset _ _%_g _%_g.\nArguments rcoset _ _%_g _%_g.\nArguments rcosets _ _%_g _%_g.\nArguments lcosets _ _%_g _%_g.\nArguments indexg _ _%_g _%_g.\nArguments conjugate _ _%_g _%_g.\nArguments conjugates _ _%_g _%_g.\nArguments class _ _%_g _%_g.\nArguments classes _ _%_g.\nArguments class_support _ _%_g _%_g.\nArguments commg_set _ _%_g _%_g.\nArguments normaliser _ _%_g.\nArguments centraliser _ _%_g.\nArguments abelian _ _%_g.\nArguments normal _ _%_g _%_g.\nArguments normalised _ _%_g.\nArguments centralises _ _%_g _%_g.\nArguments centralised _ _%_g.\n\nNotation \"[ 1 gT ]\" := (1 : {set gT}) : group_scope.\nNotation \"[ 1 ]\" := [1 FinGroup.sort _] : group_scope.\n\nNotation \"A ^#\" := (A :\\ 1) : group_scope.\n\nNotation \"x *: A\" := ([set x%g] * A) : group_scope.\nNotation \"A :* x\" := (A * [set x%g]) : group_scope.\nNotation \"A :^ x\" := (conjugate A x) : group_scope.\nNotation \"x ^: B\" := (class x B) : group_scope.\nNotation \"A :^: B\" := (conjugates A B) : group_scope.\n\nNotation \"#| B : A |\" := (indexg B A) : group_scope.\n\nNotation \"''N' ( A )\" := (normaliser A) : group_scope.\nNotation \"''N_' G ( A )\" := (G%g :&: 'N(A)) : group_scope.\nNotation \"A <| B\" := (normal A B) : group_scope.\nNotation \"''C' ( A )\" := (centraliser A) : group_scope.\nNotation \"''C_' G ( A )\" := (G%g :&: 'C(A)) : group_scope.\nNotation \"''C_' ( G ) ( A )\" := 'C_G(A) (only parsing) : group_scope.\nNotation \"''C' [ x ]\" := 'N([set x%g]) : group_scope.\nNotation \"''C_' G [ x ]\" := 'N_G([set x%g]) : group_scope.\nNotation \"''C_' ( G ) [ x ]\" := 'C_G[x] (only parsing) : group_scope.\n\nPrenex Implicits repr lcoset rcoset lcosets rcosets normal.\nPrenex Implicits conjugate conjugates class classes class_support.\nPrenex Implicits commg_set normalised centralised abelian.\n\nSection BaseSetMulProp.\n\nVariable gT : finStarMonoidType.\nImplicit Types A B C D : {set gT}.\nImplicit Type x y z : gT.\n\nLemma mulsgP A B x :\n reflect (imset2_spec mul (mem A) (fun _ => mem B) x) (x \\in A * B).\nProof.\nAdmitted.\n\nLemma mem_mulg A B x y : x \\in A -> y \\in B -> x * y \\in A * B.\nProof.\nAdmitted.\n\nLemma prodsgP (I : finType) (P : pred I) (A : I -> {set gT}) x :\n reflect (exists2 c, forall i, P i -> c i \\in A i & x = \\prod_(i | P i) c i)\n (x \\in \\prod_(i | P i) A i).\nProof.\nAdmitted.\n\nLemma mem_prodg (I : finType) (P : pred I) (A : I -> {set gT}) c :\n (forall i, P i -> c i \\in A i) -> \\prod_(i | P i) c i \\in \\prod_(i | P i) A i.\nProof.\nAdmitted.\n\nLemma mulSg A B C : A \\subset B -> A * C \\subset B * C.\nProof.\nAdmitted.\n\nLemma mulgS A B C : B \\subset C -> A * B \\subset A * C.\nProof.\nAdmitted.\n\nLemma mulgSS A B C D : A \\subset B -> C \\subset D -> A * C \\subset B * D.\nProof.\nAdmitted.\n\nLemma mulg_subl A B : 1 \\in B -> A \\subset A * B.\nProof.\nAdmitted.\n\nLemma mulg_subr A B : 1 \\in A -> B \\subset A * B.\nProof.\nAdmitted.\n\nLemma mulUg A B C : (A :|: B) * C = (A * C) :|: (B * C).\nProof.\nAdmitted.\n\nLemma mulgU A B C : A * (B :|: C) = (A * B) :|: (A * C).\nProof.\nAdmitted.\n\nLemma invUg A B : (A :|: B)^-1 = A^-1 :|: B^-1.\nProof.\nAdmitted.\n\nLemma invIg A B : (A :&: B)^-1 = A^-1 :&: B^-1.\nProof.\nAdmitted.\n\nLemma invDg A B : (A :\\: B)^-1 = A^-1 :\\: B^-1.\nProof.\nAdmitted.\n\nLemma invCg A : (~: A)^-1 = ~: A^-1.\nProof.\nAdmitted.\n\nLemma invSg A B : (A^-1 \\subset B^-1) = (A \\subset B).\nProof.\nAdmitted.\n\nLemma mem_invg x A : (x \\in A^-1) = (x^-1 \\in A).\nProof.\nAdmitted.\n\nLemma memV_invg x A : (x^-1 \\in A^-1) = (x \\in A).\nProof.\nAdmitted.\n\nLemma card_invg A : #|A^-1| = #|A|.\nProof.\nAdmitted.\n\nLemma set1gE : 1 = [set 1] :> {set gT}.\nProof.\nAdmitted.\nLemma set1gP x : reflect (x = 1) (x \\in [1 gT]).\nProof.\nAdmitted.\n\nLemma mulg_set1 x y : [set x] :* y = [set x * y].\nProof.\nAdmitted.\n\nLemma invg_set1 x : [set x]^-1 = [set x^-1].\nProof.\nAdmitted.\n\nEnd BaseSetMulProp.\n\nArguments set1gP {gT x}.\nArguments mulsgP {gT A B x}.\nArguments prodsgP {gT I P A x}.\n\nSection GroupSetMulProp.\n\nVariable gT : finGroupType.\nImplicit Types A B C D : {set gT}.\nImplicit Type x y z : gT.\n\nLemma lcosetE A x : lcoset A x = x *: A.\nProof.\nAdmitted.\n\nLemma card_lcoset A x : #|x *: A| = #|A|.\nProof.\nAdmitted.\n\nLemma mem_lcoset A x y : (y \\in x *: A) = (x^-1 * y \\in A).\nProof.\nAdmitted.\n\nLemma lcosetP A x y : reflect (exists2 a, a \\in A & y = x * a) (y \\in x *: A).\nProof.\nAdmitted.\n\nLemma lcosetsP A B C :\n reflect (exists2 x, x \\in B & C = x *: A) (C \\in lcosets A B).\nProof.\nAdmitted.\n\nLemma lcosetM A x y : (x * y) *: A = x *: (y *: A).\nProof.\nAdmitted.\n\nLemma lcoset1 A : 1 *: A = A.\nProof.\nAdmitted.\n\nLemma lcosetK : left_loop inv (fun x A => x *: A).\nProof.\nAdmitted.\n\nLemma lcosetKV : rev_left_loop inv (fun x A => x *: A).\nProof.\nAdmitted.\n\nLemma lcoset_inj : right_injective (fun x A => x *: A).\nProof.\nAdmitted.\n\nLemma lcosetS x A B : (x *: A \\subset x *: B) = (A \\subset B).\nProof.\nAdmitted.\n\nLemma sub_lcoset x A B : (A \\subset x *: B) = (x^-1 *: A \\subset B).\nProof.\nAdmitted.\n\nLemma sub_lcosetV x A B : (A \\subset x^-1 *: B) = (x *: A \\subset B).\nProof.\nAdmitted.\n\nLemma rcosetE A x : rcoset A x = A :* x.\nProof.\nAdmitted.\n\nLemma card_rcoset A x : #|A :* x| = #|A|.\nProof.\nAdmitted.\n\nLemma mem_rcoset A x y : (y \\in A :* x) = (y * x^-1 \\in A).\nProof.\nAdmitted.\n\nLemma rcosetP A x y : reflect (exists2 a, a \\in A & y = a * x) (y \\in A :* x).\nProof.\nAdmitted.\n\nLemma rcosetsP A B C :\n reflect (exists2 x, x \\in B & C = A :* x) (C \\in rcosets A B).\nProof.\nAdmitted.\n\nLemma rcosetM A x y : A :* (x * y) = A :* x :* y.\nProof.\nAdmitted.\n\nLemma rcoset1 A : A :* 1 = A.\nProof.\nAdmitted.\n\nLemma rcosetK : right_loop inv (fun A x => A :* x).\nProof.\nAdmitted.\n\nLemma rcosetKV : rev_right_loop inv (fun A x => A :* x).\nProof.\nAdmitted.\n\nLemma rcoset_inj : left_injective (fun A x => A :* x).\nProof.\nAdmitted.\n\nLemma rcosetS x A B : (A :* x \\subset B :* x) = (A \\subset B).\nProof.\nAdmitted.\n\nLemma sub_rcoset x A B : (A \\subset B :* x) = (A :* x ^-1 \\subset B).\nProof.\nAdmitted.\n\nLemma sub_rcosetV x A B : (A \\subset B :* x^-1) = (A :* x \\subset B).\nProof.\nAdmitted.\n\nLemma invg_lcosets A B : (lcosets A B)^-1 = rcosets A^-1 B^-1.\nProof.\nAdmitted.\n\nLemma conjg_preim A x : A :^ x = (conjg^~ x^-1) @^-1: A.\nProof.\nAdmitted.\n\nLemma mem_conjg A x y : (y \\in A :^ x) = (y ^ x^-1 \\in A).\nProof.\nAdmitted.\n\nLemma mem_conjgV A x y : (y \\in A :^ x^-1) = (y ^ x \\in A).\nProof.\nAdmitted.\n\nLemma memJ_conjg A x y : (y ^ x \\in A :^ x) = (y \\in A).\nProof.\nAdmitted.\n\nLemma conjsgE A x : A :^ x = x^-1 *: (A :* x).\nProof.\nAdmitted.\n\nLemma conjsg1 A : A :^ 1 = A.\nProof.\nAdmitted.\n\nLemma conjsgM A x y : A :^ (x * y) = (A :^ x) :^ y.\nProof.\nAdmitted.\n\nLemma conjsgK : @right_loop _ gT inv conjugate.\nProof.\nAdmitted.\n\nLemma conjsgKV : @rev_right_loop _ gT inv conjugate.\nProof.\nAdmitted.\n\nLemma conjsg_inj : @left_injective _ gT _ conjugate.\nProof.\nAdmitted.\n\nLemma cardJg A x : #|A :^ x| = #|A|.\nProof.\nAdmitted.\n\nLemma conjSg A B x : (A :^ x \\subset B :^ x) = (A \\subset B).\nProof.\nAdmitted.\n\nLemma properJ A B x : (A :^ x \\proper B :^ x) = (A \\proper B).\nProof.\nAdmitted.\n\nLemma sub_conjg A B x : (A :^ x \\subset B) = (A \\subset B :^ x^-1).\nProof.\nAdmitted.\n\nLemma sub_conjgV A B x : (A :^ x^-1 \\subset B) = (A \\subset B :^ x).\nProof.\nAdmitted.\n\nLemma conjg_set1 x y : [set x] :^ y = [set x ^ y].\nProof.\nAdmitted.\n\nLemma conjs1g x : 1 :^ x = 1.\nProof.\nAdmitted.\n\nLemma conjsg_eq1 A x : (A :^ x == 1%g) = (A == 1%g).\nProof.\nAdmitted.\n\nLemma conjsMg A B x : (A * B) :^ x = A :^ x * B :^ x.\nProof.\nAdmitted.\n\nLemma conjIg A B x : (A :&: B) :^ x = A :^ x :&: B :^ x.\nProof.\nAdmitted.\n\nLemma conj0g x : set0 :^ x = set0.\nProof.\nAdmitted.\n\nLemma conjTg x : [set: gT] :^ x = [set: gT].\nProof.\nAdmitted.\n\nLemma bigcapJ I r (P : pred I) (B : I -> {set gT}) x :\n \\bigcap_(i <- r | P i) (B i :^ x) = (\\bigcap_(i <- r | P i) B i) :^ x.\nProof.\nAdmitted.\n\nLemma conjUg A B x : (A :|: B) :^ x = A :^ x :|: B :^ x.\nProof.\nAdmitted.\n\nLemma bigcupJ I r (P : pred I) (B : I -> {set gT}) x :\n \\bigcup_(i <- r | P i) (B i :^ x) = (\\bigcup_(i <- r | P i) B i) :^ x.\nProof.\nAdmitted.\n\nLemma conjCg A x : (~: A) :^ x = ~: A :^ x.\nProof.\nAdmitted.\n\nLemma conjDg A B x : (A :\\: B) :^ x = A :^ x :\\: B :^ x.\nProof.\nAdmitted.\n\nLemma conjD1g A x : A^# :^ x = (A :^ x)^#.\nProof.\nAdmitted.\n\nLemma memJ_class x y A : y \\in A -> x ^ y \\in x ^: A.\nProof.\nAdmitted.\n\nLemma classS x A B : A \\subset B -> x ^: A \\subset x ^: B.\nProof.\nAdmitted.\n\nLemma class_set1 x y : x ^: [set y] = [set x ^ y].\nProof.\nAdmitted.\n\nLemma class1g x A : x \\in A -> 1 ^: A = 1.\nProof.\nAdmitted.\n\nLemma classVg x A : x^-1 ^: A = (x ^: A)^-1.\nProof.\nAdmitted.\n\nLemma mem_classes x A : x \\in A -> x ^: A \\in classes A.\nProof.\nAdmitted.\n\nLemma memJ_class_support A B x y :\n x \\in A -> y \\in B -> x ^ y \\in class_support A B.\nProof.\nAdmitted.\n\nLemma class_supportM A B C :\n class_support A (B * C) = class_support (class_support A B) C.\nProof.\nAdmitted.\n\nLemma class_support_set1l A x : class_support [set x] A = x ^: A.\nProof.\nAdmitted.\n\nLemma class_support_set1r A x : class_support A [set x] = A :^ x.\nProof.\nAdmitted.\n\nLemma classM x A B : x ^: (A * B) = class_support (x ^: A) B.\nProof.\nAdmitted.\n\nLemma class_lcoset x y A : x ^: (y *: A) = (x ^ y) ^: A.\nProof.\nAdmitted.\n\nLemma class_rcoset x A y : x ^: (A :* y) = (x ^: A) :^ y.\nProof.\nAdmitted.\n\nLemma conjugatesS A B C : B \\subset C -> A :^: B \\subset A :^: C.\nProof.\nAdmitted.\n\nLemma conjugates_set1 A x : A :^: [set x] = [set A :^ x].\nProof.\nAdmitted.\n\nLemma conjugates_conj A x B : (A :^ x) :^: B = A :^: (x *: B).\nProof.\nAdmitted.\n\nLemma class_supportEl A B : class_support A B = \\bigcup_(x in A) x ^: B.\nProof.\nAdmitted.\n\nLemma class_supportEr A B : class_support A B = \\bigcup_(x in B) A :^ x.\nProof.\nAdmitted.\n\nDefinition group_set A := (1 \\in A) && (A * A \\subset A).\n\nLemma group_setP A :\n reflect (1 \\in A /\\ {in A & A, forall x y, x * y \\in A}) (group_set A).\nProof.\nAdmitted.\n\nStructure group_type : Type := Group {\n gval :> GroupSet.sort gT;\n _ : group_set gval\n}.\n\nDefinition group_of : predArgType := group_type.\nLocal Notation groupT := group_of.\nIdentity Coercion type_of_group : group_of >-> group_type.\n\nHB.instance Definition _ := [isSub for gval].\n#[hnf] HB.instance Definition _ := [Finite of group_type by <:].\n\nHB.instance Definition _ := SubFinite.copy groupT group_type.\n\nDefinition group (A : {set gT}) gA : groupT := @Group A gA.\n\nDefinition clone_group G :=\n let: Group _ gP := G return {type of Group for G} -> groupT in fun k => k gP.\n\nLemma group_inj : injective gval.\nProof.\nAdmitted.\nLemma groupP (G : groupT) : group_set G.\nProof.\nAdmitted.\n\nLemma congr_group (H K : groupT) : H = K -> H :=: K.\nProof.\nAdmitted.\n\nLemma isgroupP A : reflect (exists G : groupT, A = G) (group_set A).\nProof.\nAdmitted.\n\nLemma group_set_one : group_set 1.\nProof.\nAdmitted.\n\nCanonical one_group := group group_set_one.\nCanonical set1_group := @group [set 1] group_set_one.\n\nLemma group_setT : group_set (setTfor gT).\nProof.\nAdmitted.\n\nCanonical setT_group := group group_setT.\n\nEnd GroupSetMulProp.\n\nArguments group_of gT%_type.\nArguments lcosetP {gT A x y}.\nArguments lcosetsP {gT A B C}.\nArguments rcosetP {gT A x y}.\nArguments rcosetsP {gT A B C}.\nArguments group_setP {gT A}.\nArguments setT_group gT%_type.\nPrenex Implicits group_set mulsgP set1gP.\n\nNotation \"{ 'group' gT }\" := (group_of gT)\n (format \"{ 'group' gT }\") : type_scope.\n\nNotation \"[ 'group' 'of' G ]\" := (clone_group (@group _ G))\n (format \"[ 'group' 'of' G ]\") : form_scope.\n\nBind Scope Group_scope with group_type.\nBind Scope Group_scope with group_of.\nNotation \"1\" := (one_group _) : Group_scope.\nNotation \"[ 1 gT ]\" := (1%G : {group gT}) : Group_scope.\nNotation \"[ 'set' : gT ]\" := (setT_group gT) : Group_scope.\n\nHB.lock\nDefinition generated (gT : finGroupType) (A : {set gT}) :=\n \\bigcap_(G : {group gT} | A \\subset G) G.\nCanonical generated_unlockable := Unlockable generated.unlock.\n\nDefinition gcore (gT : finGroupType) (A B : {set gT}) := \\bigcap_(x in B) A :^ x.\nDefinition joing (gT : finGroupType) (A B : {set gT}) := generated (A :|: B).\nDefinition commutator (gT : finGroupType) (A B : {set gT}) := generated (commg_set A B).\nDefinition cycle (gT : finGroupType) (x : gT) := generated [set x].\nDefinition order (gT : finGroupType) (x : gT) := #|cycle x|.\n\nArguments commutator _ _%_g _%_g.\nArguments joing _ _%_g _%_g.\nArguments generated _ _%_g.\n\nNotation gsort gT := (FinStarMonoid.arg_sort gT%type) (only parsing).\nNotation \"<< A >>\" := (generated A) : group_scope.\nNotation \"<[ x ] >\" := (cycle x) : group_scope.\nNotation \"#[ x ]\" := (order x) : group_scope.\nNotation \"A <*> B\" := (joing A B) : group_scope.\nNotation \"[ ~: A1 , A2 , .. , An ]\" :=\n (commutator .. (commutator A1 A2) .. An) : group_scope.\n\nPrenex Implicits order cycle gcore.\n\nSection GroupProp.\n\nVariable gT : finGroupType.\nNotation sT := {set gT}.\nImplicit Types A B C D : sT.\nImplicit Types x y z : gT.\nImplicit Types G H K : {group gT}.\n\nSection OneGroup.\n\nVariable G : {group gT}.\n\nLemma valG : val G = G.\nProof.\nAdmitted.\n\nLemma group1 : 1 \\in G.\nProof.\nAdmitted.\n#[local] Hint Resolve group1 : core.\n\nLemma group1_contra x : x \\notin G -> x != 1.\nProof.\nAdmitted.\n\nLemma sub1G : [1 gT] \\subset G.\nProof.\nAdmitted.\nLemma subG1 : (G \\subset [1]) = (G :==: 1).\nProof.\nAdmitted.\n\nLemma setI1g : 1 :&: G = 1.\nProof.\nAdmitted.\nLemma setIg1 : G :&: 1 = 1.\nProof.\nAdmitted.\n\nLemma subG1_contra H : G \\subset H -> G :!=: 1 -> H :!=: 1.\nProof.\nAdmitted.\n\nLemma repr_group : repr G = 1.\nProof.\nAdmitted.\n\nLemma cardG_gt0 : 0 < #|G|.\nProof.\nAdmitted.\n\nLemma indexg_gt0 A : 0 < #|G : A|.\nProof.\nAdmitted.\n\nLemma trivgP : reflect (G :=: 1) (G \\subset [1]).\nProof.\nAdmitted.\n\nLemma trivGP : reflect (G = 1%G) (G \\subset [1]).\nProof.\nAdmitted.\n\nLemma proper1G : ([1] \\proper G) = (G :!=: 1).\nProof.\nAdmitted.\n\nLemma in_one_group x : (x \\in 1%G) = (x == 1).\nProof.\nAdmitted.\n\nDefinition inE := (in_one_group, inE).\n\nLemma trivgPn : reflect (exists2 x, x \\in G & x != 1) (G :!=: 1).\nProof.\nAdmitted.\n\nLemma trivg_card_le1 : (G :==: 1) = (#|G| <= 1).\nProof.\nAdmitted.\n\nLemma trivg_card1 : (G :==: 1) = (#|G| == 1%N).\nProof.\nAdmitted.\n\nLemma cardG_gt1 : (#|G| > 1) = (G :!=: 1).\nProof.\nAdmitted.\n\nLemma card_le1_trivg : #|G| <= 1 -> G :=: 1.\nProof.\nAdmitted.\n\nLemma card1_trivg : #|G| = 1%N -> G :=: 1.\nProof.\nAdmitted.\n\nLemma mulG_subl A : A \\subset A * G.\nProof.\nAdmitted.\n\nLemma mulG_subr A : A \\subset (G * A).\nProof.\nAdmitted.\n\nLemma mulGid : G * G = G.\nProof.\nAdmitted.\n\nLemma mulGS A B : (G * A \\subset G * B) = (A \\subset G * B).\nProof.\nAdmitted.\n\nLemma mulSG A B : (A * G \\subset B * G) = (A \\subset B * G).\nProof.\nAdmitted.\n\nLemma mul_subG A B : A \\subset G -> B \\subset G -> A * B \\subset G.\nProof.\nAdmitted.\n\nLemma prod_subG (I : Type) (r : seq I) (P : {pred I}) (F : I -> {set gT}) :\n (forall i, P i -> F i \\subset G) -> \\prod_(i <- r | P i) F i \\subset G.\nProof.\nAdmitted.\n\nLemma groupM x y : x \\in G -> y \\in G -> x * y \\in G.\nProof.\nAdmitted.\n\nLemma groupX x n : x \\in G -> x ^+ n \\in G.\nProof.\nAdmitted.\n\nLemma groupVr x : x \\in G -> x^-1 \\in G.\nProof.\nAdmitted.\n\nLemma groupVl x : x^-1 \\in G -> x \\in G.\nProof.\nAdmitted.\n\nLemma groupV x : (x^-1 \\in G) = (x \\in G).\nProof.\nAdmitted.\n\nLemma groupMl x y : x \\in G -> (x * y \\in G) = (y \\in G).\nProof.\nAdmitted.\n\nLemma groupMr x y : x \\in G -> (y * x \\in G) = (y \\in G).\nProof.\nAdmitted.\n\nDefinition in_group := (group1, groupV, (groupMl, groupX)).\n\nLemma groupJ x y : x \\in G -> y \\in G -> x ^ y \\in G.\nProof.\nAdmitted.\n\nLemma groupJr x y : y \\in G -> (x ^ y \\in G) = (x \\in G).\nProof.\nAdmitted.\n\nLemma groupR x y : x \\in G -> y \\in G -> [~ x, y] \\in G.\nProof.\nAdmitted.\n\nLemma group_prod I r (P : pred I) F :\n (forall i, P i -> F i \\in G) -> \\prod_(i <- r | P i) F i \\in G.\nProof.\nAdmitted.\n\nLemma invGid : G^-1 = G.\nProof.\nAdmitted.\n\nLemma inv_subG A : (A^-1 \\subset G) = (A \\subset G).\nProof.\nAdmitted.\n\nLemma invg_lcoset x : (x *: G)^-1 = G :* x^-1.\nProof.\nAdmitted.\n\nLemma invg_rcoset x : (G :* x)^-1 = x^-1 *: G.\nProof.\nAdmitted.\n\nLemma memV_lcosetV x y : (y^-1 \\in x^-1 *: G) = (y \\in G :* x).\nProof.\nAdmitted.\n\nLemma memV_rcosetV x y : (y^-1 \\in G :* x^-1) = (y \\in x *: G).\nProof.\nAdmitted.\n\nLemma mulSgGid A x : x \\in A -> A \\subset G -> A * G = G.\nProof.\nAdmitted.\n\nLemma mulGSgid A x : x \\in A -> A \\subset G -> G * A = G.\nProof.\nAdmitted.\n\nLemma lcoset_refl x : x \\in x *: G.\nProof.\nAdmitted.\n\nLemma lcoset_sym x y : (x \\in y *: G) = (y \\in x *: G).\nProof.\nAdmitted.\n\nLemma lcoset_eqP {x y} : reflect (x *: G = y *: G) (x \\in y *: G).\nProof.\nAdmitted.\n\nLemma lcoset_transl x y z : x \\in y *: G -> (x \\in z *: G) = (y \\in z *: G).\nProof.\nAdmitted.\n\nLemma lcoset_trans x y z : x \\in y *: G -> y \\in z *: G -> x \\in z *: G.\nProof.\nAdmitted.\n\nLemma lcoset_id x : x \\in G -> x *: G = G.\nProof.\nAdmitted.\n\nLemma rcoset_refl x : x \\in G :* x.\nProof.\nAdmitted.\n\nLemma rcoset_sym x y : (x \\in G :* y) = (y \\in G :* x).\nProof.\nAdmitted.\n\nLemma rcoset_eqP {x y} : reflect (G :* x = G :* y) (x \\in G :* y).\nProof.\nAdmitted.\n\nLemma rcoset_transl x y z : x \\in G :* y -> (x \\in G :* z) = (y \\in G :* z).\nProof.\nAdmitted.\n\nLemma rcoset_trans x y z : x \\in G :* y -> y \\in G :* z -> x \\in G :* z.\nProof.\nAdmitted.\n\nLemma rcoset_id x : x \\in G -> G :* x = G.\nProof.\nAdmitted.\n\nVariant rcoset_repr_spec x : gT -> Type :=\n RcosetReprSpec g : g \\in G -> rcoset_repr_spec x (g * x).\n\nLemma mem_repr_rcoset x : repr (G :* x) \\in G :* x.\nProof.\nAdmitted.\n\nLemma repr_rcosetP x : rcoset_repr_spec x (repr (G :* x)).\nProof.\nAdmitted.\n\nLemma rcoset_repr x : G :* (repr (G :* x)) = G :* x.\nProof.\nAdmitted.\n\nLemma mem_rcosets A x : (G :* x \\in rcosets G A) = (x \\in G * A).\nProof.\nAdmitted.\n\nLemma mem_lcosets A x : (x *: G \\in lcosets G A) = (x \\in A * G).\nProof.\nAdmitted.\n\nLemma group_setJ A x : group_set (A :^ x) = group_set A.\nProof.\nAdmitted.\n\nLemma group_set_conjG x : group_set (G :^ x).\nProof.\nAdmitted.\n\nCanonical conjG_group x := group (group_set_conjG x).\n\nLemma conjGid : {in G, normalised G}.\nProof.\nAdmitted.\n\nLemma conj_subG x A : x \\in G -> A \\subset G -> A :^ x \\subset G.\nProof.\nAdmitted.\n\nLemma class1G : 1 ^: G = 1.\nProof.\nAdmitted.\n\nLemma classes1 : [1] \\in classes G.\nProof.\nAdmitted.\n\nLemma classGidl x y : y \\in G -> (x ^ y) ^: G = x ^: G.\nProof.\nAdmitted.\n\nLemma classGidr x : {in G, normalised (x ^: G)}.\nProof.\nAdmitted.\n\nLemma class_refl x : x \\in x ^: G.\nProof.\nAdmitted.\n#[local] Hint Resolve class_refl : core.\n\nLemma class_eqP x y : reflect (x ^: G = y ^: G) (x \\in y ^: G).\nProof.\nAdmitted.\n\nLemma class_sym x y : (x \\in y ^: G) = (y \\in x ^: G).\nProof.\nAdmitted.\n\nLemma class_transl x y z : x \\in y ^: G -> (x \\in z ^: G) = (y \\in z ^: G).\nProof.\nAdmitted.\n\nLemma class_trans x y z : x \\in y ^: G -> y \\in z ^: G -> x \\in z ^: G.\nProof.\nAdmitted.\n\nLemma repr_class x : {y | y \\in G & repr (x ^: G) = x ^ y}.\nProof.\nAdmitted.\n\nLemma classG_eq1 x : (x ^: G == 1) = (x == 1).\nProof.\nAdmitted.\n\nLemma class_subG x A : x \\in G -> A \\subset G -> x ^: A \\subset G.\nProof.\nAdmitted.\n\nLemma repr_classesP xG :\n reflect (repr xG \\in G /\\ xG = repr xG ^: G) (xG \\in classes G).\nProof.\nAdmitted.\n\nLemma mem_repr_classes xG : xG \\in classes G -> repr xG \\in xG.\nProof.\nAdmitted.\n\nLemma classes_gt0 : 0 < #|classes G|.\nProof.\nAdmitted.\n\nLemma classes_gt1 : (#|classes G| > 1) = (G :!=: 1).\nProof.\nAdmitted.\n\nLemma mem_class_support A x : x \\in A -> x \\in class_support A G.\nProof.\nAdmitted.\n\nLemma class_supportGidl A x :\n x \\in G -> class_support (A :^ x) G = class_support A G.\nProof.\nAdmitted.\n\nLemma class_supportGidr A : {in G, normalised (class_support A G)}.\nProof.\nAdmitted.\n\nLemma class_support_subG A : A \\subset G -> class_support A G \\subset G.\nProof.\nAdmitted.\n\nLemma sub_class_support A : A \\subset class_support A G.\nProof.\nAdmitted.\n\nLemma class_support_id : class_support G G = G.\nProof.\nAdmitted.\n\nLemma class_supportD1 A : (class_support A G)^# = cover (A^# :^: G).\nProof.\nAdmitted.\n\nInductive subg_of : predArgType := Subg x & x \\in G.\nDefinition sgval u := let: Subg x _ := u in x.\nDefinition subg_of_Sub := Eval hnf in [isSub for sgval].\nHB.instance Definition _ := subg_of_Sub.\n#[hnf] HB.instance Definition _ := [Finite of subg_of by <:].\n\nLemma subgP u : sgval u \\in G.\nProof.\nAdmitted.\nLemma subg_inj : injective sgval.\nProof.\nAdmitted.\nLemma congr_subg u v : u = v -> sgval u = sgval v.\nProof.\nAdmitted.\n\nDefinition subg_one := Subg group1.\nDefinition subg_inv u := Subg (groupVr (subgP u)).\nDefinition subg_mul u v := Subg (groupM (subgP u) (subgP v)).\nLemma subg_oneP : left_id subg_one subg_mul.\nProof.\nAdmitted.\n\nLemma subg_invP : left_inverse subg_one subg_inv subg_mul.\nProof.\nAdmitted.\nLemma subg_mulP : associative subg_mul.\nProof.\nAdmitted.\n\nHB.instance Definition _ := Finite_isGroup.Build subg_of\n subg_mulP subg_oneP subg_invP.\n\nLemma sgvalM : {in setT &, {morph sgval : x y / x * y}}.\nProof.\nAdmitted.\nLemma valgM : {in setT &, {morph val : x y / (x : subg_of) * y >-> x * y}}.\nProof.\nAdmitted.\n\nDefinition subg : gT -> subg_of := insubd (1 : subg_of).\nLemma subgK x : x \\in G -> val (subg x) = x.\nProof.\nAdmitted.\nLemma sgvalK : cancel sgval subg.\nProof.\nAdmitted.\nLemma subg_default x : (x \\in G) = false -> val (subg x) = 1.\nProof.\nAdmitted.\nLemma subgM : {in G &, {morph subg : x y / x * y}}.\nProof.\nAdmitted.\n\nEnd OneGroup.\n\n#[local] Hint Resolve group1 : core.\n\nLemma groupD1_inj G H : G^# = H^# -> G :=: H.\nProof.\nAdmitted.\n\nLemma invMG G H : (G * H)^-1 = H * G.\nProof.\nAdmitted.\n\nLemma mulSGid G H : H \\subset G -> H * G = G.\nProof.\nAdmitted.\n\nLemma mulGSid G H : H \\subset G -> G * H = G.\nProof.\nAdmitted.\n\nLemma mulGidPl G H : reflect (G * H = G) (H \\subset G).\nProof.\nAdmitted.\n\nLemma mulGidPr G H : reflect (G * H = H) (G \\subset H).\nProof.\nAdmitted.\n\nLemma comm_group_setP G H : reflect (commute G H) (group_set (G * H)).\nProof.\nAdmitted.\n\nLemma card_lcosets G H : #|lcosets H G| = #|G : H|.\nProof.\nAdmitted.\n\nLemma group_modl A B G : A \\subset G -> A * (B :&: G) = A * B :&: G.\nProof.\nAdmitted.\n\nLemma group_modr A B G : B \\subset G -> (G :&: A) * B = G :&: A * B.\nProof.\nAdmitted.\n\nEnd GroupProp.\n\n#[global] Hint Extern 0 (is_true (1%g \\in _)) => apply: group1 : core.\n#[global] Hint Extern 0 (is_true (0 < #|_|)) => apply: cardG_gt0 : core.\n#[global] Hint Extern 0 (is_true (0 < #|_ : _|)) => apply: indexg_gt0 : core.\n\nNotation \"G :^ x\" := (conjG_group G x) : Group_scope.\n\nNotation \"[ 'subg' G ]\" := (subg_of G) : type_scope.\nNotation \"[ 'subg' G ]\" := [set: subg_of G] : group_scope.\nNotation \"[ 'subg' G ]\" := [set: subg_of G]%G : Group_scope.\n\nPrenex Implicits subg sgval subg_of.\nBind Scope group_scope with subg_of.\nArguments subgK {gT G}.\nArguments sgvalK {gT G}.\nArguments subg_inj {gT G} [u1 u2] eq_u12 : rename.\n\nArguments trivgP {gT G}.\nArguments trivGP {gT G}.\nArguments lcoset_eqP {gT G x y}.\nArguments rcoset_eqP {gT G x y}.\nArguments mulGidPl {gT G H}.\nArguments mulGidPr {gT G H}.\nArguments comm_group_setP {gT G H}.\nArguments class_eqP {gT G x y}.\nArguments repr_classesP {gT G xG}.\n\nSection GroupInter.\n\nVariable gT : finGroupType.\nImplicit Types A B : {set gT}.\nImplicit Types G H : {group gT}.\n\nLemma group_setI G H : group_set (G :&: H).\nProof.\nAdmitted.\n\nCanonical setI_group G H := group (group_setI G H).\n\nSection Nary.\n\nVariables (I : finType) (P : pred I) (F : I -> {group gT}).\n\nLemma group_set_bigcap : group_set (\\bigcap_(i | P i) F i).\nProof.\nAdmitted.\n\nCanonical bigcap_group := group group_set_bigcap.\n\nEnd Nary.\n\nLemma group_set_generated (A : {set gT}) : group_set <>.\nProof.\nAdmitted.\n\nCanonical generated_group A := group (group_set_generated A).\nCanonical gcore_group G A : {group _} := Eval hnf in [group of gcore G A].\nCanonical commutator_group A B : {group _} := Eval hnf in [group of [~: A, B]].\nCanonical joing_group A B : {group _} := Eval hnf in [group of A <*> B].\nCanonical cycle_group x : {group _} := Eval hnf in [group of <[x]>].\n\nDefinition joinG G H := joing_group G H.\n\nDefinition subgroups A := [set G : {group gT} | G \\subset A].\n\nLemma order_gt0 (x : gT) : 0 < #[x].\nProof.\nAdmitted.\n\nEnd GroupInter.\n\n#[global] Hint Resolve order_gt0 : core.\n\nArguments generated_group _ _%_g.\nArguments joing_group _ _%_g _%_g.\nArguments subgroups _ _%_g.\n\nNotation \"G :&: H\" := (setI_group G H) : Group_scope.\nNotation \"<< A >>\" := (generated_group A) : Group_scope.\nNotation \"<[ x ] >\" := (cycle_group x) : Group_scope.\nNotation \"[ ~: A1 , A2 , .. , An ]\" :=\n (commutator_group .. (commutator_group A1 A2) .. An) : Group_scope.\nNotation \"A <*> B\" := (joing_group A B) : Group_scope.\nNotation \"G * H\" := (joinG G H) : Group_scope.\nPrenex Implicits joinG subgroups.\n\nNotation \"\\prod_ ( i <- r | P ) F\" :=\n (\\big[joinG/1%G]_(i <- r | P%B) F%G) : Group_scope.\nNotation \"\\prod_ ( i <- r ) F\" :=\n (\\big[joinG/1%G]_(i <- r) F%G) : Group_scope.\nNotation \"\\prod_ ( m <= i < n | P ) F\" :=\n (\\big[joinG/1%G]_(m <= i < n | P%B) F%G) : Group_scope.\nNotation \"\\prod_ ( m <= i < n ) F\" :=\n (\\big[joinG/1%G]_(m <= i < n) F%G) : Group_scope.\nNotation \"\\prod_ ( i | P ) F\" :=\n (\\big[joinG/1%G]_(i | P%B) F%G) : Group_scope.\nNotation \"\\prod_ i F\" :=\n (\\big[joinG/1%G]_i F%G) : Group_scope.\nNotation \"\\prod_ ( i : t | P ) F\" :=\n (\\big[joinG/1%G]_(i : t | P%B) F%G) (only parsing) : Group_scope.\nNotation \"\\prod_ ( i : t ) F\" :=\n (\\big[joinG/1%G]_(i : t) F%G) (only parsing) : Group_scope.\nNotation \"\\prod_ ( i < n | P ) F\" :=\n (\\big[joinG/1%G]_(i < n | P%B) F%G) : Group_scope.\nNotation \"\\prod_ ( i < n ) F\" :=\n (\\big[joinG/1%G]_(i < n) F%G) : Group_scope.\nNotation \"\\prod_ ( i 'in' A | P ) F\" :=\n (\\big[joinG/1%G]_(i in A | P%B) F%G) : Group_scope.\nNotation \"\\prod_ ( i 'in' A ) F\" :=\n (\\big[joinG/1%G]_(i in A) F%G) : Group_scope.\n\nSection Lagrange.\n\nVariable gT : finGroupType.\nImplicit Types G H K : {group gT}.\n\nLemma LagrangeI G H : (#|G :&: H| * #|G : H|)%N = #|G|.\nProof.\nAdmitted.\n\nLemma divgI G H : #|G| %/ #|G :&: H| = #|G : H|.\nProof.\nAdmitted.\n\nLemma divg_index G H : #|G| %/ #|G : H| = #|G :&: H|.\nProof.\nAdmitted.\n\nLemma dvdn_indexg G H : #|G : H| %| #|G|.\nProof.\nAdmitted.\n\nTheorem Lagrange G H : H \\subset G -> (#|H| * #|G : H|)%N = #|G|.\nProof.\nAdmitted.\n\nLemma cardSg G H : H \\subset G -> #|H| %| #|G|.\nProof.\nAdmitted.\n\nLemma lognSg p G H : G \\subset H -> logn p #|G| <= logn p #|H|.\nProof.\nAdmitted.\n\nLemma piSg G H : G \\subset H -> {subset \\pi(gval G) <= \\pi(gval H)}.\nProof.\nAdmitted.\n\nLemma divgS G H : H \\subset G -> #|G| %/ #|H| = #|G : H|.\nProof.\nAdmitted.\n\nLemma divg_indexS G H : H \\subset G -> #|G| %/ #|G : H| = #|H|.\nProof.\nAdmitted.\n\nLemma coprimeSg G H p : H \\subset G -> coprime #|G| p -> coprime #|H| p.\nProof.\nAdmitted.\n\nLemma coprimegS G H p : H \\subset G -> coprime p #|G| -> coprime p #|H|.\nProof.\nAdmitted.\n\nLemma indexJg G H x : #|G :^ x : H :^ x| = #|G : H|.\nProof.\nAdmitted.\n\nLemma indexgg G : #|G : G| = 1%N.\nProof.\nAdmitted.\n\nLemma rcosets_id G : rcosets G G = [set G : {set gT}].\nProof.\nAdmitted.\n\nLemma Lagrange_index G H K :\n H \\subset G -> K \\subset H -> (#|G : H| * #|H : K|)%N = #|G : K|.\nProof.\nAdmitted.\n\nLemma indexgI G H : #|G : G :&: H| = #|G : H|.\nProof.\nAdmitted.\n\nLemma indexgS G H K : H \\subset K -> #|G : K| %| #|G : H|.\nProof.\nAdmitted.\n\nLemma indexSg G H K : H \\subset K -> K \\subset G -> #|K : H| %| #|G : H|.\nProof.\nAdmitted.\n\nLemma indexg_eq1 G H : (#|G : H| == 1%N) = (G \\subset H).\nProof.\nAdmitted.\n\nLemma indexg_gt1 G H : (#|G : H| > 1) = ~~ (G \\subset H).\nProof.\nAdmitted.\n\nLemma index1g G H : H \\subset G -> #|G : H| = 1%N -> H :=: G.\nProof.\nAdmitted.\n\nLemma indexg1 G : #|G : 1| = #|G|.\nProof.\nAdmitted.\n\nLemma indexMg G A : #|G * A : G| = #|A : G|.\nProof.\nAdmitted.\n\nLemma rcosets_partition_mul G H : partition (rcosets H G) (H * G).\nProof.\nAdmitted.\n\nLemma rcosets_partition G H : H \\subset G -> partition (rcosets H G) G.\nProof.\nAdmitted.\n\nLemma LagrangeMl G H : (#|G| * #|H : G|)%N = #|G * H|.\nProof.\nAdmitted.\n\nLemma LagrangeMr G H : (#|G : H| * #|H|)%N = #|G * H|.\nProof.\nAdmitted.\n\nLemma mul_cardG G H : (#|G| * #|H| = #|G * H|%g * #|G :&: H|)%N.\nProof.\nAdmitted.\n\nLemma dvdn_cardMg G H : #|G * H| %| #|G| * #|H|.\nProof.\nAdmitted.\n\nLemma cardMg_divn G H : #|G * H| = (#|G| * #|H|) %/ #|G :&: H|.\nProof.\nAdmitted.\n\nLemma cardIg_divn G H : #|G :&: H| = (#|G| * #|H|) %/ #|G * H|.\nProof.\nAdmitted.\n\nLemma TI_cardMg G H : G :&: H = 1 -> #|G * H| = (#|G| * #|H|)%N.\nProof.\nAdmitted.\n\nLemma cardMg_TI G H : #|G| * #|H| <= #|G * H| -> G :&: H = 1.\nProof.\nAdmitted.\n\nLemma coprime_TIg G H : coprime #|G| #|H| -> G :&: H = 1.\nProof.\nAdmitted.\n\nLemma prime_TIg G H : prime #|G| -> ~~ (G \\subset H) -> G :&: H = 1.\nProof.\nAdmitted.\n\nLemma prime_meetG G H : prime #|G| -> G :&: H != 1 -> G \\subset H.\nProof.\nAdmitted.\n\nLemma coprime_cardMg G H : coprime #|G| #|H| -> #|G * H| = (#|G| * #|H|)%N.\nProof.\nAdmitted.\n\nLemma coprime_index_mulG G H K :\n H \\subset G -> K \\subset G -> coprime #|G : H| #|G : K| -> H * K = G.\nProof.\nAdmitted.\n\nEnd Lagrange.\n\nSection GeneratedGroup.\n\nVariable gT : finGroupType.\nImplicit Types x y z : gT.\nImplicit Types A B C D : {set gT}.\nImplicit Types G H K : {group gT}.\n\nLemma subset_gen A : A \\subset <>.\nProof.\nAdmitted.\n\nLemma sub_gen A B : A \\subset B -> A \\subset <>.\nProof.\nAdmitted.\n\nLemma mem_gen x A : x \\in A -> x \\in <>.\nProof.\nAdmitted.\n\nLemma generatedP x A : reflect (forall G, A \\subset G -> x \\in G) (x \\in <>).\nProof.\nAdmitted.\n\nLemma gen_subG A G : (<> \\subset G) = (A \\subset G).\nProof.\nAdmitted.\n\nLemma genGid G : <> = G.\nProof.\nAdmitted.\n\nLemma genGidG G : <>%G = G.\nProof.\nAdmitted.\n\nLemma gen_set_id A : group_set A -> <> = A.\nProof.\nAdmitted.\n\nLemma genS A B : A \\subset B -> <> \\subset <>.\nProof.\nAdmitted.\n\nLemma gen0 : <> = 1 :> {set gT}.\nProof.\nAdmitted.\n\nLemma gen_expgs A : {n | <> = (1 |: A) ^+ n}.\nProof.\nAdmitted.\n\nLemma gen_prodgP A x :\n reflect (exists n, exists2 c, forall i : 'I_n, c i \\in A & x = \\prod_i c i)\n (x \\in <>).\nProof.\nAdmitted.\n\nLemma genD A B : A \\subset <> -> <> = <>.\nProof.\nAdmitted.\n\nLemma genV A : <> = <>.\nProof.\nAdmitted.\n\nLemma genJ A z : <> = <> :^ z.\nProof.\nAdmitted.\n\nLemma conjYg A B z : (A <*> B) :^z = A :^ z <*> B :^ z.\nProof.\nAdmitted.\n\nLemma genD1 A x : x \\in <> -> <> = <>.\nProof.\nAdmitted.\n\nLemma genD1id A : <> = <>.\nProof.\nAdmitted.\n\nNotation joingT := (@joing gT) (only parsing).\nNotation joinGT := (@joinG gT) (only parsing).\n\nLemma joingE A B : A <*> B = <>.\nProof.\nAdmitted.\n\nLemma joinGE G H : (G * H)%G = (G <*> H)%G.\nProof.\nAdmitted.\n\nLemma joingC : commutative joingT.\nProof.\nAdmitted.\n\nLemma joing_idr A B : A <*> <> = A <*> B.\nProof.\nAdmitted.\n\nLemma joing_idl A B : <> <*> B = A <*> B.\nProof.\nAdmitted.\n\nLemma joing_subl A B : A \\subset A <*> B.\nProof.\nAdmitted.\n\nLemma joing_subr A B : B \\subset A <*> B.\nProof.\nAdmitted.\n\nLemma join_subG A B G : (A <*> B \\subset G) = (A \\subset G) && (B \\subset G).\nProof.\nAdmitted.\n\nLemma joing_idPl G A : reflect (G <*> A = G) (A \\subset G).\nProof.\nAdmitted.\n\nLemma joing_idPr A G : reflect (A <*> G = G) (A \\subset G).\nProof.\nAdmitted.\n\nLemma joing_subP A B G :\n reflect (A \\subset G /\\ B \\subset G) (A <*> B \\subset G).\nProof.\nAdmitted.\n\nLemma joing_sub A B C : A <*> B = C -> A \\subset C /\\ B \\subset C.\nProof.\nAdmitted.\n\nLemma genDU A B C : A \\subset C -> <> = <> -> <> = <>.\nProof.\nAdmitted.\n\nLemma joingA : associative joingT.\nProof.\nAdmitted.\n\nLemma joing1G G : 1 <*> G = G.\nProof.\nAdmitted.\n\nLemma joingG1 G : G <*> 1 = G.\nProof.\nAdmitted.\n\nLemma genM_join G H : <> = G <*> H.\nProof.\nAdmitted.\n\nLemma mulG_subG G H K : (G * H \\subset K) = (G \\subset K) && (H \\subset K).\nProof.\nAdmitted.\n\nLemma mulGsubP K H G : reflect (K \\subset G /\\ H \\subset G) (K * H \\subset G).\nProof.\nAdmitted.\n\nLemma mulG_sub K H A : K * H = A -> K \\subset A /\\ H \\subset A.\nProof.\nAdmitted.\n\nLemma trivMg G H : (G * H == 1) = (G :==: 1) && (H :==: 1).\nProof.\nAdmitted.\n\nLemma comm_joingE G H : commute G H -> G <*> H = G * H.\nProof.\nAdmitted.\n\nLemma joinGC : commutative joinGT.\nProof.\nAdmitted.\n\nLemma joinGA : associative joinGT.\nProof.\nAdmitted.\n\nLemma join1G : left_id 1%G joinGT.\nProof.\nAdmitted.\n\nLemma joinG1 : right_id 1%G joinGT.\nProof.\nAdmitted.\n\nHB.instance Definition _ := Monoid.isComLaw.Build {group gT} 1%G joinGT\n joinGA joinGC join1G.\n\nLemma bigprodGEgen I r (P : pred I) (F : I -> {set gT}) :\n (\\prod_(i <- r | P i) <>)%G :=: << \\bigcup_(i <- r | P i) F i >>.\nProof.\nAdmitted.\n\nLemma bigprodGE I r (P : pred I) (F : I -> {group gT}) :\n (\\prod_(i <- r | P i) F i)%G :=: << \\bigcup_(i <- r | P i) F i >>.\nProof.\nAdmitted.\n\nLemma mem_commg A B x y : x \\in A -> y \\in B -> [~ x, y] \\in [~: A, B].\nProof.\nAdmitted.\n\nLemma commSg A B C : A \\subset B -> [~: A, C] \\subset [~: B, C].\nProof.\nAdmitted.\n\nLemma commgS A B C : B \\subset C -> [~: A, B] \\subset [~: A, C].\nProof.\nAdmitted.\n\nLemma commgSS A B C D :\n A \\subset B -> C \\subset D -> [~: A, C] \\subset [~: B, D].\nProof.\nAdmitted.\n\nLemma der1_subG G : [~: G, G] \\subset G.\nProof.\nAdmitted.\n\nLemma comm_subG A B G : A \\subset G -> B \\subset G -> [~: A, B] \\subset G.\nProof.\nAdmitted.\n\nLemma commGC A B : [~: A, B] = [~: B, A].\nProof.\nAdmitted.\n\nLemma conjsRg A B x : [~: A, B] :^ x = [~: A :^ x, B :^ x].\nProof.\nAdmitted.\n\nEnd GeneratedGroup.\n\nArguments gen_prodgP {gT A x}.\nArguments joing_idPl {gT G A}.\nArguments joing_idPr {gT A G}.\nArguments mulGsubP {gT K H G}.\nArguments joing_subP {gT A B G}.\n\nSection Cycles.\n\nVariable gT : finGroupType.\nImplicit Types x y : gT.\nImplicit Types G : {group gT}.\n\nImport Monoid.Theory.\n\nLemma cycle1 : <[1]> = [1 gT].\nProof.\nAdmitted.\n\nLemma order1 : #[1 : gT] = 1%N.\nProof.\nAdmitted.\n\nLemma cycle_id x : x \\in <[x]>.\nProof.\nAdmitted.\n\nLemma mem_cycle x i : x ^+ i \\in <[x]>.\nProof.\nAdmitted.\n\nLemma cycle_subG x G : (<[x]> \\subset G) = (x \\in G).\nProof.\nAdmitted.\n\nLemma cycle_eq1 x : (<[x]> == 1) = (x == 1).\nProof.\nAdmitted.\n\nLemma orderE x : #[x] = #|<[x]>|.\nProof.\nAdmitted.\n\nLemma order_eq1 x : (#[x] == 1%N) = (x == 1).\nProof.\nAdmitted.\n\nLemma order_gt1 x : (#[x] > 1) = (x != 1).\nProof.\nAdmitted.\n\nLemma cycle_traject x : <[x]> =i traject (mul x) 1 #[x].\nProof.\nAdmitted.\n\nLemma cycle2g x : #[x] = 2 -> <[x]> = [set 1; x].\nProof.\nAdmitted.\n\nLemma cyclePmin x y : y \\in <[x]> -> {i | i < #[x] & y = x ^+ i}.\nProof.\nAdmitted.\n\nLemma cycleP x y : reflect (exists i, y = x ^+ i) (y \\in <[x]>).\nProof.\nAdmitted.\n\nLemma expg_order x : x ^+ #[x] = 1.\nProof.\nAdmitted.\n\nLemma expg_mod p k x : x ^+ p = 1 -> x ^+ (k %% p) = x ^+ k.\nProof.\nAdmitted.\n\nLemma expg_mod_order x i : x ^+ (i %% #[x]) = x ^+ i.\nProof.\nAdmitted.\n\nLemma invg_expg x : x^-1 = x ^+ #[x].\nProof.\nAdmitted.\n\nLemma invg2id x : #[x] = 2 -> x^-1 = x.\nProof.\nAdmitted.\n\nLemma cycleX x i : <[x ^+ i]> \\subset <[x]>.\nProof.\nAdmitted.\n\nLemma cycleV x : <[x^-1]> = <[x]>.\nProof.\nAdmitted.\n\nLemma orderV x : #[x^-1] = #[x].\nProof.\nAdmitted.\n\nLemma cycleJ x y : <[x ^ y]> = <[x]> :^ y.\nProof.\nAdmitted.\n\nLemma orderJ x y : #[x ^ y] = #[x].\nProof.\nAdmitted.\n\nEnd Cycles.\n\nSection Normaliser.\n\nVariable gT : finGroupType.\nImplicit Types x y z : gT.\nImplicit Types A B C D : {set gT}.\nImplicit Type G H K : {group gT}.\n\nLemma normP x A : reflect (A :^ x = A) (x \\in 'N(A)).\nProof.\nAdmitted.\nArguments normP {x A}.\n\nLemma group_set_normaliser A : group_set 'N(A).\nProof.\nAdmitted.\n\nCanonical normaliser_group A := group (group_set_normaliser A).\n\nLemma normsP A B : reflect {in A, normalised B} (A \\subset 'N(B)).\nProof.\nAdmitted.\nArguments normsP {A B}.\n\nLemma memJ_norm x y A : x \\in 'N(A) -> (y ^ x \\in A) = (y \\in A).\nProof.\nAdmitted.\n\nLemma norms_cycle x y : (<[y]> \\subset 'N(<[x]>)) = (x ^ y \\in <[x]>).\nProof.\nAdmitted.\n\nLemma norm1 : 'N(1) = setT :> {set gT}.\nProof.\nAdmitted.\n\nLemma norms1 A : A \\subset 'N(1).\nProof.\nAdmitted.\n\nLemma normCs A : 'N(~: A) = 'N(A).\nProof.\nAdmitted.\n\nLemma normG G : G \\subset 'N(G).\nProof.\nAdmitted.\n\nLemma normT : 'N([set: gT]) = [set: gT].\nProof.\nAdmitted.\n\nLemma normsG A G : A \\subset G -> A \\subset 'N(G).\nProof.\nAdmitted.\n\nLemma normC A B : A \\subset 'N(B) -> commute A B.\nProof.\nAdmitted.\n\nLemma norm_joinEl G H : G \\subset 'N(H) -> G <*> H = G * H.\nProof.\nAdmitted.\n\nLemma norm_joinEr G H : H \\subset 'N(G) -> G <*> H = G * H.\nProof.\nAdmitted.\n\nLemma norm_rlcoset G x : x \\in 'N(G) -> G :* x = x *: G.\nProof.\nAdmitted.\n\nLemma rcoset_mul G x y : x \\in 'N(G) -> (G :* x) * (G :* y) = G :* (x * y).\nProof.\nAdmitted.\n\nLemma normJ A x : 'N(A :^ x) = 'N(A) :^ x.\nProof.\nAdmitted.\n\nLemma norm_conj_norm x A B :\n x \\in 'N(A) -> (A \\subset 'N(B :^ x)) = (A \\subset 'N(B)).\nProof.\nAdmitted.\n\nLemma norm_gen A : 'N(A) \\subset 'N(<>).\nProof.\nAdmitted.\n\nLemma class_norm x G : G \\subset 'N(x ^: G).\nProof.\nAdmitted.\n\nLemma class_normal x G : x \\in G -> x ^: G <| G.\nProof.\nAdmitted.\n\nLemma class_sub_norm G A x : G \\subset 'N(A) -> (x ^: G \\subset A) = (x \\in A).\nProof.\nAdmitted.\n\nLemma class_support_norm A G : G \\subset 'N(class_support A G).\nProof.\nAdmitted.\n\nLemma class_support_sub_norm A B G :\n A \\subset G -> B \\subset 'N(G) -> class_support A B \\subset G.\nProof.\nAdmitted.\n\nSection norm_trans.\n\nVariables (A B C D : {set gT}).\nHypotheses (nBA : A \\subset 'N(B)) (nCA : A \\subset 'N(C)).\n\nLemma norms_gen : A \\subset 'N(<>).\nProof.\nAdmitted.\n\nLemma norms_norm : A \\subset 'N('N(B)).\nProof.\nAdmitted.\n\nLemma normsI : A \\subset 'N(B :&: C).\nProof.\nAdmitted.\n\nLemma normsU : A \\subset 'N(B :|: C).\nProof.\nAdmitted.\n\nLemma normsIs : B \\subset 'N(D) -> A :&: B \\subset 'N(C :&: D).\nProof.\nAdmitted.\n\nLemma normsD : A \\subset 'N(B :\\: C).\nProof.\nAdmitted.\n\nLemma normsM : A \\subset 'N(B * C).\nProof.\nAdmitted.\n\nLemma normsY : A \\subset 'N(B <*> C).\nProof.\nAdmitted.\n\nLemma normsR : A \\subset 'N([~: B, C]).\nProof.\nAdmitted.\n\nLemma norms_class_support : A \\subset 'N(class_support B C).\nProof.\nAdmitted.\n\nEnd norm_trans.\n\nLemma normsIG A B G : A \\subset 'N(B) -> A :&: G \\subset 'N(B :&: G).\nProof.\nAdmitted.\n\nLemma normsGI A B G : A \\subset 'N(B) -> G :&: A \\subset 'N(G :&: B).\nProof.\nAdmitted.\n\nLemma norms_bigcap I r (P : pred I) A (B_ : I -> {set gT}) :\n A \\subset \\bigcap_(i <- r | P i) 'N(B_ i) ->\n A \\subset 'N(\\bigcap_(i <- r | P i) B_ i).\nProof.\nAdmitted.\n\nLemma norms_bigcup I r (P : pred I) A (B_ : I -> {set gT}) :\n A \\subset \\bigcap_(i <- r | P i) 'N(B_ i) ->\n A \\subset 'N(\\bigcup_(i <- r | P i) B_ i).\nProof.\nAdmitted.\n\nLemma normsD1 A B : A \\subset 'N(B) -> A \\subset 'N(B^#).\nProof.\nAdmitted.\n\nLemma normD1 A : 'N(A^#) = 'N(A).\nProof.\nAdmitted.\n\nLemma normalP A B : reflect (A \\subset B /\\ {in B, normalised A}) (A <| B).\nProof.\nAdmitted.\n\nLemma normal_sub A B : A <| B -> A \\subset B.\nProof.\nAdmitted.\n\nLemma normal_norm A B : A <| B -> B \\subset 'N(A).\nProof.\nAdmitted.\n\nLemma normalS G H K : K \\subset H -> H \\subset G -> K <| G -> K <| H.\nProof.\nAdmitted.\n\nLemma normal1 G : 1 <| G.\nProof.\nAdmitted.\n\nLemma normal_refl G : G <| G.\nProof.\nAdmitted.\n\nLemma normalG G : G <| 'N(G).\nProof.\nAdmitted.\n\nLemma normalSG G H : H \\subset G -> H <| 'N_G(H).\nProof.\nAdmitted.\n\nLemma normalJ A B x : (A :^ x <| B :^ x) = (A <| B).\nProof.\nAdmitted.\n\nLemma normalM G A B : A <| G -> B <| G -> A * B <| G.\nProof.\nAdmitted.\n\nLemma normalY G A B : A <| G -> B <| G -> A <*> B <| G.\nProof.\nAdmitted.\n\nLemma normalYl G H : (H <| H <*> G) = (G \\subset 'N(H)).\nProof.\nAdmitted.\n\nLemma normalYr G H : (H <| G <*> H) = (G \\subset 'N(H)).\nProof.\nAdmitted.\n\nLemma normalI G A B : A <| G -> B <| G -> A :&: B <| G.\nProof.\nAdmitted.\n\nLemma norm_normalI G A : G \\subset 'N(A) -> G :&: A <| G.\nProof.\nAdmitted.\n\nLemma normalGI G H A : H \\subset G -> A <| G -> H :&: A <| H.\nProof.\nAdmitted.\n\nLemma normal_subnorm G H : (H <| 'N_G(H)) = (H \\subset G).\nProof.\nAdmitted.\n\nLemma normalD1 A G : (A^# <| G) = (A <| G).\nProof.\nAdmitted.\n\nLemma gcore_sub A G : gcore A G \\subset A.\nProof.\nAdmitted.\n\nLemma gcore_norm A G : G \\subset 'N(gcore A G).\nProof.\nAdmitted.\n\nLemma gcore_normal A G : A \\subset G -> gcore A G <| G.\nProof.\nAdmitted.\n\nLemma gcore_max A B G : B \\subset A -> G \\subset 'N(B) -> B \\subset gcore A G.\nProof.\nAdmitted.\n\nLemma sub_gcore A B G :\n G \\subset 'N(B) -> (B \\subset gcore A G) = (B \\subset A).\nProof.\nAdmitted.\n\nLemma rcoset_index2 G H x :\n H \\subset G -> #|G : H| = 2 -> x \\in G :\\: H -> H :* x = G :\\: H.\nProof.\nAdmitted.\n\nLemma index2_normal G H : H \\subset G -> #|G : H| = 2 -> H <| G.\nProof.\nAdmitted.\n\nLemma cent1P x y : reflect (commute x y) (x \\in 'C[y]).\nProof.\nAdmitted.\n\nLemma cent1id x : x \\in 'C[x].\nProof.\nAdmitted.\n\nLemma cent1E x y : (x \\in 'C[y]) = (x * y == y * x).\nProof.\nAdmitted.\n\nLemma cent1C x y : (x \\in 'C[y]) = (y \\in 'C[x]).\nProof.\nAdmitted.\n\nCanonical centraliser_group A : {group _} := Eval hnf in [group of 'C(A)].\n\nLemma cent_set1 x : 'C([set x]) = 'C[x].\nProof.\nAdmitted.\n\nLemma cent1J x y : 'C[x ^ y] = 'C[x] :^ y.\nProof.\nAdmitted.\n\nLemma centP A x : reflect (centralises x A) (x \\in 'C(A)).\nProof.\nAdmitted.\n\nLemma centsP A B : reflect {in A, centralised B} (A \\subset 'C(B)).\nProof.\nAdmitted.\n\nLemma centsC A B : (A \\subset 'C(B)) = (B \\subset 'C(A)).\nProof.\nAdmitted.\n\nLemma cents1 A : A \\subset 'C(1).\nProof.\nAdmitted.\n\nLemma cent1T : 'C(1) = setT :> {set gT}.\nProof.\nAdmitted.\n\nLemma cent11T : 'C[1] = setT :> {set gT}.\nProof.\nAdmitted.\n\nLemma cent_sub A : 'C(A) \\subset 'N(A).\nProof.\nAdmitted.\n\nLemma cents_norm A B : A \\subset 'C(B) -> A \\subset 'N(B).\nProof.\nAdmitted.\n\nLemma centC A B : A \\subset 'C(B) -> commute A B.\nProof.\nAdmitted.\n\nLemma cent_joinEl G H : G \\subset 'C(H) -> G <*> H = G * H.\nProof.\nAdmitted.\n\nLemma cent_joinEr G H : H \\subset 'C(G) -> G <*> H = G * H.\nProof.\nAdmitted.\n\nLemma centJ A x : 'C(A :^ x) = 'C(A) :^ x.\nProof.\nAdmitted.\n\nLemma cent_norm A : 'N(A) \\subset 'N('C(A)).\nProof.\nAdmitted.\n\nLemma norms_cent A B : A \\subset 'N(B) -> A \\subset 'N('C(B)).\nProof.\nAdmitted.\n\nLemma cent_normal A : 'C(A) <| 'N(A).\nProof.\nAdmitted.\n\nLemma centS A B : B \\subset A -> 'C(A) \\subset 'C(B).\nProof.\nAdmitted.\n\nLemma centsS A B C : A \\subset B -> C \\subset 'C(B) -> C \\subset 'C(A).\nProof.\nAdmitted.\n\nLemma centSS A B C D :\n A \\subset C -> B \\subset D -> C \\subset 'C(D) -> A \\subset 'C(B).\nProof.\nAdmitted.\n\nLemma centI A B : 'C(A) <*> 'C(B) \\subset 'C(A :&: B).\nProof.\nAdmitted.\n\nLemma centU A B : 'C(A :|: B) = 'C(A) :&: 'C(B).\nProof.\nAdmitted.\n\nLemma cent_gen A : 'C(<>) = 'C(A).\nProof.\nAdmitted.\n\nLemma cent_cycle x : 'C(<[x]>) = 'C[x].\nProof.\nAdmitted.\n\nLemma sub_cent1 A x : (A \\subset 'C[x]) = (x \\in 'C(A)).\nProof.\nAdmitted.\n\nLemma cents_cycle x y : commute x y -> <[x]> \\subset 'C(<[y]>).\nProof.\nAdmitted.\n\nLemma cycle_abelian x : abelian <[x]>.\nProof.\nAdmitted.\n\nLemma centY A B : 'C(A <*> B) = 'C(A) :&: 'C(B).\nProof.\nAdmitted.\n\nLemma centM G H : 'C(G * H) = 'C(G) :&: 'C(H).\nProof.\nAdmitted.\n\nLemma cent_classP x G : reflect (x ^: G = [set x]) (x \\in 'C(G)).\nProof.\nAdmitted.\n\nLemma commG1P A B : reflect ([~: A, B] = 1) (A \\subset 'C(B)).\nProof.\nAdmitted.\n\nLemma abelianE A : abelian A = (A \\subset 'C(A)).\nProof.\nAdmitted.\n\nLemma abelian1 : abelian [1 gT].\nProof.\nAdmitted.\n\nLemma abelianS A B : A \\subset B -> abelian B -> abelian A.\nProof.\nAdmitted.\n\nLemma abelianJ A x : abelian (A :^ x) = abelian A.\nProof.\nAdmitted.\n\nLemma abelian_gen A : abelian <> = abelian A.\nProof.\nAdmitted.\n\nLemma abelianY A B :\n abelian (A <*> B) = [&& abelian A, abelian B & B \\subset 'C(A)].\nProof.\nAdmitted.\n\nLemma abelianM G H :\n abelian (G * H) = [&& abelian G, abelian H & H \\subset 'C(G)].\nProof.\nAdmitted.\n\nSection SubAbelian.\n\nVariable A B C : {set gT}.\nHypothesis cAA : abelian A.\n\nLemma sub_abelian_cent : C \\subset A -> A \\subset 'C(C).\nProof.\nAdmitted.\n\nLemma sub_abelian_cent2 : B \\subset A -> C \\subset A -> B \\subset 'C(C).\nProof.\nAdmitted.\n\nLemma sub_abelian_norm : C \\subset A -> A \\subset 'N(C).\nProof.\nAdmitted.\n\nLemma sub_abelian_normal : (C \\subset A) = (C <| A).\nProof.\nAdmitted.\n\nEnd SubAbelian.\n\nEnd Normaliser.\n\nArguments normP {gT x A}.\nArguments centP {gT A x}.\nArguments normsP {gT A B}.\nArguments cent1P {gT x y}.\nArguments normalP {gT A B}.\nArguments centsP {gT A B}.\nArguments commG1P {gT A B}.\n\nArguments normaliser_group _ _%_g.\nArguments centraliser_group _ _%_g.\n\nNotation \"''N' ( A )\" := (normaliser_group A) : Group_scope.\nNotation \"''C' ( A )\" := (centraliser_group A) : Group_scope.\nNotation \"''C' [ x ]\" := (normaliser_group [set x%g]) : Group_scope.\nNotation \"''N_' G ( A )\" := (setI_group G 'N(A)) : Group_scope.\nNotation \"''C_' G ( A )\" := (setI_group G 'C(A)) : Group_scope.\nNotation \"''C_' ( G ) ( A )\" := (setI_group G 'C(A))\n (only parsing) : Group_scope.\nNotation \"''C_' G [ x ]\" := (setI_group G 'C[x]) : Group_scope.\nNotation \"''C_' ( G ) [ x ]\" := (setI_group G 'C[x])\n (only parsing) : Group_scope.\n\n#[global] Hint Extern 0 (is_true (_ \\subset _)) => apply: normG : core.\n#[global] Hint Extern 0 (is_true (_ <| _)) => apply: normal_refl : core.\n\nSection MinMaxGroup.\n\nVariable gT : finGroupType.\nImplicit Types gP : pred {group gT}.\n\nDefinition maxgroup A gP := maxset (fun A => group_set A && gP <>%G) A.\nDefinition mingroup A gP := minset (fun A => group_set A && gP <>%G) A.\n\nVariable gP : pred {group gT}.\nArguments gP _%_G.\n\nLemma ex_maxgroup : (exists G, gP G) -> {G : {group gT} | maxgroup G gP}.\nProof.\nAdmitted.\n\nLemma ex_mingroup : (exists G, gP G) -> {G : {group gT} | mingroup G gP}.\nProof.\nAdmitted.\n\nVariable G : {group gT}.\n\nLemma mingroupP :\n reflect (gP G /\\ forall H, gP H -> H \\subset G -> H :=: G) (mingroup G gP).\nProof.\nAdmitted.\n\nLemma maxgroupP :\n reflect (gP G /\\ forall H, gP H -> G \\subset H -> H :=: G) (maxgroup G gP).\nProof.\nAdmitted.\n\nLemma maxgroupp : maxgroup G gP -> gP G.\nProof.\nAdmitted.\n\nLemma mingroupp : mingroup G gP -> gP G.\nProof.\nAdmitted.\n\nHypothesis gPG : gP G.\n\nLemma maxgroup_exists : {H : {group gT} | maxgroup H gP & G \\subset H}.\nProof.\nAdmitted.\n\nLemma mingroup_exists : {H : {group gT} | mingroup H gP & H \\subset G}.\nProof.\nAdmitted.\n\nEnd MinMaxGroup.\n\nArguments mingroup {gT} A%_g gP.\nArguments maxgroup {gT} A%_g gP.\nArguments mingroupP {gT gP G}.\nArguments maxgroupP {gT gP G}.\n\nNotation \"[ 'max' A 'of' G | gP ]\" :=\n (maxgroup A (fun G : {group _} => gP)) : group_scope.\nNotation \"[ 'max' G | gP ]\" := [max gval G of G | gP] : group_scope.\nNotation \"[ 'max' A 'of' G | gP & gQ ]\" :=\n [max A of G | gP && gQ] : group_scope.\nNotation \"[ 'max' G | gP & gQ ]\" := [max G | gP && gQ] : group_scope.\nNotation \"[ 'min' A 'of' G | gP ]\" :=\n (mingroup A (fun G : {group _} => gP)) : group_scope.\nNotation \"[ 'min' G | gP ]\" := [min gval G of G | gP] : group_scope.\nNotation \"[ 'min' A 'of' G | gP & gQ ]\" :=\n [min A of G | gP && gQ] : group_scope.\nNotation \"[ 'min' G | gP & gQ ]\" := [min G | gP && gQ] : group_scope.\n\nHB.reexport." }, { "theorem_id": 57, "title": "072_sylow_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/frag.ml\";; \nneeds \"Library/card.ml\";; \nneeds \"Library/prime.ml\";; \n\nlet group_tybij =\n let eth = `?s (z:A) n a.\n z IN s /\\\n (!x. x IN s ==> n x IN s) /\\\n (!x y. x IN s /\\ y IN s ==> a x y IN s) /\\\n (!x y z. x IN s /\\ y IN s /\\ z IN s\n ==> a x (a y z) = a (a x y) z) /\\\n (!x. x IN s ==> a z x = x /\\ a x z = x) /\\\n (!x. x IN s ==> a (n x) x = z /\\ a x (n x) = z)`;;\n\nlet group_carrier = new_definition\n `(group_carrier:(A)group->A->bool) = \\g. FST(group_operations g)`;;\n\nlet group_id = new_definition\n `(group_id:(A)group->A) = \\g. FST(SND(group_operations g))`;;\n\nlet group_inv = new_definition\n `(group_inv:(A)group->A->A) = \\g. FST(SND(SND(group_operations g)))`;;\n\nlet group_mul = new_definition\n `(group_mul:(A)group->A->A->A) = \\g. SND(SND(SND(group_operations g)))`;;\n\nlet ([GROUP_ID; GROUP_INV; GROUP_MUL; GROUP_MUL_ASSOC;\n GROUP_MUL_LID; GROUP_MUL_RID; GROUP_MUL_LINV; GROUP_MUL_RINV] as\n GROUP_PROPERTIES) = (CONJUNCTS o prove)\n (`(!G:A group. group_id G IN group_carrier G) /\\\n (!G x:A. x IN group_carrier G ==> group_inv G x IN group_carrier G) /\\\n (!G x y:A. x IN group_carrier G /\\ y IN group_carrier G\n ==> group_mul G x y IN group_carrier G) /\\\n (!G x y z:A. x IN group_carrier G /\\\n y IN group_carrier G /\\\n z IN group_carrier G\n ==> group_mul G x (group_mul G y z) =\n group_mul G (group_mul G x y) z) /\\\n (!G x:A. x IN group_carrier G ==> group_mul G (group_id G) x = x) /\\\n (!G x:A. x IN group_carrier G ==> group_mul G x (group_id G) = x) /\\\n (!G x:A. x IN group_carrier G\n ==> group_mul G (group_inv G x) x = group_id G) /\\\n (!G x:A. x IN group_carrier G\n ==> group_mul G x(group_inv G x) = group_id G)`,\n REWRITE_TAC[AND_FORALL_THM] THEN GEN_TAC THEN\n MP_TAC(SPEC `G:A group` (MATCH_MP(MESON[]\n `(!a. mk(dest a) = a) /\\ (!r. P r <=> dest(mk r) = r)\n ==> !a. P(dest a)`) group_tybij)) THEN\n REWRITE_TAC[group_carrier; group_id; group_inv; group_mul] THEN\n SIMP_TAC[]);;\n\nlet GROUPS_EQ = `!G H:A group.\n G = H <=>\n group_carrier G = group_carrier H /\\\n group_id G = group_id H /\\\n group_inv G = group_inv H /\\\n group_mul G = group_mul H`;;\n\nlet GROUP_CARRIER_NONEMPTY = `!G:A group. ~(group_carrier G = {})`;;\n\nlet singleton_group = new_definition\n `singleton_group (a:A) = group({a},a,(\\x. a),(\\x y. a))`;;\n\nlet SINGLETON_GROUP = `(!a:A. group_carrier(singleton_group a) = {a}) /\\\n (!a:A. group_id(singleton_group a) = a) /\\\n (!a:A. group_inv(singleton_group a) = \\x. a) /\\\n (!a:A. group_mul(singleton_group a) = \\x y. a)`;;\n\nlet trivial_group = new_definition\n `trivial_group G <=> group_carrier G = {group_id G}`;;\n\nlet TRIVIAL_IMP_FINITE_GROUP = `!G:A group. trivial_group G ==> FINITE(group_carrier G)`;;\n\nlet TRIVIAL_GROUP_SINGLETON_GROUP = `!a:A. trivial_group(singleton_group a)`;;\n\nlet FINITE_SINGLETON_GROUP = `!a:A. FINITE(group_carrier(singleton_group a))`;;\n\nlet TRIVIAL_GROUP_SUBSET = `!G:A group. trivial_group G <=> group_carrier G SUBSET {group_id G}`;;\n\nlet TRIVIAL_GROUP = `!G:A group. trivial_group G <=> ?a. group_carrier G = {a}`;;\n\nlet TRIVIAL_GROUP_ALT = `!G:A group. trivial_group G <=> ?a. group_carrier G SUBSET {a}`;;\n\nlet TRIVIAL_GROUP_HAS_SIZE_1 = `!G:A group. trivial_group G <=> group_carrier(G) HAS_SIZE 1`;;\n\nlet GROUP_CARRIER_HAS_SIZE_1 = `!G:A group. group_carrier(G) HAS_SIZE 1 <=> trivial_group G`;;\n\nlet opposite_group = new_definition\n `opposite_group(G:A group) =\n group(group_carrier G,group_id G,group_inv G,\n \\x y. group_mul G y x)`;;\n\nlet OPPOSITE_GROUP = `!G:A group.\n group_carrier(opposite_group G) = group_carrier G /\\\n group_id(opposite_group G) = group_id G /\\\n group_inv(opposite_group G) = group_inv G /\\\n group_mul(opposite_group G) = \\x y. group_mul G y x`;;\n\nlet OPPOSITE_OPPOSITE_GROUP = `!G:A group. opposite_group (opposite_group G) = G`;;\n\nlet OPPOSITE_GROUP_INV = `!G x:A. group_inv(opposite_group G) x = group_inv G x`;;\n\nlet OPPOSITE_GROUP_MUL = `!G x y:A. group_mul(opposite_group G) x y = group_mul G y x`;;\n\nlet OPPOSITE_SINGLETON_GROUP = `!a:A. opposite_group(singleton_group a) = singleton_group a`;;\n\nlet TRIVIAL_OPPOSITE_GROUP = `!G:A group. trivial_group(opposite_group G) <=> trivial_group G`;;\n\nlet FINITE_OPPOSITE_GROUP = `!G:A group. FINITE(group_carrier(opposite_group G)) <=>\n FINITE(group_carrier G)`;;\n\nlet group_div = new_definition\n `group_div G x y = group_mul G x (group_inv G y)`;;\n\nlet GROUP_DIV = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_div G x y) IN group_carrier G`;;\n\nlet GROUP_MUL_LCANCEL = `!G x y z:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\ z IN group_carrier G\n ==> (group_mul G x y = group_mul G x z <=> y = z)`;;\n\nlet GROUP_MUL_LCANCEL_IMP = `!G x y z:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\ z IN group_carrier G /\\\n group_mul G x y = group_mul G x z\n ==> y = z`;;\n\nlet GROUP_MUL_RCANCEL = `!G x y z:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\ z IN group_carrier G\n ==> (group_mul G x z = group_mul G y z <=> x = y)`;;\n\nlet GROUP_MUL_RCANCEL_IMP = `!G x y z:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\ z IN group_carrier G /\\\n group_mul G x z = group_mul G y z\n ==> x = y`;;\n\nlet GROUP_LID_UNIQUE = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\ group_mul G x y = y\n ==> x = group_id G`;;\n\nlet GROUP_RID_UNIQUE = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\ group_mul G x y = x\n ==> y = group_id G`;;\n\nlet GROUP_LID_EQ = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_mul G x y = y <=> x = group_id G)`;;\n\nlet GROUP_RID_EQ = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_mul G x y = x <=> y = group_id G)`;;\n\nlet GROUP_LINV_UNIQUE = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = group_id G\n ==> group_inv G x = y`;;\n\nlet GROUP_RINV_UNIQUE = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = group_id G\n ==> group_inv G y = x`;;\n\nlet GROUP_LINV_EQ = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_inv G x = y <=> group_mul G x y = group_id G)`;;\n\nlet GROUP_RINV_EQ = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_inv G x = y <=> group_mul G y x = group_id G)`;;\n\nlet GROUP_MUL_EQ_ID = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_mul G x y = group_id G <=> group_mul G y x = group_id G)`;;\n\nlet GROUP_INV_INV = `!G x:A. x IN group_carrier G ==> group_inv G (group_inv G x) = x`;;\n\nlet GROUP_INV_ID = `!G:A group. group_inv G (group_id G) = group_id G`;;\n\nlet GROUP_INV_EQ_ID = `!G x:A.\n x IN group_carrier G\n ==> (group_inv G x = group_id G <=> x = group_id G)`;;\n\nlet GROUP_INV_MUL = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> group_inv G (group_mul G x y) =\n group_mul G (group_inv G y) (group_inv G x)`;;\n\nlet GROUP_INV_EQ = `!G x y:A. x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_inv G x = group_inv G y <=> x = y)`;;\n\nlet GROUP_DIV_REFL = `!G x:A. x IN group_carrier G ==> group_div G x x = group_id G`;;\n\nlet GROUP_DIV_EQ_ID = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_div G x y = group_id G <=> x = y)`;;\n\nlet GROUP_COMMUTES_INV = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = group_mul G y x\n ==> group_mul G (group_inv G x) y = group_mul G y (group_inv G x)`;;\n\nlet GROUP_COMMUTES_INV_EQ = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_mul G (group_inv G x) y = group_mul G y (group_inv G x) <=>\n group_mul G x y = group_mul G y x)`;;\n\nlet GROUP_COMMUTES_MUL = `!G x y z:A.\n x IN group_carrier G /\\\n y IN group_carrier G /\\\n z IN group_carrier G /\\\n group_mul G x z = group_mul G z x /\\\n group_mul G y z = group_mul G z y\n ==> group_mul G (group_mul G x y) z = group_mul G z (group_mul G x y)`;;\n\nlet FORALL_IN_GROUP_CARRIER_INV = `!(P:A->bool) G.\n (!x. x IN group_carrier G ==> P(group_inv G x)) <=>\n (!x. x IN group_carrier G ==> P x)`;;\n\nlet EXISTS_IN_GROUP_CARRIER_INV = `!P G:A group.\n (?x. x IN group_carrier G /\\ P(group_inv G x)) <=>\n (?x. x IN group_carrier G /\\ P x)`;;\n\nlet group_pow = new_recursive_definition num_RECURSION\n `group_pow G x 0 = group_id G /\\\n group_pow G x (SUC n) = group_mul G x (group_pow G x n)`;;\n\nlet GROUP_POW = `!G (x:A) n. x IN group_carrier G ==> group_pow G x n IN group_carrier G`;;\n\nlet GROUP_POW_0 = `!G (x:A). group_pow G x 0 = group_id G`;;\n\nlet GROUP_POW_1 = `!G x:A. x IN group_carrier G ==> group_pow G x 1 = x`;;\n\nlet GROUP_POW_2 = `!G x:A. x IN group_carrier G ==> group_pow G x 2 = group_mul G x x`;;\n\nlet GROUP_POW_ID = `!n. group_pow G (group_id G) n = group_id G`;;\n\nlet GROUP_POW_ADD = `!G (x:A) m n.\n x IN group_carrier G\n ==> group_pow G x (m + n) =\n group_mul G (group_pow G x m) (group_pow G x n)`;;\n\nlet GROUP_POW_SUB = `!G (x:A) m n.\n x IN group_carrier G /\\ n <= m\n ==> group_pow G x (m - n) =\n group_div G (group_pow G x m) (group_pow G x n)`;;\n\nlet GROUP_POW_SUB_ALT = `!G (x:A) m n.\n x IN group_carrier G /\\ n <= m\n ==> group_pow G x (m - n) =\n group_mul G (group_inv G (group_pow G x n)) (group_pow G x m)`;;\n\nlet GROUP_INV_POW = `!G (x:A) n.\n x IN group_carrier G\n ==> group_inv G (group_pow G x n) = group_pow G (group_inv G x) n`;;\n\nlet GROUP_POW_MUL = `!G (x:A) m n.\n x IN group_carrier G\n ==> group_pow G x (m * n) = group_pow G (group_pow G x m) n`;;\n\nlet GROUP_POW_POW = `!G (x:A) m n.\n x IN group_carrier G\n ==> group_pow G (group_pow G x m) n = group_pow G x (m * n)`;;\n\nlet GROUP_COMMUTES_POW = `!G (x:A) (y:A) n.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = group_mul G y x\n ==> group_mul G (group_pow G x n) y = group_mul G y (group_pow G x n)`;;\n\nlet GROUP_MUL_POW = `!G (x:A) (y:A) n.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = group_mul G y x\n ==> group_pow G (group_mul G x y) n =\n group_mul G (group_pow G x n) (group_pow G y n)`;;\n\nlet group_zpow = new_definition\n `group_zpow G (x:A) n =\n if &0 <= n then group_pow G x (num_of_int n)\n else group_inv G (group_pow G x (num_of_int(--n)))`;;\n\nlet GROUP_ZPOW = `!G (x:A) n. x IN group_carrier G ==> group_zpow G x n IN group_carrier G`;;\n\nlet GROUP_NPOW = `!G (x:A) n. group_zpow G x (&n) = group_pow G x n`;;\n\nlet GROUP_ZPOW_0 = `!G (x:A). group_zpow G x (&0) = group_id G`;;\n\nlet GROUP_ZPOW_1 = `!G x:A. x IN group_carrier G ==> group_zpow G x (&1) = x`;;\n\nlet GROUP_ZPOW_2 = `!G x:A. x IN group_carrier G ==> group_zpow G x (&2) = group_mul G x x`;;\n\nlet GROUP_ZPOW_ID = `!n. group_zpow G (group_id G) n = group_id G`;;\n\nlet GROUP_ZPOW_NEG = `!G (x:A) n.\n x IN group_carrier G\n ==> group_zpow G x (--n) = group_inv G (group_zpow G x n)`;;\n\nlet GROUP_ZPOW_MINUS1 = `!G x:A. x IN group_carrier G ==> group_zpow G x (-- &1) = group_inv G x`;;\n\nlet GROUP_ZPOW_POW = `(!G (x:A) n. group_zpow G x (&n) = group_pow G x n) /\\\n (!G (x:A) n. group_zpow G x (-- &n) = group_inv G (group_pow G x n))`;;\n\nlet GROUP_ZPOW_ABS_EQ_ID = `!G (x:A) n.\n x IN group_carrier G\n ==> (group_zpow G x (abs n) = group_id G <=>\n group_zpow G x n = group_id G)`;;\n\nlet GROUP_ZPOW_ADD = `!G (x:A) m n.\n x IN group_carrier G\n ==> group_zpow G x (m + n) =\n group_mul G (group_zpow G x m) (group_zpow G x n)`;;\n\nlet GROUP_ZPOW_SUB = `!G (x:A) m n.\n x IN group_carrier G\n ==> group_zpow G x (m - n) =\n group_div G (group_zpow G x m) (group_zpow G x n)`;;\n\nlet GROUP_ZPOW_SUB_ALT = `!G (x:A) m n.\n x IN group_carrier G\n ==> group_zpow G x (m - n) =\n group_mul G (group_inv G (group_zpow G x n)) (group_zpow G x m)`;;\n\nlet GROUP_INV_ZPOW = `!G (x:A) n.\n x IN group_carrier G\n ==> group_inv G (group_zpow G x n) = group_zpow G (group_inv G x) n`;;\n\nlet GROUP_ZPOW_INV = `!G (x:A) n.\n x IN group_carrier G\n ==> group_zpow G (group_inv G x) n = group_zpow G x (--n)`;;\n\nlet GROUP_ZPOW_MUL = `!G (x:A) m n.\n x IN group_carrier G\n ==> group_zpow G x (m * n) = group_zpow G (group_zpow G x m) n`;;\n\nlet GROUP_COMMUTES_ZPOW = `!G (x:A) (y:A) n.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = group_mul G y x\n ==> group_mul G (group_zpow G x n) y = group_mul G y (group_zpow G x n)`;;\n\nlet GROUP_MUL_ZPOW = `!G (x:A) (y:A) n.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = group_mul G y x\n ==> group_zpow G (group_mul G x y) n =\n group_mul G (group_zpow G x n) (group_zpow G y n)`;;\n\nlet abelian_group = new_definition\n `abelian_group (G:A group) <=>\n !x y. x IN group_carrier G /\\ y IN group_carrier G\n ==> group_mul G x y = group_mul G y x`;;\n\nlet TRIVIAL_IMP_ABELIAN_GROUP = `!G:A group. trivial_group G ==> abelian_group G`;;\n\nlet ABELIAN_SINGLETON_GROUP = `!a:A. abelian_group(singleton_group a)`;;\n\nlet ABELIAN_OPPOSITE_GROUP = `!G:A group. abelian_group (opposite_group G) <=> abelian_group G`;;\n\nlet ABELIAN_GROUP_MUL_POW = `!G (x:A) (y:A) n.\n abelian_group G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> group_pow G (group_mul G x y) n =\n group_mul G (group_pow G x n) (group_pow G y n)`;;\n\nlet ABELIAN_GROUP_MUL_ZPOW = `!G (x:A) (y:A) n.\n abelian_group G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> group_zpow G (group_mul G x y) n =\n group_mul G (group_zpow G x n) (group_zpow G y n)`;;\n\nlet ABELIAN_GROUP_DIV_ZPOW = `!G x (y:A) n.\n abelian_group G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> group_zpow G (group_div G x y) n =\n group_div G (group_zpow G x n) (group_zpow G y n)`;;\n\nlet ABELIAN_GROUP_MUL_AC = `!G:A group.\n abelian_group G <=>\n (!x y. x IN group_carrier G /\\ y IN group_carrier G\n ==> group_mul G x y = group_mul G y x) /\\\n (!x y z. x IN group_carrier G /\\ y IN group_carrier G /\\\n z IN group_carrier G\n ==> group_mul G (group_mul G x y) z =\n group_mul G x (group_mul G y z)) /\\\n (!x y z. x IN group_carrier G /\\ y IN group_carrier G /\\\n z IN group_carrier G\n ==> group_mul G x (group_mul G y z) =\n group_mul G y (group_mul G x z))`;;\n\nlet group_neg = new_definition\n `group_neg G x = if x IN group_carrier G then group_inv G x else x`;;\n\nlet group_add = new_definition\n `group_add G x (y:A) =\n if x IN group_carrier G /\\ y IN group_carrier G\n then group_mul G x y\n else if x IN group_carrier G then y\n else if y IN group_carrier G then x\n else @w. ~(w IN group_carrier G)`;;\n\nlet group_nmul = new_recursive_definition num_RECURSION\n `group_nmul G 0 x = group_id G /\\\n group_nmul G (SUC n) x = group_add G x (group_nmul G n x)`;;\n\nlet GROUP_NEG = `!G x:A. group_neg G x IN group_carrier G <=> x IN group_carrier G`;;\n\nlet GROUP_ADD = `!G x y:A.\n group_add G x y IN group_carrier G <=>\n x IN group_carrier G /\\ y IN group_carrier G`;;\n\nlet GROUP_NEG_EQ_INV = `!G x:A. x IN group_carrier G ==> group_neg G x = group_inv G x`;;\n\nlet GROUP_ADD_EQ_MUL = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> group_add G x y = group_mul G x y`;;\n\nlet GROUP_ADD_LID = `!G x:A. group_add G (group_id G) x = x`;;\n\nlet GROUP_ADD_RID = `!G x:A. group_add G x (group_id G) = x`;;\n\nlet GROUP_ADD_ASSOC = `!G x y z:A.\n group_add G x (group_add G y z) = group_add G (group_add G x y) z`;;\n\nlet GROUP_NEG_ADD = `!G x y:A. group_neg G (group_add G x y) =\n group_add G (group_neg G y) (group_neg G x)`;;\n\nlet GROUP_NEG_NEG = `!G x:A. group_neg G (group_neg G x) = x`;;\n\nlet GROUP_NEG_ID = `!G:A group. group_neg G (group_id G) = group_id G`;;\n\nlet GROUP_ADD_EQ_ID = `!G x y:A. group_add G x y = group_id G <=> group_add G y x = group_id G`;;\n\nlet GROUP_NEG_EQ_ID = `!G x:A. group_neg G x = group_id G <=> x = group_id G`;;\n\nlet GROUP_NMUL_EQ_POW = `!G (x:A) n. x IN group_carrier G ==> group_nmul G n x = group_pow G x n`;;\n\nlet GROUP_NMUL_ADD = `!G (x:A) m n.\n group_nmul G (m + n) x =\n group_add G (group_nmul G m x) (group_nmul G n x)`;;\n\nlet GROUP_NMUL_MUL = `!G (x:A) m n.\n group_nmul G (m * n) x = group_nmul G m (group_nmul G n x)`;;\n\nlet GROUP_NMUL_1 = `!G x:A. group_nmul G 1 x = x`;;\n\nlet GROUP_NEG_NMUL = `!G (x:A) n.\n group_neg G (group_nmul G n x) = group_nmul G n (group_neg G x)`;;\n\nlet GROUP_ADD_SYM = `!G x y:A. abelian_group G ==> group_add G x y = group_add G y x`;;\n\nlet GROUP_ADD_SYM_EQ = `!G:A group. (!x y. group_add G x y = group_add G y x) <=> abelian_group G`;;\n\nlet GROUP_ADD_NMUL = `!G (x:A) y n.\n abelian_group G\n ==> group_nmul G n (group_add G x y) =\n group_add G (group_nmul G n x) (group_nmul G n y)`;;\n\nlet NEUTRAL_GROUP_ADD = `!G:A group. neutral(group_add G) = group_id G`;;\n\nlet MONOIDAL_GROUP_ADD = `!G:A group. monoidal(group_add G) <=> abelian_group G`;;\n\nlet GROUP_RULE =\n let rec GROUP_MEM tm =\n if is_conj tm then CONJ (GROUP_MEM(lhand tm)) (GROUP_MEM(rand tm)) else\n try PART_MATCH I GROUP_ID tm with Failure _ ->\n try let th = try PART_MATCH rand GROUP_INV tm with Failure _ ->\n try PART_MATCH rand GROUP_POW tm with Failure _ ->\n try PART_MATCH rand GROUP_ZPOW tm with Failure _ ->\n try PART_MATCH rand GROUP_MUL tm with Failure _ ->\n PART_MATCH rand GROUP_DIV tm in\n MP th (GROUP_MEM(lhand(concl th)))\n with Failure _ -> ASSUME tm in\n let GROUP_REWR_CONV th =\n if not(is_imp(snd(strip_forall(concl th)))) then REWR_CONV th else\n let mfn = PART_MATCH (lhand o rand) th in\n fun tm -> let ith = mfn tm in MP ith (GROUP_MEM(lhand(concl ith))) in\n let GROUP_CANONIZE_CONV =\n let mfn_inv = (MATCH_MP o prove)\n (`!G t t':A.\n t = t' /\\ t IN group_carrier G\n ==> group_inv G t = group_neg G t' /\\\n group_inv G t IN group_carrier G`,\n SIMP_TAC[IMP_CONJ; group_neg; GROUP_INV])\n and mfn_neg = (MATCH_MP o prove)\n (`!G t t':A.\n t = t' /\\ t IN group_carrier G\n ==> group_neg G t = group_neg G t' /\\\n group_neg G t IN group_carrier G`,\n SIMP_TAC[GROUP_NEG])\n and mfn_pow = (MATCH_MP o prove)\n (`!G t (t':A) n.\n t = t' /\\ t IN group_carrier G\n ==> group_pow G t n = group_nmul G n t' /\\\n group_pow G t n IN group_carrier G`,\n SIMP_TAC[GROUP_NMUL_EQ_POW; IMP_CONJ; GROUP_POW])\n and mfn_nmul = (MATCH_MP o prove)\n (`!G t (t':A) n.\n t = t' /\\ t IN group_carrier G\n ==> group_nmul G n t = group_nmul G n t' /\\\n group_nmul G n t IN group_carrier G`,\n SIMP_TAC[GROUP_NMUL_EQ_POW; GROUP_POW; IMP_CONJ])\n and mfn_mul = (MATCH_MP o prove)\n (`!G s t s' t':A.\n (s = s' /\\ s IN group_carrier G) /\\\n (t = t' /\\ t IN group_carrier G)\n ==> group_mul G s t = group_add G s' t' /\\\n group_mul G s t IN group_carrier G`,\n SIMP_TAC[IMP_CONJ; group_add; GROUP_MUL])\n and mfn_add = (MATCH_MP o prove)\n (`!G s t s' t':A.\n (s = s' /\\ s IN group_carrier G) /\\\n (t = t' /\\ t IN group_carrier G)\n ==> group_add G s t = group_add G s' t' /\\\n group_add G s t IN group_carrier G`,\n SIMP_TAC[GROUP_ADD])\n and in_tm = `(IN):A->(A->bool)->bool`\n and gc_tm = `group_carrier:(A)group->A->bool` in\n let rec GROUP_TOTALIZE g tm =\n match tm with\n Comb(Comb(Comb(Const(\"group_mul\",_),g),s),t) ->\n mfn_mul(CONJ (GROUP_TOTALIZE g s) (GROUP_TOTALIZE g t))\n | Comb(Comb(Comb(Const(\"group_add\",_),g),s),t) ->\n mfn_add(CONJ (GROUP_TOTALIZE g s) (GROUP_TOTALIZE g t))\n | Comb(Comb(Comb(Const(\"group_pow\",_),g),t),n) ->\n SPEC n (mfn_pow(GROUP_TOTALIZE g t))\n | Comb(Comb(Comb(Const(\"group_nmul\",_),g),n),t) ->\n SPEC n (mfn_nmul(GROUP_TOTALIZE g t))\n | Comb(Comb(Const(\"group_inv\",_),g),t) ->\n mfn_inv(GROUP_TOTALIZE g t)\n | Comb(Comb(Const(\"group_neg\",_),g),t) ->\n mfn_neg(GROUP_TOTALIZE g t)\n | Comb(Const(\"group_id\",_),g) ->\n CONJ (REFL tm) (ISPEC g GROUP_ID)\n | _ ->\n let ifn = inst[type_of tm,aty] in\n CONJ (REFL tm)\n (ASSUME(mk_comb(mk_comb(ifn in_tm,tm),mk_comb(ifn gc_tm,g)))) in\n let GROUP_CANONIZE_CONV tm =\n match tm with\n Comb(Comb(Comb(Const(\"group_mul\",_),g),s),t)\n | Comb(Comb(Comb(Const(\"group_add\",_),g),s),t)\n | Comb(Comb(Comb(Const(\"group_pow\",_),g),s),t)\n | Comb(Comb(Comb(Const(\"group_nmul\",_),g),s),t) ->\n CONJUNCT1(GROUP_TOTALIZE g tm)\n | Comb(Comb(Const(\"group_inv\",_),g),t)\n | Comb(Comb(Const(\"group_neg\",_),g),t) ->\n CONJUNCT1(GROUP_TOTALIZE g tm)\n | _ -> REFL tm in\n NUM_REDUCE_CONV THENC INT_REDUCE_CONV THENC\n GEN_REWRITE_CONV TOP_DEPTH_CONV [GROUP_ZPOW_POW; group_div] THENC\n GROUP_CANONIZE_CONV in\n let GROUP_NORM_CONV =\n let conv = (FIRST_CONV o map GROUP_REWR_CONV o CONJUNCTS o prove)\n (`(!G x:A. x IN group_carrier G\n ==> group_add G x (group_neg G x) = group_id G) /\\\n (!G x:A. x IN group_carrier G\n ==> group_add G (group_neg G x) x = group_id G) /\\\n (!G x y:A. x IN group_carrier G\n ==> group_add G x (group_add G (group_neg G x) y) = y) /\\\n (!G x y:A. x IN group_carrier G\n ==> group_add G (group_neg G x) (group_add G x y) = y)`,\n REWRITE_TAC[GROUP_ADD_ASSOC] THEN\n SIMP_TAC[GROUP_NEG_EQ_INV; GROUP_ADD_EQ_MUL; GROUP_MUL_LINV;\n GROUP_MUL_RINV; GROUP_INV; GROUP_ADD_LID]) in\n let rec GROUP_NMUL_CONV tm =\n try REWR_CONV (CONJUNCT1 group_nmul) tm with Failure _ ->\n (LAND_CONV num_CONV THENC\n REWR_CONV(CONJUNCT2 group_nmul) THENC\n RAND_CONV GROUP_NMUL_CONV) tm in\n GROUP_CANONIZE_CONV THENC\n TOP_DEPTH_CONV GROUP_NMUL_CONV THENC\n GEN_REWRITE_CONV TOP_DEPTH_CONV\n [GROUP_NEG_ADD; GROUP_NEG_NEG; GROUP_NEG_ID] THENC\n GEN_REWRITE_CONV DEPTH_CONV [GROUP_ADD_LID; GROUP_ADD_RID] THENC\n GEN_REWRITE_CONV TOP_DEPTH_CONV [GSYM GROUP_ADD_ASSOC] THENC\n TOP_DEPTH_CONV\n (GEN_REWRITE_CONV I [GROUP_ADD_LID; GROUP_ADD_RID] ORELSEC conv) in\n let GROUP_EQ_RULE tm =\n let l,r = dest_eq tm in\n TRANS (GROUP_NORM_CONV l) (SYM(GROUP_NORM_CONV r)) in\n let is_groupty ty = match ty with Tyapp(\"group\",[a]) -> true | _ -> false in\n let rec list_of_gtm tm =\n match tm with\n Comb(Const(\"group_id\",_),_) -> []\n | Comb(Comb(Const(\"group_neg\",_),_),x) -> [false,x]\n | Comb(Comb(Comb(Const(\"group_add\",_),_),\n Comb(Comb(Const(\"group_neg\",_),_),x)),y) -> (false,x)::list_of_gtm y\n | Comb(Comb(Comb(Const(\"group_add\",_),_),x),y) -> (true,x)::list_of_gtm y\n | _ -> [true,tm] in\n let find_rot l l' =\n find (fun n -> let l1,l2 = chop_list n l in l2@l1 = l')\n (0--(length l - 1)) in\n let rec GROUP_REASSOC_CONV n tm =\n if n = 0 then REFL tm\n else (REWR_CONV GROUP_ADD_ASSOC THENC GROUP_REASSOC_CONV(n-1)) tm in\n let GROUP_ROTATE_CONV n =\n if n = 0 then REFL else\n LAND_CONV(GROUP_REASSOC_CONV(n - 1)) THENC\n REWR_CONV GROUP_ADD_EQ_ID THENC\n LAND_CONV GROUP_NORM_CONV in\n let rec GROUP_EQ_HYPERNORM_CONV tm =\n let ts = list_of_gtm(lhand tm) in\n if length ts > 2 &&\n (let p,v = hd ts and q,w = last ts in not(p = q) && v = w)\n then (GROUP_ROTATE_CONV 1 THENC GROUP_EQ_HYPERNORM_CONV) tm\n else REFL tm in\n fun tm ->\n let gvs = setify(find_terms (is_groupty o type_of) tm) in\n if gvs = [] then MESON[] tm else\n if length gvs > 1 then failwith \"GROUP_RULE: Several groups involved\" else\n let g = hd gvs in\n let GROUP_EQ_NORM_CONV =\n GROUP_REWR_CONV(GSYM(ISPEC g GROUP_DIV_EQ_ID)) THENC\n LAND_CONV GROUP_NORM_CONV in\n let avs,bod = strip_forall tm in\n let ant,con = if is_imp bod then [lhand bod],rand bod else [],bod in\n let th1 =\n if not(is_iff con) then GROUP_EQ_RULE con else\n let eq1,eq2 = dest_iff con in\n let th1 = (GROUP_EQ_NORM_CONV THENC GROUP_EQ_HYPERNORM_CONV) eq1\n and th2 = (GROUP_EQ_NORM_CONV THENC GROUP_EQ_HYPERNORM_CONV) eq2 in\n let ls1 = list_of_gtm(lhand(rand(concl th1)))\n and ls2 = list_of_gtm(lhand(rand(concl th2))) in\n try let n = find_rot ls1 ls2 in\n TRANS (CONV_RULE(RAND_CONV(GROUP_ROTATE_CONV n)) th1) (SYM th2)\n with Failure _ ->\n let th1' =\n GEN_REWRITE_RULE (RAND_CONV o TOP_DEPTH_CONV)\n [GSYM GROUP_ADD_ASSOC]\n (GEN_REWRITE_RULE (RAND_CONV o TOP_DEPTH_CONV)\n [GROUP_NEG_ADD; GROUP_NEG_NEG]\n (GEN_REWRITE_RULE RAND_CONV [GSYM GROUP_NEG_EQ_ID] th1))\n and ls1' = map (fun (p,v) -> not p,v) (rev ls1) in\n let n = find_rot ls1' ls2 in\n TRANS (CONV_RULE(RAND_CONV(GROUP_ROTATE_CONV n)) th1') (SYM th2) in\n let th2 =\n if ant = [] then th1\n else itlist PROVE_HYP (CONJUNCTS(ASSUME(hd ant))) th1 in\n let asl = hyp th2 in\n let th3 =\n if asl = [] then th2 else\n let asm = list_mk_conj asl in\n DISCH asm (itlist PROVE_HYP (CONJUNCTS(ASSUME asm)) th2) in\n let th4 = GENL avs th3 in\n let bvs = frees(concl th4) in\n GENL (sort (<) bvs) th4;;\n\nlet GROUP_TAC =\n REPEAT GEN_TAC THEN\n TRY(MATCH_MP_TAC(MESON[] `(u = v <=> s = t) ==> (u = v ==> s = t)`)) THEN\n W(fun (asl,w) ->\n let th = GROUP_RULE w in\n (MATCH_ACCEPT_TAC th ORELSE\n (MATCH_MP_TAC th THEN ASM_REWRITE_TAC[])));;\n\nlet group_product = new_definition\n `group_product (G:A group) =\n iterato (group_carrier G) (group_id G) (group_mul G)`;;\n\nlet group_sum = new_definition\n `group_sum (G:A group) =\n group_product G (@l. woset l /\\ fld l = (:K))`;;\n\nlet GROUP_PRODUCT_EQ = `!G (<<=) k (f:K->A) g.\n (!i. i IN k ==> f i = g i)\n ==> group_product G (<<=) k f = group_product G (<<=) k g`;;\n\nlet GROUP_SUM_EQ = `!G k (f:K->A) g.\n (!i. i IN k ==> f i = g i) ==> group_sum G k f = group_sum G k g`;;\n\nlet th = `(!G (<<=) k f (g:K->A).\n (!i. i IN k ==> f i = g i)\n ==> group_product G (<<=) k (\\i. f i) = group_product G (<<=) k g) /\\\n (!G k f (g:K->A).\n (!i. i IN k ==> f i = g i)\n ==> group_sum G k (\\i. f i) = group_sum G k g)`;;\n\nlet GROUP_PRODUCT_CLOSED = `!P G (<<=) k (f:K->A).\n P(group_id G) /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G /\\\n P x /\\ P y\n ==> P(group_mul G x y)) /\\\n (!i. i IN k /\\ f i IN group_carrier G /\\ ~(f i = group_id G) ==> P(f i))\n ==> P(group_product G (<<=) k f)`;;\n\nlet GROUP_SUM_CLOSED = `!P G k (f:K->A).\n P(group_id G) /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G /\\\n P x /\\ P y\n ==> P(group_mul G x y)) /\\\n (!i. i IN k /\\ f i IN group_carrier G /\\ ~(f i = group_id G) ==> P(f i))\n ==> P(group_sum G k f)`;;\n\nlet GROUP_PRODUCT = `!G (<<=) k (f:K->A). group_product G (<<=) k f IN group_carrier G`;;\n\nlet GROUP_SUM = `!G k (f:K->A). group_sum G k f IN group_carrier G`;;\n\nlet GROUP_PRODUCT_SUPPORT = `!G (<<=) k (f:K->A).\n group_product G (<<=) {i | i IN k /\\ ~(f i = group_id G)} f =\n group_product G (<<=) k f`;;\n\nlet GROUP_SUM_SUPPORT = `!G k (f:K->A).\n group_sum G {i | i IN k /\\ ~(f i = group_id G)} f =\n group_sum G k f`;;\n\nlet GROUP_PRODUCT_RESTRICT = `!G (<<=) k (f:K->A).\n group_product G (<<=) {i | i IN k /\\ f i IN group_carrier G} f =\n group_product G (<<=) k f`;;\n\nlet GROUP_SUM_RESTRICT = `!G k (f:K->A).\n group_sum G {i | i IN k /\\ f i IN group_carrier G} f =\n group_sum G k f`;;\n\nlet GROUP_PRODUCT_EXPAND_CASES = `!G (<<=) k (f:K->A).\n group_product G (<<=) k f =\n if FINITE {i | i IN k /\\ f i IN group_carrier G DIFF {group_id G}}\n then group_product G (<<=)\n {i | i IN k /\\ f i IN group_carrier G DIFF {group_id G}} f\n else group_id G`;;\n\nlet GROUP_SUM_EXPAND_CASES = `!G k (f:K->A).\n group_sum G k f =\n if FINITE {i | i IN k /\\ f i IN group_carrier G DIFF {group_id G}}\n then group_sum G\n {i | i IN k /\\ f i IN group_carrier G DIFF {group_id G}} f\n else group_id G`;;\n\nlet GROUP_PRODUCT_RESTRICT_SET = `!G (<<=) P s (f:K->A).\n group_product G (<<=) {x | x IN s /\\ P x} f =\n group_product G (<<=) s (\\x. if P x then f x else group_id G)`;;\n\nlet GROUP_SUM_RESTRICT_SET = `!G P s (f:K->A).\n group_sum G {x | x IN s /\\ P x} f =\n group_sum G s (\\x. if P x then f x else group_id G)`;;\n\nlet GROUP_PRODUCT_SUPERSET = `!G (<<=) s t (f:K->A).\n t SUBSET s /\\ (!x. x IN s /\\ ~(x IN t) ==> f x = group_id G)\n ==> group_product G (<<=) s f = group_product G (<<=) t f`;;\n\nlet GROUP_SUM_SUPERSET = `!G s t (f:K->A).\n t SUBSET s /\\ (!x. x IN s /\\ ~(x IN t) ==> f x = group_id G)\n ==> group_sum G s f = group_sum G t f`;;\n\nlet GROUP_PRODUCT_CLAUSES = `!G (<<=) (f:K->A).\n group_product G (<<=) {} f = group_id G /\\\n (!i k. FINITE {j | j IN k /\\ f j IN group_carrier G DIFF {group_id G}} /\\\n (!j. j IN k ==> i <<= j /\\ ~(j <<= i))\n ==> group_product G (<<=) (i INSERT k) f =\n if f i IN group_carrier G ==> i IN k\n then group_product G (<<=) k f\n else group_mul G (f i) (group_product G (<<=) k f))`;;\n\nlet GROUP_PRODUCT_CLAUSES_EXISTS = `!G (<<=) (f:K->A).\n group_product G (<<=) {} f = group_id G /\\\n (!k. FINITE {i | i IN k /\\ f i IN group_carrier G DIFF {group_id G}} /\\\n ~({i | i IN k /\\ f i IN group_carrier G DIFF {group_id G}} = {})\n ==> ?i. i IN k /\\\n f i IN group_carrier G DIFF {group_id G} /\\\n group_product G (<<=) k f =\n group_mul G (f i) (group_product G (<<=) (k DELETE i) f))`;;\n\nlet GROUP_SUM_CLAUSES_EXISTS = `!G (f:K->A).\n group_sum G {} f = group_id G /\\\n (!k. FINITE {i | i IN k /\\ f i IN group_carrier G DIFF {group_id G}} /\\\n ~({i | i IN k /\\ f i IN group_carrier G DIFF {group_id G}} = {})\n ==> ?i. i IN k /\\\n f i IN group_carrier G DIFF {group_id G} /\\\n group_sum G k f =\n group_mul G (f i) (group_sum G (k DELETE i) f))`;;\n\nlet GROUP_PRODUCT_EQ_ID = `!(G:A group) (<<=) (s:K->bool) f.\n (!i. i IN s ==> f i = group_id G)\n ==> group_product G (<<=) s f = group_id G`;;\n\nlet GROUP_SUM_EQ_ID = `!(G:A group) (s:K->bool) f.\n (!i. i IN s ==> f i = group_id G)\n ==> group_sum G s f = group_id G`;;\n\nlet GROUP_PRODUCT_ID = `!(G:A group) (<<=) (s:K->bool).\n group_product G (<<=) s (\\x. group_id G) = group_id G`;;\n\nlet GROUP_SUM_ID = `!(G:A group) (s:K->bool).\n group_sum G s (\\x. group_id G) = group_id G`;;\n\nlet GROUP_COMMUTES_PRODUCT = `!G (<<=) k (f:K->A) z.\n (!i. i IN k /\\ f i IN group_carrier G /\\ ~(f i = group_id G)\n ==> group_mul G (f i) z = group_mul G z (f i)) /\\\n z IN group_carrier G\n ==> group_mul G (group_product G (<<=) k f) z =\n group_mul G z (group_product G (<<=) k f)`;;\n\nlet GROUP_COMMUTES_SUM = `!G k (f:K->A) z.\n (!i. i IN k /\\ f i IN group_carrier G /\\ ~(f i = group_id G)\n ==> group_mul G (f i) z = group_mul G z (f i)) /\\\n z IN group_carrier G\n ==> group_mul G (group_sum G k f) z = group_mul G z (group_sum G k f)`;;\n\nlet GROUP_PRODUCT_SING = `!G (<<=) i (f:K->A).\n group_product G (<<=) {i} f =\n if f i IN group_carrier G then f i else group_id G`;;\n\nlet GROUP_SUM_SING = `!G i (f:K->A).\n group_sum G {i} f =\n if f i IN group_carrier G then f i else group_id G`;;\n\nlet GROUP_PRODUCT_UNION = `!G (<<=) (f:K->A) s t.\n woset(<<=) /\\ fld(<<=) = (:K) /\\\n (FINITE {i | i IN s /\\ f i IN group_carrier G DIFF {group_id G}} <=>\n FINITE {i | i IN t /\\ f i IN group_carrier G DIFF {group_id G}}) /\\\n (!x y. x IN s /\\ y IN t ==> x <<= y /\\ ~(x = y))\n ==> group_product G (<<=) (s UNION t) f =\n group_mul G (group_product G (<<=) s f)\n (group_product G (<<=) t f)`;;\n\nlet GROUP_PRODUCT_CLAUSES_LEFT = `!G (f:num->A) m n.\n group_product G (<=) (m..n) f =\n if m <= n then\n if f m IN group_carrier G\n then group_mul G (f m) (group_product G (<=) (m+1..n) f)\n else group_product G (<=) (m+1..n) f\n else group_id G`;;\n\nlet GROUP_PRODUCT_CLAUSES_RIGHT = `!G (f:num->A) m n.\n group_product G (<=) (m..n) f =\n if m <= n then\n if f n IN group_carrier G\n then if n = 0 then f 0\n else group_mul G (group_product G (<=) (m..n-1) f) (f n)\n else group_product G (<=) (m..n-1) f\n else group_id G`;;\n\nlet GROUP_PRODUCT_CLAUSES_NUMSEG = `(!G m f:num->A.\n group_product G (<=) (m..0) f =\n if m = 0 /\\ f 0 IN group_carrier G then f 0 else group_id G) /\\\n (!G m n f:num->A.\n group_product G (<=) (m..SUC n) f =\n if m <= SUC n /\\ f(SUC n) IN group_carrier G\n then group_mul G (group_product G (<=) (m..n) f) (f(SUC n))\n else group_product G (<=) (m..n) f)`;;\n\nlet GROUP_PRODUCT_CLAUSES_COMMUTING = `!G (<<=) i k (f:K->A).\n woset(<<=) /\\ fld(<<=) = (:K) /\\\n FINITE {j | j IN k /\\ f j IN group_carrier G DIFF {group_id G}} /\\\n (!j. j IN k /\\ j <<= i /\\ ~(j = i) /\\\n f i IN group_carrier G /\\ f j IN group_carrier G\n ==> group_mul G (f i) (f j) = group_mul G (f j) (f i))\n ==> group_product G (<<=) (i INSERT k) f =\n if f i IN group_carrier G ==> i IN k\n then group_product G (<<=) k f\n else group_mul G (f i) (group_product G (<<=) k f)`;;\n\nlet ABELIAN_GROUP_PRODUCT_CLAUSES = `!G (<<=) i k (f:K->A).\n woset(<<=) /\\ fld(<<=) = (:K) /\\\n abelian_group G /\\\n FINITE {j | j IN k /\\ f j IN group_carrier G DIFF {group_id G}}\n ==> group_product G (<<=) (i INSERT k) f =\n if f i IN group_carrier G ==> i IN k\n then group_product G (<<=) k f\n else group_mul G (f i) (group_product G (<<=) k f)`;;\n\nlet GROUP_SUM_CLAUSES_COMMUTING = `!G i k (f:K->A).\n FINITE {j | j IN k /\\ f j IN group_carrier G DIFF {group_id G}} /\\\n (!j. j IN k /\\ ~(j = i) /\\\n f i IN group_carrier G /\\ f j IN group_carrier G\n ==> group_mul G (f i) (f j) = group_mul G (f j) (f i))\n ==> group_sum G (i INSERT k) f =\n if f i IN group_carrier G ==> i IN k\n then group_sum G k f\n else group_mul G (f i) (group_sum G k f)`;;\n\nlet ABELIAN_GROUP_SUM_CLAUSES = `!G i k (f:K->A).\n abelian_group G /\\\n FINITE {j | j IN k /\\ f j IN group_carrier G DIFF {group_id G}}\n ==> group_sum G (i INSERT k) f =\n if f i IN group_carrier G ==> i IN k\n then group_sum G k f\n else group_mul G (f i) (group_sum G k f)`;;\n\nlet GROUP_PRODUCT_MUL = `!G (<<=) k f (g:K->A).\n woset(<<=) /\\ fld(<<=) = (:K) /\\\n FINITE {i | i IN k /\\ ~(f i = group_id G)} /\\\n FINITE {i | i IN k /\\ ~(g i = group_id G)} /\\\n (!i. i IN k ==> f i IN group_carrier G /\\ g i IN group_carrier G) /\\\n pairwise (\\i j. group_mul G (f i) (g j) = group_mul G (g j) (f i)) k\n ==> group_product G (<<=) k (\\i. group_mul G (f i) (g i)) =\n group_mul G (group_product G (<<=) k f) (group_product G (<<=) k g)`;;\n\nlet GROUP_SUM_MUL = `!G k f (g:K->A).\n FINITE {i | i IN k /\\ ~(f i = group_id G)} /\\\n FINITE {i | i IN k /\\ ~(g i = group_id G)} /\\\n (!i. i IN k ==> f i IN group_carrier G /\\ g i IN group_carrier G) /\\\n pairwise (\\i j. group_mul G (f i) (g j) = group_mul G (g j) (f i)) k\n ==> group_sum G k (\\i. group_mul G (f i) (g i)) =\n group_mul G (group_sum G k f) (group_sum G k g)`;;\n\nlet ABELIAN_GROUP_SUM_MUL = `!G k f (g:K->A).\n abelian_group G /\\\n FINITE {i | i IN k /\\ ~(f i = group_id G)} /\\\n FINITE {i | i IN k /\\ ~(g i = group_id G)} /\\\n (!i. i IN k ==> f i IN group_carrier G /\\ g i IN group_carrier G)\n ==> group_sum G k (\\i. group_mul G (f i) (g i)) =\n group_mul G (group_sum G k f) (group_sum G k g)`;;\n\nlet GROUP_SUM_INV = `!G k (f:K->A).\n FINITE {i | i IN k /\\ ~(f i = group_id G)} /\\\n (!i. i IN k ==> f i IN group_carrier G) /\\\n pairwise (\\i j. group_mul G (f i) (f j) = group_mul G (f j) (f i)) k\n ==> group_sum G k (\\i. group_inv G (f i)) =\n group_inv G (group_sum G k f)`;;\n\nlet ABELIAN_GROUP_SUM_INV = `!G k (f:K->A).\n abelian_group G /\\\n FINITE {i | i IN k /\\ ~(f i = group_id G)} /\\\n (!i. i IN k ==> f i IN group_carrier G)\n ==> group_sum G k (\\i. group_inv G (f i)) =\n group_inv G (group_sum G k f)`;;\n\nlet GROUP_SUM_POW = `!G k (f:K->A) n.\n FINITE {i | i IN k /\\ ~(f i = group_id G)} /\\\n (!i. i IN k ==> f i IN group_carrier G) /\\\n pairwise (\\i j. group_mul G (f i) (f j) = group_mul G (f j) (f i)) k\n ==> group_sum G k (\\i. group_pow G (f i) n) =\n group_pow G (group_sum G k f) n`;;\n\nlet ABELIAN_GROUP_SUM_POW = `!G k (f:K->A) n.\n abelian_group G /\\\n FINITE {i | i IN k /\\ ~(f i = group_id G)} /\\\n (!i. i IN k ==> f i IN group_carrier G)\n ==> group_sum G k (\\i. group_pow G (f i) n) =\n group_pow G (group_sum G k f) n`;;\n\nlet GROUP_SUM_ZPOW = `!G k (f:K->A) n.\n FINITE {i | i IN k /\\ ~(f i = group_id G)} /\\\n (!i. i IN k ==> f i IN group_carrier G) /\\\n pairwise (\\i j. group_mul G (f i) (f j) = group_mul G (f j) (f i)) k\n ==> group_sum G k (\\i. group_zpow G (f i) n) =\n group_zpow G (group_sum G k f) n`;;\n\nlet ABELIAN_GROUP_SUM_ZPOW = `!G k (f:K->A) n.\n abelian_group G /\\\n FINITE {i | i IN k /\\ ~(f i = group_id G)} /\\\n (!i. i IN k ==> f i IN group_carrier G)\n ==> group_sum G k (\\i. group_zpow G (f i) n) =\n group_zpow G (group_sum G k f) n`;;\n\nlet GROUP_SUM_IMAGE = `!G (f:K->A) (g:A->B) s.\n abelian_group G /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)\n ==> group_sum G (IMAGE f s) g = group_sum G s (g o f)`;;\n\nlet ABELIAN_GROUP_PRODUCT_ITERATE = `!G (<<=) (x:K->A) k.\n woset(<<=) /\\\n fld(<<=) = (:K) /\\\n abelian_group G /\\\n (!i. i IN k ==> x i IN group_carrier G)\n ==> group_product G (<<=) k x = iterate (group_add G) k x`;;\n\nlet ABELIAN_GROUP_SUM_ITERATE = `!G (x:K->A) k.\n abelian_group G /\\\n (!i. i IN k ==> x i IN group_carrier G)\n ==> group_sum G k x = iterate (group_add G) k x`;;\n\nlet ABELIAN_GROUP_ITERATE = `!G (x:K->A) k.\n abelian_group G /\\\n (!i. i IN k ==> x i IN group_carrier G)\n ==> iterate (group_add G) k x IN group_carrier G`;;\n\nlet group_conjugation = new_definition\n `group_conjugation G a x = group_mul G a (group_mul G x (group_inv G a))`;;\n\nlet GROUP_CONJUGATION = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> group_conjugation G x y IN group_carrier G`;;\n\nlet GROUP_CONJUGATION_CONJUGATION = `!G a b x:A.\n a IN group_carrier G /\\ b IN group_carrier G /\\ x IN group_carrier G\n ==> group_conjugation G a (group_conjugation G b x) =\n group_conjugation G (group_mul G a b) x`;;\n\nlet GROUP_CONJUGATION_EQ = `!G a x y:A.\n a IN group_carrier G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_conjugation G a x = group_conjugation G a y <=> x = y)`;;\n\nlet GROUP_CONJUGATION_EQ_SELF = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_conjugation G x y = y <=>\n group_mul G x y = group_mul G y x)`;;\n\nlet GROUP_CONJUGATION_EQ_ID = `!G a x:A.\n a IN group_carrier G /\\ x IN group_carrier G\n ==> (group_conjugation G a x = group_id G <=> x = group_id G)`;;\n\nlet GROUP_CONJUGATION_BY_ID = `!G x:A. x IN group_carrier G ==> group_conjugation G (group_id G) x = x`;;\n\nlet GROUP_CONJUGATION_LINV = `!G a x:A.\n a IN group_carrier G /\\ x IN group_carrier G\n ==> group_conjugation G (group_inv G a) (group_conjugation G a x) = x`;;\n\nlet GROUP_CONJUGATION_RINV = `!G a x:A.\n a IN group_carrier G /\\ x IN group_carrier G\n ==> group_conjugation G a (group_conjugation G (group_inv G a) x) = x`;;\n\nlet IN_IMAGE_GROUP_CONJUGATION = `!G s x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n s SUBSET group_carrier G\n ==> (x IN IMAGE (group_conjugation G y) s <=>\n group_conjugation G (group_inv G y) x IN s)`;;\n\nlet IMAGE_GROUP_CONJUGATION_SUBSET = `!G (a:A) s.\n a IN group_carrier G /\\ s SUBSET group_carrier G\n ==> IMAGE (group_conjugation G a) s SUBSET group_carrier G`;;\n\nlet IMAGE_GROUP_CONJUGATION_BY_ID = `!G s:A->bool.\n s SUBSET group_carrier G\n ==> IMAGE (group_conjugation G (group_id G)) s = s`;;\n\nlet IMAGE_GROUP_CONJUGATION_BY_MUL = `!G s a b:A.\n a IN group_carrier G /\\\n b IN group_carrier G /\\\n s SUBSET group_carrier G\n ==> IMAGE (group_conjugation G (group_mul G a b)) s =\n IMAGE (group_conjugation G a) (IMAGE (group_conjugation G b) s)`;;\n\nlet IMAGE_GROUP_CONJUGATION_BY_INV = `!G (a:A) s t.\n a IN group_carrier G /\\\n s SUBSET group_carrier G /\\\n t SUBSET group_carrier G\n ==> (IMAGE (group_conjugation G (group_inv G a)) s = t <=>\n IMAGE (group_conjugation G a) t = s)`;;\n\nlet IMAGE_GROUP_CONJUGATION_EQ_SWAP = `!G (a:A) s t.\n a IN group_carrier G /\\\n s SUBSET group_carrier G /\\\n t SUBSET group_carrier G /\\\n IMAGE (group_conjugation G (group_inv G a)) s = t\n ==> IMAGE (group_conjugation G a) t = s`;;\n\nlet IMAGE_GROUP_CONJUGATION_EQ_PREIMAGE = `!G (a:A) s t.\n a IN group_carrier G /\\\n s SUBSET group_carrier G /\\\n t SUBSET group_carrier G\n ==> (IMAGE (group_conjugation G a) s = t <=>\n {x | x IN group_carrier G /\\\n group_conjugation G a x IN t} = s)`;;\n\nparse_as_infix (\"subgroup_of\",(12,\"right\"));;\n\nlet subgroup_of = new_definition\n `(s:A->bool) subgroup_of (G:A group) <=>\n s SUBSET group_carrier G /\\\n group_id G IN s /\\\n (!x. x IN s ==> group_inv G x IN s) /\\\n (!x y. x IN s /\\ y IN s ==> group_mul G x y IN s)`;;\n\nlet IN_SUBGROUP_ID = `!G h:A->bool. h subgroup_of G ==> group_id G IN h`;;\n\nlet IN_SUBGROUP_INV = `!G h x:A. h subgroup_of G /\\ x IN h ==> group_inv G x IN h`;;\n\nlet IN_SUBGROUP_MUL = `!G h x y:A. h subgroup_of G /\\ x IN h /\\ y IN h ==> group_mul G x y IN h`;;\n\nlet IN_SUBGROUP_DIV = `!G h x y:A. h subgroup_of G /\\ x IN h /\\ y IN h ==> group_div G x y IN h`;;\n\nlet IN_SUBGROUP_POW = `!G h (x:A) n. h subgroup_of G /\\ x IN h ==> group_pow G x n IN h`;;\n\nlet IN_SUBGROUP_ZPOW = `!G h (x:A) n. h subgroup_of G /\\ x IN h ==> group_zpow G x n IN h`;;\n\nlet IN_SUBGROUP_CONJUGATION = `!G h a x:A.\n h subgroup_of G /\\ a IN h /\\ x IN h ==> group_conjugation G a x IN h`;;\n\nlet IN_SUBGROUP_PRODUCT = `!G h (<<=) k (f:K->A).\n h subgroup_of G /\\\n (!i. i IN k /\\ f i IN group_carrier G ==> f i IN h)\n ==> group_product G (<<=) k f IN h`;;\n\nlet IN_SUBGROUP_SUM = `!G h k (f:K->A).\n h subgroup_of G /\\\n (!i. i IN k /\\ f i IN group_carrier G ==> f i IN h)\n ==> group_sum G k f IN h`;;\n\nlet IMAGE_GROUP_CONJUGATION_SUBGROUP = `!G h a:A.\n h subgroup_of G /\\ a IN h ==> IMAGE (group_conjugation G a) h = h`;;\n\nlet SUBGROUP_OF_INTERS = `!G (gs:(A->bool)->bool).\n (!g. g IN gs ==> g subgroup_of G) /\\ ~(gs = {})\n ==> (INTERS gs) subgroup_of G`;;\n\nlet SUBGROUP_OF_INTER = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G ==> (g INTER h) subgroup_of G`;;\n\nlet SUBGROUP_OF_UNIONS = `!G (u:(A->bool)->bool).\n ~(u = {}) /\\\n (!h. h IN u ==> h subgroup_of G) /\\\n (!g h. g IN u /\\ h IN u ==> g SUBSET h \\/ h SUBSET g)\n ==> (UNIONS u) subgroup_of G`;;\n\nlet SUBGROUP_OF_OPPOSITE_GROUP = `!G h:A->bool. h subgroup_of opposite_group G <=> h subgroup_of G`;;\n\nlet SUBGROUP_OF_IMP_SUBSET = `!G s:A->bool. s subgroup_of G ==> s SUBSET group_carrier G`;;\n\nlet SUBGROUP_OF_IMP_NONEMPTY = `!G s:A->bool. s subgroup_of G ==> ~(s = {})`;;\n\nlet TRIVIAL_SUBGROUP_OF = `!G:A group. {group_id G} subgroup_of G`;;\n\nlet CARRIER_SUBGROUP_OF = `!G:A group. (group_carrier G) subgroup_of G`;;\n\nlet FINITE_SUBGROUPS = `!(G:A group). FINITE(group_carrier G) ==> FINITE {h | h subgroup_of G}`;;\n\nlet FINITE_RESTRICTED_SUBGROUPS = `!P (G:A group).\n FINITE(group_carrier G) ==> FINITE {h | h subgroup_of G /\\ P h}`;;\n\nlet subgroup_generated = new_definition\n `subgroup_generated G (s:A->bool) =\n group(INTERS {h | h subgroup_of G /\\ (group_carrier G INTER s) SUBSET h},\n group_id G,group_inv G,group_mul G)`;;\n\nlet SUBGROUP_GENERATED = `(!G s:A->bool.\n group_carrier (subgroup_generated G s) =\n INTERS {h | h subgroup_of G /\\ (group_carrier G INTER s) SUBSET h}) /\\\n (!G s:A->bool. group_id (subgroup_generated G s) = group_id G) /\\\n (!G s:A->bool. group_inv (subgroup_generated G s) = group_inv G) /\\\n (!G s:A->bool. group_mul (subgroup_generated G s) = group_mul G)`;;\n\nlet SUBGROUP_GENERATED_EQ = `!G s:A->bool.\n subgroup_generated G s = G <=>\n group_carrier(subgroup_generated G s) = group_carrier G`;;\n\nlet GROUP_ID_SUBGROUP = `!G s:A->bool. group_id G IN group_carrier(subgroup_generated G s)`;;\n\nlet GROUP_INV_SUBGROUP = `!x. x IN group_carrier (subgroup_generated G s)\n ==> group_inv G x IN group_carrier(subgroup_generated G s)`;;\n\nlet GROUP_MUL_SUBGROUP = `!x y. x IN group_carrier (subgroup_generated G s) /\\\n y IN group_carrier (subgroup_generated G s)\n ==> group_mul G x y IN group_carrier(subgroup_generated G s)`;;\n\nlet ABELIAN_SUBGROUP_GENERATED = `!G h:A->bool.\n abelian_group G ==> abelian_group(subgroup_generated G h)`;;\n\nlet GROUP_DIV_SUBGROUP_GENERATED = `!G s:A->bool. group_div (subgroup_generated G s) = group_div G`;;\n\nlet GROUP_POW_SUBGROUP_GENERATED = `!G s:A->bool. group_pow (subgroup_generated G s) = group_pow G`;;\n\nlet GROUP_ZPOW_SUBGROUP_GENERATED = `!G s:A->bool. group_zpow (subgroup_generated G s) = group_zpow G`;;\n\nlet GROUP_CONJUGATION_SUBGROUP_GENERATED = `!G s:A->bool.\n group_conjugation (subgroup_generated G s) = group_conjugation G`;;\n\nlet SUBGROUP_GENERATED_RESTRICT = `!G s:A->bool.\n subgroup_generated G s =\n subgroup_generated G (group_carrier G INTER s)`;;\n\nlet SUBGROUP_SUBGROUP_GENERATED = `!G s:A->bool. group_carrier(subgroup_generated G s) subgroup_of G`;;\n\nlet SUBGROUP_GENERATED_MONO = `!G s t:A->bool.\n s SUBSET t\n ==> group_carrier(subgroup_generated G s) SUBSET\n group_carrier(subgroup_generated G t)`;;\n\nlet SUBGROUP_GENERATED_MINIMAL = `!G h s:A->bool.\n s SUBSET h /\\ h subgroup_of G\n ==> group_carrier(subgroup_generated G s) SUBSET h`;;\n\nlet SUBGROUPS_GENERATED_EQ = `!G s t:A->bool.\n s SUBSET group_carrier(subgroup_generated G t) /\\\n t SUBSET group_carrier(subgroup_generated G s)\n ==> subgroup_generated G s = subgroup_generated G t`;;\n\nlet SUBGROUP_GENERATED_INDUCT = `!G P s:A->bool.\n (!x. x IN group_carrier G /\\ x IN s ==> P x) /\\\n P(group_id G) /\\\n (!x. P x ==> P(group_inv G x)) /\\\n (!x y. P x /\\ P y ==> P(group_mul G x y))\n ==> !x. x IN group_carrier(subgroup_generated G s) ==> P x`;;\n\nlet GROUP_CARRIER_SUBGROUP_GENERATED_SUBSET = `!G h:A->bool.\n group_carrier (subgroup_generated G h) SUBSET group_carrier G`;;\n\nlet SUBGROUP_GENERATED_SUPERSET = `!G s:A->bool.\n subgroup_generated G s = G <=>\n group_carrier G SUBSET group_carrier(subgroup_generated G s)`;;\n\nlet SUBGROUP_OF_SUBGROUP_GENERATED_EQ = `!G h k:A->bool.\n h subgroup_of (subgroup_generated G k) <=>\n h subgroup_of G /\\ h SUBSET group_carrier(subgroup_generated G k)`;;\n\nlet SUBGROUP_GENERATED_INDUCT_STRONG = `!G P s:A->bool.\n (!x. x IN group_carrier G /\\ x IN s ==> P x) /\\\n P (group_id G) /\\\n (!x. x IN group_carrier G /\\ P x ==> P (group_inv G x)) /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G /\\ P x /\\ P y\n ==> P (group_mul G x y))\n ==> !x. x IN group_carrier (subgroup_generated G s) ==> P x`;;\n\nlet SUBGROUP_GENERATED_INDUCT_ALT = `!G P s:A->bool.\n P (group_id G) /\\\n (!x. x IN group_carrier G /\\ x IN s ==> P x /\\ P(group_inv G x)) /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G /\\ P x /\\ P y\n ==> P (group_mul G x y))\n ==> !x. x IN group_carrier (subgroup_generated G s) ==> P x`;;\n\nlet SUBGROUP_GENERATED_INDUCT_LEFT = `!G P s:A->bool.\n P (group_id G) /\\\n (!x y. x IN group_carrier G /\\ x IN s /\\ y IN group_carrier G /\\ P y\n ==> P (group_mul G x y) /\\ P (group_mul G (group_inv G x) y))\n ==> !x. x IN group_carrier(subgroup_generated G s) ==> P x`;;\n\nlet FINITE_SUBGROUP_GENERATED = `!G s:A->bool.\n FINITE(group_carrier G)\n ==> FINITE(group_carrier(subgroup_generated G s))`;;\n\nlet CARD_LE_SUBGROUP_GENERATED = `!(G:A group) s (k:K->bool).\n INFINITE k /\\ s <=_c k ==> group_carrier(subgroup_generated G s) <=_c k`;;\n\nlet COUNTABLE_SUBGROUP_GENERATED = `!G s:A->bool.\n COUNTABLE(group_carrier G) \\/ COUNTABLE s\n ==> COUNTABLE(group_carrier(subgroup_generated G s))`;;\n\nlet SUBGROUP_GENERATED_SUBSET_CARRIER = `!G h:A->bool.\n group_carrier G INTER h SUBSET group_carrier(subgroup_generated G h)`;;\n\nlet SUBSET_CARRIER_SUBGROUP_GENERATED = `!G s t:A->bool.\n s SUBSET group_carrier G /\\ s SUBSET t\n ==> s SUBSET group_carrier(subgroup_generated G t)`;;\n\nlet SUBGROUP_GENERATED_MINIMAL_EQ = `!G h s:A->bool.\n h subgroup_of G\n ==> (group_carrier (subgroup_generated G s) SUBSET h <=>\n group_carrier G INTER s SUBSET h)`;;\n\nlet CARRIER_SUBGROUP_GENERATED_SUBGROUP = `!G h:A->bool.\n h subgroup_of G ==> group_carrier (subgroup_generated G h) = h`;;\n\nlet SUBGROUP_OF_SUBGROUP_GENERATED_SUBGROUP_EQ = `!G h k:A->bool.\n k subgroup_of G\n ==> (h subgroup_of (subgroup_generated G k) <=>\n h subgroup_of G /\\ h SUBSET k)`;;\n\nlet SUBGROUP_GENERATED_GROUP_CARRIER = `!G:A group. subgroup_generated G (group_carrier G) = G`;;\n\nlet SUBGROUP_OF_SUBGROUP_GENERATED = `!G g h:A->bool.\n g subgroup_of G /\\ g SUBSET h\n ==> g subgroup_of (subgroup_generated G h)`;;\n\nlet SUBGROUP_GENERATED_SUBSET_CARRIER_SUBSET = `!G s:A->bool.\n s SUBSET group_carrier G\n ==> s SUBSET group_carrier(subgroup_generated G s)`;;\n\nlet SUBGROUP_GENERATED_REFL = `!G s:A->bool. group_carrier G SUBSET s ==> subgroup_generated G s = G`;;\n\nlet SUBGROUP_GENERATED_INC = `!G s x:A.\n s SUBSET group_carrier G /\\ x IN s\n ==> x IN group_carrier(subgroup_generated G s)`;;\n\nlet SUBGROUP_GENERATED_INC_GEN = `!G s x:A.\n x IN group_carrier G /\\ x IN s\n ==> x IN group_carrier(subgroup_generated G s)`;;\n\nlet SUBGROUP_OF_SUBGROUP_GENERATED_REV = `!G g h:A->bool.\n g subgroup_of (subgroup_generated G h)\n ==> g subgroup_of G`;;\n\nlet TRIVIAL_GROUP_SUBGROUP_GENERATED = `!G s:A->bool.\n trivial_group G ==> trivial_group(subgroup_generated G s)`;;\n\nlet TRIVIAL_GROUP_SUBGROUP_GENERATED_TRIVIAL = `!G s:A->bool.\n s SUBSET {group_id G} ==> trivial_group(subgroup_generated G s)`;;\n\nlet TRIVIAL_GROUP_SUBGROUP_GENERATED_EQ = `!G s:A->bool.\n trivial_group(subgroup_generated G s) <=>\n group_carrier G INTER s SUBSET {group_id G}`;;\n\nlet TRIVIAL_GROUP_GENERATED_BY_ANYTHING = `!G s:A->bool. trivial_group G ==> subgroup_generated G s = G`;;\n\nlet SUBGROUP_GENERATED_BY_SUBGROUP_GENERATED = `!G s:A->bool.\n subgroup_generated G (group_carrier(subgroup_generated G s)) =\n subgroup_generated G s`;;\n\nlet SUBGROUP_GENERATED_INSERT_ID = `!G s:A->bool.\n subgroup_generated G (group_id G INSERT s) = subgroup_generated G s`;;\n\nlet GROUP_CARRIER_SUBGROUP_GENERATED_MONO = `!G s t:A->bool.\n group_carrier(subgroup_generated (subgroup_generated G s) t) SUBSET\n group_carrier(subgroup_generated G t)`;;\n\nlet SUBGROUP_GENERATED_IDEMPOT_GEN = `!G s t:A->bool.\n s SUBSET group_carrier(subgroup_generated G t)\n ==> subgroup_generated (subgroup_generated G t) s =\n subgroup_generated G s`;;\n\nlet SUBGROUP_GENERATED_IDEMPOT = `!G s t:A->bool.\n s SUBSET t\n ==> subgroup_generated (subgroup_generated G t) s =\n subgroup_generated G s`;;\n\nlet SUBGROUP_GENERATED_BY_SUBGROUP_GENERATED_IDEMPOT = `!G s t:A->bool.\n s SUBSET t\n ==> subgroup_generated (subgroup_generated G t)\n (group_carrier (subgroup_generated G s)) =\n subgroup_generated G s`;;\n\nlet SUBGROUP_GENERATED_UNION_LEFT = `!G s t:A->bool.\n subgroup_generated G (group_carrier(subgroup_generated G s) UNION t) =\n subgroup_generated G (s UNION t)`;;\n\nlet SUBGROUP_GENERATED_UNION_RIGHT = `!G s t:A->bool.\n subgroup_generated G (s UNION group_carrier(subgroup_generated G t)) =\n subgroup_generated G (s UNION t)`;;\n\nlet SUBGROUP_GENERATED_UNION = `!G s t:A->bool.\n subgroup_generated G (group_carrier(subgroup_generated G s) UNION\n group_carrier(subgroup_generated G t)) =\n subgroup_generated G (s UNION t)`;;\n\nlet TRIVIAL_GROUP_SUBGROUP_GENERATED_EMPTY = `!G:A group. trivial_group(subgroup_generated G {})`;;\n\nlet SUBGROUP_OF_COMMUTING_ELEMENTS = `!G z:A.\n z IN group_carrier G\n ==> {x | x IN group_carrier G /\\ group_mul G x z = group_mul G z x}\n subgroup_of G`;;\n\nlet GROUP_COMMUTES_SUBGROUP_GENERATED_EQ = `!G s z:A.\n z IN group_carrier G\n ==> ((!x. x IN group_carrier(subgroup_generated G s)\n ==> group_mul G x z = group_mul G z x) <=>\n (!x. x IN group_carrier G /\\ x IN s\n ==> group_mul G x z = group_mul G z x))`;;\n\nlet GROUP_COMMUTES_SUBGROUP_GENERATED = `!G s z:A.\n (!x. x IN s ==> group_mul G x z = group_mul G z x) /\\\n z IN group_carrier G\n ==> (!x. x IN group_carrier(subgroup_generated G s)\n ==> group_mul G x z = group_mul G z x)`;;\n\nlet GROUP_COMMUTES_SUBGROUPS_GENERATED_EQ = `!G s t:A->bool.\n (!x y. x IN group_carrier(subgroup_generated G s) /\\\n y IN group_carrier(subgroup_generated G t)\n ==> group_mul G x y = group_mul G y x) <=>\n (!x y. x IN group_carrier G /\\ x IN s /\\\n y IN group_carrier G /\\ y IN t\n ==> group_mul G x y = group_mul G y x)`;;\n\nlet ABELIAN_GROUP_SUBGROUP_GENERATED_GEN = `!G s:A->bool.\n (!x y. x IN group_carrier G /\\ x IN s /\\\n y IN group_carrier G /\\ y IN s\n ==> group_mul G x y = group_mul G y x)\n ==> abelian_group (subgroup_generated G s)`;;\n\nlet prod_group = new_definition\n `prod_group (G:A group) (G':B group) =\n group((group_carrier G) CROSS (group_carrier G'),\n (group_id G,group_id G'),\n (\\(x,x'). group_inv G x,group_inv G' x'),\n (\\(x,x') (y,y'). group_mul G x y,group_mul G' x' y'))`;;\n\nlet PROD_GROUP = `(!(G:A group) (G':B group).\n group_carrier (prod_group G G') =\n (group_carrier G) CROSS (group_carrier G')) /\\\n (!(G:A group) (G':B group).\n group_id (prod_group G G') = (group_id G,group_id G')) /\\\n (!(G:A group) (G':B group).\n group_inv (prod_group G G') =\n \\(x,x'). group_inv G x,group_inv G' x') /\\\n (!(G:A group) (G':B group).\n group_mul (prod_group G G') =\n \\(x,x') (y,y'). group_mul G x y,group_mul G' x' y')`;;\n\nlet GROUP_POW_PROD_GROUP = `!(G:A group) (H:B group) x y n.\n x IN group_carrier G /\\ y IN group_carrier H\n ==> group_pow (prod_group G H) (x,y) n =\n (group_pow G x n,group_pow H y n)`;;\n\nlet GROUP_ZPOW_PROD_GROUP = `!(G:A group) (H:B group) x y n.\n x IN group_carrier G /\\ y IN group_carrier H\n ==> group_zpow (prod_group G H) (x,y) n =\n (group_zpow G x n,group_zpow H y n)`;;\n\nlet OPPOSITE_PROD_GROUP = `!(G1:A group) (G2:B group).\n opposite_group(prod_group G1 G2) =\n prod_group (opposite_group G1) (opposite_group G2)`;;\n\nlet TRIVIAL_PROD_GROUP = `!(G:A group) (H:B group).\n trivial_group(prod_group G H) <=>\n trivial_group G /\\ trivial_group H`;;\n\nlet FINITE_PROD_GROUP = `!(G:A group) (H:B group).\n FINITE(group_carrier(prod_group G H)) <=>\n FINITE(group_carrier G) /\\ FINITE(group_carrier H)`;;\n\nlet ABELIAN_PROD_GROUP = `!(G:A group) (H:B group).\n abelian_group(prod_group G H) <=>\n abelian_group G /\\ abelian_group H`;;\n\nlet CROSS_SUBGROUP_OF_PROD_GROUP = `!(G1:A group) (G2:B group) h1 h2.\n (h1 CROSS h2) subgroup_of (prod_group G1 G2) <=>\n h1 subgroup_of G1 /\\ h2 subgroup_of G2`;;\n\nlet PROD_GROUP_SUBGROUP_GENERATED = `!(G1:A group) (G2:B group) h1 h2.\n h1 subgroup_of G1 /\\ h2 subgroup_of G2\n ==> (prod_group (subgroup_generated G1 h1) (subgroup_generated G2 h2) =\n subgroup_generated (prod_group G1 G2) (h1 CROSS h2))`;;\n\nlet product_group = new_definition\n `product_group k (G:K->A group) =\n group(cartesian_product k (\\i. group_carrier(G i)),\n RESTRICTION k (\\i. group_id (G i)),\n (\\x. RESTRICTION k (\\i. group_inv (G i) (x i))),\n (\\x y. RESTRICTION k (\\i. group_mul (G i) (x i) (y i))))`;;\n\nlet PRODUCT_GROUP = `(!k (G:K->A group).\n group_carrier(product_group k G) =\n cartesian_product k (\\i. group_carrier(G i))) /\\\n (!k (G:K->A group).\n group_id (product_group k G) =\n RESTRICTION k (\\i. group_id (G i))) /\\\n (!k (G:K->A group).\n group_inv (product_group k G) =\n \\x. RESTRICTION k (\\i. group_inv (G i) (x i))) /\\\n (!k (G:K->A group).\n group_mul (product_group k G) =\n (\\x y. RESTRICTION k (\\i. group_mul (G i) (x i) (y i))))`;;\n\nlet GROUP_POW_PRODUCT_GROUP = `!(G:K->A group) k x n.\n group_pow (product_group k G) x n =\n RESTRICTION k (\\i. group_pow (G i) (x i) n)`;;\n\nlet GROUP_ZPOW_PRODUCT_GROUP = `!(G:K->A group) k x n.\n group_zpow (product_group k G) x n =\n RESTRICTION k (\\i. group_zpow (G i) (x i) n)`;;\n\nlet OPPOSITE_PRODUCT_GROUP = `!(G:K->A group) k.\n opposite_group(product_group k G) =\n product_group k (\\i. opposite_group(G i))`;;\n\nlet GROUP_PRODUCT_INJECTION = `!k (G:K->A group) a i.\n RESTRICTION k (\\j. if j = i then a else group_id (G j)) IN\n group_carrier(product_group k G) <=>\n i IN k ==> a IN group_carrier(G i)`;;\n\nlet TRIVIAL_PRODUCT_GROUP = `!k (G:K->A group).\n trivial_group(product_group k G) <=>\n !i. i IN k ==> trivial_group(G i)`;;\n\nlet CARTESIAN_PRODUCT_SUBGROUP_OF_PRODUCT_GROUP = `!k h G:K->A group.\n (cartesian_product k h) subgroup_of (product_group k G) <=>\n !i. i IN k ==> (h i) subgroup_of (G i)`;;\n\nlet PRODUCT_GROUP_SUBGROUP_GENERATED = `!k G (h:K->A->bool).\n (!i. i IN k ==> (h i) subgroup_of (G i))\n ==> product_group k (\\i. subgroup_generated (G i) (h i)) =\n subgroup_generated (product_group k G) (cartesian_product k h)`;;\n\nlet FINITE_PRODUCT_GROUP = `!k (G:K->A group).\n FINITE(group_carrier(product_group k G)) <=>\n FINITE {i | i IN k /\\ ~trivial_group(G i)} /\\\n !i. i IN k ==> FINITE(group_carrier(G i))`;;\n\nlet ABELIAN_PRODUCT_GROUP = `!k (G:K->A group).\n abelian_group(product_group k G) <=>\n !i. i IN k ==> abelian_group(G i)`;;\n\nlet sum_group = new_definition\n `sum_group k (G:K->A group) =\n subgroup_generated\n (product_group k G)\n {x | x IN cartesian_product k (\\i. group_carrier(G i)) /\\\n FINITE {i | i IN k /\\ ~(x i = group_id(G i))}}`;;\n\nlet SUM_GROUP_ALT = `!k (G:K->A group).\n sum_group k G =\n subgroup_generated (product_group k G)\n {x | FINITE {i | i IN k /\\ ~(x i = group_id (G i))}}`;;\n\nlet SUM_GROUP_EQ_PRODUCT_GROUP = `!k (G:K->A group). FINITE k ==> sum_group k G = product_group k G`;;\n\nlet SUBGROUP_SUM_GROUP = `!k (G:K->A group).\n {x | x IN cartesian_product k (\\i. group_carrier(G i)) /\\\n FINITE {i | i IN k /\\ ~(x i = group_id(G i))}}\n subgroup_of product_group k G`;;\n\nlet SUM_GROUP_CLAUSES = `(!k (G:K->A group).\n group_carrier(sum_group k G) =\n {x | x IN cartesian_product k (\\i. group_carrier(G i)) /\\\n FINITE {i | i IN k /\\ ~(x i = group_id(G i))}}) /\\\n (!k (G:K->A group).\n group_id (sum_group k G) =\n RESTRICTION k (\\i. group_id (G i))) /\\\n (!k (G:K->A group).\n group_inv (sum_group k G) =\n \\x. RESTRICTION k (\\i. group_inv (G i) (x i))) /\\\n (!k (G:K->A group).\n group_mul (sum_group k G) =\n (\\x y. RESTRICTION k (\\i. group_mul (G i) (x i) (y i))))`;;\n\nlet GROUP_POW_SUM_GROUP = `!(G:K->A group) k x n.\n group_pow (sum_group k G) x n =\n RESTRICTION k (\\i. group_pow (G i) (x i) n)`;;\n\nlet GROUP_ZPOW_SUM_GROUP = `!(G:K->A group) k x n.\n group_zpow (sum_group k G) x n =\n RESTRICTION k (\\i. group_zpow (G i) (x i) n)`;;\n\nlet GROUP_SUM_INJECTION = `!k (G:K->A group) a i.\n RESTRICTION k (\\j. if j = i then a else group_id (G j)) IN\n group_carrier(sum_group k G) <=>\n i IN k ==> a IN group_carrier(G i)`;;\n\nlet TRIVIAL_SUM_GROUP = `!k (G:K->A group).\n trivial_group(sum_group k G) <=> !i. i IN k ==> trivial_group(G i)`;;\n\nlet CARTESIAN_PRODUCT_SUBGROUP_OF_SUM_GROUP = `!k h G:K->A group.\n (cartesian_product k h) subgroup_of (sum_group k G) <=>\n (!i. i IN k ==> (h i) subgroup_of (G i)) /\\\n (!z. z IN cartesian_product k h\n ==> FINITE {i | i IN k /\\ ~(z i = group_id(G i))})`;;\n\nlet SUM_GROUP_SUBGROUP_GENERATED = `!k G (h:K->A->bool).\n (!i. i IN k ==> (h i) subgroup_of (G i))\n ==> sum_group k (\\i. subgroup_generated (G i) (h i)) =\n subgroup_generated (sum_group k G) (cartesian_product k h)`;;\n\nlet ABELIAN_SUM_GROUP = `!k (G:K->A group).\n abelian_group (sum_group k G) <=>\n (!i. i IN k ==> abelian_group (G i))`;;\n\nlet group_homomorphism = new_definition\n `group_homomorphism (G,G') (f:A->B) <=>\n IMAGE f (group_carrier G) SUBSET group_carrier G' /\\\n f (group_id G) = group_id G' /\\\n (!x. x IN group_carrier G\n ==> f(group_inv G x) = group_inv G' (f x)) /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G\n ==> f(group_mul G x y) = group_mul G' (f x) (f y))`;;\n\nlet group_monomorphism = new_definition\n `group_monomorphism (G,G') (f:A->B) <=>\n group_homomorphism (G,G') f /\\\n !x y. x IN group_carrier G /\\ y IN group_carrier G /\\ f x = f y\n ==> x = y`;;\n\nlet group_epimorphism = new_definition\n `group_epimorphism (G,G') (f:A->B) <=>\n group_homomorphism (G,G') f /\\\n IMAGE f (group_carrier G) = group_carrier G'`;;\n\nlet group_endomorphism = new_definition\n `group_endomorphism G (f:A->A) <=> group_homomorphism (G,G) f`;;\n\nlet group_isomorphisms = new_definition\n `group_isomorphisms (G,G') ((f:A->B),g) <=>\n group_homomorphism (G,G') f /\\\n group_homomorphism (G',G) g /\\\n (!x. x IN group_carrier G ==> g(f x) = x) /\\\n (!y. y IN group_carrier G' ==> f(g y) = y)`;;\n\nlet group_isomorphism = new_definition\n `group_isomorphism (G,G') (f:A->B) <=> ?g. group_isomorphisms (G,G') (f,g)`;;\n\nlet group_automorphism = new_definition\n `group_automorphism G (f:A->A) <=> group_isomorphism (G,G) f`;;\n\nlet GROUP_HOMOMORPHISM_EQ = `!G H (f:A->B) f'.\n group_homomorphism(G,H) f /\\\n (!x. x IN group_carrier G ==> f' x = f x)\n ==> group_homomorphism (G,H) f'`;;\n\nlet GROUP_MONOMORPHISM_EQ = `!G H (f:A->B) f'.\n group_monomorphism(G,H) f /\\\n (!x. x IN group_carrier G ==> f' x = f x)\n ==> group_monomorphism (G,H) f'`;;\n\nlet GROUP_EPIMORPHISM_EQ = `!G H (f:A->B) f'.\n group_epimorphism(G,H) f /\\\n (!x. x IN group_carrier G ==> f' x = f x)\n ==> group_epimorphism (G,H) f'`;;\n\nlet GROUP_ENDOMORPHISM_EQ = `!G (f:A->A) f'.\n group_endomorphism G f /\\\n (!x. x IN group_carrier G ==> f' x = f x)\n ==> group_endomorphism G f'`;;\n\nlet GROUP_ISOMORPHISMS_EQ = `!G H (f:A->B) g.\n group_isomorphisms(G,H) (f,g) /\\\n (!x. x IN group_carrier G ==> f' x = f x) /\\\n (!y. y IN group_carrier H ==> g' y = g y)\n ==> group_isomorphisms(G,H) (f',g')`;;\n\nlet GROUP_ISOMORPHISM_EQ = `!G H (f:A->B) f'.\n group_isomorphism(G,H) f /\\\n (!x. x IN group_carrier G ==> f' x = f x)\n ==> group_isomorphism (G,H) f'`;;\n\nlet GROUP_AUTOMORPHISM_EQ = `!G (f:A->A) f'.\n group_automorphism G f /\\\n (!x. x IN group_carrier G ==> f' x = f x)\n ==> group_automorphism G f'`;;\n\nlet GROUP_HOMOMORPHISMS_EQ_ON_GENERATORS = `!G H s (f:A->B) g.\n group_homomorphism(G,H) f /\\\n group_homomorphism(G,H) g /\\\n (!x. x IN group_carrier G /\\ x IN s ==> f x = g x)\n ==> !x. x IN group_carrier(subgroup_generated G s) ==> f x = g x`;;\n\nlet GROUP_ISOMORPHISMS_SYM = `!G G' (f:A->B) g.\n group_isomorphisms (G,G') (f,g) <=> group_isomorphisms(G',G) (g,f)`;;\n\nlet GROUP_ISOMORPHISMS_IMP_ISOMORPHISM = `!(f:A->B) g G G'.\n group_isomorphisms (G,G') (f,g) ==> group_isomorphism (G,G') f`;;\n\nlet GROUP_ISOMORPHISMS_IMP_ISOMORPHISM_ALT = `!(f:A->B) g G G'.\n group_isomorphisms (G,G') (f,g) ==> group_isomorphism (G',G) g`;;\n\nlet GROUP_HOMOMORPHISM = `!G G' f:A->B.\n group_homomorphism (G,G') (f:A->B) <=>\n IMAGE f (group_carrier G) SUBSET group_carrier G' /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G\n ==> f(group_mul G x y) = group_mul G' (f x) (f y))`;;\n\nlet GROUP_EPIMORPHISM_SUBSET = `!G G' (f:A->B).\n group_epimorphism(G,G') f <=>\n group_homomorphism(G,G') f /\\\n group_carrier G' SUBSET IMAGE f (group_carrier G)`;;\n\nlet GROUP_ISOMORPHISMS = `!G H (f:A->B) g.\n group_isomorphisms(G,H) (f,g) <=>\n group_homomorphism(G,H) f /\\\n (!x. x IN group_carrier G ==> g(f x) = x) /\\\n (!y. y IN group_carrier H ==> g y IN group_carrier G /\\ f(g y) = y)`;;\n\nlet GROUP_HOMOMORPHISM_OF_ID = `!(f:A->B) G G'.\n group_homomorphism(G,G') f ==> f (group_id G) = group_id G'`;;\n\nlet GROUP_HOMOMORPHISM_INV = `!G G' (f:A->B).\n group_homomorphism(G,G') f\n ==> !x. x IN group_carrier G\n ==> f(group_inv G x) = group_inv G' (f x)`;;\n\nlet GROUP_HOMOMORPHISM_MUL = `!G G' (f:A->B).\n group_homomorphism(G,G') f\n ==> !x y. x IN group_carrier G /\\ y IN group_carrier G\n ==> f(group_mul G x y) = group_mul G' (f x) (f y)`;;\n\nlet GROUP_HOMOMORPHISM_DIV = `!G G' (f:A->B).\n group_homomorphism(G,G') f\n ==> !x y. x IN group_carrier G /\\ y IN group_carrier G\n ==> f(group_div G x y) = group_div G' (f x) (f y)`;;\n\nlet GROUP_HOMOMORPHISM_POW = `!G G' (f:A->B).\n group_homomorphism(G,G') f\n ==> !x n. x IN group_carrier G\n ==> f(group_pow G x n) = group_pow G' (f x) n`;;\n\nlet GROUP_HOMOMORPHISM_ZPOW = `!G G' (f:A->B).\n group_homomorphism(G,G') f\n ==> !x n. x IN group_carrier G\n ==> f(group_zpow G x n) = group_zpow G' (f x) n`;;\n\nlet GROUP_HOMOMORPHISM_TRIVIAL = `!G H. group_homomorphism (G,H) (\\x. group_id H)`;;\n\nlet GROUP_HOMOMORPHISM_ID = `!G:A group. group_homomorphism (G,G) (\\x. x)`;;\n\nlet GROUP_MONOMORPHISM_ID = `!G:A group. group_monomorphism (G,G) (\\x. x)`;;\n\nlet GROUP_EPIMORPHISM_ID = `!G:A group. group_epimorphism (G,G) (\\x. x)`;;\n\nlet GROUP_ISOMORPHISMS_ID = `!G:A group. group_isomorphisms (G,G) ((\\x. x),(\\x. x))`;;\n\nlet GROUP_ISOMORPHISM_ID = `!G:A group. group_isomorphism (G,G) (\\x. x)`;;\n\nlet GROUP_HOMOMORPHISM_COMPOSE = `!G1 G2 G3 (f:A->B) (g:B->C).\n group_homomorphism(G1,G2) f /\\ group_homomorphism(G2,G3) g\n ==> group_homomorphism(G1,G3) (g o f)`;;\n\nlet GROUP_MONOMORPHISM_COMPOSE = `!G1 G2 G3 (f:A->B) (g:B->C).\n group_monomorphism(G1,G2) f /\\ group_monomorphism(G2,G3) g\n ==> group_monomorphism(G1,G3) (g o f)`;;\n\nlet GROUP_MONOMORPHISM_COMPOSE_REV = `!(f:A->B) (g:B->C) A B C.\n group_homomorphism(A,B) f /\\ group_homomorphism(B,C) g /\\\n group_monomorphism(A,C) (g o f)\n ==> group_monomorphism(A,B) f`;;\n\nlet GROUP_EPIMORPHISM_COMPOSE = `!G1 G2 G3 (f:A->B) (g:B->C).\n group_epimorphism(G1,G2) f /\\ group_epimorphism(G2,G3) g\n ==> group_epimorphism(G1,G3) (g o f)`;;\n\nlet GROUP_EPIMORPHISM_COMPOSE_REV = `!(f:A->B) (g:B->C) A B C.\n group_homomorphism(A,B) f /\\ group_homomorphism(B,C) g /\\\n group_epimorphism(A,C) (g o f)\n ==> group_epimorphism(B,C) g`;;\n\nlet GROUP_MONOMORPHISM_LEFT_INVERTIBLE = `!G H (f:A->B) g.\n group_homomorphism(G,H) f /\\\n (!x. x IN group_carrier G ==> g(f x) = x)\n ==> group_monomorphism (G,H) f`;;\n\nlet GROUP_EPIMORPHISM_RIGHT_INVERTIBLE = `!G H (f:A->B) g.\n group_homomorphism(G,H) f /\\\n group_homomorphism(H,G) g /\\\n (!x. x IN group_carrier G ==> g(f x) = x)\n ==> group_epimorphism (H,G) g`;;\n\nlet GROUP_HOMOMORPHISM_INTO_SUBGROUP = `!G G' h (f:A->B).\n group_homomorphism (G,G') f /\\ IMAGE f (group_carrier G) SUBSET h\n ==> group_homomorphism (G,subgroup_generated G' h) f`;;\n\nlet GROUP_HOMOMORPHISM_INTO_SUBGROUP_EQ_GEN = `!(f:A->B) G H s.\n group_homomorphism(G,subgroup_generated H s) f <=>\n group_homomorphism(G,H) f /\\\n IMAGE f (group_carrier G) SUBSET group_carrier(subgroup_generated H s)`;;\n\nlet GROUP_HOMOMORPHISM_INTO_SUBGROUP_EQ = `!G G' h (f:A->B).\n h subgroup_of G'\n ==> (group_homomorphism (G,subgroup_generated G' h) f <=>\n group_homomorphism (G,G') f /\\\n IMAGE f (group_carrier G) SUBSET h)`;;\n\nlet GROUP_HOMOMORPHISM_FROM_SUBGROUP_GENERATED = `!(f:A->B) G H s.\n group_homomorphism (G,H) f\n ==> group_homomorphism(subgroup_generated G s,H) f`;;\n\nlet GROUP_HOMOMORPHISM_BETWEEN_SUBGROUPS = `!G H g h (f:A->B).\n group_homomorphism(G,H) f /\\ IMAGE f g SUBSET h\n ==> group_homomorphism(subgroup_generated G g,subgroup_generated H h) f`;;\n\nlet GROUP_HOMOMORPHISM_BETWEEN_SUBGROUPS_ALT = `!G H g h (f:A->B).\n group_homomorphism(G,H) f /\\ IMAGE f (group_carrier G INTER g) SUBSET h\n ==> group_homomorphism(subgroup_generated G g,subgroup_generated H h) f`;;\n\nlet GROUP_MONOMORPHISM_FROM_SUBGROUP_GENERATED = `!(f:A->B) G H s.\n group_monomorphism (G,H) f\n ==> group_monomorphism(subgroup_generated G s,H) f`;;\n\nlet GROUP_MONOMORPHISM_BETWEEN_SUBGROUPS = `!G H s t (f:A->B).\n group_monomorphism(G,H) f /\\ IMAGE f s SUBSET t\n ==> group_monomorphism(subgroup_generated G s,subgroup_generated H t) f`;;\n\nlet GROUP_MONOMORPHISM_INTO_SUPERGROUP = `!G G' t (f:A->B).\n group_monomorphism(G,subgroup_generated G' t) f\n ==> group_monomorphism(G,G') f`;;\n\nlet GROUP_HOMOMORPHISM_INCLUSION = `!G s:A->bool. group_homomorphism(subgroup_generated G s,G) (\\x. x)`;;\n\nlet GROUP_MONOMORPHISM_INCLUSION = `!G s:A->bool. group_monomorphism(subgroup_generated G s,G) (\\x. x)`;;\n\nlet SUBGROUP_GENERATED_BY_HOMOMORPHIC_IMAGE = `!G H (f:A->B) s.\n group_homomorphism(G,H) f /\\ s SUBSET group_carrier G\n ==> group_carrier (subgroup_generated H (IMAGE f s)) =\n IMAGE f (group_carrier(subgroup_generated G s))`;;\n\nlet SUBGROUP_GENERATED_BY_HOMOMORPHIC_IMAGE_EQ = `!G H s t (f:A->B).\n group_homomorphism (G,H) f /\\\n s SUBSET group_carrier G /\\\n t SUBSET group_carrier G /\\\n subgroup_generated G s = subgroup_generated G t\n ==> subgroup_generated H (IMAGE f s) =\n subgroup_generated H (IMAGE f t)`;;\n\nlet SUBGROUP_GENERATED_BY_EPIMORPHIC_IMAGE = `!G H s (f:A->B).\n group_epimorphism (G,H) f /\\\n s SUBSET group_carrier G /\\\n subgroup_generated G s = G\n ==> subgroup_generated H (IMAGE f s) = H`;;\n\nlet GROUP_EPIMORPHISM_BETWEEN_SUBGROUPS = `!G H (f:A->B).\n group_homomorphism(G,H) f /\\ s SUBSET group_carrier G\n ==> group_epimorphism(subgroup_generated G s,\n subgroup_generated H (IMAGE f s)) f`;;\n\nlet GROUP_EPIMORPHISM_INTO_SUBGROUP_EQ_GEN = `!(f:A->B) G H s.\n group_epimorphism(G,subgroup_generated H s) f <=>\n group_homomorphism(G,H) f /\\\n IMAGE f (group_carrier G) = group_carrier(subgroup_generated H s)`;;\n\nlet GROUP_EPIMORPHISM_INTO_SUBGROUP_EQ = `!G G' h (f:A->B).\n h subgroup_of G'\n ==> (group_epimorphism (G,subgroup_generated G' h) f <=>\n group_homomorphism (G,G') f /\\\n IMAGE f (group_carrier G) = h)`;;\n\nlet GROUP_ISOMORPHISM = `!G G' f:A->B.\n group_isomorphism (G,G') (f:A->B) <=>\n group_homomorphism (G,G') f /\\\n IMAGE f (group_carrier G) = group_carrier G' /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G /\\ f x = f y\n ==> x = y)`;;\n\nlet GROUP_ISOMORPHISM_SUBSET = `!G G' f:A->B.\n group_isomorphism (G,G') (f:A->B) <=>\n group_homomorphism (G,G') f /\\\n (!z. z IN group_carrier G' ==> ?x. x IN group_carrier G /\\ f x = z) /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G /\\ f x = f y\n ==> x = y)`;;\n\nlet SUBGROUP_OF_HOMOMORPHIC_IMAGE = `!G G' (f:A->B).\n group_homomorphism (G,G') f /\\ h subgroup_of G\n ==> IMAGE f h subgroup_of G'`;;\n\nlet SUBGROUP_OF_HOMOMORPHIC_PREIMAGE = `!G H (f:A->B) h.\n group_homomorphism(G,H) f /\\ h subgroup_of H\n ==> {x | x IN group_carrier G /\\ f x IN h} subgroup_of G`;;\n\nlet SUBGROUP_OF_EPIMORPHIC_PREIMAGE = `!G H (f:A->B) h.\n group_epimorphism(G,H) f /\\ h subgroup_of H\n ==> {x | x IN group_carrier G /\\ f x IN h} subgroup_of G /\\\n IMAGE f {x | x IN group_carrier G /\\ f x IN h} = h`;;\n\nlet GROUP_MONOMORPHISM_EPIMORPHISM = `!G G' f:A->B.\n group_monomorphism (G,G') f /\\ group_epimorphism (G,G') f <=>\n group_isomorphism (G,G') f`;;\n\nlet GROUP_ISOMORPHISM_EPIMORPHISM = `!G G' (f:A->B).\n group_isomorphism (G,G') f <=>\n group_epimorphism (G,G') f /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G /\\ f x = f y\n ==> x = y)`;;\n\nlet SUBGROUP_MONOMORPHISM_EPIMORPHISM = `!G G' s (f:A->B).\n group_monomorphism(G,G') f /\\\n group_epimorphism(G,subgroup_generated G' s) f <=>\n group_isomorphism(G,subgroup_generated G' s) f`;;\n\nlet GROUP_ISOMORPHISM_IMP_MONOMORPHISM = `!G G' (f:A->B).\n group_isomorphism (G,G') f ==> group_monomorphism (G,G') f`;;\n\nlet GROUP_ISOMORPHISM_IMP_EPIMORPHISM = `!G G' (f:A->B).\n group_isomorphism (G,G') f ==> group_epimorphism (G,G') f`;;\n\nlet GROUP_MONOMORPHISM_IMP_HOMOMORPHISM = `!(f:A->B) G H. group_monomorphism(G,H) f ==> group_homomorphism(G,H) f`;;\n\nlet GROUP_EPIMORPHISM_IMP_HOMOMORPHISM = `!(f:A->B) G H. group_epimorphism(G,H) f ==> group_homomorphism(G,H) f`;;\n\nlet GROUP_ISOMORPHISM_IMP_HOMOMORPHISM = `!(f:A->B) G H. group_isomorphism(G,H) f ==> group_homomorphism(G,H) f`;;\n\nlet GROUP_AUTOMORPHISM_IMP_ENDOMORPHISM = `!G (f:A->A). group_automorphism G f ==> group_endomorphism G f`;;\n\nlet GROUP_ISOMORPHISM_EQ_MONOMORPHISM_FINITE = `!G H (f:A->B).\n FINITE(group_carrier G) /\\ FINITE(group_carrier H) /\\\n CARD(group_carrier G) = CARD(group_carrier H)\n ==> (group_isomorphism(G,H) f <=> group_monomorphism(G,H) f)`;;\n\nlet GROUP_ISOMORPHISM_EQ_EPIMORPHISM_FINITE = `!G H (f:A->B).\n FINITE(group_carrier G) /\\ FINITE(group_carrier H) /\\\n CARD(group_carrier G) = CARD(group_carrier H)\n ==> (group_isomorphism(G,H) f <=> group_epimorphism(G,H) f)`;;\n\nlet GROUP_ISOMORPHISMS_CONJUGATION = `!G a:A.\n a IN group_carrier G\n ==> group_isomorphisms (G,G)\n (group_conjugation G a,group_conjugation G (group_inv G a))`;;\n\nlet GROUP_AUTOMORPHISM_CONJUGATION = `!G a:A.\n a IN group_carrier G ==> group_automorphism G (group_conjugation G a)`;;\n\nlet GROUP_ISOMORPHISM_CONJUGATION = `!G a:A. a IN group_carrier G\n ==> group_isomorphism (G,G) (group_conjugation G a)`;;\n\nlet GROUP_HOMOMORPHISM_CONJUGATION = `!G a:A. a IN group_carrier G\n ==> group_homomorphism (G,G) (group_conjugation G a)`;;\n\nlet CARD_LE_GROUP_MONOMORPHIC_IMAGE = `!G H (f:A->B).\n group_monomorphism(G,H) f ==> group_carrier G <=_c group_carrier H`;;\n\nlet CARD_LE_GROUP_EPIMORPHIC_IMAGE = `!G H (f:A->B).\n group_epimorphism(G,H) f ==> group_carrier H <=_c group_carrier G`;;\n\nlet CARD_EQ_GROUP_ISOMORPHIC_IMAGE = `!G H (f:A->B).\n group_isomorphism(G,H) f ==> group_carrier G =_c group_carrier H`;;\n\nlet FINITE_GROUP_MONOMORPHIC_PREIMAGE = `!G H (f:A->B).\n group_monomorphism(G,H) f /\\ FINITE(group_carrier H)\n ==> FINITE(group_carrier G)`;;\n\nlet FINITE_GROUP_EPIMORPHIC_IMAGE = `!G H (f:A->B).\n group_epimorphism(G,H) f /\\ FINITE(group_carrier G)\n ==> FINITE(group_carrier H)`;;\n\nlet CARD_EQ_GROUP_MONOMORPHIC_IMAGE = `!G H (f:A->B).\n group_monomorphism(G,H) f\n ==> IMAGE f (group_carrier G) =_c group_carrier G`;;\n\nlet GROUP_ISOMORPHISMS_BETWEEN_SUBGROUPS = `!G H g h (f:A->B) f'.\n group_isomorphisms(G,H) (f,f') /\\\n IMAGE f g SUBSET h /\\ IMAGE f' h SUBSET g\n ==> group_isomorphisms (subgroup_generated G g,subgroup_generated H h)\n (f,f')`;;\n\nlet GROUP_ISOMORPHISMS_BETWEEN_SUBGROUPS_ALT = `!G H g h (f:A->B) f'.\n group_isomorphisms(G,H) (f,f') /\\\n IMAGE f (group_carrier G INTER g) SUBSET h /\\\n IMAGE f' (group_carrier H INTER h) SUBSET g\n ==> group_isomorphisms (subgroup_generated G g,subgroup_generated H h)\n (f,f')`;;\n\nlet GROUP_ISOMORPHISM_BETWEEN_SUBGROUPS = `!G H g h (f:A->B).\n group_isomorphism(G,H) f /\\ g SUBSET group_carrier G /\\ IMAGE f g = h\n ==> group_isomorphism(subgroup_generated G g,subgroup_generated H h) f`;;\n\nlet GROUP_ISOMORPHISMS_COMPOSE = `!G1 G2 G3 (f1:A->B) (f2:B->C) g1 g2.\n group_isomorphisms(G1,G2) (f1,g1) /\\ group_isomorphisms(G2,G3) (f2,g2)\n ==> group_isomorphisms(G1,G3) (f2 o f1,g1 o g2)`;;\n\nlet GROUP_ISOMORPHISM_COMPOSE = `!G1 G2 G3 (f:A->B) (g:B->C).\n group_isomorphism(G1,G2) f /\\ group_isomorphism(G2,G3) g\n ==> group_isomorphism(G1,G3) (g o f)`;;\n\nlet GROUP_ISOMORPHISM_COMPOSE_REV = `!(f:A->B) (g:B->C) A B C.\n group_homomorphism(A,B) f /\\ group_homomorphism(B,C) g /\\\n group_isomorphism(A,C) (g o f)\n ==> group_monomorphism(A,B) f /\\ group_epimorphism(B,C) g`;;\n\nlet GROUP_EPIMORPHISM_ISOMORPHISM_COMPOSE_REV = `!(f:A->B) (g:B->C) A B C.\n group_epimorphism (A,B) f /\\\n group_homomorphism (B,C) g /\\\n group_isomorphism (A,C) (g o f)\n ==> group_isomorphism (A,B) f /\\ group_isomorphism (B,C) g`;;\n\nlet GROUP_MONOMORPHISM_ISOMORPHISM_COMPOSE_REV = `!(f:A->B) (g:B->C) A B C.\n group_homomorphism (A,B) f /\\\n group_monomorphism (B,C) g /\\\n group_isomorphism (A,C) (g o f)\n ==> group_isomorphism (A,B) f /\\ group_isomorphism (B,C) g`;;\n\nlet GROUP_ISOMORPHISM_INVERSE = `!(f:A->B) g G H.\n group_isomorphism(G,H) f /\\\n (!x. x IN group_carrier G ==> g(f x) = x)\n ==> group_isomorphism(H,G) g`;;\n\nlet GROUP_ISOMORPHISMS_OPPOSITE_GROUP = `!G:A group.\n group_isomorphisms(G,opposite_group G) (group_inv G,group_inv G)`;;\n\nlet GROUP_ISOMORPHISM_OPPOSITE_GROUP = `!G:A group.\n group_isomorphism(G,opposite_group G) (group_inv G)`;;\n\nlet GROUP_HOMOMORPHISM_FROM_TRIVIAL_GROUP = `!(f:A->B) G H.\n trivial_group G\n ==> (group_homomorphism(G,H) f <=> f(group_id G) = group_id H)`;;\n\nlet GROUP_MONOMORPHISM_FROM_TRIVIAL_GROUP = `!(f:A->B) G H.\n trivial_group G\n ==> (group_monomorphism (G,H) f <=> group_homomorphism (G,H) f)`;;\n\nlet GROUP_MONOMORPHISM_TO_TRIVIAL_GROUP = `!(f:A->B) G H.\n trivial_group H\n ==> (group_monomorphism (G,H) f <=>\n group_homomorphism (G,H) f /\\ trivial_group G)`;;\n\nlet GROUP_EPIMORPHISM_FROM_TRIVIAL_GROUP = `!(f:A->B) G H.\n trivial_group G\n ==> (group_epimorphism (G,H) f <=>\n group_homomorphism (G,H) f /\\ trivial_group H)`;;\n\nlet GROUP_EPIMORPHISM_TO_TRIVIAL_GROUP = `!(f:A->B) G H.\n trivial_group H\n ==> (group_epimorphism (G,H) f <=>\n group_homomorphism (G,H) f)`;;\n\nlet GROUP_HOMOMORPHISM_PAIRWISE = `!(f:A->B#C) G H K.\n group_homomorphism(G,prod_group H K) f <=>\n group_homomorphism(G,H) (FST o f) /\\\n group_homomorphism(G,K) (SND o f)`;;\n\nlet GROUP_HOMOMORPHISM_PAIRED = `!(f:A->B) (g:A->C) G H K.\n group_homomorphism(G,prod_group H K) (\\x. f x,g x) <=>\n group_homomorphism(G,H) f /\\\n group_homomorphism(G,K) g`;;\n\nlet GROUP_HOMOMORPHISM_PAIRED2 = `!(f:A->B) (g:C->D) G H G' H'.\n group_homomorphism(prod_group G H,prod_group G' H')\n (\\(x,y). f x,g y) <=>\n group_homomorphism(G,G') f /\\ group_homomorphism(H,H') g`;;\n\nlet GROUP_ISOMORPHISMS_PAIRED2 = `!(f:A->B) (g:C->D) f' g' G H G' H'.\n group_isomorphisms(prod_group G H,prod_group G' H')\n ((\\(x,y). f x,g y),(\\(x,y). f' x,g' y)) <=>\n group_isomorphisms(G,G') (f,f') /\\\n group_isomorphisms(H,H') (g,g')`;;\n\nlet GROUP_ISOMORPHISM_PAIRED2 = `!(f:A->B) (g:C->D) G H G' H'.\n group_isomorphism(prod_group G H,prod_group G' H')\n (\\(x,y). f x,g y) <=>\n group_isomorphism(G,G') f /\\ group_isomorphism(H,H') g`;;\n\nlet GROUP_HOMOMORPHISM_OF_FST = `!(f:A->C) A (B:B group) C.\n group_homomorphism (prod_group A B,C) (f o FST) <=>\n group_homomorphism (A,C) f`;;\n\nlet GROUP_HOMOMORPHISM_OF_SND = `!(f:B->C) (A:A group) B C.\n group_homomorphism (prod_group A B,C) (f o SND) <=>\n group_homomorphism (B,C) f`;;\n\nlet GROUP_EPIMORPHISM_OF_FST = `!(f:A->C) A (B:B group) C.\n group_epimorphism (prod_group A B,C) (f o FST) <=>\n group_epimorphism (A,C) f`;;\n\nlet GROUP_EPIMORPHISM_OF_SND = `!(f:B->C) (A:A group) B C.\n group_epimorphism (prod_group A B,C) (f o SND) <=>\n group_epimorphism (B,C) f`;;\n\nlet GROUP_HOMOMORPHISM_FST = `!(A:A group) (B:B group). group_homomorphism (prod_group A B,A) FST`;;\n\nlet GROUP_HOMOMORPHISM_SND = `!(A:A group) (B:B group). group_homomorphism (prod_group A B,B) SND`;;\n\nlet GROUP_EPIMORPHISM_FST = `!(A:A group) (B:B group). group_epimorphism (prod_group A B,A) FST`;;\n\nlet GROUP_EPIMORPHISM_SND = `!(A:A group) (B:B group). group_epimorphism (prod_group A B,B) SND`;;\n\nlet GROUP_ISOMORPHISM_FST = `!(G:A group) (H:B group).\n group_isomorphism (prod_group G H,G) FST <=> trivial_group H`;;\n\nlet GROUP_ISOMORPHISM_SND = `!(G:A group) (H:B group).\n group_isomorphism (prod_group G H,H) SND <=> trivial_group G`;;\n\nlet GROUP_ISOMORPHISMS_PROD_GROUP_SWAP = `!(G:A group) (H:B group).\n group_isomorphisms (prod_group G H,prod_group H G)\n ((\\(x,y). y,x),(\\(y,x). x,y))`;;\n\nlet GROUP_HOMOMORPHISM_COMPONENTWISE = `!G k H (f:A->K->B).\n group_homomorphism(G,product_group k H) f <=>\n IMAGE f (group_carrier G) SUBSET EXTENSIONAL k /\\\n !i. i IN k ==> group_homomorphism (G,H i) (\\x. f x i)`;;\n\nlet GROUP_HOMOMORPHISM_COMPONENTWISE_UNIV = `!G H (f:A->K->B).\n group_homomorphism(G,product_group (:K) H) f <=>\n !i. group_homomorphism (G,H i) (\\x. f x i)`;;\n\nlet GROUP_HOMOMORPHISM_PRODUCT_PROJECTION = `!(G:K->A group) k i.\n i IN k ==> group_homomorphism (product_group k G,G i) (\\x. x i)`;;\n\nlet GROUP_HOMOMORPHISM_SUM_PROJECTION = `!(G:K->A group) k i.\n i IN k ==> group_homomorphism (sum_group k G,G i) (\\x. x i)`;;\n\nlet GROUP_HOMOMORPHISM_PRODUCT_INJECTION = `!k (G:K->A group) i.\n group_homomorphism\n (G i,product_group k G)\n (\\a. RESTRICTION k (\\j. if j = i then a else group_id(G j)))`;;\n\nlet GROUP_HOMOMORPHISM_SUM_INJECTION = `!k (G:K->A group) i.\n group_homomorphism\n (G i,sum_group k G)\n (\\a. RESTRICTION k (\\j. if j = i then a else group_id(G j)))`;;\n\nlet GROUP_HOMOMORPHISM_PRODUCT = `!(f:K->A->B) k G H.\n group_homomorphism (product_group k G,product_group k H)\n (\\x. RESTRICTION k (\\i. (f i) (x i))) <=>\n !i. i IN k ==> group_homomorphism(G i,H i) (f i)`;;\n\nlet GROUP_HOMOMORPHISM_SUM = `!(f:K->A->B) k G H.\n group_homomorphism (sum_group k G,sum_group k H)\n (\\x. RESTRICTION k (\\i. (f i) (x i))) <=>\n !i. i IN k ==> group_homomorphism(G i,H i) (f i)`;;\n\nlet GROUP_EPIMORPHISM_PRODUCT_PROJECTION = `!(G:K->A group) k i.\n i IN k ==> group_epimorphism (product_group k G,G i) (\\x. x i)`;;\n\nlet GROUP_ISOMORPHISM_PRODUCT_PROJECTION = `!G k. group_isomorphism (product_group {k} G,G k) (\\x. x k)`;;\n\nlet GROUP_EPIMORPHISM_SUM_PROJECTION = `!(G:K->A group) k i.\n i IN k ==> group_epimorphism (sum_group k G,G i) (\\x. x i)`;;\n\nlet GROUP_ISOMORPHISM_SUM_PROJECTION = `!G k. group_isomorphism (sum_group {k} G,G k) (\\x. x k)`;;\n\nlet ABELIAN_GROUP_EPIMORPHIC_IMAGE = `!G H (f:A->B).\n group_epimorphism(G,H) f /\\ abelian_group G ==> abelian_group H`;;\n\nlet ABELIAN_GROUP_HOMOMORPHISM_GROUP_MUL = `!(f:A->B) g A B.\n abelian_group B /\\\n group_homomorphism(A,B) f /\\ group_homomorphism(A,B) g\n ==> group_homomorphism(A,B) (\\x. group_mul B (f x) (g x))`;;\n\nlet ABELIAN_GROUP_HOMOMORPHISM_INVERSION = `!G:A group. group_homomorphism (G,G) (group_inv G) <=> abelian_group G`;;\n\nlet ABELIAN_GROUP_ISOMORPHISMS_INVERSION = `!G:A group. group_isomorphisms (G,G) (group_inv G,group_inv G) <=>\n abelian_group G`;;\n\nlet ABELIAN_GROUP_ISOMORPHISM_INVERSION = `!G:A group. group_isomorphism (G,G) (group_inv G) <=> abelian_group G`;;\n\nlet ABELIAN_GROUP_MONOMORPHISM_INVERSION = `!G:A group. group_monomorphism (G,G) (group_inv G) <=> abelian_group G`;;\n\nlet ABELIAN_GROUP_EPIMORPHISM_INVERSION = `!G:A group. group_epimorphism (G,G) (group_inv G) <=> abelian_group G`;;\n\nlet ABELIAN_GROUP_HOMOMORPHISM_POWERING = `!(G:A group) n.\n abelian_group G ==> group_homomorphism(G,G) (\\x. group_pow G x n)`;;\n\nlet ABELIAN_GROUP_HOMOMORPHISM_ZPOWERING = `!(G:A group) n.\n abelian_group G ==> group_homomorphism(G,G) (\\x. group_zpow G x n)`;;\n\nparse_as_infix(\"isomorphic_group\",(12, \"right\"));;\n\nlet isomorphic_group = new_definition\n `G isomorphic_group G' <=> ?f:A->B. group_isomorphism (G,G') f`;;\n\nlet GROUP_ISOMORPHISM_IMP_ISOMORPHIC = `!G H f:A->B. group_isomorphism (G,H) f ==> G isomorphic_group H`;;\n\nlet ISOMORPHIC_PRODUCT_GROUP_SING = `!(G:K->A group) k. product_group {k} G isomorphic_group G k`;;\n\nlet ISOMORPHIC_SUM_GROUP_SING = `!(G:K->A group) k. sum_group {k} G isomorphic_group G k`;;\n\nlet ISOMORPHIC_GROUP_REFL = `!G:A group. G isomorphic_group G`;;\n\nlet ISOMORPHIC_GROUP_SYM = `!(G:A group) (H:B group). G isomorphic_group H <=> H isomorphic_group G`;;\n\nlet ISOMORPHIC_GROUP_TRANS = `!(G1:A group) (G2:B group) (G3:C group).\n G1 isomorphic_group G2 /\\ G2 isomorphic_group G3\n ==> G1 isomorphic_group G3`;;\n\nlet ISOMORPHIC_GROUP_OPPOSITE_GROUP = `!G:A group. (opposite_group G) isomorphic_group G`;;\n\nlet ISOMORPHIC_GROUP_TRIVIALITY = `!(G:A group) (H:B group).\n G isomorphic_group H ==> (trivial_group G <=> trivial_group H)`;;\n\nlet ISOMORPHIC_TO_TRIVIAL_GROUP = `(!(G:A group) (H:B group).\n trivial_group G ==> (G isomorphic_group H <=> trivial_group H)) /\\\n (!(G:A group) (H:B group).\n trivial_group H ==> (G isomorphic_group H <=> trivial_group G))`;;\n\nlet ISOMORPHIC_TRIVIAL_GROUPS = `!(G:A group) (H:B group).\n trivial_group G /\\ trivial_group H\n ==> G isomorphic_group H`;;\n\nlet ISOMORPHIC_GROUP_SINGLETON_GROUP = `(!(G:A group) (b:B).\n G isomorphic_group singleton_group b <=> trivial_group G) /\\\n (!a:A (G:B group).\n singleton_group a isomorphic_group G <=> trivial_group G)`;;\n\nlet ISOMORPHIC_GROUP_PROD_GROUPS = `!(G:A group) (G':B group) (H:C group) (H':D group).\n G isomorphic_group G' /\\ H isomorphic_group H'\n ==> (prod_group G H) isomorphic_group (prod_group G' H')`;;\n\nlet ISOMORPHIC_GROUP_PROD_GROUP_SYM = `!(G:A group) (H:B group).\n prod_group G H isomorphic_group prod_group H G`;;\n\nlet ISOMORPHIC_GROUP_PROD_GROUP_SWAP_LEFT = `!(G:A group) (H:B group) (K:C group).\n prod_group G H isomorphic_group K <=>\n prod_group H G isomorphic_group K`;;\n\nlet ISOMORPHIC_GROUP_PROD_GROUP_SWAP_RIGHT = `!(G:A group) (H:B group) (K:C group).\n G isomorphic_group prod_group H K <=>\n G isomorphic_group prod_group K H`;;\n\nlet ISOMORPHIC_PROD_TRIVIAL_GROUP = `(!(G:A group) (H:B group).\n trivial_group G ==> (prod_group G H isomorphic_group H)) /\\\n (!(G:A group) (H:B group).\n trivial_group H ==> (prod_group G H isomorphic_group G)) /\\\n (!(G:A group) (H:B group).\n trivial_group G ==> (H isomorphic_group prod_group G H)) /\\\n (!(G:A group) (H:B group).\n trivial_group H ==> (G isomorphic_group prod_group G H))`;;\n\nlet ISOMORPHIC_PRODUCT_GROUP_SUPPORT = `!k (G:K->A group).\n product_group {i | i IN k /\\ ~trivial_group(G i)} G isomorphic_group\n product_group k G`;;\n\nlet ISOMORPHIC_PRODUCT_GROUP_SYMDIFF = `!k l (G:K->A group).\n (!i. i IN (k DIFF l) UNION (l DIFF k) ==> trivial_group(G i))\n ==> product_group k G isomorphic_group product_group l G`;;\n\nlet ISOMORPHIC_SUM_GROUP_SUPPORT = `!k (G:K->A group).\n sum_group {i | i IN k /\\ ~trivial_group(G i)} G isomorphic_group\n sum_group k G`;;\n\nlet ISOMORPHIC_SUM_GROUP_SYMDIFF = `!k l (G:K->A group).\n (!i. i IN (k DIFF l) UNION (l DIFF k) ==> trivial_group(G i))\n ==> sum_group k G isomorphic_group sum_group l G`;;\n\nlet ISOMORPHIC_PRODUCT_GROUP_BIJECTIONS,ISOMORPHIC_SUM_GROUP_BIJECTIONS =\n (CONJ_PAIR o prove)\n (`(!s (G:K->A group) t (H:L->B group) f g.\n (!x. x IN s ==> f(x) IN t /\\ g(f x) = x) /\\\n (!y. y IN t ==> g(y) IN s /\\ f(g y) = y) /\\\n (!i. i IN s ==> (G i) isomorphic_group H(f i))\n ==> product_group s G isomorphic_group product_group t H) /\\\n (!s (G:K->A group) t (H:L->B group) f g.\n (!x. x IN s ==> f(x) IN t /\\ g(f x) = x) /\\\n (!y. y IN t ==> g(y) IN s /\\ f(g y) = y) /\\\n (!i. i IN s ==> (G i) isomorphic_group H(f i))\n ==> sum_group s G isomorphic_group sum_group t H)`,\n CONJ_TAC THEN REPEAT GEN_TAC THEN\n REPLICATE_TAC 2 (DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC MP_TAC)) THEN\n REWRITE_TAC[isomorphic_group; group_isomorphism] THEN\n GEN_REWRITE_TAC (LAND_CONV o TOP_DEPTH_CONV) [RIGHT_IMP_EXISTS_THM] THEN\n REWRITE_TAC[SKOLEM_THM; LEFT_IMP_EXISTS_THM] THEN\n MAP_EVERY X_GEN_TAC [`h:K->A->B`; `k:K->B->A`] THEN\n GEN_REWRITE_TAC (LAND_CONV o TOP_DEPTH_CONV)\n [group_isomorphisms; FORALL_AND_THM;\n TAUT `p ==> q /\\ r <=> (p ==> q) /\\ (p ==> r)`] THEN\n STRIP_TAC THEN\n MAP_EVERY EXISTS_TAC\n [`\\(x:K->A). RESTRICTION t (\\j:L. (h:K->A->B) (g j) (x (g j)))`;\n `\\(y:L->B). RESTRICTION s (\\i:K. (k:K->B->A) i (y (f i)))`] THEN\n REWRITE_TAC[SUM_GROUP_ALT] THENL\n [ALL_TAC;\n MATCH_MP_TAC GROUP_ISOMORPHISMS_BETWEEN_SUBGROUPS_ALT THEN\n CONJ_TAC THENL\n [ALL_TAC;\n REWRITE_TAC[SUBSET; FORALL_IN_IMAGE; IN_ELIM_THM] THEN\n SIMP_TAC[GSYM NOT_IMP; RESTRICTION] THEN\n REWRITE_TAC[NOT_IMP; IN_INTER; PRODUCT_GROUP] THEN\n REWRITE_TAC[IN_CARTESIAN_PRODUCT; IN_ELIM_THM] THEN\n CONJ_TAC THENL [X_GEN_TAC `x:K->A`; X_GEN_TAC `y:L->B`] THEN\n DISCH_THEN(CONJUNCTS_THEN2 STRIP_ASSUME_TAC MP_TAC) THEN\n MATCH_MP_TAC(MESON[FINITE_IMAGE; FINITE_SUBSET]\n `!f. t SUBSET IMAGE f s ==> FINITE s ==> FINITE t`)\n THENL [EXISTS_TAC `f:K->L`; EXISTS_TAC `g:L->K`] THEN\n RULE_ASSUM_TAC(REWRITE_RULE[group_homomorphism]) THEN\n ASM SET_TAC[]]] THEN\n (REWRITE_TAC[group_isomorphisms] THEN\n REWRITE_TAC[RESTRICTION_EXTENSION; PRODUCT_GROUP; FORALL_IN_GSPEC;\n IMP_CONJ; SUM_GROUP_CLAUSES; CARTESIAN_PRODUCT_AS_RESTRICTIONS] THEN\n ASM_SIMP_TAC[RESTRICTION] THEN\n REWRITE_TAC[GROUP_HOMOMORPHISM_COMPONENTWISE] THEN\n REWRITE_TAC[SUBSET; FORALL_IN_IMAGE; PRODUCT_GROUP] THEN\n REWRITE_TAC[RESTRICTION_IN_EXTENSIONAL] THEN SIMP_TAC[RESTRICTION] THEN\n CONJ_TAC THENL [X_GEN_TAC `j:L`; X_GEN_TAC `i:K`] THEN\n DISCH_TAC THEN GEN_REWRITE_TAC RAND_CONV [GSYM o_DEF] THEN\n MATCH_MP_TAC GROUP_HOMOMORPHISM_COMPOSE THENL\n [EXISTS_TAC `(G:K->A group) (g(j:L))`;\n EXISTS_TAC `(H:L->B group) (f(i:K))`] THEN\n ASM_SIMP_TAC[GROUP_HOMOMORPHISM_PRODUCT_PROJECTION] THEN\n ASM_MESON_TAC[]));;\n\nlet ISOMORPHIC_GROUP_PRODUCT_GROUP = `!(G:K->A group) (H:K->B group) k.\n (!i. i IN k ==> (G i) isomorphic_group (H i))\n ==> (product_group k G) isomorphic_group (product_group k H)`;;\n\nlet ISOMORPHIC_GROUP_SUM_GROUP = `!(G:K->A group) (H:K->B group) k.\n (!i. i IN k ==> (G i) isomorphic_group (H i))\n ==> (sum_group k G) isomorphic_group (sum_group k H)`;;\n\nlet GROUP_ISOMORPHISMS_PRODUCT_GROUP_DISJOINT_UNION = `!(f:K->A group) k l.\n DISJOINT k l\n ==> group_isomorphisms\n (product_group (k UNION l) f,\n prod_group (product_group k f) (product_group l f))\n ((\\f. RESTRICTION k f,RESTRICTION l f),\n (\\(f,g) x. if x IN k then f x else g x))`;;\n\nlet GROUP_ISOMORPHISMS_SUM_GROUP_DISJOINT_UNION = `!(f:K->A group) k l.\n DISJOINT k l\n ==> group_isomorphisms\n (sum_group (k UNION l) f,\n prod_group (sum_group k f) (sum_group l f))\n ((\\f. RESTRICTION k f,RESTRICTION l f),\n (\\(f,g) x. if x IN k then f x else g x))`;;\n\nlet GROUP_ISOMORPHISM_PRODUCT_GROUP_DISJOINT_UNION = `!(f:K->A group) k l.\n DISJOINT k l\n ==> group_isomorphism\n (product_group (k UNION l) f,\n prod_group (product_group k f) (product_group l f))\n (\\f. RESTRICTION k f,RESTRICTION l f)`;;\n\nlet GROUP_ISOMORPHISM_SUM_GROUP_DISJOINT_UNION = `!(f:K->A group) k l.\n DISJOINT k l\n ==> group_isomorphism\n (sum_group (k UNION l) f,\n prod_group (sum_group k f) (sum_group l f))\n (\\f. RESTRICTION k f,RESTRICTION l f)`;;\n\nlet ISOMORPHIC_PRODUCT_GROUP_DISJOINT_UNION = `!(f:K->A group) k l.\n DISJOINT k l\n ==> product_group (k UNION l) f isomorphic_group\n prod_group (product_group k f) (product_group l f)`;;\n\nlet ISOMORPHIC_SUM_GROUP_DISJOINT_UNION = `!(f:K->A group) k l.\n DISJOINT k l\n ==> sum_group (k UNION l) f isomorphic_group\n prod_group (sum_group k f) (sum_group l f)`;;\n\nlet ISOMORPHIC_PRODUCT_GROUP_INSERT = `!(f:K->A group) i k.\n ~(i IN k)\n ==> product_group (i INSERT k) f isomorphic_group\n prod_group (f i) (product_group k f)`;;\n\nlet ISOMORPHIC_SUM_GROUP_INSERT = `!(f:K->A group) i k.\n ~(i IN k)\n ==> sum_group (i INSERT k) f isomorphic_group\n prod_group (f i) (sum_group k f)`;;\n\nlet ISOMORPHIC_GROUP_CARD_EQ = `!(G:A group) (H:B group).\n G isomorphic_group H ==> group_carrier G =_c group_carrier H`;;\n\nlet ISOMORPHIC_GROUP_FINITENESS = `!(G:A group) (H:B group).\n G isomorphic_group H\n ==> (FINITE(group_carrier G) <=> FINITE(group_carrier H))`;;\n\nlet ISOMORPHIC_GROUP_INFINITENESS = `!(G:A group) (H:B group).\n G isomorphic_group H\n ==> (INFINITE(group_carrier G) <=> INFINITE(group_carrier H))`;;\n\nlet ISOMORPHIC_GROUP_HAS_ORDER = `!(G:A group) (H:B group) n.\n G isomorphic_group H\n ==> (group_carrier G HAS_SIZE n <=> group_carrier H HAS_SIZE n)`;;\n\nlet ISOMORPHIC_GROUP_ORDER = `!(G:A group) (H:B group).\n G isomorphic_group H /\\\n (FINITE(group_carrier G) \\/ FINITE(group_carrier H))\n ==> CARD(group_carrier G) = CARD(group_carrier H)`;;\n\nlet ISOMORPHIC_GROUP_ABELIANNESS = `!(G:A group) (H:B group).\n G isomorphic_group H ==> (abelian_group G <=> abelian_group H)`;;\n\nlet CREATE_ISOMORPHIC_COPY_OF_GROUP = `!(f:A->B) g G s z i m.\n z IN s /\\\n (!x. x IN group_carrier G ==> f x IN s /\\ g(f x) = x) /\\\n (!y. y IN s ==> g y IN group_carrier G /\\ f(g y) = y) /\\\n g z = group_id G /\\\n (!x. x IN s ==> i x = f(group_inv G (g x))) /\\\n (!x y. x IN s /\\ y IN s ==> m x y = f(group_mul G (g x) (g y)))\n ==> group_isomorphisms (G,group(s,z,i,m)) (f,g) /\\\n group_carrier (group(s,z,i,m)) = s /\\\n group_id (group(s,z,i,m)) = z /\\\n group_inv (group(s,z,i,m)) = i /\\\n group_mul (group(s,z,i,m)) = m`;;\n\nlet ISOMORPHIC_COPY_OF_GROUP = `!(G:A group) (s:B->bool).\n (?G'. group_carrier G' = s /\\ G isomorphic_group G') <=>\n group_carrier G =_c s`;;\n\nlet GROUP_DIRECT_LIMIT = `!c:(A group->bool).\n ~(c = {}) /\\\n (!g g'. g IN c /\\ g' IN c\n ==> ?G. G IN c /\\\n group_monomorphism(g,G) I /\\\n group_monomorphism(g',G) I)\n ==> ?G. group_carrier G = UNIONS {group_carrier g | g IN c} /\\\n !g. g IN c ==> group_monomorphism(g,G) I`;;\n\nlet group_setinv = new_definition\n `group_setinv G g = {group_inv G x | x IN g}`;;\n\nlet group_setmul = new_definition\n `group_setmul G g h = {group_mul G x y | x IN g /\\ y IN h}`;;\n\nlet GROUP_SETINV_AS_IMAGE = `!G:A group. group_setinv G = IMAGE (group_inv G)`;;\n\nlet SUBGROUP_OF_SETWISE = `!G s:A->bool.\n s subgroup_of G <=>\n s SUBSET group_carrier G /\\\n group_id G IN s /\\\n group_setinv G s SUBSET s /\\\n group_setmul G s s SUBSET s`;;\n\nlet FINITE_SUBGROUP_OF_SETWISE = `!G s:A->bool.\n FINITE s\n ==> (s subgroup_of G <=>\n s SUBSET group_carrier G /\\\n ~(s = {}) /\\\n group_setmul G s s SUBSET s)`;;\n\nlet OPPOSITE_GROUP_SETINV = `!G s:A->bool.\n group_setinv (opposite_group G) s = group_setinv G s`;;\n\nlet OPPOSITE_GROUP_SETMUL = `!G s t:A->bool.\n group_setmul (opposite_group G) s t = group_setmul G t s`;;\n\nlet GROUP_SETINV_EQ_EMPTY = `!G g:A->bool. group_setinv G g = {} <=> g = {}`;;\n\nlet GROUP_SETMUL_EQ_EMPTY = `!G g h:A->bool. group_setmul G g h = {} <=> g = {} \\/ h = {}`;;\n\nlet GROUP_SETMUL_EMPTY = `(!G s:A->bool. group_setmul G s {} = {}) /\\\n (!G t:A->bool. group_setmul G {} t = {})`;;\n\nlet GROUP_SETINV_MONO = `!G s s':A->bool.\n s SUBSET s' ==> group_setinv G s SUBSET group_setinv G s'`;;\n\nlet GROUP_SETMUL_MONO = `!G s t s' t':A->bool.\n s SUBSET s' /\\ t SUBSET t'\n ==> group_setmul G s t SUBSET group_setmul G s' t'`;;\n\nlet GROUP_SETMUL_INC_GEN = `(!G s t:A->bool.\n group_id G IN s /\\ t SUBSET group_carrier G\n ==> t SUBSET group_setmul G s t) /\\\n (!G s t:A->bool.\n s SUBSET group_carrier G /\\ group_id G IN t\n ==> s SUBSET group_setmul G s t)`;;\n\nlet GROUP_SETMUL_INC = `(!G s t:A->bool.\n s subgroup_of G /\\ t subgroup_of G ==> t SUBSET group_setmul G s t) /\\\n (!G s t:A->bool.\n s subgroup_of G /\\ t subgroup_of G ==> s SUBSET group_setmul G s t)`;;\n\nlet FINITE_GROUP_SETMUL = `!G s t:A->bool.\n FINITE s /\\ FINITE t ==> FINITE(group_setmul G s t)`;;\n\nlet GROUP_SETMUL_SYM_ELEMENTWISE = `!G s t u:A->bool.\n (!a. a IN s ==> group_setmul G {a} t = group_setmul G u {a})\n ==> group_setmul G s t = group_setmul G u s`;;\n\nlet GROUP_SETINV_SING = `!G x:A. group_setinv G {x} = {group_inv G x}`;;\n\nlet GROUP_SETMUL_SING = `!G x y:A. group_setmul G {x} {y} = {group_mul G x y}`;;\n\nlet GROUP_SETINV = `!G g:A->bool.\n g SUBSET group_carrier G ==> group_setinv G g SUBSET group_carrier G`;;\n\nlet GROUP_SETMUL = `!G g h:A->bool.\n g SUBSET group_carrier G /\\ h SUBSET group_carrier G==>\n group_setmul G g h SUBSET group_carrier G`;;\n\nlet GROUP_SETMUL_LID = `!G g:A->bool.\n g SUBSET group_carrier G ==> group_setmul G {group_id G} g = g`;;\n\nlet GROUP_SETMUL_RID = `!G g:A->bool.\n g SUBSET group_carrier G ==> group_setmul G g {group_id G} = g`;;\n\nlet GROUP_SETMUL_ASSOC = `!G g h i:A->bool.\n g SUBSET group_carrier G /\\ h SUBSET group_carrier G /\\\n i SUBSET group_carrier G\n ==> group_setmul G g (group_setmul G h i) =\n group_setmul G (group_setmul G g h) i`;;\n\nlet GROUP_SETMUL_SYM = `!G g h:A->bool.\n abelian_group G /\\ g SUBSET group_carrier G /\\ h SUBSET group_carrier G\n ==> group_setmul G g h = group_setmul G h g`;;\n\nlet GROUP_SETINV_SUBGROUP = `!G h:A->bool. h subgroup_of G ==> group_setinv G h = h`;;\n\nlet GROUP_SETMUL_LSUBSET = `!G h s:A->bool.\n h subgroup_of G /\\ s SUBSET h /\\ ~(s = {}) ==> group_setmul G s h = h`;;\n\nlet GROUP_SETMUL_RSUBSET = `!G h s:A->bool.\n h subgroup_of G /\\ s SUBSET h /\\ ~(s = {}) ==> group_setmul G h s = h`;;\n\nlet GROUP_SETMUL_LSUBSET_EQ = `!G h s:A->bool.\n h subgroup_of G /\\ s SUBSET group_carrier G\n ==> (group_setmul G s h = h <=> s SUBSET h /\\ ~(s = {}))`;;\n\nlet GROUP_SETMUL_RSUBSET_EQ = `!G h s:A->bool.\n h subgroup_of G /\\ s SUBSET group_carrier G\n ==> (group_setmul G h s = h <=> s SUBSET h /\\ ~(s = {}))`;;\n\nlet IMAGE_GROUP_CONJUGATION = `!G (a:A) s.\n IMAGE (group_conjugation G a) s =\n group_setmul G {a} (group_setmul G s {group_inv G a})`;;\n\nlet IMAGE_GROUP_CONJUGATION_EQ = `!G (a:A) s t.\n a IN group_carrier G /\\\n s SUBSET group_carrier G /\\\n t SUBSET group_carrier G\n ==> (IMAGE (group_conjugation G a) s = t <=>\n group_setmul G {a} s = group_setmul G t {a})`;;\n\nlet GROUP_SETMUL_SUBGROUP = `!G h:A->bool.\n h subgroup_of G ==> group_setmul G h h = h`;;\n\nlet GROUP_SETMUL_LCANCEL = `!G g h x:A.\n x IN group_carrier G /\\\n g SUBSET group_carrier G /\\ h SUBSET group_carrier G\n ==> (group_setmul G {x} g = group_setmul G {x} h <=> g = h)`;;\n\nlet GROUP_SETMUL_RCANCEL = `!G g h x:A.\n x IN group_carrier G /\\ g SUBSET group_carrier G /\\\n h SUBSET group_carrier G\n ==> (group_setmul G g {x} = group_setmul G h {x} <=> g = h)`;;\n\nlet GROUP_SETMUL_LCANCEL_SET = `!G h x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\ h subgroup_of G\n ==> (group_setmul G h {x} = group_setmul G h {y} <=>\n group_div G x y IN h)`;;\n\nlet GROUP_SETMUL_RCANCEL_SET = `!G h x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\ h subgroup_of G\n ==> (group_setmul G {x} h = group_setmul G {y} h <=>\n group_mul G (group_inv G x) y IN h)`;;\n\nlet SUBGROUP_SETMUL_EQ = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> ((group_setmul G g h) subgroup_of G <=>\n group_setmul G g h = group_setmul G h g)`;;\n\nlet SUBGROUP_SETMUL = `!G g h:A->bool.\n abelian_group G /\\ g subgroup_of G /\\ h subgroup_of G\n ==> (group_setmul G g h) subgroup_of G`;;\n\nlet SUBGROUP_GENERATED_SETMUL = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> subgroup_generated G (group_setmul G g h) =\n subgroup_generated G (g UNION h)`;;\n\nlet CARRIER_SUBGROUP_GENERATED_UNION = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G /\\\n group_setmul G g h = group_setmul G h g\n ==> group_carrier(subgroup_generated G (g UNION h)) =\n group_setmul G g h`;;\n\nlet group_action = new_definition\n `group_action G s (a:A->X->X) <=>\n (!g x. g IN group_carrier G /\\ x IN s ==> a g x IN s) /\\\n (!x. x IN s ==> a (group_id G) x = x) /\\\n (!g h x. g IN group_carrier G /\\ h IN group_carrier G /\\ x IN s\n ==> a (group_mul G g h) x = a g (a h x))`;;\n\nlet GROUP_ACTION_ALT = `!G s (a:A->X->X).\n group_action G s (a:A->X->X) <=>\n (!g x. g IN group_carrier G /\\ x IN s ==> a g x IN s) /\\\n (!x. x IN s ==> a (group_id G) x = x) /\\\n (!g h x. g IN group_carrier G /\\ h IN group_carrier G /\\ x IN s\n ==> a g (a h x) = a (group_mul G g h) x)`;;\n\nlet GROUP_ACTION_MUL = `!G s (a:A->X->X) g h x.\n group_action G s a /\\\n g IN group_carrier G /\\\n h IN group_carrier G /\\\n x IN s\n ==> a g (a h x) = a (group_mul G g h) x`;;\n\nlet GROUP_ACTION_LINV = `!G s (a:A->X->X) g x.\n group_action G s a /\\ g IN group_carrier G /\\ x IN s\n ==> a (group_inv G g) (a g x) = x`;;\n\nlet GROUP_ACTION_RINV = `!G s (a:A->X->X) g x.\n group_action G s a /\\ g IN group_carrier G /\\ x IN s\n ==> a g (a (group_inv G g) x) = x`;;\n\nlet GROUP_ACTION_BIJECTIVE = `!G s (a:A->X->X) g.\n group_action G s a /\\ g IN group_carrier G\n ==> !y. y IN s ==> ?!x. x IN s /\\ a g x = y`;;\n\nlet GROUP_ACTION_SURJECTIVE = `!G s (a:A->X->X) g y.\n group_action G s a /\\ g IN group_carrier G /\\ y IN s\n ==> ?x. a g x = y`;;\n\nlet GROUP_ACTION_INJECTIVE = `!G s (a:A->X->X).\n group_action G s a /\\ g IN group_carrier G /\\ x IN s /\\ y IN s\n ==> (a g x = a g y <=> x = y)`;;\n\nlet GROUP_ACTION_ON_SUBSET = `!G s t (a:A->X->X).\n group_action G s a /\\\n t SUBSET s /\\\n (!g x. g IN group_carrier G /\\ x IN t ==> a g x IN t)\n ==> group_action G t a`;;\n\nlet GROUP_ACTION_FROM_SUBGROUP = `!G s h (a:A->X->X).\n group_action G s a ==> group_action (subgroup_generated G h) s a`;;\n\nlet GROUP_ACTIONS_EQ_ON_GENERATORS = time prove\n (`!G t s (a:A->X->X) a'.\n group_action G s a /\\\n group_action G s a' /\\\n (!g x. g IN group_carrier G /\\ g IN t /\\ x IN s ==> a g x = a' g x)\n ==> !g x. g IN group_carrier(subgroup_generated G t) /\\ x IN s\n ==> a g x = a' g x`,\n REWRITE_TAC[group_action] THEN\n REPEAT GEN_TAC THEN STRIP_TAC THEN\n REWRITE_TAC[IMP_CONJ; RIGHT_FORALL_IMP_THM] THEN\n MATCH_MP_TAC SUBGROUP_GENERATED_INDUCT_STRONG THEN\n ASM_SIMP_TAC[] THEN X_GEN_TAC `g:A` THEN STRIP_TAC THEN\n X_GEN_TAC `x:X` THEN DISCH_TAC THEN MATCH_MP_TAC(MESON[]\n `!f:X->X.\n (!x y. x IN s /\\ y IN s ==> (f x = f y <=> x = y)) /\\\n g a IN s /\\ h a IN s /\\ f(g a) = a /\\ f(h a) = a\n ==> g a = h a`) THEN\n EXISTS_TAC `(a:A->X->X) g` THEN\n CONJ_TAC THENL\n [REPEAT STRIP_TAC THEN MATCH_MP_TAC GROUP_ACTION_INJECTIVE THEN\n MAP_EVERY EXISTS_TAC [`G:A group`; `s:X->bool`] THEN\n ASM_REWRITE_TAC[group_action];\n ASM_MESON_TAC[GROUP_ID; GROUP_MUL; GROUP_INV; GROUP_MUL_RINV]]);;\n\nlet GROUP_ACTION_IMAGE = `!G u s (a:A->X->X).\n group_action G s a /\\\n (!t. t IN u ==> t SUBSET s) /\\\n (!g t. g IN group_carrier G /\\ t IN u ==> IMAGE (a g) t IN u)\n ==> group_action G u (IMAGE o a)`;;\n\nlet GROUP_ACTION_IMAGE_SIZED = `!G s k (a:A->X->X).\n group_action G s a\n ==> group_action G {t | t SUBSET s /\\ t HAS_SIZE k} (IMAGE o a)`;;\n\nlet group_stabilizer = new_definition\n `group_stabilizer G (a:A->X->X) x = {g | g IN group_carrier G /\\ a g x = x}`;;\n\nlet GROUP_STABILIZER_SUBSET_CARRIER = `!G a x. group_stabilizer G a x SUBSET group_carrier G`;;\n\nlet FINITE_GROUP_STABILIZER = `!G (a:A->X->X) x.\n FINITE(group_carrier G) ==> FINITE(group_stabilizer G a x)`;;\n\nlet SUBGROUP_OF_GROUP_STABILIZER = `!G s (a:A->X->X) x.\n group_action G s a /\\ x IN s ==> group_stabilizer G a x subgroup_of G`;;\n\nlet GROUP_STABILIZER_NONEMPTY = `!G (a:A->X->X) s x.\n group_action G s a /\\ x IN s ==> ~(group_stabilizer G a x = {})`;;\n\nlet GROUP_STABILIZER_SUBGROUP_GENERATED = `!G h (a:A->X->X) x.\n group_stabilizer (subgroup_generated G h) a x =\n group_carrier(subgroup_generated G h) INTER group_stabilizer G a x`;;\n\nlet GROUP_STABILIZER_ON_SUBGROUP = `!G h (a:A->X->X) x.\n h subgroup_of G\n ==> group_stabilizer (subgroup_generated G h) a x =\n h INTER group_stabilizer G a x`;;\n\nlet GROUP_ACTION_KERNEL_POINTWISE = `!G s (a:A->X->X).\n {g | g IN group_carrier G /\\ !x. x IN s ==> a g x = x} =\n if s = {} then group_carrier G\n else INTERS {group_stabilizer G a x | x IN s}`;;\n\nlet GROUP_ACTION_EQ = `!G s (a:A->X->X) g h x.\n group_action G s a /\\\n g IN group_carrier G /\\ h IN group_carrier G /\\\n x IN s\n ==> (a g x = a h x <=>\n group_mul G (group_inv G g) h IN group_stabilizer G a x)`;;\n\nlet GROUP_ACTION_FIBRES = `!G s (a:A->X->X) h x.\n group_action G s a /\\ h IN group_carrier G /\\ x IN s\n ==> {g | g IN group_carrier G /\\ (a:A->X->X) g x = a h x} =\n IMAGE (group_mul G h) (group_stabilizer G a x)`;;\n\nlet group_orbit = new_definition\n `group_orbit G s (a:A->X->X) x y <=>\n x IN s /\\ y IN s /\\ ?g. g IN group_carrier G /\\ a g x = y`;;\n\nlet GROUP_ORBIT_IN_SET = `!G s (a:A->X->X) x y.\n group_orbit G s a x y ==> x IN s /\\ y IN s`;;\n\nlet IN_GROUP_ORBIT = `!G s (a:A->X->X) x y.\n y IN group_orbit G s a x <=>\n x IN s /\\ y IN s /\\ ?g. g IN group_carrier G /\\ a g x = y`;;\n\nlet GROUP_ORBIT = `!G s (a:A->X->X) x.\n group_action G s a\n ==> group_orbit G s a x =\n if x IN s then {a g x | g IN group_carrier G} else {}`;;\n\nlet GROUP_ORBIT_SUBSET = `!G s (a:A->X->X) x. group_orbit G s a x SUBSET s`;;\n\nlet GROUP_ORBIT_ON_SUBSET = `!G s t (a:A->X->X).\n t SUBSET s /\\ x IN t\n ==> group_orbit G t a x = t INTER group_orbit G s a x`;;\n\nlet FINITE_GROUP_ORBIT = `!G s (a:A->X->X) x.\n FINITE(group_carrier G) \\/ FINITE s ==> FINITE(group_orbit G s a x)`;;\n\nlet GROUP_ORBIT_REFL_EQ = `!G s (a:A->X->X) x.\n group_action G s a ==> (group_orbit G s a x x <=> x IN s)`;;\n\nlet GROUP_ORBIT_REFL = `!G s (a:A->X->X) x.\n group_action G s a /\\ x IN s\n ==> group_orbit G s a x x`;;\n\nlet IN_GROUP_ORBIT_SELF = `!G s (a:A->X->X) x.\n group_action G s a /\\ x IN s ==> x IN group_orbit G s a x`;;\n\nlet GROUP_ORBIT_EMPTY = `!G s (a:A->X->X) x. ~(x IN s) ==> group_orbit G s a x = {}`;;\n\nlet GROUP_ORBIT_EQ_EMPTY = `!G s (a:A->X->X) x.\n group_action G s a\n ==> (group_orbit G s a x = {} <=> ~(x IN s))`;;\n\nlet GROUP_ORBIT_SYM_EQ = `!G s (a:A->X->X) x y.\n group_action G s a\n ==> (group_orbit G s a x y <=> group_orbit G s a y x)`;;\n\nlet GROUP_ORBIT_SYM = `!G s (a:A->X->X) x y.\n group_action G s a /\\ group_orbit G s a x y\n ==> group_orbit G s a y x`;;\n\nlet GROUP_ORBIT_TRANS = `!G s (a:A->X->X) x y z.\n group_action G s a /\\ group_orbit G s a x y /\\ group_orbit G s a y z\n ==> group_orbit G s a x z`;;\n\nlet GROUP_ORBIT_EQ = `!G s (a:A->X->X) x y.\n group_action G s a /\\ x IN s /\\ y IN s\n ==> (group_orbit G s a x = group_orbit G s a y <=>\n group_orbit G s a x y)`;;\n\nlet CLOSED_GROUP_ORBIT = `!G s (a:A->X->X) x g.\n group_action G s a /\\ g IN group_carrier G\n ==> IMAGE (a g) (group_orbit G s a x) SUBSET group_orbit G s a x`;;\n\nlet GROUP_ORBIT_EQ_SING = `!G s (a:A->X->X) x y.\n group_action G s a\n ==> (group_orbit G s a y = {x} <=>\n x IN s /\\ y = x /\\ !g. g IN group_carrier G ==> a g x = x)`;;\n\nlet GROUP_ORBIT_EQ_SING_SELF = `!G s (a:A->X->X) x.\n group_action G s a\n ==> (group_orbit G s a x = {x} <=>\n x IN s /\\ !g. g IN group_carrier G ==> a g x = x)`;;\n\nlet GROUP_ORBIT_HAS_SIZE_1 = `!G s (a:A->X->X) x.\n group_action G s a\n ==> (group_orbit G s a x HAS_SIZE 1 <=>\n x IN s /\\ !g. g IN group_carrier G ==> a g x = x)`;;\n\nlet GROUP_ACTION_INVARIANT_SUBSET = `!G s (a:A->X->X) t.\n group_action G s a /\\ t SUBSET s\n ==> ((!g. g IN group_carrier G ==> IMAGE (a g) t SUBSET t) <=>\n (!g. g IN group_carrier G ==> IMAGE (a g) t = t))`;;\n\nlet GROUP_ACTION_CLOSED = `!G s (a:A->X->X) g.\n group_action G s a /\\ g IN group_carrier G\n ==> IMAGE (a g) s SUBSET s`;;\n\nlet GROUP_ACTION_INVARIANT = `!G s (a:A->X->X) g.\n group_action G s a /\\ g IN group_carrier G\n ==> IMAGE (a g) s = s`;;\n\nlet INVARIANT_GROUP_ORBIT = `!G s (a:A->X->X) x g.\n group_action G s a /\\ g IN group_carrier G\n ==> IMAGE (a g) (group_orbit G s a x) = group_orbit G s a x`;;\n\nlet SUBSET_GROUP_ORBIT_CLOSED = `!G s (a:A->X->X) x t.\n group_action G s a /\\ t SUBSET s /\\\n (!g. g IN group_carrier G ==> IMAGE (a g) t SUBSET t)\n ==> (group_orbit G s a x SUBSET t <=>\n x IN s ==> ~DISJOINT (group_orbit G s a x) t)`;;\n\nlet SUBSET_GROUP_ORBIT_INVARIANT = `!G s (a:A->X->X) x t.\n group_action G s a /\\ t SUBSET s /\\\n (!g. g IN group_carrier G ==> IMAGE (a g) t = t)\n ==> (group_orbit G s a x SUBSET t <=>\n x IN s ==> ~DISJOINT (group_orbit G s a x) t)`;;\n\nlet GROUP_ORBITS_EQ = `!G s (a:A->X->X) x y.\n group_action G s a /\\ x IN s /\\ y IN s\n ==> (group_orbit G s a x = group_orbit G s a y <=>\n ~DISJOINT (group_orbit G s a x) (group_orbit G s a y))`;;\n\nlet DISJOINT_GROUP_ORBITS = `!G s (a:A->X->X) x y.\n group_action G s a /\\ x IN s /\\ y IN s\n ==> (DISJOINT (group_orbit G s a x) (group_orbit G s a y) <=>\n ~(group_orbit G s a x = group_orbit G s a y))`;;\n\nlet PAIRWISE_DISJOINT_GROUP_ORBITS = `!G s (a:A->X->X).\n group_action G s a\n ==> pairwise DISJOINT {group_orbit G s a x |x| x IN s}`;;\n\nlet UNIONS_GROUP_ORBITS_CLOSED = `!G s (a:A->X->X) t.\n group_action G s a /\\ t SUBSET s /\\\n (!g. g IN group_carrier G ==> IMAGE (a g) t SUBSET t)\n ==> UNIONS {group_orbit G s a x |x| x IN t} = t`;;\n\nlet UNIONS_GROUP_ORBITS_INVARIANT = `!G s (a:A->X->X) t.\n group_action G s a /\\ t SUBSET s /\\\n (!g. g IN group_carrier G ==> IMAGE (a g) t = t)\n ==> UNIONS {group_orbit G s a x |x| x IN t} = t`;;\n\nlet UNIONS_GROUP_ORBITS = `!G s (a:A->X->X).\n group_action G s a\n ==> UNIONS {group_orbit G s a x |x| x IN s} = s`;;\n\nlet NSUM_CARD_GROUP_ORBITS = `!G s (a:A->X->X).\n group_action G s a /\\ FINITE s\n ==> nsum {group_orbit G s a x | x | x IN s} CARD = CARD s`;;\n\nlet ORBIT_STABILIZER_MUL_GEN = `!G s (a:A->X->X) x.\n group_action G s a /\\ x IN s\n ==> group_orbit G s a x *_c group_stabilizer G a x =_c group_carrier G`;;\n\nlet ORBIT_STABILIZER_MUL = `!G s (a:A->X->X) x.\n FINITE(group_carrier G) /\\ group_action G s a /\\ x IN s\n ==> CARD(group_orbit G s a x) * CARD(group_stabilizer G a x) =\n CARD(group_carrier G)`;;\n\nlet CARD_GROUP_ORBIT_DIVIDES = `!G s (a:A->X->X) x.\n FINITE(group_carrier G) /\\ group_action G s a /\\ x IN s\n ==> CARD(group_orbit G s a x) divides CARD(group_carrier G)`;;\n\nlet CARD_GROUP_STABILIZER_DIVIDES = `!G s (a:A->X->X) x.\n FINITE(group_carrier G) /\\ group_action G s a /\\ x IN s\n ==> CARD(group_stabilizer G a x) divides CARD(group_carrier G)`;;\n\nlet GROUP_STABILIZER_OF_ACTION = `!G s (a:A->X->X) g x.\n group_action G s a /\\ g IN group_carrier G /\\ x IN s\n ==> group_stabilizer G a (a g x) =\n IMAGE (group_conjugation G g) (group_stabilizer G a x)`;;\n\nlet GROUP_ACTION_SUBGROUP_TRANSLATION = `!G (h:A->bool).\n group_action (subgroup_generated G h) (group_carrier G) (group_mul G)`;;\n\nlet GROUP_STABILIZER_SUBGROUP_TRANSLATION = `!G h a:A.\n h subgroup_of G /\\ a IN group_carrier G\n ==> group_stabilizer (subgroup_generated G h) (group_mul G) a =\n {group_id G}`;;\n\nlet GROUP_ACTION_GROUP_TRANSLATION = `!G. group_action G (group_carrier G) (group_mul G)`;;\n\nlet GROUP_STABILIZER_GROUP_TRANSLATION = `!G a:A.\n a IN group_carrier G\n ==> group_stabilizer G (group_mul G) a = {group_id G}`;;\n\nlet GROUP_ACTION_SUBSET_TRANSLATION = `!(G:A group) u.\n (!s. s IN u ==> s SUBSET group_carrier G) /\\\n (!a s. a IN group_carrier G /\\ s IN u ==> IMAGE (group_mul G a) s IN u)\n ==> group_action G u (IMAGE o group_mul G)`;;\n\nlet GROUP_ACTION_CONJUGATION = `!G:A group. group_action G (group_carrier G) (group_conjugation G)`;;\n\nlet CARD_GROUP_SETMUL_GEN = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> (group_setmul G g h) *_c (g INTER h) =_c g *_c h`;;\n\nlet CARD_GROUP_SETMUL_MUL = `!G g h:A->bool.\n FINITE g /\\ FINITE h /\\ g subgroup_of G /\\ h subgroup_of G\n ==> CARD(group_setmul G g h) * CARD(g INTER h) = CARD g * CARD h`;;\n\nlet CARD_GROUP_SETMUL = `!G g h:A->bool.\n FINITE g /\\ FINITE h /\\ g subgroup_of G /\\ h subgroup_of G\n ==> CARD(group_setmul G g h) = (CARD g * CARD h) DIV CARD(g INTER h)`;;\n\nlet CARD_GROUP_SETMUL_DIVIDES = `!G g h:A->bool.\n FINITE g /\\ FINITE h /\\ g subgroup_of G /\\ h subgroup_of G\n ==> CARD(group_setmul G g h) divides CARD(g) * CARD(h)`;;\n\nlet GROUP_ORBIT_COMMON_DIVISOR = `!G s (a:A->X->X) n.\n group_action G s a /\\\n FINITE s /\\\n (!x. x IN s ==> n divides CARD(group_orbit G s a x))\n ==> n divides CARD s`;;\n\nlet GROUP_ORBIT_COMMON_INDEX = `!G s (a:A->X->X) p k.\n group_action G s a /\\\n FINITE s /\\ (s = {} ==> k = 0) /\\\n (!x. x IN s ==> k <= index p (CARD(group_orbit G s a x)))\n ==> k <= index p (CARD s)`;;\n\nlet right_coset = new_definition\n `right_coset G h x = group_setmul G h {x}`;;\n\nlet left_coset = new_definition\n `left_coset G x h = group_setmul G {x} h`;;\n\nlet LEFT_COSET_AS_IMAGE = `!(x:A) h. left_coset G x h = IMAGE (group_mul G x) h`;;\n\nlet RIGHT_COSET = `!G h x:A.\n x IN group_carrier G /\\ h SUBSET group_carrier G\n ==> right_coset G h x SUBSET group_carrier G`;;\n\nlet LEFT_COSET = `!G h x:A.\n x IN group_carrier G /\\ h SUBSET group_carrier G\n ==> left_coset G x h SUBSET group_carrier G`;;\n\nlet IN_RIGHT_COSET = `!G h x a:A.\n h SUBSET group_carrier G /\\\n a IN group_carrier G /\\ x IN group_carrier G\n ==> (x IN right_coset G h a <=>\n group_mul G x (group_inv G a) IN h)`;;\n\nlet IN_LEFT_COSET = `!G h x a:A.\n h SUBSET group_carrier G /\\\n a IN group_carrier G /\\ x IN group_carrier G\n ==> (x IN left_coset G a h <=>\n group_mul G (group_inv G a) x IN h)`;;\n\nlet IN_RIGHT_COSET_INV = `!G h x y:A.\n h SUBSET group_carrier G /\\\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (x IN right_coset G h (group_inv G y) <=>\n group_mul G x y IN h)`;;\n\nlet IN_LEFT_COSET_INV = `!G h x y:A.\n h SUBSET group_carrier G /\\\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (x IN left_coset G (group_inv G y) h <=>\n group_mul G y x IN h)`;;\n\nlet GROUP_SETINV_LEFT_COSET_GEN,GROUP_SETINV_RIGHT_COSET_GEN =\n (CONJ_PAIR o prove)\n (`(!G h a:A.\n h subgroup_of G /\\ a IN group_carrier G\n ==> group_setinv G (left_coset G a h) =\n right_coset G h (group_inv G a)) /\\\n (!G h a:A.\n h subgroup_of G /\\ a IN group_carrier G\n ==> group_setinv G (right_coset G h a) =\n left_coset G (group_inv G a) h)`,\n REWRITE_TAC[GROUP_SETINV_AS_IMAGE; IMP_CONJ; RIGHT_FORALL_IMP_THM] THEN\n GEN_REWRITE_TAC (LAND_CONV o ONCE_DEPTH_CONV)\n [GSYM FORALL_IN_GROUP_CARRIER_INV] THEN\n REWRITE_TAC[RIGHT_IMP_FORALL_THM; AND_FORALL_THM; IMP_IMP] THEN\n REPEAT GEN_TAC THEN SIMP_TAC[GROUP_INV_INV] THEN\n REWRITE_TAC[TAUT `(p ==> q) /\\ (p ==> r) <=> p ==> q /\\ r`] THEN\n DISCH_TAC THEN MATCH_MP_TAC(SET_RULE\n `!u. s SUBSET u /\\ t SUBSET u /\\ (!x. x IN u ==> f(f x) = x) /\\\n (!x. x IN u ==> (f x IN t <=> x IN s)) /\\\n (!x. x IN u ==> (f x IN s <=> x IN t))\n ==> IMAGE f s = t /\\ IMAGE f t = s`) THEN\n EXISTS_TAC `group_carrier G:A->bool` THEN\n ASM_SIMP_TAC[IN_LEFT_COSET; IN_RIGHT_COSET; SUBGROUP_OF_IMP_SUBSET;\n GROUP_INV_INV; GROUP_INV; LEFT_COSET; RIGHT_COSET] THEN\n REPEAT STRIP_TAC THEN EQ_TAC THEN DISCH_TAC THEN\n FIRST_X_ASSUM(MP_TAC o ISPEC `G:A group` o\n MATCH_MP (REWRITE_RULE[IMP_CONJ_ALT] IN_SUBGROUP_INV)) THEN\n ASM_SIMP_TAC[GROUP_INV_MUL; GROUP_INV_INV; GROUP_INV]);;\n\nlet RIGHT_COSET_OPPOSITE_GROUP = `!G h x:A. right_coset G h x = left_coset (opposite_group G) x h`;;\n\nlet LEFT_COSET_OPPOSITE_GROUP = `!G h x:A. left_coset G x h = right_coset (opposite_group G) h x`;;\n\nlet GROUP_CONJUGATION_RIGHT_COSET = `!G h x:A.\n x IN group_carrier G /\\ h SUBSET group_carrier G\n ==> IMAGE (group_conjugation G x) (right_coset G h x) = left_coset G x h`;;\n\nlet RIGHT_COSET_GROUP_CONJUGATION = `!G h x:A.\n x IN group_carrier G /\\ h SUBSET group_carrier G\n ==> right_coset G (IMAGE (group_conjugation G x) h) x =\n left_coset G x h`;;\n\nlet LEFT_COSET_LEFT_COSET = `!x y h:A->bool.\n x IN group_carrier G /\\\n y IN group_carrier G /\\\n h SUBSET group_carrier G\n ==> left_coset G x (left_coset G y h) =\n left_coset G (group_mul G x y) h`;;\n\nlet RIGHT_COSET_RIGHT_COSET = `!x y h:A->bool.\n h SUBSET group_carrier G /\\\n x IN group_carrier G /\\\n y IN group_carrier G\n ==> right_coset G (right_coset G h x) y =\n right_coset G h (group_mul G x y)`;;\n\nlet RIGHT_COSET_ID = `!G h:A->bool.\n h SUBSET group_carrier G ==> right_coset G h (group_id G) = h`;;\n\nlet LEFT_COSET_ID = `!G h:A->bool.\n h SUBSET group_carrier G ==> left_coset G (group_id G) h = h`;;\n\nlet LEFT_COSET_TRIVIAL = `!G x:A. x IN group_carrier G ==> left_coset G x {group_id G} = {x}`;;\n\nlet RIGHT_COSET_TRIVIAL = `!G x:A. x IN group_carrier G ==> right_coset G {group_id G} x = {x}`;;\n\nlet LEFT_COSET_CARRIER = `!G x:A. x IN group_carrier G\n ==> left_coset G x (group_carrier G) = group_carrier G`;;\n\nlet RIGHT_COSET_CARRIER = `!G x:A. x IN group_carrier G\n ==> right_coset G (group_carrier G) x = group_carrier G`;;\n\nlet RIGHT_COSET_EQ = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> (right_coset G h x = right_coset G h y <=> group_div G x y IN h)`;;\n\nlet LEFT_COSET_EQ = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> (left_coset G x h = left_coset G y h <=>\n group_mul G (group_inv G x) y IN h)`;;\n\nlet RIGHT_COSET_EQ_SUBGROUP = `!G h x:A.\n h subgroup_of G /\\ x IN group_carrier G\n ==> (right_coset G h x = h <=> x IN h)`;;\n\nlet LEFT_COSET_EQ_SUBGROUP = `!G h x:A.\n h subgroup_of G /\\ x IN group_carrier G\n ==> (left_coset G x h = h <=> x IN h)`;;\n\nlet RIGHT_COSET_EQ_EMPTY = `!G h x:A. right_coset G h x = {} <=> h = {}`;;\n\nlet LEFT_COSET_EQ_EMPTY = `!G h x:A. left_coset G x h = {} <=> h = {}`;;\n\nlet RIGHT_COSET_NONEMPTY = `!G h x:A. h subgroup_of G ==> ~(right_coset G h x = {})`;;\n\nlet LEFT_COSET_NONEMPTY = `!G h x:A. h subgroup_of G ==> ~(left_coset G x h = {})`;;\n\nlet IN_RIGHT_COSET_SELF = `!G h x:A.\n h subgroup_of G /\\ x IN group_carrier G ==> x IN right_coset G h x`;;\n\nlet IN_LEFT_COSET_SELF = `!G h x:A.\n h subgroup_of G /\\ x IN group_carrier G ==> x IN left_coset G x h`;;\n\nlet UNIONS_RIGHT_COSETS = `!G h:A->bool.\n h subgroup_of G\n ==> UNIONS {right_coset G h x |x| x IN group_carrier G} =\n group_carrier G`;;\n\nlet UNIONS_LEFT_COSETS = `!G h:A->bool.\n h subgroup_of G\n ==> UNIONS {left_coset G x h |x| x IN group_carrier G} =\n group_carrier G`;;\n\nlet RIGHT_COSETS_EQ = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> (right_coset G h x = right_coset G h y <=>\n ~(DISJOINT (right_coset G h x) (right_coset G h y)))`;;\n\nlet LEFT_COSETS_EQ = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> (left_coset G x h = left_coset G y h <=>\n ~(DISJOINT (left_coset G x h) (left_coset G y h)))`;;\n\nlet DISJOINT_RIGHT_COSETS = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> (DISJOINT (right_coset G h x) (right_coset G h y) <=>\n ~(right_coset G h x = right_coset G h y))`;;\n\nlet DISJOINT_LEFT_COSETS = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> (DISJOINT (left_coset G x h) (left_coset G y h) <=>\n ~(left_coset G x h = left_coset G y h))`;;\n\nlet PAIRWISE_DISJOINT_RIGHT_COSETS = `!G h:A->bool.\n h subgroup_of G\n ==> pairwise DISJOINT {right_coset G h a |a| a IN group_carrier G}`;;\n\nlet PAIRWISE_DISJOINT_LEFT_COSETS = `!G h:A->bool.\n h subgroup_of G\n ==> pairwise DISJOINT {left_coset G a h |a| a IN group_carrier G}`;;\n\nlet IMAGE_RIGHT_COSET_SWITCH = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> IMAGE (\\a. group_mul G a (group_mul G (group_inv G x) y))\n (right_coset G h x) =\n right_coset G h y`;;\n\nlet IMAGE_LEFT_COSET_SWITCH = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> IMAGE (\\a. group_mul G (group_div G y x) a)\n (left_coset G x h) =\n left_coset G y h`;;\n\nlet CARD_EQ_LEFT_RIGHT_COSETS = `!G h:A->bool.\n h subgroup_of G\n ==> {left_coset G x h |x| x IN group_carrier G} =_c\n {right_coset G h x |x| x IN group_carrier G}`;;\n\nlet HAS_SIZE_LEFT_RIGHT_COSETS = `!G h:A->bool.\n h subgroup_of G\n ==> ({left_coset G x h | x | x IN group_carrier G} HAS_SIZE n <=>\n {right_coset G h x | x | x IN group_carrier G} HAS_SIZE n)`;;\n\nlet CARD_EQ_RIGHT_COSETS = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> right_coset G h x =_c right_coset G h y`;;\n\nlet GROUP_ID_IN_LEFT_COSET_GEN = `!G h x:A.\n h SUBSET group_carrier G /\\ x IN group_carrier G\n ==> (group_id G IN left_coset G x h <=> group_inv G x IN h)`;;\n\nlet GROUP_ID_IN_LEFT_COSET = `!G h x:A.\n h subgroup_of G /\\ x IN group_carrier G\n ==> (group_id G IN left_coset G x h <=> x IN h)`;;\n\nlet SUBGROUP_OF_LEFT_COSET = `!G h x:A.\n h subgroup_of G /\\ x IN group_carrier G\n ==> (left_coset G x h subgroup_of G <=> left_coset G x h = h)`;;\n\nlet GROUP_ID_IN_RIGHT_COSET_GEN = `!G h x:A.\n h SUBSET group_carrier G /\\ x IN group_carrier G\n ==> (group_id G IN right_coset G h x <=> group_inv G x IN h)`;;\n\nlet GROUP_ID_IN_RIGHT_COSET = `!G h x:A.\n h subgroup_of G /\\ x IN group_carrier G\n ==> (group_id G IN right_coset G h x <=> x IN h)`;;\n\nlet SUBGROUP_OF_RIGHT_COSET = `!G h x:A.\n h subgroup_of G /\\ x IN group_carrier G\n ==> (right_coset G h x subgroup_of G <=> right_coset G h x = h)`;;\n\nlet CARD_EQ_LEFT_COSETS = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> left_coset G x h =_c left_coset G y h`;;\n\nlet CARD_EQ_RIGHT_COSET_SUBGROUP = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> right_coset G h x =_c h`;;\n\nlet CARD_EQ_LEFT_COSET_SUBGROUP = `!G h x y:A.\n h subgroup_of G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> left_coset G x h =_c h`;;\n\nlet GROUP_ORBIT_SUBGROUP_TRANSLATION = `!G h a:A.\n h subgroup_of G /\\ a IN group_carrier G\n ==> group_orbit (subgroup_generated G h) (group_carrier G) (group_mul G) a =\n right_coset G h a`;;\n\nlet GROUP_ORBIT_GROUP_TRANSLATION = `!G a:A.\n a IN group_carrier G\n ==> group_orbit G (group_carrier G) (group_mul G) a = group_carrier G`;;\n\nlet ORBIT_STABILIZER_GEN = `!G s (a:A->X->X) x.\n group_action G s a /\\ x IN s\n ==> group_orbit G s a x =_c\n {left_coset G g (group_stabilizer G a x) |g| g IN group_carrier G}`;;\n\nlet ORBIT_STABILIZER = `!G s (a:A->X->X) x.\n FINITE(group_carrier G) /\\ group_action G s a /\\ x IN s\n ==> CARD (group_orbit G s a x) =\n CARD {left_coset G g (group_stabilizer G a x) |g|\n g IN group_carrier G}`;;\n\nlet GROUP_ACTION_LEFT_COSET_MULTIPLICATION = `!G h:A->bool.\n h SUBSET group_carrier G\n ==> group_action G {left_coset G x h | x | x IN group_carrier G}\n (IMAGE o group_mul G)`;;\n\nlet GROUP_ORBIT_LEFT_COSET_MULTIPLICATION = `!G h a:A.\n a IN group_carrier G /\\ h subgroup_of G\n ==> group_orbit G { left_coset G x h | x | x IN group_carrier G}\n (IMAGE o group_mul G) (left_coset G a h) =\n { left_coset G x h | x | x IN group_carrier G}`;;\n\nlet GROUP_STABILIZER_LEFT_COSET_MULTIPLICATION = `!G h a:A.\n a IN group_carrier G /\\ h subgroup_of G\n ==> group_stabilizer G (IMAGE o group_mul G) (left_coset G a h) =\n IMAGE (group_conjugation G a) h`;;\n\nlet GROUP_ORBIT_LEFT_COSET_MULTIPLICATION_ID = `!G h:A->bool.\n h subgroup_of G\n ==> group_orbit G { left_coset G x h | x | x IN group_carrier G}\n (IMAGE o group_mul G) h =\n { left_coset G x h | x | x IN group_carrier G}`;;\n\nlet GROUP_STABILIZER_LEFT_COSET_MULTIPLICATION_ID = `!G h:A->bool.\n h subgroup_of G\n ==> group_stabilizer G (IMAGE o group_mul G) h = h`;;\n\nlet LAGRANGE_THEOREM_LEFT_GEN = `!G h:A->bool.\n h subgroup_of G\n ==> {left_coset G x h | x | x IN group_carrier G} *_c h =_c\n group_carrier G`;;\n\nlet LAGRANGE_THEOREM_RIGHT_GEN = `!G h:A->bool.\n h subgroup_of G\n ==> {right_coset G h x | x | x IN group_carrier G} *_c h =_c\n group_carrier G`;;\n\nlet LAGRANGE_THEOREM_LEFT = `!G h:A->bool.\n FINITE(group_carrier G) /\\ h subgroup_of G\n ==> CARD {left_coset G x h |x| x IN group_carrier G} * CARD h =\n CARD(group_carrier G)`;;\n\nlet LAGRANGE_THEOREM_RIGHT = `!G h:A->bool.\n FINITE(group_carrier G) /\\ h subgroup_of G\n ==> CARD {right_coset G h x |x| x IN group_carrier G} * CARD h =\n CARD(group_carrier G)`;;\n\nlet LAGRANGE_THEOREM = `!G h:A->bool.\n FINITE(group_carrier G) /\\ h subgroup_of G\n ==> (CARD h) divides CARD(group_carrier G)`;;\n\nlet CARD_LEFT_COSETS_DIVIDES = `!G h:A->bool.\n FINITE(group_carrier G) /\\ h subgroup_of G\n ==> CARD {left_coset G x h | x | x IN group_carrier G} divides\n CARD(group_carrier G)`;;\n\nlet CARD_RIGHT_COSETS_DIVIDES = `!G h:A->bool.\n FINITE(group_carrier G) /\\ h subgroup_of G\n ==> CARD {right_coset G h x | x | x IN group_carrier G} divides\n CARD(group_carrier G)`;;\n\nlet LAGRANGE_THEOREM_LEFT_DIV = `!G h:A->bool.\n FINITE(group_carrier G) /\\ h subgroup_of G\n ==> CARD {left_coset G x h | x | x IN group_carrier G} =\n CARD(group_carrier G) DIV CARD h`;;\n\nlet LAGRANGE_THEOREM_RIGHT_DIV = `!G h:A->bool.\n FINITE(group_carrier G) /\\ h subgroup_of G\n ==> CARD {right_coset G h x | x | x IN group_carrier G} =\n CARD(group_carrier G) DIV CARD h`;;\n\nlet GROUP_SETMUL_PROD_GROUP = `!(G1:A group) (G2:B group) s1 s2 t1 t2.\n group_setmul (prod_group G1 G2) (s1 CROSS s2) (t1 CROSS t2) =\n (group_setmul G1 s1 t1) CROSS (group_setmul G2 s2 t2)`;;\n\nlet RIGHT_COSET_PROD_GROUP = `!G1 G2 h1 h2 (x1:A) (x2:B).\n right_coset (prod_group G1 G2) (h1 CROSS h2) (x1,x2) =\n (right_coset G1 h1 x1) CROSS (right_coset G2 h2 x2)`;;\n\nlet LEFT_COSET_PROD_GROUP = `!G1 G2 h1 h2 (x1:A) (x2:B).\n left_coset (prod_group G1 G2) (x1,x2) (h1 CROSS h2) =\n (left_coset G1 x1 h1) CROSS (left_coset G2 x2 h2)`;;\n\nlet GROUP_SETMUL_PRODUCT_GROUP = `!(G:K->A group) k s t.\n group_setmul (product_group k G)\n (cartesian_product k s) (cartesian_product k t) =\n cartesian_product k (\\i. group_setmul (G i) (s i) (t i))`;;\n\nlet RIGHT_COSET_PRODUCT_GROUP = `!(G:K->A group) h x k.\n right_coset (product_group k G) (cartesian_product k h) x =\n cartesian_product k (\\i. right_coset (G i) (h i) (x i))`;;\n\nlet LEFT_COSET_PRODUCT_GROUP = `!(G:K->A group) h x k.\n left_coset (product_group k G) x (cartesian_product k h) =\n cartesian_product k (\\i. left_coset (G i) (x i) (h i))`;;\n\nlet GROUP_SETINV_SUBGROUP_GENERATED = `!G h:A->bool.\n group_setinv (subgroup_generated G h) = group_setinv G`;;\n\nlet GROUP_SETMUL_SUBGROUP_GENERATED = `!G h:A->bool.\n group_setmul (subgroup_generated G h) = group_setmul G`;;\n\nlet RIGHT_COSET_SUBGROUP_GENERATED = `!G h k x. right_coset (subgroup_generated G h) k x = right_coset G k x`;;\n\nlet LEFT_COSET_SUBGROUP_GENERATED = `!G h k x. left_coset (subgroup_generated G h) x k = left_coset G x k`;;\n\nlet SCHREIER_TRANSVERSAL_LEMMA = `!(G:A group) h s t.\n h subgroup_of G /\\\n s SUBSET group_carrier G /\\\n subgroup_generated G s = G /\\\n (!x. x IN s ==> group_inv G x IN s) /\\\n t SUBSET group_carrier G /\\\n UNIONS {right_coset G h x | x IN t} = group_carrier G /\\\n t INTER h SUBSET {group_id G}\n ==> group_carrier(subgroup_generated G\n (h INTER group_setmul G t (group_setmul G s (group_setinv G t)))) =\n h`;;\n\nparse_as_infix (\"normal_subgroup_of\",(12,\"right\"));;\n\nlet normal_subgroup_of = new_definition\n `(n:A->bool) normal_subgroup_of (G:A group) <=>\n n subgroup_of G /\\\n !x. x IN group_carrier G ==> left_coset G x n = right_coset G n x`;;\n\nlet NORMAL_SUBGROUP_IMP_SUBGROUP = `!G n:A->bool. n normal_subgroup_of G ==> n subgroup_of G`;;\n\nlet NORMAL_SUBGROUP_OF_IMP_SUBSET = `!G n:A->bool. n normal_subgroup_of G ==> n SUBSET group_carrier G`;;\n\nlet NORMAL_SUBGROUP_OF_OPPOSITE_GROUP = `!G n:A->bool.\n n normal_subgroup_of opposite_group G <=> n normal_subgroup_of G`;;\n\nlet ABELIAN_GROUP_NORMAL_SUBGROUP = `!G n:A->bool.\n abelian_group G ==> (n normal_subgroup_of G <=> n subgroup_of G)`;;\n\nlet NORMAL_SUBGROUP_CONJUGATE_ALT = `!G n:A->bool.\n n normal_subgroup_of G <=>\n n subgroup_of G /\\\n !x. x IN group_carrier G\n ==> group_setmul G {group_inv G x} (group_setmul G n {x}) = n`;;\n\nlet NORMAL_SUBGROUP_CONJUGATE_INV = `!G n:A->bool.\n n normal_subgroup_of G <=>\n n subgroup_of G /\\\n !x. x IN group_carrier G\n ==> group_setmul G {group_inv G x} (group_setmul G n {x}) SUBSET n`;;\n\nlet NORMAL_SUBGROUP_CONJUGATION_EQ = `!G h:A->bool.\n h normal_subgroup_of G <=>\n h subgroup_of G /\\\n !a. a IN group_carrier G ==> IMAGE (group_conjugation G a) h = h`;;\n\nlet NORMAL_SUBGROUP_CONJUGATION = `!G h:A->bool.\n h normal_subgroup_of G <=>\n h subgroup_of G /\\\n !a. a IN group_carrier G ==> IMAGE (group_conjugation G a) h SUBSET h`;;\n\nlet NORMAL_SUBGROUP_CONJUGATION_SUPERSET = `!G h:A->bool.\n h normal_subgroup_of G <=>\n h subgroup_of G /\\\n !a. a IN group_carrier G ==> h SUBSET IMAGE (group_conjugation G a) h`;;\n\nlet ABELIAN_GROUP_CONJUGATION = `!G a x:A.\n abelian_group G /\\ a IN group_carrier G /\\ x IN group_carrier G\n ==> group_conjugation G a x = x`;;\n\nlet NORMAL_SUBGROUP_OF_INTERS = `!G gs. (!g. g IN gs ==> g normal_subgroup_of G) /\\ ~(gs = {})\n ==> INTERS gs normal_subgroup_of G`;;\n\nlet NORMAL_SUBGROUP_OF_INTER = `!G g h:A->bool.\n g normal_subgroup_of G /\\ h normal_subgroup_of G\n ==> g INTER h normal_subgroup_of G`;;\n\nlet NORMAL_SUBGROUP_OF_UNIONS = `!G (u:(A->bool)->bool).\n ~(u = {}) /\\\n (!h. h IN u ==> h normal_subgroup_of G) /\\\n (!g h. g IN u /\\ h IN u ==> g SUBSET h \\/ h SUBSET g)\n ==> (UNIONS u) normal_subgroup_of G`;;\n\nlet NORMAL_SUBGROUP_ACTION_KERNEL = `!G s (a:A->X->X).\n group_action G s a\n ==> {g | g IN group_carrier G /\\ !x. x IN s ==> a g x = x}\n normal_subgroup_of G`;;\n\nlet NORMAL_SUBGROUP_LEFT_EQ_RIGHT_COSETS = `!G n:A->bool.\n n normal_subgroup_of G <=>\n n subgroup_of G /\\\n {left_coset G x n |x| x IN group_carrier G} =\n {right_coset G n x |x| x IN group_carrier G}`;;\n\nlet NORMAL_SUBGROUP_LEFT_SUBSET_RIGHT_COSETS,\n NORMAL_SUBGROUP_RIGHT_SUBSET_LEFT_COSETS = (CONJ_PAIR o prove)\n (`(!G n:A->bool.\n n normal_subgroup_of G <=>\n n subgroup_of G /\\\n {left_coset G x n |x| x IN group_carrier G} SUBSET\n {right_coset G n x |x| x IN group_carrier G}) /\\\n (!G n:A->bool.\n n normal_subgroup_of G <=>\n n subgroup_of G /\\\n {right_coset G n x |x| x IN group_carrier G} SUBSET\n {left_coset G x n |x| x IN group_carrier G})`,\n REPEAT STRIP_TAC THEN REWRITE_TAC[NORMAL_SUBGROUP_LEFT_EQ_RIGHT_COSETS] THEN\n ASM_CASES_TAC `(n:A->bool) subgroup_of G` THEN\n ASM_REWRITE_TAC[GSYM SUBSET_ANTISYM_EQ] THEN\n EQ_TAC THEN SIMP_TAC[] THEN DISCH_THEN(MP_TAC o MATCH_MP\n (ONCE_REWRITE_RULE[IMP_CONJ_ALT] DIFF_UNIONS_PAIRWISE_DISJOINT)) THEN\n ASM_SIMP_TAC[UNIONS_LEFT_COSETS; UNIONS_RIGHT_COSETS; DIFF_EQ_EMPTY;\n PAIRWISE_DISJOINT_RIGHT_COSETS; PAIRWISE_DISJOINT_LEFT_COSETS] THEN\n DISCH_THEN(MP_TAC o SYM) THEN REWRITE_TAC[EMPTY_UNIONS] THEN\n MATCH_MP_TAC(SET_RULE\n `(!x. x IN t ==> ~(P x))\n ==> (!x. x IN t DIFF s ==> P x) ==> t SUBSET s`) THEN\n ASM_SIMP_TAC[FORALL_IN_GSPEC; LEFT_COSET_NONEMPTY; RIGHT_COSET_NONEMPTY]);;\n\nlet NORMAL_SUBGROUP_MUL_SYM = `!G h:A->bool.\n h normal_subgroup_of G <=>\n h subgroup_of G /\\\n !x y. x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_mul G x y IN h <=> group_mul G y x IN h)`;;\n\nlet TRIVIAL_NORMAL_SUBGROUP_OF = `!G:A group. {group_id G} normal_subgroup_of G`;;\n\nlet CARRIER_NORMAL_SUBGROUP_OF = `!G:A group. (group_carrier G) normal_subgroup_of G`;;\n\nlet GROUP_SETINV_RIGHT_COSET = `!G n a:A.\n n normal_subgroup_of G /\\ a IN group_carrier G\n ==> group_setinv G (right_coset G n a) =\n right_coset G n (group_inv G a)`;;\n\nlet GROUP_SETINV_LEFT_COSET = `!G n a:A.\n n normal_subgroup_of G /\\ a IN group_carrier G\n ==> group_setinv G (left_coset G a n) =\n left_coset G (group_inv G a) n`;;\n\nlet GROUP_SETMUL_RIGHT_COSET = `!G n a b:A.\n n normal_subgroup_of G /\\ a IN group_carrier G /\\ b IN group_carrier G\n ==> group_setmul G (right_coset G n a) (right_coset G n b) =\n right_coset G n (group_mul G a b)`;;\n\nlet GROUP_SETMUL_LEFT_COSET = `!G n a b:A.\n n normal_subgroup_of G /\\ a IN group_carrier G /\\ b IN group_carrier G\n ==> group_setmul G (left_coset G a n) (left_coset G b n) =\n left_coset G (group_mul G a b) n`;;\n\nlet CROSS_NORMAL_SUBGROUP_OF_PROD_GROUP = `!(G1:A group) (G2:B group) h1 h2.\n (h1 CROSS h2) normal_subgroup_of (prod_group G1 G2) <=>\n h1 normal_subgroup_of G1 /\\ h2 normal_subgroup_of G2`;;\n\nlet NORMAL_SUBGROUP_OF_SUBGROUP_GENERATED_GEN = `!G s h:A->bool.\n h normal_subgroup_of G /\\\n h SUBSET group_carrier(subgroup_generated G s)\n ==> h normal_subgroup_of (subgroup_generated G s)`;;\n\nlet NORMAL_SUBGROUP_OF_SUBGROUP_GENERATED = `!G s h:A->bool.\n h normal_subgroup_of G /\\ h SUBSET s\n ==> h normal_subgroup_of (subgroup_generated G s)`;;\n\nlet GROUP_SETMUL_NORMAL_SUBGROUP_LEFT = `!G n h:A->bool.\n n normal_subgroup_of G /\\ h subgroup_of G\n ==> group_setmul G n h subgroup_of G`;;\n\nlet GROUP_SETMUL_NORMAL_SUBGROUP_RIGHT = `!G h n:A->bool.\n h subgroup_of G /\\ n normal_subgroup_of G\n ==> group_setmul G h n subgroup_of G`;;\n\nlet GROUP_SETMUL_NORMAL_SUBGROUP = `!G h k:A->bool.\n h normal_subgroup_of G /\\ k normal_subgroup_of G\n ==> group_setmul G h k normal_subgroup_of G`;;\n\nlet CARRIER_SUBGROUP_GENERATED_UNION_LEFT = `!G g h:A->bool.\n g normal_subgroup_of G /\\ h subgroup_of G\n ==> group_carrier(subgroup_generated G (g UNION h)) =\n group_setmul G g h`;;\n\nlet CARRIER_SUBGROUP_GENERATED_UNION_RIGHT = `!G g h:A->bool.\n g subgroup_of G /\\ h normal_subgroup_of G\n ==> group_carrier(subgroup_generated G (g UNION h)) =\n group_setmul G g h`;;\n\nlet group_conjugate = new_definition\n `group_conjugate (G:A group) s t <=>\n s SUBSET group_carrier G /\\\n t SUBSET group_carrier G /\\\n ?a. a IN group_carrier G /\\ IMAGE (group_conjugation G a) s = t`;;\n\nlet GROUP_CONJUGATE_REFL = `!G s:A->bool.\n group_conjugate G s s <=> s SUBSET group_carrier G`;;\n\nlet GROUP_CONJUGATE_SYM = `!G s t:A->bool. group_conjugate G s t <=> group_conjugate G t s`;;\n\nlet GROUP_CONJUGATE_TRANS = `!G s t u:A->bool.\n group_conjugate G s t /\\ group_conjugate G t u\n ==> group_conjugate G s u`;;\n\nlet GROUP_CONJUGATE_SUBGROUPS_GENERATED = `!G s t:A->bool.\n group_conjugate G s t\n ==> group_conjugate G (group_carrier(subgroup_generated G s))\n (group_carrier(subgroup_generated G t))`;;\n\nlet GROUP_CONJUGATE_IMP_ISOMORPHIC = `!G s t:A->bool.\n group_conjugate G s t\n ==> (subgroup_generated G s) isomorphic_group (subgroup_generated G t)`;;\n\nlet GROUP_CONJUGATE_IMP_CARD_EQ = `!G s t:A->bool. group_conjugate G s t ==> s =_c t`;;\n\nlet GROUP_ORBIT_CONJUGATE_STABILIZERS = `!G s (a:A->X->X) x y.\n group_action G s a /\\ group_orbit G s a x y\n ==> group_conjugate G (group_stabilizer G a x) (group_stabilizer G a y)`;;\n\nlet CARD_EQ_GROUP_ORBIT_STABILIZERS = `!G s (a:A->X->X) x y.\n group_action G s a /\\ group_orbit G s a x y\n ==> group_stabilizer G a x =_c group_stabilizer G a y`;;\n\nlet group_centralizer = new_definition\n `group_centralizer G s =\n {x:A | x IN group_carrier G /\\\n !y. y IN group_carrier G /\\ y IN s\n ==> group_mul G x y = group_mul G y x}`;;\n\nlet group_normalizer = new_definition\n `group_normalizer G s =\n {x:A | x IN group_carrier G /\\\n group_setmul G {x} (group_carrier G INTER s) =\n group_setmul G (group_carrier G INTER s) {x}}`;;\n\nlet GROUP_CENTRALIZER = `!G s:A->bool.\n s SUBSET group_carrier G\n ==> group_centralizer G s =\n {x | x IN group_carrier G /\\\n !y. y IN s ==> group_mul G x y = group_mul G y x}`;;\n\nlet GROUP_NORMALIZER = `!G s:A->bool.\n s SUBSET group_carrier G\n ==> group_normalizer G s =\n {x | x IN group_carrier G /\\\n group_setmul G {x} s = group_setmul G s {x}}`;;\n\nlet GROUP_NORMALIZER_CONJUGATION_EQ = `!G s:A->bool.\n group_normalizer G s =\n {x | x IN group_carrier G /\\\n IMAGE (group_conjugation G x) (group_carrier G INTER s) =\n (group_carrier G INTER s)}`;;\n\nlet GROUP_NORMALIZER_CONJUGATION = `!G s:A->bool.\n s SUBSET group_carrier G\n ==> group_normalizer G s =\n {x | x IN group_carrier G /\\ IMAGE (group_conjugation G x) s = s}`;;\n\nlet GROUP_NORMALIZER_FINITE = `!G s:A->bool.\n s SUBSET group_carrier G /\\ FINITE s\n ==> group_normalizer G s =\n {x | x IN group_carrier G /\\\n IMAGE (group_conjugation G x) s SUBSET s}`;;\n\nlet GROUP_CENTRALIZER_RESTRICT = `!G s:A->bool.\n group_centralizer G s =\n group_centralizer G (group_carrier G INTER s)`;;\n\nlet GROUP_NORMALIZER_RESTRICT = `!G s:A->bool.\n group_normalizer G s =\n group_normalizer G (group_carrier G INTER s)`;;\n\nlet GROUP_CENTRALIZER_SUBSET_CARRIER = `!G s:A->bool. group_centralizer G s SUBSET group_carrier G`;;\n\nlet GROUP_NORMALIZER_SUBSET_CARRIER = `!G s:A->bool. group_normalizer G s SUBSET group_carrier G`;;\n\nlet FINITE_GROUP_CENTRALIZER = `!(G:A group) s. FINITE(group_carrier G) ==> FINITE(group_centralizer G s)`;;\n\nlet FINITE_GROUP_NORMALIZER = `!(G:A group) s. FINITE(group_carrier G) ==> FINITE(group_normalizer G s)`;;\n\nlet GROUP_CENTRALIZER_SUBSET_NORMALIZER = `!G s:A->bool. group_centralizer G s SUBSET group_normalizer G s`;;\n\nlet SUBGROUP_GROUP_CENTRALIZER = `!G s:A->bool. (group_centralizer G s) subgroup_of G`;;\n\nlet SUBGROUP_GROUP_NORMALIZER = `!G s:A->bool. (group_normalizer G s) subgroup_of G`;;\n\nlet GROUP_CENTRALIZER_SUBGROUP_GENERATED = `!G h s:A->bool.\n s SUBSET h /\\ h subgroup_of G\n ==> group_centralizer (subgroup_generated G h) s =\n h INTER group_centralizer G s`;;\n\nlet GROUP_NORMALIZER_SUBGROUP_GENERATED = `!G h s:A->bool.\n s SUBSET h /\\ h subgroup_of G\n ==> group_normalizer (subgroup_generated G h) s =\n h INTER group_normalizer G s`;;\n\nlet IN_GROUP_CENTRALIZER_ID = `!(G:A group) s. group_id G IN group_centralizer G s`;;\n\nlet IN_GROUP_NORMALIZER_ID = `!(G:A group) s. group_id G IN group_normalizer G s`;;\n\nlet GROUP_CENTRALIZER_NONEMPTY = `!(G:A group) s. ~(group_centralizer G s = {})`;;\n\nlet GROUP_NORMALIZER_NONEMPTY = `!(G:A group) s. ~(group_normalizer G s = {})`;;\n\nlet GROUP_CENTRALIZER_SUBSET = `!G s:A->bool.\n s SUBSET group_centralizer G s <=>\n s SUBSET group_carrier G /\\\n !a b. a IN s /\\ b IN s ==> group_mul G a b = group_mul G b a`;;\n\nlet GROUP_CENTRALIZER_SUBSET_EQ = `!G h:A->bool.\n h subgroup_of G\n ==> (h SUBSET group_centralizer G h <=>\n abelian_group(subgroup_generated G h))`;;\n\nlet GROUP_CENTRE_EQ_CARRIER = `!G:A group.\n group_centralizer G (group_carrier G) = group_carrier G <=>\n abelian_group G`;;\n\nlet GROUP_CENTRALIZER_CENTRALIZER_SUBSET = `!G s:A->bool.\n s SUBSET group_centralizer G (group_centralizer G s) <=>\n s SUBSET group_carrier G`;;\n\nlet GROUP_NORMALIZER_MAXIMAL_GEN = `!G h n:A->bool.\n h normal_subgroup_of (subgroup_generated G n) <=>\n h subgroup_of (subgroup_generated G n) /\\\n group_carrier G INTER n SUBSET group_normalizer G h`;;\n\nlet GROUP_NORMALIZER_MAXIMAL = `!G h n:A->bool.\n n subgroup_of G\n ==> (h normal_subgroup_of (subgroup_generated G n) <=>\n h subgroup_of G /\\ h SUBSET n /\\ n SUBSET group_normalizer G h)`;;\n\nlet NORMAL_SUBGROUP_NORMALIZER_CONTAINS_CARRIER = `!G n:A->bool.\n n normal_subgroup_of G <=>\n n subgroup_of G /\\ group_carrier G SUBSET group_normalizer G n`;;\n\nlet NORMAL_SUBGROUP_NORMALIZER_EQ_CARRIER = `!G n:A->bool.\n n normal_subgroup_of G <=>\n n subgroup_of G /\\ group_normalizer G n = group_carrier G`;;\n\nlet GROUP_NORMALIZER_SUBSET = `!G h:A->bool.\n h subgroup_of G ==> h SUBSET group_normalizer G h`;;\n\nlet NORMAL_SUBGROUP_OF_NORMALIZER = `!G h:A->bool.\n h normal_subgroup_of (subgroup_generated G (group_normalizer G h)) <=>\n h subgroup_of G`;;\n\nlet GROUP_CENTRALIZER_POINTWISE = `!G s:A->bool.\n group_centralizer G s =\n if s = {} then group_carrier G\n else INTERS {group_centralizer G {x} | x IN s}`;;\n\nlet GROUP_CENTRALIZER_ALT = `!G s:A->bool.\n group_centralizer G s =\n {x | x IN group_carrier G /\\\n !y. y IN group_carrier G /\\ y IN s\n ==> group_conjugation G x y = y}`;;\n\nlet NORMAL_SUBGROUP_CENTRALIZER_NORMALIZER = `!G h:A->bool.\n group_centralizer G h normal_subgroup_of\n subgroup_generated G (group_normalizer G h)`;;\n\nlet NORMAL_SUBGROUP_CENTRALIZER = `!G n:A->bool.\n n normal_subgroup_of G\n ==> group_centralizer G n normal_subgroup_of G`;;\n\nlet GROUP_NORMALIZER_SING = `!G a:A. group_normalizer G {a} = group_centralizer G {a}`;;\n\nlet GROUP_CENTRALIZER_GALOIS_EQ = `!G s t:A->bool.\n s SUBSET group_carrier G /\\ t SUBSET group_carrier G\n ==> (s SUBSET group_centralizer G t <=>\n t SUBSET group_centralizer G s)`;;\n\nlet GROUP_CENTRALIZER_GALOIS = `!G s t:A->bool.\n s SUBSET group_carrier G /\\ t SUBSET group_centralizer G s\n ==> s SUBSET group_centralizer G t`;;\n\nlet GROUP_CENTRALIZER_MONO = `!G s t:A->bool.\n s SUBSET t ==> group_centralizer G t SUBSET group_centralizer G s`;;\n\nlet GROUP_ACTION_CONJUGATION_NORMAL_SUBGROUP = `!G n:A->bool.\n n normal_subgroup_of G\n ==> group_action G n (group_conjugation G)`;;\n\nlet GROUP_STABILIZER_CONJUGATION = `!G a:A.\n a IN group_carrier G\n ==> group_stabilizer G (group_conjugation G) a =\n group_centralizer G {a}`;;\n\nlet GROUP_ORBIT_CONJUGATION_GEN = `!G s x:A.\n s SUBSET group_carrier G\n ==> group_orbit G s (group_conjugation G) x =\n if x IN s then {y | y IN s /\\ group_conjugate G {x} {y}} else {}`;;\n\nlet GROUP_ORBIT_CONJUGATION = `!G x:A.\n group_orbit G (group_carrier G) (group_conjugation G) x =\n if x IN group_carrier G\n then {y | y IN group_carrier G /\\ group_conjugate G {x} {y}}\n else {}`;;\n\nlet GROUP_ACTION_IMAGE_CONJUGATION = `!G u:(A->bool)->bool.\n (!t. t IN u ==> t SUBSET group_carrier G) /\\\n (!g t. g IN group_carrier G /\\ t IN u\n ==> IMAGE (group_conjugation G g) t IN u)\n ==> group_action G u (IMAGE o group_conjugation G)`;;\n\nlet GROUP_STABILIZER_IMAGE_CONJUGATION = `!G s:A->bool.\n s SUBSET group_carrier G\n ==> group_stabilizer G (IMAGE o group_conjugation G) s =\n group_normalizer G s`;;\n\nlet GROUP_ACTION_IMAGE_CONJUGATION_CARRIER = `!G:A group. group_action G {s | s SUBSET group_carrier G}\n (IMAGE o group_conjugation G)`;;\n\nlet GROUP_ACTION_IMAGE_CONJUGATION_SUBGROUPS = `!G:A group. group_action G {n | n subgroup_of G}\n (IMAGE o group_conjugation G)`;;\n\nlet GROUP_ORBIT_IMAGE_CONJUGATION = `!G. group_orbit G {s | s SUBSET group_carrier G}\n (IMAGE o group_conjugation G) =\n group_conjugate G`;;\n\nlet GROUP_ORBIT_IMAGE_CONJUGATION_GEN = `!G u s:A->bool.\n (!t. t IN u ==> t SUBSET group_carrier G) /\\ s IN u\n ==> group_orbit G u (IMAGE o group_conjugation G) s =\n \\t. t IN u /\\ group_conjugate G s t`;;\n\nlet CARD_CONJUGATE_SUBSETS_MUL_GEN = `!G s:A->bool.\n s SUBSET group_carrier G\n ==> {t | group_conjugate G s t} *_c group_normalizer G s =_c\n group_carrier G`;;\n\nlet CARD_CONJUGATE_SUBSETS_MUL = `!G s:A->bool.\n FINITE(group_carrier G) /\\ s SUBSET group_carrier G\n ==> CARD {t | group_conjugate G s t} * CARD(group_normalizer G s) =\n CARD(group_carrier G)`;;\n\nlet CARD_CONJUGATE_SUBSETS = `!G s:A->bool.\n FINITE(group_carrier G) /\\ s SUBSET group_carrier G\n ==> CARD {t | group_conjugate G s t} =\n CARD(group_carrier G) DIV CARD(group_normalizer G s)`;;\n\nlet quotient_group = new_definition\n `quotient_group G (n:A->bool) =\n group ({right_coset G n x |x| x IN group_carrier G},\n n,group_setinv G,group_setmul G)`;;\n\nlet QUOTIENT_GROUP = `(!G n:A->bool.\n n normal_subgroup_of G\n ==> group_carrier(quotient_group G n) =\n {right_coset G n x |x| x IN group_carrier G}) /\\\n (!G n:A->bool.\n n normal_subgroup_of G\n ==> group_id(quotient_group G n) = n) /\\\n (!G n:A->bool.\n n normal_subgroup_of G\n ==> group_inv(quotient_group G n) = group_setinv G) /\\\n (!G n:A->bool.\n n normal_subgroup_of G\n ==> group_mul(quotient_group G n) = group_setmul G)`;;\n\nlet ABELIAN_QUOTIENT_GROUP = `!G n:A->bool.\n abelian_group G /\\ n subgroup_of G ==> abelian_group(quotient_group G n)`;;\n\nlet FINITE_QUOTIENT_GROUP = `!G n:A->bool.\n FINITE(group_carrier G) /\\ n normal_subgroup_of G\n ==> FINITE(group_carrier(quotient_group G n))`;;\n\nlet TRIVIAL_QUOTIENT_GROUP = `!G n:A->bool.\n trivial_group G /\\ n normal_subgroup_of G\n ==> trivial_group(quotient_group G n)`;;\n\nlet QUOTIENT_GROUP_ID = `!G n:A->bool.\n n normal_subgroup_of G\n ==> group_id(quotient_group G n) = n`;;\n\nlet QUOTIENT_GROUP_INV = `!G n a:A.\n n normal_subgroup_of G /\\ a IN group_carrier G\n ==> group_inv (quotient_group G n) (right_coset G n a) =\n right_coset G n (group_inv G a)`;;\n\nlet QUOTIENT_GROUP_MUL = `!G n a b:A.\n n normal_subgroup_of G /\\ a IN group_carrier G /\\ b IN group_carrier G\n ==> group_mul (quotient_group G n)\n (right_coset G n a) (right_coset G n b) =\n right_coset G n (group_mul G a b)`;;\n\nlet QUOTIENT_GROUP_DIV = `!G n a b:A.\n n normal_subgroup_of G /\\ a IN group_carrier G /\\ b IN group_carrier G\n ==> group_div (quotient_group G n)\n (right_coset G n a) (right_coset G n b) =\n right_coset G n (group_div G a b)`;;\n\nlet QUOTIENT_GROUP_POW = `!G n (a:A) k.\n n normal_subgroup_of G /\\ a IN group_carrier G\n ==> group_pow (quotient_group G n) (right_coset G n a) k =\n right_coset G n (group_pow G a k)`;;\n\nlet QUOTIENT_GROUP_ZPOW = `!G n (a:A) k.\n n normal_subgroup_of G /\\ a IN group_carrier G\n ==> group_zpow (quotient_group G n) (right_coset G n a) k =\n right_coset G n (group_zpow G a k)`;;\n\nlet GROUP_HOMOMORPHISM_RIGHT_COSET = `!G n:A->bool.\n n normal_subgroup_of G\n ==> group_homomorphism (G,quotient_group G n) (right_coset G n)`;;\n\nlet GROUP_EPIMORPHISM_RIGHT_COSET = `!G n:A->bool.\n n normal_subgroup_of G\n ==> group_epimorphism (G,quotient_group G n) (right_coset G n)`;;\n\nlet CARD_LE_QUOTIENT_GROUP = `!G n:A->bool.\n n normal_subgroup_of G\n ==> group_carrier(quotient_group G n) <=_c group_carrier G`;;\n\nlet CARD_QUOTIENT_GROUP_DIVIDES = `!G n:A->bool.\n FINITE(group_carrier G) /\\ n normal_subgroup_of G\n ==> CARD(group_carrier(quotient_group G n)) divides\n CARD(group_carrier G)`;;\n\nlet TRIVIAL_QUOTIENT_GROUP_EQ = `!G n:A->bool.\n n normal_subgroup_of G\n ==> (trivial_group(quotient_group G n) <=> n = group_carrier G)`;;\n\nlet TRIVIAL_QUOTIENT_GROUP_SELF = `!G:A group. trivial_group(quotient_group G (group_carrier G))`;;\n\nlet QUOTIENT_GROUP_TRIVIAL = `!G:A group. quotient_group G {group_id G} isomorphic_group G`;;\n\nlet GROUP_ISOMORPHISM_PROD_QUOTIENT_GROUP = `!(G1:A group) (G2:B group) n1 n2.\n n1 normal_subgroup_of G1 /\\ n2 normal_subgroup_of G2\n ==> group_isomorphism(prod_group (quotient_group G1 n1)\n (quotient_group G2 n2),\n quotient_group (prod_group G1 G2) (n1 CROSS n2))\n (\\(s,t). s CROSS t)`;;\n\nlet ISOMORPHIC_QUOTIENT_PROD_GROUP = `!(G1:A group) (G2:B group) n1 n2.\n n1 normal_subgroup_of G1 /\\ n2 normal_subgroup_of G2\n ==> quotient_group (prod_group G1 G2) (n1 CROSS n2) isomorphic_group\n prod_group (quotient_group G1 n1) (quotient_group G2 n2)`;;\n\nlet CARTESIAN_PRODUCT_NORMAL_SUBGROUP_OF_PRODUCT_GROUP = `!(G:K->A group) h k.\n (cartesian_product k h) normal_subgroup_of (product_group k G) <=>\n !i. i IN k ==> (h i) normal_subgroup_of (G i)`;;\n\nlet GROUP_ISOMORPHISM_PRODUCT_QUOTIENT_GROUP = `!(G:K->A group) n k.\n (!i. i IN k ==> (n i) normal_subgroup_of (G i))\n ==> group_isomorphism\n (product_group k (\\i. quotient_group (G i) (n i)),\n quotient_group (product_group k G) (cartesian_product k n))\n (cartesian_product k)`;;\n\nlet ISOMORPHIC_QUOTIENT_PRODUCT_GROUP = `!(G:K->A group) n k.\n (!i. i IN k ==> (n i) normal_subgroup_of (G i))\n ==> (quotient_group (product_group k G) (cartesian_product k n))\n isomorphic_group\n (product_group k (\\i. quotient_group (G i) (n i)))`;;\n\nlet SUBGROUP_OF_QUOTIENT_GROUP,SUBGROUP_OF_QUOTIENT_GROUP_ALT =\n (CONJ_PAIR o prove)\n (`(!G n h:(A->bool)->bool.\n n normal_subgroup_of G\n ==> (h subgroup_of quotient_group G n <=>\n ?k. k subgroup_of G /\\ { right_coset G n x | x IN k} = h)) /\\\n (!G n h:(A->bool)->bool.\n n normal_subgroup_of G\n ==> (h subgroup_of quotient_group G n <=>\n ?k. k subgroup_of G /\\\n n SUBSET k /\\\n { right_coset G n x | x IN k} = h))`,\n REWRITE_TAC[AND_FORALL_THM; TAUT\n `(p ==> q) /\\ (p ==> r) <=> p ==> q /\\ r`] THEN\n REPEAT GEN_TAC THEN DISCH_TAC THEN MATCH_MP_TAC(TAUT\n `(r ==> q) /\\ (p ==> r) /\\ (q ==> p)\n ==> (p <=> q) /\\ (p <=> r)`) THEN\n REPEAT CONJ_TAC THENL\n [MESON_TAC[];\n DISCH_TAC THEN\n EXISTS_TAC `{x:A | x IN group_carrier G /\\ right_coset G n x IN h}` THEN\n MATCH_MP_TAC(TAUT `q /\\ p /\\ r ==> p /\\ q /\\ r`) THEN CONJ_TAC THENL\n [FIRST_ASSUM(MP_TAC o MATCH_MP IN_SUBGROUP_ID) THEN\n MATCH_MP_TAC(SET_RULE\n `n SUBSET {x | x IN s /\\ f x = z}\n ==> z IN h ==> n SUBSET {x | x IN s /\\ f x IN h}`) THEN\n ASM_SIMP_TAC[QUOTIENT_GROUP; SUBSET; IN_ELIM_THM] THEN\n ASM_MESON_TAC[RIGHT_COSET_EQ_SUBGROUP; normal_subgroup_of;\n subgroup_of; SUBSET];\n REWRITE_TAC[SIMPLE_IMAGE] THEN\n MATCH_MP_TAC SUBGROUP_OF_EPIMORPHIC_PREIMAGE THEN\n EXISTS_TAC `quotient_group (G:A group) n` THEN\n ASM_SIMP_TAC[GROUP_EPIMORPHISM_RIGHT_COSET; ETA_AX]];\n DISCH_THEN(X_CHOOSE_THEN `k:A->bool`\n (CONJUNCTS_THEN2 ASSUME_TAC (SUBST1_TAC o SYM))) THEN\n REWRITE_TAC[SIMPLE_IMAGE] THEN\n MATCH_MP_TAC SUBGROUP_OF_HOMOMORPHIC_IMAGE THEN\n EXISTS_TAC `G:A group` THEN\n ASM_SIMP_TAC[GROUP_HOMOMORPHISM_RIGHT_COSET; ETA_AX]]);;\n\nlet SUBGROUP_OF_QUOTIENT_GROUP_GENERATED_BY = `!G n h:(A->bool)->bool.\n n normal_subgroup_of G /\\ h subgroup_of quotient_group G n\n ==> ?k. k subgroup_of G /\\ n SUBSET k /\\\n quotient_group (subgroup_generated G k) n =\n subgroup_generated (quotient_group G n) h`;;\n\nlet QUOTIENT_GROUP_SUBGROUP_GENERATED = `!G h n:A->bool.\n n normal_subgroup_of G /\\ h subgroup_of G /\\ n SUBSET h\n ==> quotient_group (subgroup_generated G h) n =\n subgroup_generated (quotient_group G n)\n {right_coset G n x | x IN h}`;;\n\nlet group_kernel = new_definition\n `group_kernel (G,G') (f:A->B) =\n {x | x IN group_carrier G /\\ f x = group_id G'}`;;\n\nlet group_image = new_definition\n `group_image (G:A group,G':B group) (f:A->B) = IMAGE f (group_carrier G)`;;\n\nlet GROUP_KERNEL_ID = `!G G' (f:A->B).\n group_homomorphism(G,G') f\n ==> group_id G IN group_kernel (G,G') f`;;\n\nlet GROUP_KERNEL_NONEMPTY = `!G H (f:A->B).\n group_homomorphism(G,H) f ==> ~(group_kernel(G,H) f = {})`;;\n\nlet GROUP_KERNEL_SUBSET_CARRIER = `!G H (f:A->B). group_kernel(G,H) f SUBSET group_carrier G`;;\n\nlet GROUP_MONOMORPHISM = `!G G' (f:A->B).\n group_monomorphism(G,G') f <=>\n group_homomorphism(G,G') f /\\\n group_kernel (G,G') f = {group_id G}`;;\n\nlet GROUP_MONOMORPHISM_ALT = `!G G' (f:A->B).\n group_monomorphism(G,G') f <=>\n group_homomorphism(G,G') f /\\\n !x. x IN group_carrier G /\\ f x = group_id G' ==> x = group_id G`;;\n\nlet GROUP_MONOMORPHISM_ALT_EQ = `!G G' f:A->B.\n group_monomorphism (G,G') f <=>\n group_homomorphism (G,G') f /\\\n !x. x IN group_carrier G ==> (f x = group_id G' <=> x = group_id G)`;;\n\nlet GROUP_EPIMORPHISM = `!G G' (f:A->B).\n group_epimorphism(G,G') f <=>\n group_homomorphism(G,G') f /\\\n group_image (G,G') f = group_carrier G'`;;\n\nlet GROUP_EPIMORPHISM_ALT = `!G G' (f:A->B).\n group_epimorphism(G,G') f <=>\n group_homomorphism(G,G') f /\\\n group_carrier G' SUBSET group_image (G,G') f`;;\n\nlet GROUP_ISOMORPHISM_EPIMORPHISM_ALT = `!G G' (f:A->B).\n group_isomorphism (G,G') f <=>\n group_epimorphism (G,G') f /\\\n (!x. x IN group_carrier G /\\ f x = group_id G' ==> x = group_id G)`;;\n\nlet GROUP_ISOMORPHISM_GROUP_KERNEL_GROUP_IMAGE = `!G G' (f:A->B).\n group_isomorphism (G,G') f <=>\n group_homomorphism(G,G') f /\\\n group_kernel (G,G') f = {group_id G} /\\\n group_image (G,G') f = group_carrier G'`;;\n\nlet GROUP_ISOMORPHISM_ALT = `!G G' (f:A->B).\n group_isomorphism (G,G') f <=>\n IMAGE f (group_carrier G) = group_carrier G' /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G\n ==> f(group_mul G x y) = group_mul G' (f x) (f y)) /\\\n (!x. x IN group_carrier G /\\ f x = group_id G' ==> x = group_id G)`;;\n\nlet SUBGROUP_GROUP_KERNEL = `!G G' (f:A->B).\n group_homomorphism(G,G') f ==> (group_kernel (G,G') f) subgroup_of G`;;\n\nlet SUBGROUP_GROUP_IMAGE = `!G G' (f:A->B).\n group_homomorphism(G,G') f ==> (group_image (G,G') f) subgroup_of G'`;;\n\nlet GROUP_KERNEL_TO_SUBGROUP_GENERATED = `!G H s (f:A->B).\n group_kernel (G,subgroup_generated H s) f = group_kernel(G,H) f`;;\n\nlet GROUP_IMAGE_TO_SUBGROUP_GENERATED = `!G H s (f:A->B).\n group_image (G,subgroup_generated H s) f = group_image(G,H) f`;;\n\nlet GROUP_KERNEL_FROM_SUBGROUP_GENERATED = `!G H s f:A->B.\n s subgroup_of G\n ==> group_kernel(subgroup_generated G s,H) f =\n group_kernel(G,H) f INTER s`;;\n\nlet GROUP_IMAGE_FROM_SUBGROUP_GENERATED = `!G H s f:A->B.\n s subgroup_of G\n ==> group_image(subgroup_generated G s,H) f =\n group_image(G,H) f INTER IMAGE f s`;;\n\nlet GROUP_ISOMORPHISM_ONTO_IMAGE = `!(f:A->B) G H.\n group_isomorphism(G,subgroup_generated H (group_image (G,H) f)) f <=>\n group_monomorphism(G,H) f`;;\n\nlet NORMAL_SUBGROUP_GROUP_KERNEL = `!G G' (f:A->B).\n group_homomorphism(G,G') f\n ==> (group_kernel (G,G') f) normal_subgroup_of G`;;\n\nlet GROUP_KERNEL_RIGHT_COSET = `!G n:A->bool.\n n normal_subgroup_of G\n ==> group_kernel(G,quotient_group G n) (right_coset G n) = n`;;\n\nlet CARD_EQ_GROUP_IMAGE_KERNEL = `!G H (f:A->B).\n group_homomorphism(G,H) f\n ==> group_image(G,H) f *_c group_kernel(G,H) f =_c group_carrier G`;;\n\nlet CARD_DIVIDES_GROUP_MONOMORPHIC_IMAGE = `!G H (f:A->B).\n group_monomorphism(G,H) f /\\ FINITE(group_carrier H)\n ==> CARD(group_carrier G) divides CARD(group_carrier H)`;;\n\nlet CARD_DIVIDES_GROUP_EPIMORPHIC_IMAGE = `!G H (f:A->B).\n group_epimorphism(G,H) f /\\ FINITE(group_carrier G)\n ==> CARD(group_carrier H) divides CARD(group_carrier G)`;;\n\nlet QUOTIENT_GROUP_UNIVERSAL_EXPLICIT = `!G G' n (f:A->B).\n group_homomorphism (G,G') f /\\ n normal_subgroup_of G /\\\n (!x y. x IN group_carrier G /\\ y IN group_carrier G /\\\n right_coset G n x = right_coset G n y\n ==> f x = f y)\n ==> ?g. group_homomorphism(quotient_group G n,G') g /\\\n !x. x IN group_carrier G ==> g(right_coset G n x) = f x`;;\n\nlet QUOTIENT_GROUP_UNIVERSAL = `!G G' n (f:A->B).\n group_homomorphism (G,G') f /\\\n n normal_subgroup_of G /\\\n n SUBSET group_kernel (G,G') f\n ==> ?g. group_homomorphism(quotient_group G n,G') g /\\\n !x. x IN group_carrier G ==> g(right_coset G n x) = f x`;;\n\nlet QUOTIENT_GROUP_UNIVERSAL_EPIMORPHISM = `!G G' n (f:A->B).\n group_epimorphism (G,G') f /\\\n n normal_subgroup_of G /\\\n n SUBSET group_kernel (G,G') f\n ==> ?g. group_epimorphism(quotient_group G n,G') g /\\\n !x. x IN group_carrier G ==> g(right_coset G n x) = f x`;;\n\nlet GROUP_KERNEL_FROM_TRIVIAL_GROUP = `!G H (f:A->B).\n group_homomorphism (G,H) f /\\ trivial_group G\n ==> group_kernel (G,H) f = group_carrier G`;;\n\nlet GROUP_IMAGE_FROM_TRIVIAL_GROUP = `!G H (f:A->B).\n group_homomorphism (G,H) f /\\ trivial_group G\n ==> group_image (G,H) f = {group_id H}`;;\n\nlet GROUP_KERNEL_TO_TRIVIAL_GROUP = `!G H (f:A->B).\n group_homomorphism (G,H) f /\\ trivial_group H\n ==> group_kernel (G,H) f = group_carrier G`;;\n\nlet GROUP_IMAGE_TO_TRIVIAL_GROUP = `!G H (f:A->B).\n group_homomorphism (G,H) f /\\ trivial_group H\n ==> group_image (G,H) f = group_carrier H`;;\n\nlet FIRST_GROUP_ISOMORPHISM_THEOREM = `!G G' (f:A->B).\n group_homomorphism(G,G') f\n ==> (quotient_group G (group_kernel (G,G') f)) isomorphic_group\n (subgroup_generated G' (group_image (G,G') f))`;;\n\nlet FIRST_GROUP_EPIMORPHISM_THEOREM = `!G G' (f:A->B).\n group_epimorphism(G,G') f\n ==> (quotient_group G (group_kernel (G,G') f)) isomorphic_group G'`;;\n\nlet GROUP_HOMOMORPHISM_PREIMAGE_IMAGE_RIGHT = `!G H (f:A->B) s.\n group_homomorphism(G,H) f /\\ s SUBSET group_carrier G\n ==> {x | x IN group_carrier G /\\ f x IN IMAGE f s} =\n group_setmul G s (group_kernel(G,H) f)`;;\n\nlet GROUP_HOMOMORPHISM_PREIMAGE_IMAGE_LEFT = `!G H (f:A->B) s.\n group_homomorphism(G,H) f /\\ s SUBSET group_carrier G\n ==> {x | x IN group_carrier G /\\ f x IN IMAGE f s} =\n group_setmul G (group_kernel(G,H) f) s`;;\n\nlet GROUP_HOMOMORPHISM_IMAGE_PREIMAGE = `!G H (f:A->B) t.\n group_homomorphism(G,H) f\n ==> IMAGE f {x | x IN group_carrier G /\\ f x IN t} =\n t INTER (group_image(G,H) f)`;;\n\nlet GROUP_HOMOMORPHISM_PREIMAGE_IMAGE = `!G H (f:A->B) s.\n group_homomorphism(G,H) f /\\\n group_kernel(G,H) f SUBSET s /\\\n s subgroup_of G\n ==> {x | x IN group_carrier G /\\ f x IN IMAGE f s} = s`;;\n\nlet GROUP_HOMOMORPHISM_IMAGE_PREIMAGE_EQ = `!G H (f:A->B) t.\n group_homomorphism(G,H) f /\\ t SUBSET group_image(G,H) f\n ==> IMAGE f {x | x IN group_carrier G /\\ f x IN t} = t`;;\n\nlet GROUP_EPIMORPHISM_SUBGROUP_CORRESPONDENCE = `!G H (f:A->B) k.\n group_epimorphism(G,H) f\n ==> (k subgroup_of H <=>\n ?j. j subgroup_of G /\\\n group_kernel(G,H) f SUBSET j /\\\n {x | x IN group_carrier G /\\ f x IN k} = j /\\\n IMAGE f j = k)`;;\n\nlet GROUP_EPIMORPHISM_SUBGROUP_CORRESPONDENCE_ALT = `!G H (f:A->B) j.\n group_epimorphism(G,H) f\n ==> (j subgroup_of G /\\ group_kernel(G,H) f SUBSET j <=>\n ?k. k subgroup_of H /\\\n {x | x IN group_carrier G /\\ f x IN k} = j /\\\n IMAGE f j = k)`;;\n\nlet NORMAL_SUBGROUP_OF_HOMOMORPHIC_PREIMAGE = `!G H (f:A->B) j.\n group_homomorphism(G,H) f /\\ j normal_subgroup_of H\n ==> {x | x IN group_carrier G /\\ f x IN j} normal_subgroup_of G`;;\n\nlet NORMAL_SUBGROUP_OF_EPIMORPHIC_IMAGE = `!G H (f:A->B) n.\n group_epimorphism(G,H) f /\\ n normal_subgroup_of G\n ==> IMAGE f n normal_subgroup_of H`;;\n\nlet NORMAL_SUBGROUP_OF_EPIMORPHIC_PREIMAGE_EQ = `!G H (f:A->B) j k.\n group_epimorphism (G,H) f /\\\n k subgroup_of H /\\\n {x | x IN group_carrier G /\\ f x IN k} = j\n ==> (j normal_subgroup_of G <=> k normal_subgroup_of H)`;;\n\nlet GROUP_EPIMORPHISM_NORMAL_SUBGROUP_CORRESPONDENCE = `!G H (f:A->B) k.\n group_epimorphism(G,H) f\n ==> (k normal_subgroup_of H <=>\n ?j. j normal_subgroup_of G /\\\n group_kernel(G,H) f SUBSET j /\\\n {x | x IN group_carrier G /\\ f x IN k} = j /\\\n IMAGE f j = k)`;;\n\nlet GROUP_EPIMORPHISM_NORMAL_SUBGROUP_CORRESPONDENCE_ALT = `!G H (f:A->B) j.\n group_epimorphism(G,H) f\n ==> (j normal_subgroup_of G /\\ group_kernel(G,H) f SUBSET j <=>\n ?k. k normal_subgroup_of H /\\\n {x | x IN group_carrier G /\\ f x IN k} = j /\\\n IMAGE f j = k)`;;\n\nlet SUBGROUP_OF_ISOMORPHIC_IMAGE_EQ = `!G H (f:A->B) j.\n group_isomorphism(G,H) f /\\ j SUBSET group_carrier G\n ==> ((IMAGE f j) subgroup_of H <=> j subgroup_of G)`;;\n\nlet NORMAL_SUBGROUP_OF_ISOMORPHIC_IMAGE_EQ = `!G H (f:A->B) j.\n group_isomorphism(G,H) f /\\ j SUBSET group_carrier G\n ==> ((IMAGE f j) normal_subgroup_of H <=> j normal_subgroup_of G)`;;\n\nlet GROUP_CONJUGATE_SUBGROUP_OF = `!G s t:A->bool.\n group_conjugate G s t\n ==> (s subgroup_of G <=> t subgroup_of G)`;;\n\nlet GROUP_CONJUGATE_NORMAL_SUBGROUP_OF = `!G s t:A->bool.\n group_conjugate G s t\n ==> (s normal_subgroup_of G <=> t normal_subgroup_of G)`;;\n\nlet NORMAL_SUBGROUP_CONJUGATE = `!G n:A->bool.\n n normal_subgroup_of G <=>\n n subgroup_of G /\\ !n'. group_conjugate G n n' ==> n' = n`;;\n\nlet NORMAL_SUBGROUP_CONJUGATE_EQ = `!G n n':A->bool.\n n normal_subgroup_of G \\/ n' normal_subgroup_of G\n ==> (group_conjugate G n n' <=> n = n')`;;\n\nlet QUOTIENT_SUBGROUP_CORRESPONDENCE = `!(G:A group) j k.\n j normal_subgroup_of G\n ==> (k subgroup_of (quotient_group G j) <=>\n ?i. i subgroup_of G /\\ j SUBSET i /\\\n {x | x IN group_carrier G /\\ right_coset G j x IN k} = i /\\\n IMAGE (right_coset G j) i = k)`;;\n\nlet QUOTIENT_NORMAL_SUBGROUP_CORRESPONDENCE = `!(G:A group) j k.\n j normal_subgroup_of G\n ==> (k normal_subgroup_of (quotient_group G j) <=>\n ?i. i normal_subgroup_of G /\\ j SUBSET i /\\\n {x | x IN group_carrier G /\\ right_coset G j x IN k} = i /\\\n IMAGE (right_coset G j) i = k)`;;\n\nlet FIRST_GROUP_ISOMORPHISM_THEOREM_GEN = `!G H (f:A->B) j k.\n group_epimorphism(G,H) f /\\\n k normal_subgroup_of H /\\ {x | x IN group_carrier G /\\ f x IN k} = j\n ==> quotient_group G j isomorphic_group quotient_group H k`;;\n\nlet FIRST_GROUP_ISOMORPHISM_THEOREM_GEN_ALT = `!G H (f:A->B) j k.\n group_epimorphism(G,H) f /\\ j normal_subgroup_of G /\\\n group_kernel (G,H) f SUBSET j /\\ IMAGE f j = k\n ==> quotient_group G j isomorphic_group quotient_group H k`;;\n\nlet SIMPLE_GROUP_EPIMORPHIC_IMAGE_EQ = `!G H (f:A->B).\n group_epimorphism(G,H) f\n ==> ((!k. k normal_subgroup_of H\n ==> k = {group_id H} \\/ k = group_carrier H) <=>\n (!h. h normal_subgroup_of G /\\ group_kernel(G,H) f PSUBSET h\n ==> h = group_carrier G))`;;\n\nlet NO_PROPER_SUBGROUP_EPIMORPHIC_IMAGE_EQ = `!G H (f:A->B).\n group_epimorphism(G,H) f\n ==> ((!k. k subgroup_of H\n ==> k = {group_id H} \\/ k = group_carrier H) <=>\n (!h. h subgroup_of G /\\ group_kernel(G,H) f PSUBSET h\n ==> h = group_carrier G))`;;\n\nlet MAXIMAL_SUBGROUP = `!G n:A->bool.\n n normal_subgroup_of G\n ==> ((!h. h subgroup_of G /\\ n PSUBSET h ==> h = group_carrier G) <=>\n (!k. k subgroup_of quotient_group G n\n ==> k = {group_id(quotient_group G n)} \\/\n k = group_carrier(quotient_group G n)))`;;\n\nlet MAXIMAL_NORMAL_SUBGROUP = `!G n:A->bool.\n n normal_subgroup_of G\n ==> ((!h. h normal_subgroup_of G /\\ n PSUBSET h\n ==> h = group_carrier G) <=>\n (!k. k normal_subgroup_of quotient_group G n\n ==> k = {group_id(quotient_group G n)} \\/\n k = group_carrier(quotient_group G n)))`;;\n\nlet trivial_homomorphism = new_definition\n `trivial_homomorphism(G,G') (f:A->B) <=>\n group_homomorphism(G,G') f /\\\n !x. x IN group_carrier G ==> f x = group_id G'`;;\n\nlet GROUP_KERNEL_IMAGE_TRIVIAL = `!(f:A->B) G G'.\n group_homomorphism (G,G') f\n ==> (group_kernel(G,G') f = group_carrier G <=>\n group_image(G,G') f = {group_id G'})`;;\n\nlet TRIVIAL_HOMOMORPHISM_GROUP_KERNEL = `!(f:A->B) G G'.\n trivial_homomorphism(G,G') f <=>\n group_homomorphism(G,G') f /\\\n group_kernel(G,G') f = group_carrier G`;;\n\nlet TRIVIAL_HOMOMORPHISM_GROUP_IMAGE = `!(f:A->B) G G'.\n trivial_homomorphism(G,G') f <=>\n group_homomorphism(G,G') f /\\\n group_image(G,G') f = {group_id G'}`;;\n\nlet TRIVIAL_HOMOMORPHISM_TRIVIAL = `!G H. trivial_homomorphism (G,H) (\\x. group_id H)`;;\n\nlet GROUP_MONOMORPHISM_TRIVIAL = `!G H. group_monomorphism (G,H) (\\x. group_id H) <=> trivial_group G`;;\n\nlet GROUP_EPIMORPHISM_TRIVIAL = `!G H. group_epimorphism (G,H) (\\x. group_id H) <=> trivial_group H`;;\n\nlet GROUP_ISOMORPHISM_TRIVIAL = `!G H. group_isomorphism (G,H) (\\x. group_id H) <=>\n trivial_group G /\\ trivial_group H`;;\n\nlet group_element_order = new_definition\n `group_element_order G (x:A) =\n @d. !n. group_pow G x n = group_id G <=> d divides n`;;\n\nlet GROUP_POW_EQ_ID = `!G (x:A) n.\n x IN group_carrier G\n ==> (group_pow G x n = group_id G <=>\n (group_element_order G x) divides n)`;;\n\nlet GROUP_POW_EQ_ID_DIVISOR = `!G (x:A) m n.\n x IN group_carrier G /\\\n group_pow G x m = group_id G /\\\n m divides n\n ==> group_pow G x n = group_id G`;;\n\nlet GROUP_POW_ELEMENT_ORDER = `!G x:A. x IN group_carrier G\n ==> group_pow G x (group_element_order G x) = group_id G`;;\n\nlet GROUP_ZPOW_EQ_ID = `!G (x:A) n.\n x IN group_carrier G\n ==> (group_zpow G x n = group_id G <=>\n &(group_element_order G x) divides n)`;;\n\nlet GROUP_ZPOW_EQ_ID_DIVISOR = `!G (x:A) m n.\n x IN group_carrier G /\\\n group_zpow G x m = group_id G /\\\n m divides n\n ==> group_zpow G x n = group_id G`;;\n\nlet GROUP_ZPOW_EQ_ALT = `!G (x:A) m n.\n x IN group_carrier G\n ==> (group_zpow G x m = group_zpow G x n <=>\n &(group_element_order G x) divides n - m)`;;\n\nlet GROUP_ZPOW_EQ = `!G (x:A) m n.\n x IN group_carrier G\n ==> (group_zpow G x m = group_zpow G x n <=>\n (m == n) (mod &(group_element_order G x)))`;;\n\nlet GROUP_POW_EQ = `!G (x:A) m n.\n x IN group_carrier G\n ==> (group_pow G x m = group_pow G x n <=>\n (m == n) (mod (group_element_order G x)))`;;\n\nlet GROUP_ZPOW_REM_ELEMENT_ORDER = `!G (x:A) n.\n x IN group_carrier G\n ==> group_zpow G x (n rem &(group_element_order G x)) =\n group_zpow G x n`;;\n\nlet GROUP_POW_MOD_ELEMENT_ORDER = `!G (x:A) n.\n x IN group_carrier G\n ==> group_pow G x (n MOD group_element_order G x) =\n group_pow G x n`;;\n\nlet GROUP_ELEMENT_ORDER_EQ_0 = `!G (x:A).\n x IN group_carrier G\n ==> (group_element_order G x = 0 <=>\n !n. ~(n = 0) ==> ~(group_pow G x n = group_id G))`;;\n\nlet GROUP_ELEMENT_ORDER_UNIQUE = `!G (x:A) d.\n x IN group_carrier G\n ==> (group_element_order G x = d <=>\n !n. group_pow G x n = group_id G <=> d divides n)`;;\n\nlet GROUP_ELEMENT_ORDER_EQ_1 = `!G (x:A).\n x IN group_carrier G\n ==> (group_element_order G x = 1 <=> x = group_id G)`;;\n\nlet GROUP_ELEMENT_ORDER_UNIQUE_PRIME = `!G (x:A) p.\n x IN group_carrier G /\\ prime p\n ==> (group_element_order G x = p <=>\n ~(x = group_id G) /\\ group_pow G x p = group_id G)`;;\n\nlet GROUP_ELEMENT_ORDER_ID = `!G:A group. group_element_order G (group_id G) = 1`;;\n\nlet GROUP_ELEMENT_ORDER_INV = `!G x:A.\n x IN group_carrier G\n ==> group_element_order G (group_inv G x) = group_element_order G x`;;\n\nlet GROUP_POW_GCD_EQ_ID = `!G (x:A) m n.\n x IN group_carrier G\n ==> (group_pow G x (gcd(m,n)) = group_id G <=>\n group_pow G x m = group_id G /\\ group_pow G x n = group_id G)`;;\n\nlet GROUP_POW_COPRIME_EQ_ID = `!G (x:A) m n.\n x IN group_carrier G /\\ coprime(m,n)\n ==> (group_pow G x m = group_id G /\\ group_pow G x n = group_id G <=>\n x = group_id G)`;;\n\nlet FINITE_GROUP_ELEMENT_ORDER_NONZERO = `!G x:A.\n FINITE(group_carrier G) /\\ x IN group_carrier G\n ==> ~(group_element_order G x = 0)`;;\n\nlet GROUP_ELEMENT_ORDER_POW = `!G (x:A) k.\n x IN group_carrier G /\\ ~(k = 0) /\\ k divides group_element_order G x\n ==> group_element_order G (group_pow G x k) =\n group_element_order G x DIV k`;;\n\nlet GROUP_ELEMENT_ORDER_POW_GEN = `!G (x:A) k.\n x IN group_carrier G\n ==> group_element_order G (group_pow G x k) =\n if k = 0 then 1\n else group_element_order G x DIV gcd(group_element_order G x,k)`;;\n\nlet GROUP_ELEMENT_ORDER_MUL_DIVIDES_GEN = `!G x (y:A) n.\n x IN group_carrier G /\\\n y IN group_carrier G /\\\n group_mul G x y = group_mul G y x /\\\n group_element_order G x divides n /\\\n group_element_order G y divides n\n ==> group_element_order G (group_mul G x y) divides n`;;\n\nlet ABELIAN_GROUP_ELEMENT_ORDER_MUL_DIVIDES_GEN = `!G x (y:A) n.\n abelian_group G /\\\n x IN group_carrier G /\\\n y IN group_carrier G /\\\n group_element_order G x divides n /\\\n group_element_order G y divides n\n ==> group_element_order G (group_mul G x y) divides n`;;\n\nlet GROUP_ELEMENT_ORDER_MUL_DIVIDES_LCM = `!G x (y:A).\n x IN group_carrier G /\\\n y IN group_carrier G /\\\n group_mul G x y = group_mul G y x\n ==> group_element_order G (group_mul G x y) divides\n lcm(group_element_order G x,group_element_order G y)`;;\n\nlet ABELIAN_GROUP_ELEMENT_ORDER_MUL_DIVIDES_LCM = `!G x (y:A).\n abelian_group G /\\\n x IN group_carrier G /\\\n y IN group_carrier G\n ==> group_element_order G (group_mul G x y) divides\n lcm(group_element_order G x,group_element_order G y)`;;\n\nlet GROUP_ELEMENT_ORDER_HOMOMORPHIC_IMAGE = `!G H (f:A->B) x.\n group_homomorphism(G,H) f /\\ x IN group_carrier G\n ==> group_element_order H (f x) divides group_element_order G x`;;\n\nlet GROUP_ELEMENT_ORDER_MONOMORPHIC_IMAGE = `!(f:A->B) G H x.\n group_monomorphism(G,H) f /\\ x IN group_carrier G\n ==> group_element_order H (f x) = group_element_order G x`;;\n\nlet ISOMORPHIC_GROUP_TORSION = `!P (G:A group) (H:B group).\n G isomorphic_group H\n ==> ((!x. x IN group_carrier G ==> P(group_element_order G x)) <=>\n (!y. y IN group_carrier H ==> P(group_element_order H y)))`;;\n\nlet GROUP_ELEMENT_ORDER_CONJUGATION = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> group_element_order G (group_conjugation G x y) =\n group_element_order G y`;;\n\nlet GROUP_ELEMENT_ORDER_MUL_DIVIDES = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = group_mul G y x\n ==> group_element_order G (group_mul G x y)\n divides (group_element_order G x * group_element_order G y)`;;\n\nlet ABELIAN_GROUP_ELEMENT_ORDER_MUL_DIVIDES = `!G x y:A.\n abelian_group G /\\ x IN group_carrier G /\\ y IN group_carrier G\n ==> group_element_order G (group_mul G x y)\n divides (group_element_order G x * group_element_order G y)`;;\n\nlet GROUP_POW_MUL_EQ_ID_SYM = `!G n x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> (group_pow G (group_mul G x y) n = group_id G <=>\n group_pow G (group_mul G y x) n = group_id G)`;;\n\nlet GROUP_ELEMENT_ORDER_MUL_SYM = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G\n ==> group_element_order G (group_mul G x y) =\n group_element_order G (group_mul G y x)`;;\n\nlet GROUP_ELEMENT_ORDER_UNIQUE_ALT = `!G (x:A) n.\n x IN group_carrier G /\\ ~(n = 0)\n ==> (group_element_order G x = n <=>\n group_pow G x n = group_id G /\\\n !m. 0 < m /\\ m < n ==> ~(group_pow G x m = group_id G))`;;\n\nlet GROUP_ELEMENT_ORDER_EQ_2 = `!G x:A.\n x IN group_carrier G\n ==> (group_element_order G x = 2 <=>\n ~(x = group_id G) /\\ group_pow G x 2 = group_id G)`;;\n\nlet GROUP_ELEMENT_ORDER_EQ_2_ALT = `!G x:A.\n x IN group_carrier G\n ==> (group_element_order G x = 2 <=>\n ~(x = group_id G) /\\ group_inv G x = x)`;;\n\nlet GROUP_ELEMENT_ORDER_POW_DIVIDES = `!G (x:A) n.\n x IN group_carrier G\n ==> group_element_order G (group_pow G x n) divides\n group_element_order G x`;;\n\nlet GROUP_ELEMENT_ORDER_MUL_EQ = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = group_mul G y x /\\\n coprime(group_element_order G x,group_element_order G y)\n ==> group_element_order G (group_mul G x y) =\n group_element_order G x * group_element_order G y`;;\n\nlet GROUP_ELEMENT_ORDER_EQ_MUL_GEN = `!G (x:A) k n.\n x IN group_carrier G /\\ ~(k = 0)\n ==> (group_element_order G x = k * n <=>\n k divides group_element_order G x /\\\n group_element_order G (group_pow G x k) = n)`;;\n\nlet GROUP_ELEMENT_ORDER_EQ_MUL = `!G (x:A) k n.\n x IN group_carrier G /\\ ~(k = 0) /\\ k divides n\n ==> (group_element_order G x = k * n <=>\n group_element_order G (group_pow G x k) = n)`;;\n\nlet ABELIAN_GROUP_ELEMENT_ORDER_MUL_EQ = `!G x y:A.\n abelian_group G /\\ x IN group_carrier G /\\ y IN group_carrier G /\\\n coprime(group_element_order G x,group_element_order G y)\n ==> group_element_order G (group_mul G x y) =\n group_element_order G x * group_element_order G y`;;\n\nlet GROUP_ELEMENT_ORDER_LCM_EXISTS = `!G x y:A.\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = group_mul G y x\n ==> ?z. z IN group_carrier G /\\\n group_element_order G z =\n lcm(group_element_order G x,group_element_order G y)`;;\n\nlet ABELIAN_GROUP_ELEMENT_ORDER_LCM_EXISTS = `!G x y:A.\n abelian_group G /\\\n x IN group_carrier G /\\ y IN group_carrier G\n ==> ?z. z IN group_carrier G /\\\n group_element_order G z =\n lcm(group_element_order G x,group_element_order G y)`;;\n\nlet ABELIAN_GROUP_ORDER_DIVIDES_MAXIMAL = `!G:A group.\n abelian_group G /\\ FINITE(group_carrier G)\n ==> ?x. x IN group_carrier G /\\\n !y. y IN group_carrier G\n ==> group_element_order G y divides group_element_order G x`;;\n\nlet ABELIAN_GROUP_ELEMENT_ORDER_DIVIDES_MAXIMAL_ALT = `!G:A group.\n abelian_group G /\\ FINITE(group_carrier G)\n ==> ?x. x IN group_carrier G /\\\n !y. y IN group_carrier G\n ==> group_pow G y (group_element_order G x) = group_id G`;;\n\nlet GROUP_ELEMENT_ORDER_SUBGROUP_GENERATED = `!G h x:A.\n group_element_order (subgroup_generated G h) x =\n group_element_order G x`;;\n\nlet GROUP_ELEMENT_ORDER_PROD_GROUP = `!(G:A group) (H:B group) x y.\n x IN group_carrier G /\\ y IN group_carrier H\n ==> group_element_order (prod_group G H) (x,y) =\n lcm(group_element_order G x,group_element_order H y)`;;\n\nlet GROUP_ELEMENT_ORDER_PROD_GROUP_ALT = `!(G:A group) (H:B group) z.\n z IN group_carrier(prod_group G H)\n ==> group_element_order (prod_group G H) z =\n lcm(group_element_order G (FST z),group_element_order H (SND z))`;;\n\nlet GROUP_ELEMENT_ORDER_SUM_GROUP = `!(G:K->A group) k x.\n x IN group_carrier(sum_group k G)\n ==> (group_element_order (sum_group k G) x =\n iterate (\\m n. lcm(m,n)) k\n (\\i. group_element_order (G i) (x i)))`;;\n\nlet GROUP_ELEMENT_ORDER_SUM_GROUP_EQ_0 = `!G k (x:K->A).\n x IN group_carrier (sum_group k G)\n ==> (group_element_order (sum_group k G) x = 0 <=>\n ?i. i IN k /\\ group_element_order (G i) (x i) = 0)`;;\n\nlet GROUP_ELEMENT_ORDER_COPRIME_DECOMP_EXPLICIT = `!G (x:A) m n.\n coprime(m,n) /\\\n x IN group_carrier G /\\\n group_element_order G x = m * n\n ==> ?r s. group_element_order G (group_zpow G x r) = m /\\\n group_element_order G (group_zpow G x s) = n /\\\n group_mul G (group_zpow G x r) (group_zpow G x s) = x`;;\n\nlet GROUP_ELEMENT_ORDER_COPRIME_DECOMP_UNIQUE = `!G (z:A) m n.\n coprime(m,n) /\\\n z IN group_carrier G /\\\n group_element_order G z = m * n\n ==> ?!(x,y). x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = z /\\\n group_mul G y x = z /\\\n group_element_order G x = m /\\\n group_element_order G y = n`;;\n\nlet GROUP_ELEMENT_ORDER_COPRIME_DECOMP = `!G (z:A) m n.\n coprime(m,n) /\\\n z IN group_carrier G /\\\n group_element_order G z = m * n\n ==> ?x y. x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = z /\\\n group_mul G y x = z /\\\n group_element_order G x = m /\\\n group_element_order G y = n`;;\n\nlet GROUP_ELEMENT_ORDER_COPRIME_DECOMP_DIVIDES = `!G (z:A) m n.\n coprime(m,n) /\\\n z IN group_carrier G /\\\n group_element_order G z divides m * n\n ==> ?x y. x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = z /\\\n group_mul G y x = z /\\\n group_element_order G x divides m /\\\n group_element_order G y divides n`;;\n\nlet GROUP_POW_EQ_ID_DECOMP = `!G (z:A) m n.\n coprime(m,n) /\\\n z IN group_carrier G /\\\n group_pow G z (m * n) = group_id G\n ==> ?x y. x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = z /\\\n group_mul G y x = z /\\\n group_pow G x m = group_id G /\\\n group_pow G y n = group_id G`;;\n\nlet GROUP_ELEMENT_ORDER_PRIMEPOW_DECOMP = `!G (z:A) p.\n prime p /\\\n z IN group_carrier G /\\\n ~(group_element_order G z = 0)\n ==> ?x y. x IN group_carrier G /\\ y IN group_carrier G /\\\n group_mul G x y = z /\\\n group_mul G y x = z /\\\n (?k. group_element_order G x = p EXP k) /\\\n coprime(p,group_element_order G y)`;;\n\nlet SUBGROUP_OF_TORSION_GENERAL = `!P G:A group.\n abelian_group G /\\\n P 1 /\\ (!m n p. p divides lcm(m,n) /\\ P m /\\ P n ==> P p)\n ==> {x | x IN group_carrier G /\\ P(group_element_order G x)}\n subgroup_of G`;;\n\nlet SUBGROUP_OF_TORSION_GEN = `!P G:A group.\n abelian_group G /\\\n P 1 /\\ (!m n p. p divides m * n /\\ P m /\\ P n ==> P p)\n ==> {x | x IN group_carrier G /\\ P(group_element_order G x)}\n subgroup_of G`;;\n\nlet SUBGROUP_OF_TORSION = `!G:A group.\n abelian_group G\n ==> {x | x IN group_carrier G /\\ ~(group_element_order G x = 0)}\n subgroup_of G`;;\n\nlet SUBGROUP_OF_PRIMES_TORSION = `!(G:A group) Q.\n abelian_group G\n ==> {x | x IN group_carrier G /\\\n !p. prime p /\\ p divides group_element_order G x\n ==> Q p}\n subgroup_of G`;;\n\nlet SUBGROUP_OF_PRIME_TORSION = `!(G:A group) p.\n abelian_group G /\\ prime p\n ==> {x | x IN group_carrier G /\\ ?k. group_element_order G x = p EXP k}\n subgroup_of G`;;\n\nlet SUBGROUP_OF_LOWER_ORDER = `!(G:A group) n.\n abelian_group G\n ==> {x | x IN group_carrier G /\\ group_element_order G x divides n}\n subgroup_of G`;;\n\nlet SUBGROUP_OF_LOWER_ORDER_ALT = `!(G:A group) n.\n abelian_group G\n ==> {x | x IN group_carrier G /\\ group_pow G x n = group_id G}\n subgroup_of G`;;\n\nlet SUBGROUP_OF_NONDIVISIBLE_ORDER = `!(G:A group) p.\n abelian_group G /\\ prime p\n ==> {x | x IN group_carrier G /\\\n ~(p divides group_element_order G x)}\n subgroup_of G`;;\n\nlet SUBGROUP_OF_COPRIME_ORDER = `!(G:A group) n.\n abelian_group G\n ==> {x | x IN group_carrier G /\\\n coprime(n,group_element_order G x)}\n subgroup_of G`;;\n\nlet TORSION_FREE_GROUP = `!G:A group.\n (!x. x IN group_carrier G ==> group_element_order G x <= 1) <=>\n (!x. x IN group_carrier G /\\ ~(x = group_id G)\n ==> group_element_order G x = 0)`;;\n\nlet TORSION_FREE_GROUP_ALT = `!G:A group.\n (!x. x IN group_carrier G ==> group_element_order G x <= 1) <=>\n (!x n. x IN group_carrier G /\\ group_pow G x n = group_id G\n ==> x = group_id G \\/ n = 0)`;;\n\nlet QUOTIENT_GROUP_POW_EQ_ID = `!(G:A group) n x k.\n n normal_subgroup_of G /\\ x IN group_carrier G\n ==> (group_pow (quotient_group G n) (right_coset G n x) k =\n group_id (quotient_group G n) <=>\n group_pow G x k IN n)`;;\n\nlet TORSION_FREE_QUOTIENT_GROUP = `!(G:A group) H.\n abelian_group G /\\\n quotient_group\n G {x | x IN group_carrier G /\\ ~(group_element_order G x = 0)} = H\n ==> !x. x IN group_carrier H ==> group_element_order H x <= 1`;;\n\nlet IMAGE_GROUP_CONJUGATION_TORSION_GEN = `!G P a:A.\n a IN group_carrier G\n ==> IMAGE (group_conjugation G a)\n {x | x IN group_carrier G /\\ P(group_element_order G x)} =\n {x | x IN group_carrier G /\\ P(group_element_order G x)}`;;\n\nlet NORMAL_SUBGROUP_OF_TORSION_GEN = `!P G:A group.\n {x | x IN group_carrier G /\\ P(group_element_order G x)}\n normal_subgroup_of G <=>\n {x | x IN group_carrier G /\\ P(group_element_order G x)}\n subgroup_of G`;;\n\nlet NORMAL_SUBGROUP_OF_TORSION = `!G:A group.\n {x | x IN group_carrier G /\\ ~(group_element_order G x = 0)}\n normal_subgroup_of G <=>\n {x | x IN group_carrier G /\\ ~(group_element_order G x = 0)}\n subgroup_of G`;;\n\nlet SUBGROUP_OF_POWERS = `!G (x:A).\n x IN group_carrier G ==> {group_zpow G x n | n IN (:int)} subgroup_of G`;;\n\nlet CARRIER_SUBGROUP_GENERATED_BY_SING = `!G x:A.\n x IN group_carrier G\n ==> group_carrier(subgroup_generated G {x}) =\n {group_zpow G x n | n IN (:int)}`;;\n\nlet cyclic_group = new_definition\n `cyclic_group G <=>\n ?x. x IN group_carrier G /\\ subgroup_generated G {x} = G`;;\n\nlet CYCLIC_GROUP = `!G:A group.\n cyclic_group G <=>\n ?x. x IN group_carrier G /\\\n group_carrier G = {group_zpow G x n | n IN (:int)}`;;\n\nlet CYCLIC_IMP_ABELIAN_GROUP = `!G:A group. cyclic_group G ==> abelian_group G`;;\n\nlet TRIVIAL_IMP_CYCLIC_GROUP = `!G:A group. trivial_group G ==> cyclic_group G`;;\n\nlet CYCLIC_GROUP_ALT = `!G:A group. cyclic_group G <=> ?x. subgroup_generated G {x} = G`;;\n\nlet CYCLIC_GROUP_GENERATED = `!G x:A. cyclic_group(subgroup_generated G {x})`;;\n\nlet CYCLIC_GROUP_EPIMORPHIC_IMAGE = `!G H (f:A->B).\n group_epimorphism(G,H) f /\\ cyclic_group G ==> cyclic_group H`;;\n\nlet ISOMORPHIC_GROUP_CYCLICITY = `!(G:A group) (H:B group).\n G isomorphic_group H ==> (cyclic_group G <=> cyclic_group H)`;;\n\nlet SUBGROUP_OF_CYCLIC_GROUP_EXPLICIT = `!G h x:A.\n x IN group_carrier G /\\ h subgroup_of (subgroup_generated G {x})\n ==> ?k. h = {group_zpow G x (&k * n) | n IN (:int)}`;;\n\nlet SUBGROUP_OF_CYCLIC_GROUP = `!G h:A->bool.\n cyclic_group G /\\ h subgroup_of G\n ==> cyclic_group(subgroup_generated G h)`;;\n\nlet CYCLIC_GROUP_QUOTIENT_GROUP = `!G n:A->bool.\n cyclic_group G /\\ n subgroup_of G ==> cyclic_group(quotient_group G n)`;;\n\nlet NO_PROPER_SUBGROUPS_IMP_CYCLIC = `!G:A group.\n (!h. h subgroup_of G ==> h SUBSET {group_id G} \\/ h = group_carrier G)\n ==> cyclic_group G`;;\n\nlet [FINITE_CYCLIC_SUBGROUP; INFINITE_CYCLIC_SUBGROUP;\n FINITE_CYCLIC_SUBGROUP_ALT; INFINITE_CYCLIC_SUBGROUP_ALT] =\n (CONJUNCTS o prove)\n (`(!G x:A.\n x IN group_carrier G\n ==> (FINITE(group_carrier(subgroup_generated G {x})) <=>\n ?n. ~(n = 0) /\\ group_pow G x n = group_id G)) /\\\n (!G x:A.\n x IN group_carrier G\n ==> (INFINITE(group_carrier(subgroup_generated G {x})) <=>\n !m n. group_pow G x m = group_pow G x n ==> m = n)) /\\\n (!G x:A.\n x IN group_carrier G\n ==> (FINITE(group_carrier(subgroup_generated G {x})) <=>\n ?n. ~(n = &0) /\\ group_zpow G x n = group_id G)) /\\\n (!G x:A.\n x IN group_carrier G\n ==> (INFINITE(group_carrier(subgroup_generated G {x})) <=>\n !m n. group_zpow G x m = group_zpow G x n ==> m = n))`,\n REWRITE_TAC[INFINITE; AND_FORALL_THM] THEN REPEAT GEN_TAC THEN\n ASM_CASES_TAC `(x:A) IN group_carrier G` THEN ASM_REWRITE_TAC[] THEN\n MATCH_MP_TAC(TAUT\n `(r ==> ~p) /\\ (r' ==> r) /\\ (~r' ==> q) /\\ (q ==> q') /\\ (q' ==> p)\n ==> (p <=> q) /\\ (~p <=> r) /\\ (p <=> q') /\\ (~p <=> r')`) THEN\n REPEAT CONJ_TAC THENL\n [DISCH_THEN(MP_TAC o SPEC `(:num)` o MATCH_MP INFINITE_IMAGE_INJ) THEN\n ASM_SIMP_TAC[num_INFINITE; CARRIER_SUBGROUP_GENERATED_BY_SING] THEN\n REWRITE_TAC[INFINITE; CONTRAPOS_THM] THEN\n MATCH_MP_TAC(REWRITE_RULE[IMP_CONJ_ALT] FINITE_SUBSET) THEN\n REWRITE_TAC[GSYM GROUP_NPOW] THEN SET_TAC[];\n REWRITE_TAC[GSYM GROUP_NPOW; GSYM INT_OF_NUM_EQ] THEN SET_TAC[];\n REWRITE_TAC[NOT_FORALL_THM; LEFT_IMP_EXISTS_THM; NOT_IMP] THEN\n MATCH_MP_TAC INT_WLOG_LT THEN REWRITE_TAC[] THEN\n CONJ_TAC THENL [MESON_TAC[]; ALL_TAC] THEN\n MAP_EVERY X_GEN_TAC [`m:int`; `n:int`] THEN REPEAT STRIP_TAC THEN\n EXISTS_TAC `num_of_int(n - m)` THEN\n ASM_SIMP_TAC[GSYM GROUP_NPOW; INT_OF_NUM_OF_INT; INT_LT_IMP_LE;\n INT_SUB_LT; GSYM INT_OF_NUM_EQ; INT_SUB_0; GROUP_ZPOW_SUB;\n GROUP_DIV_REFL; GROUP_ZPOW];\n REWRITE_TAC[GSYM INT_OF_NUM_EQ; GSYM GROUP_NPOW] THEN MESON_TAC[];\n DISCH_TAC THEN\n SUBGOAL_THEN `?n. ~(n = 0) /\\ group_pow G (x:A) n = group_id G`\n STRIP_ASSUME_TAC THENL\n [FIRST_X_ASSUM(X_CHOOSE_THEN `n:int` STRIP_ASSUME_TAC) THEN\n EXISTS_TAC `num_of_int(abs n)` THEN\n REWRITE_TAC[GSYM GROUP_NPOW; GSYM INT_OF_NUM_EQ] THEN\n SIMP_TAC[INT_OF_NUM_OF_INT; INT_ABS_POS; INT_ABS_ZERO] THEN\n ASM_REWRITE_TAC[INT_ABS] THEN COND_CASES_TAC THEN\n ASM_SIMP_TAC[GROUP_ZPOW_NEG; GROUP_INV_ID];\n MATCH_MP_TAC FINITE_SUBSET THEN\n EXISTS_TAC `IMAGE (group_pow G (x:A)) (0..n)` THEN\n ASM_SIMP_TAC[FINITE_IMAGE; FINITE_NUMSEG] THEN\n ASM_SIMP_TAC[CARRIER_SUBGROUP_GENERATED_BY_SING; SUBSET] THEN\n REWRITE_TAC[FORALL_IN_GSPEC; IN_UNIV; IN_IMAGE; IN_NUMSEG; LE_0] THEN\n X_GEN_TAC `a:int` THEN\n MP_TAC(ISPECL [`a:int`; `&n:int`] INT_DIVISION) THEN\n ASM_REWRITE_TAC[INT_OF_NUM_EQ] THEN\n DISCH_THEN(CONJUNCTS_THEN2 SUBST1_TAC MP_TAC) THEN\n SPEC_TAC(`a rem &n`,`b:int`) THEN ONCE_REWRITE_TAC[INT_MUL_SYM] THEN\n REWRITE_TAC[IMP_CONJ; GSYM INT_FORALL_POS; INT_ABS_NUM;\n INT_OF_NUM_LT] THEN\n X_GEN_TAC `m:num` THEN DISCH_TAC THEN EXISTS_TAC `m:num` THEN\n ASM_SIMP_TAC[LT_IMP_LE; GROUP_ZPOW_ADD; GROUP_ZPOW_MUL] THEN\n ASM_REWRITE_TAC[GROUP_NPOW; GROUP_ZPOW_ID] THEN\n ASM_SIMP_TAC[GROUP_MUL_LID; GROUP_POW]]]);;\n\nlet FINITE_CYCLIC_SUBGROUP_ORDER = `!G x:A.\n x IN group_carrier G\n ==> (FINITE(group_carrier(subgroup_generated G {x})) <=>\n ~(group_element_order G x = 0))`;;\n\nlet INFINITE_CYCLIC_SUBGROUP_ORDER = `!G x:A.\n x IN group_carrier G\n ==> (INFINITE (group_carrier(subgroup_generated G {x})) <=>\n group_element_order G x = 0)`;;\n\nlet FINITE_CYCLIC_SUBGROUP_EXPLICIT = `!G x:A.\n FINITE(group_carrier(subgroup_generated G {x})) /\\ x IN group_carrier G\n ==> group_carrier(subgroup_generated G {x}) =\n {group_pow G x n |n| n < group_element_order G x}`;;\n\nlet FINITE_SUBGROUPS_EQ = `!G:A group. FINITE {h | h subgroup_of G} <=> FINITE(group_carrier G)`;;\n\nlet CARD_CYCLIC_SUBGROUP_ORDER = `!G x:A.\n FINITE(group_carrier(subgroup_generated G {x})) /\\ x IN group_carrier G\n ==> CARD(group_carrier(subgroup_generated G {x})) =\n group_element_order G x`;;\n\nlet PRIME_ORDER_IMP_NO_PROPER_SUBGROUPS = `!(G:A group) p.\n (group_carrier G) HAS_SIZE p /\\ (p = 1 \\/ prime p)\n ==> !h. h subgroup_of G\n ==> h = {group_id G} \\/ h = group_carrier G`;;\n\nlet PRIME_ORDER_EQ_NO_PROPER_SUBGROUPS,\n NO_PROPER_SUBGROUPS_EQ_CYCLIC_PRIME_ORDER = (CONJ_PAIR o prove)\n (`(!(G:A group).\n FINITE(group_carrier G) /\\\n (CARD(group_carrier G) = 1 \\/ prime(CARD(group_carrier G))) <=>\n !h. h subgroup_of G ==> h = {group_id G} \\/ h = group_carrier G) /\\\n (!(G:A group).\n (!h. h subgroup_of G ==> h = {group_id G} \\/ h = group_carrier G) <=>\n cyclic_group G /\\\n FINITE(group_carrier G) /\\\n (CARD(group_carrier G) = 1 \\/ prime(CARD(group_carrier G))))`,\n REWRITE_TAC[AND_FORALL_THM] THEN GEN_TAC THEN MATCH_MP_TAC(TAUT\n `(p ==> n) /\\ (n ==> c) /\\ (c /\\ n ==> p)\n ==> (p <=> n) /\\ (n <=> c /\\ p)`) THEN\n REPEAT CONJ_TAC THENL\n [DISCH_TAC THEN\n MATCH_MP_TAC PRIME_ORDER_IMP_NO_PROPER_SUBGROUPS THEN\n REWRITE_TAC[HAS_SIZE] THEN ASM_MESON_TAC[];\n DISCH_TAC THEN MATCH_MP_TAC NO_PROPER_SUBGROUPS_IMP_CYCLIC THEN\n ASM SET_TAC[];\n STRIP_TAC THEN REWRITE_TAC[ONE_OR_PRIME]] THEN\n FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [cyclic_group]) THEN\n DISCH_THEN(X_CHOOSE_THEN `x:A` STRIP_ASSUME_TAC) THEN\n MP_TAC(ISPECL [`G:A group`; `x:A`] INFINITE_CYCLIC_SUBGROUP_ALT) THEN\n ASM_REWRITE_TAC[INFINITE] THEN\n DISCH_THEN(MP_TAC o MATCH_MP (TAUT `(~p <=> q) ==> ~q ==> p`)) THEN\n ANTS_TAC THENL\n [FIRST_X_ASSUM(MP_TAC o SPEC\n `{group_zpow G (group_zpow G (x:A) (&2)) n | n IN (:int)}`) THEN\n ASM_SIMP_TAC[SUBGROUP_OF_POWERS; GROUP_ZPOW; GSYM GROUP_ZPOW_MUL] THEN\n DISCH_THEN(DISJ_CASES_THEN MP_TAC) THENL\n [DISCH_THEN(MP_TAC o MATCH_MP (SET_RULE\n `{f n | n IN (:int)} = {a} ==> f(&1) = a`)) THEN\n DISCH_TAC THEN\n DISCH_THEN(MP_TAC o SPECL [`&2 * &1:int`; `&0:int`]) THEN\n ASM_REWRITE_TAC[GROUP_ZPOW_0] THEN CONV_TAC INT_ARITH;\n REWRITE_TAC[EXTENSION] THEN DISCH_THEN(MP_TAC o SPEC `x:A`) THEN\n ASM_REWRITE_TAC[IN_ELIM_THM; IN_UNIV] THEN\n DISCH_THEN(X_CHOOSE_THEN `n:int` (STRIP_ASSUME_TAC o GSYM)) THEN\n DISCH_THEN(MP_TAC o SPECL [`&2 * n:int`; `&1:int`]) THEN\n ASM_SIMP_TAC[GROUP_ZPOW_1] THEN MATCH_MP_TAC(INT_ARITH\n `n:int <= &0 \\/ &1 <= n ==> ~(&2 * n = &1)`) THEN\n INT_ARITH_TAC];\n DISCH_TAC THEN ASM_REWRITE_TAC[]] THEN\n X_GEN_TAC `n:num` THEN\n ASM_CASES_TAC `n = 0` THEN\n ASM_SIMP_TAC[CARD_EQ_0;GROUP_CARRIER_NONEMPTY; NUMBER_RULE\n `0 divides n <=> n = 0`] THEN\n DISCH_TAC THEN\n ABBREV_TAC `m = CARD(group_carrier(G:A group)) DIV n` THEN\n SUBGOAL_THEN `~(m = 0)` ASSUME_TAC THENL\n [EXPAND_TAC \"m\" THEN ASM_SIMP_TAC[DIV_EQ_0] THEN\n FIRST_ASSUM(MP_TAC o MATCH_MP DIVIDES_LE) THEN\n ASM_SIMP_TAC[CARD_EQ_0; GROUP_CARRIER_NONEMPTY; NOT_LT];\n ALL_TAC] THEN\n FIRST_ASSUM(MP_TAC o SPEC\n `group_carrier(subgroup_generated G {group_pow G x m:A})`) THEN\n SUBGOAL_THEN `group_element_order G (group_pow G (x:A) m) = n`\n ASSUME_TAC THENL\n [W(MP_TAC o PART_MATCH (lhand o rand)\n GROUP_ELEMENT_ORDER_POW o lhand o snd) THEN\n ASM_REWRITE_TAC[] THEN\n UNDISCH_TAC `CARD(group_carrier G:A->bool) DIV n = m` THEN\n FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [divides]) THEN\n ASM_SIMP_TAC[GSYM CARD_CYCLIC_SUBGROUP_ORDER] THEN\n DISCH_THEN(X_CHOOSE_THEN `r:num` SUBST1_TAC) THEN\n ASM_SIMP_TAC[DIV_MULT] THEN ONCE_REWRITE_TAC[MULT_SYM] THEN\n ASM_SIMP_TAC[DIV_MULT] THEN DISCH_TAC THEN\n DISCH_THEN MATCH_MP_TAC THEN CONV_TAC NUMBER_RULE;\n ALL_TAC] THEN\n SUBGOAL_THEN\n `FINITE(group_carrier (subgroup_generated G {group_pow G x m:A}))`\n ASSUME_TAC THENL\n [ASM_SIMP_TAC[FINITE_CYCLIC_SUBGROUP_ORDER; GROUP_POW] THEN\n ASM_SIMP_TAC[GROUP_ELEMENT_ORDER_POW];\n ALL_TAC] THEN\n REWRITE_TAC[SUBGROUP_SUBGROUP_GENERATED] THEN\n MATCH_MP_TAC MONO_OR THEN CONJ_TAC THEN\n DISCH_THEN(MP_TAC o AP_TERM `CARD:(A->bool)->num`) THEN\n ASM_SIMP_TAC[CARD_CYCLIC_SUBGROUP_ORDER; GROUP_POW; CARD_SING]);;\n\nlet ABELIAN_SIMPLE_GROUP = `!G:A group.\n abelian_group G\n ==> ((!h. h normal_subgroup_of G\n ==> h = {group_id G} \\/ h = group_carrier G) <=>\n FINITE(group_carrier G) /\\\n (CARD (group_carrier G) = 1 \\/ prime(CARD(group_carrier G))))`;;\n\nlet PRIME_ORDER_IMP_CYCLIC_GROUP = `!G:A group.\n FINITE(group_carrier G) /\\\n (CARD(group_carrier G) = 1 \\/ prime(CARD(group_carrier G)))\n ==> cyclic_group G`;;\n\nlet GROUP_ELEMENT_ORDER_DIVIDES_GROUP_ORDER = `!G x:A.\n x IN group_carrier G /\\ FINITE(group_carrier G)\n ==> (group_element_order G x) divides CARD(group_carrier G)`;;\n\nlet GROUP_POW_GROUP_ORDER = `!G x:A.\n x IN group_carrier G /\\ FINITE(group_carrier G)\n ==> group_pow G x (CARD(group_carrier G)) = group_id G`;;\n\nlet GROUP_ZPOW_REM_ORDER = `!G (x:A) n.\n FINITE(group_carrier G) /\\ x IN group_carrier G\n ==> group_zpow G x (n rem &(CARD(group_carrier G))) =\n group_zpow G x n`;;\n\nlet GROUP_POW_MOD_ORDER = `!G (x:A) n. FINITE(group_carrier G) /\\ x IN group_carrier G\n ==> group_pow G x (n MOD CARD(group_carrier G)) =\n group_pow G x n`;;\n\nlet SUBGROUP_OF_FINITE_CYCLIC_GROUP = `!G h a:A.\n FINITE(group_carrier G) /\\\n a IN group_carrier G /\\\n subgroup_generated G {a} = G\n ==> (h subgroup_of G <=>\n ?d. d divides CARD(group_carrier G) /\\\n h = group_carrier(subgroup_generated G {group_pow G a d}))`;;\n\nlet COUNT_FINITE_CYCLIC_GROUP_SUBGROUPS = `!(G:A group) d.\n FINITE(group_carrier G) /\\ cyclic_group G\n ==> (CARD {h | h subgroup_of G /\\ CARD h = d} =\n if d divides CARD(group_carrier G) then 1 else 0)`;;\n\nlet COUNT_FINITE_CYCLIC_GROUP_SUBGROUPS_ALL = `!G:A group.\n FINITE(group_carrier G) /\\ cyclic_group G\n ==> CARD {h | h subgroup_of G} =\n CARD {d | d divides CARD(group_carrier G)}`;;\n\nlet MAXIMAL_SUBGROUP_PRIME_INDEX = `!G n:A->bool.\n n normal_subgroup_of G\n ==> ((!h. h subgroup_of G /\\ n PSUBSET h ==> h = group_carrier G) <=>\n FINITE {right_coset G n x | x | x IN group_carrier G} /\\\n (CARD {right_coset G n x | x | x IN group_carrier G} = 1 \\/\n prime(CARD {right_coset G n x | x | x IN group_carrier G})))`;;\n\nlet PRIME_INDEX_MAXIMAL_PROPER_SUBGROUP = `!G n:A->bool.\n n normal_subgroup_of G\n ==> (FINITE {right_coset G n x | x | x IN group_carrier G} /\\\n prime(CARD {right_coset G n x | x | x IN group_carrier G}) <=>\n ~(n = group_carrier G) /\\\n !h. h subgroup_of G /\\ n PSUBSET h ==> h = group_carrier G)`;;\n\nlet MAXIMAL_PROPER_SUBGROUP_PRIME_INDEX = `!G n:A->bool.\n n normal_subgroup_of G /\\ ~(n = group_carrier G)\n ==> ((!h. h subgroup_of G /\\ n PSUBSET h ==> h = group_carrier G) <=>\n FINITE {right_coset G n x | x | x IN group_carrier G} /\\\n prime(CARD {right_coset G n x | x | x IN group_carrier G}))`;;\n\nlet GROUP_ZPOW_CANCEL = `!G n x y:A.\n FINITE(group_carrier G) /\\ coprime(n,&(CARD(group_carrier G))) /\\\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_zpow G x n = group_zpow G y n\n ==> x = y`;;\n\nlet GROUP_POW_CANCEL = `!G n x y:A.\n FINITE(group_carrier G) /\\ coprime(n,CARD(group_carrier G)) /\\\n x IN group_carrier G /\\ y IN group_carrier G /\\\n group_pow G x n = group_pow G y n\n ==> x = y`;;\n\nlet finitely_generated_group = new_definition\n `finitely_generated_group (G:A group) <=>\n ?s. FINITE s /\\ subgroup_generated G s = G`;;\n\nlet FINITELY_GENERATED_GROUP = `!G:A group.\n finitely_generated_group G <=>\n ?s. FINITE s /\\\n s SUBSET group_carrier G /\\\n subgroup_generated G s = G`;;\n\nlet CYCLIC_IMP_FINITELY_GENERATED_GROUP = `!G:A group. cyclic_group G ==> finitely_generated_group G`;;\n\nlet FINITE_IMP_FINITELY_GENERATED_GROUP = `!G:A group. FINITE(group_carrier G) ==> finitely_generated_group G`;;\n\nlet TRIVIAL_IMP_FINITELY_GENERATED_GROUP = `!G:A group. trivial_group G ==> finitely_generated_group G`;;\n\nlet FINITELY_GENERATED_GROUP_EPIMORPHIC_IMAGE = `!G H (f:A->B).\n group_epimorphism(G,H) f /\\ finitely_generated_group G\n ==> finitely_generated_group H`;;\n\nlet ISOMORPHIC_GROUP_FINITE_GENERATION = `!(G:A group) (H:B group).\n G isomorphic_group H\n ==> (finitely_generated_group G <=> finitely_generated_group H)`;;\n\nlet FINITELY_GENERATED_GROUP_QUOTIENT_GROUP = `!G n:A->bool.\n finitely_generated_group G /\\ n normal_subgroup_of G\n ==> finitely_generated_group(quotient_group G n)`;;\n\nlet FINITELY_GENERATED_IMP_COUNTABLE_GROUP = `!G:A group. finitely_generated_group G ==> COUNTABLE(group_carrier G)`;;\n\nlet FINITELY_GENERATED_PROD_GROUP = `!(G:A group) (H:B group).\n finitely_generated_group(prod_group G H) <=>\n finitely_generated_group G /\\ finitely_generated_group H`;;\n\nlet FINITELY_GENERATED_PRODUCT_GROUP = `!k (G:K->A group).\n finitely_generated_group(product_group k G) <=>\n FINITE {i | i IN k /\\ ~trivial_group(G i)} /\\\n !i. i IN k ==> finitely_generated_group(G i)`;;\n\nlet FINITELY_GENERATED_SUM_GROUP = `!k (G:K->A group).\n finitely_generated_group(sum_group k G) <=>\n FINITE {i | i IN k /\\ ~trivial_group(G i)} /\\\n !i. i IN k ==> finitely_generated_group(G i)`;;\n\nlet FINITE_GROUP_ACTIONS = `!G s (f:(A->X->X)->B).\n finitely_generated_group G /\\ FINITE s /\\\n (!a a'. (!g x. g IN group_carrier G /\\ x IN s ==> a g x = a' g x)\n ==> f a = f a')\n ==> FINITE {f a | group_action G s a}`;;\n\nlet FINITELY_GENERATED_FIXED_INDEX_SUBGROUPS = `!(G:A group) n.\n finitely_generated_group G\n ==> FINITE {h | h subgroup_of G /\\\n {right_coset G h x |x| x IN group_carrier G} HAS_SIZE n}`;;\n\nlet FINITELY_GENERATED_FINITE_INDEX_SUBGROUP = `!G h:A->bool.\n finitely_generated_group G /\\\n h subgroup_of G /\\\n FINITE {right_coset G h x | x | x IN group_carrier G}\n ==> finitely_generated_group(subgroup_generated G h)`;;\n\nlet FINITELY_GENERATED_ABELIAN_SUBGROUP_EXPLICIT = `!G s h:A->bool.\n FINITE s /\\ s SUBSET group_carrier G /\\\n abelian_group G /\\ h subgroup_of subgroup_generated G s\n ==> ?t. FINITE t /\\ t SUBSET group_carrier G /\\\n CARD t <= CARD s /\\\n subgroup_generated G t = subgroup_generated G h`;;\n\nlet FINITELY_GENERATED_ABELIAN_SUBGROUP = `!G h:A->bool.\n finitely_generated_group G /\\ abelian_group G /\\ h subgroup_of G\n ==> finitely_generated_group(subgroup_generated G h)`;;\n\nlet MAXIMAL_SUBGROUP_EXISTS = `!G:A group.\n finitely_generated_group G /\\ ~trivial_group G\n ==> ?h. h subgroup_of G /\\ ~(h = group_carrier G) /\\\n !h'. h' subgroup_of G /\\ h PSUBSET h'\n ==> h' = group_carrier G`;;\n\nlet MAXIMAL_NORMAL_SUBGROUP_EXISTS = `!G:A group.\n finitely_generated_group G /\\ ~trivial_group G\n ==> ?h. h normal_subgroup_of G /\\ ~(h = group_carrier G) /\\\n !h'. h' normal_subgroup_of G /\\ h PSUBSET h'\n ==> h' = group_carrier G`;;\n\nlet integer_group = new_definition\n `integer_group = group((:int),&0,(--),(+))`;;\n\nlet INTEGER_GROUP = `group_carrier integer_group = (:int) /\\\n group_id integer_group = &0 /\\\n group_inv integer_group = (--) /\\\n group_mul integer_group = (+)`;;\n\nlet ABELIAN_INTEGER_GROUP = `abelian_group integer_group`;;\n\nlet INFINITE_INTEGER_GROUP = `INFINITE(group_carrier integer_group)`;;\n\nlet GROUP_POW_INTEGER_GROUP = `!x n. group_pow integer_group x n = &n * x`;;\n\nlet GROUP_ZPOW_INTEGER_GROUP = `!x n. group_zpow integer_group x n = n * x`;;\n\nlet GROUP_ELEMENT_ORDER_INTEGER_GROUP = `!n. group_element_order integer_group n = if n = &0 then 1 else 0`;;\n\nlet GROUP_ENDOMORPHISM_INTEGER_GROUP_MUL = `!c. group_endomorphism integer_group (\\x. c * x)`;;\n\nlet GROUP_ENDOMORPHISM_INTEGER_GROUP_EXPLICIT = `!f. group_endomorphism integer_group f ==> f = \\x. f(&1) * x`;;\n\nlet GROUP_ENDOMORPHISM_INTEGER_GROUP_EQ,\n GROUP_ENDOMORPHISM_INTEGER_GROUP_EQ_ALT =\n (CONJ_PAIR o prove)\n (`(!f. group_endomorphism integer_group f <=> ?c. f = \\x. c * x) /\\\n (!f. group_endomorphism integer_group f <=> ?!c. f = \\x. c * x)`,\n REWRITE_TAC[AND_FORALL_THM] THEN GEN_TAC THEN MATCH_MP_TAC(MESON[]\n `(!c. P(m c)) /\\ (!f. P f ==> ?c. f = m c) /\\\n (!c d. m c = m d ==> c = d)\n ==> (P f <=> ?c. f = m c) /\\ (P f <=> ?!c. f = m c)`) THEN\n REWRITE_TAC[GROUP_ENDOMORPHISM_INTEGER_GROUP_MUL] THEN CONJ_TAC THENL\n [X_GEN_TAC `f:int->int` THEN DISCH_TAC THEN\n EXISTS_TAC `(f:int->int) (&1)` THEN\n MATCH_MP_TAC GROUP_ENDOMORPHISM_INTEGER_GROUP_EXPLICIT THEN\n ASM_REWRITE_TAC[];\n REWRITE_TAC[FUN_EQ_THM] THEN MESON_TAC[INT_MUL_RID]]);;\n\nlet GROUP_HOMOMORPHISM_GROUP_ZPOW = `!G x:A. x IN group_carrier G\n ==> group_homomorphism(integer_group,G) (group_zpow G x)`;;\n\nlet GROUP_EPIMORPHISM_GROUP_ZPOW = `!G x:A. x IN group_carrier G\n ==> group_epimorphism (integer_group,subgroup_generated G {x})\n (group_zpow G x)`;;\n\nlet GROUP_ISOMORPHISM_GROUP_ZPOW = `!G x:A. INFINITE(group_carrier(subgroup_generated G {x})) /\\\n x IN group_carrier G\n ==> group_isomorphism (integer_group,subgroup_generated G {x})\n (group_zpow G x)`;;\n\nlet ISOMORPHIC_GROUP_INFINITE_CYCLIC_INTEGER = `!G:A group.\n cyclic_group G /\\ INFINITE(group_carrier G)\n ==> G isomorphic_group integer_group`;;\n\nlet ISOMORPHIC_INFINITE_CYCLIC_GROUPS = `!(G:A group) (H:B group).\n cyclic_group G /\\ INFINITE(group_carrier G) /\\\n cyclic_group H /\\ INFINITE(group_carrier H)\n ==> G isomorphic_group H`;;\n\nlet integer_mod_group = new_definition\n `integer_mod_group n =\n if n = 0 then integer_group else\n group({m | &0 <= m /\\ m < &n},\n &0,\n (\\a. --a rem &n),\n (\\a b. (a + b) rem &n))`;;\n\nlet INTEGER_MOD_GROUP = `(group_carrier(integer_mod_group 0) = (:int)) /\\\n (!n. 0 < n\n ==> group_carrier(integer_mod_group n) = {m | &0 <= m /\\ m < &n}) /\\\n (!n. group_id(integer_mod_group n) = &0) /\\\n (!n. group_inv(integer_mod_group n) = \\a. --a rem &n) /\\\n (!n. group_mul(integer_mod_group n) = \\a b. (a + b) rem &n)`;;\n\nlet INTEGER_MOD_GROUP_TRIVIAL = `integer_mod_group 0 = integer_group`;;\n\nlet GROUP_CARRIER_INTEGER_MOD_GROUP = `!n. group_carrier (integer_mod_group n) = IMAGE (\\x. x rem &n) (:int)`;;\n\nlet GROUP_POW_INTEGER_MOD_GROUP = `!n x m. group_pow (integer_mod_group n) x m = (&m * x) rem &n`;;\n\nlet GROUP_ZPOW_INTEGER_MOD_GROUP = `!n x m. group_zpow (integer_mod_group n) x m = (m * x) rem &n`;;\n\nlet ABELIAN_INTEGER_MOD_GROUP = `!n. abelian_group(integer_mod_group n)`;;\n\nlet INTEGER_MOD_GROUP_0 = `!n. &0 IN group_carrier(integer_mod_group n)`;;\n\nlet INTEGER_MOD_GROUP_1R = `!n x. (x rem &n) IN group_carrier(integer_mod_group n)`;;\n\nlet INTEGER_MOD_GROUP_1 = `!n. &1 IN group_carrier(integer_mod_group n) <=> ~(n = 1)`;;\n\nlet GROUP_HOMOMORPHISM_PROD_INTEGER_MOD_GROUP = `!m n.\n group_homomorphism\n (integer_mod_group (m * n),\n prod_group (integer_mod_group m) (integer_mod_group n))\n (\\a. (a rem &m),(a rem &n))`;;\n\nlet TRIVIAL_INTEGER_MOD_GROUP = `!n. trivial_group(integer_mod_group n) <=> n = 1`;;\n\nlet NON_TRIVIAL_INTEGER_GROUP = `~(trivial_group integer_group)`;;\n\nlet GROUP_ELEMENT_ORDER_INTEGER_MOD_GROUP_1 = `!n. group_element_order (integer_mod_group n) (&1) = n`;;\n\nlet GROUP_ELEMENT_ORDER_INTEGER_MOD_GROUP_1R = `!n. group_element_order (integer_mod_group n) (&1 rem &n) = n`;;\n\nlet GROUP_ELEMENT_ORDER_INTEGER_MOD_GROUP = `!n m. group_element_order (integer_mod_group n) (&m) =\n if m = 0 /\\ n = 0 then 1 else n DIV gcd(n,m)`;;\n\nlet INTEGER_MOD_SUBGROUP_GENERATED_BY_1R = `!n. subgroup_generated (integer_mod_group n) {&1 rem &n} =\n integer_mod_group n`;;\n\nlet INTEGER_MOD_SUBGROUP_GENERATED_BY_1 = `!n. subgroup_generated (integer_mod_group n) {&1} =\n integer_mod_group n`;;\n\nlet CYCLIC_GROUP_INTEGER_MOD_GROUP = `!n. cyclic_group(integer_mod_group n)`;;\n\nlet CYCLIC_INTEGER_GROUP = `cyclic_group integer_group`;;\n\nlet FINITE_INTEGER_MOD_GROUP = `!n. FINITE(group_carrier(integer_mod_group n)) <=> ~(n = 0)`;;\n\nlet GROUP_EPIMORPHISM_INTEGER_MOD_GROUP_ZPOW = `!n. ~(n = 1)\n ==> group_epimorphism (integer_group,integer_mod_group n)\n (group_zpow (integer_mod_group n) (&1))`;;\n\nlet GROUP_ISOMORPHISM_GROUP_ZPOW_GEN = `!G x:A.\n x IN group_carrier G\n ==> group_isomorphism (integer_mod_group (group_element_order G x),\n subgroup_generated G {x})\n (group_zpow G x)`;;\n\nlet ISOMORPHIC_GROUP_CYCLIC_INTEGER = `!G:A group. cyclic_group G <=> ?n. G isomorphic_group integer_mod_group n`;;\n\nlet ORDER_INTEGER_MOD_GROUP = `!n. ~(n = 0) ==> CARD(group_carrier(integer_mod_group n)) = n`;;\n\nlet ISOMORPHIC_FINITE_CYCLIC_INTEGER_MOD_GROUP = `!G:A group.\n cyclic_group G /\\ FINITE(group_carrier G)\n ==> G isomorphic_group integer_mod_group (CARD(group_carrier G))`;;\n\nlet ISOMORPHIC_GROUP_INTEGER_MOD_GROUP = `(!(G:A group) n.\n G isomorphic_group integer_mod_group n <=>\n cyclic_group G /\\\n (n = 0 /\\ INFINITE(group_carrier G) \\/\n ~(n = 0) /\\ (group_carrier G) HAS_SIZE n)) /\\\n (!(G:A group) n.\n integer_mod_group n isomorphic_group G <=>\n cyclic_group G /\\\n (n = 0 /\\ INFINITE(group_carrier G) \\/\n ~(n = 0) /\\ (group_carrier G) HAS_SIZE n))`;;\n\nlet ISOMORPHIC_INTEGER_MOD_GROUPS = `!m n. integer_mod_group m isomorphic_group integer_mod_group n <=>\n m = n`;;\n\nlet ISOMORPHIC_FINITE_CYCLIC_GROUPS = `!(G:A group) (H:B group).\n cyclic_group G /\\ cyclic_group H /\\\n FINITE(group_carrier G) /\\ FINITE(group_carrier H) /\\\n CARD(group_carrier G) = CARD(group_carrier H)\n ==> G isomorphic_group H`;;\n\nlet CYCLIC_IMP_COUNTABLE_GROUP = `!G:A group. cyclic_group G ==> COUNTABLE(group_carrier G)`;;\n\nlet SUBGROUP_GENERATED_ELEMENT_ORDER = `!G a:A.\n FINITE(group_carrier G) /\\ a IN group_carrier G\n ==> (subgroup_generated G {a} = G <=>\n group_element_order G a = CARD(group_carrier G))`;;\n\nlet CYCLIC_GROUP_ELEMENT_ORDER = `!G:A group.\n FINITE(group_carrier G)\n ==> (cyclic_group G <=>\n ?a. a IN group_carrier G /\\\n group_element_order G a = CARD(group_carrier G))`;;\n\nlet [CYCLIC_PROD_INTEGER_MOD_GROUP;\n ISOMORPHIC_PROD_INTEGER_MOD_GROUP;\n GROUP_ISOMORPHISM_PROD_INTEGER_MOD_GROUP] = (CONJUNCTS o prove)\n (`(!m n. cyclic_group (prod_group (integer_mod_group m) (integer_mod_group n))\n <=> coprime(m,n)) /\\\n (!m n.\n prod_group (integer_mod_group m) (integer_mod_group n) isomorphic_group\n integer_mod_group (m * n) <=>\n coprime(m,n)) /\\\n (!m n.\n group_isomorphism\n (integer_mod_group (m * n),\n prod_group (integer_mod_group m) (integer_mod_group n))\n (\\a. (a rem &m),(a rem &n)) <=>\n coprime(m,n))`,\n REWRITE_TAC[AND_FORALL_THM] THEN REPEAT GEN_TAC THEN\n MATCH_MP_TAC(TAUT\n `(r ==> q) /\\ (q ==> p) /\\ (p ==> c) /\\ (c ==> r)\n ==> (p <=> c) /\\ (q <=> c) /\\ (r <=> c)`) THEN\n REPEAT CONJ_TAC THENL\n [ONCE_REWRITE_TAC[ISOMORPHIC_GROUP_SYM] THEN\n REWRITE_TAC[GROUP_ISOMORPHISM_IMP_ISOMORPHIC];\n DISCH_THEN(MP_TAC o MATCH_MP ISOMORPHIC_GROUP_CYCLICITY) THEN\n REWRITE_TAC[CYCLIC_GROUP_INTEGER_MOD_GROUP];\n GEN_REWRITE_TAC I [GSYM CONTRAPOS_THM] THEN\n DISCH_TAC THEN REWRITE_TAC[CYCLIC_GROUP] THEN\n REWRITE_TAC[MESON[] `~(?x. P x /\\ Q x) <=> !x. P x ==> ~Q x`] THEN\n SIMP_TAC[FORALL_PAIR_THM; PROD_GROUP; IN_CROSS;\n GROUP_ZPOW_INTEGER_MOD_GROUP; GROUP_ZPOW_PROD_GROUP] THEN\n REWRITE_TAC[GROUP_CARRIER_INTEGER_MOD_GROUP] THEN\n REWRITE_TAC[IMP_CONJ; RIGHT_FORALL_IMP_THM; FORALL_IN_IMAGE; IN_UNIV] THEN\n MAP_EVERY X_GEN_TAC [`a:int`; `b:int`] THEN\n MATCH_MP_TAC(SET_RULE `!z. z IN s /\\ ~(z IN t) ==> ~(s = t)`) THEN\n REWRITE_TAC[EXISTS_PAIR_THM; EXISTS_IN_IMAGE; RIGHT_EXISTS_AND_THM;\n IN_CROSS; GSYM CONJ_ASSOC; IN_UNIV; IN_ELIM_THM] THEN\n CONV_TAC INT_REM_DOWN_CONV THEN\n ONCE_REWRITE_TAC[EQ_SYM_EQ] THEN REWRITE_TAC[PAIR_EQ; INT_REM_EQ] THEN\n POP_ASSUM MP_TAC THEN GEN_REWRITE_TAC I [GSYM CONTRAPOS_THM] THEN\n REWRITE_TAC[num_coprime; NOT_EXISTS_THM] THEN MESON_TAC[INTEGER_RULE\n `(x * a == &1) (mod m) /\\ (x * b == &1) (mod n) /\\\n (y * a == &0) (mod m) /\\ (y * b == &1) (mod n)\n ==> coprime(m,n)`];\n REWRITE_TAC[GROUP_ISOMORPHISM_SUBSET] THEN\n REWRITE_TAC[GROUP_HOMOMORPHISM_PROD_INTEGER_MOD_GROUP] THEN\n REWRITE_TAC[PROD_GROUP; FORALL_PAIR_THM; IN_CROSS; PAIR_EQ] THEN\n ASM_CASES_TAC `m = 0` THENL\n [ASM_SIMP_TAC[INT_REM_0; MULT_CLAUSES; INT_REM_1;\n NUMBER_RULE `coprime(0,n) <=> n = 1`] THEN\n SIMP_TAC[INTEGER_MOD_GROUP; ARITH; IN_UNIV; IN_ELIM_THM] THEN\n REWRITE_TAC[UNWIND_THM2] THEN INT_ARITH_TAC;\n ALL_TAC] THEN\n ASM_CASES_TAC `n = 0` THENL\n [ASM_SIMP_TAC[INT_REM_0; MULT_CLAUSES; INT_REM_1;\n NUMBER_RULE `coprime(n,0) <=> n = 1`] THEN\n SIMP_TAC[INTEGER_MOD_GROUP; ARITH; IN_UNIV; IN_ELIM_THM] THEN\n ONCE_REWRITE_TAC[CONJ_SYM] THEN REWRITE_TAC[UNWIND_THM2] THEN\n INT_ARITH_TAC;\n ALL_TAC] THEN\n DISCH_TAC THEN ASM_SIMP_TAC[INTEGER_MOD_GROUP; LE_1; MULT_EQ_0] THEN\n REWRITE_TAC[IN_ELIM_THM] THEN\n CONJ_TAC THEN MAP_EVERY X_GEN_TAC [`a:int`; `b:int`] THENL\n [STRIP_TAC THEN\n FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [num_coprime]) THEN\n DISCH_THEN(MP_TAC o SPECL [`a:int`; `b:int`] o MATCH_MP (INTEGER_RULE\n `coprime(m:int,n)\n ==> !a b. ?c. (c == a) (mod m) /\\ (c == b) (mod n)`)) THEN\n ASM_SIMP_TAC[GSYM INT_REM_EQ; INT_REM_LT] THEN\n DISCH_THEN(X_CHOOSE_THEN `c:int` STRIP_ASSUME_TAC) THEN\n EXISTS_TAC `c rem &(m * n)` THEN\n REWRITE_TAC[INT_REM_POS_EQ; INT_LT_REM_EQ] THEN\n ASM_SIMP_TAC[INT_OF_NUM_EQ; INT_OF_NUM_LT; MULT_EQ_0; LE_1] THEN\n ASM_REWRITE_TAC[GSYM INT_OF_NUM_MUL; INT_REM_REM_MUL];\n STRIP_TAC THEN\n FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [num_coprime]) THEN\n DISCH_THEN(MP_TAC o SPECL [`a:int`; `b:int`] o MATCH_MP (INTEGER_RULE\n `coprime(m:int,n)\n ==> !a b. (a == b) (mod m) /\\ (a == b) (mod n)\n ==> (a == b) (mod (m * n))`)) THEN\n ASM_REWRITE_TAC[GSYM INT_REM_EQ] THEN\n MATCH_MP_TAC EQ_IMP THEN BINOP_TAC THEN MATCH_MP_TAC INT_REM_LT THEN\n ASM_REWRITE_TAC[INT_OF_NUM_MUL]]]);;\n\nlet CYCLIC_PROD_GROUP = `!(G:A group) (H:B group).\n cyclic_group (prod_group G H) <=>\n cyclic_group G /\\ cyclic_group H /\\\n (trivial_group G \\/\n trivial_group H \\/\n FINITE(group_carrier G) /\\ FINITE(group_carrier H) /\\\n coprime(CARD(group_carrier G),CARD(group_carrier H)))`;;\n\nlet CYCLIC_PRIME_ORDER_GROUP = `!G (a:A).\n FINITE (group_carrier G) /\\\n (CARD(group_carrier G) = 1 \\/ prime(CARD(group_carrier G))) /\\\n a IN group_carrier G /\\ ~(a = group_id G)\n ==> subgroup_generated G {a} = G`;;\n\nlet GROUP_ELEMENT_ORDER_PRIME = `!G a:A. prime p /\\ (group_carrier G) HAS_SIZE p /\\ a IN group_carrier G\n ==> group_element_order G a =\n if a = group_id G then 1 else CARD(group_carrier G)`;;\n\nlet GENERATOR_INTEGER_MOD_GROUP = `!n a. subgroup_generated (integer_mod_group n) {a} = integer_mod_group n <=>\n (n <= 1 \\/ &0 <= a /\\ a < &n) /\\ coprime(&n,a)`;;\n\nlet CYCLIC_GROUP_PRIME_ORDER_EQ = `!(G:A group).\n (!a. a IN group_carrier G /\\ ~(a = group_id G)\n ==> subgroup_generated G {a} = G) <=>\n FINITE(group_carrier G) /\\\n (CARD (group_carrier G) = 1 \\/ prime (CARD (group_carrier G)))`;;\n\nlet pgroup = new_definition\n `pgroup s (G:A group) <=>\n !p x. prime p /\\\n x IN group_carrier G /\\\n p divides group_element_order G x\n ==> p IN s`;;\n\nlet PGROUP_MONOMORPHIC_PREIMAGE = `!G H (f:A->B) s. group_monomorphism (G,H) f /\\ pgroup s H ==> pgroup s G`;;\n\nlet PGROUP_EPIMORPHIC_IMAGE = `!G H (f:A->B) s. group_epimorphism (G,H) f /\\ pgroup s G ==> pgroup s H`;;\n\nlet PGROUP_QUOTIENT_GROUP = `!(G:A group) n s.\n n normal_subgroup_of G /\\ pgroup s G ==> pgroup s (quotient_group G n)`;;\n\nlet PGROUP_SUBGROUP_GENERATED = `!(G:A group) s h.\n pgroup s G ==> pgroup s (subgroup_generated G h)`;;\n\nlet PGROUP_PROD_GROUP = `!(G:A group) (H:A group) s.\n pgroup s (prod_group G H) <=> pgroup s G /\\ pgroup s H`;;\n\nlet PGROUP_EMPTY = `!G:A group. pgroup {} G <=> trivial_group G`;;\n\nlet PGROUP_MONO = `!(G:A group) s t. pgroup s G /\\ s SUBSET t ==> pgroup t G`;;\n\nlet PGROUP_SUM_GROUP = `!k (G:K->A group) s.\n pgroup s (sum_group k G) <=> !i. i IN k ==> pgroup s (G i)`;;\n\nlet PGROUP_SING = `!(G:A group) p.\n prime p\n ==> (pgroup {p} G <=>\n !x. x IN group_carrier G ==> ?k. group_element_order G x = p EXP k)`;;\n\nlet SYLOW_THEOREM_COUNT_MOD = `!(G:A group) p k.\n FINITE(group_carrier G) /\\\n prime p /\\\n p EXP k divides CARD(group_carrier G)\n ==> (CARD {h | h subgroup_of G /\\ CARD h = p EXP k} == 1) (mod p)`;;\n\nlet SYLOW_THEOREM = `!(G:A group) p k.\n FINITE(group_carrier G) /\\\n prime p /\\\n p EXP k divides CARD(group_carrier G)\n ==> ?h. h subgroup_of G /\\ CARD h = p EXP k`;;\n\nlet CAUCHY_GROUP_THEOREM = `!(G:A group) p.\n FINITE(group_carrier G) /\\ prime p /\\ p divides CARD(group_carrier G)\n ==> ?x. x IN group_carrier G /\\ group_element_order G x = p`;;\n\nlet PRIME_DIVIDES_GROUP_ORDER = `!(G:A group) p.\n FINITE(group_carrier G) /\\ prime p\n ==> ((?x. x IN group_carrier G /\\ p divides (group_element_order G x)) <=>\n p divides CARD(group_carrier G))`;;\n\nlet COPRIME_GROUP_ORDER = `!(G:A group) n.\n FINITE(group_carrier G)\n ==> ((!x. x IN group_carrier G ==> coprime(group_element_order G x,n)) <=>\n coprime(CARD(group_carrier G),n))`;;\n\nlet FINITE_PGROUP = `!s (G:A group).\n FINITE(group_carrier G)\n ==> (pgroup s G <=>\n !p. prime p /\\ p divides CARD(group_carrier G) ==> p IN s)`;;\n\nlet FINITE_PGROUP_SING = `!(G:A group) p.\n FINITE(group_carrier G) /\\ prime p\n ==> (pgroup {p} G <=> ?k. CARD(group_carrier G) = p EXP k)`;;\n\nlet FINITE_AND_PGROUP_SING = `!(G:A group) p.\n prime p\n ==> (FINITE(group_carrier G) /\\ pgroup {p} G <=>\n ?k. (group_carrier G) HAS_SIZE (p EXP k))`;;\n\nlet FINITE_GROUP_POW_INJECTIVE_EQ = `!(G:A group) n.\n FINITE(group_carrier G)\n ==> ((!x y. x IN group_carrier G /\\ y IN group_carrier G /\\\n group_pow G x n = group_pow G y n\n ==> x = y) <=>\n coprime(n,CARD(group_carrier G)))`;;\n\nlet FINITE_GROUP_ZPOW_INJECTIVE_EQ = `!(G:A group) n.\n FINITE(group_carrier G)\n ==> ((!x y. x IN group_carrier G /\\ y IN group_carrier G /\\\n group_zpow G x n = group_zpow G y n\n ==> x = y) <=>\n coprime(n,&(CARD(group_carrier G))))`;;\n\nlet FINITE_GROUP_POW_SURJECTIVE_EQ = `!(G:A group) n.\n FINITE(group_carrier G)\n ==> ((!x. x IN group_carrier G\n ==> ?y. y IN group_carrier G /\\ group_pow G y n = x) <=>\n coprime(n,CARD(group_carrier G)))`;;\n\nlet FINITE_GROUP_ZPOW_SURJECTIVE_EQ = `!(G:A group) n.\n FINITE(group_carrier G)\n ==> ((!x. x IN group_carrier G\n ==> ?y. y IN group_carrier G /\\ group_zpow G y n = x) <=>\n coprime(n,&(CARD(group_carrier G))))`;;\n\nlet FINITE_GROUP_ZROOT_EXISTS = `!G n x:A.\n FINITE(group_carrier G) /\\\n coprime(n,&(CARD(group_carrier G))) /\\\n x IN group_carrier G\n ==> ?y. y IN group_carrier G /\\ group_zpow G y n = x`;;\n\nlet FINITE_GROUP_ROOT_EXISTS = `!G n x:A.\n FINITE(group_carrier G) /\\\n coprime(n,CARD(group_carrier G)) /\\\n x IN group_carrier G\n ==> ?y. y IN group_carrier G /\\ group_pow G y n = x`;;\n\nlet ABELIAN_GROUP_MONOMORPHISM_POWERING_EQ = `!(G:A group) n.\n abelian_group G /\\ FINITE(group_carrier G)\n ==> (group_monomorphism (G,G) (\\x. group_pow G x n) <=>\n coprime(n,CARD(group_carrier G)))`;;\n\nlet ABELIAN_GROUP_MONOMORPHISM_POWERING = `!(G:A group) n.\n abelian_group G /\\ FINITE(group_carrier G) /\\\n coprime(n,CARD(group_carrier G))\n ==> group_monomorphism (G,G) (\\x. group_pow G x n)`;;\n\nlet ABELIAN_GROUP_ISOMORPHISM_POWERING_EQ = `!(G:A group) n.\n abelian_group G /\\ FINITE(group_carrier G)\n ==> (group_isomorphism (G,G) (\\x. group_pow G x n) <=>\n coprime(n,CARD(group_carrier G)))`;;\n\nlet ABELIAN_GROUP_ISOMORPHISM_POWERING = `!(G:A group) n.\n abelian_group G /\\ FINITE(group_carrier G) /\\\n coprime(n,CARD(group_carrier G))\n ==> group_isomorphism (G,G) (\\x. group_pow G x n)`;;\n\nlet ABELIAN_GROUP_EPIMORPHISM_POWERING_EQ = `!(G:A group) n.\n abelian_group G /\\ FINITE(group_carrier G)\n ==> (group_epimorphism (G,G) (\\x. group_pow G x n) <=>\n coprime(n,CARD(group_carrier G)))`;;\n\nlet ABELIAN_GROUP_EPIMORPHISM_POWERING = `!(G:A group) n.\n abelian_group G /\\ FINITE(group_carrier G) /\\\n coprime(n,CARD(group_carrier G))\n ==> group_epimorphism (G,G) (\\x. group_pow G x n)`;;\n\nlet PGROUP_ACTION_FIXPOINTS = `!G s (a:A->X->X) p.\n group_action G s a /\\ FINITE s /\\\n prime p /\\ FINITE(group_carrier G) /\\ pgroup {p} G\n ==> (CARD {x | x IN s /\\ !g. g IN group_carrier G ==> a g x = x} ==\n CARD s) (mod p)`;;\n\nlet PGROUP_ACTION_FIXPOINT = `!G s (a:A->X->X) p.\n group_action G s a /\\\n prime p /\\ FINITE(group_carrier G) /\\ pgroup {p} G /\\\n FINITE s /\\ ~(p divides CARD s)\n ==> ?x. x IN s /\\ !g. g IN group_carrier G ==> a g x = x`;;\n\nlet SYLOW_THEOREM_CONJUGATE_GEN = `!(G:A group) p k h j.\n prime p /\\\n h subgroup_of G /\\\n FINITE {left_coset G x h | x | x IN group_carrier G} /\\\n ~(p divides CARD {left_coset G x h | x | x IN group_carrier G}) /\\\n j subgroup_of G /\\ FINITE j /\\ CARD j = p EXP k\n ==> ?a. a IN group_carrier G /\\\n j SUBSET IMAGE (group_conjugation G a) h`;;\n\nlet SYLOW_THEOREM_CONJUGATE_SUBSET = `!(G:A group) p k l h j.\n FINITE(group_carrier G) /\\ prime p /\\\n ~(p EXP (k + 1) divides CARD(group_carrier G)) /\\\n h subgroup_of G /\\ CARD h = p EXP k /\\\n j subgroup_of G /\\ CARD j = p EXP l\n ==> ?a. a IN group_carrier G /\\\n j SUBSET IMAGE (group_conjugation G a) h`;;\n\nlet SYLOW_THEOREM_CONJUGATE_ALT = `!(G:A group) p k h h'.\n FINITE(group_carrier G) /\\ prime p /\\\n ~(p EXP (k + 1) divides CARD(group_carrier G)) /\\\n h subgroup_of G /\\ CARD h = p EXP k /\\\n h' subgroup_of G /\\ CARD h' = p EXP k\n ==> group_conjugate G h h'`;;\n\nlet SYLOW_THEOREM_CONJUGATE = `!(G:A group) p k h h'.\n FINITE(group_carrier G) /\\ prime p /\\\n index p (CARD(group_carrier G)) = k /\\\n h subgroup_of G /\\ CARD h = p EXP k /\\\n h' subgroup_of G /\\ CARD h' = p EXP k\n ==> group_conjugate G h h'`;;\n\nlet SYLOW_THEOREM_CONJUGATE_EQ = `!(G:A group) p k h h'.\n FINITE(group_carrier G) /\\ prime p /\\\n index p (CARD(group_carrier G)) = k /\\\n h subgroup_of G /\\ CARD h = p EXP k\n ==> (h' subgroup_of G /\\ CARD h' = p EXP k <=> group_conjugate G h h')`;;\n\nlet SYLOW_THEOREM_PGROUP_SUPERSET = `!G p k (h:A->bool).\n FINITE(group_carrier G) /\\ prime p /\\\n h subgroup_of G /\\ CARD h = p EXP k\n ==> ?h'. h' subgroup_of G /\\ h SUBSET h' /\\\n CARD h' = p EXP (index p (CARD(group_carrier G)))`;;\n\nlet SYLOW_THEOREM_NORMAL_UNIQUE = `!(G:A group) p k h h'.\n FINITE(group_carrier G) /\\ prime p /\\\n index p (CARD(group_carrier G)) = k /\\\n h normal_subgroup_of G /\\ CARD h = p EXP k\n ==> (h' subgroup_of G /\\ CARD h' = p EXP k <=> h' = h)`;;\n\nlet SYLOW_THEOREM_COUNT_NORMALIZER = `!(G:A group) h p k.\n FINITE(group_carrier G) /\\ prime p /\\\n index p (CARD(group_carrier G)) = k /\\\n h subgroup_of G /\\ CARD h = p EXP k\n ==> CARD {h | h subgroup_of G /\\ CARD h = p EXP k} =\n CARD(group_carrier G) DIV CARD(group_normalizer G h)`;;\n\nlet SYLOW_THEOREM_COUNT_NORMALIZER_MUL = `!(G:A group) h p k.\n FINITE(group_carrier G) /\\ prime p /\\\n index p (CARD(group_carrier G)) = k /\\\n h subgroup_of G /\\ CARD h = p EXP k\n ==> CARD {h | h subgroup_of G /\\ CARD h = p EXP k} *\n CARD(group_normalizer G h) =\n CARD(group_carrier G)`;;\n\nlet SYLOW_THEOREM_NORMAL_UNIQUE_EQ = `!G p k h:A->bool.\n FINITE (group_carrier G) /\\\n prime p /\\\n index p (CARD (group_carrier G)) = k /\\\n h subgroup_of G /\\\n CARD h = p EXP k\n ==> ((!h'. h' subgroup_of G /\\ CARD h' = p EXP k <=> h' = h) <=>\n h normal_subgroup_of G)`;;\n\nlet SYLOW_THEOREM_UNIQUE = `!(G:A group) p k.\n FINITE(group_carrier G) /\\\n prime p /\\\n index p (CARD(group_carrier G)) = k\n ==> ((?!h. h subgroup_of G /\\ CARD h = p EXP k) <=>\n (?h. h normal_subgroup_of G /\\ CARD h = p EXP k))`;;\n\nlet SYLOW_THEOREM_COUNT_DIVISOR = `!(G:A group) p k.\n FINITE(group_carrier G) /\\ prime p /\\\n index p (CARD(group_carrier G)) = k\n ==> CARD {h | h subgroup_of G /\\ CARD h = p EXP k}\n divides (CARD(group_carrier G)) DIV (p EXP k)`;;\n\nlet PGROUP_NONTRIVIAL_CENTRE_GEN = `!G (n:A->bool) p.\n prime p /\\ FINITE(group_carrier G) /\\ pgroup {p} G /\\\n n normal_subgroup_of G /\\ ~(n = {group_id G})\n ==> {group_id G} PSUBSET\n (group_centralizer G (group_carrier G) INTER n)`;;\n\nlet PGROUP_NONTRIVIAL_CENTRE = `!(G:A group) p k.\n prime p /\\ ~(k = 0) /\\ (group_carrier G) HAS_SIZE (p EXP k)\n ==> {group_id G} PSUBSET (group_centralizer G (group_carrier G))`;;\n\nlet PGROUP_DIVIDES_NORMALIZER_QUOTIENT = `!G p k h:A->bool.\n FINITE(group_carrier G) /\\\n prime p /\\\n h subgroup_of G /\\ CARD h = p EXP k /\\\n p divides CARD(group_carrier G) DIV CARD h\n ==> p divides CARD(group_normalizer G h) DIV CARD h`;;\n\nlet PGROUP_SUBGROUP_PSUBSET_NORMALIZER = `!G p h:A->bool.\n prime p /\\ FINITE(group_carrier G) /\\ pgroup {p} G /\\\n h subgroup_of G /\\ ~(h = group_carrier G)\n ==> h PSUBSET group_normalizer G h`;;\n\nlet PGROUP_MAXIMAL_NORMAL_SUBGROUP_OF = `!G p h:A->bool.\n prime p /\\ FINITE(group_carrier G) /\\ pgroup {p} G /\\\n h subgroup_of G /\\\n (!h'. h' subgroup_of G /\\ h PSUBSET h' ==> h' = group_carrier G)\n ==> h normal_subgroup_of G`;;\n\nlet PGROUP_FRATTINI = `!(G:A group) p k h j.\n prime p /\\\n FINITE j /\\ j normal_subgroup_of G /\\\n h SUBSET j /\\ h subgroup_of G /\\\n index p (CARD j) = k /\\ CARD h = p EXP k\n ==> group_setmul G (group_normalizer G h) j = group_carrier G`;;\n\nlet PGROUP_SELF_NORMALIZER = `!G p k s h:A->bool.\n FINITE(group_carrier G) /\\\n prime p /\\\n index p (CARD(group_carrier G)) = k /\\\n s subgroup_of G /\\ CARD s = p EXP k /\\\n h subgroup_of G /\\ group_normalizer G s SUBSET h\n ==> group_normalizer G h = h`;;\n\nlet PGROUP_NORMALIZER_NORMALIZER = `!G p k h:A->bool.\n FINITE(group_carrier G) /\\\n prime p /\\\n index p (CARD(group_carrier G)) = k /\\\n h subgroup_of G /\\ CARD h = p EXP k\n ==> group_normalizer G (group_normalizer G h) = group_normalizer G h`;;\n\nlet GROUP_DISJOINT_SUM_ALT = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> (g INTER h SUBSET {group_id G} <=> g INTER h = {group_id G})`;;\n\nlet GROUP_DISJOINT_SUM_ID = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> (g INTER h SUBSET {group_id G} <=>\n !x y. x IN g /\\ y IN h /\\ group_mul G x y = group_id G\n ==> x = group_id G /\\ y = group_id G)`;;\n\nlet GROUP_DISJOINT_SUM_CANCEL = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> (g INTER h SUBSET {group_id G} <=>\n !x x' y y'. x IN g /\\ x' IN g /\\ y IN h /\\ y' IN h /\\\n group_mul G x y = group_mul G x' y'\n ==> x = x' /\\ y = y')`;;\n\nlet GROUP_SUM_COMMUTING_IMP_NORMAL = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G /\\\n group_carrier G SUBSET group_setmul G g h /\\\n (!x y. x IN g /\\ y IN h ==> group_mul G x y = group_mul G y x)\n ==> g normal_subgroup_of G /\\ h normal_subgroup_of G`;;\n\nlet GROUP_SUM_NORMAL_IMP_COMMUTING = `!G g h:A->bool.\n g normal_subgroup_of G /\\ h normal_subgroup_of G /\\\n g INTER h SUBSET {group_id G}\n ==> !x y. x IN g /\\ y IN h ==> group_mul G x y = group_mul G y x`;;\n\nlet GROUP_SUM_NORMAL_EQ_COMMUTING = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G /\\\n group_carrier G SUBSET group_setmul G g h /\\\n g INTER h SUBSET {group_id G}\n ==> (g normal_subgroup_of G /\\ h normal_subgroup_of G <=>\n !x y. x IN g /\\ y IN h ==> group_mul G x y = group_mul G y x)`;;\n\nlet GROUP_HOMOMORPHISM_GROUP_MUL_GEN = `!G g h:A->bool.\n group_homomorphism\n (prod_group (subgroup_generated G g) (subgroup_generated G h),G)\n (\\(x,y). group_mul G x y) <=>\n !x y. x IN group_carrier G /\\ x IN g /\\\n y IN group_carrier G /\\ y IN h\n ==> group_mul G x y = group_mul G y x`;;\n\nlet GROUP_HOMOMORPHISM_GROUP_MUL_EQ = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> (group_homomorphism\n (prod_group (subgroup_generated G g) (subgroup_generated G h),G)\n (\\(x,y). group_mul G x y) <=>\n !x y. x IN g /\\ y IN h ==> group_mul G x y = group_mul G y x)`;;\n\nlet GROUP_HOMOMORPHISM_GROUP_MUL = `!G g h:A->bool.\n abelian_group G\n ==> group_homomorphism\n (prod_group (subgroup_generated G g) (subgroup_generated G h),G)\n (\\(x,y). group_mul G x y)`;;\n\nlet GROUP_EPIMORPHISM_GROUP_MUL_EQ = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> (group_epimorphism\n (prod_group (subgroup_generated G g) (subgroup_generated G h),G)\n (\\(x,y). group_mul G x y) <=>\n group_setmul G g h = group_carrier G /\\\n !x y. x IN g /\\ y IN h ==> group_mul G x y = group_mul G y x)`;;\n\nlet GROUP_MONOMORPHISM_GROUP_MUL_EQ = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> (group_monomorphism\n (prod_group (subgroup_generated G g) (subgroup_generated G h),G)\n (\\(x,y). group_mul G x y) <=>\n g INTER h = {group_id G} /\\\n !x y. x IN g /\\ y IN h ==> group_mul G x y = group_mul G y x)`;;\n\nlet GROUP_ISOMORPHISM_GROUP_MUL_ALT = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> (group_isomorphism\n (prod_group (subgroup_generated G g) (subgroup_generated G h),G)\n (\\(x,y). group_mul G x y) <=>\n g INTER h = {group_id G} /\\\n group_setmul G g h = group_carrier G /\\\n !x y. x IN g /\\ y IN h ==> group_mul G x y = group_mul G y x)`;;\n\nlet GROUP_ISOMORPHISM_GROUP_MUL_EQ = `!G g h:A->bool.\n g subgroup_of G /\\ h subgroup_of G\n ==> (group_isomorphism\n (prod_group (subgroup_generated G g) (subgroup_generated G h),G)\n (\\(x,y). group_mul G x y) <=>\n g normal_subgroup_of G /\\ h normal_subgroup_of G /\\\n g INTER h = {group_id G} /\\\n group_setmul G g h = group_carrier G)`;;\n\nlet GROUP_ISOMORPHISM_GROUP_MUL_GEN = `!G g h:A->bool.\n g normal_subgroup_of G /\\ h normal_subgroup_of G\n ==> (group_isomorphism\n (prod_group (subgroup_generated G g) (subgroup_generated G h),G)\n (\\(x,y). group_mul G x y) <=>\n g INTER h SUBSET {group_id G} /\\\n group_setmul G g h = group_carrier G)`;;\n\nlet GROUP_ISOMORPHISM_GROUP_MUL = `!G g h:A->bool.\n abelian_group G /\\ g subgroup_of G /\\ h subgroup_of G\n ==> (group_isomorphism\n (prod_group (subgroup_generated G g) (subgroup_generated G h),G)\n (\\(x,y). group_mul G x y) <=>\n g INTER h SUBSET {group_id G} /\\\n group_setmul G g h = group_carrier G)`;;\n\nlet ISOMORPHIC_PROD_GROUP_SUBGROUP_GENERATED = `!G g h:A->bool.\n g normal_subgroup_of G /\\ h normal_subgroup_of G /\\\n g INTER h = {group_id G}\n ==> prod_group (subgroup_generated G g) (subgroup_generated G h)\n isomorphic_group subgroup_generated G (group_setmul G g h)`;;\n\nlet GROUP_INTER_IM_KER = `!(f:A->B) (g:B->C) G H K.\n group_homomorphism(G,H) f /\\\n group_homomorphism(H,K) g /\\\n group_monomorphism(G,K) (g o f)\n ==> (group_image(G,H) f) INTER (group_kernel(H,K) g) =\n {group_id H}`;;\n\nlet GROUP_SUM_IM_KER = `!(f:A->B) (g:B->C) G H K.\n group_homomorphism(G,H) f /\\\n group_homomorphism(H,K) g /\\\n group_epimorphism(G,K) (g o f)\n ==> group_setmul H (group_image(G,H) f) (group_kernel(H,K) g) =\n group_carrier H`;;\n\nlet GROUP_SUM_KER_IM = `!(f:A->B) (g:B->C) G H K.\n group_homomorphism(G,H) f /\\\n group_homomorphism(H,K) g /\\\n group_epimorphism(G,K) (g o f)\n ==> group_setmul H (group_kernel(H,K) g) (group_image(G,H) f) =\n group_carrier H`;;\n\nlet GROUP_SEMIDIRECT_SUM_IM_KER = `!(f:A->B) (g:B->C) G H K.\n group_homomorphism(G,H) f /\\\n group_homomorphism(H,K) g /\\\n group_isomorphism(G,K) (g o f)\n ==> (group_image(G,H) f) INTER (group_kernel(H,K) g) = {group_id H} /\\\n group_setmul H (group_image(G,H) f) (group_kernel(H,K) g) =\n group_carrier H`;;\n\nlet GROUP_SEMIDIRECT_SUM_KER_IM = `!(f:A->B) (g:B->C) G H K.\n group_homomorphism(G,H) f /\\\n group_homomorphism(H,K) g /\\\n group_isomorphism(G,K) (g o f)\n ==> (group_kernel(H,K) g) INTER (group_image(G,H) f) = {group_id H} /\\\n group_setmul H (group_kernel(H,K) g) (group_image(G,H) f) =\n group_carrier H`;;\n\nlet GROUP_ISOMORPHISM_GROUP_MUL_IM_KER = `!(f:A->B) (g:B->C) G H K.\n abelian_group H /\\\n group_homomorphism(G,H) f /\\\n group_homomorphism(H,K) g /\\\n group_isomorphism(G,K) (g o f)\n ==> group_isomorphism\n (prod_group (subgroup_generated H (group_image(G,H) f))\n (subgroup_generated H (group_kernel(H,K) g)),H)\n (\\(x,y). group_mul H x y)`;;\n\nlet GROUP_ISOMORPHISM_GROUP_MUL_KER_IM = `!(f:A->B) (g:B->C) G H K.\n abelian_group H /\\\n group_homomorphism(G,H) f /\\\n group_homomorphism(H,K) g /\\\n group_isomorphism(G,K) (g o f)\n ==> group_isomorphism\n (prod_group (subgroup_generated H (group_kernel(H,K) g))\n (subgroup_generated H (group_image(G,H) f)),H)\n (\\(x,y). group_mul H x y)`;;\n\nlet GROUP_HOMOMORPHISM_GROUP_SUM_GEN = `!k l G (h:K->A->bool).\n k SUBSET l\n ==> (group_homomorphism (sum_group l (\\i. subgroup_generated G (h i)),G)\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN group_carrier G /\\ x IN (h i) /\\\n y IN group_carrier G /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k)`;;\n\nlet GROUP_HOMOMORPHISM_GROUP_SUM_EQ = `!k l G (h:K->A->bool).\n k SUBSET l /\\\n (!i. i IN k ==> (h i) subgroup_of G)\n ==> (group_homomorphism (sum_group l (\\i. subgroup_generated G (h i)),G)\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN (h i) /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k)`;;\n\nlet GROUP_HOMOMORPHISM_GROUP_SUM = `!k G (h:K->A->bool).\n pairwise (\\i j. !x y. x IN h i /\\ y IN h j\n ==> group_mul G x y = group_mul G y x) k\n ==> group_homomorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k)`;;\n\nlet GROUP_HOMOMORPHISM_ABELIAN_GROUP_SUM = `!k G (h:K->A->bool).\n abelian_group G\n ==> group_homomorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k)`;;\n\nlet ABELIAN_GROUP_HOMOMORPHISM_GROUP_SUM = `!(f:K->A->B) k A B.\n abelian_group B /\\\n (!i. i IN k ==> group_homomorphism (A i,B) (f i))\n ==> group_homomorphism (sum_group k A,B)\n (\\x. group_sum B k (\\i. (f i) (x i)))`;;\n\nlet SUBGROUP_EPIMORPHISM_GROUP_SUM_GEN = `!k l G (h:K->A->bool).\n k SUBSET l\n ==> (group_epimorphism (sum_group l (\\i. subgroup_generated G (h i)),\n subgroup_generated G (UNIONS {h i | i IN k}))\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN group_carrier G /\\ x IN (h i) /\\\n y IN group_carrier G /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k)`;;\n\nlet SUBGROUP_EPIMORPHISM_GROUP_SUM_EQ = `!k l G (h:K->A->bool).\n k SUBSET l /\\\n (!i. i IN k ==> (h i) subgroup_of G)\n ==> (group_epimorphism (sum_group l (\\i. subgroup_generated G (h i)),\n subgroup_generated G (UNIONS {h i | i IN k}))\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN (h i) /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k)`;;\n\nlet SUBGROUP_EPIMORPHISM_GROUP_SUM = `!k G (h:K->A->bool).\n pairwise (\\i j. !x y. x IN h i /\\ y IN h j\n ==> group_mul G x y = group_mul G y x) k\n ==> group_epimorphism (sum_group k (\\i. subgroup_generated G (h i)),\n subgroup_generated G (UNIONS {h i | i IN k}))\n (group_sum G k)`;;\n\nlet SUBGROUP_EPIMORPHISM_ABELIAN_GROUP_SUM = `!k G (h:K->A->bool).\n abelian_group G\n ==> group_epimorphism (sum_group k (\\i. subgroup_generated G (h i)),\n subgroup_generated G (UNIONS {h i | i IN k}))\n (group_sum G k)`;;\n\nlet GROUP_EPIMORPHISM_GROUP_SUM_GEN = `!k l G (h:K->A->bool).\n k SUBSET l\n ==> (group_epimorphism (sum_group l (\\i. subgroup_generated G (h i)),G)\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN group_carrier G /\\ x IN (h i) /\\\n y IN group_carrier G /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G)`;;\n\nlet GROUP_EPIMORPHISM_GROUP_SUM_EQ = `!k l G (h:K->A->bool).\n k SUBSET l /\\\n (!i. i IN k ==> (h i) subgroup_of G)\n ==> (group_epimorphism (sum_group l (\\i. subgroup_generated G (h i)),G)\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN (h i) /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G)`;;\n\nlet GROUP_EPIMORPHISM_GROUP_SUM = `!k G (h:K->A->bool).\n pairwise (\\i j. !x y. x IN h i /\\ y IN h j\n ==> group_mul G x y = group_mul G y x) k /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G\n ==> group_epimorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k)`;;\n\nlet GROUP_EPIMORPHISM_ABELIAN_GROUP_SUM = `!k G (h:K->A->bool).\n abelian_group G /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G\n ==> group_epimorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k)`;;\n\nlet GROUP_MONOMORPHISM_GROUP_SUM_GEN = `!k G (h:K->A->bool).\n group_monomorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN group_carrier G /\\ x IN (h i) /\\\n y IN group_carrier G /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k /\\\n !i. i IN k\n ==> group_carrier\n (subgroup_generated G (h i)) INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G}`;;\n\nlet GROUP_MONOMORPHISM_GROUP_SUM_EQ = `!k G (h:K->A->bool).\n (!i. i IN k ==> (h i) subgroup_of G)\n ==> (group_monomorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN (h i) /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k /\\\n !i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})`;;\n\nlet GROUP_MONOMORPHISM_GROUP_SUM = `!k G (h:K->A->bool).\n (!i. i IN k ==> (h i) subgroup_of G) /\\\n pairwise (\\i j. !x y. x IN h i /\\ y IN h j\n ==> group_mul G x y = group_mul G y x) k /\\\n (!i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})\n ==> group_monomorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k)`;;\n\nlet GROUP_MONOMORPHISM_ABELIAN_GROUP_SUM = `!k G (h:K->A->bool).\n abelian_group G /\\\n (!i. i IN k ==> (h i) subgroup_of G) /\\\n (!i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})\n ==> group_monomorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k)`;;\n\nlet SUBGROUP_ISOMORPHISM_GROUP_SUM_GEN = `!k G (h:K->A->bool).\n group_isomorphism (sum_group k (\\i. subgroup_generated G (h i)),\n subgroup_generated G (UNIONS {h i | i IN k}))\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN group_carrier G /\\ x IN (h i) /\\\n y IN group_carrier G /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k /\\\n !i. i IN k\n ==> group_carrier\n (subgroup_generated G (h i)) INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G}`;;\n\nlet SUBGROUP_ISOMORPHISM_GROUP_SUM_EQ = `!k G (h:K->A->bool).\n (!i. i IN k ==> (h i) subgroup_of G)\n ==> (group_isomorphism (sum_group k (\\i. subgroup_generated G (h i)),\n subgroup_generated G (UNIONS {h i | i IN k}))\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN (h i) /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k /\\\n !i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})`;;\n\nlet SUBGROUP_ISOMORPHISM_GROUP_SUM = `!k G (h:K->A->bool).\n (!i. i IN k ==> (h i) subgroup_of G) /\\\n pairwise (\\i j. !x y. x IN h i /\\ y IN h j\n ==> group_mul G x y = group_mul G y x) k /\\\n (!i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})\n ==> group_isomorphism (sum_group k (\\i. subgroup_generated G (h i)),\n subgroup_generated G (UNIONS {h i | i IN k}))\n (group_sum G k)`;;\n\nlet SUBGROUP_ISOMORPHISM_ABELIAN_GROUP_SUM = `!k G (h:K->A->bool).\n abelian_group G /\\\n (!i. i IN k ==> (h i) subgroup_of G) /\\\n (!i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})\n ==> group_isomorphism (sum_group k (\\i. subgroup_generated G (h i)),\n subgroup_generated G (UNIONS {h i | i IN k}))\n (group_sum G k)`;;\n\nlet GROUP_ISOMORPHISM_GROUP_SUM_GEN = `!k G (h:K->A->bool).\n group_isomorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN group_carrier G /\\ x IN (h i) /\\\n y IN group_carrier G /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G /\\\n !i. i IN k\n ==> group_carrier\n (subgroup_generated G (h i)) INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G}`;;\n\nlet GROUP_ISOMORPHISM_GROUP_SUM_EQ = `!k G (h:K->A->bool).\n (!i. i IN k ==> (h i) subgroup_of G)\n ==> (group_isomorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k) <=>\n pairwise (\\i j. !x y. x IN (h i) /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G /\\\n !i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})`;;\n\nlet GROUP_ISOMORPHISM_GROUP_SUM = `!k G (h:K->A->bool).\n (!i. i IN k ==> (h i) subgroup_of G) /\\\n pairwise (\\i j. !x y. x IN h i /\\ y IN h j\n ==> group_mul G x y = group_mul G y x) k /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G /\\\n (!i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})\n ==> group_isomorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k)`;;\n\nlet GROUP_ISOMORPHISM_ABELIAN_GROUP_SUM = `!k G (h:K->A->bool).\n abelian_group G /\\\n (!i. i IN k ==> (h i) subgroup_of G) /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G /\\\n (!i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})\n ==> group_isomorphism (sum_group k (\\i. subgroup_generated G (h i)),G)\n (group_sum G k)`;;\n\nlet ISOMORPHIC_SUM_GROUP_GEN = `!k G (h:K->A->bool).\n pairwise (\\i j. !x y. x IN group_carrier G /\\ x IN (h i) /\\\n y IN group_carrier G /\\ y IN (h j)\n ==> group_mul G x y = group_mul G y x) k /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G /\\\n (!i. i IN k\n ==> group_carrier\n (subgroup_generated G (h i)) INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})\n ==> sum_group k (\\i. subgroup_generated G (h i)) isomorphic_group G`;;\n\nlet ISOMORPHIC_SUM_GROUP = `!k G (h:K->A->bool).\n (!i. i IN k ==> (h i) subgroup_of G) /\\\n pairwise (\\i j. !x y. x IN h i /\\ y IN h j\n ==> group_mul G x y = group_mul G y x) k /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G /\\\n (!i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})\n ==> sum_group k (\\i. subgroup_generated G (h i)) isomorphic_group G`;;\n\nlet ISOMORPHIC_ABELIAN_SUM_GROUP = `!k G (h:K->A->bool).\n abelian_group G /\\\n (!i. i IN k ==> (h i) subgroup_of G) /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G /\\\n (!i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})\n ==> sum_group k (\\i. subgroup_generated G (h i)) isomorphic_group G`;;\n\nlet ISOMORPHIC_NORMAL_SUM_GROUP = `!k G (h:K->A->bool).\n (!i. i IN k ==> (h i) normal_subgroup_of G) /\\\n subgroup_generated G (UNIONS {h i | i IN k}) = G /\\\n (!i. i IN k\n ==> h i INTER\n group_carrier\n (subgroup_generated G (UNIONS {h j | j IN k DELETE i})) =\n {group_id G})\n ==> sum_group k (\\i. subgroup_generated G (h i)) isomorphic_group G`;;\n\nlet CARRIER_SUBGROUP_GENERATED_UNIONS = `!(G:A group) u.\n abelian_group G\n ==> group_carrier(subgroup_generated G (UNIONS u)) =\n IMAGE (group_sum G u)\n (group_carrier (sum_group u (\\i. subgroup_generated G i)))`;;\n\nlet CARRIER_SUBGROUP_GENERATED_UNIONS_ALT = `!(G:A group) u.\n abelian_group G\n ==> group_carrier(subgroup_generated G (UNIONS u)) =\n { group_sum G u f | f |\n (!s. s IN u ==> f s IN group_carrier(subgroup_generated G s)) /\\\n FINITE {s | s IN u /\\ ~(f s = group_id G)}}`;;\n\nlet CARRIER_SUBGROUP_GENERATED_UNIONS_FINITE = `!(G:A group) u.\n abelian_group G /\\ FINITE u\n ==> group_carrier(subgroup_generated G (UNIONS u)) =\n { group_sum G u f | f |\n (!s. s IN u ==> f s IN group_carrier(subgroup_generated G s))}`;;\n\nlet CARRIER_SUBGROUP_GENERATED_UNIONS_EXPLICIT = `!(G:A group) u.\n abelian_group G\n ==> group_carrier(subgroup_generated G (UNIONS u)) =\n { group_sum G t f | t,f |\n FINITE t /\\ t SUBSET u /\\\n (!s. s IN t ==> f s IN group_carrier(subgroup_generated G s))}`;;\n\nlet CARRIER_SUBGROUP_GENERATED_ALT = `!G (s:A->bool).\n abelian_group G /\\ s SUBSET group_carrier G\n ==> group_carrier(subgroup_generated G s) =\n { group_sum G s (\\x. group_zpow G x (n x)) | n |\n FINITE {x | x IN s /\\ ~(n x = &0)}}`;;\n\nlet CARRIER_SUBGROUP_GENERATED_FINITE = `!G (s:A->bool).\n abelian_group G /\\ FINITE s /\\ s SUBSET group_carrier G\n ==> group_carrier(subgroup_generated G s) =\n { group_sum G s (\\x. group_zpow G x (n x)) | n IN (:A->int)}`;;\n\nlet CARRIER_SUBGROUP_GENERATED_EXPLICIT = `!G (s:A->bool).\n abelian_group G /\\ s SUBSET group_carrier G\n ==> group_carrier(subgroup_generated G s) =\n { group_sum G t (\\x. group_zpow G x (n x)) | t,n |\n FINITE t /\\ t SUBSET s}`;;\n\nlet SUBGROUP_GENERATED_UNIONS_PRIME_TORSION_FINITE = `!(G:A group) P.\n FINITE {p | prime p /\\ P p}\n ==> subgroup_generated G\n (UNIONS\n {{ x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k} | prime p /\\ P p}) =\n subgroup_generated G\n {x | x IN group_carrier G /\\\n !p. prime p /\\ p divides group_element_order G x ==> P p}`;;\n\nlet SUBGROUP_GENERATED_UNIONS_PRIME_TORSION = `!(G:A group) P.\n subgroup_generated G\n (UNIONS\n {{ x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k} | prime p /\\ P p}) =\n subgroup_generated G\n {x | x IN group_carrier G /\\ ~(group_element_order G x = 0) /\\\n !p. prime p /\\ p divides group_element_order G x ==> P p}`;;\n\nlet SUBGROUP_GENERATED_UNIONS_PRIME_TORSION_FULL = `!(G:A group).\n subgroup_generated G\n (UNIONS\n {{ x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k} | prime p}) =\n subgroup_generated G\n {x | x IN group_carrier G /\\ ~(group_element_order G x = 0)}`;;\n\nlet PGROUP_PRIME_TORSION = `!(G:A group) p.\n abelian_group G /\\ prime p\n ==> pgroup {p} (subgroup_generated G\n {x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k})`;;\n\nlet PGROUP_SUBSET_PRIME_TORSION = `!(G:A group) p s.\n prime p /\\\n s SUBSET group_carrier G /\\\n pgroup {p} (subgroup_generated G s)\n ==> s SUBSET {x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k}`;;\n\nlet ABELIAN_GROUP_TORSION_ISOMORPHISM = `!G:A group.\n abelian_group G\n ==> group_isomorphism\n (sum_group {p | prime p}\n (\\p. subgroup_generated G\n {x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k}),\n subgroup_generated G\n {x | x IN group_carrier G /\\ ~(group_element_order G x = 0)})\n (group_sum G {p | prime p})`;;\n\nlet ABELIAN_GROUP_TORSION_STRUCTURE = `!G:A group.\n abelian_group G\n ==> subgroup_generated G\n {x | x IN group_carrier G /\\ ~(group_element_order G x = 0)}\n isomorphic_group\n sum_group {p | prime p}\n (\\p. subgroup_generated G\n {x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k})`;;\n\nlet TORSION_ABELIAN_GROUP_ISOMORPHISM = `!G:A group.\n abelian_group G /\\\n (!x. x IN group_carrier G ==> ~(group_element_order G x = 0))\n ==> group_isomorphism\n (sum_group {p | prime p}\n (\\p. subgroup_generated G\n {x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k}),\n G)\n (group_sum G {p | prime p})`;;\n\nlet TORSION_ABELIAN_GROUP_STRUCTURE = `!G:A group.\n abelian_group G /\\\n (!x. x IN group_carrier G ==> ~(group_element_order G x = 0))\n ==> G isomorphic_group\n sum_group {p | prime p}\n (\\p. subgroup_generated G\n {x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k})`;;\n\nlet FINITE_ABELIAN_GROUP_STRUCTURE = `!G:A group.\n abelian_group G /\\ FINITE(group_carrier G)\n ==> G isomorphic_group\n sum_group {p | prime p /\\ p divides CARD(group_carrier G)}\n (\\p. subgroup_generated G\n {x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k})`;;\n\nlet FINITE_ABELIAN_GROUP_STRUCTURE_ALT = `!G:A group.\n abelian_group G /\\ FINITE(group_carrier G)\n ==> G isomorphic_group\n product_group {p | prime p /\\ p divides CARD(group_carrier G)}\n (\\p. subgroup_generated G\n {x | x IN group_carrier G /\\\n ?k. group_element_order G x = p EXP k})`;;\n\nlet TORSION_ABELIAN_GROUP_AS_SUM_OF_PGROUPS = `!G:A group.\n abelian_group G\n ==> ((!x. x IN group_carrier G ==> ~(group_element_order G x = 0)) <=>\n ?H:num->A group.\n (!p. prime p ==> pgroup {p} (H p)) /\\\n G isomorphic_group sum_group {p | prime p} H)`;;\n\nlet FINITELY_GENERATED_ABELIAN_SUBGROUP_STRUCTURE_ISOMORPHISM = `!G (s:A->bool).\n abelian_group G /\\ FINITE s\n ==> ?t. FINITE t /\\ CARD t <= CARD s /\\ t SUBSET group_carrier G /\\\n subgroup_generated G t = subgroup_generated G s /\\\n group_isomorphism\n (sum_group t (\\x. subgroup_generated G {x}),\n subgroup_generated G s)\n (group_sum G t)`;;\n\nlet FINITELY_GENERATED_ABELIAN_SUBGROUP_STRUCTURE_ISOMORPHISM_ALT = `!G (s:A->bool).\n abelian_group G /\\ FINITE s\n ==> ?t. FINITE t /\\ CARD t <= CARD s /\\ t SUBSET group_carrier G /\\\n subgroup_generated G t = subgroup_generated G s /\\\n group_isomorphism\n (product_group t (\\x. subgroup_generated G {x}),\n subgroup_generated G s)\n (group_sum G t)`;;\n\nlet FINITELY_GENERATED_ABELIAN_SUBGROUP_STRUCTURE_EXPLICIT = `!G (s:A->bool).\n abelian_group G /\\ FINITE s\n ==> ?t. FINITE t /\\ CARD t <= CARD s /\\ t SUBSET group_carrier G /\\\n subgroup_generated G t = subgroup_generated G s /\\\n subgroup_generated G s isomorphic_group\n sum_group t (\\x. subgroup_generated G {x})`;;\n\nlet FINITELY_GENERATED_ABELIAN_SUBGROUP_STRUCTURE_EXPLICIT_ALT = `!G (s:A->bool).\n abelian_group G /\\ FINITE s\n ==> ?t. FINITE t /\\ CARD t <= CARD s /\\ t SUBSET group_carrier G /\\\n subgroup_generated G t = subgroup_generated G s /\\\n subgroup_generated G s isomorphic_group\n product_group t (\\x. subgroup_generated G {x})`;;\n\nlet FINITELY_GENERATED_ABELIAN_GROUP_STRUCTURE_EXPLICIT = `!G:A group.\n finitely_generated_group G /\\ abelian_group G <=>\n ?t. FINITE t /\\ t SUBSET group_carrier G /\\\n G isomorphic_group sum_group t (\\x. subgroup_generated G {x})`;;\n\nlet FINITELY_GENERATED_ABELIAN_GROUP_STRUCTURE_EXPLICIT_ALT = `!G:A group.\n finitely_generated_group G /\\ abelian_group G <=>\n ?t. FINITE t /\\ t SUBSET group_carrier G /\\\n G isomorphic_group product_group t (\\x. subgroup_generated G {x})`;;\n\nlet FINITELY_GENERATED_ABELIAN_GROUP_AS_SUM_OF_CYCLIC_GROUPS = `!G:A group.\n finitely_generated_group G /\\ abelian_group G <=>\n ?n H:num->A group.\n (!i. 1 <= i /\\ i <= n ==> cyclic_group (H i)) /\\\n G isomorphic_group sum_group (1..n) H`;;\n\nlet FINITELY_GENERATED_ABELIAN_GROUP_AS_PRODUCT_OF_CYCLIC_GROUPS = `!G:A group.\n finitely_generated_group G /\\ abelian_group G <=>\n ?n H:num->A group.\n (!i. 1 <= i /\\ i <= n ==> cyclic_group (H i)) /\\\n G isomorphic_group product_group (1..n) H`;;\n\nlet FINITELY_GENERATED_ABELIAN_GROUP_AS_SUM_OF_INTEGER_MOD_GROUPS = `!G:A group.\n finitely_generated_group G /\\ abelian_group G <=>\n ?n d. G isomorphic_group sum_group (1..n) (\\i. integer_mod_group(d i))`;;\n\nlet FINITELY_GENERATED_ABELIAN_GROUP_AS_PRODUCT_OF_INTEGER_MOD_GROUPS = `!G:A group.\n finitely_generated_group G /\\ abelian_group G <=>\n ?n d. G isomorphic_group\n product_group (1..n) (\\i. integer_mod_group(d i))`;;\n\nlet FINITELY_GENERATED_ABELIAN_GROUP_AS_SUM_OF_INTEGER_GROUPS = `!G:A group.\n finitely_generated_group G /\\ abelian_group G /\\\n (!x. x IN group_carrier G ==> group_element_order G x <= 1) <=>\n ?n. G isomorphic_group sum_group (1..n) (\\i. integer_group)`;;\n\nlet FINITELY_GENERATED_ABELIAN_GROUP_AS_PRODUCT_OF_INTEGER_GROUPS = `!G:A group.\n finitely_generated_group G /\\ abelian_group G /\\\n (!x. x IN group_carrier G ==> group_element_order G x <= 1) <=>\n ?n. G isomorphic_group product_group (1..n) (\\i. integer_group)`;;\n\nlet free_abelian_group = new_definition\n `free_abelian_group (s:A->bool) =\n group({c | frag_support c SUBSET s},frag_0,frag_neg,frag_add)`;;\n\nlet FREE_ABELIAN_GROUP = `(!s:A->bool.\n group_carrier(free_abelian_group s) = {c | frag_support c SUBSET s}) /\\\n (!s:A->bool. group_id(free_abelian_group s) = frag_0) /\\\n (!s:A->bool. group_inv(free_abelian_group s) = frag_neg) /\\\n (!s:A->bool. group_mul(free_abelian_group s) = frag_add)`;;\n\nlet ABELIAN_FREE_ABELIAN_GROUP = `!s:A->bool. abelian_group(free_abelian_group s)`;;\n\nlet FREE_ABELIAN_GROUP_POW = `!(s:A->bool) x n.\n group_pow (free_abelian_group s) x n = frag_cmul (&n) x`;;\n\nlet FREE_ABELIAN_GROUP_ZPOW = `!(s:A->bool) x n.\n group_zpow (free_abelian_group s) x n = frag_cmul n x`;;\n\nlet FRAG_OF_IN_FREE_ABELIAN_GROUP = `!s x:A. frag_of x IN group_carrier(free_abelian_group s) <=> x IN s`;;\n\nlet FREE_ABELIAN_GROUP_INDUCT = `!P s:A->bool.\n P(frag_0) /\\\n (!x y. x IN group_carrier(free_abelian_group s) /\\\n y IN group_carrier(free_abelian_group s) /\\\n P x /\\ P y\n ==> P(frag_sub x y)) /\\\n (!a. a IN s ==> P(frag_of a))\n ==> !x. x IN group_carrier(free_abelian_group s) ==> P x`;;\n\nlet FREE_ABELIAN_GROUP_UNIVERSAL = `!(f:A->B) s G.\n IMAGE f s SUBSET group_carrier G /\\ abelian_group G\n ==> ?h. group_homomorphism(free_abelian_group s,G) h /\\\n !x. x IN s ==> h(frag_of x) = f x`;;\n\nlet ISOMORPHIC_GROUP_INTEGER_FREE_ABELIAN_GROUP_SING = `!x:A. integer_group isomorphic_group free_abelian_group {x}`;;\n\nlet GROUP_HOMOMORPHISM_FREE_ABELIAN_GROUPS_ID = `!k k':A->bool.\n group_homomorphism (free_abelian_group k,free_abelian_group k') (\\x. x) <=>\n k SUBSET k'`;;\n\nlet GROUP_ISOMORPHISM_FREE_ABELIAN_GROUP_SUM = `!k (f:K->A->bool).\n pairwise (\\i j. DISJOINT (f i) (f j)) k\n ==> group_isomorphism (sum_group k (\\i. free_abelian_group(f i)),\n free_abelian_group(UNIONS {f i | i IN k}))\n (iterate frag_add k)`;;\n\nlet ISOMORPHIC_FREE_ABELIAN_GROUP_UNIONS = `!k:(A->bool)->bool.\n pairwise DISJOINT k\n ==> free_abelian_group(UNIONS k) isomorphic_group\n sum_group k free_abelian_group`;;\n\nlet ISOMORPHIC_SUM_INTEGER_GROUP = `!k:A->bool.\n sum_group k (\\i. integer_group) isomorphic_group free_abelian_group k`;;\n\nlet CARD_EQ_FREE_ABELIAN_GROUP_INFINITE = `!s:A->bool. INFINITE s ==> group_carrier(free_abelian_group s) =_c s`;;\n\nlet CARD_EQ_HOMOMORPHISMS_FROM_FREE_ABELIAN_GROUP = `!(s:A->bool) (G:B group).\n abelian_group G\n ==> {f | EXTENSIONAL (group_carrier(free_abelian_group s)) f /\\\n group_homomorphism(free_abelian_group s,G) f} =_c\n (group_carrier G) ^_c s`;;\n\nlet ISOMORPHIC_FREE_ABELIAN_GROUPS = `!(s:A->bool) (t:B->bool).\n free_abelian_group s isomorphic_group free_abelian_group t <=>\n s =_c t`;;\n\nlet group_exactness = new_definition\n `group_exactness (G,H,K) ((f:A->B),(g:B->C)) <=>\n group_homomorphism (G,H) f /\\ group_homomorphism (H,K) g /\\\n group_image (G,H) f = group_kernel (H,K) g`;;\n\nlet short_exact_sequence = new_definition\n `short_exact_sequence(A,B,C) (f:A->B,g:B->C) <=>\n group_monomorphism (A,B) f /\\\n group_exactness (A,B,C) (f,g) /\\\n group_epimorphism (B,C) g`;;\n\nlet SHORT_EXACT_SEQUENCE = `!(f:A->B) (g:B->C) A B C.\n short_exact_sequence(A,B,C) (f,g) <=>\n group_monomorphism (A,B) f /\\\n group_epimorphism (B,C) g /\\\n group_image (A,B) f = group_kernel (B,C) g`;;\n\nlet GROUP_EXACTNESS_MONOMORPHISM = `!f:(A->B) (g:B->C) A B C.\n trivial_group A\n ==> (group_exactness (A,B,C) (f,g) <=>\n group_homomorphism(A,B) f /\\ group_monomorphism (B,C) g)`;;\n\nlet GROUP_EXACTNESS_EPIMORPHISM = `!f:(A->B) (g:B->C) A B C.\n trivial_group C\n ==> (group_exactness (A,B,C) (f,g) <=>\n group_epimorphism(A,B) f /\\ group_homomorphism (B,C) g)`;;\n\nlet EXTREMELY_SHORT_EXACT_SEQUENCE = `!f:(A->B) (g:B->C) A B C.\n group_exactness (A,B,C) (f,g) /\\\n trivial_group A /\\ trivial_group C\n ==> trivial_group B`;;\n\nlet GROUP_EXACTNESS_EPIMORPHISM_EQ_TRIVIALITY = `!(f:A->B) (g:B->C) (h:C->D) A B C D.\n group_exactness (A,B,C) (f,g) /\\\n group_exactness (B,C,D) (g,h)\n ==> (group_epimorphism (A,B) f <=> trivial_homomorphism(B,C) g)`;;\n\nlet GROUP_EXACTNESS_MONOMORPHISM_EQ_TRIVIALITY = `!(f:A->B) (g:B->C) (h:C->D) A B C D.\n group_exactness (A,B,C) (f,g) /\\\n group_exactness (B,C,D) (g,h)\n ==> (group_monomorphism (C,D) h <=> trivial_homomorphism(B,C) g)`;;\n\nlet VERY_SHORT_EXACT_SEQUENCE = `!(f:A->B) (g:B->C) (h:C->D) A B C D.\n group_exactness (A,B,C) (f,g) /\\\n group_exactness (B,C,D) (g,h) /\\\n trivial_group A /\\ trivial_group D\n ==> group_isomorphism (B,C) g`;;\n\nlet GROUP_EXACTNESS_EQ_TRIVIALITY = `!f:(A->B) (g:B->C) (h:C->D) (k:D->E) A B C D E.\n group_exactness (A,B,C) (f,g) /\\\n group_exactness (B,C,D) (g,h) /\\\n group_exactness (C,D,E) (h,k)\n ==> (trivial_group C <=>\n group_epimorphism (A,B) f /\\\n group_monomorphism (D,E) k)`;;\n\nlet GROUP_EXACTNESS_IMP_TRIVIALITY = `!(f:A->B) (g:B->C) (h:C->D) (k:D->E) A B C D E.\n group_exactness (A,B,C) (f,g) /\\\n group_exactness (B,C,D) (g,h) /\\\n group_exactness (C,D,E) (h,k) /\\\n group_isomorphism (A,B) f /\\\n group_isomorphism (D,E) k\n ==> trivial_group C`;;\n\nlet GROUP_EXACTNESS_ISOMORPHISM_EQ_TRIVIALITY = `!(f:A->B) (g:B->C) (h:C->D) (j:D->E) (k:E->G) A B C D E G.\n group_exactness (A,B,C) (f,g) /\\\n group_exactness (B,C,D) (g,h) /\\\n group_exactness (C,D,E) (h,j) /\\\n group_exactness (D,E,G) (j,k)\n ==> (group_isomorphism (C,D) h <=>\n trivial_homomorphism(B,C) g /\\ trivial_homomorphism(D,E) j)`;;\n\nlet GROUP_EXACTNESS_ISOMORPHISM_EQ_MONO_EPI = `!(f:A->B) (g:B->C) (h:C->D) (j:D->E) (k:E->G) A B C D E G.\n group_exactness (A,B,C) (f,g) /\\\n group_exactness (B,C,D) (g,h) /\\\n group_exactness (C,D,E) (h,j) /\\\n group_exactness (D,E,G) (j,k)\n ==> (group_isomorphism (C,D) h <=>\n group_epimorphism(A,B) f /\\ group_monomorphism(E,G) k)`;;\n\nlet SHORT_EXACT_SEQUENCE_NORMAL_SUBGROUP = `!G n:A->bool.\n n normal_subgroup_of G\n ==> short_exact_sequence\n (subgroup_generated G n,G,quotient_group G n)\n ((\\x. x),right_coset G n)`;;\n\nlet SHORT_EXACT_SEQUENCE_PROD_GROUP = `!(G:A group) (H:B group).\n short_exact_sequence(G,prod_group G H,H) ((\\x. x,group_id H),SND)`;;\n\nlet SHORT_EXACT_SEQUENCE_PROD_GROUP_ALT = `!(G:A group) (H:B group).\n short_exact_sequence(H,prod_group G H,G) ((\\x. group_id G,x),FST)`;;\n\nlet EXACT_SEQUENCE_SUM_LEMMA = `!(f:X->C) (g:X->D) (h:A->C) (i:A->X) (j:B->X) (k:B->D) A B C D X.\n abelian_group X /\\\n group_isomorphism(A,C) h /\\\n group_isomorphism(B,D) k /\\\n group_exactness(A,X,D) (i,g) /\\\n group_exactness(B,X,C) (j,f) /\\\n (!x. x IN group_carrier A ==> f(i x) = h x) /\\\n (!x. x IN group_carrier B ==> g(j x) = k x)\n ==> group_isomorphism (prod_group A B,X)\n (\\(x,y). group_mul X (i x) (j y)) /\\\n group_isomorphism (X,prod_group C D) (\\z. f z,g z)`;;\n\nlet SHORT_EXACT_SEQUENCE_QUOTIENT = `!(f:A->B) (g:B->C) A B C.\n short_exact_sequence(A,B,C) (f,g)\n ==> subgroup_generated B (group_image(A,B) f) isomorphic_group A /\\\n quotient_group B (group_image(A,B) f) isomorphic_group C`;;\n\nlet TRIVIAL_GROUPS_IMP_SHORT_EXACT_SEQUENCE = `!(f:A->B) (g:B->C) (h:C->D) (k:D->E) A B C D E.\n trivial_group A /\\ trivial_group E /\\\n group_exactness(A,B,C) (f,g) /\\\n group_exactness(B,C,D) (g,h) /\\\n group_exactness(C,D,E) (h,k)\n ==> short_exact_sequence(B,C,D) (g,h)`;;\n\nlet SHORT_EXACT_SEQUENCE_TRIVIAL_GROUPS = `!(g:B->C) h B C D.\n short_exact_sequence(B,C,D) (g,h) <=>\n ?f:(A->B) (k:D->E) A E.\n trivial_group A /\\ trivial_group E /\\\n group_exactness(A,B,C) (f,g) /\\\n group_exactness(B,C,D) (g,h) /\\\n group_exactness(C,D,E) (h,k)`;;\n\nlet SPLITTING_SUBLEMMA_GEN = `!(f:A->B) (g:B->C) A B C h k.\n group_exactness(A,B,C) (f,g) /\\\n group_image(A,B) f = h /\\ k subgroup_of B /\\\n h INTER k SUBSET {group_id B} /\\ group_setmul B h k = group_carrier B\n ==> group_isomorphism(subgroup_generated B k,\n subgroup_generated C (group_image(B,C) g)) g`;;\n\nlet SPLITTING_SUBLEMMA = `!(f:A->B) (g:B->C) A B C h k.\n short_exact_sequence(A,B,C) (f,g) /\\\n group_image(A,B) f = h /\\ k subgroup_of B /\\\n h INTER k SUBSET {group_id B} /\\ group_setmul B h k = group_carrier B\n ==> group_isomorphism(A,subgroup_generated B h) f /\\\n group_isomorphism(subgroup_generated B k,C) g`;;\n\nlet SPLITTING_LEMMA_LEFT_GEN = `!(f:A->B) f' (g:B->C) A B C.\n short_exact_sequence(A,B,C) (f,g) /\\\n group_homomorphism(B,A) f' /\\\n group_isomorphism(A,A) (f' o f)\n ==> ?h k. h normal_subgroup_of B /\\ k normal_subgroup_of B /\\\n h INTER k SUBSET {group_id B} /\\\n group_setmul B h k = group_carrier B /\\\n group_isomorphism(A,subgroup_generated B h) f /\\\n group_isomorphism(subgroup_generated B k,C) g`;;\n\nlet SPLITTING_LEMMA_LEFT = `!(f:A->B) f' (g:B->C) A B C.\n short_exact_sequence(A,B,C) (f,g) /\\\n group_homomorphism(B,A) f' /\\\n (!x. x IN group_carrier A ==> f'(f x) = x)\n ==> ?h k. h normal_subgroup_of B /\\ k normal_subgroup_of B /\\\n h INTER k SUBSET {group_id B} /\\\n group_setmul B h k = group_carrier B /\\\n group_isomorphism(A,subgroup_generated B h) f /\\\n group_isomorphism(subgroup_generated B k,C) g`;;\n\nlet SPLITTING_LEMMA_LEFT_PROD_GROUP = `!(f:A->B) f' (g:B->C) A B C.\n short_exact_sequence(A,B,C) (f,g) /\\\n abelian_group B /\\\n group_homomorphism(B,A) f' /\\\n (!x. x IN group_carrier A ==> f'(f x) = x)\n ==> B isomorphic_group prod_group A C`;;\n\nlet SPLITTING_LEMMA_RIGHT_GEN = `!(f:A->B) (g:B->C) g' A B C.\n short_exact_sequence(A,B,C) (f,g) /\\\n group_homomorphism(C,B) g' /\\\n group_isomorphism(C,C) (g o g')\n ==> ?h k. h normal_subgroup_of B /\\ k subgroup_of B /\\\n h INTER k SUBSET {group_id B} /\\\n group_setmul B h k = group_carrier B /\\\n group_isomorphism(A,subgroup_generated B h) f /\\\n group_isomorphism(subgroup_generated B k,C) g`;;\n\nlet SPLITTING_LEMMA_RIGHT = `!(f:A->B) (g:B->C) g' A B C.\n short_exact_sequence(A,B,C) (f,g) /\\\n group_homomorphism(C,B) g' /\\\n (!z. z IN group_carrier C ==> g(g' z) = z)\n ==> ?h k. h normal_subgroup_of B /\\ k subgroup_of B /\\\n h INTER k SUBSET {group_id B} /\\\n group_setmul B h k = group_carrier B /\\\n group_isomorphism(A,subgroup_generated B h) f /\\\n group_isomorphism(subgroup_generated B k,C) g`;;\n\nlet SPLITTING_LEMMA_RIGHT_PROD_GROUP = `!(f:A->B) (g:B->C) g' A B C.\n short_exact_sequence(A,B,C) (f,g) /\\\n abelian_group B /\\\n group_homomorphism(C,B) g' /\\\n (!z. z IN group_carrier C ==> g(g' z) = z)\n ==> B isomorphic_group prod_group A C`;;\n\nlet SPLITTING_LEMMA_FREE_ABELIAN_GROUP = `!(f:A->B) (g:B->C) A B C (s:D->bool).\n short_exact_sequence (A,B,C) (f,g) /\\\n abelian_group B /\\ C isomorphic_group free_abelian_group s\n ==> B isomorphic_group prod_group A C`;;\n\nlet FOUR_LEMMA_MONO = `!(f:A->B) (g:B->C) (h:C->D) (f':A'->B') (g':B'->C') (h':C'->D') a b c d\n A B C D A' B' C' D'.\n group_epimorphism(A,A') a /\\\n group_monomorphism(B,B') b /\\\n group_homomorphism(C,C') c /\\\n group_monomorphism(D,D') d /\\\n group_exactness(A,B,C) (f,g) /\\ group_exactness(B,C,D) (g,h) /\\\n group_exactness(A',B',C') (f',g') /\\ group_exactness(B',C',D') (g',h') /\\\n (!x. x IN group_carrier A ==> f'(a x) = b(f x)) /\\\n (!y. y IN group_carrier B ==> g'(b y) = c(g y)) /\\\n (!z. z IN group_carrier C ==> h'(c z) = d(h z))\n ==> group_monomorphism(C,C') c`;;\n\nlet FOUR_LEMMA_EPI = `!(f:A->B) (g:B->C) (h:C->D) (f':A'->B') (g':B'->C') (h':C'->D') a b c d\n A B C D A' B' C' D'.\n group_epimorphism(A,A') a /\\\n group_homomorphism(B,B') b /\\\n group_epimorphism(C,C') c /\\\n group_monomorphism(D,D') d /\\\n group_exactness(A,B,C) (f,g) /\\ group_exactness(B,C,D) (g,h) /\\\n group_exactness(A',B',C') (f',g') /\\ group_exactness(B',C',D') (g',h') /\\\n (!x. x IN group_carrier A ==> f'(a x) = b(f x)) /\\\n (!y. y IN group_carrier B ==> g'(b y) = c(g y)) /\\\n (!z. z IN group_carrier C ==> h'(c z) = d(h z))\n ==> group_epimorphism(B,B') b`;;\n\nlet FIVE_LEMMA = `!(f:A->B) (g:B->C) (h:C->D) (k:D->E)\n (f':A'->B') (g':B'->C') (h':C'->D') (k':D'->E') a b c d e\n A B C D E A' B' C' D' E'.\n group_epimorphism(A,A') a /\\\n group_isomorphism(B,B') b /\\\n group_homomorphism(C,C') c /\\\n group_isomorphism(D,D') d /\\\n group_monomorphism(E,E') e /\\\n group_exactness(A,B,C) (f,g) /\\\n group_exactness(B,C,D) (g,h) /\\\n group_exactness(C,D,E) (h,k) /\\\n group_exactness(A',B',C') (f',g') /\\\n group_exactness(B',C',D') (g',h') /\\\n group_exactness(C',D',E') (h',k') /\\\n (!x. x IN group_carrier A ==> f'(a x) = b(f x)) /\\\n (!y. y IN group_carrier B ==> g'(b y) = c(g y)) /\\\n (!z. z IN group_carrier C ==> h'(c z) = d(h z)) /\\\n (!w. w IN group_carrier D ==> k'(d w) = e(k w))\n ==> group_isomorphism(C,C') c`;;\n\nlet SHORT_FIVE_LEMMA_MONO = `!(f:A->B) (g:B->C) (f':A'->B') (g':B'->C') a b c A B C A' B' C'.\n group_monomorphism(A,A') a /\\\n group_homomorphism(B,B') b /\\\n group_monomorphism(C,C') c /\\\n short_exact_sequence(A,B,C) (f,g) /\\\n short_exact_sequence(A',B',C') (f',g') /\\\n (!x. x IN group_carrier A ==> f'(a x) = b(f x)) /\\\n (!y. y IN group_carrier B ==> g'(b y) = c(g y))\n ==> group_monomorphism(B,B') b`;;\n\nlet SHORT_FIVE_LEMMA_EPI = `!(f:A->B) (g:B->C) (f':A'->B') (g':B'->C') a b c A B C A' B' C'.\n group_epimorphism(A,A') a /\\\n group_homomorphism(B,B') b /\\\n group_epimorphism(C,C') c /\\\n short_exact_sequence(A,B,C) (f,g) /\\\n short_exact_sequence(A',B',C') (f',g') /\\\n (!x. x IN group_carrier A ==> f'(a x) = b(f x)) /\\\n (!y. y IN group_carrier B ==> g'(b y) = c(g y))\n ==> group_epimorphism(B,B') b`;;\n\nlet SHORT_FIVE_LEMMA = `!(f:A->B) (g:B->C) (f':A'->B') (g':B'->C') a b c A B C A' B' C'.\n group_isomorphism(A,A') a /\\\n group_homomorphism(B,B') b /\\\n group_isomorphism(C,C') c /\\\n short_exact_sequence(A,B,C) (f,g) /\\\n short_exact_sequence(A',B',C') (f',g') /\\\n (!x. x IN group_carrier A ==> f'(a x) = b(f x)) /\\\n (!y. y IN group_carrier B ==> g'(b y) = c(g y))\n ==> group_isomorphism(B,B') b`;;\n\nlet EXACT_SEQUENCE_HEXAGON_LEMMA = `!(f:X->C) (g:X->D) (h:A->C) (h':C->A) (i:A->X) (j:B->X) (k:B->D) (k':D->B)\n (a:A->Y) (b:B->Y) (c:W->C) (d:W->D) (l:W->X) (m:X->Y) A B C D W X Y.\n abelian_group X /\\\n group_homomorphism(A,Y) a /\\\n group_homomorphism(B,Y) b /\\\n group_homomorphism(W,C) c /\\\n group_homomorphism(W,D) d /\\\n group_isomorphisms(A,C) (h,h') /\\\n group_isomorphisms(B,D) (k,k') /\\\n group_exactness(A,X,D) (i,g) /\\\n group_exactness(B,X,C) (j,f) /\\\n group_exactness(W,X,Y) (l,m) /\\\n (!x. x IN group_carrier W ==> f(l x) = c x) /\\\n (!x. x IN group_carrier W ==> g(l x) = d x) /\\\n (!x. x IN group_carrier A ==> f(i x) = h x) /\\\n (!x. x IN group_carrier A ==> m(i x) = a x) /\\\n (!x. x IN group_carrier B ==> g(j x) = k x) /\\\n (!x. x IN group_carrier B ==> m(j x) = b x)\n ==> !x. x IN group_carrier W\n ==> group_inv Y (a(h'(c x))) = b(k'(d x))`;;" }, { "theorem_id": 57, "title": "072_sylow_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory Sylow\n imports Coset Exponent\nbegin\n\ntext \\See also \\<^cite>\\\"Kammueller-Paulson:1999\"\\.\\\n\ntext \\The combinatorial argument is in theory \\Exponent\\.\\\n\nlemma le_extend_mult: \"\\0 < c; a \\ b\\ \\ a \\ b * c\" for c :: nat\n by sorry\n\nlocale sylow = group +\n fixes p and a and m and calM and RelM\n assumes prime_p: \"prime p\"\n and order_G: \"order G = (p^a) * m\"\n and finite_G[iff]: \"finite (carrier G)\"\n defines \"calM \\ {s. s \\ carrier G \\ card s = p^a}\"\n and \"RelM \\ {(N1, N2). N1 \\ calM \\ N2 \\ calM \\ (\\g \\ carrier G. N1 = N2 #> g)}\"\nbegin\n\nlemma RelM_subset: \"RelM \\ calM \\ calM\"\n by sorry\n\nlemma RelM_refl_on: \"refl_on calM RelM\"\n by sorry\n\nlemma RelM_sym: \"sym RelM\"\n by sorry\n\nlemma RelM_trans: \"trans RelM\"\n by sorry\n\nlemma RelM_equiv: \"equiv calM RelM\"\n by sorry\n\nlemma M_subset_calM_prep: \"M' \\ calM // RelM \\ M' \\ calM\"\n by sorry\n\nend\n\nsubsection \\Main Part of the Proof\\\n\nlocale sylow_central = sylow +\n fixes H and M1 and M\n assumes M_in_quot: \"M \\ calM // RelM\"\n and not_dvd_M: \"\\ (p ^ Suc (multiplicity p m) dvd card M)\"\n and M1_in_M: \"M1 \\ M\"\n defines \"H \\ {g. g \\ carrier G \\ M1 #> g = M1}\"\nbegin\n\nlemma M_subset_calM: \"M \\ calM\"\n by sorry\n\nlemma card_M1: \"card M1 = p^a\"\n by sorry\n\nlemma exists_x_in_M1: \"\\x. x \\ M1\"\n by sorry\n\nlemma M1_subset_G [simp]: \"M1 \\ carrier G\"\n by sorry\n\nlemma M1_inj_H: \"\\f \\ H\\M1. inj_on f H\"\n by sorry\n\nend\n\nsubsection \\Discharging the Assumptions of \\sylow_central\\\\\n\ncontext sylow\nbegin\n\nlemma EmptyNotInEquivSet: \"{} \\ calM // RelM\"\n by sorry\n\nlemma existsM1inM: \"M \\ calM // RelM \\ \\M1. M1 \\ M\"\n by sorry\n\nlemma zero_less_o_G: \"0 < order G\"\n by sorry\n\nlemma zero_less_m: \"m > 0\"\n by sorry\n\nlemma card_calM: \"card calM = (p^a) * m choose p^a\"\n by sorry\n\nlemma zero_less_card_calM: \"card calM > 0\"\n by sorry\n\nlemma max_p_div_calM: \"\\ (p ^ Suc (multiplicity p m) dvd card calM)\"\n by sorry\n\nlemma finite_calM: \"finite calM\"\n by sorry\n\nlemma lemma_A1: \"\\M \\ calM // RelM. \\ (p ^ Suc (multiplicity p m) dvd card M)\"\n by sorry\n\nend\n\nsubsubsection \\Introduction and Destruct Rules for \\H\\\\\n\ncontext sylow_central\nbegin\n\nlemma H_I: \"\\g \\ carrier G; M1 #> g = M1\\ \\ g \\ H\"\n by sorry\n\nlemma H_into_carrier_G: \"x \\ H \\ x \\ carrier G\"\n by sorry\n\nlemma in_H_imp_eq: \"g \\ H \\ M1 #> g = M1\"\n by sorry\n\nlemma H_m_closed: \"\\x \\ H; y \\ H\\ \\ x \\ y \\ H\"\n by sorry\n\nlemma H_not_empty: \"H \\ {}\"\n by sorry\n\nlemma H_is_subgroup: \"subgroup H G\"\n by sorry\n\nlemma rcosetGM1g_subset_G: \"\\g \\ carrier G; x \\ M1 #> g\\ \\ x \\ carrier G\"\n by sorry\n\nlemma finite_M1: \"finite M1\"\n by sorry\n\nlemma finite_rcosetGM1g: \"g \\ carrier G \\ finite (M1 #> g)\"\n by sorry\n\nlemma M1_cardeq_rcosetGM1g: \"g \\ carrier G \\ card (M1 #> g) = card M1\"\n by sorry\n\nlemma M1_RelM_rcosetGM1g: \n assumes \"g \\ carrier G\"\n shows \"(M1, M1 #> g) \\ RelM\"\n by sorry\n\nend\n\nsubsection \\Equal Cardinalities of \\M\\ and the Set of Cosets\\\n\ntext \\Injections between \\<^term>\\M\\ and \\<^term>\\rcosets\\<^bsub>G\\<^esub> H\\ show that\n their cardinalities are equal.\\\n\nlemma ElemClassEquiv: \"\\equiv A r; C \\ A // r\\ \\ \\x \\ C. \\y \\ C. (x, y) \\ r\"\n by sorry\n\ncontext sylow_central\nbegin\n\nlemma M_elem_map: \"M2 \\ M \\ \\g. g \\ carrier G \\ M1 #> g = M2\"\n by sorry\n\nlemmas M_elem_map_carrier = M_elem_map [THEN someI_ex, THEN conjunct1]\n\nlemmas M_elem_map_eq = M_elem_map [THEN someI_ex, THEN conjunct2]\n\nlemma M_funcset_rcosets_H:\n \"(\\x\\M. H #> (SOME g. g \\ carrier G \\ M1 #> g = x)) \\ M \\ rcosets H\"\n by sorry\n\nlemma inj_M_GmodH: \"\\f \\ M \\ rcosets H. inj_on f M\"\n by sorry\n\nend\n\nsubsubsection \\The Opposite Injection\\\n\ncontext sylow_central\nbegin\n\nlemma H_elem_map: \"H1 \\ rcosets H \\ \\g. g \\ carrier G \\ H #> g = H1\"\n by sorry\n\nlemmas H_elem_map_carrier = H_elem_map [THEN someI_ex, THEN conjunct1]\n\nlemmas H_elem_map_eq = H_elem_map [THEN someI_ex, THEN conjunct2]\n\nlemma rcosets_H_funcset_M:\n \"(\\C \\ rcosets H. M1 #> (SOME g. g \\ carrier G \\ H #> g = C)) \\ rcosets H \\ M\"\n by sorry\n\nlemma inj_GmodH_M: \"\\g \\ rcosets H\\M. inj_on g (rcosets H)\"\n by sorry\n\nlemma calM_subset_PowG: \"calM \\ Pow (carrier G)\"\n by sorry\n\nlemma finite_M: \"finite M\"\n by sorry\n\nlemma cardMeqIndexH: \"card M = card (rcosets H)\"\n by sorry\n\nlemma index_lem: \"card M * card H = order G\"\n by sorry\n\nlemma card_H_eq: \"card H = p^a\"\n by sorry\n\nend\n\nlemma (in sylow) sylow_thm: \"\\H. subgroup H G \\ card H = p^a\"\n by sorry\n\ntext \\Needed because the locale's automatic definition refers to\n \\<^term>\\semigroup G\\ and \\<^term>\\group_axioms G\\ rather than\n simply to \\<^term>\\group G\\.\\\nlemma sylow_eq: \"sylow G p a m \\ group G \\ sylow_axioms G p a m\"\n by sorry\n\nsubsection \\Sylow's Theorem\\\n\ntheorem sylow_thm:\n \"\\prime p; group G; order G = (p^a) * m; finite (carrier G)\\\n \\ \\H. subgroup H G \\ card H = p^a\"\n by sorry\n\nend" }, { "theorem_id": 57, "title": "072_sylow_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Thomas Browning\n-/\nmodule\n\npublic import Mathlib.Algebra.Order.Archimedean.Basic\npublic import Mathlib.Data.SetLike.Fintype\npublic import Mathlib.GroupTheory.PGroup\npublic import Mathlib.GroupTheory.NoncommPiCoprod\n\n/-!\n# Sylow theorems\n\nThe Sylow theorems are the following results for every finite group `G` and every prime number `p`.\n\n* There exists a Sylow `p`-subgroup of `G`.\n* All Sylow `p`-subgroups of `G` are conjugate to each other.\n* Let `nₚ` be the number of Sylow `p`-subgroups of `G`, then `nₚ` divides the index of the Sylow\n `p`-subgroup, `nₚ ≡ 1 [MOD p]`, and `nₚ` is equal to the index of the normalizer of the Sylow\n `p`-subgroup in `G`.\n\n## Main definitions\n\n* `Sylow p G` : The type of Sylow `p`-subgroups of `G`.\n\n## Main statements\n\n* `Sylow.exists_subgroup_card_pow_prime`: A generalization of Sylow's first theorem:\n For every prime power `pⁿ` dividing the cardinality of `G`,\n there exists a subgroup of `G` of order `pⁿ`.\n* `IsPGroup.exists_le_sylow`: A generalization of Sylow's first theorem:\n Every `p`-subgroup is contained in a Sylow `p`-subgroup.\n* `Sylow.card_eq_multiplicity`: The cardinality of a Sylow subgroup is `p ^ n`\n where `n` is the multiplicity of `p` in the group order.\n* `Sylow.isPretransitive_of_finite`: a generalization of Sylow's second theorem:\n If the number of Sylow `p`-subgroups is finite, then all Sylow `p`-subgroups are conjugate.\n* `card_sylow_modEq_one`: a generalization of Sylow's third theorem:\n If the number of Sylow `p`-subgroups is finite, then it is congruent to `1` modulo `p`.\n-/\n\n@[expose] public section\n\n\nopen MulAction Subgroup\n\nsection InfiniteSylow\n\nvariable (p : ℕ) (G : Type*) [Group G]\n\n/-- A Sylow `p`-subgroup is a maximal `p`-subgroup. -/\nstructure Sylow extends Subgroup G where\n isPGroup' : IsPGroup p toSubgroup\n is_maximal' : ∀ {Q : Subgroup G}, IsPGroup p Q → toSubgroup ≤ Q → Q = toSubgroup\n\nvariable {p} {G}\n\nnamespace Sylow\n\nattribute [coe] toSubgroup\n\ninstance : CoeOut (Sylow p G) (Subgroup G) :=\n ⟨toSubgroup⟩\n\n@[ext]\ntheorem ext {P Q : Sylow p G} (h : (P : Subgroup G) = Q) : P = Q := by cases P; cases Q; congr\n\ninstance : SetLike (Sylow p G) G where\n coe := (↑)\n coe_injective' _ _ h := ext (SetLike.coe_injective h)\n\ninstance : PartialOrder (Sylow p G) := .ofSetLike (Sylow p G) G\n\ninstance : SubgroupClass (Sylow p G) G where\n mul_mem := Subgroup.mul_mem _\n one_mem _ := Subgroup.one_mem _\n inv_mem := Subgroup.inv_mem _\n\n@[simp]\nprotected theorem coe_coe (P : Sylow p G) : (P : Subgroup G) = (P : Set G) :=\n rfl\n\n/-- A `p`-subgroup with index indivisible by `p` is a Sylow subgroup. -/\ndef _root_.IsPGroup.toSylow [Fact p.Prime] {P : Subgroup G}\n (hP1 : IsPGroup p P) (hP2 : ¬ p ∣ P.index) : Sylow p G :=\n { P with\n isPGroup' := hP1\n is_maximal' := by sorry\ndef ofCard [Finite G] {p : ℕ} [Fact p.Prime] (H : Subgroup G)\n (card_eq : Nat.card H = p ^ (Nat.card G).factorization p) : Sylow p G :=\n (IsPGroup.of_card card_eq).toSylow (by\n rw [← mul_dvd_mul_iff_left (Nat.card_pos (α := H)).ne', card_mul_index, card_eq, ← pow_succ]\n exact Nat.pow_succ_factorization_not_dvd Nat.card_pos.ne' Fact.out)\n\n@[simp, norm_cast]\ntheorem coe_ofCard [Finite G] {p : ℕ} [Fact p.Prime] (H : Subgroup G)\n (card_eq : Nat.card H = p ^ (Nat.card G).factorization p) : ofCard H card_eq = H :=\n rfl\n\nvariable (P : Sylow p G)\n\nvariable {K : Type*} [Group K] (ϕ : K →* G) {N : Subgroup G}\n\n/-- The preimage of a Sylow subgroup under a p-group-kernel homomorphism is a Sylow subgroup. -/\ndef comapOfKerIsPGroup (hϕ : IsPGroup p ϕ.ker) (h : P ≤ ϕ.range) : Sylow p K :=\n { P.1.comap ϕ with\n isPGroup' := P.2.comap_of_ker_isPGroup ϕ hϕ\n is_maximal' := fun {Q} hQ hle => by\n show Q = P.1.comap ϕ\n rw [← P.3 (hQ.map ϕ) (le_trans (ge_of_eq (map_comap_eq_self h)) (map_mono hle))]\n exact (comap_map_eq_self ((P.1.ker_le_comap ϕ).trans hle)).symm }\n\n@[simp]\ntheorem coe_comapOfKerIsPGroup (hϕ : IsPGroup p ϕ.ker) (h : P ≤ ϕ.range) :\n P.comapOfKerIsPGroup ϕ hϕ h = P.comap ϕ :=\n rfl\n\n/-- The preimage of a Sylow subgroup under an injective homomorphism is a Sylow subgroup. -/\ndef comapOfInjective (hϕ : Function.Injective ϕ) (h : P ≤ ϕ.range) : Sylow p K :=\n P.comapOfKerIsPGroup ϕ (IsPGroup.ker_isPGroup_of_injective hϕ) h\n\n@[simp]\ntheorem coe_comapOfInjective (hϕ : Function.Injective ϕ) (h : P ≤ ϕ.range) :\n P.comapOfInjective ϕ hϕ h = P.comap ϕ :=\n rfl\n\n/-- A sylow subgroup of G is also a sylow subgroup of a subgroup of G. -/\nprotected def subtype (h : P ≤ N) : Sylow p N :=\n P.comapOfInjective N.subtype Subtype.coe_injective (by rwa [range_subtype])\n\n@[simp]\ntheorem coe_subtype (h : P ≤ N) : P.subtype h = subgroupOf P N :=\n rfl\n\ntheorem subtype_injective {P Q : Sylow p G} {hP : P ≤ N} {hQ : Q ≤ N}\n (h : P.subtype hP = Q.subtype hQ) : P = Q := by sorry\nend Sylow\n\n/-- A generalization of **Sylow's first theorem**.\n Every `p`-subgroup is contained in a Sylow `p`-subgroup. -/\ntheorem IsPGroup.exists_le_sylow {P : Subgroup G} (hP : IsPGroup p P) : ∃ Q : Sylow p G, P ≤ Q :=\n Exists.elim\n (zorn_le_nonempty₀ { Q : Subgroup G | IsPGroup p Q }\n (fun c hc1 hc2 Q hQ =>\n ⟨{ carrier := ⋃ R : c, R\n one_mem' := ⟨Q, ⟨⟨Q, hQ⟩, rfl⟩, Q.one_mem⟩\n inv_mem' := fun {_} ⟨_, ⟨R, rfl⟩, hg⟩ => ⟨R, ⟨R, rfl⟩, R.1.inv_mem hg⟩\n mul_mem' := fun {_} _ ⟨_, ⟨R, rfl⟩, hg⟩ ⟨_, ⟨S, rfl⟩, hh⟩ =>\n (hc2.total R.2 S.2).elim (fun T => ⟨S, ⟨S, rfl⟩, S.1.mul_mem (T hg) hh⟩) fun T =>\n ⟨R, ⟨R, rfl⟩, R.1.mul_mem hg (T hh)⟩ },\n fun ⟨g, _, ⟨S, rfl⟩, hg⟩ => by\n refine Exists.imp (fun k hk => ?_) (hc1 S.2 ⟨g, hg⟩)\n rwa [Subtype.ext_iff, coe_pow] at hk ⊢, fun M hM _ hg => ⟨M, ⟨⟨M, hM⟩, rfl⟩, hg⟩⟩)\n P hP)\n fun {Q} h => ⟨⟨Q, h.2.prop, h.2.eq_of_ge⟩, h.1⟩\n\nnamespace Sylow\n\ninstance nonempty : Nonempty (Sylow p G) :=\n IsPGroup.of_bot.exists_le_sylow.nonempty\n\nnoncomputable instance inhabited : Inhabited (Sylow p G) :=\n Classical.inhabited_of_nonempty nonempty\n\ntheorem exists_comap_eq_of_ker_isPGroup {H : Type*} [Group H] (P : Sylow p H) {f : H →* G}\n (hf : IsPGroup p f.ker) : ∃ Q : Sylow p G, Q.comap f = P :=\n Exists.imp (fun Q hQ => P.3 (Q.2.comap_of_ker_isPGroup f hf) (map_le_iff_le_comap.mp hQ))\n (P.2.map f).exists_le_sylow\n\ntheorem exists_comap_eq_of_injective {H : Type*} [Group H] (P : Sylow p H) {f : H →* G}\n (hf : Function.Injective f) : ∃ Q : Sylow p G, Q.comap f = P :=\n P.exists_comap_eq_of_ker_isPGroup (IsPGroup.ker_isPGroup_of_injective hf)\n\ntheorem exists_comap_subtype_eq {H : Subgroup G} (P : Sylow p H) :\n ∃ Q : Sylow p G, Q.comap H.subtype = P :=\n P.exists_comap_eq_of_injective Subtype.coe_injective\n\n/-- If the kernel of `f : H →* G` is a `p`-group,\n then `Finite (Sylow p G)` implies `Finite (Sylow p H)`. -/\ntheorem finite_of_ker_is_pGroup {H : Type*} [Group H] {f : H →* G}\n (hf : IsPGroup p f.ker) [Finite (Sylow p G)] : Finite (Sylow p H) :=\n let h_exists := fun P : Sylow p H => P.exists_comap_eq_of_ker_isPGroup hf\n let g : Sylow p H → Sylow p G := fun P => Classical.choose (h_exists P)\n have hg : ∀ P : Sylow p H, (g P).1.comap f = P := fun P => Classical.choose_spec (h_exists P)\n Finite.of_injective g fun P Q h => ext (by rw [← hg, h]; exact (h_exists Q).choose_spec)\n\n/-- If `f : H →* G` is injective, then `Finite (Sylow p G)` implies `Finite (Sylow p H)`. -/\ntheorem finite_of_injective {H : Type*} [Group H] {f : H →* G}\n (hf : Function.Injective f) [Finite (Sylow p G)] : Finite (Sylow p H) :=\n finite_of_ker_is_pGroup (IsPGroup.ker_isPGroup_of_injective hf)\n\n/-- If `H` is a subgroup of `G`, then `Finite (Sylow p G)` implies `Finite (Sylow p H)`. -/\ninstance (H : Subgroup G) [Finite (Sylow p G)] : Finite (Sylow p H) :=\n finite_of_injective H.subtype_injective\n\n/-- If a Sylow `p`-subgroup has finite index, then the number of Sylow `p`-subgroups is finite. -/\ntheorem finite_of_finiteIndex (P : Sylow p G) [P.FiniteIndex] : Finite (Sylow p G) := by sorry\nopen Pointwise\n\n/-- `Subgroup.pointwiseMulAction` preserves Sylow subgroups. -/\ninstance pointwiseMulAction {α : Type*} [Group α] [MulDistribMulAction α G] :\n MulAction α (Sylow p G) where\n smul g P :=\n ⟨g • P.toSubgroup, P.2.map _, fun {Q} hQ hS =>\n inv_smul_eq_iff.mp\n (P.3 (hQ.map _) fun s hs =>\n (congr_arg (· ∈ g⁻¹ • Q) (inv_smul_smul g s)).mp\n (smul_mem_pointwise_smul (g • s) g⁻¹ Q (hS (smul_mem_pointwise_smul s g P hs))))⟩\n one_smul P := ext (one_smul α P.toSubgroup)\n mul_smul g h P := ext (mul_smul g h P.toSubgroup)\n\ntheorem pointwise_smul_def {α : Type*} [Group α] [MulDistribMulAction α G] {g : α}\n {P : Sylow p G} : ↑(g • P) = g • (P : Subgroup G) :=\n rfl\n\ninstance mulAction : MulAction G (Sylow p G) :=\n compHom _ MulAut.conj\n\ntheorem smul_def {g : G} {P : Sylow p G} : g • P = MulAut.conj g • P :=\n rfl\n\ntheorem coe_subgroup_smul {g : G} {P : Sylow p G} :\n ↑(g • P) = MulAut.conj g • (P : Subgroup G) :=\n rfl\n\ntheorem coe_smul {g : G} {P : Sylow p G} : ↑(g • P) = MulAut.conj g • (P : Set G) :=\n rfl\n\ntheorem smul_le {P : Sylow p G} {H : Subgroup G} (hP : P ≤ H) (h : H) : ↑(h • P) ≤ H :=\n Subgroup.conj_smul_le_of_le hP h\n\ntheorem smul_subtype {P : Sylow p G} {H : Subgroup G} (hP : P ≤ H) (h : H) :\n h • P.subtype hP = (h • P).subtype (smul_le hP h) :=\n ext (Subgroup.conj_smul_subgroupOf hP h)\n\ntheorem smul_eq_iff_mem_normalizer {g : G} {P : Sylow p G} :\n g • P = P ↔ g ∈ normalizer P := by sorry\ntheorem smul_eq_of_normal {g : G} {P : Sylow p G} [h : P.Normal] : g • P = P := by sorry\nend Sylow\n\ntheorem Subgroup.sylow_mem_fixedPoints_iff (H : Subgroup G) {P : Sylow p G} :\n P ∈ fixedPoints H (Sylow p G) ↔ H ≤ normalizer P := by sorry\ntheorem IsPGroup.inf_normalizer_sylow {P : Subgroup G} (hP : IsPGroup p P) (Q : Sylow p G) :\n P ⊓ normalizer Q = P ⊓ Q :=\n le_antisymm\n (le_inf inf_le_left\n (sup_eq_right.mp\n (Q.3 (hP.to_inf_left.to_sup_of_normal_right' Q.2 inf_le_right) le_sup_right)))\n (inf_le_inf_left P le_normalizer)\n\ntheorem IsPGroup.sylow_mem_fixedPoints_iff {P : Subgroup G} (hP : IsPGroup p P) {Q : Sylow p G} :\n Q ∈ fixedPoints P (Sylow p G) ↔ P ≤ Q := by sorry\ninstance Sylow.isPretransitive_of_finite [hp : Fact p.Prime] [Finite (Sylow p G)] :\n IsPretransitive G (Sylow p G) :=\n ⟨fun P Q => by\n classical\n have H := fun {R : Sylow p G} {S : orbit G P} =>\n calc\n S ∈ fixedPoints R (orbit G P) ↔ S.1 ∈ fixedPoints R (Sylow p G) :=\n forall_congr' fun a => Subtype.ext_iff\n _ ↔ R.1 ≤ S := R.2.sylow_mem_fixedPoints_iff\n _ ↔ S.1.1 = R := ⟨fun h => R.3 S.1.2 h, ge_of_eq⟩\n suffices Set.Nonempty (fixedPoints Q (orbit G P)) by\n exact Exists.elim this fun R hR => by\n rw [← Sylow.ext (H.mp hR)]\n exact R.2\n apply Q.2.nonempty_fixed_point_of_prime_not_dvd_card\n refine fun h => hp.out.not_dvd_one (Nat.modEq_zero_iff_dvd.mp ?_)\n calc\n 1 = Nat.card (fixedPoints P (orbit G P)) := ?_\n _ ≡ Nat.card (orbit G P) [MOD p] := (P.2.card_modEq_card_fixedPoints (orbit G P)).symm\n _ ≡ 0 [MOD p] := Nat.modEq_zero_iff_dvd.mpr h\n rw [← Nat.card_unique (α := ({⟨P, mem_orbit_self P⟩} : Set (orbit G P))), eq_comm]\n congr\n rw [Set.eq_singleton_iff_unique_mem]\n exact ⟨H.mpr rfl, fun R h => Subtype.ext (Sylow.ext (H.mp h))⟩⟩\n\nvariable (p) (G)\n\n/-- A generalization of **Sylow's third theorem**.\n If the number of Sylow `p`-subgroups is finite, then it is congruent to `1` modulo `p`. -/\ntheorem card_sylow_modEq_one [Fact p.Prime] [Finite (Sylow p G)] :\n Nat.card (Sylow p G) ≡ 1 [MOD p] := by sorry\ntheorem not_dvd_card_sylow [hp : Fact p.Prime] [Finite (Sylow p G)] : ¬p ∣ Nat.card (Sylow p G) :=\n fun h =>\n hp.1.ne_one\n (Nat.dvd_one.mp\n ((Nat.modEq_iff_dvd' zero_le_one).mp\n ((Nat.modEq_zero_iff_dvd.mpr h).symm.trans (card_sylow_modEq_one p G))))\n\nvariable {p} {G}\n\nnamespace Sylow\n\n/-- Sylow subgroups are isomorphic -/\nnonrec def equivSMul (P : Sylow p G) (g : G) : P ≃* (g • P : Sylow p G) :=\n equivSMul (MulAut.conj g) P.toSubgroup\n\n/-- Sylow subgroups are isomorphic -/\nnoncomputable def equiv [Fact p.Prime] [Finite (Sylow p G)] (P Q : Sylow p G) : P ≃* Q := by sorry\ntheorem orbit_eq_top [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) : orbit G P = ⊤ :=\n top_le_iff.mp fun Q _ => exists_smul_eq G P Q\n\ntheorem stabilizer_eq_normalizer (P : Sylow p G) :\n stabilizer G P = normalizer P := by sorry\ntheorem conj_eq_normalizer_conj_of_mem_centralizer [Fact p.Prime] [Finite (Sylow p G)]\n (P : Sylow p G) (x g : G) (hx : x ∈ centralizer P)\n (hy : g⁻¹ * x * g ∈ centralizer P) :\n ∃ n ∈ normalizer P, g⁻¹ * x * g = n⁻¹ * x * n := by sorry\ntheorem conj_eq_normalizer_conj_of_mem [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G)\n [_hP : IsMulCommutative P] (x g : G) (hx : x ∈ P) (hy : g⁻¹ * x * g ∈ P) :\n ∃ n ∈ normalizer P, g⁻¹ * x * g = n⁻¹ * x * n :=\n P.conj_eq_normalizer_conj_of_mem_centralizer x g\n (P.le_centralizer hx) (P.le_centralizer hy)\n\n/-- Sylow `p`-subgroups are in bijection with cosets of the normalizer of a Sylow `p`-subgroup -/\nnoncomputable def equivQuotientNormalizer [Fact p.Prime] [Finite (Sylow p G)]\n (P : Sylow p G) : Sylow p G ≃ G ⧸ normalizer P :=\n calc\n Sylow p G ≃ (⊤ : Set (Sylow p G)) := (Equiv.Set.univ (Sylow p G)).symm\n _ ≃ orbit G P := Equiv.setCongr P.orbit_eq_top.symm\n _ ≃ G ⧸ stabilizer G P := orbitEquivQuotientStabilizer G P\n _ ≃ G ⧸ normalizer P := by rw [P.stabilizer_eq_normalizer]\n\ninstance [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) :\n Finite (G ⧸ normalizer P) :=\n Finite.of_equiv (Sylow p G) P.equivQuotientNormalizer\n\ntheorem card_eq_card_quotient_normalizer [Fact p.Prime] [Finite (Sylow p G)]\n (P : Sylow p G) : Nat.card (Sylow p G) = Nat.card (G ⧸ normalizer P) :=\n Nat.card_congr P.equivQuotientNormalizer\n\ntheorem card_eq_index_normalizer [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) :\n Nat.card (Sylow p G) = (normalizer (P : Set G)).index :=\n P.card_eq_card_quotient_normalizer\n\ntheorem card_dvd_index [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) :\n Nat.card (Sylow p G) ∣ P.index :=\n ((congr_arg _ P.card_eq_index_normalizer).mp dvd_rfl).trans\n (index_dvd_of_le le_normalizer)\n\n/-- Auxiliary lemma for `Sylow.not_dvd_index` which is strictly stronger. -/\nprivate theorem not_dvd_index_aux [hp : Fact p.Prime] (P : Sylow p G) [P.Normal]\n [P.FiniteIndex] : ¬ p ∣ P.index := by sorry\ntheorem not_dvd_index' [hp : Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G)\n (hP : P.relIndex (normalizer P) ≠ 0) : ¬ p ∣ P.index := by sorry\ntheorem not_dvd_index [Fact p.Prime] (P : Sylow p G) [P.FiniteIndex] :\n ¬ p ∣ P.index := by sorry\nsection mapSurjective\n\nvariable [Finite G] {G' : Type*} [Group G'] {f : G →* G'} (hf : Function.Surjective f)\n\n/-- Surjective group homomorphisms map Sylow subgroups to Sylow subgroups. -/\ndef mapSurjective [Fact p.Prime] (P : Sylow p G) : Sylow p G' :=\n { P.1.map f with\n isPGroup' := P.2.map f\n is_maximal' := fun hQ hPQ ↦ ((P.2.map f).toSylow\n (fun h ↦ P.not_dvd_index (h.trans (P.index_map_dvd hf)))).3 hQ hPQ }\n\n@[simp] theorem coe_mapSurjective [Fact p.Prime] (P : Sylow p G) : P.mapSurjective hf = P.map f :=\n rfl\n\ntheorem mapSurjective_surjective (p : ℕ) [Fact p.Prime] :\n Function.Surjective (Sylow.mapSurjective hf : Sylow p G → Sylow p G') := by sorry\nend mapSurjective\n\n/-- **Frattini's Argument**: If `N` is a normal subgroup of `G`, and if `P` is a Sylow `p`-subgroup\n of `N`, then `N_G(P) ⊔ N = G`. -/\ntheorem normalizer_sup_eq_top {p : ℕ} [Fact p.Prime] {N : Subgroup G} [N.Normal]\n [Finite (Sylow p N)] (P : Sylow p N) :\n normalizer (P.map N.subtype) ⊔ N = ⊤ := by sorry\ntheorem normalizer_sup_eq_top' {p : ℕ} [Fact p.Prime] {N : Subgroup G} [N.Normal]\n [Finite (Sylow p N)] (P : Sylow p G) (hP : P ≤ N) : normalizer P ⊔ N = ⊤ := by sorry\nend Sylow\n\nend InfiniteSylow\n\nopen Equiv Equiv.Perm Finset Function List QuotientGroup\n\nuniverse u\n\nvariable {G : Type u} [Group G]\n\ntheorem QuotientGroup.card_preimage_mk (s : Subgroup G) (t : Set (G ⧸ s)) :\n Nat.card (QuotientGroup.mk ⁻¹' t) = Nat.card s * Nat.card t := by sorry\nnamespace Sylow\ntheorem mem_fixedPoints_mul_left_cosets_iff_mem_normalizer {H : Subgroup G} [Finite (H : Set G)]\n {x : G} : (x : G ⧸ H) ∈ MulAction.fixedPoints H (G ⧸ H) ↔ x ∈ normalizer H :=\n ⟨fun hx =>\n have ha : ∀ {y : G ⧸ H}, y ∈ orbit H (x : G ⧸ H) → y = x := mem_fixedPoints'.1 hx _\n (inv_mem_iff (G := G)).1\n (mem_normalizer_fintype fun n (hn : n ∈ H) =>\n have : (n⁻¹ * x)⁻¹ * x ∈ H := QuotientGroup.eq.1 (ha ⟨⟨n⁻¹, inv_mem hn⟩, rfl⟩)\n show _ ∈ H by\n rw [mul_inv_rev, inv_inv] at this\n convert this\n rw [inv_inv]),\n fun hx : ∀ n : G, n ∈ H ↔ x * n * x⁻¹ ∈ H =>\n mem_fixedPoints'.2 fun y =>\n Quotient.inductionOn' y fun y hy =>\n QuotientGroup.eq.2\n (let ⟨⟨b, hb₁⟩, hb₂⟩ := hy\n have hb₂ : (b * x)⁻¹ * y ∈ H := QuotientGroup.eq.1 hb₂\n (inv_mem_iff (G := G)).1 <|\n (hx _).2 <|\n (mul_mem_cancel_left (inv_mem hb₁)).1 <| by\n rw [hx] at hb₂; simpa [mul_inv_rev, mul_assoc] using hb₂)⟩\n\n/-- The fixed points of the action of `H` on its cosets correspond to `normalizer H / H`. -/\ndef fixedPointsMulLeftCosetsEquivQuotient (H : Subgroup G) [Finite (H : Set G)] :\n MulAction.fixedPoints H (G ⧸ H) ≃\n normalizer H ⧸ H.comap (normalizer (H : Set G)).subtype :=\n @subtypeQuotientEquivQuotientSubtype G (· ∈ normalizer H) (_) (_)\n (· ∈ MulAction.fixedPoints H (G ⧸ H))\n (fun _ => (@mem_fixedPoints_mul_left_cosets_iff_mem_normalizer _ _ _ ‹_› _).symm)\n (by\n intros\n unfold_projs\n rw [leftRel_apply (α := normalizer (H : Set G)), leftRel_apply]\n rfl)\n\n/-- If `H` is a `p`-subgroup of `G`, then the index of `H` inside its normalizer is congruent\n mod `p` to the index of `H`. -/\ntheorem card_quotient_normalizer_modEq_card_quotient [Finite G] {p : ℕ} {n : ℕ} [hp : Fact p.Prime]\n {H : Subgroup G} (hH : Nat.card H = p ^ n) :\n Nat.card (normalizer H ⧸ H.comap (normalizer (H : Set G)).subtype) ≡\n Nat.card (G ⧸ H) [MOD p] := by sorry\ntheorem card_normalizer_modEq_card [Finite G] {p : ℕ} {n : ℕ} [hp : Fact p.Prime] {H : Subgroup G}\n (hH : Nat.card H = p ^ n) :\n Nat.card (normalizer (H : Set G)) ≡ Nat.card G [MOD p ^ (n + 1)] := by sorry\ntheorem prime_dvd_card_quotient_normalizer [Finite G] {p : ℕ} {n : ℕ} [Fact p.Prime]\n (hdvd : p ^ (n + 1) ∣ Nat.card G) {H : Subgroup G} (hH : Nat.card H = p ^ n) :\n p ∣ Nat.card (normalizer (H : Set G) ⧸ H.comap (normalizer (H : Set G)).subtype) :=\n let ⟨s, hs⟩ := exists_eq_mul_left_of_dvd hdvd\n have hcard : Nat.card (G ⧸ H) = s * p :=\n (mul_left_inj' (show Nat.card H ≠ 0 from Nat.card_pos.ne')).1\n (by\n rw [← card_eq_card_quotient_mul_card_subgroup H, hH, hs, pow_succ', mul_assoc, mul_comm p])\n have hm :\n s * p % p =\n Nat.card (normalizer H ⧸ H.comap (normalizer (H : Set G)).subtype) % p :=\n hcard ▸ (card_quotient_normalizer_modEq_card_quotient hH).symm\n Nat.dvd_of_mod_eq_zero (by rwa [Nat.mod_eq_zero_of_dvd (dvd_mul_left _ _), eq_comm] at hm)\n\n/-- If `H` is a `p`-subgroup but not a Sylow `p`-subgroup of cardinality `p ^ n`,\n then `p ^ (n + 1)` divides the cardinality of the normalizer of `H`. -/\ntheorem prime_pow_dvd_card_normalizer [Finite G] {p : ℕ} {n : ℕ} [_hp : Fact p.Prime]\n (hdvd : p ^ (n + 1) ∣ Nat.card G) {H : Subgroup G} (hH : Nat.card H = p ^ n) :\n p ^ (n + 1) ∣ Nat.card (normalizer (H : Set G)) :=\n Nat.modEq_zero_iff_dvd.1 ((card_normalizer_modEq_card hH).trans hdvd.modEq_zero_nat)\n\n/-- If `H` is a subgroup of `G` of cardinality `p ^ n`,\n then `H` is contained in a subgroup of cardinality `p ^ (n + 1)`\n if `p ^ (n + 1)` divides the cardinality of `G` -/\ntheorem exists_subgroup_card_pow_succ [Finite G] {p : ℕ} {n : ℕ} [hp : Fact p.Prime]\n (hdvd : p ^ (n + 1) ∣ Nat.card G) {H : Subgroup G} (hH : Nat.card H = p ^ n) :\n ∃ K : Subgroup G, Nat.card K = p ^ (n + 1) ∧ H ≤ K :=\n let ⟨s, hs⟩ := exists_eq_mul_left_of_dvd hdvd\n have hcard : Nat.card (G ⧸ H) = s * p :=\n (mul_left_inj' (show Nat.card H ≠ 0 from Nat.card_pos.ne')).1\n (by\n rw [← card_eq_card_quotient_mul_card_subgroup H, hH, hs, pow_succ', mul_assoc, mul_comm p])\n have hm : s * p % p = Nat.card (normalizer H ⧸ H.subgroupOf (normalizer H)) % p :=\n Nat.card_congr (fixedPointsMulLeftCosetsEquivQuotient H) ▸\n hcard ▸ (IsPGroup.of_card hH).card_modEq_card_fixedPoints _\n have hm' : p ∣ Nat.card (normalizer H ⧸ H.subgroupOf (normalizer H)) :=\n Nat.dvd_of_mod_eq_zero (by rwa [Nat.mod_eq_zero_of_dvd (dvd_mul_left _ _), eq_comm] at hm)\n let ⟨x, hx⟩ := @exists_prime_orderOf_dvd_card' _ (QuotientGroup.Quotient.group _) _ _ hp hm'\n have hequiv : H ≃ H.subgroupOf (normalizer H) := (subgroupOfEquivOfLe le_normalizer).symm.toEquiv\n ⟨((zpowers x).comap (mk' (H.subgroupOf (normalizer H)))).map (normalizer H).subtype, by\n show Nat.card (Subgroup.map (normalizer (H : Set G)).subtype\n (comap (mk' (H.subgroupOf (normalizer H))) (Subgroup.zpowers x))) = p ^ (n + 1)\n suffices Nat.card (Subtype.val ''\n ((zpowers x).comap (mk' (H.subgroupOf (normalizer H))) : Set (normalizer H))) = p ^ (n + 1)\n by convert this using 2\n rw [Nat.card_image_of_injective Subtype.val_injective\n ((zpowers x).comap (mk' (H.subgroupOf (normalizer H))) : Set (normalizer (H : Set G))),\n pow_succ, ← hH, Nat.card_congr hequiv, ← hx, ← Nat.card_zpowers, ← Nat.card_prod]\n exact Nat.card_congr\n (preimageMkEquivSubgroupProdSet (H.subgroupOf (normalizer H)) (zpowers x)), by\n intro y hy\n simp only [Subgroup.coe_subtype, mk'_apply, Subgroup.mem_map, Subgroup.mem_comap]\n refine ⟨⟨y, le_normalizer hy⟩, ⟨0, ?_⟩, rfl⟩\n dsimp only\n rw [zpow_zero, eq_comm, QuotientGroup.eq_one_iff]\n simpa using hy⟩\n\n/-- If `H` is a subgroup of `G` of cardinality `p ^ n`,\n then `H` is contained in a subgroup of cardinality `p ^ m`\n if `n ≤ m` and `p ^ m` divides the cardinality of `G` -/\ntheorem exists_subgroup_card_pow_prime_le [Finite G] (p : ℕ) :\n ∀ {n m : ℕ} [_hp : Fact p.Prime] (_hdvd : p ^ m ∣ Nat.card G) (H : Subgroup G)\n (_hH : Nat.card H = p ^ n) (_hnm : n ≤ m), ∃ K : Subgroup G, Nat.card K = p ^ m ∧ H ≤ K := by sorry\ntheorem exists_subgroup_card_pow_prime [Finite G] (p : ℕ) {n : ℕ} [Fact p.Prime]\n (hdvd : p ^ n ∣ Nat.card G) : ∃ K : Subgroup G, Nat.card K = p ^ n :=\n let ⟨K, hK⟩ := exists_subgroup_card_pow_prime_le p hdvd ⊥\n (by rw [card_bot, pow_zero]) n.zero_le\n ⟨K, hK.1⟩\n\n/-- A special case of **Sylow's first theorem**. If `G` is a `p`-group of size at least `p ^ n`\nthen there is a subgroup of cardinality `p ^ n`. -/\nlemma exists_subgroup_card_pow_prime_of_le_card {n p : ℕ} (hp : p.Prime) (h : IsPGroup p G)\n (hn : p ^ n ≤ Nat.card G) : ∃ H : Subgroup G, Nat.card H = p ^ n := by sorry\nlemma exists_subgroup_le_card_pow_prime_of_le_card {n p : ℕ} (hp : p.Prime) (h : IsPGroup p G)\n {H : Subgroup G} (hn : p ^ n ≤ Nat.card H) : ∃ H' ≤ H, Nat.card H' = p ^ n := by sorry\nlemma exists_subgroup_le_card_le {k p : ℕ} (hp : p.Prime) (h : IsPGroup p G) {H : Subgroup G}\n (hk : k ≤ Nat.card H) (hk₀ : k ≠ 0) : ∃ H' ≤ H, Nat.card H' ≤ k ∧ k < p * Nat.card H' := by sorry\ntheorem pow_dvd_card_of_pow_dvd_card [Finite G] {p n : ℕ} [hp : Fact p.Prime] (P : Sylow p G)\n (hdvd : p ^ n ∣ Nat.card G) : p ^ n ∣ Nat.card P := by sorry\ntheorem dvd_card_of_dvd_card [Finite G] {p : ℕ} [Fact p.Prime] (P : Sylow p G)\n (hdvd : p ∣ Nat.card G) : p ∣ Nat.card P := by sorry\ntheorem card_coprime_index [Finite G] {p : ℕ} [hp : Fact p.Prime] (P : Sylow p G) :\n (Nat.card P).Coprime P.index :=\n let ⟨_n, hn⟩ := IsPGroup.iff_card.mp P.2\n hn.symm ▸ (hp.1.coprime_pow_of_not_dvd P.not_dvd_index).symm\n\ntheorem ne_bot_of_dvd_card [Finite G] {p : ℕ} [hp : Fact p.Prime] (P : Sylow p G)\n (hdvd : p ∣ Nat.card G) : (P : Subgroup G) ≠ ⊥ := by sorry\ntheorem card_eq_multiplicity [Finite G] {p : ℕ} [hp : Fact p.Prime] (P : Sylow p G) :\n Nat.card P = p ^ Nat.factorization (Nat.card G) p := by sorry\nnoncomputable def unique_of_normal {p : ℕ} [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G)\n (h : P.Normal) : Unique (Sylow p G) := by sorry\ninstance characteristic_of_subsingleton {p : ℕ} [Subsingleton (Sylow p G)] (P : Sylow p G) :\n P.Characteristic := by sorry\ntheorem normal_of_subsingleton {p : ℕ} [Subsingleton (Sylow p G)] (P : Sylow p G) :\n P.Normal :=\n Subgroup.normal_of_characteristic _\n\ntheorem characteristic_of_normal {p : ℕ} [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G)\n (h : P.Normal) : P.Characteristic := by sorry\ntheorem normal_of_normalizer_normal {p : ℕ} [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G)\n (hn : (normalizer (P : Set G)).Normal) : P.Normal := by sorry\ntheorem normalizer_normalizer {p : ℕ} [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) :\n normalizer (normalizer (P : Set G)) = normalizer (P : Set G) := by sorry\ntheorem normal_of_all_max_subgroups_normal [Finite G]\n (hnc : ∀ H : Subgroup G, IsCoatom H → H.Normal) {p : ℕ} [Fact p.Prime] [Finite (Sylow p G)]\n (P : Sylow p G) : P.Normal :=\n normalizer_eq_top_iff.mp\n (by\n rcases eq_top_or_exists_le_coatom (normalizer (P : Set G))\n with (heq | ⟨K, hK, hNK⟩)\n · exact heq\n · haveI := hnc _ hK\n have hPK : P ≤ K := le_trans le_normalizer hNK\n refine (hK.1 ?_).elim\n rw [← sup_of_le_right hNK, P.normalizer_sup_eq_top' hPK])\n\ntheorem normal_of_normalizerCondition (hnc : NormalizerCondition G) {p : ℕ} [Fact p.Prime]\n [Finite (Sylow p G)] (P : Sylow p G) : P.Normal :=\n normalizer_eq_top_iff.mp <|\n normalizerCondition_iff_only_full_group_self_normalizing.mp hnc _ <| normalizer_normalizer _\n\n/-- If all its Sylow subgroups are normal, then a finite group is isomorphic to the direct product\nof these Sylow subgroups.\n-/\nnoncomputable def directProductOfNormal [Finite G]\n (hn : ∀ {p : ℕ} [Fact p.Prime] (P : Sylow p G), P.Normal) :\n (∀ p : (Nat.card G).primeFactors, ∀ P : Sylow p G, P) ≃* G := by sorry\nend Sylow\n" }, { "theorem_id": 57, "title": "072_sylow_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq div.\nFrom mathcomp Require Import fintype prime bigop finset fingroup morphism.\nFrom mathcomp Require Import automorphism quotient action cyclic gproduct .\nFrom mathcomp Require Import gfunctor commutator pgroup center nilpotent.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nLocal Open Scope group_scope.\n\nSection ModP.\n\nVariable (aT : finGroupType) (sT : finType) (D : {group aT}).\nVariable to : action D sT.\n\nLemma pgroup_fix_mod (p : nat) (G : {group aT}) (S : {set sT}) :\n p.\nProof.\nAdmitted.\n\nEnd ModP.\n\nSection ModularGroupAction.\n\nVariables (aT rT : finGroupType) (D : {group aT}) (R : {group rT}).\nVariables (to : groupAction D R) (p : nat).\nImplicit Types (G H : {group aT}) (M : {group rT}).\n\nLemma nontrivial_gacent_pgroup G M :\n p.\nProof.\nAdmitted.\n\nLemma pcore_sub_astab_irr G M :\n p.\nProof.\nAdmitted.\n\nLemma pcore_faithful_irr_act G M :\n p.\nProof.\nAdmitted.\n\nEnd ModularGroupAction.\n\nSection Sylow.\n\nVariables (p : nat) (gT : finGroupType) (G : {group gT}).\nImplicit Types P Q H K : {group gT}.\n\nTheorem Sylow's_theorem :\n [/\\ forall P, [max P | p.\nProof.\nAdmitted.\n\nLemma max_pgroup_Sylow P : [max P | p.\nProof.\nAdmitted.\n\nLemma Sylow_superset Q :\n Q \\subset G -> p.\nProof.\nAdmitted.\n\nLemma Sylow_exists : {P : {group gT} | p.\nProof.\nAdmitted.\n\nLemma Syl_trans : [transitive G, on 'Syl_p(G) | 'JG].\nProof.\nAdmitted.\n\nLemma Sylow_trans P Q :\n p.\nProof.\nAdmitted.\n\nLemma Sylow_subJ P Q :\n p.\nProof.\nAdmitted.\n\nLemma Sylow_Jsub P Q :\n p.\nProof.\nAdmitted.\n\nLemma card_Syl P : p.\nProof.\nAdmitted.\n\nLemma card_Syl_dvd : #|'Syl_p(G)| %| #|G|.\nProof.\nAdmitted.\n\nLemma card_Syl_mod : prime p -> #|'Syl_p(G)| %% p = 1%N.\nProof.\nAdmitted.\n\nLemma Frattini_arg H P : G <| H -> p.\nProof.\nAdmitted.\n\nEnd Sylow.\n\nSection MoreSylow.\n\nVariables (gT : finGroupType) (p : nat).\nImplicit Types G H P : {group gT}.\n\nLemma Sylow_setI_normal G H P :\n G <| H -> p.\nProof.\nAdmitted.\n\nLemma normal_sylowP G :\n reflect (exists2 P : {group gT}, p.\nProof.\nAdmitted.\n\nLemma trivg_center_pgroup P : p.\nProof.\nAdmitted.\n\nLemma p2group_abelian P : p.\nProof.\nAdmitted.\n\nLemma card_p2group_abelian P : prime p -> #|P| = (p ^ 2)%N -> abelian P.\nProof.\nAdmitted.\n\nLemma Sylow_transversal_gen (T : {set {group gT}}) G :\n (forall P, P \\in T -> P \\subset G) ->\n (forall p, p \\in \\pi(G) -> exists2 P, P \\in T & p.\nProof.\nAdmitted.\n\nLemma Sylow_gen G : <<\\bigcup_(P : {group gT} | Sylow G P) P>> = G.\nProof.\nAdmitted.\n\nEnd MoreSylow.\n\nSection SomeHall.\n\nVariable gT : finGroupType.\nImplicit Types (p : nat) (pi : nat_pred) (G H K P R : {group gT}).\n\nLemma Hall_pJsub p pi G H P :\n pi.\nProof.\nAdmitted.\n\nLemma Hall_psubJ p pi G H P :\n pi.\nProof.\nAdmitted.\n\nLemma Hall_setI_normal pi G K H :\n K <| G -> pi.\nProof.\nAdmitted.\n\nLemma coprime_mulG_setI_norm H G K R :\n K * R = G -> G \\subset 'N(H) -> coprime #|K| #|R| ->\n (K :&: H) * (R :&: H) = G :&: H.\nProof.\nAdmitted.\n\nEnd SomeHall.\n\nSection Nilpotent.\n\nVariable gT : finGroupType.\nImplicit Types (G H K P L : {group gT}) (p q : nat).\n\nLemma pgroup_nil p P : p.\nProof.\nAdmitted.\n\nLemma pgroup_sol p P : p.\nProof.\nAdmitted.\n\nLemma small_nil_class G : nil_class G <= 5 -> nilpotent G.\nProof.\nAdmitted.\n\nLemma nil_class2 G : (nil_class G <= 2) = (G^`(1) \\subset 'Z(G)).\nProof.\nAdmitted.\n\nLemma nil_class3 G : (nil_class G <= 3) = ('L_3(G) \\subset 'Z(G)).\nProof.\nAdmitted.\n\nLemma nilpotent_maxp_normal pi G H :\n nilpotent G -> [max H | pi.\nProof.\nAdmitted.\n\nLemma nilpotent_Hall_pcore pi G H :\n nilpotent G -> pi.\nProof.\nAdmitted.\n\nLemma nilpotent_pcore_Hall pi G : nilpotent G -> pi.\nProof.\nAdmitted.\n\nLemma nilpotent_pcoreC pi G : nilpotent G -> 'O_pi(G) \\x 'O_pi^'(G) = G.\nProof.\nAdmitted.\n\nLemma sub_nilpotent_cent2 H K G :\n nilpotent G -> K \\subset G -> H \\subset G -> coprime #|K| #|H| ->\n H \\subset 'C(K).\nProof.\nAdmitted.\n\nLemma pi_center_nilpotent G : nilpotent G -> \\pi('Z(G)) = \\pi(G).\nProof.\nAdmitted.\n\nLemma Sylow_subnorm p G P : p.\nProof.\nAdmitted.\n\nEnd Nilpotent.\n\nLemma nil_class_pgroup (gT : finGroupType) (p : nat) (P : {group gT}) :\n p.\nProof.\nAdmitted.\n\nDefinition Zgroup (gT : finGroupType) (A : {set gT}) :=\n [forall (V : {group gT} | Sylow A V), cyclic V].\n\nSection Zgroups.\n\nVariables (gT rT : finGroupType) (D : {group gT}) (f : {morphism D >-> rT}).\nImplicit Types G H K : {group gT}.\n\nLemma ZgroupS G H : H \\subset G -> Zgroup G -> Zgroup H.\nProof.\nAdmitted.\n\nLemma morphim_Zgroup G : Zgroup G -> Zgroup (f @* G).\nProof.\nAdmitted.\n\nLemma nil_Zgroup_cyclic G : Zgroup G -> nilpotent G -> cyclic G.\nProof.\nAdmitted.\n\nEnd Zgroups.\n\nArguments Zgroup {gT} A%_g.\n\nSection NilPGroups.\n\nVariables (p : nat) (gT : finGroupType).\nImplicit Type G P N : {group gT}.\n\nLemma normal_pgroup r P N :\n p.\nProof.\nAdmitted.\n\nTheorem Baer_Suzuki x G :\n x \\in G -> (forall y, y \\in G -> p.\nProof.\nAdmitted.\n\nEnd NilPGroups." }, { "theorem_id": 58, "title": "073_ascending_or_descending_sequences__erdős–szekeres", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "let lemma = `!f s. s = UNIONS (IMAGE (\\a. {x | x IN s /\\ f(x) = a}) (IMAGE f s))`;;\n\nlet PIGEONHOLE_LEMMA = `!f:A->B s n.\n FINITE s /\\ (n - 1) * CARD(IMAGE f s) < CARD s\n ==> ?t a. t SUBSET s /\\ t HAS_SIZE n /\\ (!x. x IN t ==> f(x) = a)`;;\n\nlet mono_on = define\n `mono_on (f:num->real) r s <=>\n !i j. i IN s /\\ j IN s /\\ i <= j ==> r (f i) (f j)`;;\n\nlet MONO_ON_SUBSET = `!s t. t SUBSET s /\\ mono_on f r s ==> mono_on f r t`;;\n\nlet ERDOS_SZEKERES = `!f:num->real m n.\n (?s. s SUBSET (1..m*n+1) /\\ s HAS_SIZE (m + 1) /\\ mono_on f (<=) s) \\/\n (?s. s SUBSET (1..m*n+1) /\\ s HAS_SIZE (n + 1) /\\ mono_on f (>=) s)`;;" }, { "theorem_id": 58, "title": "073_ascending_or_descending_sequences__erdős–szekeres", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Sequence of Properties on Subsequences\\\n\ntheory Diagonal_Subsequence\nimports Complex_Main\nbegin\n\nlocale subseqs =\n fixes P::\"nat\\(nat\\nat)\\bool\"\n assumes ex_subseq: \"\\n s. strict_mono (s::nat\\nat) \\ \\r'. strict_mono r' \\ P n (s \\ r')\"\nbegin\n\ndefinition reduce where \"reduce s n = (SOME r'::nat\\nat. strict_mono r' \\ P n (s \\ r'))\"\n\nlemma subseq_reduce[intro, simp]:\n \"strict_mono s \\ strict_mono (reduce s n)\"\n by sorry\n\nlemma reduce_holds:\n \"strict_mono s \\ P n (s \\ reduce s n)\"\n by sorry\n\nprimrec seqseq :: \"nat \\ nat \\ nat\" where\n \"seqseq 0 = id\"\n| \"seqseq (Suc n) = seqseq n \\ reduce (seqseq n) n\"\n\nlemma subseq_seqseq[intro, simp]: \"strict_mono (seqseq n)\"\n by sorry\n\nlemma seqseq_holds:\n \"P n (seqseq (Suc n))\"\n by sorry\n\ndefinition diagseq :: \"nat \\ nat\" where \"diagseq i = seqseq i i\"\n\nlemma diagseq_mono: \"diagseq n < diagseq (Suc n)\"\n by sorry\n\nlemma subseq_diagseq: \"strict_mono diagseq\"\n by sorry\n\nprimrec fold_reduce where\n \"fold_reduce n 0 = id\"\n| \"fold_reduce n (Suc k) = fold_reduce n k \\ reduce (seqseq (n + k)) (n + k)\"\n\nlemma subseq_fold_reduce[intro, simp]: \"strict_mono (fold_reduce n k)\"\n by sorry\n\nlemma ex_subseq_reduce_index: \"seqseq (n + k) = seqseq n \\ fold_reduce n k\"\n by sorry\n\nlemma seqseq_fold_reduce: \"seqseq n = fold_reduce 0 n\"\n by sorry\n\nlemma diagseq_fold_reduce: \"diagseq n = fold_reduce 0 n n\"\n by sorry\n\nlemma fold_reduce_add: \"fold_reduce 0 (m + n) = fold_reduce 0 m \\ fold_reduce m n\"\n by sorry\n\nlemma diagseq_add: \"diagseq (k + n) = (seqseq k \\ (fold_reduce k n)) (k + n)\"\n by sorry\n\nlemma diagseq_sub:\n assumes \"m \\ n\" shows \"diagseq n = (seqseq m \\ (fold_reduce m (n - m))) n\"\n by sorry\n\nlemma subseq_diagonal_rest: \"strict_mono (\\x. fold_reduce k x (k + x))\"\n by sorry\n\nlemma diagseq_seqseq: \"diagseq \\ ((+) k) = (seqseq k \\ (\\x. fold_reduce k x (k + x)))\"\n by sorry\n\nlemma diagseq_holds:\n assumes subseq_stable: \"\\r s n. strict_mono r \\ P n s \\ P n (s \\ r)\"\n shows \"P k (diagseq \\ ((+) (Suc k)))\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 58, "title": "073_ascending_or_descending_sequences__erdős–szekeres", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport Mathlib.Algebra.Order.Group.Nat\nimport Mathlib.Data.Finset.Max\nimport Mathlib.Data.Fintype.Powerset\nimport Mathlib.Data.Set.Monotone\nimport Mathlib.Order.Interval.Finset.Nat\n\n/-!\n# Erdős–Szekeres theorem\n\nThis file proves Theorem 73 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/), also\nknown as the Erdős–Szekeres theorem: given a sequence of more than `r * s` distinct\nvalues, there is an increasing sequence of length longer than `r` or a decreasing sequence of length\nlonger than `s`.\n\nWe use the proof outlined at\nhttps://en.wikipedia.org/wiki/Erdos-Szekeres_theorem#Pigeonhole_principle.\n\n## Tags\n\nsequences, increasing, decreasing, Ramsey, Erdos-Szekeres, Erdős–Szekeres, Erdős-Szekeres\n-/\n\nopen Function Finset\n\nnamespace Theorems100\n\nvariable {α β : Type*} [Fintype α] [LinearOrder α] [LinearOrder β] {f : α → β} {i : α}\n\n/-- The possible lengths of an increasing sequence which ends at `i`. -/\nprivate noncomputable def incSequencesTo (f : α → β) (i : α) : Finset ℕ :=\n open Classical in\n image card {t : Finset α | IsGreatest t i ∧ StrictMonoOn f t}\n\n/-- The possible lengths of a decreasing sequence which ends at `i`. -/\nprivate noncomputable def decSequencesTo (f : α → β) (i : α) : Finset ℕ :=\n open Classical in\n image card {t : Finset α | IsGreatest t i ∧ StrictAntiOn f t}\n\n/-- The singleton sequence is increasing, so 1 is a possible length. -/\nprivate lemma one_mem_incSequencesTo : 1 ∈ incSequencesTo f i := mem_image.2 ⟨{i}, by simp⟩\n/-- The singleton sequence is decreasing, so 1 is a possible length. -/\nprivate lemma one_mem_decSequencesTo : 1 ∈ decSequencesTo f i := one_mem_incSequencesTo (β := βᵒᵈ)\n\n/-- The singleton sequence is increasing, so the set of lengths is nonempty. -/\nprivate lemma incSequencesTo_nonempty : (incSequencesTo f i).Nonempty := ⟨1, one_mem_incSequencesTo⟩\n/-- The singleton sequence is decreasing, so the set of lengths is nonempty. -/\nprivate lemma decSequencesTo_nonempty : (decSequencesTo f i).Nonempty := ⟨1, one_mem_decSequencesTo⟩\n\n/-- The maximum length of an increasing sequence which ends at `i`. -/\nprivate noncomputable def maxIncSequencesTo (f : α → β) (i : α) : ℕ :=\n max' (incSequencesTo f i) incSequencesTo_nonempty\n\n/-- The maximum length of a decreasing sequence which ends at `i`. -/\nprivate noncomputable def maxDecSequencesTo (f : α → β) (i : α) : ℕ :=\n max' (decSequencesTo f i) decSequencesTo_nonempty\n\nprivate lemma one_le_maxIncSequencesTo : 1 ≤ maxIncSequencesTo f i :=\n le_max' _ _ one_mem_incSequencesTo\nprivate lemma one_le_maxDecSequencesTo : 1 ≤ maxDecSequencesTo f i :=\n le_max' _ _ one_mem_decSequencesTo\n\nprivate lemma maxIncSequencesTo_mem : maxIncSequencesTo f i ∈ incSequencesTo f i :=\n max'_mem _ incSequencesTo_nonempty\nprivate lemma maxDecSequencesTo_mem : maxDecSequencesTo f i ∈ decSequencesTo f i :=\n max'_mem _ decSequencesTo_nonempty\n\n/--\nWe will want to show that if `i ≠ j`, then the pairs\n`(maxIncSequencesTo f i, maxDecSequencesTo f i)` and\n`(maxIncSequencesTo f j, maxDecSequencesTo f j)` are different.\nTo this end, we will assume wlog that `i < j`, and show that if `f i < f j`,\nthen `maxIncSequencesTo f i < maxIncSequencesTo f j`, and later dualise to prove that if `f j < f i`\nthen `maxDecSequencesTo f i < maxDecSequencesTo f j`.\n-/\nprivate lemma maxIncSequencesTo_lt {i j : α} (hij : i < j) (hfij : f i < f j) :\n maxIncSequencesTo f i < maxIncSequencesTo f j := by sorry\ntheorem erdos_szekeres {r s : ℕ} {f : α → β} (hn : r * s < Fintype.card α) (hf : Injective f) :\n (∃ t : Finset α, r < #t ∧ StrictMonoOn f t) ∨\n ∃ t : Finset α, s < #t ∧ StrictAntiOn f t := by sorry\nend Theorems100\n" }, { "theorem_id": 58, "title": "073_ascending_or_descending_sequences__erdős–szekeres", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import mathcomp.ssreflect.ssreflect.\nFrom mathcomp Require Import ssrfun ssrbool eqtype ssrnat seq fintype.\nFrom mathcomp Require Import tuple finfun finset bigop path order.\n\nRequire Import partition tableau Schensted ordtype Greene Greene_inv.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nImport Order.TTheory.\nOpen Scope N.\n\nSection OrderedType.\n\nVariables (disp : unit) (T : inhOrderType disp).\n\nLemma Greene_rel_one (s : seq T) (R : rel T) :\n exists t : seq T, subseq t s /\\ sorted R t /\\ size t = (Greene_rel R s) 1.\nProof.\nAdmitted.\n\nTheorem Erdos_Szekeres (m n : nat) (s : seq T) :\n size s > m * n ->\n (exists t, subseq t s /\\ sorted <=%O t /\\ size t > m) \\/\n (exists t, subseq t s /\\ sorted >%O t /\\ size t > n).\nProof.\nAdmitted.\n\nEnd OrderedType." }, { "theorem_id": 59, "title": "075_the_mean_value_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "let dest_neg_imp tm =\n try dest_imp tm with Failure _ ->\n try (dest_neg tm,mk_const(\"F\",[]))\n with Failure _ -> failwith \"dest_neg_imp\";;\n\nlet (CONV_OF_RCONV: conv -> conv) =\n let rec get_bv tm =\n if is_abs tm then bndvar tm\n else if is_comb tm then try get_bv (rand tm)\n with Failure _ -> get_bv (rator tm)\n else failwith \"\" in\n fun conv tm ->\n let v = get_bv tm in\n let th1 = conv tm in\n let th2 = ONCE_DEPTH_CONV (GEN_ALPHA_CONV v) (rhs(concl th1)) in\n TRANS th1 th2;;\n\nlet (CONV_OF_THM: thm -> conv) =\n CONV_OF_RCONV o REWR_CONV;;\n\nlet (X_FUN_EQ_CONV:term->conv) =\n fun v -> (REWR_CONV FUN_EQ_THM) THENC GEN_ALPHA_CONV v;;\n\nlet (FUN_EQ_CONV:conv) =\n fun tm ->\n let vars = frees tm in\n let op,[ty1;ty2] = dest_type(type_of (lhs tm)) in\n if op = \"fun\"\n then let varnm =\n if (is_vartype ty1) then \"x\" else\n hd(explode(fst(dest_type ty1))) in\n let x = variant vars (mk_var(varnm,ty1)) in\n X_FUN_EQ_CONV x tm\n else failwith \"FUN_EQ_CONV\";;\n\nlet (SINGLE_DEPTH_CONV:conv->conv) =\n let rec SINGLE_DEPTH_CONV conv tm =\n try conv tm with Failure _ ->\n (SUB_CONV (SINGLE_DEPTH_CONV conv) THENC (TRY_CONV conv)) tm in\n SINGLE_DEPTH_CONV;;\n\nlet (OLD_SKOLEM_CONV:conv) =\n SINGLE_DEPTH_CONV (REWR_CONV SKOLEM_THM);;\n\nlet (X_SKOLEM_CONV:term->conv) =\n fun v -> OLD_SKOLEM_CONV THENC GEN_ALPHA_CONV v;;\n\nlet EXISTS_UNIQUE_CONV tm =\n let v = bndvar(rand tm) in\n let th1 = REWR_CONV EXISTS_UNIQUE_THM tm in\n let tm1 = rhs(concl th1) in\n let vars = frees tm1 in\n let v = variant vars v in\n let v' = variant (v::vars) v in\n let th2 =\n (LAND_CONV(GEN_ALPHA_CONV v) THENC\n RAND_CONV(BINDER_CONV(GEN_ALPHA_CONV v') THENC\n GEN_ALPHA_CONV v)) tm1 in\n TRANS th1 th2;;\n\nlet NOT_FORALL_CONV = CONV_OF_THM NOT_FORALL_THM;;\n\nlet NOT_EXISTS_CONV = CONV_OF_THM NOT_EXISTS_THM;;\n\nlet RIGHT_IMP_EXISTS_CONV = CONV_OF_THM RIGHT_IMP_EXISTS_THM;;\n\nlet FORALL_IMP_CONV = CONV_OF_RCONV\n (REWR_CONV TRIV_FORALL_IMP_THM ORELSEC\n REWR_CONV RIGHT_FORALL_IMP_THM ORELSEC\n REWR_CONV LEFT_FORALL_IMP_THM);;\n\nlet EXISTS_AND_CONV = CONV_OF_RCONV\n (REWR_CONV TRIV_EXISTS_AND_THM ORELSEC\n REWR_CONV LEFT_EXISTS_AND_THM ORELSEC\n REWR_CONV RIGHT_EXISTS_AND_THM);;\n\nlet LEFT_IMP_EXISTS_CONV = CONV_OF_THM LEFT_IMP_EXISTS_THM;;\n\nlet LEFT_AND_EXISTS_CONV tm =\n let v = bndvar(rand(rand(rator tm))) in\n (REWR_CONV LEFT_AND_EXISTS_THM THENC TRY_CONV (GEN_ALPHA_CONV v)) tm;;\n\nlet RIGHT_AND_EXISTS_CONV =\n CONV_OF_THM RIGHT_AND_EXISTS_THM;;\n\nlet AND_FORALL_CONV = CONV_OF_THM AND_FORALL_THM;;\n\nlet F_IMP = TAUT `!t. ~t ==> t ==> F`;;\n\nlet LEFT_AND_OVER_OR = TAUT\n `!t1 t2 t3. t1 /\\ (t2 \\/ t3) <=> t1 /\\ t2 \\/ t1 /\\ t3`;;\n\nlet RIGHT_AND_OVER_OR = TAUT\n `!t1 t2 t3. (t2 \\/ t3) /\\ t1 <=> t2 /\\ t1 \\/ t3 /\\ t1`;;\n\nlet INST_TY_TERM(substl,insttyl) th = INST substl (INST_TYPE insttyl th);;\n\nlet NOT_MP thi th =\n try MP thi th with Failure _ ->\n try let t = dest_neg (concl thi) in\n MP(MP (SPEC t F_IMP) thi) th\n with Failure _ -> failwith \"NOT_MP\";;\n\nlet MK_ABS qth =\n try let ov = bndvar(rand(concl qth)) in\n let bv,rth = SPEC_VAR qth in\n let sth = ABS bv rth in\n let cnv = ALPHA_CONV ov in\n CONV_RULE(BINOP_CONV cnv) sth\n with Failure _ -> failwith \"MK_ABS\";;\n\nlet HALF_MK_ABS th =\n try let th1 = MK_ABS th in\n CONV_RULE(LAND_CONV ETA_CONV) th1\n with Failure _ -> failwith \"HALF_MK_ABS\";;\n\nlet SUBST thl pat th =\n let eqs,vs = unzip thl in\n let gvs = map (genvar o type_of) vs in\n let gpat = subst (zip gvs vs) pat in\n let ls,rs = unzip (map (dest_eq o concl) eqs) in\n let ths = map (ASSUME o mk_eq) (zip gvs rs) in\n let th1 = ASSUME gpat in\n let th2 = SUBS ths th1 in\n let th3 = itlist DISCH (map concl ths) (DISCH gpat th2) in\n let th4 = INST (zip ls gvs) th3 in\n MP (rev_itlist (C MP) eqs th4) th;;\n\nprioritize_num();;\n\nlet LESS_EQUAL_ANTISYM = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL LE_ANTISYM)));;\nlet NOT_LESS_0 = GEN_ALL(EQF_ELIM(SPEC_ALL(CONJUNCT1 LT)));;\nlet LESS_LEMMA1 = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL(CONJUNCT2 LT))));;\nlet LESS_SUC_REFL = ARITH_RULE `!n. n < SUC n`;;\nlet LESS_EQ_SUC_REFL = ARITH_RULE `!n. n <= SUC n`;;\nlet LESS_EQUAL_ADD = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL LE_EXISTS)));;\nlet LESS_EQ_IMP_LESS_SUC = GEN_ALL(snd(EQ_IMP_RULE(SPEC_ALL LT_SUC_LE)));;\nlet LESS_MONO_ADD = GEN_ALL(snd(EQ_IMP_RULE(SPEC_ALL LT_ADD_RCANCEL)));;\nlet LESS_SUC = ARITH_RULE `!m n. m < n ==> m < (SUC n)`;;\nlet LESS_ADD_1 = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL\n (REWRITE_RULE[ADD1] LT_EXISTS))));;\nlet SUC_SUB1 = ARITH_RULE `!m. SUC m - 1 = m`;;\nlet LESS_ADD_SUC = ARITH_RULE `!m n. m < m + SUC n`;;\nlet OR_LESS = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL LE_SUC_LT)));;\nlet NOT_SUC_LESS_EQ = ARITH_RULE `!n m. ~(SUC n <= m) <=> m <= n`;;\nlet LESS_LESS_CASES = ARITH_RULE `!m n. (m = n) \\/ m < n \\/ n < m`;;\nlet SUB_SUB = `!b c. c <= b ==> (!a. a - (b - c) = (a + c) - b)`;;\nlet LESS_CASES_IMP = ARITH_RULE `!m n. ~(m < n) /\\ ~(m = n) ==> n < m`;;\nlet SUB_LESS_EQ = ARITH_RULE `!n m. (n - m) <= n`;;\nlet SUB_EQ_EQ_0 = ARITH_RULE `!m n. (m - n = m) <=> (m = 0) \\/ (n = 0)`;;\nlet SUB_LEFT_LESS_EQ =\n ARITH_RULE `!m n p. m <= (n - p) <=> (m + p) <= n \\/ m <= 0`;;\nlet SUB_LEFT_GREATER_EQ = ARITH_RULE `!m n p. m >= (n - p) <=> (m + p) >= n`;;\nlet LESS_0_CASES = ARITH_RULE `!m. (0 = m) \\/ 0 < m`;;\nlet LESS_OR = ARITH_RULE `!m n. m < n ==> (SUC m) <= n`;;\nlet SUB_OLD = `(!m. 0 - m = 0) /\\\n (!m n. (SUC m) - n = (if m < n then 0 else SUC(m - n)))`;;\n\nlet SYM_CANON_CONV sym fn =\n REWR_CONV sym o\n check (not o fn o ((snd o dest_comb) F_F I) o dest_comb);;\n\nlet (IMP_SUBST_TAC:thm_tactic) =\n fun th (asl,w) ->\n let tms = find_terms (can (PART_MATCH (lhs o snd o dest_imp) th)) w in\n let tm1 = hd (sort free_in tms) in\n let th1 = PART_MATCH (lhs o snd o dest_imp) th tm1 in\n let (a,(l,r)) = (I F_F dest_eq) (dest_imp (concl th1)) in\n let gv = genvar (type_of l) in\n let pat = subst[gv,l] w in\n null_meta,\n [(asl,a); (asl,subst[(r,gv)] pat)],\n fun i [t1;t2] -> SUBST[(SYM(MP th1 t1),gv)] pat t2;;\n\nlet EXT_CONV = SYM o uncurry X_FUN_EQ_CONV o\n (I F_F (mk_eq o (rator F_F rator) o dest_eq)) o dest_forall;;\n\nlet EQUAL_TAC = REPEAT(FIRST [AP_TERM_TAC; AP_THM_TAC; ABS_TAC]);;\n\nlet X_BETA_CONV v tm =\n SYM(BETA_CONV(mk_comb(mk_abs(v,tm),v)));;\n\nlet EXACT_CONV =\n ONCE_DEPTH_CONV o FIRST_CONV o\n map (fun t -> K t o check((=)(lhs(concl t))));;\n\nlet HABS_CONV tm =\n let v,bod = dest_abs tm in\n let hop,pl = strip_comb bod in\n let eql = rev(map (X_BETA_CONV v) pl) in\n ABS v (itlist (C(curry MK_COMB)) eql (REFL hop));;\n\nlet EXPAND_TAC s = FIRST_ASSUM(SUBST1_TAC o SYM o\n check((=) s o fst o dest_var o rhs o concl)) THEN BETA_TAC;;\n\nprioritize_real();;\n\nlet real_le = `!x y. x <= y <=> ~(y < x)`;;\n\nlet REAL_10 = REAL_ARITH `~(&1 = &0)`;;\n\nlet REAL_LDISTRIB = REAL_ADD_LDISTRIB;;\n\nlet REAL_LT_IADD = REAL_ARITH `!x y z. y < z ==> x + y < x + z`;;\n\nlet REAL_MUL_RID = `!x. x * &1 = x`;;\n\nlet REAL_MUL_RINV = `!x. ~(x = &0) ==> (x * (inv x) = &1)`;;\n\nlet REAL_RDISTRIB = `!x y z. (x + y) * z = (x * z) + (y * z)`;;\n\nlet REAL_EQ_LADD = `!x y z. (x + y = x + z) <=> (y = z)`;;\n\nlet REAL_EQ_RADD = `!x y z. (x + z = y + z) <=> (x = y)`;;\n\nlet REAL_ADD_LID_UNIQ = `!x y. (x + y = y) <=> (x = &0)`;;\n\nlet REAL_ADD_RID_UNIQ = `!x y. (x + y = x) <=> (y = &0)`;;\n\nlet REAL_LNEG_UNIQ = `!x y. (x + y = &0) <=> (x = --y)`;;\n\nlet REAL_RNEG_UNIQ = `!x y. (x + y = &0) <=> (y = --x)`;;\n\nlet REAL_NEG_ADD = `!x y. --(x + y) = (--x) + (--y)`;;\n\nlet REAL_MUL_LZERO = `!x. &0 * x = &0`;;\n\nlet REAL_MUL_RZERO = `!x. x * &0 = &0`;;\n\nlet REAL_NEG_LMUL = `!x y. --(x * y) = (--x) * y`;;\n\nlet REAL_NEG_RMUL = `!x y. --(x * y) = x * (--y)`;;\n\nlet REAL_NEG_NEG = `!x. --(--x) = x`;;\n\nlet REAL_NEG_MUL2 = `!x y. (--x) * (--y) = x * y`;;\n\nlet REAL_LT_LADD = `!x y z. (x + y) < (x + z) <=> y < z`;;\n\nlet REAL_LT_RADD = `!x y z. (x + z) < (y + z) <=> x < y`;;\n\nlet REAL_NOT_LT = `!x y. ~(x < y) <=> y <= x`;;\n\nlet REAL_LT_ANTISYM = `!x y. ~(x < y /\\ y < x)`;;\n\nlet REAL_LT_GT = `!x y. x < y ==> ~(y < x)`;;\n\nlet REAL_NOT_LE = `!x y. ~(x <= y) <=> y < x`;;\n\nlet REAL_LE_TOTAL = `!x y. x <= y \\/ y <= x`;;\n\nlet REAL_LE_REFL = `!x. x <= x`;;\n\nlet REAL_LE_LT = `!x y. x <= y <=> x < y \\/ (x = y)`;;\n\nlet REAL_LT_LE = `!x y. x < y <=> x <= y /\\ ~(x = y)`;;\n\nlet REAL_LT_IMP_LE = `!x y. x < y ==> x <= y`;;\n\nlet REAL_LTE_TRANS = `!x y z. x < y /\\ y <= z ==> x < z`;;\n\nlet REAL_LE_TRANS = `!x y z. x <= y /\\ y <= z ==> x <= z`;;\n\nlet REAL_NEG_LT0 = `!x. (--x) < &0 <=> &0 < x`;;\n\nlet REAL_NEG_GT0 = `!x. &0 < (--x) <=> x < &0`;;\n\nlet REAL_NEG_LE0 = `!x. (--x) <= &0 <=> &0 <= x`;;\n\nlet REAL_NEG_GE0 = `!x. &0 <= (--x) <=> x <= &0`;;\n\nlet REAL_LT_NEGTOTAL = `!x. (x = &0) \\/ (&0 < x) \\/ (&0 < --x)`;;\n\nlet REAL_LE_NEGTOTAL = `!x. &0 <= x \\/ &0 <= --x`;;\n\nlet REAL_LE_MUL = `!x y. &0 <= x /\\ &0 <= y ==> &0 <= (x * y)`;;\n\nlet REAL_LE_SQUARE = `!x. &0 <= x * x`;;\n\nlet REAL_LT_01 = `&0 < &1`;;\n\nlet REAL_LE_LADD = `!x y z. (x + y) <= (x + z) <=> y <= z`;;\n\nlet REAL_LE_RADD = `!x y z. (x + z) <= (y + z) <=> x <= y`;;\n\nlet REAL_LT_ADD2 = `!w x y z. w < x /\\ y < z ==> (w + y) < (x + z)`;;\n\nlet REAL_LT_ADD = `!x y. &0 < x /\\ &0 < y ==> &0 < (x + y)`;;\n\nlet REAL_LT_ADDNEG = `!x y z. y < (x + (--z)) <=> (y + z) < x`;;\n\nlet REAL_LT_ADDNEG2 = `!x y z. (x + (--y)) < z <=> x < (z + y)`;;\n\nlet REAL_LT_ADD1 = `!x y. x <= y ==> x < (y + &1)`;;\n\nlet REAL_SUB_ADD = `!x y. (x - y) + y = x`;;\n\nlet REAL_SUB_ADD2 = `!x y. y + (x - y) = x`;;\n\nlet REAL_SUB_REFL = `!x. x - x = &0`;;\n\nlet REAL_SUB_0 = `!x y. (x - y = &0) <=> (x = y)`;;\n\nlet REAL_LE_DOUBLE = `!x. &0 <= x + x <=> &0 <= x`;;\n\nlet REAL_LE_NEGL = `!x. (--x <= x) <=> (&0 <= x)`;;\n\nlet REAL_LE_NEGR = `!x. (x <= --x) <=> (x <= &0)`;;\n\nlet REAL_NEG_EQ0 = `!x. (--x = &0) <=> (x = &0)`;;\n\nlet REAL_NEG_0 = `--(&0) = &0`;;\n\nlet REAL_NEG_SUB = `!x y. --(x - y) = y - x`;;\n\nlet REAL_SUB_LT = `!x y. &0 < x - y <=> y < x`;;\n\nlet REAL_SUB_LE = `!x y. &0 <= (x - y) <=> y <= x`;;\n\nlet REAL_EQ_LMUL = `!x y z. (x * y = x * z) <=> (x = &0) \\/ (y = z)`;;\n\nlet REAL_EQ_RMUL = `!x y z. (x * z = y * z) <=> (z = &0) \\/ (x = y)`;;\n\nlet REAL_SUB_LDISTRIB = `!x y z. x * (y - z) = (x * y) - (x * z)`;;\n\nlet REAL_SUB_RDISTRIB = `!x y z. (x - y) * z = (x * z) - (y * z)`;;\n\nlet REAL_NEG_EQ = `!x y. (--x = y) <=> (x = --y)`;;\n\nlet REAL_NEG_MINUS1 = `!x. --x = (--(&1)) * x`;;\n\nlet REAL_INV_NZ = `!x. ~(x = &0) ==> ~(inv x = &0)`;;\n\nlet REAL_INVINV = `!x. ~(x = &0) ==> (inv (inv x) = x)`;;\n\nlet REAL_LT_IMP_NE = `!x y. x < y ==> ~(x = y)`;;\n\nlet REAL_INV_POS = `!x. &0 < x ==> &0 < inv x`;;\n\nlet REAL_LT_LMUL_0 = `!x y. &0 < x ==> (&0 < (x * y) <=> &0 < y)`;;\n\nlet REAL_LT_RMUL_0 = `!x y. &0 < y ==> (&0 < (x * y) <=> &0 < x)`;;\n\nlet REAL_LT_LMUL_EQ = `!x y z. &0 < x ==> ((x * y) < (x * z) <=> y < z)`;;\n\nlet REAL_LT_RMUL_EQ = `!x y z. &0 < z ==> ((x * z) < (y * z) <=> x < y)`;;\n\nlet REAL_LT_RMUL_IMP = `!x y z. x < y /\\ &0 < z ==> (x * z) < (y * z)`;;\n\nlet REAL_LT_LMUL_IMP = `!x y z. y < z /\\ &0 < x ==> (x * y) < (x * z)`;;\n\nlet REAL_LINV_UNIQ = `!x y. (x * y = &1) ==> (x = inv y)`;;\n\nlet REAL_RINV_UNIQ = `!x y. (x * y = &1) ==> (y = inv x)`;;\n\nlet REAL_NEG_INV = `!x. ~(x = &0) ==> (--(inv x) = inv(--x))`;;\n\nlet REAL_INV_1OVER = `!x. inv x = &1 / x`;;\n\nlet REAL = `!n. &(SUC n) = &n + &1`;;\n\nlet REAL_POS = `!n. &0 <= &n`;;\n\nlet REAL_LE = `!m n. &m <= &n <=> m <= n`;;\n\nlet REAL_LT = `!m n. &m < &n <=> m < n`;;\n\nlet REAL_INJ = `!m n. (&m = &n) <=> (m = n)`;;\n\nlet REAL_ADD = `!m n. &m + &n = &(m + n)`;;\n\nlet REAL_MUL = `!m n. &m * &n = &(m * n)`;;\n\nlet REAL_INV1 = `inv(&1) = &1`;;\n\nlet REAL_DIV_LZERO = `!x. &0 / x = &0`;;\n\nlet REAL_LT_NZ = `!n. ~(&n = &0) <=> (&0 < &n)`;;\n\nlet REAL_NZ_IMP_LT = `!n. ~(n = 0) ==> &0 < &n`;;\n\nlet REAL_LT_RDIV_0 = `!y z. &0 < z ==> (&0 < (y / z) <=> &0 < y)`;;\n\nlet REAL_LT_RDIV = `!x y z. &0 < z ==> ((x / z) < (y / z) <=> x < y)`;;\n\nlet REAL_LT_FRACTION_0 = `!n d. ~(n = 0) ==> (&0 < (d / &n) <=> &0 < d)`;;\n\nlet REAL_LT_MULTIPLE = `!n d. 1 < n ==> (d < (&n * d) <=> &0 < d)`;;\n\nlet REAL_LT_FRACTION = `!n d. (1 < n) ==> ((d / &n) < d <=> &0 < d)`;;\n\nlet REAL_LT_HALF1 = `!d. &0 < (d / &2) <=> &0 < d`;;\n\nlet REAL_LT_HALF2 = `!d. (d / &2) < d <=> &0 < d`;;\n\nlet REAL_DOUBLE = `!x. x + x = &2 * x`;;\n\nlet REAL_HALF_DOUBLE = `!x. (x / &2) + (x / &2) = x`;;\n\nlet REAL_SUB_SUB = `!x y. (x - y) - x = --y`;;\n\nlet REAL_LT_ADD_SUB = `!x y z. (x + y) < z <=> x < (z - y)`;;\n\nlet REAL_LT_SUB_RADD = `!x y z. (x - y) < z <=> x < z + y`;;\n\nlet REAL_LT_SUB_LADD = `!x y z. x < (y - z) <=> (x + z) < y`;;\n\nlet REAL_LE_SUB_LADD = `!x y z. x <= (y - z) <=> (x + z) <= y`;;\n\nlet REAL_LE_SUB_RADD = `!x y z. (x - y) <= z <=> x <= z + y`;;\n\nlet REAL_LT_NEG2 = `!x y. --x < --y <=> y < x`;;\n\nlet REAL_LE_NEG2 = `!x y. --x <= --y <=> y <= x`;;\n\nlet REAL_SUB_LZERO = `!x. &0 - x = --x`;;\n\nlet REAL_SUB_RZERO = `!x. x - &0 = x`;;\n\nlet REAL_LTE_ADD2 = `!w x y z. w < x /\\ y <= z ==> (w + y) < (x + z)`;;\n\nlet REAL_LTE_ADD = `!x y. &0 < x /\\ &0 <= y ==> &0 < (x + y)`;;\n\nlet REAL_LT_MUL2_ALT = `!x1 x2 y1 y2. &0 <= x1 /\\ &0 <= y1 /\\ x1 < x2 /\\ y1 < y2 ==>\n (x1 * y1) < (x2 * y2)`;;\n\nlet REAL_SUB_LNEG = `!x y. (--x) - y = --(x + y)`;;\n\nlet REAL_SUB_RNEG = `!x y. x - (--y) = x + y`;;\n\nlet REAL_SUB_NEG2 = `!x y. (--x) - (--y) = y - x`;;\n\nlet REAL_SUB_TRIANGLE = `!a b c. (a - b) + (b - c) = a - c`;;\n\nlet REAL_INV_MUL_WEAK = `!x y. ~(x = &0) /\\ ~(y = &0) ==>\n (inv(x * y) = inv(x) * inv(y))`;;\n\nlet REAL_LE_LMUL_LOCAL = `!x y z. &0 < x ==> ((x * y) <= (x * z) <=> y <= z)`;;\n\nlet REAL_LE_RMUL_EQ = `!x y z. &0 < z ==> ((x * z) <= (y * z) <=> x <= y)`;;\n\nlet REAL_SUB_INV2 = `!x y. ~(x = &0) /\\ ~(y = &0) ==>\n (inv(x) - inv(y) = (y - x) / (x * y))`;;\n\nlet REAL_SUB_SUB2 = `!x y. x - (x - y) = y`;;\n\nlet REAL_MEAN = `!x y. x < y ==> ?z. x < z /\\ z < y`;;\n\nlet REAL_EQ_LMUL2 = `!x y z. ~(x = &0) ==> ((y = z) <=> (x * y = x * z))`;;\n\nlet REAL_LE_MUL2V = `!x1 x2 y1 y2.\n (& 0) <= x1 /\\ (& 0) <= y1 /\\ x1 <= x2 /\\ y1 <= y2 ==>\n (x1 * y1) <= (x2 * y2)`;;\n\nlet REAL_LE_LDIV = `!x y z. &0 < x /\\ y <= (z * x) ==> (y / x) <= z`;;\n\nlet REAL_LE_RDIV = `!x y z. &0 < x /\\ (y * x) <= z ==> y <= (z / x)`;;\n\nlet REAL_LT_1 = `!x y. &0 <= x /\\ x < y ==> (x / y) < &1`;;\n\nlet REAL_LE_LMUL_IMP = `!x y z. &0 <= x /\\ y <= z ==> (x * y) <= (x * z)`;;\n\nlet REAL_LE_RMUL_IMP = `!x y z. &0 <= x /\\ y <= z ==> (y * x) <= (z * x)`;;\n\nlet REAL_INV_LT1 = `!x. &0 < x /\\ x < &1 ==> &1 < inv(x)`;;\n\nlet REAL_LT_IMP_NZ = `!x. &0 < x ==> ~(x = &0)`;;\n\nlet REAL_EQ_RMUL_IMP = `!x y z. ~(z = &0) /\\ (x * z = y * z) ==> (x = y)`;;\n\nlet REAL_EQ_LMUL_IMP = `!x y z. ~(x = &0) /\\ (x * y = x * z) ==> (y = z)`;;\n\nlet REAL_FACT_NZ = `!n. ~(&(FACT n) = &0)`;;\n\nlet REAL_POSSQ = `!x. &0 < (x * x) <=> ~(x = &0)`;;\n\nlet REAL_SUMSQ = `!x y. ((x * x) + (y * y) = &0) <=> (x = &0) /\\ (y = &0)`;;\n\nlet REAL_EQ_NEG = `!x y. (--x = --y) <=> (x = y)`;;\n\nlet REAL_DIV_MUL2 = `!x z. ~(x = &0) /\\ ~(z = &0) ==> !y. y / z = (x * y) / (x * z)`;;\n\nlet REAL_MIDDLE1 = `!a b. a <= b ==> a <= (a + b) / &2`;;\n\nlet REAL_MIDDLE2 = `!a b. a <= b ==> ((a + b) / &2) <= b`;;\n\nlet ABS_ZERO = `!x. (abs(x) = &0) <=> (x = &0)`;;\n\nlet ABS_0 = `abs(&0) = &0`;;\n\nlet ABS_1 = `abs(&1) = &1`;;\n\nlet ABS_NEG = `!x. abs(--x) = abs(x)`;;\n\nlet ABS_TRIANGLE = `!x y. abs(x + y) <= abs(x) + abs(y)`;;\n\nlet ABS_POS = `!x. &0 <= abs(x)`;;\n\nlet ABS_MUL = `!x y. abs(x * y) = abs(x) * abs(y)`;;\n\nlet ABS_LT_MUL2 = `!w x y z. abs(w) < y /\\ abs(x) < z ==> abs(w * x) < (y * z)`;;\n\nlet ABS_SUB = `!x y. abs(x - y) = abs(y - x)`;;\n\nlet ABS_NZ = `!x. ~(x = &0) <=> &0 < abs(x)`;;\n\nlet ABS_INV = `!x. ~(x = &0) ==> (abs(inv x) = inv(abs(x)))`;;\n\nlet ABS_ABS = `!x. abs(abs(x)) = abs(x)`;;\n\nlet ABS_LE = `!x. x <= abs(x)`;;\n\nlet ABS_REFL = `!x. (abs(x) = x) <=> &0 <= x`;;\n\nlet ABS_N = `!n. abs(&n) = &n`;;\n\nlet ABS_BETWEEN = `!x y d. &0 < d /\\ ((x - d) < y) /\\ (y < (x + d)) <=> abs(y - x) < d`;;\n\nlet ABS_BOUND = `!x y d. abs(x - y) < d ==> y < (x + d)`;;\n\nlet ABS_STILLNZ = `!x y. abs(x - y) < abs(y) ==> ~(x = &0)`;;\n\nlet ABS_CASES = `!x. (x = &0) \\/ &0 < abs(x)`;;\n\nlet ABS_BETWEEN1 = `!x y z. x < z /\\ (abs(y - x)) < (z - x) ==> y < z`;;\n\nlet ABS_SIGN = `!x y. abs(x - y) < y ==> &0 < x`;;\n\nlet ABS_SIGN2 = `!x y. abs(x - y) < --y ==> x < &0`;;\n\nlet ABS_DIV = `!y. ~(y = &0) ==> !x. abs(x / y) = abs(x) / abs(y)`;;\n\nlet ABS_CIRCLE = `!x y h. abs(h) < (abs(y) - abs(x)) ==> abs(x + h) < abs(y)`;;\n\nlet REAL_SUB_ABS = `!x y. (abs(x) - abs(y)) <= abs(x - y)`;;\n\nlet ABS_SUB_ABS = `!x y. abs(abs(x) - abs(y)) <= abs(x - y)`;;\n\nlet ABS_BETWEEN2 = `!x0 x y0 y. x0 < y0 /\\ abs(x - x0) < (y0 - x0) / &2 /\\\n abs(y - y0) < (y0 - x0) / &2\n ==> x < y`;;\n\nlet ABS_BOUNDS = `!x k. abs(x) <= k <=> --k <= x /\\ x <= k`;;\n\nlet pow = real_pow;;\n\nlet POW_0 = `!n. &0 pow (SUC n) = &0`;;\n\nlet POW_NZ = `!c n. ~(c = &0) ==> ~(c pow n = &0)`;;\n\nlet POW_INV = `!c n. ~(c = &0) ==> (inv(c pow n) = (inv c) pow n)`;;\n\nlet POW_ABS = `!c n. abs(c) pow n = abs(c pow n)`;;\n\nlet POW_PLUS1 = `!e n. &0 < e ==> (&1 + (&n * e)) <= (&1 + e) pow n`;;\n\nlet POW_ADD = `!c m n. c pow (m + n) = (c pow m) * (c pow n)`;;\n\nlet POW_1 = `!x. x pow 1 = x`;;\n\nlet POW_2 = `!x. x pow 2 = x * x`;;\n\nlet POW_POS = `!x n. &0 <= x ==> &0 <= (x pow n)`;;\n\nlet POW_LE = `!n x y. &0 <= x /\\ x <= y ==> (x pow n) <= (y pow n)`;;\n\nlet POW_M1 = `!n. abs((--(&1)) pow n) = &1`;;\n\nlet POW_MUL = `!n x y. (x * y) pow n = (x pow n) * (y pow n)`;;\n\nlet REAL_LE_SQUARE_POW = `!x. &0 <= x pow 2`;;\n\nlet ABS_POW2 = `!x. abs(x pow 2) = x pow 2`;;\n\nlet REAL_LE1_POW2 = `!x. &1 <= x ==> &1 <= (x pow 2)`;;\n\nlet REAL_LT1_POW2 = `!x. &1 < x ==> &1 < (x pow 2)`;;\n\nlet POW_POS_LT = `!x n. &0 < x ==> &0 < (x pow (SUC n))`;;\n\nlet POW_2_LE1 = `!n. &1 <= &2 pow n`;;\n\nlet POW_2_LT = `!n. &n < &2 pow n`;;\n\nlet POW_MINUS1 = `!n. (--(&1)) pow (2 * n) = &1`;;\n\nlet REAL_SUP_EXISTS = `!P. (?x. P x) /\\ (?z. !x. P x ==> x < z) ==>\n (?s. !y. (?x. P x /\\ y < x) <=> y < s)`;;\n\nlet sup_def = new_definition\n `sup s = @a. (!x. x IN s ==> x <= a) /\\\n (!b. (!x. x IN s ==> x <= b) ==> a <= b)`;;\n\nlet sup = `sup P = @s. !y. (?x. P x /\\ y < x) <=> y < s`;;\n\nlet REAL_SUP = `!P. (?x. P x) /\\ (?z. !x. P x ==> x < z) ==>\n (!y. (?x. P x /\\ y < x) <=> y < sup P)`;;\n\nlet REAL_SUP_UBOUND = `!P. (?x. P x) /\\ (?z. !x. P x ==> x < z) ==>\n (!y. P y ==> y <= sup P)`;;\n\nlet SETOK_LE_LT = `!P. (?x. P x) /\\ (?z. !x. P x ==> x <= z) <=>\n (?x. P x) /\\ (?z. !x. P x ==> x < z)`;;\n\nlet REAL_SUP_LE = `!P. (?x. P x) /\\ (?z. !x. P x ==> x <= z) ==>\n (!y. (?x. P x /\\ y < x) <=> y < sup P)`;;\n\nlet REAL_SUP_UBOUND_LE = `!P. (?x. P x) /\\ (?z. !x. P x ==> x <= z) ==>\n (!y. P y ==> y <= sup P)`;;\n\nlet REAL_ARCH_SIMPLE = `!x. ?n. x <= &n`;;\n\nlet REAL_ARCH = `!x. &0 < x ==> !y. ?n. y < &n * x`;;\n\nlet REAL_ARCH_LEAST = `!y. &0 < y ==> !x. &0 <= x ==>\n ?n. (&n * y) <= x /\\ x < (&(SUC n) * y)`;;\n\nlet REAL_POW_LBOUND = `!x n. &0 <= x ==> &1 + &n * x <= (&1 + x) pow n`;;\n\nlet REAL_ARCH_POW = `!x y. &1 < x ==> ?n. y < x pow n`;;\n\nlet REAL_ARCH_POW2 = `!x. ?n. x < &2 pow n`;;\n\nprioritize_real();;\n\nmake_overloadable \"sum\" `:A->(B->real)->real`;;\n\noverload_interface(\"sum\",`sum:(A->bool)->(A->real)->real`);;\noverload_interface(\"sum\",`psum:(num#num)->(num->real)->real`);;\n\nlet sum_EXISTS = `?sum. (!f n. sum(n,0) f = &0) /\\\n (!f m n. sum(n,SUC m) f = sum(n,m) f + f(n + m))`;;\n\nlet sum_DEF = new_specification [\"psum\"] sum_EXISTS;;\n\nlet sum = `(sum(n,0) f = &0) /\\\n (sum(n,SUC m) f = sum(n,m) f + f(n + m))`;;\n\nlet PSUM_SUM = `!f m n. sum(m,n) f = sum {i | m <= i /\\ i < m + n} f`;;\n\nlet PSUM_SUM_NUMSEG = `!f m n. ~(m = 0 /\\ n = 0) ==> sum(m,n) f = sum(m..(m+n)-1) f`;;\n\nlet SUM_TWO = `!f n p. sum(0,n) f + sum(n,p) f = sum(0,n + p) f`;;\n\nlet SUM_DIFF = `!f m n. sum(m,n) f = sum(0,m + n) f - sum(0,m) f`;;\n\nlet ABS_SUM = `!f m n. abs(sum(m,n) f) <= sum(m,n) (\\n. abs(f n))`;;\n\nlet SUM_LE = `!f g m n. (!r. m <= r /\\ r < n + m ==> f(r) <= g(r))\n ==> (sum(m,n) f <= sum(m,n) g)`;;\n\nlet SUM_EQ = `!f g m n. (!r. m <= r /\\ r < (n + m) ==> (f(r) = g(r)))\n ==> (sum(m,n) f = sum(m,n) g)`;;\n\nlet SUM_POS = `!f. (!n. &0 <= f(n)) ==> !m n. &0 <= sum(m,n) f`;;\n\nlet SUM_POS_GEN = `!f m n.\n (!n. m <= n ==> &0 <= f(n))\n ==> &0 <= sum(m,n) f`;;\n\nlet SUM_ABS = `!f m n. abs(sum(m,n) (\\m. abs(f m))) = sum(m,n) (\\m. abs(f m))`;;\n\nlet SUM_ABS_LE = `!f m n. abs(sum(m,n) f) <= sum(m,n)(\\n. abs(f n))`;;\n\nlet SUM_ZERO = `!f N. (!n. n >= N ==> (f(n) = &0)) ==>\n (!m n. m >= N ==> (sum(m,n) f = &0))`;;\n\nlet SUM_ADD = `!f g m n. sum(m,n) (\\n. f(n) + g(n)) = sum(m,n) f + sum(m,n) g`;;\n\nlet SUM_CMUL = `!f c m n. sum(m,n) (\\n. c * f(n)) = c * sum(m,n) f`;;\n\nlet SUM_NEG = `!f n d. sum(n,d) (\\n. --(f n)) = --(sum(n,d) f)`;;\n\nlet SUM_SUB = `!f g m n. sum(m,n)(\\n. (f n) - (g n)) = sum(m,n) f - sum(m,n) g`;;\n\nlet SUM_SUBST = `!f g m n. (!p. m <= p /\\ p < (m + n) ==> (f p = g p))\n ==> (sum(m,n) f = sum(m,n) g)`;;\n\nlet SUM_NSUB = `!n f c. sum(0,n) f - (&n * c) = sum(0,n)(\\p. f(p) - c)`;;\n\nlet SUM_BOUND = `!f K m n. (!p. m <= p /\\ p < (m + n) ==> (f(p) <= K))\n ==> (sum(m,n) f <= (&n * K))`;;\n\nlet SUM_GROUP = `!n k f. sum(0,n)(\\m. sum(m * k,k) f) = sum(0,n * k) f`;;\n\nlet SUM_1 = `!f n. sum(n,1) f = f(n)`;;\n\nlet SUM_2 = `!f n. sum(n,2) f = f(n) + f(n + 1)`;;\n\nlet SUM_OFFSET = `!f n k. sum(0,n)(\\m. f(m + k)) = sum(0,n + k) f - sum(0,k) f`;;\n\nlet SUM_REINDEX = `!f m k n. sum(m + k,n) f = sum(m,n)(\\r. f(r + k))`;;\n\nlet SUM_0 = `!m n. sum(m,n)(\\r. &0) = &0`;;\n\nlet SUM_CANCEL = `!f n d. sum(n,d) (\\n. f(SUC n) - f(n)) = f(n + d) - f(n)`;;\n\nlet SUM_HORNER = `!f n x. sum(0,SUC n)(\\i. f(i) * x pow i) =\n f(0) + x * sum(0,n)(\\i. f(SUC i) * x pow i)`;;\n\nlet SUM_CONST = `!c n. sum(0,n) (\\m. c) = &n * c`;;\n\nlet SUM_SPLIT = `!f n p. sum(m,n) f + sum(m + n,p) f = sum(m,n + p) f`;;\n\nlet SUM_SWAP = `!f m1 n1 m2 n2.\n sum(m1,n1) (\\a. sum(m2,n2) (\\b. f a b)) =\n sum(m2,n2) (\\b. sum(m1,n1) (\\a. f a b))`;;\n\nlet SUM_EQ_0 = `(!r. m <= r /\\ r < m + n ==> (f(r) = &0)) ==> (sum(m,n) f = &0)`;;\n\nlet SUM_MORETERMS_EQ = `!m n p.\n n <= p /\\ (!r. m + n <= r /\\ r < m + p ==> (f(r) = &0))\n ==> (sum(m,p) f = sum(m,n) f)`;;\n\nlet SUM_DIFFERENCES_EQ = `!m n p.\n n <= p /\\ (!r. m + n <= r /\\ r < m + p ==> (f(r) = g(r)))\n ==> (sum(m,p) f - sum(m,n) f = sum(m,p) g - sum(m,n) g)`;;\n\nlet REAL_SUM_CONV =\n let sum_tm = `sum` in\n let pth = `sum(0,1) f = f 0`;;\nparse_as_infix(\"re_intersect\",(17,\"right\"));;\nparse_as_infix(\"re_subset\",(12,\"right\"));;\n\nlet re_Union = new_definition(\n `re_Union S = \\x:A. ?s. S s /\\ s x`);;\n\nlet re_union = new_definition(\n `P re_union Q = \\x:A. P x \\/ Q x`);;\n\nlet re_intersect = new_definition\n `P re_intersect Q = \\x:A. P x /\\ Q x`;;\n\nlet re_null = new_definition(\n `re_null = \\x:A. F`);;\n\nlet re_universe = new_definition(\n `re_universe = \\x:A. T`);;\n\nlet re_subset = new_definition(\n `P re_subset Q <=> !x:A. P x ==> Q x`);;\n\nlet re_compl = new_definition(\n `re_compl S = \\x:A. ~(S x)`);;\n\nlet SUBSETA_REFL = `!S:A->bool. S re_subset S`;;\n\nlet COMPL_MEM = `!S:A->bool. !x. S x <=> ~(re_compl S x)`;;\n\nlet SUBSETA_ANTISYM = `!P:A->bool. !Q. P re_subset Q /\\ Q re_subset P <=> (P = Q)`;;\n\nlet SUBSETA_TRANS = `!P:A->bool. !Q R. P re_subset Q /\\ Q re_subset R ==> P re_subset R`;;\n\nlet istopology = new_definition(\n `!L:(A->bool)->bool. istopology L <=>\n L re_null /\\\n L re_universe /\\\n (!a b. L a /\\ L b ==> L (a re_intersect b)) /\\\n (!P. P re_subset L ==> L (re_Union P))`);;\n\nlet topology_tybij = new_type_definition \"topology\" (\"topology\",\"open\")\n (prove(`?t:(A->bool)->bool. istopology t`,\n EXISTS_TAC `re_universe:(A->bool)->bool` THEN\n REWRITE_TAC[istopology; re_universe]));;\n\nlet TOPOLOGY = `!L:(A)topology. open(L) re_null /\\\n open(L) re_universe /\\\n (!x y. open(L) x /\\ open(L) y ==> open(L) (x re_intersect y)) /\\\n (!P. P re_subset (open L) ==> open(L) (re_Union P))`;;\n\nlet TOPOLOGY_UNION = `!L:(A)topology. !P. P re_subset (open L) ==> open(L) (re_Union P)`;;\n\nlet neigh = new_definition(\n `neigh(top)(N,(x:A)) = ?P. open(top) P /\\ P re_subset N /\\ P x`);;\n\nlet OPEN_OWN_NEIGH = `!S top. !x:A. open(top) S /\\ S x ==> neigh(top)(S,x)`;;\n\nlet OPEN_UNOPEN = `!S top. open(top) S <=>\n (re_Union (\\P:A->bool. open(top) P /\\ P re_subset S) = S)`;;\n\nlet OPEN_SUBOPEN = `!S top. open(top) S <=>\n !x:A. S x ==> ?P. P x /\\ open(top) P /\\ P re_subset S`;;\n\nlet OPEN_NEIGH = `!S top. open(top) S = !x:A. S x ==> ?N. neigh(top)(N,x) /\\ N re_subset S`;;\n\nlet closed = new_definition(\n `closed(L:(A)topology) S = open(L)(re_compl S)`);;\n\nlet limpt = new_definition(\n `limpt(top) x S <=>\n !N:A->bool. neigh(top)(N,x) ==> ?y. ~(x = y) /\\ S y /\\ N y`);;\n\nlet CLOSED_LIMPT = `!top S. closed(top) S <=> (!x:A. limpt(top) x S ==> S x)`;;\n\nlet ismet = new_definition(\n `ismet (m:A#A->real) <=> (!x y. (m(x,y) = &0) <=> (x = y)) /\\\n (!x y z. m(y,z) <= m(x,y) + m(x,z))`);;\n\nlet metric_tybij = new_type_definition \"metric\" (\"metric\",\"mdist\")\n (prove(`?m:(A#A->real). ismet m`,\n EXISTS_TAC `\\((x:A),(y:A)). if x = y then &0 else &1` THEN\n REWRITE_TAC[ismet] THEN\n CONV_TAC(ONCE_DEPTH_CONV GEN_BETA_CONV) THEN\n CONJ_TAC THEN REPEAT GEN_TAC THENL\n [BOOL_CASES_TAC `x:A = y` THEN REWRITE_TAC[REAL_10];\n REPEAT COND_CASES_TAC THEN\n ASM_REWRITE_TAC[REAL_ADD_LID; REAL_ADD_RID; REAL_LE_REFL; REAL_LE_01]\n THEN GEN_REWRITE_TAC LAND_CONV [GSYM REAL_ADD_LID] THEN\n TRY(MATCH_MP_TAC REAL_LE_ADD2) THEN\n REWRITE_TAC[REAL_LE_01; REAL_LE_REFL] THEN\n FIRST_ASSUM(UNDISCH_TAC o check is_neg o concl) THEN\n EVERY_ASSUM(SUBST1_TAC o SYM) THEN REWRITE_TAC[]]));;\n\nlet METRIC_ISMET = `!m:(A)metric. ismet (mdist m)`;;\n\nlet METRIC_ZERO = `!m:(A)metric. !x y. ((mdist m)(x,y) = &0) <=> (x = y)`;;\n\nlet METRIC_SAME = `!m:(A)metric. !x. (mdist m)(x,x) = &0`;;\n\nlet METRIC_POS = `!m:(A)metric. !x y. &0 <= (mdist m)(x,y)`;;\n\nlet METRIC_SYM = `!m:(A)metric. !x y. (mdist m)(x,y) = (mdist m)(y,x)`;;\n\nlet METRIC_TRIANGLE = `!m:(A)metric. !x y z. (mdist m)(x,z) <= (mdist m)(x,y) + (mdist m)(y,z)`;;\n\nlet METRIC_NZ = `!m:(A)metric. !x y. ~(x = y) ==> &0 < (mdist m)(x,y)`;;\n\nlet mtop = new_definition(\n `!m:(A)metric. mtop m =\n topology(\\S. !x. S x ==> ?e. &0 < e /\\ (!y. (mdist m)(x,y) < e ==> S y))`);;\n\nlet mtop_istopology = `!m:(A)metric. istopology\n (\\S. !x. S x ==> ?e. &0 < e /\\ (!y. (mdist m)(x,y) < e ==> S y))`;;\n\nlet MTOP_OPEN = `!m:(A)metric. open(mtop m) S <=>\n (!x. S x ==> ?e. &0 < e /\\ (!y. (mdist m(x,y)) < e ==> S y))`;;\n\nlet ball = new_definition(\n `!m:(A)metric. !x e. ball(m)(x,e) = \\y. (mdist m)(x,y) < e`);;\n\nlet BALL_OPEN = `!m:(A)metric. !x e. &0 < e ==> open(mtop(m))(ball(m)(x,e))`;;\n\nlet BALL_NEIGH = `!m:(A)metric. !x e. &0 < e ==> neigh(mtop(m))(ball(m)(x,e),x)`;;\n\nlet MTOP_LIMPT = `!m:(A)metric. !x S. limpt(mtop m) x S <=>\n !e. &0 < e ==> ?y. ~(x = y) /\\ S y /\\ (mdist m)(x,y) < e`;;\n\nlet ISMET_R1 = `ismet (\\(x,y). abs(y - x))`;;\n\nlet mr1 = new_definition(\n `mr1 = metric(\\(x,y). abs(y - x))`);;\n\nlet MR1_DEF = `!x y. (mdist mr1)(x,y) = abs(y - x)`;;\n\nlet MR1_ADD = `!x d. (mdist mr1)(x,x+d) = abs(d)`;;\n\nlet MR1_SUB = `!x d. (mdist mr1)(x,x-d) = abs(d)`;;\n\nlet MR1_ADD_LE = `!x d. &0 <= d ==> ((mdist mr1)(x,x+d) = d)`;;\n\nlet MR1_SUB_LE = `!x d. &0 <= d ==> ((mdist mr1)(x,x-d) = d)`;;\n\nlet MR1_ADD_LT = `!x d. &0 < d ==> ((mdist mr1)(x,x+d) = d)`;;\n\nlet MR1_SUB_LT = `!x d. &0 < d ==> ((mdist mr1)(x,x-d) = d)`;;\n\nlet MR1_BETWEEN1 = `!x y z. x < z /\\ (mdist mr1)(x,y) < (z - x) ==> y < z`;;\n\nlet MR1_LIMPT = `!x. limpt(mtop mr1) x re_universe`;;\n\nparse_as_infix (\"tends\",(12,\"right\"));;\n\nlet dorder = new_definition(\n `dorder (g:A->A->bool) <=>\n !x y. g x x /\\ g y y ==> ?z. g z z /\\ (!w. g w z ==> g w x /\\ g w y)`);;\n\nlet tends = new_definition\n `(s tends l)(top,g) <=>\n !N:A->bool. neigh(top)(N,l) ==>\n ?n:B. g n n /\\ !m:B. g m n ==> N(s m)`;;\n\nlet bounded = new_definition(\n `bounded((m:(A)metric),(g:B->B->bool)) f <=>\n ?k x N. g N N /\\ (!n. g n N ==> (mdist m)(f(n),x) < k)`);;\n\nlet tendsto = new_definition(\n `tendsto((m:(A)metric),x) y z <=>\n &0 < (mdist m)(x,y) /\\ (mdist m)(x,y) <= (mdist m)(x,z)`);;\n\nparse_as_infix(\"-->\",(12,\"right\"));;\n\noverride_interface (\"-->\",`(tends)`);;\n\nlet DORDER_LEMMA = `!g:A->A->bool.\n dorder g ==>\n !P Q. (?n. g n n /\\ (!m. g m n ==> P m)) /\\\n (?n. g n n /\\ (!m. g m n ==> Q m))\n ==> (?n. g n n /\\ (!m. g m n ==> P m /\\ Q m))`;;\n\nlet DORDER_THEN tac th =\n let [t1;t2] = map (rand o rand o body o rand) (conjuncts(concl th)) in\n let dog = (rator o rator o rand o rator o body) t1 in\n let thl = map ((uncurry X_BETA_CONV) o (I F_F rand) o dest_abs) [t1;t2] in\n let th1 = CONV_RULE(EXACT_CONV thl) th in\n let th2 = MATCH_MP DORDER_LEMMA (ASSUME (list_mk_icomb \"dorder\" [dog])) in\n let th3 = MATCH_MP th2 th1 in\n let th4 = CONV_RULE(EXACT_CONV(map SYM thl)) th3 in\n tac th4;;\n\nlet DORDER_NGE = `dorder ((>=) :num->num->bool)`;;\n\nlet DORDER_TENDSTO = `!m:(A)metric. !x. dorder(tendsto(m,x))`;;\n\nlet MTOP_TENDS = `!d g. !x:B->A. !x0. (x --> x0)(mtop(d),g) <=>\n !e. &0 < e ==> ?n. g n n /\\ !m. g m n ==> mdist(d)(x(m),x0) < e`;;\n\nlet MTOP_TENDS_UNIQ = `!g d. dorder (g:B->B->bool) ==>\n (x --> x0)(mtop(d),g) /\\ (x --> x1)(mtop(d),g) ==> (x0:A = x1)`;;\n\nlet SEQ_TENDS = `!d:(A)metric. !x x0. (x --> x0)(mtop(d), (>=) :num->num->bool) <=>\n !e. &0 < e ==> ?N. !n. n >= N ==> mdist(d)(x(n),x0) < e`;;\n\nlet LIM_TENDS = `!m1:(A)metric. !m2:(B)metric. !f x0 y0.\n limpt(mtop m1) x0 re_universe ==>\n ((f --> y0)(mtop(m2),tendsto(m1,x0)) <=>\n !e. &0 < e ==>\n ?d. &0 < d /\\ !x. &0 < (mdist m1)(x,x0) /\\ (mdist m1)(x,x0) <= d\n ==> (mdist m2)(f(x),y0) < e)`;;\n\nlet LIM_TENDS2 = `!m1:(A)metric. !m2:(B)metric. !f x0 y0.\n limpt(mtop m1) x0 re_universe ==>\n ((f --> y0)(mtop(m2),tendsto(m1,x0)) <=>\n !e. &0 < e ==>\n ?d. &0 < d /\\ !x. &0 < (mdist m1)(x,x0) /\\ (mdist m1)(x,x0) < d ==>\n (mdist m2)(f(x),y0) < e)`;;\n\nlet MR1_BOUNDED = `!(g:A->A->bool) f. bounded(mr1,g) f <=>\n ?k N. g N N /\\ (!n. g n N ==> abs(f n) < k)`;;\n\nlet NET_NULL = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) <=> ((\\n. x(n) - x0) --> &0)(mtop(mr1),g)`;;\n\nlet NET_CONV_BOUNDED = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) ==> bounded(mr1,g) x`;;\n\nlet NET_CONV_NZ = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) /\\ ~(x0 = &0) ==>\n ?N. g N N /\\ (!n. g n N ==> ~(x n = &0))`;;\n\nlet NET_CONV_IBOUNDED = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) /\\ ~(x0 = &0) ==>\n bounded(mr1,g) (\\n. inv(x n))`;;\n\nlet NET_NULL_ADD = `!g:A->A->bool. dorder g ==>\n !x y. (x --> &0)(mtop(mr1),g) /\\ (y --> &0)(mtop(mr1),g) ==>\n ((\\n. x(n) + y(n)) --> &0)(mtop(mr1),g)`;;\n\nlet NET_NULL_MUL = `!g:A->A->bool. dorder g ==>\n !x y. bounded(mr1,g) x /\\ (y --> &0)(mtop(mr1),g) ==>\n ((\\n. x(n) * y(n)) --> &0)(mtop(mr1),g)`;;\n\nlet NET_NULL_CMUL = `!g:A->A->bool. !k x.\n (x --> &0)(mtop(mr1),g) ==> ((\\n. k * x(n)) --> &0)(mtop(mr1),g)`;;\n\nlet NET_ADD = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ (y --> y0)(mtop(mr1),g)\n ==> ((\\n. x(n) + y(n)) --> (x0 + y0))(mtop(mr1),g)`;;\n\nlet NET_NEG = `!g:A->A->bool x x0.\n dorder g\n ==> ((x --> x0)(mtop(mr1),g) <=>\n ((\\n. --(x n)) --> --x0)(mtop(mr1),g))`;;\n\nlet NET_SUB = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ (y --> y0)(mtop(mr1),g)\n ==> ((\\n. x(n) - y(n)) --> (x0 - y0))(mtop(mr1),g)`;;\n\nlet NET_MUL = `!g:A->A->bool x y x0 y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ (y --> y0)(mtop(mr1),g)\n ==> ((\\n. x(n) * y(n)) --> (x0 * y0))(mtop(mr1),g)`;;\n\nlet NET_INV = `!g:A->A->bool x x0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ ~(x0 = &0)\n ==> ((\\n. inv(x(n))) --> inv x0)(mtop(mr1),g)`;;\n\nlet NET_DIV = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\\n (y --> y0)(mtop(mr1),g) /\\ ~(y0 = &0)\n ==> ((\\n. x(n) / y(n)) --> (x0 / y0))(mtop(mr1),g)`;;\n\nlet NET_ABS = `!x x0. (x --> x0)(mtop(mr1),g) ==>\n ((\\n:A. abs(x n)) --> abs(x0))(mtop(mr1),g)`;;\n\nlet NET_SUM = `!g. dorder g /\\\n ((\\x. &0) --> &0)(mtop(mr1),g)\n ==> !m n. (!r. m <= r /\\ r < m + n ==> (f r --> l r)(mtop(mr1),g))\n ==> ((\\x. sum(m,n) (\\r. f r x)) --> sum(m,n) l)\n (mtop(mr1),g)`;;\n\nlet NET_LE = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\\n (y --> y0)(mtop(mr1),g) /\\\n (?N. g N N /\\ !n. g n N ==> x(n) <= y(n))\n ==> x0 <= y0`;;\n\nparse_as_infix (\"tends_num_real\",(12,\"right\"));;\n\nparse_as_infix (\"sums\",(12,\"right\"));;\n\nlet tends_num_real = new_definition(\n `x tends_num_real x0 <=> (x tends x0)(mtop(mr1), (>=) :num->num->bool)`);;\n\noverride_interface (\"-->\",`(tends_num_real)`);;\n\nlet SEQ = `!x x0. (x --> x0) <=>\n !e. &0 < e ==> ?N. !n. n >= N ==> abs(x(n) - x0) < e`;;\n\nlet SEQ_CONST = `!k. (\\x. k) --> k`;;\n\nlet SEQ_ADD = `!x x0 y y0. x --> x0 /\\ y --> y0 ==> (\\n. x(n) + y(n)) --> (x0 + y0)`;;\n\nlet SEQ_MUL = `!x x0 y y0. x --> x0 /\\ y --> y0 ==> (\\n. x(n) * y(n)) --> (x0 * y0)`;;\n\nlet SEQ_NEG = `!x x0. x --> x0 <=> (\\n. --(x n)) --> --x0`;;\n\nlet SEQ_INV = `!x x0. x --> x0 /\\ ~(x0 = &0) ==> (\\n. inv(x n)) --> inv x0`;;\n\nlet SEQ_SUB = `!x x0 y y0. x --> x0 /\\ y --> y0 ==> (\\n. x(n) - y(n)) --> (x0 - y0)`;;\n\nlet SEQ_DIV = `!x x0 y y0. x --> x0 /\\ y --> y0 /\\ ~(y0 = &0) ==>\n (\\n. x(n) / y(n)) --> (x0 / y0)`;;\n\nlet SEQ_UNIQ = `!x x1 x2. x --> x1 /\\ x --> x2 ==> (x1 = x2)`;;\n\nlet SEQ_NULL = `!s l. s --> l <=> (\\n. s(n) - l) --> &0`;;\n\nlet SEQ_SUM = `!f l m n.\n (!r. m <= r /\\ r < m + n ==> f r --> l r)\n ==> (\\k. sum(m,n) (\\r. f r k)) --> sum(m,n) l`;;\n\nlet SEQ_TRANSFORM = `!s t l N. (!n. N <= n ==> (s n = t n)) /\\ s --> l ==> t --> l`;;\n\nlet convergent = new_definition(\n `convergent f <=> ?l. f --> l`);;\n\nlet cauchy = new_definition(\n `cauchy f <=> !e. &0 < e ==>\n ?N:num. !m n. m >= N /\\ n >= N ==> abs(f(m) - f(n)) < e`);;\n\nlet lim = new_definition(\n `lim f = @l. f --> l`);;\n\nlet SEQ_LIM = `!f. convergent f <=> (f --> lim f)`;;\n\nlet subseq = new_definition(\n `subseq (f:num->num) <=> !m n. m < n ==> (f m) < (f n)`);;\n\nlet SUBSEQ_SUC = `!f. subseq f <=> !n. f(n) < f(SUC n)`;;\n\nlet mono = new_definition(\n `mono (f:num->real) <=>\n (!m n. m <= n ==> f(m) <= f(n)) \\/\n (!m n. m <= n ==> f(m) >= f(n))`);;\n\nlet MONO_SUC = `!f. mono f <=> (!n. f(SUC n) >= f(n)) \\/ (!n. f(SUC n) <= f(n))`;;\n\nlet MAX_LEMMA = `!s N. ?k. !n:num. n < N ==> abs(s n) < k`;;\n\nlet SEQ_BOUNDED = `!s. bounded(mr1, (>=)) s <=> ?k. !n:num. abs(s n) < k`;;\n\nlet SEQ_BOUNDED_2 = `!f k K. (!n:num. k <= f(n) /\\ f(n) <= K) ==> bounded(mr1, (>=)) f`;;\n\nlet SEQ_CBOUNDED = `!f. cauchy f ==> bounded(mr1, (>=)) f`;;\n\nlet SEQ_ICONV = `!f. bounded(mr1, (>=)) f /\\ (!m n. m >= n ==> f(m) >= f(n))\n ==> convergent f`;;\n\nlet SEQ_NEG_CONV = `!f. convergent f <=> convergent (\\n. --(f n))`;;\n\nlet SEQ_NEG_BOUNDED = `!f. bounded(mr1, (>=))(\\n:num. --(f n)) <=> bounded(mr1, (>=)) f`;;\n\nlet SEQ_BCONV = `!f. bounded(mr1, (>=)) f /\\ mono f ==> convergent f`;;\n\nlet SEQ_MONOSUB = `!s:num->real. ?f. subseq f /\\ mono(\\n.s(f n))`;;\n\nlet SEQ_SBOUNDED = `!s (f:num->num). bounded(mr1, (>=)) s ==> bounded(mr1, (>=)) (\\n. s(f n))`;;\n\nlet SEQ_SUBLE = `!f n. subseq f ==> n <= f(n)`;;\n\nlet SEQ_DIRECT = `!f. subseq f ==> !N1 N2. ?n. n >= N1 /\\ f(n) >= N2`;;\n\nlet SEQ_CAUCHY = `!f. cauchy f <=> convergent f`;;\n\nlet SEQ_LE = `!f g l m. f --> l /\\ g --> m /\\ (?N. !n. n >= N ==> f(n) <= g(n))\n ==> l <= m`;;\n\nlet SEQ_LE_0 = `!f g. f --> &0 /\\ (?N. !n. n >= N ==> abs(g n) <= abs(f n))\n ==> g --> &0`;;\n\nlet SEQ_SUC = `!f l. f --> l <=> (\\n. f(SUC n)) --> l`;;\n\nlet SEQ_ABS = `!f. (\\n. abs(f n)) --> &0 <=> f --> &0`;;\n\nlet SEQ_ABS_IMP = `!f l. f --> l ==> (\\n. abs(f n)) --> abs(l)`;;\n\nlet SEQ_INV0 = `!f. (!y. ?N. !n. n >= N ==> f(n) > y)\n ==> (\\n. inv(f n)) --> &0`;;\n\nlet SEQ_POWER_ABS = `!c. abs(c) < &1 ==> (\\n. abs(c) pow n) --> &0`;;\n\nlet SEQ_POWER = `!c. abs(c) < &1 ==> (\\n. c pow n) --> &0`;;\n\nlet SEQ_HARMONIC = `!a. (\\n. a / &n) --> &0`;;\n\nlet SEQ_SUBSEQ = `!f l. f --> l ==> !a b. ~(a = 0) ==> (\\n. f(a * n + b)) --> l`;;\n\nlet SEQ_POW = `!f l. (f --> l) ==> !n. (\\i. f(i) pow n) --> l pow n`;;\n\nlet NEST_LEMMA = `!f g. (!n. f(SUC n) >= f(n)) /\\\n (!n. g(SUC n) <= g(n)) /\\\n (!n. f(n) <= g(n)) ==>\n ?l m. l <= m /\\ ((!n. f(n) <= l) /\\ f --> l) /\\\n ((!n. m <= g(n)) /\\ g --> m)`;;\n\nlet NEST_LEMMA_UNIQ = `!f g. (!n. f(SUC n) >= f(n)) /\\\n (!n. g(SUC n) <= g(n)) /\\\n (!n. f(n) <= g(n)) /\\\n (\\n. f(n) - g(n)) --> &0 ==>\n ?l. ((!n. f(n) <= l) /\\ f --> l) /\\\n ((!n. l <= g(n)) /\\ g --> l)`;;\n\nlet BOLZANO_LEMMA = `!P. (!a b c. a <= b /\\ b <= c /\\ P(a,b) /\\ P(b,c) ==> P(a,c)) /\\\n (!x. ?d. &0 < d /\\ !a b. a <= x /\\ x <= b /\\ (b - a) < d ==> P(a,b))\n ==> !a b. a <= b ==> P(a,b)`;;\n\nlet BOLZANO_LEMMA_ALT = `!P. (!a b c. a <= b /\\ b <= c /\\ P a b /\\ P b c ==> P a c) /\\\n (!x. ?d. &0 < d /\\ (!a b. a <= x /\\ x <= b /\\ b - a < d ==> P a b))\n ==> !a b. a <= b ==> P a b`;;\n\nlet sums = new_definition\n `f sums s <=> (\\n. sum(0,n) f) --> s`;;\n\nlet summable = new_definition(\n `summable f <=> ?s. f sums s`);;\n\nlet suminf = new_definition(\n `suminf f = @s. f sums s`);;\n\nlet SUM_SUMMABLE = `!f l. f sums l ==> summable f`;;\n\nlet SUMMABLE_SUM = `!f. summable f ==> f sums (suminf f)`;;\n\nlet SUM_UNIQ = `!f x. f sums x ==> (x = suminf f)`;;\n\nlet SER_UNIQ = `!f x y. f sums x /\\ f sums y ==> (x = y)`;;\n\nlet SER_0 = `!f n. (!m. n <= m ==> (f(m) = &0)) ==>\n f sums (sum(0,n) f)`;;\n\nlet SER_POS_LE = `!f n. summable f /\\ (!m. n <= m ==> &0 <= f(m))\n ==> sum(0,n) f <= suminf f`;;\n\nlet SER_POS_LT = `!f n. summable f /\\ (!m. n <= m ==> &0 < f(m))\n ==> sum(0,n) f < suminf f`;;\n\nlet SER_GROUP = `!f k. summable f /\\ 0 < k ==>\n (\\n. sum(n * k,k) f) sums (suminf f)`;;\n\nlet SER_PAIR = `!f. summable f ==> (\\n. sum(2 * n,2) f) sums (suminf f)`;;\n\nlet SER_OFFSET = `!f. summable f ==> !k. (\\n. f(n + k)) sums (suminf f - sum(0,k) f)`;;\n\nlet SER_OFFSET_REV = `!f k. summable(\\n. f(n + k)) ==>\n f sums (sum(0,k) f) + suminf (\\n. f(n + k))`;;\n\nlet SER_POS_LT_PAIR = `!f n. summable f /\\\n (!d. &0 < (f(n + (2 * d))) +\n f(n + ((2 * d) + 1)))\n ==> sum(0,n) f < suminf f`;;\n\nlet SER_ADD = `!x x0 y y0. x sums x0 /\\ y sums y0 ==> (\\n. x(n) + y(n)) sums (x0 + y0)`;;\n\nlet SER_CMUL = `!x x0 c. x sums x0 ==> (\\n. c * x(n)) sums (c * x0)`;;\n\nlet SER_NEG = `!x x0. x sums x0 ==> (\\n. --(x n)) sums --x0`;;\n\nlet SER_SUB = `!x x0 y y0. x sums x0 /\\ y sums y0 ==> (\\n. x(n) - y(n)) sums (x0 - y0)`;;\n\nlet SER_CDIV = `!x x0 c. x sums x0 ==> (\\n. x(n) / c) sums (x0 / c)`;;\n\nlet SER_CAUCHY = `!f. summable f <=>\n !e. &0 < e ==> ?N. !m n. m >= N ==> abs(sum(m,n) f) < e`;;\n\nlet SER_ZERO = `!f. summable f ==> f --> &0`;;\n\nlet SER_COMPAR = `!f g. (?N. !n. n >= N ==> abs(f(n)) <= g(n)) /\\ summable g ==>\n summable f`;;\n\nlet SER_COMPARA = `!f g. (?N. !n. n >= N ==> abs(f(n)) <= g(n)) /\\ summable g ==>\n summable (\\k. abs(f k))`;;\n\nlet SER_LE = `!f g. (!n. f(n) <= g(n)) /\\ summable f /\\ summable g\n ==> suminf f <= suminf g`;;\n\nlet SER_LE2 = `!f g. (!n. abs(f n) <= g(n)) /\\ summable g ==>\n summable f /\\ suminf f <= suminf g`;;\n\nlet SER_ACONV = `!f. summable (\\n. abs(f n)) ==> summable f`;;\n\nlet SER_ABS = `!f. summable(\\n. abs(f n)) ==> abs(suminf f) <= suminf(\\n. abs(f n))`;;\n\nlet GP_FINITE = `!x. ~(x = &1) ==>\n !n. (sum(0,n) (\\n. x pow n) = ((x pow n) - &1) / (x - &1))`;;\n\nlet GP = `!x. abs(x) < &1 ==> (\\n. x pow n) sums inv(&1 - x)`;;\n\nlet ABS_NEG_LEMMA = `!c x y. c <= &0 ==> abs(x) <= c * abs(y) ==> (x = &0)`;;\n\nlet SER_RATIO = `!f c N. c < &1 /\\\n (!n. n >= N ==> abs(f(SUC n)) <= c * abs(f(n))) ==>\n summable f`;;\n\nlet SEQ_TRUNCATION = `!f l n b.\n f sums l /\\ (!m. abs(sum(n,m) f) <= b)\n ==> abs(l - sum(0,n) f) <= b`;;\n\nparse_as_infix (\"tends_real_real\",(12,\"right\"));;\n\nparse_as_infix (\"diffl\",(12,\"right\"));;\nparse_as_infix (\"contl\",(12,\"right\"));;\nparse_as_infix (\"differentiable\",(12,\"right\"));;\n\nlet tends_real_real = new_definition\n `(f tends_real_real l)(x0) <=>\n (f tends l)(mtop(mr1),tendsto(mr1,x0))`;;\n\noverride_interface (\"-->\",`(tends_real_real)`);;\n\nlet LIM = `!f y0 x0. (f --> y0)(x0) <=>\n !e. &0 < e ==>\n ?d. &0 < d /\\ !x. &0 < abs(x - x0) /\\ abs(x - x0) < d ==>\n abs(f(x) - y0) < e`;;\n\nlet LIM_CONST = `!k x. ((\\x. k) --> k)(x)`;;\n\nlet LIM_ADD = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) ==>\n ((\\x. f(x) + g(x)) --> (l + m))(x)`;;\n\nlet LIM_MUL = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) ==>\n ((\\x. f(x) * g(x)) --> (l * m))(x)`;;\n\nlet LIM_NEG = `!f l. (f --> l)(x) <=> ((\\x. --(f(x))) --> --l)(x)`;;\n\nlet LIM_INV = `!f l. (f --> l)(x) /\\ ~(l = &0) ==>\n ((\\x. inv(f(x))) --> inv l)(x)`;;\n\nlet LIM_SUB = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) ==>\n ((\\x. f(x) - g(x)) --> (l - m))(x)`;;\n\nlet LIM_DIV = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) /\\ ~(m = &0) ==>\n ((\\x. f(x) / g(x)) --> (l / m))(x)`;;\n\nlet LIM_NULL = `!f l x. (f --> l)(x) <=> ((\\x. f(x) - l) --> &0)(x)`;;\n\nlet LIM_SUM = `!f l m n x.\n (!r. m <= r /\\ r < m + n ==> (f r --> l r)(x))\n ==> ((\\x. sum(m,n) (\\r. f r x)) --> sum(m,n) l)(x)`;;\n\nlet LIM_X = `!x0. ((\\x. x) --> x0)(x0)`;;\n\nlet LIM_UNIQ = `!f l m x. (f --> l)(x) /\\ (f --> m)(x) ==> (l = m)`;;\n\nlet LIM_EQUAL = `!f g l x0. (!x. ~(x = x0) ==> (f x = g x)) ==>\n ((f --> l)(x0) <=> (g --> l)(x0))`;;\n\nlet LIM_TRANSFORM = `!f g x0 l. ((\\x. f(x) - g(x)) --> &0)(x0) /\\ (g --> l)(x0)\n ==> (f --> l)(x0)`;;\n\nlet diffl = new_definition\n `(f diffl l)(x) <=> ((\\h. (f(x+h) - f(x)) / h) --> l)(&0)`;;\n\nlet contl = new_definition\n `f contl x <=> ((\\h. f(x + h)) --> f(x))(&0)`;;\n\nlet differentiable = new_definition\n `f differentiable x <=> ?l. (f diffl l)(x)`;;\n\nlet DIFF_UNIQ = `!f l m x. (f diffl l)(x) /\\ (f diffl m)(x) ==> (l = m)`;;\n\nlet DIFF_CONT = `!f l x. (f diffl l)(x) ==> f contl x`;;\n\nlet CONTL_LIM = `!f x. f contl x <=> (f --> f(x))(x)`;;\n\nlet CONT_X = `!x. (\\x. x) contl x`;;\n\nlet CONT_CONST = `!x. (\\x. k) contl x`;;\n\nlet CONT_ADD = `!x. f contl x /\\ g contl x ==> (\\x. f(x) + g(x)) contl x`;;\n\nlet CONT_MUL = `!x. f contl x /\\ g contl x ==> (\\x. f(x) * g(x)) contl x`;;\n\nlet CONT_NEG = `!x. f contl x ==> (\\x. --(f(x))) contl x`;;\n\nlet CONT_INV = `!x. f contl x /\\ ~(f x = &0) ==> (\\x. inv(f(x))) contl x`;;\n\nlet CONT_SUB = `!x. f contl x /\\ g contl x ==> (\\x. f(x) - g(x)) contl x`;;\n\nlet CONT_DIV = `!x. f contl x /\\ g contl x /\\ ~(g x = &0) ==>\n (\\x. f(x) / g(x)) contl x`;;\n\nlet CONT_ABS = `!f x. f contl x ==> (\\x. abs(f x)) contl x`;;\n\nlet CONT_COMPOSE = `!f g x. f contl x /\\ g contl (f x) ==> (\\x. g(f x)) contl x`;;\n\nlet IVT = `!f a b y. a <= b /\\\n (f(a) <= y /\\ y <= f(b)) /\\\n (!x. a <= x /\\ x <= b ==> f contl x)\n ==> (?x. a <= x /\\ x <= b /\\ (f(x) = y))`;;\n\nlet IVT2 = `!f a b y. (a <= b) /\\ (f(b) <= y /\\ y <= f(a)) /\\\n (!x. a <= x /\\ x <= b ==> f contl x) ==>\n ?x. a <= x /\\ x <= b /\\ (f(x) = y)`;;\n\nlet DIFF_CONST = `!k x. ((\\x. k) diffl &0)(x)`;;\n\nlet DIFF_ADD = `!f g l m x. (f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) + g(x)) diffl (l + m))(x)`;;\n\nlet DIFF_MUL = `!f g l m x. (f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) * g(x)) diffl ((l * g(x)) + (m * f(x))))(x)`;;\n\nlet DIFF_CMUL = `!f c l x. (f diffl l)(x) ==> ((\\x. c * f(x)) diffl (c * l))(x)`;;\n\nlet DIFF_NEG = `!f l x. (f diffl l)(x) ==> ((\\x. --(f x)) diffl --l)(x)`;;\n\nlet DIFF_SUB = `!f g l m x. (f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) - g(x)) diffl (l - m))(x)`;;\n\nlet DIFF_CARAT = `!f l x. (f diffl l)(x) <=>\n ?g. (!z. f(z) - f(x) = g(z) * (z - x)) /\\ g contl x /\\ (g(x) = l)`;;\n\nlet DIFF_CHAIN = `!f g l m x.\n (f diffl l)(g x) /\\ (g diffl m)(x) ==> ((\\x. f(g x)) diffl (l * m))(x)`;;\n\nlet DIFF_X = `!x. ((\\x. x) diffl &1)(x)`;;\n\nlet DIFF_POW = `!n x. ((\\x. x pow n) diffl (&n * (x pow (n - 1))))(x)`;;\n\nlet DIFF_XM1 = `!x. ~(x = &0) ==> ((\\x. inv(x)) diffl (--(inv(x) pow 2)))(x)`;;\n\nlet DIFF_INV = `!f l x. (f diffl l)(x) /\\ ~(f(x) = &0) ==>\n ((\\x. inv(f x)) diffl --(l / (f(x) pow 2)))(x)`;;\n\nlet DIFF_DIV = `!f g l m. (f diffl l)(x) /\\ (g diffl m)(x) /\\ ~(g(x) = &0) ==>\n ((\\x. f(x) / g(x)) diffl (((l * g(x)) - (m * f(x))) / (g(x) pow 2)))(x)`;;\n\nlet DIFF_SUM = `!f f' m n x. (!r. m <= r /\\ r < (m + n)\n ==> ((\\x. f r x) diffl (f' r x))(x))\n ==> ((\\x. sum(m,n)(\\n. f n x)) diffl (sum(m,n) (\\r. f' r x)))(x)`;;\n\nlet CONT_BOUNDED = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. !x. a <= x /\\ x <= b ==> f(x) <= M`;;\n\nlet CONT_BOUNDED_ABS = `!f a b. (!x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. !x. a <= x /\\ x <= b ==> abs(f(x)) <= M`;;\n\nlet CONT_HASSUP = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. (!x. a <= x /\\ x <= b ==> f(x) <= M) /\\\n (!N. N < M ==> ?x. a <= x /\\ x <= b /\\ N < f(x))`;;\n\nlet CONT_ATTAINS = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. (!x. a <= x /\\ x <= b ==> f(x) <= M) /\\\n (?x. a <= x /\\ x <= b /\\ (f(x) = M))`;;\n\nlet CONT_ATTAINS2 = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. (!x. a <= x /\\ x <= b ==> M <= f(x)) /\\\n (?x. a <= x /\\ x <= b /\\ (f(x) = M))`;;\n\nlet CONT_ATTAINS_ALL = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?L M. (!x. a <= x /\\ x <= b ==> L <= f(x) /\\ f(x) <= M) /\\\n !y. L <= y /\\ y <= M ==> ?x. a <= x /\\ x <= b /\\ (f(x) = y)`;;\n\nlet DIFF_LINC = `!f x l. (f diffl l)(x) /\\ &0 < l ==>\n ?d. &0 < d /\\ !h. &0 < h /\\ h < d ==> f(x) < f(x + h)`;;\n\nlet DIFF_LDEC = `!f x l. (f diffl l)(x) /\\ l < &0 ==>\n ?d. &0 < d /\\ !h. &0 < h /\\ h < d ==> f(x) < f(x - h)`;;\n\nlet DIFF_LMAX = `!f x l. (f diffl l)(x) /\\\n (?d. &0 < d /\\ (!y. abs(x - y) < d ==> f(y) <= f(x))) ==> (l = &0)`;;\n\nlet DIFF_LMIN = `!f x l. (f diffl l)(x) /\\\n (?d. &0 < d /\\ (!y. abs(x - y) < d ==> f(x) <= f(y))) ==> (l = &0)`;;\n\nlet DIFF_LCONST = `!f x l. (f diffl l)(x) /\\\n (?d. &0 < d /\\ (!y. abs(x - y) < d ==> (f(y) = f(x)))) ==> (l = &0)`;;\n\nlet INTERVAL_LEMMA_LT = `!a b x. a < x /\\ x < b ==>\n ?d. &0 < d /\\ !y. abs(x - y) < d ==> a < y /\\ y < b`;;\n\nlet INTERVAL_LEMMA = `!a b x. a < x /\\ x < b ==>\n ?d. &0 < d /\\ !y. abs(x - y) < d ==> a <= y /\\ y <= b`;;\n\nlet ROLLE = `!f a b. a < b /\\\n (f(a) = f(b)) /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> f differentiable x)\n ==> ?z. a < z /\\ z < b /\\ (f diffl &0)(z)`;;\n\nlet MVT_LEMMA = `!(f:real->real) a b.\n (\\x. f(x) - (((f(b) - f(a)) / (b - a)) * x))(a) =\n (\\x. f(x) - (((f(b) - f(a)) / (b - a)) * x))(b)`;;\n\nlet MVT = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> f differentiable x)\n ==> ?l z. a < z /\\ z < b /\\ (f diffl l)(z) /\\\n (f(b) - f(a) = (b - a) * l)`;;\n\nlet MVT_ALT = `!f f' a b.\n a < b /\\ (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x))\n ==> ?z. a < z /\\ z < b /\\ (f b - f a = (b - a) * f'(z))`;;\n\nlet DIFF_ISCONST_END = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> (f diffl &0)(x))\n ==> (f b = f a)`;;\n\nlet DIFF_ISCONST = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> (f diffl &0)(x))\n ==> !x. a <= x /\\ x <= b ==> (f x = f a)`;;\n\nlet DIFF_ISCONST_END_SIMPLE = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl &0)(x))\n ==> (f b = f a)`;;\n\nlet DIFF_ISCONST_ALL = `!f x y. (!x. (f diffl &0)(x)) ==> (f(x) = f(y))`;;\n\nlet INTERVAL_ABS = REAL_ARITH\n `!x z d. (x - d) <= z /\\ z <= (x + d) <=> abs(z - x) <= d`;;\n\nlet CONT_INJ_LEMMA = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) ==>\n ~(!z. abs(z - x) <= d ==> f(z) <= f(x))`;;\n\nlet CONT_INJ_LEMMA2 = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) ==>\n ~(!z. abs(z - x) <= d ==> f(x) <= f(z))`;;\n\nlet CONT_INJ_RANGE = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) ==>\n ?e. &0 < e /\\\n (!y. abs(y - f(x)) <= e ==> ?z. abs(z - x) <= d /\\ (f z = y))`;;\n\nlet CONT_INVERSE = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z)\n ==> g contl (f x)`;;\n\nlet DIFF_INVERSE = `!f g l x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) /\\\n (f diffl l)(x) /\\\n ~(l = &0)\n ==> (g diffl (inv l))(f x)`;;\n\nlet DIFF_INVERSE_LT = `!f g l x d. &0 < d /\\\n (!z. abs(z - x) < d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) < d ==> f contl z) /\\\n (f diffl l)(x) /\\\n ~(l = &0)\n ==> (g diffl (inv l))(f x)`;;\n\nlet IVT_DERIVATIVE_0 = `!f f' a b.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n f'(a) > &0 /\\ f'(b) < &0\n ==> ?z. a < z /\\ z < b /\\ (f'(z) = &0)`;;\n\nlet IVT_DERIVATIVE_POS = `!f f' a b y.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n f'(a) > y /\\ f'(b) < y\n ==> ?z. a < z /\\ z < b /\\ (f'(z) = y)`;;\n\nlet IVT_DERIVATIVE_NEG = `!f f' a b y.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n f'(a) < y /\\ f'(b) > y\n ==> ?z. a < z /\\ z < b /\\ (f'(z) = y)`;;\n\nlet SEQ_CONT_UNIFORM = `!s f x0. (!e. &0 < e\n ==> ?N d. &0 < d /\\\n !x n. abs(x - x0) < d /\\ n >= N\n ==> abs(s n x - f(x)) < e) /\\\n (?N:num. !n. n >= N ==> (s n) contl x0)\n ==> f contl x0`;;\n\nlet SER_COMPARA_UNIFORM = `!s x0 g.\n (?N d. &0 < d /\\\n !n x. abs(x - x0) < d /\\ n >= N\n ==> abs(s x n) <= g n) /\\ summable g\n ==> ?f d. &0 < d /\\\n !e. &0 < e\n ==> ?N. !x n. abs(x - x0) < d /\\ n >= N\n ==> abs(sum(0,n) (s x) - f(x)) < e`;;\n\nlet SER_COMPARA_UNIFORM_WEAK = `!s x0 g.\n (?N d. &0 < d /\\\n !n x. abs(x - x0) < d /\\ n >= N\n ==> abs(s x n) <= g n) /\\ summable g\n ==> ?f. !e. &0 < e\n ==> ?N d. &0 < d /\\\n !x n. abs(x - x0) < d /\\ n >= N\n ==> abs(sum(0,n) (s x) - f(x)) < e`;;\n\nlet CONTL = `!f x. f contl x <=>\n !e. &0 < e ==> ?d. &0 < d /\\ !x'. abs(x' - x) < d\n ==> abs(f(x') - f(x)) < e`;;\n\nlet CONTL_SEQ = `!f x l. f contl l /\\ x tends_num_real l\n\n ==> (\\n. f(x n)) tends_num_real f(l)`;;\n\nlet SUP_INTERVAL = `!P a b.\n (?x. a <= x /\\ x <= b /\\ P x)\n ==> ?s. a <= s /\\ s <= b /\\\n !y. y < s <=> (?x. a <= x /\\ x <= b /\\ P x /\\ y < x)`;;\n\nlet CONT_UNIFORM = `!f a b. a <= b /\\ (!x. a <= x /\\ x <= b ==> f contl x)\n ==> !e. &0 < e ==> ?d. &0 < d /\\\n !x y. a <= x /\\ x <= b /\\\n a <= y /\\ y <= b /\\\n abs(x - y) < d\n ==> abs(f(x) - f(y)) < e`;;\n\nlet CONT_UNIFORM_STRONG = `!f a b. (!x. a <= x /\\ x <= b ==> f contl x)\n ==> !e. &0 < e\n ==> ?d. &0 < d /\\\n !x y. (a <= x /\\ x <= b \\/ a <= y /\\ y <= b) /\\\n abs(x - y) < d\n ==> abs(f(x) - f(y)) < e`;;\n\nremove_interface \"-->\";;" }, { "theorem_id": 59, "title": "075_the_mean_value_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Derivative\\\n\ntheory Derivative\n imports\n Bounded_Linear_Function\n Line_Segment\n Convex_Euclidean_Space\nbegin\n\ndeclare bounded_linear_inner_left [intro]\n\ndeclare has_derivative_bounded_linear[dest]\n\nsubsection \\Derivatives\\\n\nlemma has_derivative_add_const:\n \"(f has_derivative f') net \\ ((\\x. f x + c) has_derivative f') net\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Derivative with composed bilinear function\\\n\ntext \\More explicit epsilon-delta forms.\\\n\nproposition has_derivative_within':\n \"(f has_derivative f')(at x within s) \\\n bounded_linear f' \\\n (\\e>0. \\d>0. \\x'\\s. 0 < norm (x' - x) \\ norm (x' - x) < d \\\n norm (f x' - f x - f'(x' - x)) / norm (x' - x) < e)\"\n by sorry\n\nlemma has_derivative_at':\n \"(f has_derivative f') (at x) \n \\ bounded_linear f' \\\n (\\e>0. \\d>0. \\x'. 0 < norm (x' - x) \\ norm (x' - x) < d \\\n norm (f x' - f x - f'(x' - x)) / norm (x' - x) < e)\"\n by sorry\n\nlemma has_derivative_componentwise_within:\n \"(f has_derivative f') (at a within S) \\\n (\\i \\ Basis. ((\\x. f x \\ i) has_derivative (\\x. f' x \\ i)) (at a within S))\"\n by sorry\n\nlemma has_derivative_at_withinI:\n \"(f has_derivative f') (at x) \\ (f has_derivative f') (at x within s)\"\n by sorry\n\nlemma has_derivative_right:\n fixes f :: \"real \\ real\"\n and y :: \"real\"\n shows \"(f has_derivative (" }, { "theorem_id": 59, "title": "075_the_mean_value_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Sébastien Gouëzel\n-/\nmodule\n\npublic import Mathlib.Analysis.Calculus.Deriv.AffineMap\npublic import Mathlib.Analysis.Calculus.Deriv.Comp\npublic import Mathlib.Analysis.Calculus.Deriv.Mul\npublic import Mathlib.Analysis.Calculus.Deriv.Slope\npublic import Mathlib.Analysis.Calculus.LocalExtr.Rolle\npublic import Mathlib.Analysis.Normed.Group.AddTorsor\npublic import Mathlib.Analysis.RCLike.Basic\n/-!\n# Mean value theorem\n\nIn this file we prove Cauchy's and Lagrange's mean value theorems, and deduce some corollaries.\n\nCauchy's mean value theorem says that for two functions `f` and `g`\nthat are continuous on `[a, b]` and are differentiable on `(a, b)`,\nthere exists a point `c ∈ (a, b)` such that `f' c / g' c = (f b - f a) / (g b - g a)`.\nWe formulate this theorem with both sides multiplied by the denominators,\nsee `exists_ratio_hasDerivAt_eq_ratio_slope`,\nin order to avoid auxiliary conditions like `g' c ≠ 0`.\n\nLagrange's mean value theorem, see `exists_hasDerivAt_eq_slope`,\nsays that for a function `f` that is continuous on `[a, b]` and is differentiable on `(a, b)`,\nthere exists a point `c ∈ (a, b)` such that `f' c = (f b - f a) / (b - a)`.\n\nLagrange's MVT implies that `(f b - f a) / (b - a) > C`\nprovided that `f' c > C` for all `c ∈ (a, b)`, see `mul_sub_lt_image_sub_of_lt_deriv`,\nand other theorems for `>` / `≥` / `<` / `≤`.\n\nIn case `C = 0`, we deduce that a function with a positive derivative is strictly monotone,\nsee `strictMonoOn_of_deriv_pos` and nearby theorems for other types of monotonicity.\n\nWe also prove that a real function whose derivative tends to infinity from the right at a point\nis not differentiable on the right at that point, and similarly differentiability on the left.\n\n## Main results\n\n\n* `exists_ratio_hasDerivAt_eq_ratio_slope` and `exists_ratio_deriv_eq_ratio_slope` :\n Cauchy's Mean Value Theorem.\n\n* `exists_hasDerivAt_eq_slope` and `exists_deriv_eq_slope` : Lagrange's Mean Value Theorem.\n\n* `domain_mvt` : Lagrange's Mean Value Theorem, applied to a segment in a convex domain.\n\n* `Convex.image_sub_lt_mul_sub_of_deriv_lt`, `Convex.mul_sub_lt_image_sub_of_lt_deriv`,\n `Convex.image_sub_le_mul_sub_of_deriv_le`, `Convex.mul_sub_le_image_sub_of_le_deriv`,\n if `∀ x, C (/≥) (f' x)`, then `C * (y - x) (/≥) (f y - f x)` whenever `x < y`.\n\n* `monotoneOn_of_deriv_nonneg`, `antitoneOn_of_deriv_nonpos`,\n `strictMono_of_deriv_pos`, `strictAnti_of_deriv_neg` :\n if the derivative of a function is non-negative/non-positive/positive/negative, then\n the function is monotone/antitone/strictly monotone/strictly monotonically\n decreasing.\n\n* `convexOn_of_deriv`, `convexOn_of_deriv2_nonneg` : if the derivative of a function\n is increasing or its second derivative is nonnegative, then the original function is convex.\n\n-/\n\npublic section\n\nopen Set Function Filter\nopen scoped Topology\n\n/-! ### Functions `[a, b] → ℝ`. -/\n\nsection Interval\n\n-- Declare all variables here to make sure they come in a correct order\nvariable (f f' : ℝ → ℝ) {a b : ℝ} (hab : a < b) (hfc : ContinuousOn f (Icc a b))\n (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x) (hfd : DifferentiableOn ℝ f (Ioo a b))\n (g g' : ℝ → ℝ) (hgc : ContinuousOn g (Icc a b)) (hgg' : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x)\n (hgd : DifferentiableOn ℝ g (Ioo a b))\n\ninclude hab hfc hff' hgc hgg' in\n/-- Cauchy's **Mean Value Theorem**, `HasDerivAt` version. -/\ntheorem exists_ratio_hasDerivAt_eq_ratio_slope :\n ∃ c ∈ Ioo a b, (g b - g a) * f' c = (f b - f a) * g' c := by sorry\ntheorem exists_ratio_hasDerivAt_eq_ratio_slope' {lfa lga lfb lgb : ℝ}\n (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x)\n (hfa : Tendsto f (𝓝[>] a) (𝓝 lfa)) (hga : Tendsto g (𝓝[>] a) (𝓝 lga))\n (hfb : Tendsto f (𝓝[<] b) (𝓝 lfb)) (hgb : Tendsto g (𝓝[<] b) (𝓝 lgb)) :\n ∃ c ∈ Ioo a b, (lgb - lga) * f' c = (lfb - lfa) * g' c := by sorry\ntheorem exists_hasDerivAt_eq_slope : ∃ c ∈ Ioo a b, f' c = (f b - f a) / (b - a) := by sorry\ntheorem exists_ratio_deriv_eq_ratio_slope :\n ∃ c ∈ Ioo a b, (g b - g a) * deriv f c = (f b - f a) * deriv g c :=\n exists_ratio_hasDerivAt_eq_ratio_slope f (deriv f) hab hfc\n (fun x hx => ((hfd x hx).differentiableAt <| IsOpen.mem_nhds isOpen_Ioo hx).hasDerivAt) g\n (deriv g) hgc fun x hx =>\n ((hgd x hx).differentiableAt <| IsOpen.mem_nhds isOpen_Ioo hx).hasDerivAt\n\ninclude hab in\n/-- Cauchy's Mean Value Theorem, extended `deriv` version. -/\ntheorem exists_ratio_deriv_eq_ratio_slope' {lfa lga lfb lgb : ℝ}\n (hdf : DifferentiableOn ℝ f <| Ioo a b) (hdg : DifferentiableOn ℝ g <| Ioo a b)\n (hfa : Tendsto f (𝓝[>] a) (𝓝 lfa)) (hga : Tendsto g (𝓝[>] a) (𝓝 lga))\n (hfb : Tendsto f (𝓝[<] b) (𝓝 lfb)) (hgb : Tendsto g (𝓝[<] b) (𝓝 lgb)) :\n ∃ c ∈ Ioo a b, (lgb - lga) * deriv f c = (lfb - lfa) * deriv g c :=\n exists_ratio_hasDerivAt_eq_ratio_slope' _ _ hab _ _\n (fun x hx => ((hdf x hx).differentiableAt <| Ioo_mem_nhds hx.1 hx.2).hasDerivAt)\n (fun x hx => ((hdg x hx).differentiableAt <| Ioo_mem_nhds hx.1 hx.2).hasDerivAt) hfa hga hfb hgb\n\ninclude hab hfc hfd in\n/-- Lagrange's **Mean Value Theorem**, `deriv` version. -/\ntheorem exists_deriv_eq_slope : ∃ c ∈ Ioo a b, deriv f c = (f b - f a) / (b - a) :=\n exists_hasDerivAt_eq_slope f (deriv f) hab hfc fun x hx =>\n ((hfd x hx).differentiableAt <| IsOpen.mem_nhds isOpen_Ioo hx).hasDerivAt\n\ninclude hab hfc hfd in\n/-- Lagrange's **Mean Value Theorem**, `deriv` version. -/\ntheorem exists_deriv_eq_slope' : ∃ c ∈ Ioo a b, deriv f c = slope f a b := by sorry\ntheorem not_differentiableWithinAt_of_deriv_tendsto_atTop_Ioi (f : ℝ → ℝ) {a : ℝ}\n (hf : Tendsto (deriv f) (𝓝[>] a) atTop) : ¬ DifferentiableWithinAt ℝ f (Ioi a) a := by sorry\ntheorem not_differentiableWithinAt_of_deriv_tendsto_atBot_Ioi (f : ℝ → ℝ) {a : ℝ}\n (hf : Tendsto (deriv f) (𝓝[>] a) atBot) : ¬ DifferentiableWithinAt ℝ f (Ioi a) a := by sorry\ntheorem not_differentiableWithinAt_of_deriv_tendsto_atBot_Iio (f : ℝ → ℝ) {a : ℝ}\n (hf : Tendsto (deriv f) (𝓝[<] a) atBot) : ¬ DifferentiableWithinAt ℝ f (Iio a) a := by sorry\ntheorem not_differentiableWithinAt_of_deriv_tendsto_atTop_Iio (f : ℝ → ℝ) {a : ℝ}\n (hf : Tendsto (deriv f) (𝓝[<] a) atTop) : ¬ DifferentiableWithinAt ℝ f (Iio a) a := by sorry\nend Interval\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `C < f'`, then\n`f` grows faster than `C * x` on `D`, i.e., `C * (y - x) < f y - f x` whenever `x, y ∈ D`,\n`x < y`. -/\ntheorem Convex.mul_sub_lt_image_sub_of_lt_deriv {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : DifferentiableOn ℝ f (interior D)) {C}\n (hf'_gt : ∀ x ∈ interior D, C < deriv f x) :\n ∀ᵉ (x ∈ D) (y ∈ D), x < y → C * (y - x) < f y - f x := by sorry\ntheorem mul_sub_lt_image_sub_of_lt_deriv {f : ℝ → ℝ} (hf : Differentiable ℝ f) {C}\n (hf'_gt : ∀ x, C < deriv f x) ⦃x y⦄ (hxy : x < y) : C * (y - x) < f y - f x :=\n convex_univ.mul_sub_lt_image_sub_of_lt_deriv hf.continuous.continuousOn hf.differentiableOn\n (fun x _ => hf'_gt x) x trivial y trivial hxy\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `C ≤ f'`, then\n`f` grows at least as fast as `C * x` on `D`, i.e., `C * (y - x) ≤ f y - f x` whenever `x, y ∈ D`,\n`x ≤ y`. -/\ntheorem Convex.mul_sub_le_image_sub_of_le_deriv {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : DifferentiableOn ℝ f (interior D)) {C}\n (hf'_ge : ∀ x ∈ interior D, C ≤ deriv f x) :\n ∀ᵉ (x ∈ D) (y ∈ D), x ≤ y → C * (y - x) ≤ f y - f x := by sorry\ntheorem mul_sub_le_image_sub_of_le_deriv {f : ℝ → ℝ} (hf : Differentiable ℝ f) {C}\n (hf'_ge : ∀ x, C ≤ deriv f x) ⦃x y⦄ (hxy : x ≤ y) : C * (y - x) ≤ f y - f x :=\n convex_univ.mul_sub_le_image_sub_of_le_deriv hf.continuous.continuousOn hf.differentiableOn\n (fun x _ => hf'_ge x) x trivial y trivial hxy\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `f' < C`, then\n`f` grows slower than `C * x` on `D`, i.e., `f y - f x < C * (y - x)` whenever `x, y ∈ D`,\n`x < y`. -/\ntheorem Convex.image_sub_lt_mul_sub_of_deriv_lt {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : DifferentiableOn ℝ f (interior D)) {C}\n (lt_hf' : ∀ x ∈ interior D, deriv f x < C) (x : ℝ) (hx : x ∈ D) (y : ℝ) (hy : y ∈ D)\n (hxy : x < y) : f y - f x < C * (y - x) := by sorry\ntheorem image_sub_lt_mul_sub_of_deriv_lt {f : ℝ → ℝ} (hf : Differentiable ℝ f) {C}\n (lt_hf' : ∀ x, deriv f x < C) ⦃x y⦄ (hxy : x < y) : f y - f x < C * (y - x) :=\n convex_univ.image_sub_lt_mul_sub_of_deriv_lt hf.continuous.continuousOn hf.differentiableOn\n (fun x _ => lt_hf' x) x trivial y trivial hxy\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `f' ≤ C`, then\n`f` grows at most as fast as `C * x` on `D`, i.e., `f y - f x ≤ C * (y - x)` whenever `x, y ∈ D`,\n`x ≤ y`. -/\ntheorem Convex.image_sub_le_mul_sub_of_deriv_le {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : DifferentiableOn ℝ f (interior D)) {C}\n (le_hf' : ∀ x ∈ interior D, deriv f x ≤ C) (x : ℝ) (hx : x ∈ D) (y : ℝ) (hy : y ∈ D)\n (hxy : x ≤ y) : f y - f x ≤ C * (y - x) := by sorry\ntheorem image_sub_le_mul_sub_of_deriv_le {f : ℝ → ℝ} (hf : Differentiable ℝ f) {C}\n (le_hf' : ∀ x, deriv f x ≤ C) ⦃x y⦄ (hxy : x ≤ y) : f y - f x ≤ C * (y - x) :=\n convex_univ.image_sub_le_mul_sub_of_deriv_le hf.continuous.continuousOn hf.differentiableOn\n (fun x _ => le_hf' x) x trivial y trivial hxy\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `f'` is positive, then\n`f` is a strictly monotone function on `D`.\nNote that we don't require differentiability explicitly as it already implied by the derivative\nbeing strictly positive. -/\ntheorem strictMonoOn_of_deriv_pos {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : ∀ x ∈ interior D, 0 < deriv f x) : StrictMonoOn f D := by sorry\ntheorem strictMono_of_deriv_pos {f : ℝ → ℝ} (hf' : ∀ x, 0 < deriv f x) : StrictMono f :=\n strictMonoOn_univ.1 <| strictMonoOn_of_deriv_pos convex_univ (fun z _ =>\n (differentiableAt_of_deriv_ne_zero (hf' z).ne').differentiableWithinAt.continuousWithinAt)\n fun x _ => hf' x\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `f'` is strictly positive,\nthen `f` is a strictly monotone function on `D`. -/\nlemma strictMonoOn_of_hasDerivWithinAt_pos {D : Set ℝ} (hD : Convex ℝ D) {f f' : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : ∀ x ∈ interior D, HasDerivWithinAt f (f' x) (interior D) x)\n (hf'₀ : ∀ x ∈ interior D, 0 < f' x) : StrictMonoOn f D :=\n strictMonoOn_of_deriv_pos hD hf fun x hx ↦ by\n rw [deriv_eqOn isOpen_interior hf' hx]; exact hf'₀ _ hx\n\n/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is strictly positive, then\n`f` is a strictly monotone function. -/\nlemma strictMono_of_hasDerivAt_pos {f f' : ℝ → ℝ} (hf : ∀ x, HasDerivAt f (f' x) x)\n (hf' : ∀ x, 0 < f' x) : StrictMono f :=\n strictMono_of_deriv_pos fun x ↦ by rw [(hf _).deriv]; exact hf' _\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `f'` is nonnegative, then\n`f` is a monotone function on `D`. -/\ntheorem monotoneOn_of_deriv_nonneg {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : DifferentiableOn ℝ f (interior D))\n (hf'_nonneg : ∀ x ∈ interior D, 0 ≤ deriv f x) : MonotoneOn f D := fun x hx y hy hxy => by\n simpa only [zero_mul, sub_nonneg] using\n hD.mul_sub_le_image_sub_of_le_deriv hf hf' hf'_nonneg x hx y hy hxy\n\n/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is nonnegative, then\n`f` is a monotone function. -/\ntheorem monotone_of_deriv_nonneg {f : ℝ → ℝ} (hf : Differentiable ℝ f) (hf' : ∀ x, 0 ≤ deriv f x) :\n Monotone f :=\n monotoneOn_univ.1 <|\n monotoneOn_of_deriv_nonneg convex_univ hf.continuous.continuousOn hf.differentiableOn fun x _ =>\n hf' x\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `f'` is nonnegative, then\n`f` is a monotone function on `D`. -/\nlemma monotoneOn_of_hasDerivWithinAt_nonneg {D : Set ℝ} (hD : Convex ℝ D) {f f' : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : ∀ x ∈ interior D, HasDerivWithinAt f (f' x) (interior D) x)\n (hf'₀ : ∀ x ∈ interior D, 0 ≤ f' x) : MonotoneOn f D :=\n monotoneOn_of_deriv_nonneg hD hf (fun _ hx ↦ (hf' _ hx).differentiableWithinAt) fun x hx ↦ by\n rw [deriv_eqOn isOpen_interior hf' hx]; exact hf'₀ _ hx\n\n/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is nonnegative, then\n`f` is a monotone function. -/\nlemma monotone_of_hasDerivAt_nonneg {f f' : ℝ → ℝ} (hf : ∀ x, HasDerivAt f (f' x) x)\n (hf' : 0 ≤ f') : Monotone f :=\n monotone_of_deriv_nonneg (fun _ ↦ (hf _).differentiableAt) fun x ↦ by\n rw [(hf _).deriv]; exact hf' _\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `f'` is negative, then\n`f` is a strictly antitone function on `D`. -/\ntheorem strictAntiOn_of_deriv_neg {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : ∀ x ∈ interior D, deriv f x < 0) : StrictAntiOn f D :=\n fun x hx y => by\n simpa only [zero_mul, sub_lt_zero] using\n hD.image_sub_lt_mul_sub_of_deriv_lt hf\n (fun z hz => (differentiableAt_of_deriv_ne_zero (hf' z hz).ne).differentiableWithinAt) hf' x\n hx y\n\n/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is negative, then\n`f` is a strictly antitone function.\nNote that we don't require differentiability explicitly as it already implied by the derivative\nbeing strictly negative. -/\ntheorem strictAnti_of_deriv_neg {f : ℝ → ℝ} (hf' : ∀ x, deriv f x < 0) : StrictAnti f :=\n strictAntiOn_univ.1 <| strictAntiOn_of_deriv_neg convex_univ\n (fun z _ =>\n (differentiableAt_of_deriv_ne_zero (hf' z).ne).differentiableWithinAt.continuousWithinAt)\n fun x _ => hf' x\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `f'` is strictly positive,\nthen `f` is a strictly monotone function on `D`. -/\nlemma strictAntiOn_of_hasDerivWithinAt_neg {D : Set ℝ} (hD : Convex ℝ D) {f f' : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : ∀ x ∈ interior D, HasDerivWithinAt f (f' x) (interior D) x)\n (hf'₀ : ∀ x ∈ interior D, f' x < 0) : StrictAntiOn f D :=\n strictAntiOn_of_deriv_neg hD hf fun x hx ↦ by\n rw [deriv_eqOn isOpen_interior hf' hx]; exact hf'₀ _ hx\n\n/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is strictly positive, then\n`f` is a strictly monotone function. -/\nlemma strictAnti_of_hasDerivAt_neg {f f' : ℝ → ℝ} (hf : ∀ x, HasDerivAt f (f' x) x)\n (hf' : ∀ x, f' x < 0) : StrictAnti f :=\n strictAnti_of_deriv_neg fun x ↦ by rw [(hf _).deriv]; exact hf' _\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `f'` is nonpositive, then\n`f` is an antitone function on `D`. -/\ntheorem antitoneOn_of_deriv_nonpos {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : DifferentiableOn ℝ f (interior D))\n (hf'_nonpos : ∀ x ∈ interior D, deriv f x ≤ 0) : AntitoneOn f D := fun x hx y hy hxy => by\n simpa only [zero_mul, sub_nonpos] using\n hD.image_sub_le_mul_sub_of_deriv_le hf hf' hf'_nonpos x hx y hy hxy\n\n/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is nonpositive, then\n`f` is an antitone function. -/\ntheorem antitone_of_deriv_nonpos {f : ℝ → ℝ} (hf : Differentiable ℝ f) (hf' : ∀ x, deriv f x ≤ 0) :\n Antitone f :=\n antitoneOn_univ.1 <|\n antitoneOn_of_deriv_nonpos convex_univ hf.continuous.continuousOn hf.differentiableOn fun x _ =>\n hf' x\n\n/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`\nof the real line. If `f` is differentiable on the interior of `D` and `f'` is nonpositive, then\n`f` is an antitone function on `D`. -/\nlemma antitoneOn_of_hasDerivWithinAt_nonpos {D : Set ℝ} (hD : Convex ℝ D) {f f' : ℝ → ℝ}\n (hf : ContinuousOn f D) (hf' : ∀ x ∈ interior D, HasDerivWithinAt f (f' x) (interior D) x)\n (hf'₀ : ∀ x ∈ interior D, f' x ≤ 0) : AntitoneOn f D :=\n antitoneOn_of_deriv_nonpos hD hf (fun _ hx ↦ (hf' _ hx).differentiableWithinAt) fun x hx ↦ by\n rw [deriv_eqOn isOpen_interior hf' hx]; exact hf'₀ _ hx\n\n/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is nonpositive, then `f` is an antitone\nfunction. -/\nlemma antitone_of_hasDerivAt_nonpos {f f' : ℝ → ℝ} (hf : ∀ x, HasDerivAt f (f' x) x)\n (hf' : f' ≤ 0) : Antitone f :=\n antitone_of_deriv_nonpos (fun _ ↦ (hf _).differentiableAt) fun x ↦ by\n rw [(hf _).deriv]; exact hf' _\n\n/-! ### Functions `f : E → ℝ` -/\n\nvariable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]\n\n/-- Lagrange's **Mean Value Theorem**, applied to convex domains. -/\ntheorem domain_mvt {f : E → ℝ} {s : Set E} {x y : E} {f' : E → StrongDual ℝ E}\n (hf : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hs : Convex ℝ s) (xs : x ∈ s) (ys : y ∈ s) :\n ∃ z ∈ segment ℝ x y, f y - f x = f' z (y - x) := by sorry\n" }, { "theorem_id": 59, "title": "075_the_mean_value_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Export CoRN.tactics.DiffTactics2.\nRequire Export CoRN.ftc.MoreFunctions.\n\nSection Rolle." }, { "theorem_id": 60, "title": "077_sum_of_kth_powers", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/binomial.ml\";;\nneeds \"Library/analysis.ml\";;\nneeds \"Library/transc.ml\";;\n\nprioritize_real();;\n\nlet SUM_DIFFS = `!a m n. m <= n + 1 ==> sum(m..n) (\\i. a(i + 1) - a(i)) = a(n + 1) - a(m)`;;\n\nlet DIFF_SUM = `!f f' a b.\n (!k. a <= k /\\ k <= b ==> ((\\x. f x k) diffl f'(k)) x)\n ==> ((\\x. sum(a..b) (f x)) diffl (sum(a..b) f')) x`;;\n\nlet bernoulli = define\n `(bernoulli 0 = &1) /\\\n (!n. bernoulli(SUC n) =\n --sum(0..n) (\\j. &(binom(n + 2,j)) * bernoulli j) / (&n + &2))`;;\n\nlet BERNOULLI = `!n. sum(0..n) (\\j. &(binom(n + 1,j)) * bernoulli j) =\n if n = 0 then &1 else &0`;;\n\nlet bernpoly = new_definition\n `bernpoly n x = sum(0..n) (\\k. &(binom(n,k)) * bernoulli k * x pow (n - k))`;;\n\nlet DIFF_BERNPOLY = `!n x. ((bernpoly (SUC n)) diffl (&(SUC n) * bernpoly n x)) x`;;\n\nlet INTEGRALS_EQ = `!f g. (!x. ((\\x. f(x) - g(x)) diffl &0) x) /\\ f(&0) = g(&0)\n ==> !x. f(x) = g(x)`;;\n\nlet RECURRENCE_BERNPOLY = `!n x. bernpoly n (x + &1) - bernpoly n x = &n * x pow (n - 1)`;;\n\nlet SUM_OF_POWERS = `!n. sum(0..n) (\\k. &k pow m) =\n (bernpoly(SUC m) (&n + &1) - bernpoly(SUC m) (&0)) / (&m + &1)`;;\n\nlet SUM_CONV =\n let pth = `sum(0..0) f = f 0 /\\ sum(0..SUC n) f = sum(0..n) f + f(SUC n)`;;\n\nlet BERNPOLY_CONV =\n let conv_1 =\n REWR_CONV bernpoly THENC SUM_CONV THENC\n TOP_DEPTH_CONV BETA_CONV THENC NUM_REDUCE_CONV\n and conv_3 =\n ONCE_DEPTH_CONV BINOM_CONV THENC REAL_POLY_CONV in\n fun tm ->\n let n = dest_small_numeral(lhand tm) in\n let conv_2 = GEN_REWRITE_CONV ONCE_DEPTH_CONV (BERNOULLIS n) in\n (conv_1 THENC conv_2 THENC conv_3) tm;;\n\nlet SOP_CONV =\n let pth = prove\n (`sum(0..n) (\\k. &k pow m) =\n (\\p. (p(&n + &1) - p(&0)) / (&m + &1))\n (\\x. bernpoly (SUC m) x)`,\n REWRITE_TAC[SUM_OF_POWERS]) in\n let conv_0 = REWR_CONV pth in\n REWR_CONV pth THENC\n RAND_CONV(ABS_CONV(LAND_CONV NUM_SUC_CONV THENC BERNPOLY_CONV)) THENC\n TOP_DEPTH_CONV BETA_CONV THENC\n REAL_POLY_CONV;;\n\nlet SOP_NUM_CONV =\n let pth = prove\n (`sum(0..n) (\\k. &k pow p) = &m ==> nsum(0..n) (\\k. k EXP p) = m`,\n REWRITE_TAC[REAL_OF_NUM_POW; GSYM REAL_OF_NUM_SUM_NUMSEG;\n REAL_OF_NUM_EQ]) in\n let rule_1 = PART_MATCH (lhs o rand) pth in\n fun tm ->\n let th1 = rule_1 tm in\n let th2 = SOP_CONV(lhs(lhand(concl th1))) in\n MATCH_MP th1 th2;;\n\ntime SOP_NUM_CONV `nsum(0..1000) (\\k. k EXP 10)`;;\n\ntime SOP_CONV `sum(0..n) (\\k. &k pow 0)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 1)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 2)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 3)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 4)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 5)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 6)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 7)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 8)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 9)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 10)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 11)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 12)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 13)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 14)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 15)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 16)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 17)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 18)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 19)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 20)`;;\ntime SOP_CONV `sum(0..n) (\\k. &k pow 21)`;;" }, { "theorem_id": 60, "title": "077_sum_of_kth_powers", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Bernoulli numbers\\\n\ntheory Bernoulli\nimports Complex_Main\nbegin\n\nsubsection \\Preliminaries\\\n \nlemma power_numeral_reduce: \"a ^ numeral n = a * a ^ pred_numeral n\"\n by sorry\n\nlemma fact_diff_Suc: \"n < Suc m \\ fact (Suc m - n) = of_nat (Suc m - n) * fact (m - n)\"\n by sorry\n\nlemma of_nat_binomial_Suc:\n assumes \"k \\ n\"\n shows \"(of_nat (Suc n choose k) :: 'a :: field_char_0) = \n of_nat (Suc n) / of_nat (Suc n - k) * of_nat (n choose k)\"\n by sorry\n\nlemma integrals_eq:\n assumes \"f 0 = g 0\"\n assumes \"\\ x. ((\\x. f x - g x) has_real_derivative 0) (at x)\"\n shows \"f x = g x\"\n by sorry\n\nlemma sum_diff: \"((\\i\\n::nat. f (i + 1) - f i)::'a::field) = f (n + 1) - f 0\"\n by sorry\n \nlemma Rats_sum: \"(\\x. x \\ A \\ f x \\ \\) \\ sum f A \\ \\\"\n by sorry\n\nsubsection \\Bernoulli Numbers and Bernoulli Polynomials\\\n\ndeclare sum.cong [fundef_cong]\n\nfun bernoulli :: \"nat \\ 'a :: field_char_0\"\nwhere\n \"bernoulli 0 = 1\"\n| \"bernoulli (Suc n) = (-1 / (of_nat n + 2)) * (\\k \\ n. (of_nat (n + 2 choose k) * bernoulli k))\"\n \ndeclare bernoulli.simps[simp del]\n \nlemmas bernoulli_0 [simp] = bernoulli.simps(1)\nlemmas bernoulli_Suc = bernoulli.simps(2)\nlemma bernoulli_1 [simp]: \"bernoulli 1 = -1/2\" by (simp add: bernoulli_Suc)\nlemma bernoulli_Suc_0 [simp]: \"bernoulli (Suc 0) = -1/2\" by (simp add: bernoulli_Suc)\n\nlemma of_rat_bernoulli: \"of_rat (bernoulli n) = bernoulli n\"\n by sorry\n\nlemma of_real_of_rat: \"of_real (of_rat x) = (of_rat x :: 'a :: real_field)\"\n by sorry\n\nlemma of_real_bernoulli: \"of_real (bernoulli n) = (bernoulli n :: 'a :: real_field)\"\n by sorry\n\ntext \\\n The ``normal'' Bernoulli numbers are the negative Bernoulli numbers $B_n^{-}$ we just defined\n (so called because $B_1^{-} = -\\frac{1}{2}$). There is also another convention, the \n positive Bernoulli numbers $B_n^{+}$, which differ from the negative ones only in that \n $B_1^{+} = \\frac{1}{2}$. Both conventions have their justification, since a number of theorems \n are easier to state with one than the other.\n\\\ndefinition bernoulli' :: \"nat \\ 'a :: field_char_0\" where\n \"bernoulli' n = (if n = 1 then 1/2 else bernoulli n)\"\n \nlemma bernoulli'_0 [simp]: \"bernoulli' 0 = 1\" by (simp add: bernoulli'_def)\n \nlemma bernoulli'_1 [simp]: \"bernoulli' (Suc 0) = 1/2\"\n by sorry\n\nlemma bernoulli_conv_bernoulli': \"n \\ 1 \\ bernoulli n = bernoulli' n\"\n by sorry\n \nlemma bernoulli'_conv_bernoulli: \"n \\ 1 \\ bernoulli' n = bernoulli n\"\n by sorry\n \nlemma bernoulli_conv_bernoulli'_if: \n \"n \\ 1 \\ bernoulli n = (if n = 1 then -1/2 else bernoulli' n)\"\n by sorry\n\nlemma of_rat_bernoulli': \"of_rat (bernoulli' n) = bernoulli' n\"\n by sorry\n\nlemma of_real_bernoulli': \"of_real (bernoulli' n) = (bernoulli' n :: 'a :: real_field)\"\n by sorry\n\nlemma bernoulli_in_Rats: \"bernoulli n \\ \\\"\n by sorry\n\nlemma bernoulli'_in_Rats: \"bernoulli' n \\ \\\"\n by sorry\n\ndefinition bernpoly :: \"nat \\ 'a \\ 'a :: real_algebra_1\" where\n \"bernpoly n = (\\x. \\k \\ n. of_nat (n choose k) * of_real (bernoulli k) * x ^ (n - k))\"\n \nlemma bernpoly_altdef:\n \"bernpoly n = (\\x. \\k\\n. of_nat (n choose k) * of_real (bernoulli (n - k)) * x ^ k)\"\n by sorry\n\nlemma bernoulli_Suc': \n \"bernoulli (Suc n) = -1/(of_nat n + 2) * (\\k\\n. of_nat (n + 2 choose (k + 2)) * bernoulli (n - k))\" \n by sorry\n \nsubsection \\Basic Observations on Bernoulli Polynomials\\\n\nlemma bernpoly_0 [simp]: \"bernpoly n 0 = of_real (bernoulli n)\"\n by sorry\n\nlemma continuous_on_bernpoly [continuous_intros]: \n \"continuous_on A (bernpoly n :: 'a \\ 'a :: real_normed_algebra_1)\"\n by sorry\n\nlemma isCont_bernpoly [continuous_intros]: \n \"isCont (bernpoly n :: 'a \\ 'a :: real_normed_algebra_1) x\"\n by sorry\n\nlemma has_field_derivative_bernpoly:\n \"(bernpoly (Suc n) has_field_derivative \n (of_nat (n + 1) * bernpoly n x :: 'a :: real_normed_field)) (at x)\"\n by sorry\n \nlemmas has_field_derivative_bernpoly' [derivative_intros] =\n DERIV_chain'[OF _ has_field_derivative_bernpoly] \n\nlemma sum_binomial_times_bernoulli:\n \"(\\k\\n. of_nat ((Suc n) choose k) * bernoulli k) = (if n = 0 then 1 else 0)\"\n by sorry\n \nlemma sum_binomial_times_bernoulli':\n \"(\\k 0 \\ (n choose k) = (if k = 0 then 1 else ((n - 1) choose (k - 1)) + ((n - 1) choose k))\"\n by sorry\n\nlemma sum_unroll:\n \"(\\k\\n::nat. f k) = (if n = 0 then f 0 else f n + (\\k\\n - 1. f k))\"\n by sorry\n\nlemma bernoulli_unroll:\n \"n > 0 \\ bernoulli n = - 1 / (of_nat n + 1) * (\\k\\n - 1. of_nat (n + 1 choose k) * bernoulli k)\"\n by sorry\n\nlemmas bernoulli_unroll_all = binomial_unroll bernoulli_unroll sum_unroll bernpoly_def\n\nlemma bernpoly_1_1: \"bernpoly 1 1 = of_real (1/2)\"\n by sorry\n\nsubsection \\Sum of Powers with Bernoulli Polynomials\\\n\nlemma diff_bernpoly:\n fixes x :: real\n shows \"bernpoly n (x + 1) - bernpoly n x = of_nat n * x ^ (n - 1)\"\n by sorry\n\nlemma bernpoly_of_real: \"bernpoly n (of_real x) = of_real (bernpoly n x)\"\n by sorry\n \nlemma bernpoly_1:\n assumes \"n \\ 1\"\n shows \"bernpoly n 1 = of_real (bernoulli n)\"\n by sorry\n \nlemma bernpoly_1': \"bernpoly n 1 = of_real (bernoulli' n)\"\n by sorry\n\ntheorem sum_of_powers: \n \"(\\k\\n::nat. (real k) ^ m) = (bernpoly (Suc m) (n + 1) - bernpoly (Suc m) 0) / (m + 1)\"\n by sorry\n \nlemma sum_of_powers_nat_aux: \n assumes \"real a = b / c\" \"real b' = b\" \"real c' = c\"\n shows \"a = b' div c'\"\n by sorry\n\nsubsection \\Instances for Square And Cubic Numbers\\\n\ntheorem sum_of_squares: \"real (\\k\\n::nat. k ^ 2) = real (2 * n ^ 3 + 3 * n ^ 2 + n) / 6\"\n by sorry\n\ncorollary sum_of_squares_nat: \"(\\k\\n::nat. k ^ 2) = (2 * n ^ 3 + 3 * n ^ 2 + n) div 6\"\n by sorry\n\ntheorem sum_of_cubes: \"real (\\k\\n::nat. k ^ 3) = real (n ^ 2 + n) ^ 2 / 4\"\n by sorry\n \ncorollary sum_of_cubes_nat: \"(\\k\\n::nat. k ^ 3) = (n ^ 2 + n) ^ 2 div 4\"\n by sorry\n\nend" }, { "theorem_id": 60, "title": "077_sum_of_kth_powers", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Kevin Buzzard\n-/\nmodule\n\npublic import Mathlib.Algebra.BigOperators.Field\npublic import Mathlib.RingTheory.PowerSeries.Inverse\npublic import Mathlib.RingTheory.PowerSeries.Exp\n\n/-!\n# Bernoulli numbers\n\nThe Bernoulli numbers are a sequence of rational numbers that frequently show up in\nnumber theory.\n\n## Mathematical overview\n\nThe Bernoulli numbers $(B_0, B_1, B_2, \\ldots)=(1, -1/2, 1/6, 0, -1/30, \\ldots)$ are\na sequence of rational numbers. They show up in the formula for the sums of $k$th\npowers. They are related to the Taylor series expansions of $x/\\tan(x)$ and\nof $\\coth(x)$, and also show up in the values that the Riemann Zeta function\ntakes both at both negative and positive integers (and hence in the\ntheory of modular forms). For example, if $1 \\leq n$ then\n\n$$\\zeta(2n)=\\sum_{t\\geq1}t^{-2n}=(-1)^{n+1}\\frac{(2\\pi)^{2n}B_{2n}}{2(2n)!}.$$\n\nThis result is formalised in Lean: `riemannZeta_two_mul_nat`.\n\nThe Bernoulli numbers can be formally defined using the power series\n\n$$\\sum B_n\\frac{t^n}{n!}=\\frac{t}{1-e^{-t}}$$\n\nalthough that happens to not be the definition in mathlib (this is an *implementation\ndetail* and need not concern the mathematician).\n\nNote that $B_1=-1/2$, meaning that we are using the $B_n^-$ of\n[from Wikipedia](https://en.wikipedia.org/wiki/Bernoulli_number).\n\n## Implementation detail\n\nThe Bernoulli numbers are defined using well-founded induction, by the formula\n$$B_n=1-\\sum_{k\\lt n}\\frac{\\binom{n}{k}}{n-k+1}B_k.$$\nThis formula is true for all $n$ and in particular $B_0=1$. Note that this is the definition\nfor positive Bernoulli numbers, which we call `bernoulli'`. The negative Bernoulli numbers are\nthen defined as `bernoulli := (-1)^n * bernoulli'`.\n\n## Main theorems\n\n`sum_bernoulli : ∑ k ∈ Finset.range n, (n.choose k : ℚ) * bernoulli k = if n = 1 then 1 else 0`\n-/\n\n@[expose] public section\n\n\nopen Nat Finset Finset.Nat PowerSeries\n\nvariable (A : Type*) [CommRing A] [Algebra ℚ A]\n\n/-! ### Definitions -/\n\n\n/-- The Bernoulli numbers:\nthe $n$-th Bernoulli number $B_n$ is defined recursively via\n$$B_n = 1 - \\sum_{k < n} \\binom{n}{k}\\frac{B_k}{n+1-k}$$ -/\ndef bernoulli' (n : ℕ) : ℚ :=\n 1 - ∑ k : Fin n, n.choose k / (n - k + 1) * bernoulli' k\n\ntheorem bernoulli'_def' (n : ℕ) :\n bernoulli' n = 1 - ∑ k : Fin n, n.choose k / (n - k + 1) * bernoulli' k := by sorry\ntheorem bernoulli'_def (n : ℕ) :\n bernoulli' n = 1 - ∑ k ∈ range n, n.choose k / (n - k + 1) * bernoulli' k := by sorry\ntheorem bernoulli'_spec (n : ℕ) :\n (∑ k ∈ range n.succ, (n.choose (n - k) : ℚ) / (n - k + 1) * bernoulli' k) = 1 := by sorry\ntheorem bernoulli'_spec' (n : ℕ) :\n (∑ k ∈ antidiagonal n, ((k.1 + k.2).choose k.2 : ℚ) / (k.2 + 1) * bernoulli' k.1) = 1 := by sorry\nsection Examples\n\n@[simp]\ntheorem bernoulli'_zero : bernoulli' 0 = 1 := by sorry\ntheorem bernoulli'_one : bernoulli' 1 = 1 / 2 := by sorry\ntheorem bernoulli'_two : bernoulli' 2 = 1 / 6 := by sorry\ntheorem bernoulli'_three : bernoulli' 3 = 0 := by sorry\ntheorem bernoulli'_four : bernoulli' 4 = -1 / 30 := by sorry\nend Examples\n\n@[simp]\ntheorem sum_bernoulli' (n : ℕ) : (∑ k ∈ range n, (n.choose k : ℚ) * bernoulli' k) = n := by sorry\ndef bernoulli'PowerSeries :=\n mk fun n => algebraMap ℚ A (bernoulli' n / n !)\n\ntheorem bernoulli'PowerSeries_mul_exp_sub_one :\n bernoulli'PowerSeries A * (exp A - 1) = X * exp A := by sorry\ntheorem bernoulli'_eq_zero_of_odd {n : ℕ} (h_odd : Odd n) (hlt : 1 < n) : bernoulli' n = 0 := by sorry\ndef bernoulli (n : ℕ) : ℚ :=\n (-1) ^ n * bernoulli' n\n\ntheorem bernoulli'_eq_bernoulli (n : ℕ) : bernoulli' n = (-1) ^ n * bernoulli n := by sorry\ntheorem bernoulli_zero : bernoulli 0 = 1 := by simp [bernoulli]\n\n@[simp]\ntheorem bernoulli_one : bernoulli 1 = -1 / 2 := by norm_num [bernoulli]\n\n@[simp]\ntheorem bernoulli_two : bernoulli 2 = 6⁻¹ := by sorry\ntheorem bernoulli_eq_zero_of_odd {n : ℕ} (h_odd : Odd n) (hlt : 1 < n) : bernoulli n = 0 := by sorry\ntheorem bernoulli_eq_bernoulli'_of_ne_one {n : ℕ} (hn : n ≠ 1) : bernoulli n = bernoulli' n := by sorry\ntheorem sum_bernoulli (n : ℕ) :\n (∑ k ∈ range n, (n.choose k : ℚ) * bernoulli k) = if n = 1 then 1 else 0 := by sorry\ntheorem bernoulli_spec' (n : ℕ) :\n (∑ k ∈ antidiagonal n, ((k.1 + k.2).choose k.2 : ℚ) / (k.2 + 1) * bernoulli k.1) =\n if n = 0 then 1 else 0 := by sorry\ndef bernoulliPowerSeries :=\n mk fun n => algebraMap ℚ A (bernoulli n / n !)\n\ntheorem bernoulliPowerSeries_mul_exp_sub_one : bernoulliPowerSeries A * (exp A - 1) = X := by sorry\nsection Faulhaber\n\n/-- **Faulhaber's theorem** relating the **sum of p-th powers** to the Bernoulli numbers:\n$$\\sum_{k=0}^{n-1} k^p = \\sum_{i=0}^p B_i\\binom{p+1}{i}\\frac{n^{p+1-i}}{p+1}.$$\nSee https://proofwiki.org/wiki/Faulhaber%27s_Formula and [orosi2018faulhaber] for\nthe proof provided here. -/\ntheorem sum_range_pow (n p : ℕ) :\n (∑ k ∈ range n, (k : ℚ) ^ p) =\n ∑ i ∈ range (p + 1), bernoulli i * ((p + 1).choose i) * (n : ℚ) ^ (p + 1 - i) / (p + 1) := by sorry\ntheorem sum_Ico_pow (n p : ℕ) :\n (∑ k ∈ Ico 1 (n + 1), (k : ℚ) ^ p) =\n ∑ i ∈ range (p + 1), bernoulli' i * (p + 1).choose i * (n : ℚ) ^ (p + 1 - i) / (p + 1) := by sorry\nend Faulhaber\n" }, { "theorem_id": 60, "title": "077_sum_of_kth_powers", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nFixpoint bernoullicoeff (n:nat) (k:nat) : R:=\nmatch n with | O => match k with | O => INR 1\n | _ => INR 0\n end\n |(S m)=> \n match k with \n| O => (sum_f_R0 (fun l => -((bernoullicoeff m l)*(/INR (S l))*(INR n)*/ INR (S (S l)) )) m)\n| (S l)=> (bernoullicoeff m l)*/(INR (S l))*(INR n)\n end\nend.\n\nDefinition bernoulli_polynomial (n:nat) (x:R):=\n(sum_f_R0 (fun l => (bernoullicoeff n l) *x^l) n).\n\nTheorem bernoulli_polynomial_derivable_pt_lim:\nforall n:nat,forall x:R,\nderivable_pt_lim (bernoulli_polynomial (S n)) x ((bernoulli_polynomial n x)*(INR (S n))).\nProof.\nAdmitted.\n\nTheorem bernoulli_polynomial_derivable_pt_lim_shift:\nforall n:nat,forall x:R,\n derivable_pt_lim (fun x=> (bernoulli_polynomial (S n) (x+1))) x ((bernoulli_polynomial n (x+1))*(INR (S n))).\nProof.\nAdmitted.\n\nLemma sumzero : forall n:nat, sum_f_R0 (fun _ => 0:R) n=(0:R).\nProof.\nAdmitted.\n\nTheorem bernoulli_polynomial_val_0_1:\n forall n:nat,n<>1%nat -> bernoulli_polynomial n 0=bernoulli_polynomial n 1.\nProof.\nAdmitted.\n\nLemma primitive_diff : forall f g fp : (R->R), \n(forall x:R, derivable_pt_lim f x (fp x))->\n(forall x:R, derivable_pt_lim g x (fp x))->\nforall x:R, f x=(plus_fct g (fct_cte ((f 0)-(g 0)))) x.\nProof.\nAdmitted.\n\nLemma primitive_eq:forall f g fp : (R->R), \n(forall x:R, derivable_pt_lim f x (fp x))->\n(forall x:R, derivable_pt_lim g x (fp x))->\nf 0=g 0->\nforall x:R, f x=g x.\nProof.\nAdmitted.\n\nLemma kthpowers : forall n:nat, forall x:R,\nx^n*(INR (S n))=(bernoulli_polynomial (S n) (x+1))-(bernoulli_polynomial (S n) x).\nProof.\nAdmitted.\n\nLemma sum_kthpowers : forall r:nat, forall n:nat, \n(0\nsum_f_R0 (fun k => ((INR k)^r)%R) n\n=((bernoulli_polynomial (S r) (INR n+1))-(bernoulli_polynomial (S r) 0))/(INR r+1).\nProof.\nAdmitted." }, { "theorem_id": 61, "title": "078_the_cauchy-schwarz_inequality", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/matroids.ml\";;\nneeds \"Multivariate/misc.ml\";;\n\nlet FORALL_1 = `(!i. 1 <= i /\\ i <= 1 ==> P i) <=> P 1`;;\n\nlet FORALL_2 = `!P. (!i. 1 <= i /\\ i <= 2 ==> P i) <=> P 1 /\\ P 2`;;\n\nlet FORALL_3 = `!P. (!i. 1 <= i /\\ i <= 3 ==> P i) <=> P 1 /\\ P 2 /\\ P 3`;;\n\nlet FORALL_4 = `!P. (!i. 1 <= i /\\ i <= 4 ==> P i) <=> P 1 /\\ P 2 /\\ P 3 /\\ P 4`;;\n\nlet SUM_1 = `sum(1..1) f = f(1)`;;\n\nlet SUM_2 = `!t. sum(1..2) t = t(1) + t(2)`;;\n\nlet SUM_3 = `!t. sum(1..3) t = t(1) + t(2) + t(3)`;;\n\nlet SUM_4 = `!t. sum(1..4) t = t(1) + t(2) + t(3) + t(4)`;;\n\nlet vector_add = new_definition\n `(vector_add:real^N->real^N->real^N) x y = lambda i. x$i + y$i`;;\n\nlet vector_sub = new_definition\n `(vector_sub:real^N->real^N->real^N) x y = lambda i. x$i - y$i`;;\n\nlet vector_neg = new_definition\n `(vector_neg:real^N->real^N) x = lambda i. --(x$i)`;;\n\noverload_interface (\"+\",`(vector_add):real^N->real^N->real^N`);;\noverload_interface (\"-\",`(vector_sub):real^N->real^N->real^N`);;\noverload_interface (\"--\",`(vector_neg):real^N->real^N`);;\n\nprioritize_real();;\n\nlet prioritize_vector = let ty = `:real^N` in\n fun () -> prioritize_overload ty;;\n\nparse_as_infix(\"%\",(21,\"right\"));;\n\nlet vector_mul = new_definition\n `((%):real->real^N->real^N) c x = lambda i. c * x$i`;;\n\nlet vec = new_definition\n `(vec:num->real^N) n = lambda i. &n`;;\n\nparse_as_infix(\"dot\",(20,\"right\"));;\n\nlet dot = new_definition\n `(x:real^N) dot (y:real^N) = sum(1..dimindex(:N)) (\\i. x$i * y$i)`;;\n\nlet DOT_1 = `(x:real^1) dot (y:real^1) = x$1 * y$1`;;\n\nlet DOT_2 = `(x:real^2) dot (y:real^2) = x$1 * y$1 + x$2 * y$2`;;\n\nlet DOT_3 = `(x:real^3) dot (y:real^3) = x$1 * y$1 + x$2 * y$2 + x$3 * y$3`;;\n\nlet DOT_4 = `(x:real^4) dot (y:real^4) = x$1 * y$1 + x$2 * y$2 + x$3 * y$3 + x$4 * y$4`;;\n\nlet VECTOR_ARITH_TAC =\n let RENAMED_LAMBDA_BETA th =\n if fst(dest_fun_ty(type_of(funpow 3 rand (concl th)))) = aty\n then INST_TYPE [aty,bty; bty,aty] LAMBDA_BETA else LAMBDA_BETA in\n POP_ASSUM_LIST(K ALL_TAC) THEN\n REPEAT(GEN_TAC ORELSE CONJ_TAC ORELSE DISCH_TAC ORELSE EQ_TAC) THEN\n REPEAT(POP_ASSUM MP_TAC) THEN REWRITE_TAC[IMP_IMP; GSYM CONJ_ASSOC] THEN\n REWRITE_TAC[dot; GSYM SUM_ADD_NUMSEG; GSYM SUM_SUB_NUMSEG;\n GSYM SUM_LMUL; GSYM SUM_RMUL; GSYM SUM_NEG] THEN\n (MATCH_MP_TAC SUM_EQ_NUMSEG ORELSE MATCH_MP_TAC SUM_EQ_0_NUMSEG ORELSE\n GEN_REWRITE_TAC ONCE_DEPTH_CONV [CART_EQ]) THEN\n REWRITE_TAC[AND_FORALL_THM] THEN TRY EQ_TAC THEN\n TRY(MATCH_MP_TAC MONO_FORALL) THEN GEN_TAC THEN\n REWRITE_TAC[TAUT `(a ==> b) /\\ (a ==> c) <=> a ==> b /\\ c`;\n TAUT `(a ==> b) \\/ (a ==> c) <=> a ==> b \\/ c`] THEN\n TRY(MATCH_MP_TAC(TAUT `(a ==> b ==> c) ==> (a ==> b) ==> (a ==> c)`)) THEN\n REWRITE_TAC[vector_add; vector_sub; vector_neg; vector_mul; vec] THEN\n DISCH_THEN(fun th -> REWRITE_TAC[MATCH_MP(RENAMED_LAMBDA_BETA th) th]) THEN\n REAL_ARITH_TAC;;\n\nlet VECTOR_ARITH tm = prove(tm,VECTOR_ARITH_TAC);;\n\nlet VEC_COMPONENT = `!k i. (vec k :real^N)$i = &k`;;\n\nlet VECTOR_ADD_COMPONENT = `!x:real^N y i. (x + y)$i = x$i + y$i`;;\n\nlet VECTOR_SUB_COMPONENT = `!x:real^N y i. (x - y)$i = x$i - y$i`;;\n\nlet VECTOR_NEG_COMPONENT = `!x:real^N i. (--x)$i = --(x$i)`;;\n\nlet VECTOR_MUL_COMPONENT = `!c x:real^N i. (c % x)$i = c * x$i`;;\n\nlet COND_COMPONENT = `(if b then x else y)$i = if b then x$i else y$i`;;\n\nlet VECTOR_ADD_SYM = VECTOR_ARITH `!x y:real^N. x + y = y + x`;;\n\nlet VECTOR_ADD_LID = VECTOR_ARITH `!x. vec 0 + x = x`;;\n\nlet VECTOR_ADD_RID = VECTOR_ARITH `!x. x + vec 0 = x`;;\n\nlet VECTOR_SUB_REFL = VECTOR_ARITH `!x. x - x = vec 0`;;\n\nlet VECTOR_ADD_LINV = VECTOR_ARITH `!x. --x + x = vec 0`;;\n\nlet VECTOR_ADD_RINV = VECTOR_ARITH `!x. x + --x = vec 0`;;\n\nlet VECTOR_SUB_RADD = VECTOR_ARITH `!x y. x - (x + y) = --y:real^N`;;\n\nlet VECTOR_NEG_SUB = VECTOR_ARITH `!x:real^N y. --(x - y) = y - x`;;\n\nlet VECTOR_SUB_EQ = VECTOR_ARITH `!x y. (x - y = vec 0) <=> (x = y)`;;\n\nlet VECTOR_MUL_ASSOC = VECTOR_ARITH `!a b x. a % (b % x) = (a * b) % x`;;\n\nlet VECTOR_MUL_LID = VECTOR_ARITH `!x. &1 % x = x`;;\n\nlet VECTOR_MUL_LZERO = VECTOR_ARITH `!x. &0 % x = vec 0`;;\n\nlet VECTOR_SUB_ADD = VECTOR_ARITH `(x - y) + y = x:real^N`;;\n\nlet VECTOR_SUB_ADD2 = VECTOR_ARITH `y + (x - y) = x:real^N`;;\n\nlet VECTOR_ADD_LDISTRIB = VECTOR_ARITH `c % (x + y) = c % x + c % y`;;\n\nlet VECTOR_SUB_LDISTRIB = VECTOR_ARITH `c % (x - y) = c % x - c % y`;;\n\nlet VECTOR_ADD_RDISTRIB = VECTOR_ARITH `(a + b) % x = a % x + b % x`;;\n\nlet VECTOR_SUB_RDISTRIB = VECTOR_ARITH `(a - b) % x = a % x - b % x`;;\n\nlet VECTOR_ADD_SUB = VECTOR_ARITH `(x + y:real^N) - x = y`;;\n\nlet VECTOR_EQ_ADDR = VECTOR_ARITH `(x + y = x) <=> (y = vec 0)`;;\n\nlet VECTOR_SUB = VECTOR_ARITH `x - y = x + --(y:real^N)`;;\n\nlet VECTOR_SUB_RZERO = VECTOR_ARITH `x - vec 0 = x`;;\n\nlet VECTOR_MUL_RZERO = VECTOR_ARITH `c % vec 0 = vec 0`;;\n\nlet VECTOR_NEG_MINUS1 = VECTOR_ARITH `--x = (--(&1)) % x`;;\n\nlet VECTOR_ADD_ASSOC = VECTOR_ARITH `(x:real^N) + y + z = (x + y) + z`;;\n\nlet VECTOR_SUB_LZERO = VECTOR_ARITH `vec 0 - x = --x`;;\n\nlet VECTOR_NEG_NEG = VECTOR_ARITH `--(--(x:real^N)) = x`;;\n\nlet VECTOR_MUL_LNEG = VECTOR_ARITH `--c % x = --(c % x)`;;\n\nlet VECTOR_MUL_RNEG = VECTOR_ARITH `c % --x = --(c % x)`;;\n\nlet VECTOR_NEG_0 = VECTOR_ARITH `--(vec 0) = vec 0`;;\n\nlet VECTOR_NEG_EQ_0 = VECTOR_ARITH `--x = vec 0 <=> x = vec 0`;;\n\nlet VECTOR_EQ_NEG2 = VECTOR_ARITH `!x y:real^N. --x = --y <=> x = y`;;\n\nlet VECTOR_ADD_AC = VECTOR_ARITH\n `(m + n = n + m:real^N) /\\\n ((m + n) + p = m + n + p) /\\\n (m + n + p = n + m + p)`;;\n\nlet VEC_EQ = `!m n. (vec m = vec n) <=> (m = n)`;;\n\nlet SUMS_SYM = `!s t:real^N->bool.\n {x + y | x IN s /\\ y IN t} = {y + x | y IN t /\\ x IN s}`;;\n\nlet SUMS_ASSOC = `!s t u:real^N->bool.\n {w + z | w IN {x + y | x IN s /\\ y IN t} /\\ z IN u} =\n {x + v | x IN s /\\ v IN {y + z | y IN t /\\ z IN u}}`;;\n\nlet EUCLIDEAN_SPACE_INFINITE = `INFINITE(:real^N)`;;\n\nlet DOT_SYM = VECTOR_ARITH `!x y. x dot y = y dot x`;;\n\nlet DOT_LADD = VECTOR_ARITH `!x y z. (x + y) dot z = (x dot z) + (y dot z)`;;\n\nlet DOT_RADD = VECTOR_ARITH `!x y z. x dot (y + z) = (x dot y) + (x dot z)`;;\n\nlet DOT_LSUB = VECTOR_ARITH `!x y z. (x - y) dot z = (x dot z) - (y dot z)`;;\n\nlet DOT_RSUB = VECTOR_ARITH `!x y z. x dot (y - z) = (x dot y) - (x dot z)`;;\n\nlet DOT_LMUL = VECTOR_ARITH `!c x y. (c % x) dot y = c * (x dot y)`;;\n\nlet DOT_RMUL = VECTOR_ARITH `!c x y. x dot (c % y) = c * (x dot y)`;;\n\nlet DOT_LNEG = VECTOR_ARITH `!x y. (--x) dot y = --(x dot y)`;;\n\nlet DOT_RNEG = VECTOR_ARITH `!x y. x dot (--y) = --(x dot y)`;;\n\nlet DOT_LZERO = VECTOR_ARITH `!x. (vec 0) dot x = &0`;;\n\nlet DOT_RZERO = VECTOR_ARITH `!x. x dot (vec 0) = &0`;;\n\nlet DOT_POS_LE = `!x. &0 <= x dot x`;;\n\nlet DOT_EQ_0 = `!x:real^N. ((x dot x = &0) <=> (x = vec 0))`;;\n\nlet DOT_POS_LT = `!x. (&0 < x dot x) <=> ~(x = vec 0)`;;\n\nlet FORALL_DOT_EQ_0 = `(!y. (!x. x dot y = &0) <=> y = vec 0) /\\\n (!x. (!y. x dot y = &0) <=> x = vec 0)`;;\n\nlet REFLECT_UNIV = `IMAGE (--) (:real^N) = (:real^N)`;;\n\nlet TRANSLATION_UNIV = `!a. IMAGE (\\x. a + x) (:real^N) = (:real^N)`;;\n\nlet TRANSLATION_SUBSET_GALOIS_RIGHT = `!s t a:real^N.\n s SUBSET IMAGE (\\x. a + x) t <=> IMAGE (\\x. --a + x) s SUBSET t`;;\n\nlet TRANSLATION_SUBSET_GALOIS_LEFT = `!s t a:real^N.\n IMAGE (\\x. a + x) s SUBSET t <=> s SUBSET IMAGE (\\x. --a + x) t`;;\n\nlet TRANSLATION_GALOIS = `!s t a:real^N. s = IMAGE (\\x. a + x) t <=> t = IMAGE (\\x. --a + x) s`;;\n\nlet IN_TRANSLATION_GALOIS = `!s a b:real^N. b IN IMAGE (\\x. a + x) s <=> (b - a) IN s`;;\n\nlet IN_TRANSLATION_GALOIS_ALT = `!s a b:real^N. (a + b) IN s <=> b IN IMAGE (\\x. --a + x) s`;;\n\nlet FORALL_DIMINDEX_1 = `(!i. 1 <= i /\\ i <= dimindex(:1) ==> P i) <=> P 1`;;\n\nlet VECTOR_ONE = `!x:real^1. x = lambda i. x$1`;;\n\nlet FORALL_REAL_ONE = `(!x:real^1. P x) <=> (!x. P(lambda i. x))`;;\n\nmake_overloadable \"norm\" `:A->real`;;\noverload_interface(\"norm\",`vector_norm:real^N->real`);;\n\nlet vector_norm = new_definition\n `norm x = sqrt(x dot x)`;;\n\noverride_interface(\"dist\",`distance:real^N#real^N->real`);;\n\nlet dist = new_definition\n `dist(x,y) = norm(x - y)`;;\n\nlet NORM_REAL = `!x:real^1. norm(x) = abs(x$1)`;;\n\nlet DIST_REAL = `!x:real^1 y. dist(x,y) = abs(x$1 - y$1)`;;\n\nlet NORM_0 = `norm(vec 0) = &0`;;\n\nlet NORM_POS_LE = `!x. &0 <= norm x`;;\n\nlet NORM_NEG = `!x. norm(--x) = norm x`;;\n\nlet NORM_SUB = `!x y. norm(x - y) = norm(y - x)`;;\n\nlet NORM_MUL = `!a x. norm(a % x) = abs(a) * norm x`;;\n\nlet NORM_EQ_0_DOT = `!x. (norm x = &0) <=> (x dot x = &0)`;;\n\nlet NORM_EQ_0 = `!x. (norm x = &0) <=> (x = vec 0)`;;\n\nlet NORM_POS_LT = `!x. &0 < norm x <=> ~(x = vec 0)`;;\n\nlet NORM_POW_2 = `!x. norm(x) pow 2 = x dot x`;;\n\nlet NORM_EQ_0_IMP = `!x. (norm x = &0) ==> (x = vec 0)`;;\n\nlet NORM_LE_0 = `!x. norm x <= &0 <=> (x = vec 0)`;;\n\nlet VECTOR_MUL_EQ_0 = `!a x. (a % x = vec 0) <=> (a = &0) \\/ (x = vec 0)`;;\n\nlet VECTOR_MUL_LCANCEL = `!a x y. (a % x = a % y) <=> (a = &0) \\/ (x = y)`;;\n\nlet VECTOR_MUL_RCANCEL = `!a b x. (a % x = b % x) <=> (a = b) \\/ (x = vec 0)`;;\n\nlet VECTOR_MUL_LCANCEL_IMP = `!a x y. ~(a = &0) /\\ (a % x = a % y) ==> (x = y)`;;\n\nlet VECTOR_MUL_RCANCEL_IMP = `!a b x. ~(x = vec 0) /\\ (a % x = b % x) ==> (a = b)`;;\n\nlet NORM_CAUCHY_SCHWARZ = `!(x:real^N) y. x dot y <= norm(x) * norm(y)`;;\n\nlet NORM_CAUCHY_SCHWARZ_ABS = `!x:real^N y. abs(x dot y) <= norm(x) * norm(y)`;;\n\nlet REAL_ABS_NORM = `!x. abs(norm x) = norm x`;;\n\nlet NORM_CAUCHY_SCHWARZ_DIV = `!x:real^N y. abs((x dot y) / (norm x * norm y)) <= &1`;;\n\nlet NORM_TRIANGLE = `!x y. norm(x + y) <= norm(x) + norm(y)`;;\n\nlet NORM_TRIANGLE_SUB = `!x y:real^N. norm(x) <= norm(y) + norm(x - y)`;;\n\nlet NORM_TRIANGLE_LE = `!x y. norm(x) + norm(y) <= e ==> norm(x + y) <= e`;;\n\nlet NORM_TRIANGLE_LT = `!x y. norm(x) + norm(y) < e ==> norm(x + y) < e`;;\n\nlet COMPONENT_LE_NORM = `!x:real^N i. abs(x$i) <= norm x`;;\n\nlet NORM_BOUND_COMPONENT_LE = `!x:real^N e. norm(x) <= e\n ==> !i. 1 <= i /\\ i <= dimindex(:N) ==> abs(x$i) <= e`;;\n\nlet NORM_BOUND_COMPONENT_LT = `!x:real^N e. norm(x) < e\n ==> !i. 1 <= i /\\ i <= dimindex(:N) ==> abs(x$i) < e`;;\n\nlet NORM_LE_L1 = `!x:real^N. norm x <= sum(1..dimindex(:N)) (\\i. abs(x$i))`;;\n\nlet REAL_ABS_SUB_NORM = `abs(norm(x) - norm(y)) <= norm(x - y)`;;\n\nlet NORM_LE = `!x y. norm(x) <= norm(y) <=> x dot x <= y dot y`;;\n\nlet NORM_LT = `!x y. norm(x) < norm(y) <=> x dot x < y dot y`;;\n\nlet NORM_EQ = `!x y. (norm x = norm y) <=> (x dot x = y dot y)`;;\n\nlet NORM_EQ_1 = `!x. norm(x) = &1 <=> x dot x = &1`;;\n\nlet NORM_LE_COMPONENTWISE = `!x:real^N y:real^N.\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> abs(x$i) <= abs(y$i))\n ==> norm(x) <= norm(y)`;;\n\nlet NORM_EQ_COMPONENTWISE = `!x:real^N y:real^N.\n (!i. 1 <= i /\\ i <= dimindex (:N) ==> abs(x$i) = abs(y$i))\n ==> norm x = norm y`;;\n\nlet L1_LE_NORM = `!x:real^N.\n sum(1..dimindex(:N)) (\\i. abs(x$i)) <= sqrt(&(dimindex(:N))) * norm x`;;\n\nlet DIST_INCREASES_ONLINE = `!a b d. ~(d = vec 0)\n ==> dist(a,b + d) > dist(a,b) \\/ dist(a,b - d) > dist(a,b)`;;\n\nlet NORM_INCREASES_ONLINE = `!a:real^N d. ~(d = vec 0)\n ==> norm(a + d) > norm(a) \\/ norm(a - d) > norm(a)`;;\n\nlet DOT_SQUARE_NORM = `!x. x dot x = norm(x) pow 2`;;\n\nlet NORM_EQ_SQUARE = `!x:real^N. norm(x) = a <=> &0 <= a /\\ x dot x = a pow 2`;;\n\nlet NORM_LE_SQUARE = `!x:real^N. norm(x) <= a <=> &0 <= a /\\ x dot x <= a pow 2`;;\n\nlet NORM_GE_SQUARE = `!x:real^N. norm(x) >= a <=> a <= &0 \\/ x dot x >= a pow 2`;;\n\nlet NORM_LT_SQUARE = `!x:real^N. norm(x) < a <=> &0 < a /\\ x dot x < a pow 2`;;\n\nlet NORM_GT_SQUARE = `!x:real^N. norm(x) > a <=> a < &0 \\/ x dot x > a pow 2`;;\n\nlet NORM_LT_SQUARE_ALT = `!x:real^N. norm(x) < a <=> &0 <= a /\\ x dot x < a pow 2`;;\n\nlet NORM_ARITH =\n let find_normedterms =\n let augment_norm b tm acc =\n match tm with\n Comb(Const(\"vector_norm\",_),v) -> insert (b,v) acc\n | _ -> acc in\n let rec find_normedterms tm acc =\n match tm with\n Comb(Comb(Const(\"real_add\",_),l),r) ->\n find_normedterms l (find_normedterms r acc)\n | Comb(Comb(Const(\"real_mul\",_),c),n) ->\n if not (is_ratconst c) then acc else\n augment_norm (rat_of_term c >=/ num 0) n acc\n | _ -> augment_norm true tm acc in\n find_normedterms in\n let lincomb_neg t = mapf minus_num t in\n let lincomb_cmul c t = if c =/ num 0 then undefined else mapf (( */ ) c) t in\n let lincomb_add l r = combine (+/) (fun x -> x =/ num 0) l r in\n let lincomb_sub l r = lincomb_add l (lincomb_neg r) in\n let lincomb_eq l r = lincomb_sub l r = undefined in\n let rec vector_lincomb tm =\n match tm with\n Comb(Comb(Const(\"vector_add\",_),l),r) ->\n lincomb_add (vector_lincomb l) (vector_lincomb r)\n | Comb(Comb(Const(\"vector_sub\",_),l),r) ->\n lincomb_sub (vector_lincomb l) (vector_lincomb r)\n | Comb(Comb(Const(\"%\",_),l),r) ->\n lincomb_cmul (rat_of_term l) (vector_lincomb r)\n | Comb(Const(\"vector_neg\",_),t) ->\n lincomb_neg (vector_lincomb t)\n | Comb(Const(\"vec\",_),n) when is_numeral n && dest_numeral n =/ num 0 ->\n undefined\n | _ -> (tm |=> num 1) in\n let vector_lincombs tms =\n itlist (fun t fns ->\n if can (assoc t) fns then fns else\n let f = vector_lincomb t in\n try let _,f' = find (fun (_,f') -> lincomb_eq f f') fns in\n (t,f')::fns\n with Failure _ -> (t,f)::fns) tms [] in\n let rec replacenegnorms fn tm =\n match tm with\n Comb(Comb(Const(\"real_add\",_),l),r) ->\n BINOP_CONV (replacenegnorms fn) tm\n | Comb(Comb(Const(\"real_mul\",_),c),n) when rat_of_term c \n RAND_CONV fn tm\n | _ -> REFL tm in\n let flip v eq =\n if defined eq v then (v |-> minus_num(apply eq v)) eq else eq in\n let rec allsubsets s =\n match s with\n [] -> [[]]\n | (a::t) -> let res = allsubsets t in\n map (fun b -> a::b) res @ res in\n let evaluate env lin =\n foldr (fun x c s -> s +/ c */ apply env x) lin (num 0) in\n let rec solve (vs,eqs) =\n match (vs,eqs) with\n [],[] -> (0 |=> num 1)\n | _,eq::oeqs ->\n let v = hd(intersect vs (dom eq)) in\n let c = apply eq v in\n let vdef = lincomb_cmul (num(-1) // c) eq in\n let eliminate eqn =\n if not(defined eqn v) then eqn else\n lincomb_add (lincomb_cmul (apply eqn v) vdef) eqn in\n let soln = solve (subtract vs [v],map eliminate oeqs) in\n (v |-> evaluate soln (undefine v vdef)) soln in\n let rec combinations k l =\n if k = 0 then [[]] else\n match l with\n [] -> []\n | h::t -> map (fun c -> h::c) (combinations (k - 1) t) @\n combinations k t in\n let vertices vs eqs =\n let vertex cmb =\n let soln = solve(vs,cmb) in\n map (fun v -> tryapplyd soln v (num 0)) vs in\n let rawvs = mapfilter vertex (combinations (length vs) eqs) in\n let unset = filter (forall (fun c -> c >=/ num 0)) rawvs in\n itlist (insert' (forall2 (=/))) unset [] in\n let subsumes l m = forall2 (fun x y -> abs_num x <=/ abs_num y) l m in\n let rec subsume todo dun =\n match todo with\n [] -> dun\n | v::ovs -> let dun' = if exists (fun w -> subsumes w v) dun then dun\n else v::(filter (fun w -> not(subsumes v w)) dun) in\n subsume ovs dun' in\n let NORM_CMUL_RULE =\n let MATCH_pth = (MATCH_MP o prove)\n (`!b x. b >= norm(x) ==> !c. abs(c) * b >= norm(c % x)`,\n SIMP_TAC[NORM_MUL; real_ge; REAL_LE_LMUL; REAL_ABS_POS]) in\n fun c th -> ISPEC(term_of_rat c) (MATCH_pth th) in\n let NORM_ADD_RULE =\n let MATCH_pth = (MATCH_MP o prove)\n (`!b1 b2 x1 x2. b1 >= norm(x1) /\\ b2 >= norm(x2)\n ==> b1 + b2 >= norm(x1 + x2)`,\n REWRITE_TAC[real_ge] THEN REPEAT STRIP_TAC THEN\n MATCH_MP_TAC NORM_TRIANGLE_LE THEN ASM_SIMP_TAC[REAL_LE_ADD2]) in\n fun th1 th2 -> MATCH_pth (CONJ th1 th2) in\n let INEQUALITY_CANON_RULE =\n CONV_RULE(LAND_CONV REAL_POLY_CONV) o\n CONV_RULE(LAND_CONV REAL_RAT_REDUCE_CONV) o\n GEN_REWRITE_RULE I [REAL_ARITH `s >= t <=> s - t >= &0`] in\n let NORM_CANON_CONV =\n let APPLY_pth1 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `x:real^N = &1 % x`]\n and APPLY_pth2 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `x - y:real^N = x + --y`]\n and APPLY_pth3 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `--x:real^N = -- &1 % x`]\n and APPLY_pth4 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `&0 % x:real^N = vec 0`;\n VECTOR_ARITH `c % vec 0:real^N = vec 0`]\n and APPLY_pth5 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `c % (d % x) = (c * d) % x`]\n and APPLY_pth6 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `c % (x + y) = c % x + c % y`]\n and APPLY_pth7 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `vec 0 + x = x`;\n VECTOR_ARITH `x + vec 0 = x`]\n and APPLY_pth8 =\n GEN_REWRITE_CONV I [VECTOR_ARITH `c % x + d % x = (c + d) % x`] THENC\n LAND_CONV REAL_RAT_ADD_CONV THENC\n GEN_REWRITE_CONV TRY_CONV [VECTOR_ARITH `&0 % x = vec 0`]\n and APPLY_pth9 =\n GEN_REWRITE_CONV I\n [VECTOR_ARITH `(c % x + z) + d % x = (c + d) % x + z`;\n VECTOR_ARITH `c % x + (d % x + z) = (c + d) % x + z`;\n VECTOR_ARITH `(c % x + w) + (d % x + z) = (c + d) % x + (w + z)`] THENC\n LAND_CONV(LAND_CONV REAL_RAT_ADD_CONV)\n and APPLY_ptha =\n GEN_REWRITE_CONV I [VECTOR_ARITH `&0 % x + y = y`]\n and APPLY_pthb =\n GEN_REWRITE_CONV I\n [VECTOR_ARITH `c % x + d % y = c % x + d % y`;\n VECTOR_ARITH `(c % x + z) + d % y = c % x + (z + d % y)`;\n VECTOR_ARITH `c % x + (d % y + z) = c % x + (d % y + z)`;\n VECTOR_ARITH `(c % x + w) + (d % y + z) = c % x + (w + (d % y + z))`]\n and APPLY_pthc =\n GEN_REWRITE_CONV I\n [VECTOR_ARITH `c % x + d % y = d % y + c % x`;\n VECTOR_ARITH `(c % x + z) + d % y = d % y + (c % x + z)`;\n VECTOR_ARITH `c % x + (d % y + z) = d % y + (c % x + z)`;\n VECTOR_ARITH `(c % x + w) + (d % y + z) = d % y + ((c % x + w) + z)`]\n and APPLY_pthd =\n GEN_REWRITE_CONV TRY_CONV\n [VECTOR_ARITH `x + vec 0 = x`] in\n let headvector tm =\n match tm with\n Comb(Comb(Const(\"vector_add\",_),Comb(Comb(Const(\"%\",_),l),v)),r) -> v\n | Comb(Comb(Const(\"%\",_),l),v) -> v\n | _ -> failwith \"headvector: non-canonical term\" in\n let rec VECTOR_CMUL_CONV tm =\n ((APPLY_pth5 THENC LAND_CONV REAL_RAT_MUL_CONV) ORELSEC\n (APPLY_pth6 THENC BINOP_CONV VECTOR_CMUL_CONV)) tm\n and VECTOR_ADD_CONV tm =\n try APPLY_pth7 tm with Failure _ ->\n try APPLY_pth8 tm with Failure _ ->\n match tm with\n Comb(Comb(Const(\"vector_add\",_),lt),rt) ->\n let l = headvector lt and r = headvector rt in\n if l < r then (APPLY_pthb THENC\n RAND_CONV VECTOR_ADD_CONV THENC\n APPLY_pthd) tm\n else if r < l then (APPLY_pthc THENC\n RAND_CONV VECTOR_ADD_CONV THENC\n APPLY_pthd) tm else\n (APPLY_pth9 THENC\n ((APPLY_ptha THENC VECTOR_ADD_CONV) ORELSEC\n RAND_CONV VECTOR_ADD_CONV THENC\n APPLY_pthd)) tm\n | _ -> REFL tm in\n let rec VECTOR_CANON_CONV tm =\n match tm with\n Comb(Comb(Const(\"vector_add\",_),l),r) ->\n let lth = VECTOR_CANON_CONV l and rth = VECTOR_CANON_CONV r in\n let th = MK_COMB(AP_TERM (rator(rator tm)) lth,rth) in\n CONV_RULE (RAND_CONV VECTOR_ADD_CONV) th\n | Comb(Comb(Const(\"%\",_),l),r) ->\n let rth = AP_TERM (rator tm) (VECTOR_CANON_CONV r) in\n CONV_RULE (RAND_CONV(APPLY_pth4 ORELSEC VECTOR_CMUL_CONV)) rth\n | Comb(Comb(Const(\"vector_sub\",_),l),r) ->\n (APPLY_pth2 THENC VECTOR_CANON_CONV) tm\n | Comb(Const(\"vector_neg\",_),t) ->\n (APPLY_pth3 THENC VECTOR_CANON_CONV) tm\n | Comb(Const(\"vec\",_),n) when is_numeral n && dest_numeral n =/ num 0 ->\n REFL tm\n | _ -> APPLY_pth1 tm in\n fun tm ->\n match tm with\n Comb(Const(\"vector_norm\",_),e) -> RAND_CONV VECTOR_CANON_CONV tm\n | _ -> failwith \"NORM_CANON_CONV\" in\n let REAL_VECTOR_COMBO_PROVER =\n let pth_zero = `norm(vec 0:real^N) = &0`;;\n\nlet NORM_ARITH_TAC = CONV_TAC NORM_ARITH;;\n\nlet ASM_NORM_ARITH_TAC =\n REPEAT(FIRST_X_ASSUM(MP_TAC o check (not o is_forall o concl))) THEN\n NORM_ARITH_TAC;;\n\nlet HOMOMORPHISM_REAL_TO_REAL = `!f:real->real.\n (!x y. f(x + y) = f x + f y) /\\ (!x y. f(x * y) = f x * f y) <=>\n (f = \\x. &0) \\/ (f = \\x. x)`;;\n\nlet DOT_NORM = `!x y. x dot y = (norm(x + y) pow 2 - norm(x) pow 2 - norm(y) pow 2) / &2`;;\n\nlet DOT_NORM_SUB = `!x y. x dot y = ((norm(x) pow 2 + norm(y) pow 2) - norm(x - y) pow 2) / &2`;;\n\nlet VECTOR_EQ = `!x y. (x = y) <=> (x dot x = x dot y) /\\ (y dot y = x dot x)`;;\n\nlet DIST_REFL = `!x. dist(x,x) = &0`;;\n\nlet DIST_SYM = `!x y. dist(x,y) = dist(y,x)`;;\n\nlet DIST_POS_LE = `!x y. &0 <= dist(x,y)`;;\n\nlet REAL_ABS_DIST = `!x y:real^N. abs(dist(x,y)) = dist(x,y)`;;\n\nlet DIST_TRIANGLE = `!x:real^N y z. dist(x,z) <= dist(x,y) + dist(y,z)`;;\n\nlet DIST_TRIANGLE_ALT = `!x y z. dist(y,z) <= dist(x,y) + dist(x,z)`;;\n\nlet DIST_EQ_0 = `!x y. (dist(x,y) = &0) <=> (x = y)`;;\n\nlet DIST_POS_LT = `!x y. ~(x = y) ==> &0 < dist(x,y)`;;\n\nlet DIST_NZ = `!x y. ~(x = y) <=> &0 < dist(x,y)`;;\n\nlet DIST_TRIANGLE_LE = `!x y z e. dist(x,z) + dist(y,z) <= e ==> dist(x,y) <= e`;;\n\nlet DIST_TRIANGLE_LT = `!x y z e. dist(x,z) + dist(y,z) < e ==> dist(x,y) < e`;;\n\nlet DIST_TRIANGLE_HALF_L = `!x1 x2 y. dist(x1,y) < e / &2 /\\ dist(x2,y) < e / &2 ==> dist(x1,x2) < e`;;\n\nlet DIST_TRIANGLE_HALF_R = `!x1 x2 y. dist(y,x1) < e / &2 /\\ dist(y,x2) < e / &2 ==> dist(x1,x2) < e`;;\n\nlet DIST_TRIANGLE_ADD = `!x x' y y'. dist(x + y,x' + y') <= dist(x,x') + dist(y,y')`;;\n\nlet DIST_MUL = `!x y c. dist(c % x,c % y) = abs(c) * dist(x,y)`;;\n\nlet DIST_TRIANGLE_ADD_HALF = `!x x' y y':real^N.\n dist(x,x') < e / &2 /\\ dist(y,y') < e / &2 ==> dist(x + y,x' + y') < e`;;\n\nlet DIST_LE_0 = `!x y. dist(x,y) <= &0 <=> x = y`;;\n\nlet DIST_EQ = `!w x y z. dist(w,x) = dist(y,z) <=> dist(w,x) pow 2 = dist(y,z) pow 2`;;\n\nlet DIST_0 = `!x. dist(x,vec 0) = norm(x) /\\ dist(vec 0,x) = norm(x)`;;\n\nlet DIST_RESCALE = `!a x y:real^N. norm(x) = norm(y) ==> dist(a % x,y) = dist(x,a % y)`;;\n\nlet DIST_DESCALE = `!a b x y:real^N.\n &0 <= a /\\ &0 <= b /\\ norm(x) = norm(y)\n ==> dist(a % x,b % y) >= min a b * dist(x,y)`;;\n\nlet NEUTRAL_VECTOR_ADD = `neutral(+) = vec 0:real^N`;;\n\nlet MONOIDAL_VECTOR_ADD = `monoidal((+):real^N->real^N->real^N)`;;\n\nlet vsum = new_definition\n `(vsum:(A->bool)->(A->real^N)->real^N) s f = lambda i. sum s (\\x. f(x)$i)`;;\n\nlet VSUM_CLAUSES = `(!f. vsum {} f = vec 0) /\\\n (!x f s. FINITE s\n ==> (vsum (x INSERT s) f =\n if x IN s then vsum s f else f(x) + vsum s f))`;;\n\nlet VSUM = `!f s. FINITE s ==> vsum s f = iterate (+) s f`;;\n\nlet VSUM_EQ_0 = `!f s. (!x:A. x IN s ==> (f(x) = vec 0)) ==> (vsum s f = vec 0)`;;\n\nlet VSUM_0 = `vsum s (\\x. vec 0) = vec 0`;;\n\nlet VSUM_LMUL = `!f c s. vsum s (\\x. c % f(x)) = c % vsum s f`;;\n\nlet VSUM_RMUL = `!c s v. vsum s (\\x. c x % v) = (sum s c) % v`;;\n\nlet VSUM_ADD = `!f g s. FINITE s ==> (vsum s (\\x. f x + g x) = vsum s f + vsum s g)`;;\n\nlet VSUM_SUB = `!f g s. FINITE s ==> (vsum s (\\x. f x - g x) = vsum s f - vsum s g)`;;\n\nlet VSUM_CONST = `!c s. FINITE s ==> (vsum s (\\n. c) = &(CARD s) % c)`;;\n\nlet VSUM_COMPONENT = `!s f:A->real^N i. vsum s f$i = sum s (\\x. f x$i)`;;\n\nlet VSUM_IMAGE = `!f g s. FINITE s /\\ (!x y. x IN s /\\ y IN s /\\ (f x = f y) ==> (x = y))\n ==> (vsum (IMAGE f s) g = vsum s (g o f))`;;\n\nlet VSUM_UNION = `!f s t. FINITE s /\\ FINITE t /\\ DISJOINT s t\n ==> (vsum (s UNION t) f = vsum s f + vsum t f)`;;\n\nlet VSUM_DIFF = `!f s t. FINITE s /\\ t SUBSET s\n ==> (vsum (s DIFF t) f = vsum s f - vsum t f)`;;\n\nlet VSUM_DELETE = `!f s a. FINITE s /\\ a IN s\n ==> vsum (s DELETE a) f = vsum s f - f a`;;\n\nlet VSUM_INCL_EXCL = `!s t (f:A->real^N).\n FINITE s /\\ FINITE t\n ==> vsum s f + vsum t f = vsum (s UNION t) f + vsum (s INTER t) f`;;\n\nlet VSUM_NEG = `!f s. vsum s (\\x. --f x) = --vsum s f`;;\n\nlet VSUM_EQ = `!f g s. (!x. x IN s ==> (f x = g x)) ==> (vsum s f = vsum s g)`;;\n\nlet VSUM_SUPERSET = `!f:A->real^N u v.\n u SUBSET v /\\ (!x. x IN v /\\ ~(x IN u) ==> (f(x) = vec 0))\n ==> (vsum v f = vsum u f)`;;\n\nlet VSUM_SUPPORT = `!f:A->real^N s. vsum {x | x IN s /\\ ~(f x = vec 0)} f = vsum s f`;;\n\nlet VSUM_UNIV = `!f:A->real^N s.\n support (+) f (:A) SUBSET s ==> vsum s f = vsum (:A) f`;;\n\nlet VSUM_EQ_SUPERSET = `!f s t:A->bool.\n FINITE t /\\ t SUBSET s /\\\n (!x. x IN t ==> (f x = g x)) /\\\n (!x. x IN s /\\ ~(x IN t) ==> f(x) = vec 0)\n ==> vsum s f = vsum t g`;;\n\nlet VSUM_UNION_RZERO = `!f:A->real^N u v.\n (!x. x IN v /\\ ~(x IN u) ==> (f(x) = vec 0))\n ==> (vsum (u UNION v) f = vsum u f)`;;\n\nlet VSUM_UNION_LZERO = `!f:A->real^N u v.\n (!x. x IN u /\\ ~(x IN v) ==> (f(x) = vec 0))\n ==> (vsum (u UNION v) f = vsum v f)`;;\n\nlet VSUM_RESTRICT = `!f s. vsum s (\\x. if x IN s then f(x) else vec 0) = vsum s f`;;\n\nlet VSUM_RESTRICT_SET = `!P s f. vsum {x | x IN s /\\ P x} f =\n vsum s (\\x. if P x then f x else vec 0)`;;\n\nlet VSUM_CASES = `!s P f g. FINITE s\n ==> vsum s (\\x:A. if P x then (f x):real^N else g x) =\n vsum {x | x IN s /\\ P x} f + vsum {x | x IN s /\\ ~P x} g`;;\n\nlet VSUM_SING = `!f x. vsum {x} f = f(x)`;;\n\nlet VSUM_NORM = `!f s. FINITE s ==> norm(vsum s f) <= sum s (\\x. norm(f x))`;;\n\nlet VSUM_NORM_LE = `!s f:A->real^N g.\n FINITE s /\\ (!x. x IN s ==> norm(f x) <= g(x))\n ==> norm(vsum s f) <= sum s g`;;\n\nlet VSUM_NORM_TRIANGLE = `!s f b. FINITE s /\\ sum s (\\a. norm(f a)) <= b ==> norm(vsum s f) <= b`;;\n\nlet VSUM_NORM_BOUND = `!s f b. FINITE s /\\ (!x:A. x IN s ==> norm(f(x)) <= b)\n ==> norm(vsum s f) <= &(CARD s) * b`;;\n\nlet VSUM_CLAUSES_NUMSEG = `(!m. vsum(m..0) f = if m = 0 then f(0) else vec 0) /\\\n (!m n. vsum(m..SUC n) f = if m <= SUC n then vsum(m..n) f + f(SUC n)\n else vsum(m..n) f)`;;\n\nlet VSUM_CLAUSES_RIGHT = `!f m n. 0 < n /\\ m <= n ==> vsum(m..n) f = vsum(m..n-1) f + (f n):real^N`;;\n\nlet VSUM_CMUL_NUMSEG = `!f c m n. vsum (m..n) (\\x. c % f x) = c % vsum (m..n) f`;;\n\nlet VSUM_EQ_NUMSEG = `!f g m n.\n (!x. m <= x /\\ x <= n ==> (f x = g x))\n ==> (vsum(m .. n) f = vsum(m .. n) g)`;;\n\nlet VSUM_IMAGE_GEN = `!f:A->B g s.\n FINITE s\n ==> (vsum s g =\n vsum (IMAGE f s) (\\y. vsum {x | x IN s /\\ (f(x) = y)} g))`;;\n\nlet VSUM_GROUP = `!f:A->B g s t.\n FINITE s /\\ IMAGE f s SUBSET t\n ==> vsum t (\\y. vsum {x | x IN s /\\ f(x) = y} g) = vsum s g`;;\n\nlet VSUM_GROUP_RELATION = `!R:A->B->bool g s t.\n FINITE s /\\\n (!x. x IN s ==> ?!y. y IN t /\\ R x y)\n ==> vsum t (\\y. vsum {x | x IN s /\\ R x y} g) = vsum s g`;;\n\nlet VSUM_VMUL = `!f v s. (sum s f) % v = vsum s (\\x. f(x) % v)`;;\n\nlet VSUM_DELTA = `!s a. vsum s (\\x. if x = a then b else vec 0) =\n if a IN s then b else vec 0`;;\n\nlet VSUM_ADD_NUMSEG = `!f g m n. vsum(m..n) (\\i. f i + g i) = vsum(m..n) f + vsum(m..n) g`;;\n\nlet VSUM_SUB_NUMSEG = `!f g m n. vsum(m..n) (\\i. f i - g i) = vsum(m..n) f - vsum(m..n) g`;;\n\nlet VSUM_ADD_SPLIT = `!f m n p.\n m <= n + 1 ==> vsum(m..n + p) f = vsum(m..n) f + vsum(n + 1..n + p) f`;;\n\nlet VSUM_VSUM_PRODUCT = `!s:A->bool t:A->B->bool x.\n FINITE s /\\ (!i. i IN s ==> FINITE(t i))\n ==> vsum s (\\i. vsum (t i) (x i)) =\n vsum {i,j | i IN s /\\ j IN t i} (\\(i,j). x i j)`;;\n\nlet VSUM_IMAGE_NONZERO = `!d:B->real^N i:A->B s.\n FINITE s /\\\n (!x y. x IN s /\\ y IN s /\\ ~(x = y) /\\ i x = i y ==> d(i x) = vec 0)\n ==> vsum (IMAGE i s) d = vsum s (d o i)`;;\n\nlet VSUM_UNION_NONZERO = `!f s t. FINITE s /\\ FINITE t /\\ (!x. x IN s INTER t ==> f(x) = vec 0)\n ==> vsum (s UNION t) f = vsum s f + vsum t f`;;\n\nlet VSUM_UNIONS_NONZERO = `!f s. FINITE s /\\ (!t:A->bool. t IN s ==> FINITE t) /\\\n (!t1 t2 x. t1 IN s /\\ t2 IN s /\\ ~(t1 = t2) /\\ x IN t1 /\\ x IN t2\n ==> f x = vec 0)\n ==> vsum (UNIONS s) f = vsum s (\\t. vsum t f)`;;\n\nlet VSUM_CLAUSES_LEFT = `!f m n. m <= n ==> vsum(m..n) f = f m + vsum(m + 1..n) f`;;\n\nlet VSUM_DIFFS = `!m n. vsum(m..n) (\\k. f(k) - f(k + 1)) =\n if m <= n then f(m) - f(n + 1) else vec 0`;;\n\nlet VSUM_DIFFS_ALT = `!m n. vsum(m..n) (\\k. f(k + 1) - f(k)) =\n if m <= n then f(n + 1) - f(m) else vec 0`;;\n\nlet VSUM_DELETE_CASES = `!x f s.\n FINITE(s:A->bool)\n ==> vsum(s DELETE x) f = if x IN s then vsum s f - f x else vsum s f`;;\n\nlet VSUM_EQ_GENERAL = `!s:A->bool t:B->bool (f:A->real^N) g h.\n (!y. y IN t ==> ?!x. x IN s /\\ h x = y) /\\\n (!x. x IN s ==> h x IN t /\\ g(h x) = f x)\n ==> vsum s f = vsum t g`;;\n\nlet VSUM_EQ_GENERAL_INVERSES = `!s t (f:A->real^N) (g:B->real^N) h k.\n (!y. y IN t ==> k y IN s /\\ h (k y) = y) /\\\n (!x. x IN s ==> h x IN t /\\ k (h x) = x /\\ g (h x) = f x)\n ==> vsum s f = vsum t g`;;\n\nlet VSUM_NORM_ALLSUBSETS_BOUND = `!f:A->real^N p e.\n FINITE p /\\\n (!q. q SUBSET p ==> norm(vsum q f) <= e)\n ==> sum p (\\x. norm(f x)) <= &2 * &(dimindex(:N)) * e`;;\n\nlet DOT_LSUM = `!s f y. FINITE s ==> (vsum s f) dot y = sum s (\\x. f(x) dot y)`;;\n\nlet DOT_RSUM = `!s f x. FINITE s ==> x dot (vsum s f) = sum s (\\y. x dot f(y))`;;\n\nlet VSUM_OFFSET = `!p f m n. vsum(m + p..n + p) f = vsum(m..n) (\\i. f (i + p))`;;\n\nlet VSUM_OFFSET_0 = `!f m n. m <= n ==> vsum(m..n) f = vsum(0..n - m) (\\i. f (i + m))`;;\n\nlet VSUM_TRIV_NUMSEG = `!f m n. n < m ==> vsum(m..n) f = vec 0`;;\n\nlet VSUM_CONST_NUMSEG = `!c m n. vsum(m..n) (\\n. c) = &((n + 1) - m) % c`;;\n\nlet VSUM_SUC = `!f m n. vsum (SUC n..SUC m) f = vsum (n..m) (f o SUC)`;;\n\nlet VSUM_BIJECTION = `!f:A->real^N p s:A->bool.\n (!x. x IN s ==> p(x) IN s) /\\\n (!y. y IN s ==> ?!x. x IN s /\\ p(x) = y)\n ==> vsum s f = vsum s (f o p)`;;\n\nlet VSUM_PARTIAL_SUC = `!f g:num->real^N m n.\n vsum (m..n) (\\k. f(k) % (g(k + 1) - g(k))) =\n if m <= n then f(n + 1) % g(n + 1) - f(m) % g(m) -\n vsum (m..n) (\\k. (f(k + 1) - f(k)) % g(k + 1))\n else vec 0`;;\n\nlet VSUM_PARTIAL_PRE = `!f g:num->real^N m n.\n vsum (m..n) (\\k. f(k) % (g(k) - g(k - 1))) =\n if m <= n then f(n + 1) % g(n) - f(m) % g(m - 1) -\n vsum (m..n) (\\k. (f(k + 1) - f(k)) % g(k))\n else vec 0`;;\n\nlet VSUM_COMBINE_L = `!f m n p.\n 0 < n /\\ m <= n /\\ n <= p + 1\n ==> vsum(m..n - 1) f + vsum(n..p) f = vsum(m..p) f`;;\n\nlet VSUM_COMBINE_R = `!f m n p.\n m <= n + 1 /\\ n <= p\n ==> vsum(m..n) f + vsum(n + 1..p) f = vsum(m..p) f`;;\n\nlet VSUM_INJECTION = `!f p s.\n FINITE s /\\\n (!x. x IN s ==> p x IN s) /\\\n (!x y. x IN s /\\ y IN s /\\ p x = p y ==> x = y)\n ==> vsum s (f o p) = vsum s f`;;\n\nlet VSUM_SWAP = `!f s t.\n FINITE s /\\ FINITE t\n ==> vsum s (\\i. vsum t (f i)) = vsum t (\\j. vsum s (\\i. f i j))`;;\n\nlet VSUM_SWAP_NUMSEG = `!a b c d f.\n vsum (a..b) (\\i. vsum (c..d) (f i)) =\n vsum (c..d) (\\j. vsum (a..b) (\\i. f i j))`;;\n\nlet VSUM_ADD_GEN = `!f g s.\n FINITE {x | x IN s /\\ ~(f x = vec 0)} /\\\n FINITE {x | x IN s /\\ ~(g x = vec 0)}\n ==> vsum s (\\x. f x + g x) = vsum s f + vsum s g`;;\n\nlet VSUM_CASES_1 = `!s a. FINITE s /\\ a IN s\n ==> vsum s (\\x. if x = a then y else f(x)) = vsum s f + (y - f a)`;;\n\nlet VSUM_SING_NUMSEG = `vsum(n..n) f = f n`;;\n\nlet VSUM_1 = `vsum(1..1) f = f(1)`;;\n\nlet VSUM_2 = `!t. vsum(1..2) t = t(1) + t(2)`;;\n\nlet VSUM_3 = `!t. vsum(1..3) t = t(1) + t(2) + t(3)`;;\n\nlet VSUM_4 = `!t. vsum(1..4) t = t(1) + t(2) + t(3) + t(4)`;;\n\nlet VSUM_PAIR = `!f:num->real^N m n.\n vsum(2*m..2*n+1) f = vsum(m..n) (\\i. f(2*i) + f(2*i+1))`;;\n\nlet VSUM_PAIR_0 = `!f:num->real^N n. vsum(0..2*n+1) f = vsum(0..n) (\\i. f(2*i) + f(2*i+1))`;;\n\nlet VSUM_REFLECT = `!x m n. vsum(m..n) x =\n if n < m then vec 0 else vsum(0..n-m) (\\i. x(n - i))`;;\n\nlet th = `(!f g s. (!x. x IN s ==> f(x) = g(x))\n ==> vsum s (\\i. f(i)) = vsum s g) /\\\n (!f g a b. (!i. a <= i /\\ i <= b ==> f(i) = g(i))\n ==> vsum(a..b) (\\i. f(i)) = vsum(a..b) g) /\\\n (!f g p. (!x. p x ==> f x = g x)\n ==> vsum {y | p y} (\\i. f(i)) = vsum {y | p y} g)`;;\n\nlet EXPAND_VSUM_CONV =\n let [pth_0; pth_1; pth_2] = (CONJUNCTS o prove)\n (`(n < m ==> vsum(m..n) (f:num->real^N) = vec 0) /\\\n vsum(m..m) (f:num->real^N) = f m /\\\n (m <= n ==> vsum (m..n) (f:num->real^N) = f m + vsum (m + 1..n) f)`,\n REWRITE_TAC[VSUM_CLAUSES_LEFT; VSUM_SING_NUMSEG; VSUM_TRIV_NUMSEG])\n and ns_tm = `..` and f_tm = `f:num->real^N`\n and m_tm = `m:num` and n_tm = `n:num`\n and n_ty = `:N` in\n let rec conv tm =\n let smn,ftm = dest_comb tm in\n let s,mn = dest_comb smn in\n if not(is_const s && fst(dest_const s) = \"vsum\")\n then failwith \"EXPAND_VSUM_CONV\" else\n let mtm,ntm = dest_binop ns_tm mn in\n let m = dest_numeral mtm and n = dest_numeral ntm in\n let nty = hd(tl(snd(dest_type(snd(dest_fun_ty(type_of ftm)))))) in\n let ilist = [nty,n_ty] in\n let ifn = inst ilist and tfn = INST_TYPE ilist in\n if n < m then\n let th1 = INST [ftm,ifn f_tm; mtm,m_tm; ntm,n_tm] (tfn pth_0) in\n MP th1 (EQT_ELIM(NUM_LT_CONV(lhand(concl th1))))\n else if n = m then CONV_RULE (RAND_CONV(TRY_CONV BETA_CONV))\n (INST [ftm,ifn f_tm; mtm,m_tm] (tfn pth_1))\n else\n let th1 = INST [ftm,ifn f_tm; mtm,m_tm; ntm,n_tm] (tfn pth_2) in\n let th2 = MP th1 (EQT_ELIM(NUM_LE_CONV(lhand(concl th1)))) in\n CONV_RULE (RAND_CONV(COMB2_CONV (RAND_CONV(TRY_CONV BETA_CONV))\n (LAND_CONV(LAND_CONV NUM_ADD_CONV) THENC conv))) th2 in\n conv;;\n\nlet basis = new_definition\n `basis k = lambda i. if i = k then &1 else &0`;;\n\nlet NORM_BASIS = `!k. 1 <= k /\\ k <= dimindex(:N)\n ==> (norm(basis k :real^N) = &1)`;;\n\nlet NORM_BASIS_1 = `norm(basis 1) = &1`;;\n\nlet VECTOR_CHOOSE_SIZE = `!c. &0 <= c ==> ?x:real^N. norm(x) = c`;;\n\nlet VECTOR_CHOOSE_DIST = `!x e. &0 <= e ==> ?y:real^N. dist(x,y) = e`;;\n\nlet BASIS_INJ = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\\n (basis i :real^N = basis j)\n ==> (i = j)`;;\n\nlet BASIS_INJ_EQ = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\ 1 <= j /\\ j <= dimindex(:N)\n ==> (basis i:real^N = basis j <=> i = j)`;;\n\nlet BASIS_NE = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\\n ~(i = j)\n ==> ~(basis i :real^N = basis j)`;;\n\nlet BASIS_COMPONENT = `!k i. 1 <= i /\\ i <= dimindex(:N)\n ==> ((basis k :real^N)$i = if i = k then &1 else &0)`;;\n\nlet BASIS_EXPANSION = `!x:real^N. vsum(1..dimindex(:N)) (\\i. x$i % basis i) = x`;;\n\nlet BASIS_EXPANSION_UNIQUE = `!f x:real^N. (vsum(1..dimindex(:N)) (\\i. f(i) % basis i) = x) <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> f(i) = x$i)`;;\n\nlet DOT_BASIS = `!x:real^N i.\n 1 <= i /\\ i <= dimindex(:N)\n ==> ((basis i) dot x = x$i) /\\ (x dot (basis i) = x$i)`;;\n\nlet DOT_BASIS_BASIS = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> (basis i:real^N) dot (basis j) = if i = j then &1 else &0`;;\n\nlet DOT_BASIS_BASIS_UNEQUAL = `!i j. ~(i = j) ==> (basis i) dot (basis j) = &0`;;\n\nlet BASIS_EQ_0 = `!i. (basis i :real^N = vec 0) <=> ~(i IN 1..dimindex(:N))`;;\n\nlet BASIS_NONZERO = `!k. 1 <= k /\\ k <= dimindex(:N)\n ==> ~(basis k :real^N = vec 0)`;;\n\nlet VECTOR_EQ_LDOT = `!y z. (!x. x dot y = x dot z) <=> y = z`;;\n\nlet VECTOR_EQ_RDOT = `!x y. (!z. x dot z = y dot z) <=> x = y`;;\n\nlet orthogonal = new_definition\n `orthogonal x y <=> (x dot y = &0)`;;\n\nlet ORTHOGONAL_0 = `!x. orthogonal (vec 0) x /\\ orthogonal x (vec 0)`;;\n\nlet ORTHOGONAL_REFL = `!x. orthogonal x x <=> x = vec 0`;;\n\nlet ORTHOGONAL_SYM = `!x y. orthogonal x y <=> orthogonal y x`;;\n\nlet ORTHOGONAL_LNEG = `!x y. orthogonal (--x) y <=> orthogonal x y`;;\n\nlet ORTHOGONAL_RNEG = `!x y. orthogonal x (--y) <=> orthogonal x y`;;\n\nlet ORTHOGONAL_MUL = `(!a x y:real^N. orthogonal (a % x) y <=> a = &0 \\/ orthogonal x y) /\\\n (!a x y:real^N. orthogonal x (a % y) <=> a = &0 \\/ orthogonal x y)`;;\n\nlet ORTHOGONAL_BASIS = `!x:real^N i. 1 <= i /\\ i <= dimindex(:N)\n ==> (orthogonal (basis i) x <=> (x$i = &0))`;;\n\nlet ORTHOGONAL_BASIS_BASIS = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> (orthogonal (basis i :real^N) (basis j) <=> ~(i = j))`;;\n\nlet ORTHOGONAL_CLAUSES = `(!a. orthogonal a (vec 0)) /\\\n (!a x c. orthogonal a x ==> orthogonal a (c % x)) /\\\n (!a x. orthogonal a x ==> orthogonal a (--x)) /\\\n (!a x y. orthogonal a x /\\ orthogonal a y ==> orthogonal a (x + y)) /\\\n (!a x y. orthogonal a x /\\ orthogonal a y ==> orthogonal a (x - y)) /\\\n (!a. orthogonal (vec 0) a) /\\\n (!a x c. orthogonal x a ==> orthogonal (c % x) a) /\\\n (!a x. orthogonal x a ==> orthogonal (--x) a) /\\\n (!a x y. orthogonal x a /\\ orthogonal y a ==> orthogonal (x + y) a) /\\\n (!a x y. orthogonal x a /\\ orthogonal y a ==> orthogonal (x - y) a)`;;\n\nlet ORTHOGONAL_RVSUM = `!f:A->real^N s x.\n FINITE s /\\\n (!y. y IN s ==> orthogonal x (f y))\n ==> orthogonal x (vsum s f)`;;\n\nlet ORTHOGONAL_LVSUM = `!f:A->real^N s y.\n FINITE s /\\\n (!x. x IN s ==> orthogonal (f x) y)\n ==> orthogonal (vsum s f) y`;;\n\nlet NORM_ADD_PYTHAGOREAN = `!a b:real^N.\n orthogonal a b\n ==> norm(a + b) pow 2 = norm(a) pow 2 + norm(b) pow 2`;;\n\nlet NORM_VSUM_PYTHAGOREAN = `!k u:A->real^N.\n FINITE k /\\ pairwise (\\i j. orthogonal (u i) (u j)) k\n ==> norm(vsum k u) pow 2 = sum k (\\i. norm(u i) pow 2)`;;\n\nlet VECTOR_1 = `(vector[x]:A^1)$1 = x`;;\n\nlet VECTOR_2 = `(vector[x;y]:A^2)$1 = x /\\\n (vector[x;y]:A^2)$2 = y`;;\n\nlet VECTOR_3 = `(vector[x;y;z]:A^3)$1 = x /\\\n (vector[x;y;z]:A^3)$2 = y /\\\n (vector[x;y;z]:A^3)$3 = z`;;\n\nlet VECTOR_4 = `(vector[w;x;y;z]:A^4)$1 = w /\\\n (vector[w;x;y;z]:A^4)$2 = x /\\\n (vector[w;x;y;z]:A^4)$3 = y /\\\n (vector[w;x;y;z]:A^4)$4 = z`;;\n\nlet FORALL_VECTOR_1 = `(!v:A^1. P v) <=> !x. P(vector[x])`;;\n\nlet FORALL_VECTOR_2 = `(!v:A^2. P v) <=> !x y. P(vector[x;y])`;;\n\nlet FORALL_VECTOR_3 = `(!v:A^3. P v) <=> !x y z. P(vector[x;y;z])`;;\n\nlet FORALL_VECTOR_4 = `(!v:A^4. P v) <=> !w x y z. P(vector[w;x;y;z])`;;\n\nlet EXISTS_VECTOR_1 = `(?v:A^1. P v) <=> ?x. P(vector[x])`;;\n\nlet EXISTS_VECTOR_2 = `(?v:A^2. P v) <=> ?x y. P(vector[x;y])`;;\n\nlet EXISTS_VECTOR_3 = `(?v:A^3. P v) <=> ?x y z. P(vector[x;y;z])`;;\n\nlet EXISTS_VECTOR_4 = `(?v:A^4. P v) <=> ?w x y z. P(vector[w;x;y;z])`;;\n\nlet VECTOR_EXPAND_1 = `!x:real^1. x = vector[x$1]`;;\n\nlet VECTOR_EXPAND_2 = `!x:real^2. x = vector[x$1;x$2]`;;\n\nlet VECTOR_EXPAND_3 = `!x:real^3. x = vector[x$1;x$2;x$3]`;;\n\nlet VECTOR_EXPAND_4 = `!x:real^4. x = vector[x$1;x$2;x$3;x$4]`;;\n\nlet linear = new_definition\n `linear (f:real^M->real^N) <=>\n (!x y. f(x + y) = f(x) + f(y)) /\\\n (!c x. f(c % x) = c % f(x))`;;\n\nlet LINEAR_COMPOSE_CMUL = `!f c. linear f ==> linear (\\x. c % f(x))`;;\n\nlet LINEAR_COMPOSE_NEG = `!f. linear f ==> linear (\\x. --(f(x)))`;;\n\nlet LINEAR_COMPOSE_NEG_EQ = `!f:real^M->real^N. linear(\\x. --(f x)) <=> linear f`;;\n\nlet LINEAR_COMPOSE_ADD = `!f g. linear f /\\ linear g ==> linear (\\x. f(x) + g(x))`;;\n\nlet LINEAR_COMPOSE_SUB = `!f g. linear f /\\ linear g ==> linear (\\x. f(x) - g(x))`;;\n\nlet LINEAR_COMPOSE = `!f g. linear f /\\ linear g ==> linear (g o f)`;;\n\nlet LINEAR_ID = `linear (\\x. x)`;;\n\nlet LINEAR_I = `linear I`;;\n\nlet LINEAR_ZERO = `linear (\\x. vec 0)`;;\n\nlet LINEAR_NEGATION = `linear(--)`;;\n\nlet LINEAR_COMPOSE_VSUM = `!f s. FINITE s /\\ (!a. a IN s ==> linear(f a))\n ==> linear(\\x. vsum s (\\a. f a x))`;;\n\nlet LINEAR_VMUL_COMPONENT = `!f:real^M->real^N v k.\n linear f /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> linear (\\x. f(x)$k % v)`;;\n\nlet LINEAR_0 = `!f. linear f ==> (f(vec 0) = vec 0)`;;\n\nlet LINEAR_CMUL = `!f c x. linear f ==> (f(c % x) = c % f(x))`;;\n\nlet LINEAR_NEG = `!f x. linear f ==> (f(--x) = --(f x))`;;\n\nlet LINEAR_ADD = `!f x y. linear f ==> (f(x + y) = f(x) + f(y))`;;\n\nlet LINEAR_SUB = `!f x y. linear f ==> (f(x - y) = f(x) - f(y))`;;\n\nlet LINEAR_VSUM = `!f g s. linear f /\\ FINITE s ==> (f(vsum s g) = vsum s (f o g))`;;\n\nlet LINEAR_VSUM_MUL = `!f s c v.\n linear f /\\ FINITE s\n ==> f(vsum s (\\i. c i % v i)) = vsum s (\\i. c(i) % f(v i))`;;\n\nlet LINEAR_INJECTIVE_0 = `!f. linear f\n ==> ((!x y. (f(x) = f(y)) ==> (x = y)) <=>\n (!x. (f(x) = vec 0) ==> (x = vec 0)))`;;\n\nlet LINEAR_BOUNDED = `!f:real^M->real^N. linear f ==> ?B. !x. norm(f x) <= B * norm(x)`;;\n\nlet LINEAR_BOUNDED_POS = `!f:real^M->real^N. linear f ==> ?B. &0 < B /\\ !x. norm(f x) <= B * norm(x)`;;\n\nlet SYMMETRIC_LINEAR_IMAGE = `!f s. (!x. x IN s ==> --x IN s) /\\ linear f\n ==> !x. x IN (IMAGE f s) ==> --x IN (IMAGE f s)`;;\n\nlet bilinear = new_definition\n `bilinear f <=> (!x. linear(\\y. f x y)) /\\ (!y. linear(\\x. f x y))`;;\n\nlet BILINEAR_SWAP = `!op:real^M->real^N->real^P.\n bilinear(\\x y. op y x) <=> bilinear op`;;\n\nlet BILINEAR_LADD = `!h x y z. bilinear h ==> h (x + y) z = (h x z) + (h y z)`;;\n\nlet BILINEAR_RADD = `!h x y z. bilinear h ==> h x (y + z) = (h x y) + (h x z)`;;\n\nlet BILINEAR_LMUL = `!h c x y. bilinear h ==> h (c % x) y = c % (h x y)`;;\n\nlet BILINEAR_RMUL = `!h c x y. bilinear h ==> h x (c % y) = c % (h x y)`;;\n\nlet BILINEAR_LNEG = `!h x y. bilinear h ==> h (--x) y = --(h x y)`;;\n\nlet BILINEAR_RNEG = `!h x y. bilinear h ==> h x (--y) = --(h x y)`;;\n\nlet BILINEAR_LZERO = `!h x. bilinear h ==> h (vec 0) x = vec 0`;;\n\nlet BILINEAR_RZERO = `!h x. bilinear h ==> h x (vec 0) = vec 0`;;\n\nlet BILINEAR_LSUB = `!h x y z. bilinear h ==> h (x - y) z = (h x z) - (h y z)`;;\n\nlet BILINEAR_RSUB = `!h x y z. bilinear h ==> h x (y - z) = (h x y) - (h x z)`;;\n\nlet BILINEAR_LSUM = `!bop:real^M->real^N->real^P f s:A->bool y.\n bilinear bop /\\ FINITE s\n ==> bop(vsum s f) y = vsum s (\\i. bop (f i) y)`;;\n\nlet BILINEAR_RSUM = `!bop:real^M->real^N->real^P f s:A->bool x.\n bilinear bop /\\ FINITE s\n ==> bop x (vsum s f) = vsum s (\\i. bop x (f i))`;;\n\nlet BILINEAR_VSUM = `!h:real^M->real^N->real^P.\n bilinear h /\\ FINITE s /\\ FINITE t\n ==> h (vsum s f) (vsum t g) = vsum (s CROSS t) (\\(i,j). h (f i) (g j))`;;\n\nlet BILINEAR_BOUNDED = `!h:real^M->real^N->real^P.\n bilinear h ==> ?B. !x y. norm(h x y) <= B * norm(x) * norm(y)`;;\n\nlet BILINEAR_BOUNDED_POS = `!h. bilinear h\n ==> ?B. &0 < B /\\ !x y. norm(h x y) <= B * norm(x) * norm(y)`;;\n\nlet BILINEAR_VSUM_PARTIAL_SUC = `!f g h:real^M->real^N->real^P m n.\n bilinear h\n ==> vsum (m..n) (\\k. h (f k) (g(k + 1) - g(k))) =\n if m <= n then h (f(n + 1)) (g(n + 1)) - h (f m) (g m) -\n vsum (m..n) (\\k. h (f(k + 1) - f(k)) (g(k + 1)))\n else vec 0`;;\n\nlet BILINEAR_VSUM_PARTIAL_PRE = `!f g h:real^M->real^N->real^P m n.\n bilinear h\n ==> vsum (m..n) (\\k. h (f k) (g(k) - g(k - 1))) =\n if m <= n then h (f(n + 1)) (g(n)) - h (f m) (g(m - 1)) -\n vsum (m..n) (\\k. h (f(k + 1) - f(k)) (g(k)))\n else vec 0`;;\n\nlet BILINEAR_VSUM_CONVOLUTION_1 = `!bop:real^M->real^N->real^P a b n.\n bilinear bop\n ==> vsum(0..n) (\\m. vsum (0..m) (\\i. bop (a i) (b(m - i)))) =\n vsum(0..n) (\\m. bop (a m) (vsum(0..n-m) b))`;;\n\nlet BILINEAR_VSUM_CONVOLUTION_2 = `!bop:real^M->real^N->real^P a b n.\n bilinear bop\n ==> vsum(0..n) (\\m. vsum(0..m) (\\k. vsum(0..k) (\\i. bop (a i) (b(k-i))))) =\n vsum(0..n) (\\m. bop (vsum(0..m) a) (vsum(0..n-m) b))`;;\n\nlet adjoint = new_definition\n `adjoint(f:real^M->real^N) = @f'. !x y. f(x) dot y = x dot f'(y)`;;\n\nlet ADJOINT_WORKS = `!f:real^M->real^N. linear f ==> !x y. f(x) dot y = x dot (adjoint f)(y)`;;\n\nlet ADJOINT_LINEAR = `!f:real^M->real^N. linear f ==> linear(adjoint f)`;;\n\nlet ADJOINT_CLAUSES = `!f:real^M->real^N.\n linear f ==> (!x y. x dot (adjoint f)(y) = f(x) dot y) /\\\n (!x y. (adjoint f)(y) dot x = y dot f(x))`;;\n\nlet ADJOINT_ADJOINT = `!f:real^M->real^N. linear f ==> adjoint(adjoint f) = f`;;\n\nlet ADJOINT_UNIQUE = `!f f'. linear f /\\ (!x y. f'(x) dot y = x dot f(y))\n ==> f' = adjoint f`;;\n\nlet ADJOINT_COMPOSE = `!f g:real^N->real^N.\n linear f /\\ linear g ==> adjoint(f o g) = adjoint g o adjoint f`;;\n\nlet SELF_ADJOINT_COMPOSE = `!f g:real^N->real^N.\n linear f /\\ linear g /\\ adjoint f = f /\\ adjoint g = g\n ==> (adjoint(f o g) = f o g <=> f o g = g o f)`;;\n\nlet SELF_ADJOINT_ORTHOGONAL_EIGENVECTORS = `!f:real^N->real^N v w a b.\n linear f /\\ adjoint f = f /\\ f v = a % v /\\ f w = b % w /\\ ~(a = b)\n ==> orthogonal v w`;;\n\nlet ORTHOGONAL_PROJECTION_ALT = `!f:real^N->real^N.\n linear f\n ==> ((!x y. orthogonal (f x - x) (f x - f y)) <=>\n (!x y. orthogonal (f x - x) (f y)))`;;\n\nlet ORTHOGONAL_PROJECTION_EQ_SELF_ADJOINT_IDEMPOTENT = `!f:real^N->real^N.\n linear f\n ==> ((!x y. orthogonal (f x - x) (f x - f y)) <=>\n adjoint f = f /\\ f o f = f)`;;\n\nlet LIPSCHITZ_ON_POS = `!f:real^M->real^N s.\n (?B. !x y. x IN s /\\ y IN s\n ==> norm(f x - f y) <= B * norm(x - y)) <=>\n (?B. &0 < B /\\\n !x y. x IN s /\\ y IN s\n ==> norm(f x - f y) <= B * norm(x - y))`;;\n\nlet LIPSCHITZ_POS = `!f:real^M->real^N.\n (?B. !x y. norm(f x - f y) <= B * norm(x - y)) <=>\n (?B. &0 < B /\\ !x y. norm(f x - f y) <= B * norm(x - y))`;;\n\nlet LIPSCHITZ_ON_COMPOSE = `!f:real^M->real^N g:real^N->real^P s t.\n (?B. !x y. x IN s /\\ y IN s ==> norm(f x - f y) <= B * norm(x - y)) /\\\n (?B. !x y. x IN t /\\ y IN t ==> norm(g x - g y) <= B * norm(x - y)) /\\\n IMAGE f s SUBSET t\n ==> ?B. !x y. x IN s /\\ y IN s\n ==> norm(g(f x) - g(f y)) <= B * norm(x - y)`;;\n\nlet LINEAR_IMP_LIPSCHITZ = `!f:real^M->real^N.\n linear f ==> ?B. !x y. norm(f x - f y) <= B * norm(x - y)`;;\n\nlet LIPSCHITZ_ON_COMPONENTWISE = `!f:real^M->real^N s.\n (?B. !x y. x IN s /\\ y IN s ==> norm(f x - f y) <= B * norm(x - y)) <=>\n !i. 1 <= i /\\ i <= dimindex(:N)\n ==> ?B. !x y. x IN s /\\ y IN s\n ==> abs(f x$i - f y$i) <= B * norm(x - y)`;;\n\noverload_interface (\"--\",`(matrix_neg):real^N^M->real^N^M`);;\noverload_interface (\"+\",`(matrix_add):real^N^M->real^N^M->real^N^M`);;\noverload_interface (\"-\",`(matrix_sub):real^N^M->real^N^M->real^N^M`);;\n\nmake_overloadable \"**\" `:A->B->C`;;\n\noverload_interface (\"**\",`(vector_matrix_mul):real^M->real^N^M->real^N`);;\noverload_interface (\"**\",`(matrix_mul):real^N^M->real^P^N->real^P^M`);;\noverload_interface (\"**\",`(matrix_vector_mul):real^N^M->real^N->real^M`);;\n\nparse_as_infix(\"%%\",(21,\"right\"));;\n\nprioritize_real();;\n\nlet matrix_cmul = new_definition\n `((%%):real->real^N^M->real^N^M) c A = lambda i j. c * A$i$j`;;\n\nlet matrix_neg = new_definition\n `!A:real^N^M. --A = lambda i j. --(A$i$j)`;;\n\nlet matrix_add = new_definition\n `!A:real^N^M B:real^N^M. A + B = lambda i j. A$i$j + B$i$j`;;\n\nlet matrix_sub = new_definition\n `!A:real^N^M B:real^N^M. A - B = lambda i j. A$i$j - B$i$j`;;\n\nlet matrix_mul = new_definition\n `!A:real^N^M B:real^P^N.\n A ** B =\n lambda i j. sum(1..dimindex(:N)) (\\k. A$i$k * B$k$j)`;;\n\nlet matrix_vector_mul = new_definition\n `!A:real^N^M x:real^N.\n A ** x = lambda i. sum(1..dimindex(:N)) (\\j. A$i$j * x$j)`;;\n\nlet vector_matrix_mul = new_definition\n `!A:real^N^M x:real^M.\n x ** A = lambda j. sum(1..dimindex(:M)) (\\i. A$i$j * x$i)`;;\n\nlet mat = new_definition\n `(mat:num->real^N^M) k = lambda i j. if i = j then &k else &0`;;\n\nlet transp = new_definition\n `(transp:real^N^M->real^M^N) A = lambda i j. A$j$i`;;\n\nlet row = new_definition\n `(row:num->real^N^M->real^N) i A = lambda j. A$i$j`;;\n\nlet column = new_definition\n `(column:num->real^N^M->real^M) j A = lambda i. A$i$j`;;\n\nlet rows = new_definition\n `rows(A:real^N^M) = { row i A | 1 <= i /\\ i <= dimindex(:M)}`;;\n\nlet columns = new_definition\n `columns(A:real^N^M) = { column i A | 1 <= i /\\ i <= dimindex(:N)}`;;\n\nlet MATRIX_CMUL_COMPONENT = `!c A:real^N^M i. (c %% A)$i$j = c * A$i$j`;;\n\nlet MATRIX_ADD_COMPONENT = `!A B:real^N^M i j. (A + B)$i$j = A$i$j + B$i$j`;;\n\nlet MATRIX_SUB_COMPONENT = `!A B:real^N^M i j. (A - B)$i$j = A$i$j - B$i$j`;;\n\nlet MATRIX_NEG_COMPONENT = `!A:real^N^M i j. (--A)$i$j = --(A$i$j)`;;\n\nlet TRANSP_COMPONENT = `!A:real^N^M i j. (transp A)$i$j = A$j$i`;;\n\nlet MAT_COMPONENT = `!n i j.\n 1 <= i /\\ i <= dimindex(:M) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> (mat n:real^N^M)$i$j = if i = j then &n else &0`;;\n\nlet MAT_0_COMPONENT = `!i j. (mat 0:real^N^M)$i$j = &0`;;\n\nlet MATRIX_ADD_ROW = `!X Y:real^M^N i. (X + Y)$i = X$i + Y$i`;;\n\nlet MATRIX_SUB_ROW = `!X Y:real^M^N i. (X - Y)$i = X$i - Y$i`;;\n\nlet MATRIX_NEG_ROW = `!X:real^M^N i. (--X)$i = --(X$i)`;;\n\nlet MATRIX_CMUL_ROW = `!c X:real^M^N i. (c %% X)$i = c % X$i`;;\n\nlet MAT_0_ROW = `mat 0:real^M^N$i = vec 0`;;\n\nlet symmetric_matrix = new_definition\n `symmetric_matrix (A:real^N^N) <=> transp A = A`;;\n\nlet normal_matrix = new_definition\n `normal_matrix (A:real^N^N) <=> transp A ** A = A ** transp A`;;\n\nlet SYMMETRIC_IMP_NORMAL_MATRIX = `!A:real^N^N. symmetric_matrix A ==> normal_matrix A`;;\n\nlet MATRIX_ARITH_TAC =\n let CART2_EQ_FULL = `!x y:A^M^N. x = y <=> (!i j. x$i$j = y$i$j)`;;\n\nlet MAT_CMUL = `!a. mat a = &a %% mat 1`;;\n\nlet ROW_0 = `!i. row i (mat 0:real^N^N) = vec 0`;;\n\nlet COLUMN_0 = `!i. column i (mat 0:real^N^N) = vec 0`;;\n\nlet MATRIX_CMUL_ASSOC = `!a b X:real^M^N. a %% (b %% X) = (a * b) %% X`;;\n\nlet MATRIX_CMUL_LID = `!X:real^M^N. &1 %% X = X`;;\n\nlet MATRIX_ADD_SYM = `!A:real^N^M B. A + B = B + A`;;\n\nlet MATRIX_ADD_ASSOC = `!A:real^N^M B C. A + (B + C) = (A + B) + C`;;\n\nlet MATRIX_ADD_LID = `!A. mat 0 + A = A`;;\n\nlet MATRIX_ADD_RID = `!A. A + mat 0 = A`;;\n\nlet MATRIX_ADD_LNEG = `!A. --A + A = mat 0`;;\n\nlet MATRIX_ADD_RNEG = `!A. A + --A = mat 0`;;\n\nlet MATRIX_SUB = `!A:real^N^M B. A - B = A + --B`;;\n\nlet MATRIX_SUB_REFL = `!A. A - A = mat 0`;;\n\nlet MATRIX_SUB_EQ = `!A B:real^N^M. A - B = mat 0 <=> A = B`;;\n\nlet MATRIX_SUB_ADD = `!A B:real^N^M. (A - B) + B = A`;;\n\nlet MATRIX_SUB_ADD2 = `!A B:real^N^M. A + (B - A) = B`;;\n\nlet MATRIX_ADD_LDISTRIB = `!A:real^N^M B:real^P^N C. A ** (B + C) = A ** B + A ** C`;;\n\nlet MATRIX_MUL_LID = `!A:real^N^M. mat 1 ** A = A`;;\n\nlet MATRIX_MUL_RID = `!A:real^N^M. A ** mat 1 = A`;;\n\nlet MATRIX_MUL_ASSOC = `!A:real^N^M B:real^P^N C:real^Q^P. A ** B ** C = (A ** B) ** C`;;\n\nlet MATRIX_MUL_LZERO = `!A. (mat 0:real^N^M) ** (A:real^P^N) = mat 0`;;\n\nlet MATRIX_MUL_RZERO = `!A. (A:real^N^M) ** (mat 0:real^P^N) = mat 0`;;\n\nlet MATRIX_ADD_RDISTRIB = `!A:real^N^M B C:real^P^N. (A + B) ** C = A ** C + B ** C`;;\n\nlet MATRIX_SUB_LDISTRIB = `!A:real^N^M B C:real^P^N. A ** (B - C) = A ** B - A ** C`;;\n\nlet MATRIX_SUB_RDISTRIB = `!A:real^N^M B C:real^P^N. (A - B) ** C = A ** C - B ** C`;;\n\nlet MATRIX_MUL_LMUL = `!A:real^N^M B:real^P^N c. (c %% A) ** B = c %% (A ** B)`;;\n\nlet MATRIX_MUL_RMUL = `!A:real^N^M B:real^P^N c. A ** (c %% B) = c %% (A ** B)`;;\n\nlet MATRIX_CMUL_ADD_LDISTRIB = `!A:real^N^M B c. c %% (A + B) = c %% A + c %% B`;;\n\nlet MATRIX_CMUL_SUB_LDISTRIB = `!A:real^N^M B c. c %% (A - B) = c %% A - c %% B`;;\n\nlet MATRIX_CMUL_ADD_RDISTRIB = `!A:real^N^M b c. (b + c) %% A = b %% A + c %% A`;;\n\nlet MATRIX_CMUL_SUB_RDISTRIB = `!A:real^N^M b c. (b - c) %% A = b %% A - c %% A`;;\n\nlet MATRIX_CMUL_RZERO = `!c. c %% mat 0 = mat 0`;;\n\nlet MATRIX_CMUL_LZERO = `!A. &0 %% A = mat 0`;;\n\nlet MATRIX_NEG_MINUS1 = `!A:real^N^M. --A = --(&1) %% A`;;\n\nlet MATRIX_ADD_AC = `(A:real^N^M) + B = B + A /\\\n (A + B) + C = A + (B + C) /\\\n A + (B + C) = B + (A + C)`;;\n\nlet MATRIX_NEG_ADD = `!A B:real^N^M. --(A + B) = --A + --B`;;\n\nlet MATRIX_NEG_SUB = `!A B:real^N^M. --(A - B) = B - A`;;\n\nlet MATRIX_NEG_0 = `--(mat 0) = mat 0`;;\n\nlet MATRIX_SUB_RZERO = `!A:real^N^M. A - mat 0 = A`;;\n\nlet MATRIX_SUB_LZERO = `!A:real^N^M. mat 0 - A = --A`;;\n\nlet MATRIX_NEG_EQ_0 = `!A:real^N^M. --A = mat 0 <=> A = mat 0`;;\n\nlet MATRIX_VECTOR_MUL_ASSOC = `!A:real^N^M B:real^P^N x:real^P. A ** B ** x = (A ** B) ** x`;;\n\nlet MATRIX_VECTOR_MUL_LID = `!x:real^N. mat 1 ** x = x`;;\n\nlet MATRIX_VECTOR_MUL_LZERO = `!x:real^N. mat 0 ** x = vec 0`;;\n\nlet MATRIX_VECTOR_MUL_RZERO = `!A:real^M^N. A ** vec 0 = vec 0`;;\n\nlet MATRIX_VECTOR_MUL_ADD_LDISTRIB = `!A:real^M^N x:real^M y. A ** (x + y) = A ** x + A ** y`;;\n\nlet MATRIX_VECTOR_MUL_SUB_LDISTRIB = `!A:real^M^N x:real^M y. A ** (x - y) = A ** x - A ** y`;;\n\nlet MATRIX_VECTOR_MUL_ADD_RDISTRIB = `!A:real^M^N B x:real^M. (A + B) ** x = (A ** x) + (B ** x)`;;\n\nlet MATRIX_VECTOR_MUL_SUB_RDISTRIB = `!A:real^M^N B x:real^M. (A - B) ** x = (A ** x) - (B ** x)`;;\n\nlet MATRIX_VECTOR_MUL_RMUL = `!A:real^M^N x:real^M c. A ** (c % x) = c % (A ** x)`;;\n\nlet MATRIX_MUL_LNEG = `!A:real^N^M B:real^P^N. (--A) ** B = --(A ** B)`;;\n\nlet MATRIX_MUL_RNEG = `!A:real^N^M B:real^P^N. A ** --B = --(A ** B)`;;\n\nlet MATRIX_NEG_NEG = `!A:real^N^M. --(--A) = A`;;\n\nlet MATRIX_TRANSP_MUL = `!A B. transp(A ** B) = transp(B) ** transp(A)`;;\n\nlet TRANSP_EQ_0 = `!A:real^N^M. transp A = mat 0 <=> A = mat 0`;;\n\nlet SYMMETRIC_MATRIX_MUL = `!A B:real^N^N.\n symmetric_matrix A /\\ symmetric_matrix B\n ==> (symmetric_matrix(A ** B) <=> A ** B = B ** A)`;;\n\nlet MATRIX_EQ = `!A:real^N^M B. (A = B) = !x:real^N. A ** x = B ** x`;;\n\nlet MATRIX_EQ_0 = `!A:real^N^N. A = mat 0 <=> !x. A ** x = vec 0`;;\n\nlet MATRIX_VECTOR_MUL_COMPONENT = `!A:real^N^M x k.\n 1 <= k /\\ k <= dimindex(:M) ==> ((A ** x)$k = (A$k) dot x)`;;\n\nlet DOT_LMUL_MATRIX = `!A:real^N^M x:real^M y:real^N. (x ** A) dot y = x dot (A ** y)`;;\n\nlet TRANSP_MATRIX_CMUL = `!A:real^M^N c. transp(c %% A) = c %% transp A`;;\n\nlet SYMMETRIC_MATRIX_CMUL = `!c A:real^N^N.\n symmetric_matrix A ==> symmetric_matrix(c %% A)`;;\n\nlet TRANSP_MATRIX_ADD = `!A B:real^N^M. transp(A + B) = transp A + transp B`;;\n\nlet SYMMETRIC_MATRIX_ADD = `!A B:real^N^N.\n symmetric_matrix A /\\ symmetric_matrix B\n ==> symmetric_matrix(A + B)`;;\n\nlet TRANSP_MATRIX_SUB = `!A B:real^N^M. transp(A - B) = transp A - transp B`;;\n\nlet SYMMETRIC_MATRIX_SUB = `!A B:real^N^N.\n symmetric_matrix A /\\ symmetric_matrix B\n ==> symmetric_matrix(A - B)`;;\n\nlet TRANSP_MATRIX_NEG = `!A:real^N^M. transp(--A) = --(transp A)`;;\n\nlet SYMMETRIC_MATRIX_NEG = `!A:real^N^N. symmetric_matrix(--A) <=> symmetric_matrix A`;;\n\nlet TRANSP_MAT = `!n. transp(mat n) = mat n`;;\n\nlet TRANSP_TRANSP = `!A:real^N^M. transp(transp A) = A`;;\n\nlet SYMMETRIC_MATRIX_MAT = `!n. symmetric_matrix(mat n)`;;\n\nlet SYMMETRIC_MATRIX_COVARIANCE = `!A:real^N^M. symmetric_matrix(transp A ** A)`;;\n\nlet SYMMETRIC_MATRIX_SIMILAR = `!A B:real^N^N.\n symmetric_matrix B ==> symmetric_matrix(transp A ** B ** A)`;;\n\nlet TRANSP_EQ = `!A B:real^M^N. transp A = transp B <=> A = B`;;\n\nlet ROW_TRANSP = `!A:real^N^M i.\n 1 <= i /\\ i <= dimindex(:N) ==> row i (transp A) = column i A`;;\n\nlet COLUMN_TRANSP = `!A:real^N^M i.\n 1 <= i /\\ i <= dimindex(:M) ==> column i (transp A) = row i A`;;\n\nlet ROWS_TRANSP = `!A:real^N^M. rows(transp A) = columns A`;;\n\nlet COLUMNS_TRANSP = `!A:real^N^M. columns(transp A) = rows A`;;\n\nlet VECTOR_MATRIX_MUL_TRANSP = `!A:real^M^N x:real^N. x ** A = transp A ** x`;;\n\nlet MATRIX_VECTOR_MUL_TRANSP = `!A:real^M^N x:real^M. A ** x = x ** transp A`;;\n\nlet ROWS_NONEMPTY = `!A:real^N^M. ~(rows A = {})`;;\n\nlet COLUMNS_NONEMPTY = `!A:real^N^M. ~(columns A = {})`;;\n\nlet FINITE_ROWS = `!A:real^N^M. FINITE(rows A)`;;\n\nlet FINITE_COLUMNS = `!A:real^N^M. FINITE(columns A)`;;\n\nlet CARD_ROWS_LE = `!A:real^M^N. CARD(rows A) <= dimindex(:N)`;;\n\nlet CARD_COLUMNS_LE = `!A:real^M^N. CARD(columns A) <= dimindex(:M)`;;\n\nlet MATRIX_EQUAL_ROWS = `!A B:real^N^M.\n A = B <=> !i. 1 <= i /\\ i <= dimindex(:M) ==> row i A = row i B`;;\n\nlet MATRIX_EQUAL_COLUMNS = `!A B:real^N^M.\n A = B <=> !i. 1 <= i /\\ i <= dimindex(:N) ==> column i A = column i B`;;\n\nlet MATRIX_CMUL_EQ_0 = `!A:real^M^N c. c %% A = mat 0 <=> c = &0 \\/ A = mat 0`;;\n\nlet MAT_EQ = `!m n. mat m = mat n <=> m = n`;;\n\nlet MATRIX_VECTOR_LMUL = `!A:real^M^N c x:real^M. (c %% A) ** x = c % (A ** x)`;;\n\nlet MATRIX_VECTOR_MUL_LNEG = `!A:real^M^N x:real^M. --A ** x = --(A ** x)`;;\n\nlet MATRIX_VECTOR_MUL_RNEG = `!A:real^M^N x:real^M. A ** --x = --(A ** x)`;;\n\nlet COLUMN_MATRIX_MUL = `!A:real^N^M B:real^P^N.\n 1 <= i /\\ i <= dimindex(:P) ==> column i (A ** B) = A ** column i B`;;\n\nlet ROW_MATRIX_MUL = `!A:real^N^M B:real^P^N.\n 1 <= i /\\ i <= dimindex(:M) ==> row i (A ** B) = transp B ** row i A`;;\n\nlet MATRIX_MUL_DOT = `!A:real^N^M x. A ** x = lambda i. A$i dot x`;;\n\nlet MATRIX_MUL_VSUM = `!A:real^N^M x. A ** x = vsum(1..dimindex(:N)) (\\i. x$i % column i A)`;;\n\nlet VECTOR_COMPONENTWISE = `!x:real^N.\n x = lambda j. sum(1..dimindex(:N))\n (\\i. x$i * (basis i :real^N)$j)`;;\n\nlet LINEAR_COMPONENTWISE_EXPANSION = `!f:real^M->real^N.\n linear(f)\n ==> !x j. 1 <= j /\\ j <= dimindex(:N)\n ==> (f x $j =\n sum(1..dimindex(:M)) (\\i. x$i * f(basis i)$j))`;;\n\nlet invertible = new_definition\n `invertible(A:real^N^M) <=>\n ?A':real^M^N. (A ** A' = mat 1) /\\ (A' ** A = mat 1)`;;\n\nlet INVERTIBLE_I = `invertible(mat 1:real^N^N)`;;\n\nlet INVERTIBLE_NEG = `!A:real^N^M. invertible(--A) <=> invertible A`;;\n\nlet INVERTIBLE_CMUL = `!A:real^N^M c. invertible(c %% A) <=> ~(c = &0) /\\ invertible(A)`;;\n\nlet INVERTIBLE_MAT = `!a. invertible(mat a:real^N^N) <=> ~(a = 0)`;;\n\nlet MATRIX_ENTIRE = `(!A:real^N^M B:real^P^N. invertible A ==> (A ** B = mat 0 <=> B = mat 0)) /\\\n (!A:real^N^M B:real^P^N. invertible B ==> (A ** B = mat 0 <=> A = mat 0))`;;\n\nlet matrix = new_definition\n `(matrix:(real^M->real^N)->real^M^N) f = lambda i j. f(basis j)$i`;;\n\nlet MATRIX_COMPONENT = `!f:real^M->real^N i j.\n 1 <= j /\\ j <= dimindex(:M)\n ==> (matrix f)$i$j = f (basis j)$i`;;\n\nlet MATRIX_VECTOR_MUL_LINEAR = `!A:real^N^M. linear(\\x. A ** x)`;;\n\nlet MATRIX_WORKS = `!f:real^M->real^N. linear f ==> !x. matrix f ** x = f(x)`;;\n\nlet MATRIX_VECTOR_MUL = `!f:real^M->real^N. linear f ==> f = \\x. matrix f ** x`;;\n\nlet MATRIX_OF_MATRIX_VECTOR_MUL = `!A:real^N^M. matrix(\\x. A ** x) = A`;;\n\nlet MATRIX_COMPOSE = `!f g. linear f /\\ linear g ==> (matrix(g o f) = matrix g ** matrix f)`;;\n\nlet MATRIX_0 = `matrix(\\x. vec 0):real^M^N = mat 0`;;\n\nlet MATRIX_VECTOR_COLUMN = `!A:real^N^M x.\n A ** x = vsum(1..dimindex(:N)) (\\i. x$i % (transp A)$i)`;;\n\nlet MATRIX_MUL_COMPONENT = `!i. 1 <= i /\\ i <= dimindex(:P)\n ==> ((A:real^N^P) ** (B:real^M^N))$i = transp B ** A$i`;;\n\nlet ADJOINT_MATRIX = `!A:real^N^M. adjoint(\\x. A ** x) = (\\x. transp A ** x)`;;\n\nlet MATRIX_ADJOINT = `!f. linear f ==> matrix(adjoint f) = transp(matrix f)`;;\n\nlet MATRIX_ID = `matrix(\\x. x) = mat 1`;;\n\nlet MATRIX_I = `matrix I = mat 1`;;\n\nlet LINEAR_EQ_MATRIX = `!f g. linear f /\\ linear g /\\ matrix f = matrix g ==> f = g`;;\n\nlet MATRIX_CMUL = `!f:real^M->real^N c.\n linear f ==> matrix(\\x. c % f x) = c %% matrix f`;;\n\nlet MATRIX_NEG = `!f:real^M->real^N.\n linear f ==> matrix(\\x. --(f x)) = --(matrix f)`;;\n\nlet MATRIX_ADD = `!f g:real^M->real^N.\n linear f /\\ linear g ==> matrix(\\x. f x + g x) = matrix f + matrix g`;;\n\nlet MATRIX_SELF_ADJOINT = `!f. linear f ==> (adjoint f = f <=> symmetric_matrix(matrix f))`;;\n\nlet LINEAR_MATRIX_EXISTS = `!f:real^M->real^N. linear f <=> ?A:real^M^N. f = \\x. A ** x`;;\n\nlet LINEAR_1_GEN = `!f:real^N->real^N.\n dimindex(:N) = 1 ==> (linear f <=> ?c. f = \\x. c % x)`;;\n\nlet LINEAR_1 = `!f:real^1->real^1. linear f <=> ?c. f = \\x. c % x`;;\n\nlet SYMMETRIC_MATRIX = `!A:real^N^N. symmetric_matrix A <=> adjoint(\\x. A ** x) = \\x. A ** x`;;\n\nlet DOT_MATRIX_TRANSP_LMUL = `!A x y:real^N. (transp A ** x) dot y = x dot (A ** y)`;;\n\nlet DOT_MATRIX_TRANSP_RMUL = `!A x y:real^N. x dot (transp A ** y) = (A ** x) dot y`;;\n\nlet SYMMETRIC_MATRIX_ORTHOGONAL_EIGENVECTORS = `!A:real^N^N v w a b.\n symmetric_matrix A /\\ A ** v = a % v /\\ A ** w = b % w /\\ ~(a = b)\n ==> orthogonal v w`;;\n\nlet MATRIX_INJECTIVE_0 = `!m:real^M^N.\n (!x y:real^M. m ** x = m ** y ==> x = y) <=>\n (!x:real^M. m ** x = vec 0 ==> x = vec 0)`;;\n\nlet onorm = new_definition\n `onorm (f:real^M->real^N) = sup { norm(f x) | norm(x) = &1 }`;;\n\nlet NORM_BOUND_GENERALIZE = `!f:real^M->real^N b.\n linear f\n ==> ((!x. norm(x) = &1 ==> norm(f x) <= b) <=>\n (!x. norm(f x) <= b * norm(x)))`;;\n\nlet ONORM_DOT = `!f:real^M->real^N. onorm f = sup {f x dot y | norm x = &1 /\\ norm y = &1}`;;\n\nlet ONORM = `!f:real^M->real^N.\n linear f\n ==> (!x. norm(f x) <= onorm f * norm(x)) /\\\n (!b. (!x. norm(f x) <= b * norm(x)) ==> onorm f <= b)`;;\n\nlet ONORM_LE_EQ = `!f:real^M->real^N b.\n linear f ==> (onorm f <= b <=> !x. norm(f x) <= b * norm x)`;;\n\nlet ONORM_POS_LE = `!f. linear f ==> &0 <= onorm f`;;\n\nlet ONORM_EQ_0 = `!f:real^M->real^N. linear f ==> ((onorm f = &0) <=> (!x. f x = vec 0))`;;\n\nlet ONORM_CONST = `!y:real^N. onorm(\\x:real^M. y) = norm(y)`;;\n\nlet ONORM_POS_LT = `!f. linear f ==> (&0 < onorm f <=> ~(!x. f x = vec 0))`;;\n\nlet ONORM_COMPOSE = `!f g. linear f /\\ linear g ==> onorm(f o g) <= onorm f * onorm g`;;\n\nlet ONORM_CMUL = `!f:real^M->real^N c. linear f ==> onorm(\\x. c % f x) = abs c * onorm f`;;\n\nlet ONORM_NEG = `!f:real^M->real^N. onorm(\\x. --f x) = onorm f`;;\n\nlet ONORM_TRIANGLE = `!f:real^M->real^N g.\n linear f /\\ linear g ==> onorm(\\x. f x + g x) <= onorm f + onorm g`;;\n\nlet ONORM_TRIANGLE_LE = `!f g. linear f /\\ linear g /\\ onorm(f) + onorm(g) <= e\n ==> onorm(\\x. f x + g x) <= e`;;\n\nlet ONORM_TRIANGLE_LT = `!f g. linear f /\\ linear g /\\ onorm(f) + onorm(g) < e\n ==> onorm(\\x. f x + g x) < e`;;\n\nlet ONORM_ID = `onorm(\\x:real^N. x) = &1`;;\n\nlet ONORM_I = `onorm(I:real^N->real^N) = &1`;;\n\nlet ONORM_INVERSE_FUNCTION_BOUND = `!f g:real^M->real^N.\n linear f /\\ linear g /\\ f o g = I ==> &1 <= onorm f * onorm g`;;\n\nlet ONORM_ADJOINT = `!f:real^N->real^N. linear f ==> onorm(adjoint f) = onorm f`;;\n\nlet ONORM_COMPOSE_ADJOINT_LEFT = `!f:real^N->real^N. linear f ==> onorm(adjoint f o f) = onorm f pow 2`;;\n\nlet ONORM_COMPOSE_ADJOINT_RIGHT = `!f:real^N->real^N. linear f ==> onorm(f o adjoint f) = onorm f pow 2`;;\n\nlet ONORM_TRANSP = `!A:real^N^N. onorm(\\x. transp A ** x) = onorm(\\x. A ** x)`;;\n\nlet ONORM_COVARIANCE = `!A:real^N^N.\n onorm(\\x. (transp A ** A) ** x) = onorm(\\x. A ** x) pow 2`;;\n\nlet ONORM_COVARIANCE_ALT = `!A:real^N^N.\n onorm(\\x. (A ** transp A) ** x) = onorm(\\x. A ** x) pow 2`;;\n\nlet ONORM_LE_EQ_2,ONORM_LE_EQ_2_ABS = (CONJ_PAIR o prove)\n (`(!f:real^M->real^N b.\n linear f\n ==> (onorm f <= b <=> !x y. x dot (f y) <= b * norm x * norm y)) /\\\n (!f:real^M->real^N b.\n linear f\n ==> (onorm f <= b <=> !x y. abs(x dot (f y)) <= b * norm x * norm y))`,\n REWRITE_TAC[AND_FORALL_THM] THEN REPEAT GEN_TAC THEN\n ASM_CASES_TAC `linear(f:real^M->real^N)` THEN ASM_REWRITE_TAC[] THEN\n MATCH_MP_TAC(TAUT\n `(r ==> q) /\\ (p ==> r) /\\ (q ==> p) ==> (p <=> q) /\\ (p <=> r)`) THEN\n CONJ_TAC THENL\n [REPEAT(MATCH_MP_TAC MONO_FORALL THEN GEN_TAC) THEN REAL_ARITH_TAC;\n ASM_SIMP_TAC[ONORM_LE_EQ]] THEN\n CONJ_TAC THEN DISCH_TAC THENL\n [MAP_EVERY X_GEN_TAC [`x:real^N`; `y:real^M`] THEN\n TRANS_TAC REAL_LE_TRANS `norm(x:real^N) * norm((f:real^M->real^N) y)` THEN\n REWRITE_TAC[NORM_CAUCHY_SCHWARZ_ABS] THEN\n GEN_REWRITE_TAC RAND_CONV [REAL_ARITH `b * x * y:real = x * b * y`] THEN\n ASM_SIMP_TAC[REAL_LE_LMUL; NORM_POS_LE];\n X_GEN_TAC `x:real^M` THEN\n ASM_CASES_TAC `(f:real^M->real^N) x = vec 0` THENL\n [ASM_CASES_TAC `x:real^M = vec 0` THEN\n ASM_REWRITE_TAC[NORM_0; REAL_MUL_RZERO; REAL_LE_REFL] THEN\n FIRST_X_ASSUM(MP_TAC o SPECL [`basis 1:real^N`; `x:real^M`]) THEN\n ASM_SIMP_TAC[DOT_RZERO; NORM_BASIS; LE_REFL;\n DIMINDEX_GE_1; REAL_MUL_LID];\n FIRST_ASSUM(MP_TAC o SPECL [`(f:real^M->real^N) x`; `x:real^M`]) THEN\n REWRITE_TAC[GSYM NORM_POW_2; REAL_ARITH\n `y pow 2 <= b * y * x <=> y * y <= y * b * x`] THEN\n ASM_SIMP_TAC[REAL_LE_LMUL_EQ; NORM_POS_LT]]]);;\n\nlet lift = new_definition\n `(lift:real->real^1) x = lambda i. x`;;\n\nlet drop = new_definition\n `(drop:real^1->real) x = x$1`;;\n\nlet LIFT_COMPONENT = `!x. (lift x)$1 = x`;;\n\nlet LIFT_DROP = `(!x. lift(drop x) = x) /\\ (!x. drop(lift x) = x)`;;\n\nlet IMAGE_LIFT_DROP = `(!s. IMAGE (lift o drop) s = s) /\\ (!s. IMAGE (drop o lift) s = s)`;;\n\nlet IN_IMAGE_LIFT_DROP = `(!x s. x IN IMAGE lift s <=> drop x IN s) /\\\n (!x s. x IN IMAGE drop s <=> lift x IN s)`;;\n\nlet FORALL_LIFT = `(!x. P x) = (!x. P(lift x))`;;\n\nlet EXISTS_LIFT = `(?x. P x) = (?x. P(lift x))`;;\n\nlet FORALL_DROP = `(!x. P x) = (!x. P(drop x))`;;\n\nlet EXISTS_DROP = `(?x. P x) = (?x. P(drop x))`;;\n\nlet FORALL_LIFT_FUN = `!P:(A->real^1)->bool. (!f. P f) <=> (!f. P(lift o f))`;;\n\nlet FORALL_DROP_FUN = `!P:(A->real)->bool. (!f. P f) <=> (!f. P(drop o f))`;;\n\nlet FORALL_FUN_LIFT = `!P:(real->A)->bool. (!f. P f) <=> (!f. P(f o lift))`;;\n\nlet FORALL_FUN_DROP = `!P:(real^1->A)->bool. (!f. P f) <=> (!f. P(f o drop))`;;\n\nlet EXISTS_LIFT_FUN = `!P:(A->real^1)->bool. (?f. P f) <=> (?f. P(lift o f))`;;\n\nlet EXISTS_DROP_FUN = `!P:(A->real)->bool. (?f. P f) <=> (?f. P(drop o f))`;;\n\nlet EXISTS_FUN_LIFT = `!P:(real->A)->bool. (?f. P f) <=> (?f. P(f o lift))`;;\n\nlet EXISTS_FUN_DROP = `!P:(real^1->A)->bool. (?f. P f) <=> (?f. P(f o drop))`;;\n\nlet LIFT_EQ = `!x y. (lift x = lift y) <=> (x = y)`;;\n\nlet DROP_EQ = `!x y. (drop x = drop y) <=> (x = y)`;;\n\nlet LIFT_IN_IMAGE_LIFT = `!x s. (lift x) IN (IMAGE lift s) <=> x IN s`;;\n\nlet FORALL_LIFT_IMAGE = `!P. (!s. P s) <=> (!s. P(IMAGE lift s))`;;\n\nlet EXISTS_LIFT_IMAGE = `!P. (?s. P s) <=> (?s. P(IMAGE lift s))`;;\n\nlet SUBSET_LIFT_IMAGE = `!s t. IMAGE lift s SUBSET IMAGE lift t <=> s SUBSET t`;;\n\nlet FORALL_DROP_IMAGE = `!P. (!s. P s) <=> (!s. P(IMAGE drop s))`;;\n\nlet EXISTS_DROP_IMAGE = `!P. (?s. P s) <=> (?s. P(IMAGE drop s))`;;\n\nlet SUBSET_DROP_IMAGE = `!s t. IMAGE drop s SUBSET IMAGE drop t <=> s SUBSET t`;;\n\nlet DROP_IN_IMAGE_DROP = `!x s. (drop x) IN (IMAGE drop s) <=> x IN s`;;\n\nlet LIFT_NUM = `!n. lift(&n) = vec n`;;\n\nlet LIFT_ADD = `!x y. lift(x + y) = lift x + lift y`;;\n\nlet LIFT_SUB = `!x y. lift(x - y) = lift x - lift y`;;\n\nlet LIFT_CMUL = `!x c. lift(c * x) = c % lift(x)`;;\n\nlet LIFT_NEG = `!x. lift(--x) = --(lift x)`;;\n\nlet LIFT_EQ_CMUL = `!x. lift x = x % vec 1`;;\n\nlet SUM_VSUM = `!f s. sum s f = drop(vsum s(lift o f))`;;\n\nlet VSUM_REAL = `!f s. vsum s f = lift(sum s (drop o f))`;;\n\nlet LIFT_SUM = `!k x. lift(sum k x) = vsum k (lift o x)`;;\n\nlet DROP_VSUM = `!k x. drop(vsum k x) = sum k (drop o x)`;;\n\nlet DROP_LAMBDA = `!x. drop(lambda i. x i) = x 1`;;\n\nlet DROP_VEC = `!n. drop(vec n) = &n`;;\n\nlet DROP_ADD = `!x y. drop(x + y) = drop x + drop y`;;\n\nlet DROP_SUB = `!x y. drop(x - y) = drop x - drop y`;;\n\nlet DROP_CMUL = `!x c. drop(c % x) = c * drop(x)`;;\n\nlet DROP_NEG = `!x. drop(--x) = --(drop x)`;;\n\nlet NORM_1 = `!x. norm x = abs(drop x)`;;\n\nlet DIST_1 = `!x y. dist(x,y) = abs(drop x - drop y)`;;\n\nlet NORM_1_POS = `!x. &0 <= drop x ==> norm x = drop x`;;\n\nlet NORM_LIFT = `!x. norm(lift x) = abs(x)`;;\n\nlet DIST_LIFT = `!x y. dist(lift x,lift y) = abs(x - y)`;;\n\nlet ABS_DROP = `!x. abs(drop x) = norm x`;;\n\nlet LINEAR_VMUL_DROP = `!f v. linear f ==> linear (\\x. drop(f x) % v)`;;\n\nlet LINEAR_FROM_REALS = `!f:real^1->real^N. linear f ==> f = \\x. drop x % column 1 (matrix f)`;;\n\nlet LINEAR_TO_REALS = `!f:real^N->real^1. linear f ==> f = \\x. lift(row 1 (matrix f) dot x)`;;\n\nlet LINEAR_FROM_1 = `!f:real^1->real^N. linear f <=> ?c. f = \\x. drop x % c`;;\n\nlet DROP_EQ_0 = `!x. drop x = &0 <=> x = vec 0`;;\n\nlet DROP_WLOG_LE = `(!x y. P x y <=> P y x) /\\ (!x y. drop x <= drop y ==> P x y)\n ==> (!x y. P x y)`;;\n\nlet IMAGE_LIFT_UNIV = `IMAGE lift (:real) = (:real^1)`;;\n\nlet IMAGE_DROP_UNIV = `IMAGE drop (:real^1) = (:real)`;;\n\nlet LINEAR_LIFT_DOT = `!a. linear(\\x. lift(a dot x))`;;\n\nlet LINEAR_TO_1 = `!f:real^N->real^1. linear f <=> ?a. f = \\x. lift(a dot x)`;;\n\nlet LINEAR_LIFT_COMPONENT = `!k. linear(\\x:real^N. lift(x$k))`;;\n\nlet BILINEAR_DROP_MUL = `bilinear (\\x y:real^N. drop x % y)`;;\n\nlet BILINEAR_MUL_DROP = `bilinear(\\y:real^N x. drop x % y)`;;\n\nlet BILINEAR_LIFT_MUL = `bilinear (\\x y. lift(drop x * drop y))`;;\n\nlet LINEAR_COMPONENTWISE = `!f:real^M->real^N.\n linear f <=>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> linear(\\x. lift(f(x)$i))`;;\n\nlet DROP_BASIS = `!i. drop(basis i) = if i = 1 then &1 else &0`;;\n\nlet indicator = new_definition\n `indicator s :real^M->real^1 = \\x. if x IN s then vec 1 else vec 0`;;\n\nlet DROP_INDICATOR = `!s x. drop(indicator s x) = if x IN s then &1 else &0`;;\n\nlet DROP_INDICATOR_POS_LE = `!s x. &0 <= drop(indicator s x)`;;\n\nlet DROP_INDICATOR_LE_1 = `!s x. drop(indicator s x) <= &1`;;\n\nlet DROP_INDICATOR_ABS_LE_1 = `!s x. abs(drop(indicator s x)) <= &1`;;\n\nlet INDICATOR_COMPLEMENT = `!s. indicator((:real^N) DIFF s) = \\x. vec 1 - indicator s x`;;\n\nlet VECTORIZE_ADD = `!m1 m2:real^N^M. vectorize(m1 + m2) = vectorize m1 + vectorize m2`;;\n\nlet VECTORIZE_CMUL = `!c m:real^N^M. vectorize(c %% m) = c % vectorize m`;;\n\nlet VECTORIZE_SUB = `!m1 m2:real^N^M. vectorize(m1 - m2) = vectorize m1 - vectorize m2`;;\n\nlet VECTORIZE_0 = `vectorize(mat 0:real^N^M) = vec 0`;;\n\nlet MATRIFY_0 = `matrify(vec 0) = mat 0`;;\n\nlet VECTORIZE_EQ_0 = `!m:real^N^M. vectorize m = vec 0 <=> m = mat 0`;;\n\nlet MATRIFY_ADD = `!x y:real^(M,N)finite_prod. matrify(x + y) = matrify x + matrify y`;;\n\nlet MATRIFY_CMUL = `!c x:real^(M,N)finite_prod. matrify(c % x) = c %% matrify x`;;\n\nlet MATRIFY_SUB = `!x y:real^(M,N)finite_prod. matrify(x - y) = matrify x - matrify y`;;\n\nlet MATRIFY_EQ_0 = `!m:real^(M,N)finite_prod. matrify m = mat 0 <=> m = vec 0`;;\n\nlet BILINEAR_MATRIX_VECTOR_MUL = `bilinear (\\(m:real^(M,N)finite_prod) x:real^N. matrify m ** x)`;;\n\nlet BILINEAR_MATRIX_MUL = `bilinear (\\(m1:real^(M,N)finite_prod) (m2:real^(N,P)finite_prod).\n vectorize(matrify m1 ** matrify m2))`;;\n\nlet LINEAR_FSTCART = `linear fstcart`;;\n\nlet LINEAR_SNDCART = `linear sndcart`;;\n\nlet FSTCART_VEC = `!n. fstcart(vec n) = vec n`;;\n\nlet FSTCART_ADD = `!x:real^(M,N)finite_sum y. fstcart(x + y) = fstcart(x) + fstcart(y)`;;\n\nlet FSTCART_CMUL = `!x:real^(M,N)finite_sum c. fstcart(c % x) = c % fstcart(x)`;;\n\nlet FSTCART_NEG = `!x:real^(M,N)finite_sum. --(fstcart x) = fstcart(--x)`;;\n\nlet FSTCART_SUB = `!x:real^(M,N)finite_sum y. fstcart(x - y) = fstcart(x) - fstcart(y)`;;\n\nlet FSTCART_VSUM = `!k x. FINITE k ==> (fstcart(vsum k x) = vsum k (\\i. fstcart(x i)))`;;\n\nlet SNDCART_VEC = `!n. sndcart(vec n) = vec n`;;\n\nlet SNDCART_ADD = `!x:real^(M,N)finite_sum y. sndcart(x + y) = sndcart(x) + sndcart(y)`;;\n\nlet SNDCART_CMUL = `!x:real^(M,N)finite_sum c. sndcart(c % x) = c % sndcart(x)`;;\n\nlet SNDCART_NEG = `!x:real^(M,N)finite_sum. --(sndcart x) = sndcart(--x)`;;\n\nlet SNDCART_SUB = `!x:real^(M,N)finite_sum y. sndcart(x - y) = sndcart(x) - sndcart(y)`;;\n\nlet SNDCART_VSUM = `!k x. FINITE k ==> (sndcart(vsum k x) = vsum k (\\i. sndcart(x i)))`;;\n\nlet PASTECART_VEC = `!n. pastecart (vec n) (vec n) = vec n`;;\n\nlet PASTECART_ADD = `!x1 y1 x2:real^M y2:real^N.\n pastecart x1 y1 + pastecart x2 y2 = pastecart (x1 + x2) (y1 + y2)`;;\n\nlet PASTECART_CMUL = `!x1 y1 c. pastecart (c % x1) (c % y1) = c % pastecart x1 y1`;;\n\nlet PASTECART_NEG = `!x:real^M y:real^N. pastecart (--x) (--y) = --(pastecart x y)`;;\n\nlet PASTECART_SUB = `!x1 y1 x2:real^M y2:real^N.\n pastecart x1 y1 - pastecart x2 y2 = pastecart (x1 - x2) (y1 - y2)`;;\n\nlet PASTECART_VSUM = `!k x y. FINITE k ==> (pastecart (vsum k x) (vsum k y) =\n vsum k (\\i. pastecart (x i) (y i)))`;;\n\nlet PASTECART_EQ_VEC = `!x y n. pastecart x y = vec n <=> x = vec n /\\ y = vec n`;;\n\nlet FSTCART_SNDCART_MAT_ZERO = `fstcart(mat 0:real^M^(A,B)finite_sum) = mat 0 /\\\n sndcart(mat 0:real^M^(A,B)finite_sum) = mat 0`;;\n\nlet FSTCART_SNDCART_MATRIX_ADD = `!x:real^K^(M,N)finite_sum y.\n fstcart(x + y) = fstcart(x) + fstcart(y) /\\\n sndcart(x + y) = sndcart(x) + sndcart(y)`;;\n\nlet NORM_FSTCART = `!x. norm(fstcart x) <= norm x`;;\n\nlet DIST_FSTCART = `!x y. dist(fstcart x,fstcart y) <= dist(x,y)`;;\n\nlet NORM_SNDCART = `!x. norm(sndcart x) <= norm x`;;\n\nlet DIST_SNDCART = `!x y. dist(sndcart x,sndcart y) <= dist(x,y)`;;\n\nlet DOT_PASTECART = `!x1 x2 y1 y2. (pastecart x1 x2) dot (pastecart y1 y2) =\n x1 dot y1 + x2 dot y2`;;\n\nlet SQNORM_PASTECART = `!x y. norm(pastecart x y) pow 2 = norm(x) pow 2 + norm(y) pow 2`;;\n\nlet NORM_PASTECART = `!x y. norm(pastecart x y) = sqrt(norm(x) pow 2 + norm(y) pow 2)`;;\n\nlet NORM_PASTECART_LE = `!x y. norm(pastecart x y) <= norm(x) + norm(y)`;;\n\nlet DIST_PASTECART_LE = `!x1 y1 x2 y2.\n dist(pastecart x1 y1,pastecart x2 y2)\n <= dist(x1,x2) + dist(y1,y2)`;;\n\nlet NORM_LE_PASTECART = `!x:real^M y:real^N.\n norm(x) <= norm(pastecart x y) /\\\n norm(y) <= norm(pastecart x y)`;;\n\nlet DIST_LE_PASTECART = `!x1 y1 x2 y2.\n dist(x1,x2) <= dist(pastecart x1 y1,pastecart x2 y2) /\\\n dist(y1,y2) <= dist(pastecart x1 y1,pastecart x2 y2)`;;\n\nlet NORM_PASTECART_0 = `(!x. norm(pastecart x (vec 0)) = norm x) /\\\n (!y. norm(pastecart (vec 0) y) = norm y)`;;\n\nlet DIST_PASTECART_CANCEL = `(!x x' y. dist(pastecart x y,pastecart x' y) = dist(x,x')) /\\\n (!x y y'. dist(pastecart x y,pastecart x y') = dist(y,y'))`;;\n\nlet LINEAR_PASTECART = `!f:real^M->real^N g:real^M->real^P.\n linear f /\\ linear g ==> linear (\\x. pastecart (f x) (g x))`;;\n\nlet LINEAR_PASTECART_EQ = `!f:real^M->real^N g:real^M->real^P.\n linear (\\x. pastecart (f x) (g x)) <=> linear f /\\ linear g`;;\n\nlet dropout = new_definition\n `(dropout k:real^M->real^N) x =\n lambda i. if i < k /\\ i <= dimindex(:M) then x$i\n else if i + 1 <= dimindex(:M) then x$(i + 1)\n else &0`;;\n\nlet pushin = new_definition\n `pushin k t x = lambda i. if i < k then x$i\n else if i = k then t\n else x$(i - 1)`;;\n\nlet DROPOUT_PUSHIN = `!k t x.\n dimindex(:M) + 1 = dimindex(:N)\n ==> (dropout k:real^N->real^M) (pushin k t x) = x`;;\n\nlet PUSHIN_DROPOUT = `!k x.\n dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> pushin k (x$k) ((dropout k:real^N->real^M) x) = x`;;\n\nlet DROPOUT_GALOIS = `!k x:real^N y:real^M.\n dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> (y = dropout k x <=> (?t. x = pushin k t y))`;;\n\nlet IN_IMAGE_DROPOUT = `!x s.\n dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> (x IN IMAGE (dropout k:real^N->real^M) s <=>\n ?t. (pushin k t x) IN s)`;;\n\nlet DROPOUT_EQ = `!x y k. dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N) /\\\n x$k = y$k /\\ (dropout k:real^N->real^M) x = dropout k y\n ==> x = y`;;\n\nlet DROPOUT_0 = `dropout k (vec 0:real^N) = vec 0`;;\n\nlet DOT_DROPOUT = `!k x y:real^N.\n dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> (dropout k x:real^M) dot (dropout k y) = x dot y - x$k * y$k`;;\n\nlet DOT_PUSHIN = `!k a b x y:real^M.\n dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> (pushin k a x:real^N) dot (pushin k b y) = x dot y + a * b`;;\n\nlet DROPOUT_ADD = `!k x y:real^N. dropout k (x + y) = dropout k x + dropout k y`;;\n\nlet DROPOUT_SUB = `!k x y:real^N. dropout k (x - y) = dropout k x - dropout k y`;;\n\nlet DROPOUT_MUL = `!k c x:real^N. dropout k (c % x) = c % dropout k x`;;\n\nlet LINEAR_DROPOUT = `!k. linear(dropout k :real^N->real^M)`;;\n\nlet LINEAR_PUSHIN = `!k. linear(pushin k (&0))`;;\n\nlet subspace = new_definition\n `subspace s <=>\n vec(0) IN s /\\\n (!x y. x IN s /\\ y IN s ==> (x + y) IN s) /\\\n (!c x. x IN s ==> (c % x) IN s)`;;\n\nlet span = new_definition\n `span s = subspace hull s`;;\n\nlet dependent = new_definition\n `dependent s <=> ?a. a IN s /\\ a IN span(s DELETE a)`;;\n\nlet independent = new_definition\n `independent s <=> ~(dependent s)`;;\n\nlet SUBSPACE_UNIV = `subspace(UNIV:real^N->bool)`;;\n\nlet SUBSPACE_IMP_NONEMPTY = `!s. subspace s ==> ~(s = {})`;;\n\nlet SUBSPACE_0 = `subspace s ==> vec(0) IN s`;;\n\nlet SUBSPACE_ADD = `!x y s. subspace s /\\ x IN s /\\ y IN s ==> (x + y) IN s`;;\n\nlet SUBSPACE_MUL = `!x c s. subspace s /\\ x IN s ==> (c % x) IN s`;;\n\nlet SUBSPACE_MUL_EQ = `!s c x:real^N. subspace s ==> ((c % x) IN s <=> c = &0 \\/ x IN s)`;;\n\nlet SUBSPACE_NEG = `!x s. subspace s /\\ x IN s ==> (--x) IN s`;;\n\nlet SUBSPACE_NEG_EQ = `!s x:real^N. subspace s ==> (--x IN s <=> x IN s)`;;\n\nlet SUBSPACE_SUB = `!x y s. subspace s /\\ x IN s /\\ y IN s ==> (x - y) IN s`;;\n\nlet SUBSPACE_VSUM = `!s f t. subspace s /\\ FINITE t /\\ (!x. x IN t ==> f(x) IN s)\n ==> (vsum t f) IN s`;;\n\nlet SUBSPACE_LINEAR_IMAGE = `!f s. linear f /\\ subspace s ==> subspace(IMAGE f s)`;;\n\nlet SUBSPACE_LINEAR_PREIMAGE = `!f s. linear f /\\ subspace s ==> subspace {x | f(x) IN s}`;;\n\nlet SUBSPACE_TRIVIAL = `subspace {vec 0}`;;\n\nlet SUBSPACE_INTER = `!s t. subspace s /\\ subspace t ==> subspace (s INTER t)`;;\n\nlet SUBSPACE_INTERS = `!f. (!s. s IN f ==> subspace s) ==> subspace(INTERS f)`;;\n\nlet LINEAR_INJECTIVE_0_SUBSPACE = `!f:real^M->real^N s.\n linear f /\\ subspace s\n ==> ((!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y) <=>\n (!x. x IN s /\\ f x = vec 0 ==> x = vec 0))`;;\n\nlet SUBSPACE_UNION_CHAIN = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ subspace(s UNION t)\n ==> s SUBSET t \\/ t SUBSET s`;;\n\nlet SUBSPACE_PCROSS = `!s:real^M->bool t:real^N->bool.\n subspace s /\\ subspace t ==> subspace(s PCROSS t)`;;\n\nlet SUBSPACE_PCROSS_EQ = `!s:real^M->bool t:real^N->bool.\n subspace(s PCROSS t) <=> subspace s /\\ subspace t`;;\n\nlet SPAN_SPAN = `!s. span(span s) = span s`;;\n\nlet SPAN_MONO = `!s t. s SUBSET t ==> span s SUBSET span t`;;\n\nlet SUBSPACE_SPAN = `!s. subspace(span s)`;;\n\nlet NONEMPTY_SPAN = `!s:real^N->bool. ~(span s = {})`;;\n\nlet SPAN_CLAUSES = `(!a s. a IN s ==> a IN span s) /\\\n (vec(0) IN span s) /\\\n (!x y s. x IN span s /\\ y IN span s ==> (x + y) IN span s) /\\\n (!x c s. x IN span s ==> (c % x) IN span s)`;;\n\nlet SPAN_INDUCT = `!s h. (!x. x IN s ==> x IN h) /\\ subspace h ==> !x. x IN span(s) ==> h(x)`;;\n\nlet SPAN_EMPTY = `span {} = {vec 0}`;;\n\nlet INDEPENDENT_EMPTY = `independent {}`;;\n\nlet INDEPENDENT_NONZERO = `!s. independent s ==> ~(vec 0 IN s)`;;\n\nlet INDEPENDENT_MONO = `!s t. independent t /\\ s SUBSET t ==> independent s`;;\n\nlet DEPENDENT_MONO = `!s t:real^N->bool. dependent s /\\ s SUBSET t ==> dependent t`;;\n\nlet SPAN_SUBSPACE = `!b s. b SUBSET s /\\ s SUBSET (span b) /\\ subspace s ==> (span b = s)`;;\n\nlet SPAN_INDUCT_ALT = `!s h. h(vec 0) /\\\n (!c x y. x IN s /\\ h(y) ==> h(c % x + y))\n ==> !x:real^N. x IN span(s) ==> h(x)`;;\n\nlet SPAN_SUPERSET = `!x. x IN s ==> x IN span s`;;\n\nlet SPAN_INC = `!s. s SUBSET span s`;;\n\nlet SPAN_UNION_SUBSET = `!s t. span s UNION span t SUBSET span(s UNION t)`;;\n\nlet SPAN_UNIV = `span(:real^N) = (:real^N)`;;\n\nlet SPAN_0 = `vec(0) IN span s`;;\n\nlet SPAN_ADD = `!x y s. x IN span s /\\ y IN span s ==> (x + y) IN span s`;;\n\nlet SPAN_MUL = `!x c s. x IN span s ==> (c % x) IN span s`;;\n\nlet SPAN_MUL_EQ = `!x:real^N c s. ~(c = &0) ==> ((c % x) IN span s <=> x IN span s)`;;\n\nlet SPAN_NEG = `!x s. x IN span s ==> (--x) IN span s`;;\n\nlet SPAN_NEG_EQ = `!x s. --x IN span s <=> x IN span s`;;\n\nlet SPAN_SUB = `!x y s. x IN span s /\\ y IN span s ==> (x - y) IN span s`;;\n\nlet SPAN_VSUM = `!s f t. FINITE t /\\ (!x. x IN t ==> f(x) IN span(s))\n ==> (vsum t f) IN span(s)`;;\n\nlet SPAN_ADD_EQ = `!s x y. x IN span s ==> ((x + y) IN span s <=> y IN span s)`;;\n\nlet SPAN_EQ_SELF = `!s. span s = s <=> subspace s`;;\n\nlet SPAN_OF_SUBSPACE = `!s:real^N->bool. subspace s ==> span s = s`;;\n\nlet SPAN_SUBSET_SUBSPACE = `!s t:real^N->bool. s SUBSET t /\\ subspace t ==> span s SUBSET t`;;\n\nlet SUBSPACE_TRANSLATION_SELF = `!s a. subspace s /\\ a IN s ==> IMAGE (\\x. a + x) s = s`;;\n\nlet SUBSPACE_TRANSLATION_SELF_EQ = `!s a:real^N. subspace s ==> (IMAGE (\\x. a + x) s = s <=> a IN s)`;;\n\nlet SUBSPACE_SUMS = `!s t. subspace s /\\ subspace t\n ==> subspace {x + y | x IN s /\\ y IN t}`;;\n\nlet SPAN_UNION = `!s t. span(s UNION t) = {x + y:real^N | x IN span s /\\ y IN span t}`;;\n\nlet SPAN_LINEAR_IMAGE = `!f:real^M->real^N s. linear f ==> (span(IMAGE f s) = IMAGE f (span s))`;;\n\nlet DEPENDENT_LINEAR_IMAGE_EQ = `!f:real^M->real^N s.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (dependent(IMAGE f s) <=> dependent s)`;;\n\nlet DEPENDENT_LINEAR_IMAGE = `!f:real^M->real^N s.\n linear f /\\ (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y) /\\\n dependent(s)\n ==> dependent(IMAGE f s)`;;\n\nlet INDEPENDENT_LINEAR_IMAGE_EQ = `!f:real^M->real^N s.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (independent(IMAGE f s) <=> independent s)`;;\n\nlet SPAN_BREAKDOWN = `!b s a:real^N.\n b IN s /\\ a IN span s ==> ?k. (a - k % b) IN span(s DELETE b)`;;\n\nlet SPAN_BREAKDOWN_EQ = `!a:real^N s. (x IN span(a INSERT s) <=> (?k. (x - k % a) IN span s))`;;\n\nlet SPAN_INSERT_0 = `!s. span(vec 0 INSERT s) = span s`;;\n\nlet SPAN_SING = `!a. span {a} = {u % a | u IN (:real)}`;;\n\nlet SPAN_2 = `!a b. span {a,b} = {u % a + v % b | u IN (:real) /\\ v IN (:real)}`;;\n\nlet SPAN_3 = `!a b c. span {a,b,c} =\n {u % a + v % b + w % c | u IN (:real) /\\ v IN (:real) /\\ w IN (:real)}`;;\n\nlet IN_SPAN_INSERT = `!a b:real^N s.\n a IN span(b INSERT s) /\\ ~(a IN span s) ==> b IN span(a INSERT s)`;;\n\nlet IN_SPAN_DELETE = `!a b s.\n a IN span s /\\ ~(a IN span (s DELETE b))\n ==> b IN span (a INSERT (s DELETE b))`;;\n\nlet EQ_SPAN_INSERT_EQ = `!s x y:real^N. (x - y) IN span s ==> span(x INSERT s) = span(y INSERT s)`;;\n\nlet SPAN_EXPLICIT = `!(p:real^N -> bool).\n span p =\n {y | ?s u. FINITE s /\\ s SUBSET p /\\\n vsum s (\\v. u v % v) = y}`;;\n\nlet DEPENDENT_EXPLICIT = `!p. dependent (p:real^N -> bool) <=>\n ?s u. FINITE s /\\ s SUBSET p /\\\n (?v. v IN s /\\ ~(u v = &0)) /\\\n vsum s (\\v. u v % v) = vec 0`;;\n\nlet DEPENDENT_FINITE = `!s:real^N->bool.\n FINITE s\n ==> (dependent s <=> ?u. (?v. v IN s /\\ ~(u v = &0)) /\\\n vsum s (\\v. u(v) % v) = vec 0)`;;\n\nlet SPAN_FINITE = `!s:real^N->bool.\n FINITE s ==> span s = {y | ?u. vsum s (\\v. u v % v) = y}`;;\n\nlet SPAN_STDBASIS = `span {basis i :real^N | 1 <= i /\\ i <= dimindex(:N)} = UNIV`;;\n\nlet HAS_SIZE_STDBASIS = `{basis i :real^N | 1 <= i /\\ i <= dimindex(:N)} HAS_SIZE\n dimindex(:N)`;;\n\nlet FINITE_STDBASIS = `FINITE {basis i :real^N | 1 <= i /\\ i <= dimindex(:N)}`;;\n\nlet CARD_STDBASIS = `CARD {basis i :real^N | 1 <= i /\\ i <= dimindex(:N)} =\n dimindex(:N)`;;\n\nlet IN_SPAN_IMAGE_BASIS = `!x:real^N s.\n x IN span(IMAGE basis s) <=>\n !i. 1 <= i /\\ i <= dimindex(:N) /\\ ~(i IN s) ==> x$i = &0`;;\n\nlet INDEPENDENT_STDBASIS = `independent {basis i :real^N | 1 <= i /\\ i <= dimindex(:N)}`;;\n\nlet INDEPENDENT_BASIS_IMAGE = `!k. independent(IMAGE basis k:real^N->bool) <=> k SUBSET 1..dimindex(:N) `;;\n\nlet dim = new_definition\n `dim (v:real^N->bool) =\n @n. ?b. b SUBSET v /\\ independent b /\\ v SUBSET (span b) /\\ b HAS_SIZE n`;;\n\nlet euclidean_matroid = new_definition\n `euclidean_matroid = matroid((:real^N),span)`;;\n\nlet EUCLIDEAN_MATROID = `matroid_set euclidean_matroid = (:real^N) /\\\n matroid_span euclidean_matroid = (span:(real^N->bool)->(real^N->bool))`;;\n\nlet EUCLIDEAN_MATROID_INDEPENDENT = `matroid_independent (euclidean_matroid:(real^N)matroid) = independent`;;\n\nlet EUCLIDEAN_MATROID_SPANNING = `!s. matroid_spanning euclidean_matroid s <=> span s = (:real^N)`;;\n\nlet EUCLIDEAN_MATROID_SUBSPACE = `matroid_subspace (euclidean_matroid:(real^N)matroid) = subspace`;;\n\nlet EUCLIDEAN_MATROID_FINITE_DIMENSIONAL = `matroid_finite_dimensional (euclidean_matroid:(real^N)matroid)`;;\n\nlet EUCLIDEAN_MATROID_DIMENSION = `matroid_dimension (euclidean_matroid:(real^N)matroid) = dimindex(:N)`;;\n\nlet EUCLIDEAN_MATROID_FINITE_DIM = `!s:real^N->bool. matroid_finite_dim euclidean_matroid s`;;\n\nlet EUCLIDEAN_SUBMATROID = `(!s:real^N->bool. matroid_set (submatroid euclidean_matroid s) = span s) /\\\n (!s:real^N->bool. matroid_span (submatroid euclidean_matroid s) = span)`;;\n\nlet EUCLIDEAN_MATROID_DIM = `matroid_dim (euclidean_matroid:(real^N)matroid) = dim`;;\n\nlet SPAN_EQ = `!s t:real^N->bool. span s = span t <=> s SUBSET span t /\\ t SUBSET span s`;;\n\nlet SPAN_EQ_INSERT = `!s x:real^N. span(x INSERT s) = span s <=> x IN span s`;;\n\nlet INDEPENDENT_INSERT = `!a:real^N s. independent(a INSERT s) <=>\n if a IN s then independent s\n else independent s /\\ ~(a IN span s)`;;\n\nlet SPAN_TRANS = `!x y:real^N s. x IN span(s) /\\ y IN span(x INSERT s) ==> y IN span(s)`;;\n\nlet SPANNING_SUBSET_INDEPENDENT = `!s t:real^N->bool.\n t SUBSET s /\\ independent s /\\ s SUBSET span(t) ==> s = t`;;\n\nlet EXCHANGE_LEMMA = `!s t:real^N->bool.\n FINITE t /\\ independent s /\\ s SUBSET span t\n ==> ?t'. t' HAS_SIZE (CARD t) /\\\n s SUBSET t' /\\ t' SUBSET (s UNION t) /\\ s SUBSET (span t')`;;\n\nlet INDEPENDENT_SPAN_BOUND = `!s t. FINITE t /\\ independent s /\\ s SUBSET span(t)\n ==> FINITE s /\\ CARD(s) <= CARD(t)`;;\n\nlet INDEPENDENT_BOUND = `!s:real^N->bool.\n independent s ==> FINITE s /\\ CARD(s) <= dimindex(:N)`;;\n\nlet DEPENDENT_BIGGERSET = `!s:real^N->bool. (FINITE s ==> CARD(s) > dimindex(:N)) ==> dependent s`;;\n\nlet INDEPENDENT_IMP_FINITE = `!s:real^N->bool. independent s ==> FINITE s`;;\n\nlet MAXIMAL_INDEPENDENT_SUBSET_EXTEND = `!s v:real^N->bool.\n s SUBSET v /\\ independent s\n ==> ?b. s SUBSET b /\\ b SUBSET v /\\ independent b /\\\n v SUBSET (span b)`;;\n\nlet MAXIMAL_INDEPENDENT_SUBSET = `!v:real^N->bool. ?b. b SUBSET v /\\ independent b /\\ v SUBSET (span b)`;;\n\nlet BASIS_EXISTS = `!v. ?b. b SUBSET v /\\ independent b /\\ v SUBSET (span b) /\\\n b HAS_SIZE (dim v)`;;\n\nlet BASIS_EXISTS_FINITE = `!v. ?b. FINITE b /\\\n b SUBSET v /\\\n independent b /\\\n v SUBSET (span b) /\\\n b HAS_SIZE (dim v)`;;\n\nlet BASIS_SUBSPACE_EXISTS = `!s:real^N->bool.\n subspace s\n ==> ?b. FINITE b /\\\n b SUBSET s /\\\n independent b /\\\n span b = s /\\\n b HAS_SIZE dim s`;;\n\nlet INDEPENDENT_CARD_LE_DIM = `!v b:real^N->bool.\n b SUBSET v /\\ independent b ==> FINITE b /\\ CARD(b) <= dim v`;;\n\nlet SPAN_CARD_GE_DIM = `!v b:real^N->bool.\n v SUBSET (span b) /\\ FINITE b ==> dim(v) <= CARD(b)`;;\n\nlet BASIS_CARD_EQ_DIM = `!v b. b SUBSET v /\\ v SUBSET (span b) /\\ independent b\n ==> FINITE b /\\ (CARD b = dim v)`;;\n\nlet BASIS_HAS_SIZE_DIM = `!v b. independent b /\\ span b = v ==> b HAS_SIZE (dim v)`;;\n\nlet DIM_SPAN = `!s:real^N->bool. dim(span s) = dim s`;;\n\nlet DIM_UNIQUE = `!v b. b SUBSET v /\\ v SUBSET (span b) /\\ independent b /\\ b HAS_SIZE n\n ==> dim v = n`;;\n\nlet DIM_LE_CARD = `!s. FINITE s ==> dim s <= CARD s`;;\n\nlet DIM_UNIV = `dim(:real^N) = dimindex(:N)`;;\n\nlet DIM_SUBSET = `!s t:real^N->bool. s SUBSET t ==> dim(s) <= dim(t)`;;\n\nlet DIM_SUBSET_UNIV = `!s:real^N->bool. dim(s) <= dimindex(:N)`;;\n\nlet BASIS_HAS_SIZE_UNIV = `!b. independent b /\\ span b = (:real^N) ==> b HAS_SIZE (dimindex(:N))`;;\n\nlet CARD_GE_DIM_INDEPENDENT = `!v b:real^N->bool.\n b SUBSET v /\\ independent b /\\ dim v <= CARD(b)\n ==> v SUBSET span b`;;\n\nlet CARD_LE_DIM_SPANNING = `!v b:real^N->bool.\n v SUBSET span b /\\ FINITE b /\\ CARD(b) <= dim v ==> independent b`;;\n\nlet CARD_EQ_DIM = `!v b. b SUBSET v /\\ b HAS_SIZE (dim v)\n ==> (independent b <=> v SUBSET (span b))`;;\n\nlet INDEPENDENT_BOUND_GENERAL = `!s:real^N->bool. independent s ==> FINITE s /\\ CARD(s) <= dim(s)`;;\n\nlet DEPENDENT_BIGGERSET_GENERAL = `!s:real^N->bool. (FINITE s ==> CARD(s) > dim(s)) ==> dependent s`;;\n\nlet DIM_INSERT_0 = `!s:real^N->bool. dim(vec 0 INSERT s) = dim s`;;\n\nlet DIM_EQ_CARD = `!s:real^N->bool. independent s ==> dim s = CARD s`;;\n\nlet DEPENDENT_EQ_DIM_LT_CARD = `!s:real^N->bool. dependent s <=> FINITE s ==> dim s < CARD s`;;\n\nlet INDEPENDENT_EQ_DIM_EQ_CARD = `!s:real^N->bool. independent s <=> FINITE s /\\ dim s = CARD s`;;\n\nlet SUBSET_LE_DIM = `!s t:real^N->bool. s SUBSET (span t) ==> dim s <= dim t`;;\n\nlet SPAN_EQ_DIM = `!s t. span s = span t ==> dim s = dim t`;;\n\nlet DIM_EMPTY = `dim({}:real^N->bool) = 0`;;\n\nlet DIM_INSERT = `!x:real^N s. dim(x INSERT s) = if x IN span s then dim s else dim s + 1`;;\n\nlet CHOOSE_SUBSPACE_OF_SUBSPACE = `!s:real^N->bool n.\n n <= dim s ==> ?t. subspace t /\\ t SUBSET span s /\\ dim t = n`;;\n\nlet SUBSPACE_EXISTS = `!n. n <= dimindex(:N) ==> ?s:real^N->bool. subspace s /\\ dim s = n`;;\n\nlet DIM_EQ_SPAN = `!s t:real^N->bool. s SUBSET t /\\ dim t <= dim s ==> span s = span t`;;\n\nlet DIM_EQ_FULL = `!s:real^N->bool. dim s = dimindex(:N) <=> span s = (:real^N)`;;\n\nlet DIM_PSUBSET = `!s t:real^N->bool. span s PSUBSET span t ==> dim s < dim t`;;\n\nlet LOWDIM_EXPAND_DIMENSION = `!s:real^N->bool n.\n dim s <= n /\\ n <= dimindex(:N)\n ==> ?t. dim(t) = n /\\ span s SUBSET span t`;;\n\nlet LOWDIM_EXPAND_BASIS = `!s:real^N->bool n.\n dim s <= n /\\ n <= dimindex(:N)\n ==> ?b. b HAS_SIZE n /\\ independent b /\\ span s SUBSET span b`;;\n\nlet INDEPENDENT_EXPLICIT = `!b:real^N->bool.\n independent b <=>\n FINITE b /\\\n !c. vsum b (\\v. c(v) % v) = vec 0 ==> !v. v IN b ==> c(v) = &0`;;\n\nlet INDEPENDENT_SING = `!x. independent {x} <=> ~(x = vec 0)`;;\n\nlet DEPENDENT_SING = `!x. dependent {x} <=> x = vec 0`;;\n\nlet DEPENDENT_2 = `!a b:real^N.\n dependent {a,b} <=>\n if a = b then a = vec 0\n else ?x y. x % a + y % b = vec 0 /\\ ~(x = &0 /\\ y = &0)`;;\n\nlet DEPENDENT_3 = `!a b c:real^N.\n ~(a = b) /\\ ~(a = c) /\\ ~(b = c)\n ==> (dependent {a,b,c} <=>\n ?x y z. x % a + y % b + z % c = vec 0 /\\\n ~(x = &0 /\\ y = &0 /\\ z = &0))`;;\n\nlet INDEPENDENT_2 = `!a b:real^N x y.\n independent{a,b} /\\ ~(a = b)\n ==> (x % a + y % b = vec 0 <=> x = &0 /\\ y = &0)`;;\n\nlet INDEPENDENT_3 = `!a b c:real^N x y z.\n independent{a,b,c} /\\ ~(a = b) /\\ ~(a = c) /\\ ~(b = c)\n ==> (x % a + y % b + z % c = vec 0 <=> x = &0 /\\ y = &0 /\\ z = &0)`;;\n\nlet LINEAR_SUBSPACE_GRAPH = `!f:real^M->real^N.\n linear f <=> subspace {pastecart x (f x) | x IN (:real^M)}`;;\n\nlet SPANS_IMAGE = `!f b v. linear f /\\ v SUBSET (span b)\n ==> (IMAGE f v) SUBSET span(IMAGE f b)`;;\n\nlet DIM_LINEAR_IMAGE_LE = `!f:real^M->real^N s. linear f ==> dim(IMAGE f s) <= dim s`;;\n\nlet DIM_SING = `!x. dim{x} = if x = vec 0 then 0 else 1`;;\n\nlet DIM_EQ_0 = `!s:real^N->bool. dim s = 0 <=> s SUBSET {vec 0}`;;\n\nlet SPANNING_SURJECTIVE_IMAGE = `!f:real^M->real^N s.\n UNIV SUBSET (span s) /\\ linear f /\\ (!y. ?x. f(x) = y)\n ==> UNIV SUBSET span(IMAGE f s)`;;\n\nlet INDEPENDENT_INJECTIVE_IMAGE_GEN = `!f:real^M->real^N s.\n independent s /\\ linear f /\\\n (!x y. x IN span s /\\ y IN span s /\\ f(x) = f(y) ==> x = y)\n ==> independent (IMAGE f s)`;;\n\nlet INDEPENDENT_INJECTIVE_IMAGE = `!f:real^M->real^N s.\n independent s /\\ linear f /\\ (!x y. (f(x) = f(y)) ==> (x = y))\n ==> independent (IMAGE f s)`;;\n\nlet VECTOR_SUB_PROJECT_ORTHOGONAL = `!b:real^N x. b dot (x - ((b dot x) / (b dot b)) % b) = &0`;;\n\nlet BASIS_ORTHOGONAL = `!b:real^N->bool.\n FINITE b\n ==> ?c. FINITE c /\\ CARD c <= CARD b /\\\n span c = span b /\\ pairwise orthogonal c`;;\n\nlet ORTHOGONAL_BASIS_EXISTS = `!v:real^N->bool.\n ?b. independent b /\\\n b SUBSET span v /\\\n v SUBSET span b /\\\n b HAS_SIZE dim v /\\\n pairwise orthogonal b`;;\n\nlet SPAN_SPECIAL_SCALE = `!s a x:real^N.\n span((a % x) INSERT s) = if a = &0 then span s else span(x INSERT s)`;;\n\nlet LINEAR_INDEP_IMAGE_LEMMA = `!f b. linear(f:real^M->real^N) /\\\n FINITE b /\\\n independent (IMAGE f b) /\\\n (!x y. x IN b /\\ y IN b /\\ (f x = f y) ==> (x = y))\n ==> !x. x IN span b ==> (f(x) = vec 0) ==> (x = vec 0)`;;\n\nlet LINEAR_INDEPENDENT_EXTEND_LEMMA = `!f b. FINITE b\n ==> independent b\n ==> ?g:real^M->real^N.\n (!x y. x IN span b /\\ y IN span b\n ==> (g(x + y) = g(x) + g(y))) /\\\n (!x c. x IN span b ==> (g(c % x) = c % g(x))) /\\\n (!x. x IN b ==> (g x = f x))`;;\n\nlet LINEAR_INDEPENDENT_EXTEND = `!f b. independent b\n ==> ?g:real^M->real^N. linear g /\\ (!x. x IN b ==> (g x = f x))`;;\n\nlet SUBSPACE_KERNEL = `!f. linear f ==> subspace {x | f(x) = vec 0}`;;\n\nlet LINEAR_EQ_0_SPAN = `!f:real^M->real^N b.\n linear f /\\ (!x. x IN b ==> f(x) = vec 0)\n ==> !x. x IN span(b) ==> f(x) = vec 0`;;\n\nlet LINEAR_EQ_0 = `!f b s. linear f /\\ s SUBSET (span b) /\\ (!x. x IN b ==> f(x) = vec 0)\n ==> !x. x IN s ==> f(x) = vec 0`;;\n\nlet LINEAR_EQ = `!f g b s. linear f /\\ linear g /\\ s SUBSET (span b) /\\\n (!x. x IN b ==> f(x) = g(x))\n ==> !x. x IN s ==> f(x) = g(x)`;;\n\nlet LINEAR_EQ_STDBASIS = `!f:real^M->real^N g.\n linear f /\\ linear g /\\\n (!i. 1 <= i /\\ i <= dimindex(:M)\n ==> f(basis i) = g(basis i))\n ==> f = g`;;\n\nlet SUBSPACE_LINEAR_FIXED_POINTS = `!f:real^N->real^N. linear f ==> subspace {x | f(x) = x}`;;\n\nlet BILINEAR_EQ = `!f:real^M->real^N->real^P g b c s.\n bilinear f /\\ bilinear g /\\\n s SUBSET (span b) /\\ t SUBSET (span c) /\\\n (!x y. x IN b /\\ y IN c ==> f x y = g x y)\n ==> !x y. x IN s /\\ y IN t ==> f x y = g x y`;;\n\nlet BILINEAR_EQ_STDBASIS = `!f:real^M->real^N->real^P g.\n bilinear f /\\ bilinear g /\\\n (!i j. 1 <= i /\\ i <= dimindex(:M) /\\ 1 <= j /\\ j <= dimindex(:N)\n ==> f (basis i) (basis j) = g (basis i) (basis j))\n ==> f = g`;;\n\nlet LEFT_INVERTIBLE_TRANSP = `!A:real^N^M.\n (?B:real^N^M. B ** transp A = mat 1) <=> (?B:real^M^N. A ** B = mat 1)`;;\n\nlet RIGHT_INVERTIBLE_TRANSP = `!A:real^N^M.\n (?B:real^N^M. transp A ** B = mat 1) <=> (?B:real^M^N. B ** A = mat 1)`;;\n\nlet INVERTIBLE_TRANSP = `!A:real^N^M. invertible(transp A) <=> invertible A`;;\n\nlet LINEAR_INJECTIVE_LEFT_INVERSE = `!f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> ?g. linear g /\\ g o f = I`;;\n\nlet LINEAR_INJECTIVE_LEFT_INVERSE_EQ = `!f:real^M->real^N.\n linear f\n ==> ((!x y. f x = f y ==> x = y) <=> ?g. linear g /\\ g o f = I)`;;\n\nlet LINEAR_SURJECTIVE_RIGHT_INVERSE = `!f:real^M->real^N.\n linear f /\\ (!y. ?x. f x = y) ==> ?g. linear g /\\ f o g = I`;;\n\nlet LINEAR_SURJECTIVE_RIGHT_INVERSE_EQ = `!f:real^M->real^N.\n linear f\n ==> ((!y. ?x. f x = y) <=> ?g. linear g /\\ f o g = I)`;;\n\nlet MATRIX_LEFT_INVERTIBLE_INJECTIVE = `!A:real^N^M.\n (?B:real^M^N. B ** A = mat 1) <=>\n !x y:real^N. A ** x = A ** y ==> x = y`;;\n\nlet MATRIX_LEFT_INVERTIBLE_KER = `!A:real^N^M.\n (?B:real^M^N. B ** A = mat 1) <=> !x. A ** x = vec 0 ==> x = vec 0`;;\n\nlet MATRIX_RIGHT_INVERTIBLE_SURJECTIVE = `!A:real^N^M.\n (?B:real^M^N. A ** B = mat 1) <=> !y:real^M. ?x. A ** x = y`;;\n\nlet MATRIX_LEFT_INVERTIBLE_INDEPENDENT_COLUMNS = `!A:real^N^M. (?B:real^M^N. B ** A = mat 1) <=>\n !c. vsum(1..dimindex(:N)) (\\i. c(i) % column i A) = vec 0 ==>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> c(i) = &0`;;\n\nlet MATRIX_RIGHT_INVERTIBLE_INDEPENDENT_ROWS = `!A:real^N^M. (?B:real^M^N. A ** B = mat 1) <=>\n !c. vsum(1..dimindex(:M)) (\\i. c(i) % row i A) = vec 0 ==>\n !i. 1 <= i /\\ i <= dimindex(:M) ==> c(i) = &0`;;\n\nlet MATRIX_RIGHT_INVERTIBLE_SPAN_COLUMNS = `!A:real^N^M. (?B:real^M^N. A ** B = mat 1) <=> span(columns A) = (:real^M)`;;\n\nlet MATRIX_LEFT_INVERTIBLE_SPAN_ROWS = `!A:real^N^M. (?B:real^M^N. B ** A = mat 1) <=> span(rows A) = (:real^N)`;;\n\nlet LINEAR_INJECTIVE_IMP_SURJECTIVE = `!f:real^N->real^N.\n linear f /\\ (!x y. (f(x) = f(y)) ==> (x = y))\n ==> !y. ?x. f(x) = y`;;\n\nlet LINEAR_SURJECTIVE_IMP_INJECTIVE = `!f:real^N->real^N.\n linear f /\\ (!y. ?x. f(x) = y)\n ==> !x y. (f(x) = f(y)) ==> (x = y)`;;\n\nlet LINEAR_SURJECTIVE_IFF_INJECTIVE = `!f:real^N->real^N.\n linear f ==> ((!y. ?x. f x = y) <=> (!x y. f x = f y ==> x = y))`;;\n\nlet LEFT_RIGHT_INVERSE_EQ = `!f:A->A g h. f o g = I /\\ g o h = I ==> f = h`;;\n\nlet ISOMORPHISM_EXPAND = `!f g. f o g = I /\\ g o f = I <=> (!x. f(g x) = x) /\\ (!x. g(f x) = x)`;;\n\nlet LINEAR_INJECTIVE_ISOMORPHISM = `!f:real^N->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> ?f'. linear f' /\\ (!x. f'(f x) = x) /\\ (!x. f(f' x) = x)`;;\n\nlet LINEAR_SURJECTIVE_ISOMORPHISM = `!f:real^N->real^N.\n linear f /\\ (!y. ?x. f x = y)\n ==> ?f'. linear f' /\\ (!x. f'(f x) = x) /\\ (!x. f(f' x) = x)`;;\n\nlet LINEAR_INVERSE_LEFT = `!f:real^N->real^N f'.\n linear f /\\ linear f' ==> ((f o f' = I) <=> (f' o f = I))`;;\n\nlet LEFT_INVERSE_LINEAR = `!f g:real^N->real^N. linear f /\\ (g o f = I) ==> linear g`;;\n\nlet RIGHT_INVERSE_LINEAR = `!f g:real^N->real^N. linear f /\\ (f o g = I) ==> linear g`;;\n\nlet LEFT_RIGHT_INVERSE_LINEAR = `!f g:real^M->real^N.\n linear f /\\ g o f = I /\\ f o g = I ==> linear g`;;\n\nlet LINEAR_BIJECTIVE_LEFT_RIGHT_INVERSE = `!f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y)\n ==> ?g. linear g /\\ (!x. g(f x) = x) /\\ (!y. f(g y) = y)`;;\n\nlet LINEAR_BIJECTIVE_LEFT_RIGHT_INVERSE_EQ = `!f:real^M->real^N.\n linear f\n ==> ((!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y) <=>\n ?g. linear g /\\ f o g = I /\\ g o f = I)`;;\n\nlet LINEAR_INJECTIVE_LEFT_RIGHT_INVERSE_EQ = `!f:real^N->real^N.\n linear f\n ==> ((!x y. f x = f y ==> x = y) <=>\n (?g. linear g /\\ f o g = I /\\ g o f = I))`;;\n\nlet LINEAR_SURJECTIVE_LEFT_RIGHT_INVERSE_EQ = `!f:real^N->real^N.\n linear f\n ==> ((!y. ?x. f x = y) <=>\n (?g. linear g /\\ f o g = I /\\ g o f = I))`;;\n\nlet MATRIX_LEFT_RIGHT_INVERSE = `!A:real^N^N A':real^N^N. (A ** A' = mat 1) <=> (A' ** A = mat 1)`;;\n\nlet MATRIX_LEFT_INVERTIBLE = `!f:real^M->real^N.\n linear f ==> ((?B:real^N^M. B ** matrix f = mat 1) <=>\n (?g. linear g /\\ g o f = I))`;;\n\nlet MATRIX_RIGHT_INVERTIBLE = `!f:real^M->real^N.\n linear f ==> ((?B:real^N^M. matrix f ** B = mat 1) <=>\n (?g. linear g /\\ f o g = I))`;;\n\nlet INVERTIBLE_LEFT_INVERSE = `!A:real^N^N. invertible(A) <=> ?B:real^N^N. B ** A = mat 1`;;\n\nlet INVERTIBLE_RIGHT_INVERSE = `!A:real^N^N. invertible(A) <=> ?B:real^N^N. A ** B = mat 1`;;\n\nlet MATRIX_INVERTIBLE = `!f:real^M->real^N.\n linear f\n ==> (invertible(matrix f) <=>\n ?g. linear g /\\ f o g = I /\\ g o f = I)`;;\n\nlet INVERTIBLE_EQ_INJECTIVE_AND_SURJECTIVE = `!m:real^M^N.\n invertible m <=>\n (!x y:real^M. m ** x = m ** y ==> x = y) /\\\n IMAGE (\\x. m ** x) (:real^M) = (:real^N)`;;\n\nlet LINEAR_INVERTIBLE_BOUNDED_BELOW_POS = `!f:real^M->real^N g.\n linear f /\\ linear g /\\ (g o f = I)\n ==> ?B. &0 < B /\\ !x. B * norm(x) <= norm(f x)`;;\n\nlet LINEAR_INVERTIBLE_BOUNDED_BELOW = `!f:real^M->real^N g.\n linear f /\\ linear g /\\ (g o f = I)\n ==> ?B. !x. B * norm(x) <= norm(f x)`;;\n\nlet LINEAR_INJECTIVE_BOUNDED_BELOW_POS = `!f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> ?B. &0 < B /\\ !x. norm(x) * B <= norm(f x)`;;\n\nlet DIM_INJECTIVE_LINEAR_IMAGE = `!f:real^M->real^N s.\n linear f /\\ (!x y. f x = f y ==> x = y) ==> dim(IMAGE f s) = dim s`;;\n\nlet LINEAR_INJECTIVE_DIMINDEX_LE = `!f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> dimindex(:M) <= dimindex(:N)`;;\n\nlet LINEAR_SURJECTIVE_DIMINDEX_LE = `!f:real^M->real^N.\n linear f /\\ (!y. ?x. f x = y)\n ==> dimindex(:N) <= dimindex(:M)`;;\n\nlet LINEAR_BIJECTIVE_DIMINDEX_EQ = `!f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y)\n ==> dimindex(:M) = dimindex(:N)`;;\n\nlet INVERTIBLE_IMP_SQUARE_MATRIX = `!A:real^N^M. invertible A ==> dimindex(:M) = dimindex(:N)`;;\n\nlet rowvector = new_definition\n `(rowvector:real^N->real^N^1) v = lambda i j. v$j`;;\n\nlet columnvector = new_definition\n `(columnvector:real^N->real^1^N) v = lambda i j. v$i`;;\n\nlet TRANSP_COLUMNVECTOR = `!v. transp(columnvector v) = rowvector v`;;\n\nlet TRANSP_ROWVECTOR = `!v. transp(rowvector v) = columnvector v`;;\n\nlet DOT_ROWVECTOR_COLUMNVECTOR = `!A:real^N^M v:real^N. columnvector(A ** v) = A ** columnvector v`;;\n\nlet DOT_MATRIX_PRODUCT = `!x y:real^N. x dot y = (rowvector x ** columnvector y)$1$1`;;\n\nlet DOT_MATRIX_VECTOR_MUL = `!A:real^N^N B:real^N^N x:real^N y:real^N.\n (A ** x) dot (B ** y) =\n ((rowvector x) ** (transp(A) ** B) ** (columnvector y))$1$1`;;\n\nlet MATRIX_VECTOR_MUL_IN_COLUMNSPACE = `!A:real^M^N x:real^M. (A ** x) IN span(columns A)`;;\n\nlet SUBSPACE_ORTHOGONAL_TO_VECTOR = `!x. subspace {y | orthogonal x y}`;;\n\nlet SUBSPACE_ORTHOGONAL_TO_VECTORS = `!s. subspace {y | (!x. x IN s ==> orthogonal x y)}`;;\n\nlet ORTHOGONAL_TO_SPAN = `!s x. (!y. y IN s ==> orthogonal x y)\n ==> !y. y IN span(s) ==> orthogonal x y`;;\n\nlet ORTHOGONAL_TO_SPAN_EQ = `!s x. (!y. y IN span(s) ==> orthogonal x y) <=>\n (!y. y IN s ==> orthogonal x y)`;;\n\nlet ORTHOGONAL_TO_SPANS_EQ = `!s t. (!x y. x IN span(s) /\\ y IN span(t) ==> orthogonal x y) <=>\n (!x y. x IN s /\\ y IN t ==> orthogonal x y)`;;\n\nlet ORTHOGONAL_NULLSPACE_ROWSPACE = `!A:real^M^N x y:real^M.\n A ** x = vec 0 /\\ y IN span(rows A) ==> orthogonal x y`;;\n\nlet NULLSPACE_INTER_ROWSPACE = `!A:real^M^N x:real^M. A ** x = vec 0 /\\ x IN span(rows A) <=> x = vec 0`;;\n\nlet MATRIX_VECTOR_MUL_INJECTIVE_ON_ROWSPACE = `!A:real^M^N x y:real^M.\n x IN span(rows A) /\\ y IN span(rows A) /\\ A ** x = A ** y ==> x = y`;;\n\nlet DIM_ROWS_LE_DIM_COLUMNS = `!A:real^M^N. dim(rows A) <= dim(columns A)`;;\n\nlet rank = new_definition\n `rank(A:real^M^N) = dim(columns A)`;;\n\nlet RANK_ROW = `!A:real^M^N. rank(A) = dim(rows A)`;;\n\nlet RANK_TRANSP = `!A:real^M^N. rank(transp A) = rank A`;;\n\nlet MATRIX_VECTOR_MUL_BASIS = `!A:real^M^N k. 1 <= k /\\ k <= dimindex(:M)\n ==> A ** (basis k) = column k A`;;\n\nlet COLUMNS_IMAGE_BASIS = `!A:real^M^N.\n columns A = IMAGE (\\x. A ** x) {basis i | 1 <= i /\\ i <= dimindex(:M)}`;;\n\nlet RANK_DIM_IM = `!A:real^M^N. rank A = dim(IMAGE (\\x. A ** x) (:real^M))`;;\n\nlet RANK_BOUND = `!A:real^M^N. rank(A) <= MIN (dimindex(:M)) (dimindex(:N))`;;\n\nlet FULL_RANK_INJECTIVE = `!A:real^M^N.\n rank A = dimindex(:M) <=>\n (!x y:real^M. A ** x = A ** y ==> x = y)`;;\n\nlet FULL_RANK_SURJECTIVE = `!A:real^M^N.\n rank A = dimindex(:N) <=> (!y:real^N. ?x:real^M. A ** x = y)`;;\n\nlet RANK_I = `rank(mat 1:real^N^N) = dimindex(:N)`;;\n\nlet MATRIX_FULL_LINEAR_EQUATIONS = `!A:real^M^N b:real^N.\n rank A = dimindex(:N) ==> ?x. A ** x = b`;;\n\nlet MATRIX_NONFULL_LINEAR_EQUATIONS_EQ = `!A:real^M^N.\n (?x. ~(x = vec 0) /\\ A ** x = vec 0) <=> ~(rank A = dimindex(:M))`;;\n\nlet MATRIX_NONFULL_LINEAR_EQUATIONS = `!A:real^M^N.\n ~(rank A = dimindex(:M)) ==> ?x. ~(x = vec 0) /\\ A ** x = vec 0`;;\n\nlet MATRIX_TRIVIAL_LINEAR_EQUATIONS = `!A:real^M^N.\n dimindex(:N) < dimindex(:M)\n ==> ?x. ~(x = vec 0) /\\ A ** x = vec 0`;;\n\nlet RANK_EQ_0 = `!A:real^M^N. rank A = 0 <=> A = mat 0`;;\n\nlet RANK_0 = `rank(mat 0) = 0`;;\n\nlet RANK_MUL_LE_RIGHT = `!A:real^N^M B:real^P^N. rank(A ** B) <= rank(B)`;;\n\nlet RANK_MUL_LE_LEFT = `!A:real^N^M B:real^P^N. rank(A ** B) <= rank(A)`;;\n\nlet SPAN_COLUMNSPACE = `!A:real^M^N. span(columns A) = {y | ?x. A ** x = y}`;;\n\nlet MATRIX_AUGMENTED_LINEAR_EQUATIONS = `!A:real^N^M y:real^N.\n (?x. transp A ** x = y) <=>\n rank(pastecart A (rowvector y)) = rank A`;;\n\nlet NORM_COLUMN_LE_ONORM = `!A:real^N^M i. norm(column i A) <= onorm(\\x. A ** x)`;;\n\nlet MATRIX_COMPONENT_LE_ONORM = `!A:real^N^M i j. abs(A$i$j) <= onorm(\\x. A ** x)`;;\n\nlet COMPONENT_LE_ONORM = `!f:real^M->real^N i j. linear f ==> abs(matrix f$i$j) <= onorm f`;;\n\nlet ONORM_LE_MATRIX_COMPONENT_SUM = `!A:real^N^M.\n onorm(\\x. A ** x) <=\n sum (1..dimindex(:M))\n (\\i. sum(1..dimindex(:N)) (\\j. abs(A$i$j)))`;;\n\nlet ONORM_LE_MATRIX_COMPONENT = `!A:real^N^M B.\n (!i j. 1 <= i /\\ i <= dimindex(:M) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> abs(A$i$j) <= B)\n ==> onorm(\\x. A ** x) <= &(dimindex(:M)) * &(dimindex(:N)) * B`;;\n\nlet MATRIX_RATIONAL_APPROXIMATION = `!A:real^N^M e.\n &0 < e\n ==> ?B. (!i j. 1 <= i /\\ i <= dimindex(:M) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> rational(B$i$j)) /\\\n onorm(\\x. (A - B) ** x) < e`;;\n\nlet HYPERPLANE_EQ_EMPTY = `!a:real^N b. {x | a dot x = b} = {} <=> a = vec 0 /\\ ~(b = &0)`;;\n\nlet HYPERPLANE_EQ_UNIV = `!a b. {x | a dot x = b} = (:real^N) <=> a = vec 0 /\\ b = &0`;;\n\nlet HALFSPACE_EQ_EMPTY_LT = `!a:real^N b. {x | a dot x < b} = {} <=> a = vec 0 /\\ b <= &0`;;\n\nlet HALFSPACE_EQ_EMPTY_GT = `!a:real^N b. {x | a dot x > b} = {} <=> a = vec 0 /\\ b >= &0`;;\n\nlet HALFSPACE_EQ_EMPTY_LE = `!a:real^N b. {x | a dot x <= b} = {} <=> a = vec 0 /\\ b < &0`;;\n\nlet HALFSPACE_EQ_EMPTY_GE = `!a:real^N b. {x | a dot x >= b} = {} <=> a = vec 0 /\\ b > &0`;;\n\nlet ADJOINT_INJECTIVE = `!f:real^M->real^N.\n linear f\n ==> ((!x y. adjoint f x = adjoint f y ==> x = y) <=>\n (!y. ?x. f x = y))`;;\n\nlet ADJOINT_SURJECTIVE = `!f:real^M->real^N.\n linear f\n ==> ((!y. ?x. adjoint f x = y) <=> (!x y. f x = f y ==> x = y))`;;\n\nlet ADJOINT_INJECTIVE_INJECTIVE = `!f:real^N->real^N.\n linear f\n ==> ((!x y. adjoint f x = adjoint f y ==> x = y) <=>\n (!x y. f x = f y ==> x = y))`;;\n\nlet ADJOINT_INJECTIVE_INJECTIVE_0 = `!f:real^N->real^N.\n linear f\n ==> ((!x. adjoint f x = vec 0 ==> x = vec 0) <=>\n (!x. f x = vec 0 ==> x = vec 0))`;;\n\nlet TRANSP_INJECTIVE = `!m:real^M^N.\n (!x y:real^N. transp m ** x = transp m ** y ==> x = y) <=>\n IMAGE (\\x. m ** x) (:real^M) = (:real^N)`;;\n\nlet TRANSP_SURJECTIVE = `!m:real^M^N.\n IMAGE (\\x. transp m ** x) (:real^N) = (:real^M) <=>\n (!x y:real^M. m ** x = m ** y ==> x = y)`;;\n\nlet LINEAR_SINGULAR_INTO_HYPERPLANE = `!f:real^N->real^N.\n linear f\n ==> (~(!x y. f(x) = f(y) ==> x = y) <=>\n ?a. ~(a = vec 0) /\\ !x. a dot f(x) = &0)`;;\n\nlet LINEAR_SINGULAR_IMAGE_HYPERPLANE = `!f:real^N->real^N.\n linear f /\\ ~(!x y. f(x) = f(y) ==> x = y)\n ==> ?a. ~(a = vec 0) /\\ !s. IMAGE f s SUBSET {x | a dot x = &0}`;;\n\nlet SPAN_DELETE_0 = `!s:real^N->bool. span(s DELETE vec 0) = span s`;;\n\nlet DIM_BASIS_IMAGE = `!k. dim(IMAGE basis k:real^N->bool) = CARD((1..dimindex(:N)) INTER k)`;;\n\nlet SPAN_IMAGE_SCALE = `!c s. (!x. x IN s ==> ~(c x = &0))\n ==> span (IMAGE (\\x:real^N. c(x) % x) s) = span s`;;\n\nlet DIM_IMAGE_SCALE = `!c s:real^N->bool.\n (!x. x IN s ==> ~(c x = &0)) ==> dim(IMAGE (\\x. c x % x) s) = dim s`;;\n\nlet PAIRWISE_ORTHOGONAL_INDEPENDENT = `!s:real^N->bool.\n pairwise orthogonal s /\\ ~(vec 0 IN s) ==> independent s`;;\n\nlet PAIRWISE_ORTHOGONAL_IMP_FINITE = `!s:real^N->bool. pairwise orthogonal s ==> FINITE s`;;\n\nlet GRAM_SCHMIDT_STEP = `!s a x.\n pairwise orthogonal s /\\ x IN span s\n ==> orthogonal x (a - vsum s (\\b:real^N. (b dot a) / (b dot b) % b))`;;\n\nlet ORTHOGONAL_EXTENSION = `!s t:real^N->bool.\n pairwise orthogonal s\n ==> ?u. pairwise orthogonal (s UNION u) /\\\n span (s UNION u) = span (s UNION t)`;;\n\nlet ORTHOGONAL_EXTENSION_STRONG = `!s t:real^N->bool.\n pairwise orthogonal s\n ==> ?u. DISJOINT u (vec 0 INSERT s) /\\\n pairwise orthogonal (s UNION u) /\\\n span (s UNION u) = span (s UNION t)`;;\n\nlet ORTHONORMAL_EXTENSION = `!s t:real^N->bool.\n pairwise orthogonal s /\\ (!x. x IN s ==> norm x = &1)\n ==> ?u. DISJOINT u s /\\\n pairwise orthogonal (s UNION u) /\\\n (!x. x IN u ==> norm x = &1) /\\\n span(s UNION u) = span(s UNION t)`;;\n\nlet VECTOR_IN_ORTHOGONAL_SPANNINGSET = `!a. ?s. a IN s /\\ pairwise orthogonal s /\\ span s = (:real^N)`;;\n\nlet VECTOR_IN_ORTHOGONAL_BASIS = `!a. ~(a = vec 0)\n ==> ?s. a IN s /\\ ~(vec 0 IN s) /\\\n pairwise orthogonal s /\\\n independent s /\\\n s HAS_SIZE (dimindex(:N)) /\\\n span s = (:real^N)`;;\n\nlet VECTOR_IN_ORTHONORMAL_BASIS = `!a. norm a = &1\n ==> ?s. a IN s /\\\n pairwise orthogonal s /\\\n (!x. x IN s ==> norm x = &1) /\\\n independent s /\\\n s HAS_SIZE (dimindex(:N)) /\\\n span s = (:real^N)`;;\n\nlet BESSEL_INEQUALITY = `!s x:real^N.\n pairwise orthogonal s /\\ (!x. x IN s ==> norm x = &1)\n ==> sum s (\\e. (e dot x) pow 2) <= norm(x) pow 2`;;\n\nlet ORTHOGONAL_SPANNINGSET_SUBSPACE = `!s:real^N->bool.\n subspace s\n ==> ?b. b SUBSET s /\\ pairwise orthogonal b /\\ span b = s`;;\n\nlet ORTHOGONAL_BASIS_SUBSPACE = `!s:real^N->bool.\n subspace s\n ==> ?b. ~(vec 0 IN b) /\\\n b SUBSET s /\\\n pairwise orthogonal b /\\\n independent b /\\\n b HAS_SIZE (dim s) /\\\n span b = s`;;\n\nlet ORTHONORMAL_BASIS_SUBSPACE = `!s:real^N->bool.\n subspace s\n ==> ?b. b SUBSET s /\\\n pairwise orthogonal b /\\\n (!x. x IN b ==> norm x = &1) /\\\n independent b /\\\n b HAS_SIZE (dim s) /\\\n span b = s`;;\n\nlet ORTHOGONAL_TO_SUBSPACE_EXISTS_GEN = `!s t:real^N->bool.\n span s PSUBSET span t\n ==> ?x. ~(x = vec 0) /\\ x IN span t /\\\n (!y. y IN span s ==> orthogonal x y)`;;\n\nlet ORTHOGONAL_TO_SUBSPACE_EXISTS = `!s:real^N->bool. dim s < dimindex(:N)\n ==> ?x. ~(x = vec 0) /\\ !y. y IN s ==> orthogonal x y`;;\n\nlet ORTHOGONAL_TO_VECTOR_EXISTS = `!x:real^N. 2 <= dimindex(:N) ==> ?y. ~(y = vec 0) /\\ orthogonal x y`;;\n\nlet SPAN_NOT_UNIV_ORTHOGONAL = `!s. ~(span s = (:real^N))\n ==> ?a. ~(a = vec 0) /\\ !x. x IN span s ==> a dot x = &0`;;\n\nlet SPAN_NOT_UNIV_SUBSET_HYPERPLANE = `!s. ~(span s = (:real^N))\n ==> ?a. ~(a = vec 0) /\\ span s SUBSET {x | a dot x = &0}`;;\n\nlet LOWDIM_SUBSET_HYPERPLANE = `!s. dim s < dimindex(:N)\n ==> ?a:real^N. ~(a = vec 0) /\\ span s SUBSET {x | a dot x = &0}`;;\n\nlet VECTOR_EQ_DOT_SPAN = `!b x y:real^N.\n (!v. v IN b ==> v dot x = v dot y) /\\ x IN span b /\\ y IN span b\n ==> x = y`;;\n\nlet ORTHONORMAL_BASIS_EXPAND = `!b x:real^N.\n pairwise orthogonal b /\\ (!v. v IN b ==> norm v = &1) /\\ x IN span b\n ==> vsum b (\\v. (v dot x) % v) = x`;;\n\nlet ORTHONORMAL_BASIS_EXPAND_DOT = `!b x y:real^N.\n pairwise orthogonal b /\\\n (!v. v IN b ==> norm v = &1) /\\\n (x IN span b \\/ y IN span b)\n ==> sum b (\\v. (v dot x) * (v dot y)) = x dot y`;;\n\nlet ORTHONORMAL_BASIS_EXPAND_NORM = `!b x:real^N.\n pairwise orthogonal b /\\\n (!v. v IN b ==> norm v = &1) /\\\n x IN span b\n ==> sum b (\\v. (v dot x) pow 2) = norm x pow 2`;;\n\nlet ORTHOGONAL_IMP_INDEPENDENT_SUBSPACES = `!s t:real^N->bool.\n (!a b. a IN s /\\ b IN t ==> orthogonal a b)\n ==> s INTER t SUBSET {vec 0}`;;\n\nlet INDEPENDENT_SUBSPACES_ALT = `!s t:real^N->bool.\n subspace s /\\ subspace t\n ==> (s INTER t SUBSET {vec 0} <=> s INTER t = {vec 0})`;;\n\nlet INDEPENDENT_SUBSPACES_0 = `!s t:real^N->bool.\n subspace s /\\ subspace t\n ==> (s INTER t SUBSET {vec 0} <=>\n !x y. x IN s /\\ y IN t /\\ x + y = vec 0\n ==> x = vec 0 /\\ y = vec 0)`;;\n\nlet INDEPENDENT_SUBSPACES = `!s t:real^N->bool.\n subspace s /\\ subspace t\n ==> (s INTER t SUBSET {vec 0} <=>\n !x y x' y'. x IN s /\\ x' IN s /\\ y IN t /\\ y' IN t /\\\n x + y = x' + y'\n ==> x = x' /\\ y = y')`;;\n\nlet ORTHOGONAL_SUBSPACE_DECOMP_UNIQUE = `!s t x y x' y':real^N.\n (!a b. a IN s /\\ b IN t ==> orthogonal a b) /\\\n x IN span s /\\ x' IN span s /\\ y IN span t /\\ y' IN span t /\\\n x + y = x' + y'\n ==> x = x' /\\ y = y'`;;\n\nlet ORTHOGONAL_SUBSPACE_DECOMP_EXISTS = `!s x:real^N. ?y z. y IN span s /\\ (!w. w IN span s ==> orthogonal z w) /\\\n x = y + z`;;\n\nlet ORTHOGONAL_SUBSPACE_DECOMP = `!s x. ?!(y,z). y IN span s /\\\n z IN {z:real^N | !x. x IN span s ==> orthogonal z x} /\\\n x = y + z`;;\n\nlet ISOMETRY_SUBSET_SUBSPACE = `!s:real^M->bool t:real^N->bool.\n subspace s /\\ subspace t /\\ dim s <= dim t\n ==> ?f. linear f /\\ IMAGE f s SUBSET t /\\\n (!x. x IN s ==> norm(f x) = norm(x))`;;\n\nlet ISOMETRIES_SUBSPACES = `!s:real^M->bool t:real^N->bool.\n subspace s /\\ subspace t /\\ dim s = dim t\n ==> ?f g. linear f /\\ linear g /\\\n IMAGE f s = t /\\ IMAGE g t = s /\\\n (!x. x IN s ==> norm(f x) = norm x) /\\\n (!y. y IN t ==> norm(g y) = norm y) /\\\n (!x. x IN s ==> g(f x) = x) /\\\n (!y. y IN t ==> f(g y) = y)`;;\n\nlet ISOMETRY_SUBSPACES = `!s:real^M->bool t:real^N->bool.\n subspace s /\\ subspace t /\\ dim s = dim t\n ==> ?f:real^M->real^N. linear f /\\ IMAGE f s = t /\\\n (!x. x IN s ==> norm(f x) = norm(x))`;;\n\nlet ISOMETRY_UNIV_SUBSPACE = `!s. subspace s /\\ dimindex(:M) = dim s\n ==> ?f:real^M->real^N.\n linear f /\\ IMAGE f (:real^M) = s /\\\n (!x. norm(f x) = norm(x))`;;\n\nlet ISOMETRY_UNIV_SUPERSET_SUBSPACE = `!s. subspace s /\\ dim s <= dimindex(:M) /\\ dimindex(:M) <= dimindex(:N)\n ==> ?f:real^M->real^N.\n linear f /\\ s SUBSET (IMAGE f (:real^M)) /\\\n (!x. norm(f x) = norm(x))`;;\n\nlet ISOMETRY_UNIV_UNIV = `dimindex(:M) <= dimindex(:N)\n ==> ?f:real^M->real^N. linear f /\\ (!x. norm(f x) = norm(x))`;;\n\nlet SUBSPACE_ISOMORPHISM = `!s t. subspace s /\\ subspace t /\\ dim(s) = dim(t)\n ==> ?f:real^M->real^N.\n linear f /\\ (IMAGE f s = t) /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> (x = y))`;;\n\nlet ISOMORPHISMS_UNIV_UNIV = `dimindex(:M) = dimindex(:N)\n ==> ?f:real^M->real^N g.\n linear f /\\ linear g /\\\n (!x. norm(f x) = norm x) /\\ (!y. norm(g y) = norm y) /\\\n (!x. g(f x) = x) /\\ (!y. f(g y) = y)`;;\n\nlet SUBSPACE_HYPERPLANE = `!a. subspace {x:real^N | a dot x = &0}`;;\n\nlet SUBSPACE_SPECIAL_HYPERPLANE = `!k. subspace {x:real^N | x$k = &0}`;;\n\nlet SPECIAL_HYPERPLANE_SPAN = `!k. 1 <= k /\\ k <= dimindex(:N)\n ==> {x:real^N | x$k = &0} =\n span(IMAGE basis ((1..dimindex(:N)) DELETE k))`;;\n\nlet DIM_SPECIAL_HYPERPLANE = `!k. 1 <= k /\\ k <= dimindex(:N)\n ==> dim {x:real^N | x$k = &0} = dimindex(:N) - 1`;;\n\nlet LOWDIM_EQ_INTER_HYPERPLANE = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ t SUBSET s /\\ dim t + 1 = dim s\n ==> ?a. ~(a = vec 0) /\\ {x | a dot x = &0} INTER s = t`;;\n\nlet LOWDIM_EQ_HYPERPLANE = `!s. dim s = dimindex(:N) - 1\n ==> ?a:real^N. ~(a = vec 0) /\\ span s = {x | a dot x = &0}`;;\n\nlet DIM_IMAGE_KERNEL_GEN = `!f:real^M->real^N s.\n linear f /\\ subspace s\n ==> dim(IMAGE f s) + dim {x | x IN s /\\ f x = vec 0} = dim(s)`;;\n\nlet DIM_IMAGE_KERNEL = `!f:real^M->real^N.\n linear f\n ==> dim(IMAGE f (:real^M)) + dim {x | f x = vec 0} = dimindex(:M)`;;\n\nlet DIM_SUMS_INTER = `!s t:real^N->bool.\n subspace s /\\ subspace t\n ==> dim {x + y | x IN s /\\ y IN t} + dim(s INTER t) = dim(s) + dim(t)`;;\n\nlet DIM_UNION_INTER = `!s t:real^N->bool.\n subspace s /\\ subspace t\n ==> dim(s UNION t) + dim(s INTER t) = dim s + dim t`;;\n\nlet DIM_KERNEL_COMPOSE = `!f:real^M->real^N g:real^N->real^P.\n linear f /\\ linear g\n ==> dim {x | (g o f) x = vec 0} <=\n dim {x | f(x) = vec 0} +\n dim {y | g(y) = vec 0}`;;\n\nlet DIM_ORTHOGONAL_SUM = `!s t:real^N->bool.\n (!x y. x IN s /\\ y IN t ==> x dot y = &0)\n ==> dim(s UNION t) = dim(s) + dim(t)`;;\n\nlet DIM_SUBSPACE_ORTHOGONAL_TO_VECTORS = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ s SUBSET t\n ==> dim {y | y IN t /\\ !x. x IN s ==> orthogonal x y} + dim s = dim t`;;\n\nlet DIM_SPECIAL_SUBSPACE = `!k. dim {x:real^N |\n !i. 1 <= i /\\ i <= dimindex(:N) /\\ i IN k ==> x$i = &0} =\n CARD((1..dimindex(:N)) DIFF k)`;;\n\nlet INDEPENDENT_UNION = `!s t:real^N->bool.\n independent s /\\ independent t /\\\n (span s) INTER (span t) SUBSET {vec 0}\n ==> independent(s UNION t)`;;\n\nlet LINEAR_INJECTIVE_ON_IFF_DIM = `!f:real^M->real^N s.\n linear f /\\ subspace s\n ==> ((!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y) <=>\n dim(IMAGE f s) = dim s)`;;\n\nlet DIM_INJECTIVE_ON_LINEAR_IMAGE = `!f:real^M->real^N s.\n linear f /\\ subspace s /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)\n ==> dim(IMAGE f s) = dim s`;;\n\nlet DIM_EQ_SUBSPACES = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ s SUBSET t /\\ dim t <= dim s\n ==> s = t`;;\n\nlet DIM_EQ_SUBSPACE = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ s SUBSET t\n ==> (dim s = dim t <=> s = t)`;;\n\nlet LINEAR_SURJECTIVE_ON_IFF_DIM = `!f:real^M->real^N s t.\n linear f /\\ subspace s /\\ subspace t /\\ IMAGE f s SUBSET t\n ==> (IMAGE f s = t <=> dim(IMAGE f s) = dim t)`;;\n\nlet LINEAR_INJECTIVE_IMP_SURJECTIVE_ON = `!f:real^M->real^N s t.\n linear f /\\ subspace s /\\ subspace t /\\\n IMAGE f s SUBSET t /\\ dim t <= dim s /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)\n ==> IMAGE f s = t`;;\n\nlet LINEAR_SURJECTIVE_IFF_INJECTIVE_ON = `!f:real^M->real^N s t.\n linear f /\\ subspace s /\\ subspace t /\\\n IMAGE f s SUBSET t /\\ dim s = dim t\n ==> (IMAGE f s = t <=>\n !x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)`;;\n\nlet LINEAR_INJECTIVE_IFF_DIM = `!f:real^M->real^N.\n linear f\n ==> ((!x y. f x = f y ==> x = y) <=>\n dim(IMAGE f (:real^M)) = dimindex(:M))`;;\n\nlet LINEAR_SURJECTIVE_IFF_DIM = `!f:real^M->real^N.\n linear f\n ==> ((!y. ?x. f x = y) <=>\n dim(IMAGE f (:real^M)) = dimindex(:N))`;;\n\nlet LINEAR_SURJECTIVE_IFF_INJECTIVE_GEN = `!f:real^M->real^N.\n dimindex(:M) = dimindex(:N) /\\ linear f\n ==> ((!y. ?x. f x = y) <=> (!x y. f x = f y ==> x = y))`;;\n\nlet MATRIX_INVERTIBLE_LEFT_GEN = `!f:real^M->real^N.\n linear f /\\ dimindex(:N) <= dimindex(:M)\n ==> (invertible(matrix f) <=> ?g. linear g /\\ g o f = I)`;;\n\nlet MATRIX_INVERTIBLE_LEFT = `!f:real^N->real^N.\n linear f\n ==> (invertible(matrix f) <=> ?g. linear g /\\ g o f = I)`;;\n\nlet MATRIX_INVERTIBLE_RIGHT_GEN = `!f:real^M->real^N.\n linear f /\\ dimindex(:M) <= dimindex(:N)\n ==> (invertible(matrix f) <=> ?g. linear g /\\ f o g = I)`;;\n\nlet MATRIX_INVERTIBLE_RIGHT = `!f:real^N->real^N.\n linear f\n ==> (invertible(matrix f) <=> ?g. linear g /\\ f o g = I)`;;\n\nlet PASTECART_AS_ORTHOGONAL_SUM = `!x:real^M y:real^N.\n pastecart x y = pastecart x (vec 0) + pastecart (vec 0) y`;;\n\nlet PCROSS_AS_ORTHOGONAL_SUM = `!s:real^M->bool t:real^N->bool.\n s PCROSS t =\n {u + v | u IN IMAGE (\\x. pastecart x (vec 0)) s /\\\n v IN IMAGE (\\y. pastecart (vec 0) y) t}`;;\n\nlet DIM_PCROSS = `!s:real^M->bool t:real^N->bool.\n subspace s /\\ subspace t ==> dim(s PCROSS t) = dim s + dim t`;;\n\nlet SPAN_PCROSS_SUBSET = `!s:real^M->bool t:real^N->bool.\n span(s PCROSS t) SUBSET (span s) PCROSS (span t)`;;\n\nlet SPAN_PCROSS = `!s:real^M->bool t:real^N->bool.\n ~(s = {}) /\\ ~(t = {}) /\\ (vec 0 IN s \\/ vec 0 IN t)\n ==> span(s PCROSS t) = (span s) PCROSS (span t)`;;\n\nlet DIM_PCROSS_STRONG = `!s:real^M->bool t:real^N->bool.\n ~(s = {}) /\\ ~(t = {}) /\\ (vec 0 IN s \\/ vec 0 IN t)\n ==> dim(s PCROSS t) = dim s + dim t`;;\n\nlet SPAN_SUMS = `!s t:real^N->bool.\n ~(s = {}) /\\ ~(t = {}) /\\ vec 0 IN (s UNION t)\n ==> span {x + y | x IN s /\\ y IN t} =\n {x + y | x IN span s /\\ y IN span t}`;;\n\nlet RANK_NULLSPACE = `!A:real^M^N. rank A + dim {x | A ** x = vec 0} = dimindex(:M)`;;\n\nlet RANK_SYLVESTER = `!A:real^N^M B:real^P^N.\n rank(A) + rank(B) <= rank(A ** B) + dimindex(:N)`;;\n\nlet RANK_GRAM = `!A:real^M^N. rank(transp A ** A) = rank A`;;\n\nlet RANK_TRIANGLE = `!A B:real^M^N. rank(A + B) <= rank(A) + rank(B)`;;\n\nlet COVARIANCE_MATRIX_EQ_0 = `!A:real^N^M. transp A ** A = mat 0 <=> A = mat 0`;;\n\nlet MATRIX_MUL_COVARIANCE_LCANCEL = `!A:real^N^P B C:real^M^N.\n (transp A ** A) ** B = (transp A ** A) ** C <=> A ** B = A ** C`;;\n\nlet MATRIX_MUL_COVARIANCE_RCANCEL = `!A:real^P^N B C:real^N^M.\n B ** (A ** transp A) = C ** (A ** transp A) <=> B ** A = C ** A`;;\n\nlet MATRIX_VECTOR_MUL_COVARIANCE_EQ_0 = `!A:real^M^N x. (transp A ** A) ** x = vec 0 <=> A ** x = vec 0`;;\n\nlet matrix_inv = new_definition\n `matrix_inv (A:real^M^N) =\n matrix(\\y. @x. (!w. A ** w = vec 0 ==> orthogonal x w) /\\\n (!z. orthogonal (y - A ** x) (A ** z)))`;;\n\nlet MOORE_PENROSE_PSEUDOINVERSE,MOORE_PENROSE_PSEUDOINVERSE_UNIQUE =\n let lemma_existence = `!f:real^M->real^N y.\n linear f\n ==> ?x. (!w. f w = vec 0 ==> orthogonal x w) /\\\n (!z. orthogonal (y - f x) (f z))`;;\n\nlet SYMMETRIC_MATRIX_INV_RMUL = `!A:real^M^N. symmetric_matrix(A ** matrix_inv A)`;;\n\nlet MATRIX_INV_INV = `!A:real^M^N. matrix_inv (matrix_inv A) = A`;;\n\nlet MATRIX_INV_EQ = `!A B:real^M^N. matrix_inv A = matrix_inv B <=> A = B`;;\n\nlet MATRIX_INV_MUL_OUTER = `!A:real^M^N. matrix_inv A ** A ** matrix_inv A = matrix_inv A`;;\n\nlet SYMMETRIC_MATRIX_INV_LMUL = `!A:real^M^N. symmetric_matrix(matrix_inv A ** A)`;;\n\nlet MATRIX_INV_UNIQUE_STRONG = `!A:real^M^N X.\n A ** X ** A = A /\\ X ** A ** X = X /\\\n symmetric_matrix(A ** X) /\\ symmetric_matrix(X ** A)\n ==> matrix_inv A = X`;;\n\nlet MATRIX_INV_TRANSP = `!A:real^M^N. matrix_inv (transp A) = transp(matrix_inv A)`;;\n\nlet TRANSP_MATRIX_INV = `!A:real^M^N. transp(matrix_inv A) = matrix_inv(transp A)`;;\n\nlet SYMMETRIC_MATRIX_INV = `!A:real^N^N. symmetric_matrix(matrix_inv A) <=> symmetric_matrix A`;;\n\nlet MATRIX_INV_0 = `matrix_inv(mat 0:real^M^N) = mat 0`;;\n\nlet MATRIX_INV_EQ_0 = `!A:real^M^N. matrix_inv A = mat 0 <=> A = mat 0`;;\n\nlet MATRIX_INV_CMUL = `!c A:real^M^N. matrix_inv (c %% A) = inv(c) %% matrix_inv A`;;\n\nlet MATRIX_INV = `!A:real^N^M.\n invertible A ==> A ** matrix_inv A = mat 1 /\\ matrix_inv A ** A = mat 1`;;\n\nlet MATRIX_INV_LEFT = `!A:real^N^N. matrix_inv A ** A = mat 1 <=> invertible A`;;\n\nlet MATRIX_INV_RIGHT = `!A:real^N^N. A ** matrix_inv A = mat 1 <=> invertible A`;;\n\nlet MATRIX_MUL_LCANCEL = `!A:real^M^N B:real^P^M C.\n invertible A ==> (A ** B = A ** C <=> B = C)`;;\n\nlet MATRIX_MUL_RCANCEL = `!A B:real^M^N C:real^P^M.\n invertible C ==> (A ** C = B ** C <=> A = B)`;;\n\nlet RANK_INVERTIBLE_RMUL = `!A:real^M^N B:real^P^M. invertible B ==> rank(A ** B) = rank A`;;\n\nlet RANK_INVERTIBLE_LMUL = `!A:real^M^N B:real^P^M. invertible A ==> rank(A ** B) = rank B`;;\n\nlet RANK_CMUL = `!A:real^N^M c. rank(c %% A) = if c = &0 then 0 else rank A`;;\n\nlet RANK_NEG = `!A:real^N^M. rank(--A) = rank A`;;\n\nlet MATRIX_INV_UNIQUE = `!A:real^N^M B. A ** B = mat 1 /\\ B ** A = mat 1 ==> matrix_inv A = B`;;\n\nlet MATRIX_INV_I = `matrix_inv(mat 1:real^N^N) = mat 1`;;\n\nlet INVERTIBLE_MATRIX_INV = `!A:real^M^N. invertible(matrix_inv A) <=> invertible A`;;\n\nlet MATRIX_INV_UNIQUE_LEFT = `!A:real^N^N B. A ** B = mat 1 ==> matrix_inv B = A`;;\n\nlet MATRIX_INV_UNIQUE_RIGHT = `!A:real^N^N B. A ** B = mat 1 ==> matrix_inv A = B`;;\n\nlet MATRIX_INV_COVARIANCE = `!A:real^M^N.\n matrix_inv(transp A ** A) = matrix_inv(A) ** transp(matrix_inv A)`;;\n\nlet COVARIANCE_MATRIX_INV = `!A:real^M^N.\n transp(matrix_inv A) ** matrix_inv A = matrix_inv(A ** transp A)`;;\n\nlet NORMAL_MATRIX_INV = `!A:real^N^N. normal_matrix(matrix_inv A) <=> normal_matrix A`;;\n\nlet MATRIX_INV_COVARIANCE_RMUL = `!A:real^M^N. matrix_inv(transp A ** A) ** transp A = matrix_inv A`;;\n\nlet MATRIX_INV_COVARIANCE_LMUL = `!A:real^M^N. transp(A) ** matrix_inv(A ** transp A) = matrix_inv A`;;\n\nlet RANK_SIMILAR = `!A:real^N^N U:real^M^N.\n invertible U ==> rank(matrix_inv U ** A ** U) = rank A`;;\n\nlet RANK_MATRIX_INV = `!A:real^M^N. rank(matrix_inv A) = rank A`;;\n\nlet RANK_MATRIX_INV_RMUL = `!A:real^M^N. rank(A ** matrix_inv A) = rank A`;;\n\nlet RANK_MATRIX_INV_LMUL = `!A:real^M^N. rank(matrix_inv A ** A) = rank A`;;\n\nlet MATRIX_INV_MULTIPLE_TRANP_RIGHT = `!A:real^M^N.\n matrix_inv A = matrix_inv A ** transp(matrix_inv A) ** transp A`;;\n\nlet MATRIX_TRANSP_MULTIPLE_INV_RIGHT = `!A:real^M^N. transp A = transp A ** A ** matrix_inv A`;;\n\nlet MATRIX_INV_MULTIPLE_TRANP_LEFT = `!A:real^M^N.\n matrix_inv A = transp A ** transp(matrix_inv A) ** matrix_inv A`;;\n\nlet MATRIX_TRANSP_MULTIPLE_INV_LEFT = `!A:real^M^N. transp A = matrix_inv A ** A ** transp A`;;\n\nlet MATRIX_VECTOR_MUL_INV_EQ_0 = `!A:real^M^N. matrix_inv A ** x = vec 0 <=> transp A ** x = vec 0`;;\n\nlet KERNEL_MATRIX_INV = `!A:real^M^N.\n {x | matrix_inv A ** x = vec 0} = {x | transp A ** x = vec 0}`;;\n\nlet IMAGE_MATRIX_INV = `!A:real^M^N.\n IMAGE (\\x:real^N. matrix_inv A ** x) UNIV =\n IMAGE (\\x. transp A ** x) UNIV`;;\n\nlet COMMUTING_MATRIX_INV_COVARIANCE = `!A:real^M^N.\n matrix_inv(transp A ** A) ** (transp A ** A) =\n (transp A ** A) ** matrix_inv(transp A ** A)`;;\n\nlet COMMUTING_MATRIX_INV_NORMAL = `!A:real^N^N.\n normal_matrix A ==> matrix_inv A ** A = A ** matrix_inv A`;;\n\nlet MATRIX_MUL_INV_EQ_0 = `!A:real^P^N B:real^N^M.\n matrix_inv A ** matrix_inv B = mat 0 <=> B ** A = mat 0`;;\n\nlet MATRIX_INV_IDEMPOTENT = `!A:real^N^N. symmetric_matrix A /\\ A ** A = A ==> matrix_inv A = A`;;\n\nlet IDEMPOTENT_MATRIX_MUL_LINV = `!A:real^N^M.\n (matrix_inv A ** A) ** (matrix_inv A ** A) = matrix_inv A ** A`;;\n\nlet IDEMPOTENT_MATRIX_MUL_RINV = `!A:real^N^M.\n (A ** matrix_inv A) ** (A ** matrix_inv A) = A ** matrix_inv A`;;\n\nlet MATRIX_INV_MUL_LINV = `!A:real^N^M. matrix_inv(matrix_inv A ** A) = matrix_inv A ** A`;;\n\nlet MATRIX_INV_MUL_RINV = `!A:real^N^M. matrix_inv(A ** matrix_inv A) = A ** matrix_inv A`;;\n\nlet infnorm = define\n `infnorm (x:real^N) = sup { abs(x$i) | 1 <= i /\\ i <= dimindex(:N) }`;;\n\nlet NUMSEG_DIMINDEX_NONEMPTY = `?i. i IN 1..dimindex(:N)`;;\n\nlet INFNORM_SET_IMAGE = `{abs(x$i) | 1 <= i /\\ i <= dimindex(:N)} =\n IMAGE (\\i. abs(x$i)) (1..dimindex(:N))`;;\n\nlet INFNORM_SET_LEMMA = `FINITE {abs((x:real^N)$i) | 1 <= i /\\ i <= dimindex(:N)} /\\\n ~({abs(x$i) | 1 <= i /\\ i <= dimindex(:N)} = {})`;;\n\nlet INFNORM_POS_LE = `!x. &0 <= infnorm x`;;\n\nlet INFNORM_TRIANGLE = `!x y. infnorm(x + y) <= infnorm x + infnorm y`;;\n\nlet INFNORM_EQ_0 = `!x. infnorm x = &0 <=> x = vec 0`;;\n\nlet INFNORM_0 = `infnorm(vec 0) = &0`;;\n\nlet INFNORM_NEG = `!x. infnorm(--x) = infnorm x`;;\n\nlet INFNORM_SUB = `!x y. infnorm(x - y) = infnorm(y - x)`;;\n\nlet REAL_ABS_SUB_INFNORM = `abs(infnorm x - infnorm y) <= infnorm(x - y)`;;\n\nlet REAL_ABS_INFNORM = `!x. abs(infnorm x) = infnorm x`;;\n\nlet COMPONENT_LE_INFNORM = `!x:real^N i. 1 <= i /\\ i <= dimindex (:N) ==> abs(x$i) <= infnorm x`;;\n\nlet INFNORM_MUL_LEMMA = `!a x. infnorm(a % x) <= abs a * infnorm x`;;\n\nlet INFNORM_MUL = `!a x:real^N. infnorm(a % x) = abs a * infnorm x`;;\n\nlet INFNORM_POS_LT = `!x. &0 < infnorm x <=> ~(x = vec 0)`;;\n\nlet INFNORM_LE_NORM = `!x. infnorm(x) <= norm(x)`;;\n\nlet NORM_LE_INFNORM = `!x:real^N. norm(x) <= sqrt(&(dimindex(:N))) * infnorm(x)`;;\n\nlet NORM_CAUCHY_SCHWARZ_EQ = `!x:real^N y. x dot y = norm(x) * norm(y) <=> norm(x) % y = norm(y) % x`;;\n\nlet NORM_CAUCHY_SCHWARZ_ABS_EQ = `!x:real^N y. abs(x dot y) = norm(x) * norm(y) <=>\n norm(x) % y = norm(y) % x \\/ norm(x) % y = --norm(y) % x`;;\n\nlet NORM_TRIANGLE_EQ = `!x y:real^N. norm(x + y) = norm(x) + norm(y) <=> norm(x) % y = norm(y) % x`;;\n\nlet DIST_TRIANGLE_EQ = `!x y z. dist(x,z) = dist(x,y) + dist(y,z) <=>\n norm (x - y) % (y - z) = norm (y - z) % (x - y)`;;\n\nlet NORM_CROSS_MULTIPLY = `!a b x y:real^N.\n a % x = b % y /\\ &0 < a /\\ &0 < b\n ==> norm y % x = norm x % y`;;\n\nlet collinear = new_definition\n `collinear s <=> ?u. !x y. x IN s /\\ y IN s ==> ?c. x - y = c % u`;;\n\nlet COLLINEAR_ALT2 = `!s:real^N->bool. collinear s <=> ?u v. !x. x IN s ==> ?c. x - u = c % v`;;\n\nlet COLLINEAR_ALT = `!s:real^N->bool. collinear s <=> ?u v. !x. x IN s ==> ?c. x = u + c % v`;;\n\nlet COLLINEAR_SUBSET = `!s t. collinear t /\\ s SUBSET t ==> collinear s`;;\n\nlet COLLINEAR_EMPTY = `collinear {}`;;\n\nlet COLLINEAR_SING = `!x. collinear {x}`;;\n\nlet COLLINEAR_2 = `!x y:real^N. collinear {x,y}`;;\n\nlet COLLINEAR_SMALL = `!s. FINITE s /\\ CARD s <= 2 ==> collinear s`;;\n\nlet COLLINEAR_3 = `!x y z. collinear {x,y,z} <=> collinear {vec 0,x - y,z - y}`;;\n\nlet COLLINEAR_LEMMA = `!x y:real^N. collinear {vec 0,x,y} <=>\n x = vec 0 \\/ y = vec 0 \\/ ?c. y = c % x`;;\n\nlet COLLINEAR_LEMMA_ALT = `!x y. collinear {vec 0,x,y} <=> x = vec 0 \\/ ?c. y = c % x`;;\n\nlet COLLINEAR_SPAN = `!a b:real^N. collinear{vec 0,a,b} <=> a = vec 0 \\/ b IN span {a}`;;\n\nlet NORM_CAUCHY_SCHWARZ_EQUAL = `!x y:real^N. abs(x dot y) = norm(x) * norm(y) <=> collinear {vec 0,x,y}`;;\n\nlet DOT_CAUCHY_SCHWARZ_EQUAL = `!x y:real^N.\n (x dot y) pow 2 = (x dot x) * (y dot y) <=>\n collinear {vec 0,x,y}`;;\n\nlet COLLINEAR_3_EXPAND = `!a b c:real^N. collinear{a,b,c} <=> a = c \\/ ?u. b = u % a + (&1 - u) % c`;;\n\nlet COLLINEAR_TRIPLES = `!s a b:real^N.\n ~(a = b)\n ==> (collinear(a INSERT b INSERT s) <=>\n !x. x IN s ==> collinear{a,b,x})`;;\n\nlet COLLINEAR_4_3 = `!a b c d:real^N.\n ~(a = b)\n ==> (collinear {a,b,c,d} <=> collinear{a,b,c} /\\ collinear{a,b,d})`;;\n\nlet COLLINEAR_3_TRANS = `!a b c d:real^N.\n collinear{a,b,c} /\\ collinear{b,c,d} /\\ ~(b = c) ==> collinear{a,b,d}`;;\n\nlet ORTHOGONAL_TO_ORTHOGONAL_2D = `!x y z:real^2.\n ~(x = vec 0) /\\ orthogonal x y /\\ orthogonal x z\n ==> collinear {vec 0,y,z}`;;\n\nlet COLLINEAR_3_2D = `!x y z:real^2. collinear{x,y,z} <=>\n (z$1 - x$1) * (y$2 - x$2) = (y$1 - x$1) * (z$2 - x$2)`;;\n\nlet COLLINEAR_3_DOT_MULTIPLES = `!a b c:real^N.\n collinear {a,b,c} <=>\n ((b - a) dot (b - a)) % (c - a) = ((c - a) dot (b - a)) % (b - a)`;;\n\nlet ORTHOGONAL_AND_COLLINEAR = `!x y:real^N.\n orthogonal x y /\\ collinear{vec 0,x,y} <=> x = vec 0 \\/ y = vec 0`;;\n\nlet between = new_definition\n `between x (a,b) <=> dist(a,b) = dist(a,x) + dist(x,b)`;;\n\nlet BETWEEN_REFL = `!a b. between a (a,b) /\\ between b (a,b) /\\ between a (a,a)`;;\n\nlet BETWEEN_REFL_EQ = `!a x. between x (a,a) <=> x = a`;;\n\nlet BETWEEN_SYM = `!a b x. between x (a,b) <=> between x (b,a)`;;\n\nlet BETWEEN_ANTISYM = `!a b c. between a (b,c) /\\ between b (a,c) ==> a = b`;;\n\nlet BETWEEN_TRANS = `!a b c d. between a (b,c) /\\ between d (a,c) ==> between d (b,c)`;;\n\nlet BETWEEN_TRANS_2 = `!a b c d. between a (b,c) /\\ between d (a,b) ==> between a (c,d)`;;\n\nlet BETWEEN_TRANSLATION = `!a x y. between (a + x) (a + y,a + z) <=> between x (y,z)`;;\n\nlet BETWEEN_NORM = `!a b x:real^N.\n between x (a,b) <=> norm(x - a) % (b - x) = norm(b - x) % (x - a)`;;\n\nlet BETWEEN_DOT = `!a b x:real^N.\n between x (a,b) <=> (x - a) dot (b - x) = norm(x - a) * norm(b - x)`;;\n\nlet BETWEEN_EXISTS_EXTENSION = `!a b x:real^N.\n between b (a,x) /\\ ~(b = a) ==> ?d. &0 <= d /\\ x = b + d % (b - a)`;;\n\nlet BETWEEN_IMP_COLLINEAR = `!a b x:real^N. between x (a,b) ==> collinear {a,x,b}`;;\n\nlet BETWEEN_CMUL_LIFT = `!a b c v:real^N.\n between (c % v) (a % v,b % v) <=>\n v = vec 0 \\/ between (lift c) (lift a,lift b)`;;\n\nlet BETWEEN_1 = `!a b x. between x (a,b) <=>\n drop a <= drop x /\\ drop x <= drop b \\/\n drop b <= drop x /\\ drop x <= drop a`;;\n\nlet COLLINEAR_BETWEEN_CASES = `!a b c:real^N.\n collinear {a,b,c} <=>\n between a (b,c) \\/ between b (c,a) \\/ between c (a,b)`;;\n\nlet COLLINEAR_BETWEEN_CASES_2 = `!a b c d:real^N.\n between c (a,b) /\\ between d (a,b)\n ==> between d (a,c) \\/ between d (c,b)`;;\n\nlet BETWEEN_RESTRICTED_CASES = `!a b c x:real^N.\n between x (a,b) /\\ between x (a,c) /\\ ~(x = a)\n ==> between b (a,c) \\/ between c (a,b)`;;\n\nlet COLLINEAR_DIST_BETWEEN = `!a b x. collinear {x,a,b} /\\\n dist(x,a) <= dist(a,b) /\\ dist(x,b) <= dist(a,b)\n ==> between x (a,b)`;;\n\nlet BETWEEN_COLLINEAR_DIST_EQ = `!a b x:real^N.\n between x (a,b) <=>\n collinear {a, x, b} /\\\n dist(x,a) <= dist(a,b) /\\ dist(x,b) <= dist(a,b)`;;\n\nlet COLLINEAR_1 = `!s:real^1->bool. collinear s`;;\n\nlet midpoint = new_definition\n `midpoint(a,b) = inv(&2) % (a + b)`;;\n\nlet MIDPOINT_REFL = `!x. midpoint(x,x) = x`;;\n\nlet MIDPOINT_SYM = `!a b. midpoint(a,b) = midpoint(b,a)`;;\n\nlet DIST_MIDPOINT = `!a b. dist(a,midpoint(a,b)) = dist(a,b) / &2 /\\\n dist(b,midpoint(a,b)) = dist(a,b) / &2 /\\\n dist(midpoint(a,b),a) = dist(a,b) / &2 /\\\n dist(midpoint(a,b),b) = dist(a,b) / &2`;;\n\nlet MIDPOINT_EQ_ENDPOINT = `!a b. (midpoint(a,b) = a <=> a = b) /\\\n (midpoint(a,b) = b <=> a = b) /\\\n (a = midpoint(a,b) <=> a = b) /\\\n (b = midpoint(a,b) <=> a = b)`;;\n\nlet BETWEEN_MIDPOINT = `!a b. between (midpoint(a,b)) (a,b) /\\ between (midpoint(a,b)) (b,a)`;;\n\nlet MIDPOINT_LINEAR_IMAGE = `!f a b. linear f ==> midpoint(f a,f b) = f(midpoint(a,b))`;;\n\nlet COLLINEAR_MIDPOINT = `!a b. collinear{a,midpoint(a,b),b}`;;\n\nlet MIDPOINT_COLLINEAR = `!a b c:real^N.\n ~(a = c)\n ==> (b = midpoint(a,c) <=> collinear{a,b,c} /\\ dist(a,b) = dist(b,c))`;;\n\nlet MIDPOINT_BETWEEN = `!a b c:real^N.\n b = midpoint (a,c) <=> between b (a,c) /\\ dist (a,b) = dist (b,c)`;;\n\nlet DROP_MIDPOINT = `!x y. drop(midpoint(x,y)) = (drop x + drop y) / &2`;;\n\nlet open_interval = new_definition\n `open_interval(a:real^N,b:real^N) =\n {x:real^N | !i. 1 <= i /\\ i <= dimindex(:N)\n ==> a$i < x$i /\\ x$i < b$i}`;;\n\nlet closed_interval = new_definition\n `closed_interval(l:(real^N#real^N)list) =\n {x:real^N | !i. 1 <= i /\\ i <= dimindex(:N)\n ==> FST(HD l)$i <= x$i /\\ x$i <= SND(HD l)$i}`;;\n\nmake_overloadable \"interval\" `:A`;;\n\noverload_interface(\"interval\",`open_interval`);;\noverload_interface(\"interval\",`closed_interval`);;\n\nlet interval = `(interval (a,b) = {x:real^N | !i. 1 <= i /\\ i <= dimindex(:N)\n ==> a$i < x$i /\\ x$i < b$i}) /\\\n (interval [a,b] = {x:real^N | !i. 1 <= i /\\ i <= dimindex(:N)\n ==> a$i <= x$i /\\ x$i <= b$i})`;;\n\nlet IN_INTERVAL = `(!x:real^N.\n x IN interval (a,b) <=>\n !i. 1 <= i /\\ i <= dimindex(:N)\n ==> a$i < x$i /\\ x$i < b$i) /\\\n (!x:real^N.\n x IN interval [a,b] <=>\n !i. 1 <= i /\\ i <= dimindex(:N)\n ==> a$i <= x$i /\\ x$i <= b$i)`;;\n\nlet IN_INTERVAL_REFLECT = `(!a b x. (--x) IN interval[--b,--a] <=> x IN interval[a,b]) /\\\n (!a b x. (--x) IN interval(--b,--a) <=> x IN interval(a,b))`;;\n\nlet REFLECT_INTERVAL = `(!a b:real^N. IMAGE (--) (interval[a,b]) = interval[--b,--a]) /\\\n (!a b:real^N. IMAGE (--) (interval(a,b)) = interval(--b,--a))`;;\n\nlet INTERVAL_EQ_EMPTY = `((interval [a:real^N,b] = {}) <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\ b$i < a$i) /\\\n ((interval (a:real^N,b) = {}) <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\ b$i <= a$i)`;;\n\nlet INTERVAL_NE_EMPTY = `(~(interval [a:real^N,b] = {}) <=>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= b$i) /\\\n (~(interval (a:real^N,b) = {}) <=>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> a$i < b$i)`;;\n\nlet SUBSET_INTERVAL_IMP = `((!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i)\n ==> interval[c,d] SUBSET interval[a:real^N,b]) /\\\n ((!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i < c$i /\\ d$i < b$i)\n ==> interval[c,d] SUBSET interval(a:real^N,b)) /\\\n ((!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i)\n ==> interval(c,d) SUBSET interval[a:real^N,b]) /\\\n ((!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i)\n ==> interval(c,d) SUBSET interval(a:real^N,b))`;;\n\nlet INTERVAL_SING = `interval[a,a] = {a} /\\ interval(a,a) = {}`;;\n\nlet SUBSET_INTERVAL = `(interval[c,d] SUBSET interval[a:real^N,b] <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> c$i <= d$i)\n ==> (!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i)) /\\\n (interval[c,d] SUBSET interval(a:real^N,b) <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> c$i <= d$i)\n ==> (!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i < c$i /\\ d$i < b$i)) /\\\n (interval(c,d) SUBSET interval[a:real^N,b] <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> c$i < d$i)\n ==> (!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i)) /\\\n (interval(c,d) SUBSET interval(a:real^N,b) <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> c$i < d$i)\n ==> (!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i))`;;\n\nlet DISJOINT_INTERVAL = `!a b c d:real^N.\n (interval[a,b] INTER interval[c,d] = {} <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\\n (b$i < a$i \\/ d$i < c$i \\/ b$i < c$i \\/ d$i < a$i)) /\\\n (interval[a,b] INTER interval(c,d) = {} <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\\n (b$i < a$i \\/ d$i <= c$i \\/ b$i <= c$i \\/ d$i <= a$i)) /\\\n (interval(a,b) INTER interval[c,d] = {} <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\\n (b$i <= a$i \\/ d$i < c$i \\/ b$i <= c$i \\/ d$i <= a$i)) /\\\n (interval(a,b) INTER interval(c,d) = {} <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\\n (b$i <= a$i \\/ d$i <= c$i \\/ b$i <= c$i \\/ d$i <= a$i))`;;\n\nlet ENDS_IN_INTERVAL = `(!a b. a IN interval[a,b] <=> ~(interval[a,b] = {})) /\\\n (!a b. b IN interval[a,b] <=> ~(interval[a,b] = {})) /\\\n (!a b. ~(a IN interval(a,b))) /\\\n (!a b. ~(b IN interval(a,b)))`;;\n\nlet ENDS_IN_UNIT_INTERVAL = `vec 0 IN interval[vec 0,vec 1] /\\\n vec 1 IN interval[vec 0,vec 1] /\\\n ~(vec 0 IN interval(vec 0,vec 1)) /\\\n ~(vec 1 IN interval(vec 0,vec 1))`;;\n\nlet INTER_INTERVAL = `interval[a,b] INTER interval[c,d] =\n interval[(lambda i. max (a$i) (c$i)),(lambda i. min (b$i) (d$i))]`;;\n\nlet INTERVAL_OPEN_SUBSET_CLOSED = `!a b. interval(a,b) SUBSET interval[a,b]`;;\n\nlet WLOG_LINEAR_INJECTIVE_IMAGE_2 = `!P Q. (!f s. P s /\\ linear f ==> Q(IMAGE f s)) /\\\n (!g t. Q t /\\ linear g ==> P(IMAGE g t))\n ==> !f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> !s. Q(IMAGE f s) <=> P s`;;\n\nlet WLOG_LINEAR_INJECTIVE_IMAGE_2_ALT = `!P Q f s. (!h u. P u /\\ linear h ==> Q(IMAGE h u)) /\\\n (!g t. Q t /\\ linear g ==> P(IMAGE g t)) /\\\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (Q(IMAGE f s) <=> P s)`;;\n\nlet WLOG_LINEAR_INJECTIVE_IMAGE = `!P. (!f s. P s /\\ linear f ==> P(IMAGE f s))\n ==> !f:real^N->real^N. linear f /\\ (!x y. f x = f y ==> x = y)\n ==> !s. P(IMAGE f s) <=> P s`;;\n\nlet WLOG_LINEAR_INJECTIVE_IMAGE_ALT = `!P f s. (!g t. P t /\\ linear g ==> P(IMAGE g t)) /\\\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (P(IMAGE f s) <=> P s)`;;\n\nlet LINEAR_INVARIANT_RULE th =\n let [f;s] = fst(strip_forall(concl th)) in\n let (rm,rn) = dest_fun_ty (type_of f) in\n let m = last(snd(dest_type rm)) and n = last(snd(dest_type rn)) in\n let th' = INST_TYPE [m,n; n,m] th in\n let th0 = CONJ th th' in\n let th1 = try MATCH_MP WLOG_LINEAR_INJECTIVE_IMAGE_2 th0\n with Failure _ ->\n MATCH_MP WLOG_LINEAR_INJECTIVE_IMAGE_2\n (GEN_REWRITE_RULE (BINOP_CONV o ONCE_DEPTH_CONV) [CONJ_SYM] th0) in\n GEN_REWRITE_RULE BINDER_CONV [RIGHT_IMP_FORALL_THM] th1;;\n\nlet SUBSPACE_LINEAR_IMAGE_EQ = `!f s. linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (subspace (IMAGE f s) <=> subspace s)`;;\n\nlet invariant_under_linear = ref([]:thm list);;\n\nlet invariant_under_translation = ref([]:thm list);;\n\nlet scaling_theorems = ref([]:thm list);;\n\nlet COUNTABLE_UNION_OF_BIJECTIVE_IMAGE = `!(f:A->B) P P'.\n (!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y) /\\\n (!s. P' (IMAGE f s) <=> P s)\n ==> (!s. (COUNTABLE UNION_OF P') (IMAGE f s) <=>\n (COUNTABLE UNION_OF P) s)`;;\n\nlet COUNTABLE_INTERSECTION_OF_BIJECTIVE_IMAGE = `!(f:A->B) P P'.\n (!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y) /\\\n (!s. P' (IMAGE f s) <=> P s)\n ==> (!s. (COUNTABLE INTERSECTION_OF P') (IMAGE f s) <=>\n (COUNTABLE INTERSECTION_OF P) s)`;;\n\nlet AFFINITY_SCALING_TRANSLATION = `!m c:real^N. (\\x. m % x + c) = (\\x. c + x) o (\\x. m % x)`;;\n\nlet LINEAR_SCALING = `!c. linear(\\x:real^N. c % x)`;;\n\nlet INJECTIVE_SCALING = `!c. (!x y:real^N. c % x = c % y ==> x = y) <=> ~(c = &0)`;;\n\nlet SURJECTIVE_SCALING = `!c. (!y:real^N. ?x. c % x = y) <=> ~(c = &0)`;;\n\nlet SCALING_INVARIANT =\n let pths = (CONJUNCTS o UNDISCH o prove)\n (`&0 < c\n ==> linear(\\x:real^N. c % x) /\\\n (!x y:real^N. c % x = c % y ==> x = y) /\\\n (!y:real^N. ?x. c % x = y)`,\n SIMP_TAC[REAL_LT_IMP_NZ; LINEAR_SCALING;\n INJECTIVE_SCALING; SURJECTIVE_SCALING])\n and sc_tm = `\\x:real^N. c % x`\n and sa_tm = `&0:real < c`\n and c_tm = `c:real` in\n fun th ->\n let ith = BETA_RULE(ISPEC sc_tm th) in\n let avs,bod = strip_forall(concl ith) in\n let cjs = conjuncts(lhand bod) in\n let cths = map (fun t -> find(fun th -> aconv (concl th) t) pths) cjs in\n let oth = MP (SPECL avs ith) (end_itlist CONJ cths) in\n GEN c_tm (DISCH sa_tm (GENL avs oth));;\n\nlet add_scaling_theorems thl =\n (scaling_theorems := (!scaling_theorems) @ thl);;\n\nlet add_linear_invariants thl =\n ignore(mapfilter (fun th -> add_scaling_theorems[SCALING_INVARIANT th]) thl);\n (invariant_under_linear := (!invariant_under_linear) @ thl);;\n\nlet add_translation_invariants thl =\n (invariant_under_translation := (!invariant_under_translation) @ thl);;\n\nlet th_sets = `!f. (!x y. f x = f y ==> x = y)\n ==> (if p then f x else f y) = f(if p then x else y) /\\\n (if p then IMAGE f s else IMAGE f t) =\n IMAGE f (if p then s else t) /\\\n (f x) INSERT (IMAGE f s) = IMAGE f (x INSERT s) /\\\n (IMAGE f s) DELETE (f x) = IMAGE f (s DELETE x) /\\\n (IMAGE f s) INTER (IMAGE f t) = IMAGE f (s INTER t) /\\\n (IMAGE f s) UNION (IMAGE f t) = IMAGE f (s UNION t) /\\\n UNIONS(IMAGE (IMAGE f) u) = IMAGE f (UNIONS u) /\\\n (IMAGE f s) DIFF (IMAGE f t) = IMAGE f (s DIFF t) /\\\n (IMAGE f s (f x) <=> s x) /\\\n ((f x) IN (IMAGE f s) <=> x IN s) /\\\n ((f o xs) (n:num) = f(xs n)) /\\\n ((f o pt) (tt:real^1) = f(pt tt)) /\\\n (IMAGE (f o g) k = IMAGE f (IMAGE g k)) /\\\n (DISJOINT (IMAGE f s) (IMAGE f t) <=> DISJOINT s t) /\\\n ((IMAGE f s) SUBSET (IMAGE f t) <=> s SUBSET t) /\\\n ((IMAGE f s) PSUBSET (IMAGE f t) <=> s PSUBSET t) /\\\n (IMAGE f s = IMAGE f t <=> s = t) /\\\n ((IMAGE f s) HAS_SIZE n <=> s HAS_SIZE n) /\\\n (FINITE(IMAGE f s) <=> FINITE s) /\\\n (INFINITE(IMAGE f s) <=> INFINITE s) /\\\n (COUNTABLE(IMAGE f s) <=> COUNTABLE s)`;;\n\nlet th_set = `!f:A->B s. (!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y)\n ==> INTERS (IMAGE (IMAGE f) s) = IMAGE f (INTERS s)`;;\n\nlet PRESERVES_NORM_PRESERVES_DOT = `!f:real^M->real^N x y.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> (f x) dot (f y) = x dot y`;;\n\nlet PRESEVES_NORM_PRESERVES_DIST = `!f:real^M->real^N.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> !x y. dist(f x,f y) = dist(x,y)`;;\n\nlet PRESERVES_NORM_INJECTIVE = `!f:real^M->real^N.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> !x y. f x = f y ==> x = y`;;\n\nlet ORTHOGONAL_LINEAR_IMAGE_EQ = `!f:real^M->real^N x y.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> (orthogonal (f x) (f y) <=> orthogonal x y)`;;\n\nlet NORMAL_MATRIX_IFF_SAME_NORM_TRANSP,NORMAL_MATRIX_IFF_SAME_DOT_TRANSP =\n (CONJ_PAIR o prove)\n (`(!A:real^N^N.\n normal_matrix A <=>\n !x. norm(transp A ** x) = norm(A ** x)) /\\\n (!A:real^N^N.\n normal_matrix A <=>\n !x y. (transp A ** x) dot (transp A ** y) = (A ** x) dot (A ** y))`,\n REWRITE_TAC[normal_matrix; AND_FORALL_THM] THEN GEN_TAC THEN MATCH_MP_TAC\n (TAUT `(q <=> r) /\\ (p <=> r) ==> (p <=> q) /\\ (p <=> r)`) THEN\n CONJ_TAC THENL\n [EQ_TAC THENL [ALL_TAC; SIMP_TAC[NORM_EQ]] THEN\n REPEAT STRIP_TAC THEN MATCH_MP_TAC SAME_NORM_SAME_DOT THEN\n ASM_REWRITE_TAC[MATRIX_VECTOR_MUL_LINEAR] THEN\n GEN_REWRITE_TAC RAND_CONV [GSYM ETA_AX] THEN\n REWRITE_TAC[MATRIX_VECTOR_MUL_LINEAR];\n REWRITE_TAC[DOT_MATRIX_TRANSP_RMUL] THEN\n GEN_REWRITE_TAC (RAND_CONV o funpow 2 BINDER_CONV o RAND_CONV)\n [GSYM DOT_MATRIX_TRANSP_LMUL] THEN\n ONCE_REWRITE_TAC[GSYM REAL_SUB_0] THEN REWRITE_TAC[GSYM DOT_LSUB] THEN\n REWRITE_TAC[FORALL_DOT_EQ_0; MATRIX_VECTOR_MUL_ASSOC] THEN\n REWRITE_TAC[GSYM MATRIX_EQ_0; GSYM MATRIX_VECTOR_MUL_SUB_RDISTRIB] THEN\n REWRITE_TAC[MATRIX_SUB_EQ] THEN MESON_TAC[]]);;\n\nlet NORMAL_MATRIX_KERNEL_TRANSP_EXPLICIT = `!A x:real^N.\n normal_matrix A\n ==> (transp A ** x = vec 0 <=> A ** x = vec 0)`;;\n\nlet NORMAL_MATRIX_KERNEL_TRANSP = `!A:real^N^N.\n normal_matrix A\n ==> {x | transp A ** x = vec 0} = {x | A ** x = vec 0}`;;\n\nadd_linear_invariants\n [GSYM LINEAR_ADD;\n GSYM LINEAR_CMUL;\n GSYM LINEAR_SUB;\n GSYM LINEAR_NEG;\n MIDPOINT_LINEAR_IMAGE;\n MESON[] `!f:real^M->real^N x.\n (!x. norm(f x) = norm x) ==> norm(f x) = norm x`;\n PRESERVES_NORM_PRESERVES_DOT;\n MESON[dist; LINEAR_SUB]\n `!f:real^M->real^N x y.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> dist(f x,f y) = dist(x,y)`;\n MESON[] `!f:real^M->real^N x y.\n (!x y. f x = f y ==> x = y) ==> (f x = f y <=> x = y)`;\n SUBSPACE_LINEAR_IMAGE_EQ;\n ORTHOGONAL_LINEAR_IMAGE_EQ;\n SPAN_LINEAR_IMAGE;\n DEPENDENT_LINEAR_IMAGE_EQ;\n INDEPENDENT_LINEAR_IMAGE_EQ;\n DIM_INJECTIVE_LINEAR_IMAGE];;\n\nadd_translation_invariants\n [VECTOR_ARITH `!a x y. a + x:real^N = a + y <=> x = y`;\n NORM_ARITH `!a x y. dist(a + x,a + y) = dist(x,y)`;\n VECTOR_ARITH `!a x y. &1 / &2 % ((a + x) + (a + y)) = a + &1 / &2 % (x + y)`;\n VECTOR_ARITH `!a x y. inv(&2) % ((a + x) + (a + y)) = a + inv(&2) % (x + y)`;\n VECTOR_ARITH `!a x y. (a + x) - (a + y):real^N = x - y`;\n (EQT_ELIM o (REWRITE_CONV[midpoint] THENC(EQT_INTRO o NORM_ARITH)))\n `!a x y. midpoint(a + x,a + y) = a + midpoint(x,y)`;\n (EQT_ELIM o (REWRITE_CONV[between] THENC(EQT_INTRO o NORM_ARITH)))\n `!a x y z. between (a + x) (a + y,a + z) <=> between x (y,z)`];;\n\nlet th = `!a s b c:real^N. (a + b) + c IN IMAGE (\\x. a + x) s <=> (b + c) IN s`;;\n\nadd_translation_invariants [MEM_TRANSLATION];;\n\nlet MEM_LINEAR_IMAGE = `!f:real^M->real^N x l.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (MEM (f x) (MAP f l) <=> MEM x l)`;;\n\nadd_linear_invariants [MEM_LINEAR_IMAGE];;\n\nlet LENGTH_TRANSLATION = `!a:real^N l. LENGTH(MAP (\\x. a + x) l) = LENGTH l`;;\n\nlet QUANTIFY_SURJECTION_HIGHER_THM = `!f:A->B.\n (!y. ?x. f x = y)\n ==> ((!P. (!x. P x) <=> (!x. P (f x))) /\\\n (!P. (?x. P x) <=> (?x. P (f x))) /\\\n (!Q. (!s. Q s) <=> (!s. Q(IMAGE f s))) /\\\n (!Q. (?s. Q s) <=> (?s. Q(IMAGE f s))) /\\\n (!Q. (!s. Q s) <=> (!s. Q(IMAGE (IMAGE f) s))) /\\\n (!Q. (?s. Q s) <=> (?s. Q(IMAGE (IMAGE f) s))) /\\\n (!P. (!g:real^1->B. P g) <=> (!g. P(f o g))) /\\\n (!P. (?g:real^1->B. P g) <=> (?g. P(f o g))) /\\\n (!P. (!g:num->B. P g) <=> (!g. P(f o g))) /\\\n (!P. (?g:num->B. P g) <=> (?g. P(f o g))) /\\\n (!Q. (!l. Q l) <=> (!l. Q(MAP f l))) /\\\n (!Q. (?l. Q l) <=> (?l. Q(MAP f l)))) /\\\n ((!P. {x | P x} = IMAGE f {x | P(f x)}) /\\\n (!Q. {s | Q s} = IMAGE (IMAGE f) {s | Q(IMAGE f s)}) /\\\n (!R. {l | R l} = IMAGE (MAP f) {l | R(MAP f l)}))`;;\n\nlet PARTIAL_EXPAND_QUANTS_CONV avoid th =\n let ath,sth = CONJ_PAIR th in\n let conv1 = GEN_REWRITE_CONV I [ath]\n and conv2 = GEN_REWRITE_CONV I [sth] in\n let conv1' tm =\n let th = conv1 tm in\n if mem (fst(dest_var(fst(dest_abs(rand tm))))) avoid\n then failwith \"Not going to expand this variable\" else th in\n let rec conv tm =\n ((conv1' THENC BINDER_CONV conv) ORELSEC\n (conv2 THENC\n RAND_CONV(RAND_CONV(ABS_CONV(BINDER_CONV(LAND_CONV conv))))) ORELSEC\n SUB_CONV conv) tm in\n conv;;\n\nlet EXPAND_QUANTS_CONV = PARTIAL_EXPAND_QUANTS_CONV [];;" }, { "theorem_id": 61, "title": "078_the_cauchy-schwarz_inequality", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Inner Product Spaces and Gradient Derivative\\\n\ntheory Inner_Product\nimports Complex_Main\nbegin\n\nsubsection \\Real inner product spaces\\\n\ntext \\\n Temporarily relax type constraints for \\<^term>\\open\\, \\<^term>\\uniformity\\,\n \\<^term>\\dist\\, and \\<^term>\\norm\\.\n\\\n\nsetup \\Sign.add_const_constraint\n (\\<^const_name>\\open\\, SOME \\<^typ>\\'a::open set \\ bool\\)\\\n\nsetup \\Sign.add_const_constraint\n (\\<^const_name>\\dist\\, SOME \\<^typ>\\'a::dist \\ 'a \\ real\\)\\\n\nsetup \\Sign.add_const_constraint\n (\\<^const_name>\\uniformity\\, SOME \\<^typ>\\('a::uniformity \\ 'a) filter\\)\\\n\nsetup \\Sign.add_const_constraint\n (\\<^const_name>\\norm\\, SOME \\<^typ>\\'a::norm \\ real\\)\\\n\nclass real_inner = real_vector + sgn_div_norm + dist_norm + uniformity_dist + open_uniformity +\n fixes inner :: \"'a \\ 'a \\ real\"\n assumes inner_commute: \"inner x y = inner y x\"\n and inner_add_left: \"inner (x + y) z = inner x z + inner y z\"\n and inner_scaleR_left [simp]: \"inner (scaleR r x) y = r * (inner x y)\"\n and inner_ge_zero [simp]: \"0 \\ inner x x\"\n and inner_eq_zero_iff [simp]: \"inner x x = 0 \\ x = 0\"\n and norm_eq_sqrt_inner: \"norm x = sqrt (inner x x)\"\nbegin\n\nlemma inner_zero_left [simp]: \"inner 0 x = 0\"\n by sorry\n\nlemma inner_minus_left [simp]: \"inner (- x) y = - inner x y\"\n by sorry\n\nlemma inner_diff_left: \"inner (x - y) z = inner x z - inner y z\"\n by sorry\n\nlemma inner_sum_left: \"inner (\\x\\A. f x) y = (\\x\\A. inner (f x) y)\"\n by sorry\n\nlemma all_zero_iff [simp]: \"(\\u. inner x u = 0) \\ (x = 0)\"\n by sorry\n\ntext \\Transfer distributivity rules to right argument.\\\n\nlemma inner_add_right: \"inner x (y + z) = inner x y + inner x z\"\n by sorry\n\nlemma inner_scaleR_right [simp]: \"inner x (scaleR r y) = r * (inner x y)\"\n by sorry\n\nlemma inner_zero_right [simp]: \"inner x 0 = 0\"\n by sorry\n\nlemma inner_minus_right [simp]: \"inner x (- y) = - inner x y\"\n by sorry\n\nlemma inner_diff_right: \"inner x (y - z) = inner x y - inner x z\"\n by sorry\n\nlemma inner_sum_right: \"inner x (\\y\\A. f y) = (\\y\\A. inner x (f y))\"\n by sorry\n\nlemmas inner_add [algebra_simps] = inner_add_left inner_add_right\nlemmas inner_diff [algebra_simps] = inner_diff_left inner_diff_right\nlemmas inner_scaleR = inner_scaleR_left inner_scaleR_right\n\ntext \\Legacy theorem names\\\nlemmas inner_left_distrib = inner_add_left\nlemmas inner_right_distrib = inner_add_right\nlemmas inner_distrib = inner_left_distrib inner_right_distrib\n\nlemma inner_gt_zero_iff [simp]: \"0 < inner x x \\ x \\ 0\"\n by sorry\n\nlemma power2_norm_eq_inner: \"(norm x)\\<^sup>2 = inner x x\"\n by sorry\n\nlemma dot_square_norm: \"inner x x = (norm x)\\<^sup>2\"\n by sorry\n\ntext \\Identities involving real multiplication and division.\\\n\nlemma inner_mult_left: \"inner (of_real m * a) b = m * (inner a b)\"\n by sorry\n\nlemma inner_mult_right: \"inner a (of_real m * b) = m * (inner a b)\"\n by sorry\n\nlemma inner_mult_left': \"inner (a * of_real m) b = m * (inner a b)\"\n by sorry\n\nlemma inner_mult_right': \"inner a (b * of_real m) = (inner a b) * m\"\n by sorry\n\nlemma Cauchy_Schwarz_ineq:\n \"(inner x y)\\<^sup>2 \\ inner x x * inner y y\"\n by sorry\n\nlemma Cauchy_Schwarz_ineq2:\n \"\\inner x y\\ \\ norm x * norm y\"\n by sorry\n\nlemma norm_cauchy_schwarz: \"inner x y \\ norm x * norm y\"\n by sorry\n\nsubclass real_normed_vector\nproof\n fix a :: real and x y :: 'a\n show \"norm x = 0 \\ x = 0\"\n unfolding norm_eq_sqrt_inner by simp\n show \"norm (x + y) \\ norm x + norm y\"\n proof (rule power2_le_imp_le)\n have \"inner x y \\ norm x * norm y\"\n by (rule norm_cauchy_schwarz)\n thus \"(norm (x + y))\\<^sup>2 \\ (norm x + norm y)\\<^sup>2\"\n unfolding power2_sum power2_norm_eq_inner\n by (simp add: inner_add inner_commute)\n show \"0 \\ norm x + norm y\"\n unfolding norm_eq_sqrt_inner by simp\n qed\n have \"sqrt (a\\<^sup>2 * inner x x) = \\a\\ * sqrt (inner x x)\"\n by (simp add: real_sqrt_mult)\n then show \"norm (a *\\<^sub>R x) = \\a\\ * norm x\"\n unfolding norm_eq_sqrt_inner\n by (simp add: power2_eq_square mult.assoc)\nqed\n\nend\n\nlemma square_bound_lemma:\n fixes x :: real\n shows \"x < (1 + x) * (1 + x)\"\n by sorry\n\nlemma square_continuous:\n fixes e :: real\n shows \"e > 0 \\ \\d. 0 < d \\ (\\y. \\y - x\\ < d \\ \\y * y - x * x\\ < e)\"\n by sorry\n\nlemma norm_le: \"norm x \\ norm y \\ inner x x \\ inner y y\"\n by sorry\n\nlemma norm_lt: \"norm x < norm y \\ inner x x < inner y y\"\n by sorry\n\nlemma norm_eq: \"norm x = norm y \\ inner x x = inner y y\"\n by sorry\n\nlemma norm_eq_1: \"norm x = 1 \\ inner x x = 1\"\n by sorry\n\nlemma inner_divide_left:\n fixes a :: \"'a :: {real_inner,real_div_algebra}\"\n shows \"inner (a / of_real m) b = (inner a b) / m\"\n by sorry\n\nlemma inner_divide_right:\n fixes a :: \"'a :: {real_inner,real_div_algebra}\"\n shows \"inner a (b / of_real m) = (inner a b) / m\"\n by sorry\n\ntext \\\n Re-enable constraints for \\<^term>\\open\\, \\<^term>\\uniformity\\,\n \\<^term>\\dist\\, and \\<^term>\\norm\\.\n\\\n\nsetup \\Sign.add_const_constraint\n (\\<^const_name>\\open\\, SOME \\<^typ>\\'a::topological_space set \\ bool\\)\\\n\nsetup \\Sign.add_const_constraint\n (\\<^const_name>\\uniformity\\, SOME \\<^typ>\\('a::uniform_space \\ 'a) filter\\)\\\n\nsetup \\Sign.add_const_constraint\n (\\<^const_name>\\dist\\, SOME \\<^typ>\\'a::metric_space \\ 'a \\ real\\)\\\n\nsetup \\Sign.add_const_constraint\n (\\<^const_name>\\norm\\, SOME \\<^typ>\\'a::real_normed_vector \\ real\\)\\\n\nlemma bounded_bilinear_inner:\n \"bounded_bilinear (inner::'a::real_inner \\ 'a \\ real)\"\n by sorry\n\nlemmas tendsto_inner [tendsto_intros] =\n bounded_bilinear.tendsto [OF bounded_bilinear_inner]\n\nlemmas isCont_inner [simp] =\n bounded_bilinear.isCont [OF bounded_bilinear_inner]\n\nlemmas has_derivative_inner [derivative_intros] =\n bounded_bilinear.FDERIV [OF bounded_bilinear_inner]\n\nlemmas bounded_linear_inner_left =\n bounded_bilinear.bounded_linear_left [OF bounded_bilinear_inner]\n\nlemmas bounded_linear_inner_right =\n bounded_bilinear.bounded_linear_right [OF bounded_bilinear_inner]\n\nlemmas bounded_linear_inner_left_comp = bounded_linear_inner_left[THEN bounded_linear_compose]\n\nlemmas bounded_linear_inner_right_comp = bounded_linear_inner_right[THEN bounded_linear_compose]\n\nlemmas has_derivative_inner_right [derivative_intros] =\n bounded_linear.has_derivative [OF bounded_linear_inner_right]\n\nlemmas has_derivative_inner_left [derivative_intros] =\n bounded_linear.has_derivative [OF bounded_linear_inner_left]\n\nlemma differentiable_inner [simp]:\n \"f differentiable (at x within s) \\ g differentiable at x within s \\ (\\x. inner (f x) (g x)) differentiable at x within s\"\n by sorry\n\nsubsection \\Class instances\\\n\ninstantiation real :: real_inner\nbegin\n\ndefinition inner_real_def [simp]: \"inner = " }, { "theorem_id": 61, "title": "078_the_cauchy-schwarz_inequality", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2019 Zhouhang Zhou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Zhouhang Zhou, Sébastien Gouëzel, Frédéric Dupuis\n-/\nmodule\n\npublic import Mathlib.Algebra.BigOperators.Field\npublic import Mathlib.Analysis.Complex.Basic\npublic import Mathlib.Analysis.InnerProductSpace.Defs\npublic import Mathlib.LinearAlgebra.SesquilinearForm.Basic\n\n/-!\n# Properties of inner product spaces\n\nThis file proves many basic properties of inner product spaces (real or complex).\n\n## Main results\n\n- `inner_mul_inner_self_le`: the Cauchy-Schwarz inequality (one of many variants).\n- `norm_inner_eq_norm_iff`: the equality criterion in the Cauchy-Schwarz inequality (also in many\n variants).\n- `inner_eq_sum_norm_sq_div_four`: the polarization identity.\n\n## Tags\n\ninner product space, Hilbert space, norm\n\n-/\n\n@[expose] public section\n\n\nnoncomputable section\n\nopen RCLike Real Filter Topology ComplexConjugate Finsupp\n\nopen LinearMap (BilinForm)\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜]\n\nsection BasicProperties_Seminormed\n\nopen scoped InnerProductSpace\n\nvariable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]\nvariable [SeminormedAddCommGroup F] [InnerProductSpace ℝ F]\n\nlocal notation \"⟪\" x \", \" y \"⟫\" => inner 𝕜 x y\n\nlocal postfix:90 \"†\" => starRingEnd _\n\nexport InnerProductSpace (norm_sq_eq_re_inner)\n\n@[simp]\ntheorem inner_conj_symm (x y : E) : ⟪y, x⟫† = ⟪x, y⟫ :=\n InnerProductSpace.conj_inner_symm _ _\n\ntheorem real_inner_comm (x y : F) : ⟪y, x⟫_ℝ = ⟪x, y⟫_ℝ :=\n @inner_conj_symm ℝ _ _ _ _ x y\n\ntheorem inner_eq_zero_symm {x y : E} : ⟪x, y⟫ = 0 ↔ ⟪y, x⟫ = 0 := by sorry\ninstance {ι : Sort*} (v : ι → E) : Std.Symm fun i j => ⟪v i, v j⟫ = 0 where\n symm _ _ := inner_eq_zero_symm.1\n\ntheorem inner_self_im (x : E) : im ⟪x, x⟫ = 0 := by sorry\ntheorem inner_add_left (x y z : E) : ⟪x + y, z⟫ = ⟪x, z⟫ + ⟪y, z⟫ :=\n InnerProductSpace.add_left _ _ _\n\ntheorem inner_add_right (x y z : E) : ⟪x, y + z⟫ = ⟪x, y⟫ + ⟪x, z⟫ := by sorry\ntheorem inner_re_symm (x y : E) : re ⟪x, y⟫ = re ⟪y, x⟫ := by rw [← inner_conj_symm, conj_re]\n\ntheorem inner_im_symm (x y : E) : im ⟪x, y⟫ = -im ⟪y, x⟫ := by rw [← inner_conj_symm, conj_im]\n\nsection Algebra\nvariable {𝕝 : Type*} [CommSemiring 𝕝] [StarRing 𝕝] [Algebra 𝕝 𝕜] [Module 𝕝 E]\n [IsScalarTower 𝕝 𝕜 E] [StarModule 𝕝 𝕜]\n\n/-- See `inner_smul_left` for the common special when `𝕜 = 𝕝`. -/\nlemma inner_smul_left_eq_star_smul (x y : E) (r : 𝕝) : ⟪r • x, y⟫ = r† • ⟪x, y⟫ := by sorry\nlemma inner_smul_left_eq_smul [TrivialStar 𝕝] (x y : E) (r : 𝕝) : ⟪r • x, y⟫ = r • ⟪x, y⟫ := by sorry\nlemma inner_smul_right_eq_smul (x y : E) (r : 𝕝) : ⟪x, r • y⟫ = r • ⟪x, y⟫ := by sorry\nend Algebra\n\n/-- See `inner_smul_left_eq_star_smul` for the case of a general algebra action. -/\ntheorem inner_smul_left (x y : E) (r : 𝕜) : ⟪r • x, y⟫ = r† * ⟪x, y⟫ :=\n inner_smul_left_eq_star_smul ..\n\ntheorem real_inner_smul_left (x y : F) (r : ℝ) : ⟪r • x, y⟫_ℝ = r * ⟪x, y⟫_ℝ :=\n inner_smul_left _ _ _\n\ntheorem inner_smul_real_left (x y : E) (r : ℝ) : ⟪(r : 𝕜) • x, y⟫ = r • ⟪x, y⟫ := by sorry\ntheorem inner_smul_right (x y : E) (r : 𝕜) : ⟪x, r • y⟫ = r * ⟪x, y⟫ :=\n inner_smul_right_eq_smul ..\n\ntheorem real_inner_smul_right (x y : F) (r : ℝ) : ⟪x, r • y⟫_ℝ = r * ⟪x, y⟫_ℝ :=\n inner_smul_right _ _ _\n\ntheorem inner_smul_real_right (x y : E) (r : ℝ) : ⟪x, (r : 𝕜) • y⟫ = r • ⟪x, y⟫ := by sorry\nvariable (𝕜)\n\n/-- The inner product as a sesquilinear map.\n\nNote that in the case `𝕜 = ℝ` this is a bilinear form. -/\ndef innerₛₗ : E →ₗ⋆[𝕜] E →ₗ[𝕜] 𝕜 :=\n LinearMap.mk₂'ₛₗ _ _ (fun v w => ⟪v, w⟫) inner_add_left (fun _ _ _ => inner_smul_left _ _ _)\n inner_add_right fun _ _ _ => inner_smul_right _ _ _\n\n@[simp]\ntheorem coe_innerₛₗ_apply (v : E) : ⇑(innerₛₗ 𝕜 v) = fun w => ⟪v, w⟫ :=\n rfl\n\n@[simp]\ntheorem innerₛₗ_apply_apply (v w : E) : innerₛₗ 𝕜 v w = ⟪v, w⟫ :=\n rfl\n\nvariable (F)\n/-- The inner product as a bilinear map in the real case. -/\ndef innerₗ : F →ₗ[ℝ] F →ₗ[ℝ] ℝ := innerₛₗ ℝ\n\n@[simp] lemma flip_innerₗ : (innerₗ F).flip = innerₗ F := by sorry\nvariable {F}\n\n@[simp] lemma innerₗ_apply_apply (v w : F) : innerₗ F v w = ⟪v, w⟫_ℝ := rfl\n\nvariable {𝕜}\n\n@[deprecated (since := \"2025-12-26\")] alias sesqFormOfInner := innerₛₗ\n@[deprecated (since := \"2025-12-26\")] noncomputable alias bilinFormOfRealInner := innerₗ\n\n/-- An inner product with a sum on the left. -/\ntheorem sum_inner {ι : Type*} (s : Finset ι) (f : ι → E) (x : E) :\n ⟪∑ i ∈ s, f i, x⟫ = ∑ i ∈ s, ⟪f i, x⟫ :=\n map_sum ((innerₛₗ 𝕜).flip x) _ _\n\n/-- An inner product with a sum on the right. -/\ntheorem inner_sum {ι : Type*} (s : Finset ι) (f : ι → E) (x : E) :\n ⟪x, ∑ i ∈ s, f i⟫ = ∑ i ∈ s, ⟪x, f i⟫ :=\n map_sum (innerₛₗ 𝕜 x) _ _\n\n/-- An inner product with a sum on the left, `Finsupp` version. -/\nprotected theorem Finsupp.sum_inner {ι : Type*} {M : Type*} [Zero M] (l : ι →₀ M)\n (v : ι → M → E) (x : E) : ⟪l.sum v, x⟫ = l.sum fun (i : ι) (a : M) ↦ ⟪v i a, x⟫ := by sorry\ntheorem inner_zero_left (x : E) : ⟪0, x⟫ = 0 := by sorry\ntheorem inner_re_zero_left (x : E) : re ⟪0, x⟫ = 0 := by sorry\ntheorem inner_zero_right (x : E) : ⟪x, 0⟫ = 0 := by sorry\ntheorem inner_re_zero_right (x : E) : re ⟪x, 0⟫ = 0 := by sorry\ntheorem inner_self_nonneg {x : E} : 0 ≤ re ⟪x, x⟫ :=\n PreInnerProductSpace.toCore.re_inner_nonneg x\n\ntheorem real_inner_self_nonneg {x : F} : 0 ≤ ⟪x, x⟫_ℝ :=\n @inner_self_nonneg ℝ F _ _ _ x\n\ntheorem inner_self_ofReal_re (x : E) : (re ⟪x, x⟫ : 𝕜) = ⟪x, x⟫ :=\n ((RCLike.is_real_TFAE (⟪x, x⟫ : 𝕜)).out 2 3).2 (inner_self_im (𝕜 := 𝕜) x)\n\n@[simp]\ntheorem inner_self_eq_norm_sq_to_K (x : E) : ⟪x, x⟫ = (‖x‖ : 𝕜) ^ 2 := by sorry\ntheorem inner_self_re_eq_norm (x : E) : re ⟪x, x⟫ = ‖⟪x, x⟫‖ := by sorry\ntheorem inner_self_ofReal_norm (x : E) : (‖⟪x, x⟫‖ : 𝕜) = ⟪x, x⟫ := by sorry\ntheorem real_inner_self_abs (x : F) : |⟪x, x⟫_ℝ| = ⟪x, x⟫_ℝ :=\n @inner_self_ofReal_norm ℝ F _ _ _ x\n\ntheorem norm_inner_symm (x y : E) : ‖⟪x, y⟫‖ = ‖⟪y, x⟫‖ := by rw [← inner_conj_symm, norm_conj]\n\n@[simp]\ntheorem inner_neg_left (x y : E) : ⟪-x, y⟫ = -⟪x, y⟫ := by sorry\ntheorem inner_neg_right (x y : E) : ⟪x, -y⟫ = -⟪x, y⟫ := by sorry\ntheorem inner_neg_neg (x y : E) : ⟪-x, -y⟫ = ⟪x, y⟫ := by simp\n\ntheorem inner_self_conj (x : E) : ⟪x, x⟫† = ⟪x, x⟫ := inner_conj_symm _ _\n\ntheorem inner_sub_left (x y z : E) : ⟪x - y, z⟫ = ⟪x, z⟫ - ⟪y, z⟫ := by sorry\ntheorem inner_sub_right (x y z : E) : ⟪x, y - z⟫ = ⟪x, y⟫ - ⟪x, z⟫ := by sorry\ntheorem inner_mul_symm_re_eq_norm (x y : E) : re (⟪x, y⟫ * ⟪y, x⟫) = ‖⟪x, y⟫ * ⟪y, x⟫‖ := by sorry\ntheorem inner_add_add_self (x y : E) : ⟪x + y, x + y⟫ = ⟪x, x⟫ + ⟪x, y⟫ + ⟪y, x⟫ + ⟪y, y⟫ := by sorry\ntheorem real_inner_add_add_self (x y : F) :\n ⟪x + y, x + y⟫_ℝ = ⟪x, x⟫_ℝ + 2 * ⟪x, y⟫_ℝ + ⟪y, y⟫_ℝ := by sorry\ntheorem inner_sub_sub_self (x y : E) : ⟪x - y, x - y⟫ = ⟪x, x⟫ - ⟪x, y⟫ - ⟪y, x⟫ + ⟪y, y⟫ := by sorry\ntheorem real_inner_sub_sub_self (x y : F) :\n ⟪x - y, x - y⟫_ℝ = ⟪x, x⟫_ℝ - 2 * ⟪x, y⟫_ℝ + ⟪y, y⟫_ℝ := by sorry\ntheorem parallelogram_law {x y : E} : ⟪x + y, x + y⟫ + ⟪x - y, x - y⟫ = 2 * (⟪x, x⟫ + ⟪y, y⟫) := by sorry\ntheorem inner_mul_inner_self_le (x y : E) : ‖⟪x, y⟫‖ * ‖⟪y, x⟫‖ ≤ re ⟪x, x⟫ * re ⟪y, y⟫ :=\n letI : PreInnerProductSpace.Core 𝕜 E := PreInnerProductSpace.toCore\n InnerProductSpace.Core.inner_mul_inner_self_le x y\n\n/-- Cauchy–Schwarz inequality for real inner products. -/\ntheorem real_inner_mul_inner_self_le (x y : F) : ⟪x, y⟫_ℝ * ⟪x, y⟫_ℝ ≤ ⟪x, x⟫_ℝ * ⟪y, y⟫_ℝ :=\n calc\n ⟪x, y⟫_ℝ * ⟪x, y⟫_ℝ ≤ ‖⟪x, y⟫_ℝ‖ * ‖⟪y, x⟫_ℝ‖ := by sorry\ntheorem inner_eq_ofReal_norm_sq_left_iff {v w : E} : ⟪v, w⟫_𝕜 = ‖v‖ ^ 2 ↔ ⟪v, v - w⟫_𝕜 = 0 := by sorry\ntheorem inner_eq_norm_sq_left_iff {v w : F} : ⟪v, w⟫_ℝ = ‖v‖ ^ 2 ↔ ⟪v, v - w⟫_ℝ = 0 :=\n inner_eq_ofReal_norm_sq_left_iff\n\ntheorem inner_eq_ofReal_norm_sq_right_iff {v w : E} : ⟪v, w⟫_𝕜 = ‖w‖ ^ 2 ↔ ⟪v - w, w⟫_𝕜 = 0 := by sorry\ntheorem inner_eq_norm_sq_right_iff {v w : F} : ⟪v, w⟫_ℝ = ‖w‖ ^ 2 ↔ ⟪v - w, w⟫_ℝ = 0 :=\n inner_eq_ofReal_norm_sq_right_iff\n\nend BasicProperties_Seminormed\n\nsection BasicProperties\n\nvariable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\nvariable [NormedAddCommGroup F] [InnerProductSpace ℝ F]\n\nlocal notation \"⟪\" x \", \" y \"⟫\" => inner 𝕜 x y\n\nexport InnerProductSpace (norm_sq_eq_re_inner)\n\ntheorem inner_self_eq_zero {x : E} : ⟪x, x⟫ = 0 ↔ x = 0 := by sorry\ntheorem inner_self_ne_zero {x : E} : ⟪x, x⟫ ≠ 0 ↔ x ≠ 0 :=\n inner_self_eq_zero.not\n\nvariable (𝕜)\n\ntheorem ext_inner_left {x y : E} (h : ∀ v, ⟪v, x⟫ = ⟪v, y⟫) : x = y := by sorry\ntheorem ext_iff_inner_left {x y : E} : x = y ↔ ∀ v, ⟪v, x⟫ = ⟪v, y⟫ :=\n ⟨fun h _ ↦ h ▸ rfl, ext_inner_left 𝕜⟩\n\ntheorem ext_inner_right {x y : E} (h : ∀ v, ⟪x, v⟫ = ⟪y, v⟫) : x = y := by sorry\ntheorem ext_iff_inner_right {x y : E} : x = y ↔ ∀ v, ⟪x, v⟫ = ⟪y, v⟫ :=\n ⟨fun h _ ↦ h ▸ rfl, ext_inner_right 𝕜⟩\n\nvariable {𝕜}\n\ntheorem re_inner_self_nonpos {x : E} : re ⟪x, x⟫ ≤ 0 ↔ x = 0 := by sorry\nlemma re_inner_self_pos {x : E} : 0 < re ⟪x, x⟫ ↔ x ≠ 0 := by sorry\nopen scoped InnerProductSpace in\ntheorem real_inner_self_nonpos {x : F} : ⟪x, x⟫_ℝ ≤ 0 ↔ x = 0 := re_inner_self_nonpos (𝕜 := ℝ)\n\nopen scoped InnerProductSpace in\ntheorem real_inner_self_pos {x : F} : 0 < ⟪x, x⟫_ℝ ↔ x ≠ 0 := re_inner_self_pos (𝕜 := ℝ)\n\n/-- A family of vectors is linearly independent if they are nonzero\nand orthogonal. -/\ntheorem linearIndependent_of_ne_zero_of_inner_eq_zero {ι : Type*} {v : ι → E} (hz : ∀ i, v i ≠ 0)\n (ho : Pairwise fun i j => ⟪v i, v j⟫ = 0) : LinearIndependent 𝕜 v := by sorry\nend BasicProperties\n\nsection Norm_Seminormed\n\nopen scoped InnerProductSpace\n\nvariable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]\nvariable [SeminormedAddCommGroup F] [InnerProductSpace ℝ F]\n\nlocal notation \"⟪\" x \", \" y \"⟫\" => inner 𝕜 x y\n\nlocal notation \"IK\" => @RCLike.I 𝕜 _\n\ntheorem norm_eq_sqrt_re_inner (x : E) : ‖x‖ = √(re ⟪x, x⟫) :=\n calc\n ‖x‖ = √(‖x‖ ^ 2) := (sqrt_sq (norm_nonneg _)).symm\n _ = √(re ⟪x, x⟫) := congr_arg _ (norm_sq_eq_re_inner _)\n\ntheorem norm_eq_sqrt_real_inner (x : F) : ‖x‖ = √⟪x, x⟫_ℝ :=\n @norm_eq_sqrt_re_inner ℝ _ _ _ _ x\n\ntheorem inner_self_eq_norm_mul_norm (x : E) : re ⟪x, x⟫ = ‖x‖ * ‖x‖ := by sorry\ntheorem inner_self_eq_norm_sq (x : E) : re ⟪x, x⟫ = ‖x‖ ^ 2 := by sorry\ntheorem real_inner_self_eq_norm_mul_norm (x : F) : ⟪x, x⟫_ℝ = ‖x‖ * ‖x‖ := by sorry\ntheorem real_inner_self_eq_norm_sq (x : F) : ⟪x, x⟫_ℝ = ‖x‖ ^ 2 := by sorry\ntheorem norm_add_sq (x y : E) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by sorry\ntheorem norm_add_sq_real (x y : F) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * ⟪x, y⟫_ℝ + ‖y‖ ^ 2 := by sorry\ntheorem norm_add_mul_self (x y : E) :\n ‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + 2 * re ⟪x, y⟫ + ‖y‖ * ‖y‖ := by sorry\ntheorem norm_add_mul_self_real (x y : F) :\n ‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + 2 * ⟪x, y⟫_ℝ + ‖y‖ * ‖y‖ := by sorry\ntheorem norm_sub_sq (x y : E) : ‖x - y‖ ^ 2 = ‖x‖ ^ 2 - 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by sorry\ntheorem norm_sub_sq_real (x y : F) : ‖x - y‖ ^ 2 = ‖x‖ ^ 2 - 2 * ⟪x, y⟫_ℝ + ‖y‖ ^ 2 :=\n @norm_sub_sq ℝ _ _ _ _ _ _\n\nalias norm_sub_pow_two_real := norm_sub_sq_real\n\n/-- Expand the square -/\ntheorem norm_sub_mul_self (x y : E) :\n ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ - 2 * re ⟪x, y⟫ + ‖y‖ * ‖y‖ := by sorry\ntheorem norm_sub_mul_self_real (x y : F) :\n ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ - 2 * ⟪x, y⟫_ℝ + ‖y‖ * ‖y‖ := by sorry\ntheorem norm_inner_le_norm (x y : E) : ‖⟪x, y⟫‖ ≤ ‖x‖ * ‖y‖ := by sorry\ntheorem nnnorm_inner_le_nnnorm (x y : E) : ‖⟪x, y⟫‖₊ ≤ ‖x‖₊ * ‖y‖₊ :=\n norm_inner_le_norm x y\n\ntheorem re_inner_le_norm (x y : E) : re ⟪x, y⟫ ≤ ‖x‖ * ‖y‖ :=\n le_trans (re_le_norm ⟪x, y⟫) (norm_inner_le_norm x y)\n\n/-- Cauchy–Schwarz inequality with norm -/\ntheorem abs_real_inner_le_norm (x y : F) : |⟪x, y⟫_ℝ| ≤ ‖x‖ * ‖y‖ :=\n (Real.norm_eq_abs _).ge.trans (norm_inner_le_norm x y)\n\n/-- Cauchy–Schwarz inequality with norm -/\ntheorem real_inner_le_norm (x y : F) : ⟪x, y⟫_ℝ ≤ ‖x‖ * ‖y‖ :=\n le_trans (le_abs_self _) (abs_real_inner_le_norm _ _)\n\nlemma inner_eq_zero_of_left {x : E} (y : E) (h : ‖x‖ = 0) : ⟪x, y⟫_𝕜 = 0 := by sorry\nlemma inner_eq_zero_of_right (x : E) {y : E} (h : ‖y‖ = 0) : ⟪x, y⟫_𝕜 = 0 := by sorry\nvariable (𝕜)\n\ninclude 𝕜 in\ntheorem parallelogram_law_with_norm_mul (x y : E) :\n ‖x + y‖ * ‖x + y‖ + ‖x - y‖ * ‖x - y‖ = 2 * (‖x‖ * ‖x‖ + ‖y‖ * ‖y‖) := by sorry\ntheorem parallelogram_law_with_norm (x y : E) :\n ‖x + y‖ ^ 2 + ‖x - y‖ ^ 2 = 2 * (‖x‖ ^ 2 + ‖y‖ ^ 2) := by sorry\ntheorem parallelogram_law_with_nnnorm_mul (x y : E) :\n ‖x + y‖₊ * ‖x + y‖₊ + ‖x - y‖₊ * ‖x - y‖₊ = 2 * (‖x‖₊ * ‖x‖₊ + ‖y‖₊ * ‖y‖₊) :=\n Subtype.ext <| parallelogram_law_with_norm_mul 𝕜 x y\n\ninclude 𝕜 in\ntheorem parallelogram_law_with_nnnorm (x y : E) :\n ‖x + y‖₊ ^ 2 + ‖x - y‖₊ ^ 2 = 2 * (‖x‖₊ ^ 2 + ‖y‖₊ ^ 2) := by sorry\nvariable {𝕜}\n\n/-- Polarization identity: The real part of the inner product, in terms of the norm. -/\ntheorem re_inner_eq_norm_add_mul_self_sub_norm_mul_self_sub_norm_mul_self_div_two (x y : E) :\n re ⟪x, y⟫ = (‖x + y‖ * ‖x + y‖ - ‖x‖ * ‖x‖ - ‖y‖ * ‖y‖) / 2 := by sorry\ntheorem re_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two (x y : E) :\n re ⟪x, y⟫ = (‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ - ‖x - y‖ * ‖x - y‖) / 2 := by sorry\ntheorem re_inner_eq_norm_add_mul_self_sub_norm_sub_mul_self_div_four (x y : E) :\n re ⟪x, y⟫ = (‖x + y‖ * ‖x + y‖ - ‖x - y‖ * ‖x - y‖) / 4 := by sorry\ntheorem im_inner_eq_norm_sub_i_smul_mul_self_sub_norm_add_i_smul_mul_self_div_four (x y : E) :\n im ⟪x, y⟫ = (‖x - IK • y‖ * ‖x - IK • y‖ - ‖x + IK • y‖ * ‖x + IK • y‖) / 4 := by sorry\ntheorem inner_eq_sum_norm_sq_div_four (x y : E) :\n ⟪x, y⟫ = ((‖x + y‖ : 𝕜) ^ 2 - (‖x - y‖ : 𝕜) ^ 2 +\n ((‖x - IK • y‖ : 𝕜) ^ 2 - (‖x + IK • y‖ : 𝕜) ^ 2) * IK) / 4 := by sorry\ntheorem real_inner_eq_norm_add_mul_self_sub_norm_mul_self_sub_norm_mul_self_div_two (x y : F) :\n ⟪x, y⟫_ℝ = (‖x + y‖ * ‖x + y‖ - ‖x‖ * ‖x‖ - ‖y‖ * ‖y‖) / 2 :=\n re_to_real.symm.trans <|\n re_inner_eq_norm_add_mul_self_sub_norm_mul_self_sub_norm_mul_self_div_two x y\n\n/-- Polarization identity: The real inner product, in terms of the norm. -/\ntheorem real_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two (x y : F) :\n ⟪x, y⟫_ℝ = (‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ - ‖x - y‖ * ‖x - y‖) / 2 :=\n re_to_real.symm.trans <|\n re_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two x y\n\n/-- Pythagorean theorem, if-and-only-if vector inner product form. -/\ntheorem norm_add_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero (x y : F) :\n ‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ ⟪x, y⟫_ℝ = 0 := by sorry\ntheorem norm_add_eq_sqrt_iff_real_inner_eq_zero {x y : F} :\n ‖x + y‖ = √(‖x‖ * ‖x‖ + ‖y‖ * ‖y‖) ↔ ⟪x, y⟫_ℝ = 0 := by sorry\ntheorem norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero (x y : E) (h : ⟪x, y⟫ = 0) :\n ‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ := by sorry\ntheorem norm_add_sq_eq_norm_sq_add_norm_sq_real {x y : F} (h : ⟪x, y⟫_ℝ = 0) :\n ‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ :=\n (norm_add_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero x y).2 h\n\n/-- Pythagorean theorem, subtracting vectors, if-and-only-if vector\ninner product form. -/\ntheorem norm_sub_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero (x y : F) :\n ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ ⟪x, y⟫_ℝ = 0 := by sorry\ntheorem norm_sub_eq_sqrt_iff_real_inner_eq_zero {x y : F} :\n ‖x - y‖ = √(‖x‖ * ‖x‖ + ‖y‖ * ‖y‖) ↔ ⟪x, y⟫_ℝ = 0 := by sorry\ntheorem norm_sub_sq_eq_norm_sq_add_norm_sq_real {x y : F} (h : ⟪x, y⟫_ℝ = 0) :\n ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ :=\n (norm_sub_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero x y).2 h\n\n/-- The sum and difference of two vectors are orthogonal if and only\nif they have the same norm. -/\ntheorem real_inner_add_sub_eq_zero_iff (x y : F) : ⟪x + y, x - y⟫_ℝ = 0 ↔ ‖x‖ = ‖y‖ := by sorry\ntheorem norm_sub_eq_norm_add {v w : E} (h : ⟪v, w⟫ = 0) : ‖w - v‖ = ‖w + v‖ := by sorry\ntheorem abs_real_inner_div_norm_mul_norm_le_one (x y : F) : |⟪x, y⟫_ℝ / (‖x‖ * ‖y‖)| ≤ 1 := by sorry\ntheorem real_inner_smul_self_left (x : F) (r : ℝ) : ⟪r • x, x⟫_ℝ = r * (‖x‖ * ‖x‖) := by sorry\ntheorem real_inner_smul_self_right (x : F) (r : ℝ) : ⟪x, r • x⟫_ℝ = r * (‖x‖ * ‖x‖) := by sorry\ntheorem inner_sum_smul_sum_smul_of_sum_eq_zero {ι₁ : Type*} {s₁ : Finset ι₁} {w₁ : ι₁ → ℝ}\n (v₁ : ι₁ → F) (h₁ : ∑ i ∈ s₁, w₁ i = 0) {ι₂ : Type*} {s₂ : Finset ι₂} {w₂ : ι₂ → ℝ}\n (v₂ : ι₂ → F) (h₂ : ∑ i ∈ s₂, w₂ i = 0) :\n ⟪∑ i₁ ∈ s₁, w₁ i₁ • v₁ i₁, ∑ i₂ ∈ s₂, w₂ i₂ • v₂ i₂⟫_ℝ =\n (-∑ i₁ ∈ s₁, ∑ i₂ ∈ s₂, w₁ i₁ * w₂ i₂ * (‖v₁ i₁ - v₂ i₂‖ * ‖v₁ i₁ - v₂ i₂‖)) / 2 := by sorry\nend Norm_Seminormed\n\nsection Norm\n\nopen scoped InnerProductSpace\n\nvariable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\nvariable [NormedAddCommGroup F] [InnerProductSpace ℝ F]\nvariable {ι : Type*}\n\nlocal notation \"⟪\" x \", \" y \"⟫\" => inner 𝕜 x y\n\n/-- Formula for the distance between the images of two nonzero points under an inversion with center\nzero. See also `EuclideanGeometry.dist_inversion_inversion` for inversions around a general\npoint. -/\ntheorem dist_div_norm_sq_smul {x y : F} (hx : x ≠ 0) (hy : y ≠ 0) (R : ℝ) :\n dist ((R / ‖x‖) ^ 2 • x) ((R / ‖y‖) ^ 2 • y) = R ^ 2 / (‖x‖ * ‖y‖) * dist x y :=\n calc\n dist ((R / ‖x‖) ^ 2 • x) ((R / ‖y‖) ^ 2 • y) =\n √(‖(R / ‖x‖) ^ 2 • x - (R / ‖y‖) ^ 2 • y‖ ^ 2) := by sorry\ntheorem norm_inner_div_norm_mul_norm_eq_one_of_ne_zero_of_ne_zero_mul {x : E} {r : 𝕜} (hx : x ≠ 0)\n (hr : r ≠ 0) : ‖⟪x, r • x⟫‖ / (‖x‖ * ‖r • x‖) = 1 := by sorry\ntheorem abs_real_inner_div_norm_mul_norm_eq_one_of_ne_zero_of_ne_zero_mul {x : F} {r : ℝ}\n (hx : x ≠ 0) (hr : r ≠ 0) : |⟪x, r • x⟫_ℝ| / (‖x‖ * ‖r • x‖) = 1 :=\n norm_inner_div_norm_mul_norm_eq_one_of_ne_zero_of_ne_zero_mul hx hr\n\n/-- The inner product of a nonzero vector with a positive multiple of\nitself, divided by the product of their norms, has value 1. -/\ntheorem real_inner_div_norm_mul_norm_eq_one_of_ne_zero_of_pos_mul {x : F} {r : ℝ} (hx : x ≠ 0)\n (hr : 0 < r) : ⟪x, r • x⟫_ℝ / (‖x‖ * ‖r • x‖) = 1 := by sorry\ntheorem real_inner_div_norm_mul_norm_eq_neg_one_of_ne_zero_of_neg_mul {x : F} {r : ℝ} (hx : x ≠ 0)\n (hr : r < 0) : ⟪x, r • x⟫_ℝ / (‖x‖ * ‖r • x‖) = -1 := by sorry\nvariable (𝕜) in\ntheorem norm_inner_eq_norm_tfae (x y : E) :\n List.TFAE [‖⟪x, y⟫‖ = ‖x‖ * ‖y‖,\n x = 0 ∨ y = (⟪x, y⟫ / ⟪x, x⟫) • x,\n x = 0 ∨ ∃ r : 𝕜, y = r • x,\n x = 0 ∨ y ∈ 𝕜 ∙ x] := by sorry\ntheorem norm_inner_eq_norm_iff {x y : E} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :\n ‖⟪x, y⟫‖ = ‖x‖ * ‖y‖ ↔ ∃ r : 𝕜, r ≠ 0 ∧ y = r • x :=\n calc\n ‖⟪x, y⟫‖ = ‖x‖ * ‖y‖ ↔ x = 0 ∨ ∃ r : 𝕜, y = r • x :=\n (norm_inner_eq_norm_tfae 𝕜 x y).out 0 2\n _ ↔ ∃ r : 𝕜, y = r • x := or_iff_right hx₀\n _ ↔ ∃ r : 𝕜, r ≠ 0 ∧ y = r • x :=\n ⟨fun ⟨r, h⟩ => ⟨r, fun hr₀ => hy₀ <| h.symm ▸ smul_eq_zero.2 <| Or.inl hr₀, h⟩,\n fun ⟨r, _hr₀, h⟩ => ⟨r, h⟩⟩\n\n/-- The inner product of two vectors, divided by the product of their\nnorms, has absolute value 1 if and only if they are nonzero and one is\na multiple of the other. One form of equality case for Cauchy-Schwarz. -/\ntheorem norm_inner_div_norm_mul_norm_eq_one_iff (x y : E) :\n ‖⟪x, y⟫ / (‖x‖ * ‖y‖)‖ = 1 ↔ x ≠ 0 ∧ ∃ r : 𝕜, r ≠ 0 ∧ y = r • x := by sorry\ntheorem abs_real_inner_div_norm_mul_norm_eq_one_iff (x y : F) : := by sorry\ntheorem inner_eq_norm_mul_iff_div {x y : E} (h₀ : x ≠ 0) :\n ⟪x, y⟫ = (‖x‖ : 𝕜) * ‖y‖ ↔ (‖y‖ / ‖x‖ : 𝕜) • x = y := by sorry\ntheorem inner_eq_norm_mul_iff {x y : E} :\n ⟪x, y⟫ = (‖x‖ : 𝕜) * ‖y‖ ↔ (‖y‖ : 𝕜) • x = (‖x‖ : 𝕜) • y := by sorry\ntheorem inner_eq_norm_mul_iff_real {x y : F} : ⟪x, y⟫_ℝ = ‖x‖ * ‖y‖ ↔ ‖y‖ • x = ‖x‖ • y :=\n inner_eq_norm_mul_iff\n\n/-- The inner product of two vectors, divided by the product of their\nnorms, has value 1 if and only if they are nonzero and one is\na positive multiple of the other. -/\ntheorem real_inner_div_norm_mul_norm_eq_one_iff (x y : F) :\n ⟪x, y⟫_ℝ / (‖x‖ * ‖y‖) = 1 ↔ x ≠ 0 ∧ ∃ r : ℝ, 0 < r ∧ y = r • x := by sorry\ntheorem real_inner_div_norm_mul_norm_eq_neg_one_iff (x y : F) :\n ⟪x, y⟫_ℝ / (‖x‖ * ‖y‖) = -1 ↔ x ≠ 0 ∧ ∃ r : ℝ, r < 0 ∧ y = r • x := by sorry\ntheorem inner_eq_one_iff_of_norm_eq_one {x y : E} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) :\n ⟪x, y⟫ = 1 ↔ x = y := by sorry\ntheorem inner_eq_neg_one_iff_of_norm_eq_one {x y : E} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) :\n ⟪x, y⟫ = -1 ↔ x = -y := by sorry\ntheorem real_inner_le_one_of_norm_eq_one {x y : F} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) :\n ⟪x, y⟫_ℝ ≤ 1 := by sorry\ntheorem neg_one_le_real_inner_of_norm_eq_one {x y : F} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) :\n -1 ≤ ⟪x, y⟫_ℝ := by sorry\ntheorem real_inner_mem_Icc_of_norm_eq_one {x y : F} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) :\n ⟪x, y⟫_ℝ ∈ Set.Icc (-1) 1 :=\n ⟨neg_one_le_real_inner_of_norm_eq_one hx hy, real_inner_le_one_of_norm_eq_one hx hy⟩\n\ntheorem inner_self_eq_one_of_norm_eq_one {x : E} (hx : ‖x‖ = 1) : ⟪x, x⟫_𝕜 = 1 :=\n (inner_eq_one_iff_of_norm_eq_one hx hx).mpr rfl\n\ntheorem inner_lt_norm_mul_iff_real {x y : F} : ⟪x, y⟫_ℝ < ‖x‖ * ‖y‖ ↔ ‖y‖ • x ≠ ‖x‖ • y :=\n calc\n ⟪x, y⟫_ℝ < ‖x‖ * ‖y‖ ↔ ⟪x, y⟫_ℝ ≠ ‖x‖ * ‖y‖ :=\n ⟨ne_of_lt, lt_of_le_of_ne (real_inner_le_norm _ _)⟩\n _ ↔ ‖y‖ • x ≠ ‖x‖ • y := not_congr inner_eq_norm_mul_iff_real\n\n/-- If the inner product of two unit vectors is strictly less than `1`, then the two vectors are\ndistinct. One form of the equality case for Cauchy-Schwarz. -/\ntheorem inner_lt_one_iff_real_of_norm_eq_one {x y : F} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) :\n ⟪x, y⟫_ℝ < 1 ↔ x ≠ y := by convert inner_lt_norm_mul_iff_real (F := F) <;> simp [hx, hy]\n\n@[deprecated (since := \"2025-11-15\")] alias inner_eq_one_iff_of_norm_one :=\n inner_eq_one_iff_of_norm_eq_one\n@[deprecated (since := \"2025-11-15\")] alias inner_self_eq_one_of_norm_one :=\n inner_self_eq_one_of_norm_eq_one\n@[deprecated (since := \"2025-11-15\")] alias inner_lt_one_iff_real_of_norm_one :=\n inner_lt_one_iff_real_of_norm_eq_one\n\n/-- The sphere of radius `r = ‖y‖` is tangent to the plane `⟪x, y⟫ = ‖y‖ ^ 2` at `x = y`. -/\ntheorem eq_of_norm_le_re_inner_eq_norm_sq {x y : E} (hle : ‖x‖ ≤ ‖y‖) (h : re ⟪x, y⟫ = ‖y‖ ^ 2) :\n x = y := by sorry\ntheorem norm_add_eq_iff_real {x y : F} : ‖x + y‖ = ‖x‖ + ‖y‖ ↔ ‖y‖ • x = ‖x‖ • y := by sorry\nend Norm\n\nsection RCLike\n\nlocal notation \"⟪\" x \", \" y \"⟫\" => inner 𝕜 x y\n\n/-- A field `𝕜` satisfying `RCLike` is itself a `𝕜`-inner product space. -/\ninstance RCLike.innerProductSpace : InnerProductSpace 𝕜 𝕜 where\n inner x y := y * conj x\n norm_sq_eq_re_inner x := by simp only [mul_conj, ← ofReal_pow, ofReal_re]\n conj_inner_symm x y := by simp only [mul_comm, map_mul, starRingEnd_self_apply]\n add_left x y z := by simp only [mul_add, map_add]\n smul_left x y z := by simp only [mul_comm (conj z), mul_assoc, smul_eq_mul, map_mul]\n\n@[simp]\ntheorem RCLike.inner_apply (x y : 𝕜) : ⟪x, y⟫ = y * conj x :=\n rfl\n\n/-- A version of `RCLike.inner_apply` that swaps the order of multiplication. -/\ntheorem RCLike.inner_apply' (x y : 𝕜) : ⟪x, y⟫ = conj x * y := mul_comm _ _\n\nend RCLike\n\nsection RCLikeToReal\n\nopen scoped InnerProductSpace\n\nvariable {G : Type*}\nvariable (𝕜 E)\nvariable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n\nlocal notation \"⟪\" x \", \" y \"⟫\" => inner 𝕜 x y\n\n/-- A general inner product implies a real inner product. This is not registered as an instance\nsince `𝕜` does not appear in the return type `Inner ℝ E`. -/\n@[implicit_reducible]\ndef Inner.rclikeToReal : Inner ℝ E where inner x y := re ⟪x, y⟫\n\n/-- A general inner product space structure implies a real inner product structure.\n\nThis is not registered as an instance since\n* `𝕜` does not appear in the return type `InnerProductSpace ℝ E`,\n* It is likely to create instance diamonds, as it builds upon the diamond-prone\n `NormedSpace.restrictScalars`.\n\nHowever, it can be used in a proof to obtain a real inner product space structure from a given\n`𝕜`-inner product space structure. -/\n-- See note [reducible non-instances]\nabbrev InnerProductSpace.rclikeToReal : InnerProductSpace ℝ E :=\n { Inner.rclikeToReal 𝕜 E,\n NormedSpace.restrictScalars ℝ 𝕜 E with\n norm_sq_eq_re_inner := norm_sq_eq_re_inner\n conj_inner_symm := fun _ _ => inner_re_symm _ _\n add_left := fun x y z => by\n simp +instances only [Inner.rclikeToReal, inner_add_left, map_add]\n smul_left := fun x y r => by\n letI := NormedSpace.restrictScalars ℝ 𝕜 E\n have : r • x = (r : 𝕜) • x := rfl\n simp +instances only [Inner.rclikeToReal, this, conj_trivial, inner_smul_left, conj_ofReal,\n re_ofReal_mul] }\n\nvariable {E}\n\ntheorem real_inner_eq_re_inner (x y : E) :\n (Inner.rclikeToReal 𝕜 E).inner x y = re ⟪x, y⟫ :=\n rfl\n\ntheorem real_inner_I_smul_self (x : E) :\n (Inner.rclikeToReal 𝕜 E).inner x ((I : 𝕜) • x) = 0 := by sorry\ndef InnerProductSpace.complexToReal [SeminormedAddCommGroup G] [InnerProductSpace ℂ G] :\n InnerProductSpace ℝ G :=\n InnerProductSpace.rclikeToReal ℂ G\n\ninstance : InnerProductSpace ℝ ℂ := InnerProductSpace.complexToReal\n\n@[simp]\nprotected theorem Complex.inner (w z : ℂ) : ⟪w, z⟫_ℝ = (z * conj w).re :=\n rfl\n\nend RCLikeToReal\n\n/-- An `RCLike` field is a real inner product space. -/\nnoncomputable instance RCLike.toInnerProductSpaceReal : InnerProductSpace ℝ 𝕜 where\n __ := Inner.rclikeToReal 𝕜 𝕜\n norm_sq_eq_re_inner := norm_sq_eq_re_inner\n conj_inner_symm x y := inner_re_symm ..\n add_left x y z :=\n show re (_ * _) = re (_ * _) + re (_ * _) by simp only [map_add, mul_re, conj_re, conj_im]; ring\n smul_left x y r :=\n show re (_ * _) = _ * re (_ * _) by\n simp only [mul_re, conj_re, conj_im, conj_trivial, smul_re, smul_im]; ring\n\n-- The instance above does not create diamonds for concrete `𝕜`:\nexample : (innerProductSpace : InnerProductSpace ℝ ℝ) = RCLike.toInnerProductSpaceReal := rfl\nexample :\n (instInnerProductSpaceRealComplex : InnerProductSpace ℝ ℂ) = RCLike.toInnerProductSpaceReal :=\n rfl\n\nsection IsPosSemidef\n\nvariable [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n\nlemma isSymm_inner : LinearMap.IsSymm (innerₗ E) where\n eq x y := by simp [real_inner_comm]\n\nlemma isNonneg_inner : LinearMap.IsNonneg (innerₗ E) where\n nonneg x := by simp\n\nlemma isPosSemidef_inner : LinearMap.IsPosSemidef (innerₗ E) where\n isSymm := isSymm_inner\n isNonneg := isNonneg_inner\n\nend IsPosSemidef\n" }, { "theorem_id": 61, "title": "078_the_cauchy-schwarz_inequality", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Utf8 List Reals Psatz.\nImport ListNotations.\n\nRequire Import SummationR.\n\nNotation \"u .[ i ]\" := (List.nth (pred i) u 0%R)\n (at level 1, format \"'[' u '[' .[ i ] ']' ']'\").\n\nTheorem fold_Rminus : ∀ x y, (x + - y = x - y)%R.\nProof.\nAdmitted.\n\nTheorem Rplus_shuffle0 : ∀ n m p : R, (n + m + p)%R = (n + p + m)%R.\nProof.\nAdmitted.\n\nDefinition dot_mul n a b := Σ (k = 1, n), (a.[k] * b.[k]).\n\nTheorem Binet_Cauchy_identity : ∀ (a b c d : list R) n,\n (dot_mul n a c * dot_mul n b d =\n dot_mul n a d * dot_mul n b c +\n Σ (i = 1, n), Σ (j = i + 1, n),\n ((a.\nProof.\nAdmitted.\n\nTheorem Lagrange_identity : ∀ n (a b : list R),\n ((Σ (k = 1, n), (a.\nProof.\nAdmitted.\n\nTheorem Cauchy_Schwarz_inequality : ∀ (u v : list R) n,\n ((Σ (k = 1, n), (u.\nProof.\nAdmitted.\n\nCheck Cauchy_Schwarz_inequality." }, { "theorem_id": 62, "title": "079_the_intermediate_value_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "let dest_neg_imp tm =\n try dest_imp tm with Failure _ ->\n try (dest_neg tm,mk_const(\"F\",[]))\n with Failure _ -> failwith \"dest_neg_imp\";;\n\nlet (CONV_OF_RCONV: conv -> conv) =\n let rec get_bv tm =\n if is_abs tm then bndvar tm\n else if is_comb tm then try get_bv (rand tm)\n with Failure _ -> get_bv (rator tm)\n else failwith \"\" in\n fun conv tm ->\n let v = get_bv tm in\n let th1 = conv tm in\n let th2 = ONCE_DEPTH_CONV (GEN_ALPHA_CONV v) (rhs(concl th1)) in\n TRANS th1 th2;;\n\nlet (CONV_OF_THM: thm -> conv) =\n CONV_OF_RCONV o REWR_CONV;;\n\nlet (X_FUN_EQ_CONV:term->conv) =\n fun v -> (REWR_CONV FUN_EQ_THM) THENC GEN_ALPHA_CONV v;;\n\nlet (FUN_EQ_CONV:conv) =\n fun tm ->\n let vars = frees tm in\n let op,[ty1;ty2] = dest_type(type_of (lhs tm)) in\n if op = \"fun\"\n then let varnm =\n if (is_vartype ty1) then \"x\" else\n hd(explode(fst(dest_type ty1))) in\n let x = variant vars (mk_var(varnm,ty1)) in\n X_FUN_EQ_CONV x tm\n else failwith \"FUN_EQ_CONV\";;\n\nlet (SINGLE_DEPTH_CONV:conv->conv) =\n let rec SINGLE_DEPTH_CONV conv tm =\n try conv tm with Failure _ ->\n (SUB_CONV (SINGLE_DEPTH_CONV conv) THENC (TRY_CONV conv)) tm in\n SINGLE_DEPTH_CONV;;\n\nlet (OLD_SKOLEM_CONV:conv) =\n SINGLE_DEPTH_CONV (REWR_CONV SKOLEM_THM);;\n\nlet (X_SKOLEM_CONV:term->conv) =\n fun v -> OLD_SKOLEM_CONV THENC GEN_ALPHA_CONV v;;\n\nlet EXISTS_UNIQUE_CONV tm =\n let v = bndvar(rand tm) in\n let th1 = REWR_CONV EXISTS_UNIQUE_THM tm in\n let tm1 = rhs(concl th1) in\n let vars = frees tm1 in\n let v = variant vars v in\n let v' = variant (v::vars) v in\n let th2 =\n (LAND_CONV(GEN_ALPHA_CONV v) THENC\n RAND_CONV(BINDER_CONV(GEN_ALPHA_CONV v') THENC\n GEN_ALPHA_CONV v)) tm1 in\n TRANS th1 th2;;\n\nlet NOT_FORALL_CONV = CONV_OF_THM NOT_FORALL_THM;;\n\nlet NOT_EXISTS_CONV = CONV_OF_THM NOT_EXISTS_THM;;\n\nlet RIGHT_IMP_EXISTS_CONV = CONV_OF_THM RIGHT_IMP_EXISTS_THM;;\n\nlet FORALL_IMP_CONV = CONV_OF_RCONV\n (REWR_CONV TRIV_FORALL_IMP_THM ORELSEC\n REWR_CONV RIGHT_FORALL_IMP_THM ORELSEC\n REWR_CONV LEFT_FORALL_IMP_THM);;\n\nlet EXISTS_AND_CONV = CONV_OF_RCONV\n (REWR_CONV TRIV_EXISTS_AND_THM ORELSEC\n REWR_CONV LEFT_EXISTS_AND_THM ORELSEC\n REWR_CONV RIGHT_EXISTS_AND_THM);;\n\nlet LEFT_IMP_EXISTS_CONV = CONV_OF_THM LEFT_IMP_EXISTS_THM;;\n\nlet LEFT_AND_EXISTS_CONV tm =\n let v = bndvar(rand(rand(rator tm))) in\n (REWR_CONV LEFT_AND_EXISTS_THM THENC TRY_CONV (GEN_ALPHA_CONV v)) tm;;\n\nlet RIGHT_AND_EXISTS_CONV =\n CONV_OF_THM RIGHT_AND_EXISTS_THM;;\n\nlet AND_FORALL_CONV = CONV_OF_THM AND_FORALL_THM;;\n\nlet F_IMP = TAUT `!t. ~t ==> t ==> F`;;\n\nlet LEFT_AND_OVER_OR = TAUT\n `!t1 t2 t3. t1 /\\ (t2 \\/ t3) <=> t1 /\\ t2 \\/ t1 /\\ t3`;;\n\nlet RIGHT_AND_OVER_OR = TAUT\n `!t1 t2 t3. (t2 \\/ t3) /\\ t1 <=> t2 /\\ t1 \\/ t3 /\\ t1`;;\n\nlet INST_TY_TERM(substl,insttyl) th = INST substl (INST_TYPE insttyl th);;\n\nlet NOT_MP thi th =\n try MP thi th with Failure _ ->\n try let t = dest_neg (concl thi) in\n MP(MP (SPEC t F_IMP) thi) th\n with Failure _ -> failwith \"NOT_MP\";;\n\nlet MK_ABS qth =\n try let ov = bndvar(rand(concl qth)) in\n let bv,rth = SPEC_VAR qth in\n let sth = ABS bv rth in\n let cnv = ALPHA_CONV ov in\n CONV_RULE(BINOP_CONV cnv) sth\n with Failure _ -> failwith \"MK_ABS\";;\n\nlet HALF_MK_ABS th =\n try let th1 = MK_ABS th in\n CONV_RULE(LAND_CONV ETA_CONV) th1\n with Failure _ -> failwith \"HALF_MK_ABS\";;\n\nlet SUBST thl pat th =\n let eqs,vs = unzip thl in\n let gvs = map (genvar o type_of) vs in\n let gpat = subst (zip gvs vs) pat in\n let ls,rs = unzip (map (dest_eq o concl) eqs) in\n let ths = map (ASSUME o mk_eq) (zip gvs rs) in\n let th1 = ASSUME gpat in\n let th2 = SUBS ths th1 in\n let th3 = itlist DISCH (map concl ths) (DISCH gpat th2) in\n let th4 = INST (zip ls gvs) th3 in\n MP (rev_itlist (C MP) eqs th4) th;;\n\nprioritize_num();;\n\nlet LESS_EQUAL_ANTISYM = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL LE_ANTISYM)));;\nlet NOT_LESS_0 = GEN_ALL(EQF_ELIM(SPEC_ALL(CONJUNCT1 LT)));;\nlet LESS_LEMMA1 = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL(CONJUNCT2 LT))));;\nlet LESS_SUC_REFL = ARITH_RULE `!n. n < SUC n`;;\nlet LESS_EQ_SUC_REFL = ARITH_RULE `!n. n <= SUC n`;;\nlet LESS_EQUAL_ADD = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL LE_EXISTS)));;\nlet LESS_EQ_IMP_LESS_SUC = GEN_ALL(snd(EQ_IMP_RULE(SPEC_ALL LT_SUC_LE)));;\nlet LESS_MONO_ADD = GEN_ALL(snd(EQ_IMP_RULE(SPEC_ALL LT_ADD_RCANCEL)));;\nlet LESS_SUC = ARITH_RULE `!m n. m < n ==> m < (SUC n)`;;\nlet LESS_ADD_1 = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL\n (REWRITE_RULE[ADD1] LT_EXISTS))));;\nlet SUC_SUB1 = ARITH_RULE `!m. SUC m - 1 = m`;;\nlet LESS_ADD_SUC = ARITH_RULE `!m n. m < m + SUC n`;;\nlet OR_LESS = GEN_ALL(fst(EQ_IMP_RULE(SPEC_ALL LE_SUC_LT)));;\nlet NOT_SUC_LESS_EQ = ARITH_RULE `!n m. ~(SUC n <= m) <=> m <= n`;;\nlet LESS_LESS_CASES = ARITH_RULE `!m n. (m = n) \\/ m < n \\/ n < m`;;\nlet SUB_SUB = `!b c. c <= b ==> (!a. a - (b - c) = (a + c) - b)`;;\nlet LESS_CASES_IMP = ARITH_RULE `!m n. ~(m < n) /\\ ~(m = n) ==> n < m`;;\nlet SUB_LESS_EQ = ARITH_RULE `!n m. (n - m) <= n`;;\nlet SUB_EQ_EQ_0 = ARITH_RULE `!m n. (m - n = m) <=> (m = 0) \\/ (n = 0)`;;\nlet SUB_LEFT_LESS_EQ =\n ARITH_RULE `!m n p. m <= (n - p) <=> (m + p) <= n \\/ m <= 0`;;\nlet SUB_LEFT_GREATER_EQ = ARITH_RULE `!m n p. m >= (n - p) <=> (m + p) >= n`;;\nlet LESS_0_CASES = ARITH_RULE `!m. (0 = m) \\/ 0 < m`;;\nlet LESS_OR = ARITH_RULE `!m n. m < n ==> (SUC m) <= n`;;\nlet SUB_OLD = `(!m. 0 - m = 0) /\\\n (!m n. (SUC m) - n = (if m < n then 0 else SUC(m - n)))`;;\n\nlet SYM_CANON_CONV sym fn =\n REWR_CONV sym o\n check (not o fn o ((snd o dest_comb) F_F I) o dest_comb);;\n\nlet (IMP_SUBST_TAC:thm_tactic) =\n fun th (asl,w) ->\n let tms = find_terms (can (PART_MATCH (lhs o snd o dest_imp) th)) w in\n let tm1 = hd (sort free_in tms) in\n let th1 = PART_MATCH (lhs o snd o dest_imp) th tm1 in\n let (a,(l,r)) = (I F_F dest_eq) (dest_imp (concl th1)) in\n let gv = genvar (type_of l) in\n let pat = subst[gv,l] w in\n null_meta,\n [(asl,a); (asl,subst[(r,gv)] pat)],\n fun i [t1;t2] -> SUBST[(SYM(MP th1 t1),gv)] pat t2;;\n\nlet EXT_CONV = SYM o uncurry X_FUN_EQ_CONV o\n (I F_F (mk_eq o (rator F_F rator) o dest_eq)) o dest_forall;;\n\nlet EQUAL_TAC = REPEAT(FIRST [AP_TERM_TAC; AP_THM_TAC; ABS_TAC]);;\n\nlet X_BETA_CONV v tm =\n SYM(BETA_CONV(mk_comb(mk_abs(v,tm),v)));;\n\nlet EXACT_CONV =\n ONCE_DEPTH_CONV o FIRST_CONV o\n map (fun t -> K t o check((=)(lhs(concl t))));;\n\nlet HABS_CONV tm =\n let v,bod = dest_abs tm in\n let hop,pl = strip_comb bod in\n let eql = rev(map (X_BETA_CONV v) pl) in\n ABS v (itlist (C(curry MK_COMB)) eql (REFL hop));;\n\nlet EXPAND_TAC s = FIRST_ASSUM(SUBST1_TAC o SYM o\n check((=) s o fst o dest_var o rhs o concl)) THEN BETA_TAC;;\n\nprioritize_real();;\n\nlet real_le = `!x y. x <= y <=> ~(y < x)`;;\n\nlet REAL_10 = REAL_ARITH `~(&1 = &0)`;;\n\nlet REAL_LDISTRIB = REAL_ADD_LDISTRIB;;\n\nlet REAL_LT_IADD = REAL_ARITH `!x y z. y < z ==> x + y < x + z`;;\n\nlet REAL_MUL_RID = `!x. x * &1 = x`;;\n\nlet REAL_MUL_RINV = `!x. ~(x = &0) ==> (x * (inv x) = &1)`;;\n\nlet REAL_RDISTRIB = `!x y z. (x + y) * z = (x * z) + (y * z)`;;\n\nlet REAL_EQ_LADD = `!x y z. (x + y = x + z) <=> (y = z)`;;\n\nlet REAL_EQ_RADD = `!x y z. (x + z = y + z) <=> (x = y)`;;\n\nlet REAL_ADD_LID_UNIQ = `!x y. (x + y = y) <=> (x = &0)`;;\n\nlet REAL_ADD_RID_UNIQ = `!x y. (x + y = x) <=> (y = &0)`;;\n\nlet REAL_LNEG_UNIQ = `!x y. (x + y = &0) <=> (x = --y)`;;\n\nlet REAL_RNEG_UNIQ = `!x y. (x + y = &0) <=> (y = --x)`;;\n\nlet REAL_NEG_ADD = `!x y. --(x + y) = (--x) + (--y)`;;\n\nlet REAL_MUL_LZERO = `!x. &0 * x = &0`;;\n\nlet REAL_MUL_RZERO = `!x. x * &0 = &0`;;\n\nlet REAL_NEG_LMUL = `!x y. --(x * y) = (--x) * y`;;\n\nlet REAL_NEG_RMUL = `!x y. --(x * y) = x * (--y)`;;\n\nlet REAL_NEG_NEG = `!x. --(--x) = x`;;\n\nlet REAL_NEG_MUL2 = `!x y. (--x) * (--y) = x * y`;;\n\nlet REAL_LT_LADD = `!x y z. (x + y) < (x + z) <=> y < z`;;\n\nlet REAL_LT_RADD = `!x y z. (x + z) < (y + z) <=> x < y`;;\n\nlet REAL_NOT_LT = `!x y. ~(x < y) <=> y <= x`;;\n\nlet REAL_LT_ANTISYM = `!x y. ~(x < y /\\ y < x)`;;\n\nlet REAL_LT_GT = `!x y. x < y ==> ~(y < x)`;;\n\nlet REAL_NOT_LE = `!x y. ~(x <= y) <=> y < x`;;\n\nlet REAL_LE_TOTAL = `!x y. x <= y \\/ y <= x`;;\n\nlet REAL_LE_REFL = `!x. x <= x`;;\n\nlet REAL_LE_LT = `!x y. x <= y <=> x < y \\/ (x = y)`;;\n\nlet REAL_LT_LE = `!x y. x < y <=> x <= y /\\ ~(x = y)`;;\n\nlet REAL_LT_IMP_LE = `!x y. x < y ==> x <= y`;;\n\nlet REAL_LTE_TRANS = `!x y z. x < y /\\ y <= z ==> x < z`;;\n\nlet REAL_LE_TRANS = `!x y z. x <= y /\\ y <= z ==> x <= z`;;\n\nlet REAL_NEG_LT0 = `!x. (--x) < &0 <=> &0 < x`;;\n\nlet REAL_NEG_GT0 = `!x. &0 < (--x) <=> x < &0`;;\n\nlet REAL_NEG_LE0 = `!x. (--x) <= &0 <=> &0 <= x`;;\n\nlet REAL_NEG_GE0 = `!x. &0 <= (--x) <=> x <= &0`;;\n\nlet REAL_LT_NEGTOTAL = `!x. (x = &0) \\/ (&0 < x) \\/ (&0 < --x)`;;\n\nlet REAL_LE_NEGTOTAL = `!x. &0 <= x \\/ &0 <= --x`;;\n\nlet REAL_LE_MUL = `!x y. &0 <= x /\\ &0 <= y ==> &0 <= (x * y)`;;\n\nlet REAL_LE_SQUARE = `!x. &0 <= x * x`;;\n\nlet REAL_LT_01 = `&0 < &1`;;\n\nlet REAL_LE_LADD = `!x y z. (x + y) <= (x + z) <=> y <= z`;;\n\nlet REAL_LE_RADD = `!x y z. (x + z) <= (y + z) <=> x <= y`;;\n\nlet REAL_LT_ADD2 = `!w x y z. w < x /\\ y < z ==> (w + y) < (x + z)`;;\n\nlet REAL_LT_ADD = `!x y. &0 < x /\\ &0 < y ==> &0 < (x + y)`;;\n\nlet REAL_LT_ADDNEG = `!x y z. y < (x + (--z)) <=> (y + z) < x`;;\n\nlet REAL_LT_ADDNEG2 = `!x y z. (x + (--y)) < z <=> x < (z + y)`;;\n\nlet REAL_LT_ADD1 = `!x y. x <= y ==> x < (y + &1)`;;\n\nlet REAL_SUB_ADD = `!x y. (x - y) + y = x`;;\n\nlet REAL_SUB_ADD2 = `!x y. y + (x - y) = x`;;\n\nlet REAL_SUB_REFL = `!x. x - x = &0`;;\n\nlet REAL_SUB_0 = `!x y. (x - y = &0) <=> (x = y)`;;\n\nlet REAL_LE_DOUBLE = `!x. &0 <= x + x <=> &0 <= x`;;\n\nlet REAL_LE_NEGL = `!x. (--x <= x) <=> (&0 <= x)`;;\n\nlet REAL_LE_NEGR = `!x. (x <= --x) <=> (x <= &0)`;;\n\nlet REAL_NEG_EQ0 = `!x. (--x = &0) <=> (x = &0)`;;\n\nlet REAL_NEG_0 = `--(&0) = &0`;;\n\nlet REAL_NEG_SUB = `!x y. --(x - y) = y - x`;;\n\nlet REAL_SUB_LT = `!x y. &0 < x - y <=> y < x`;;\n\nlet REAL_SUB_LE = `!x y. &0 <= (x - y) <=> y <= x`;;\n\nlet REAL_EQ_LMUL = `!x y z. (x * y = x * z) <=> (x = &0) \\/ (y = z)`;;\n\nlet REAL_EQ_RMUL = `!x y z. (x * z = y * z) <=> (z = &0) \\/ (x = y)`;;\n\nlet REAL_SUB_LDISTRIB = `!x y z. x * (y - z) = (x * y) - (x * z)`;;\n\nlet REAL_SUB_RDISTRIB = `!x y z. (x - y) * z = (x * z) - (y * z)`;;\n\nlet REAL_NEG_EQ = `!x y. (--x = y) <=> (x = --y)`;;\n\nlet REAL_NEG_MINUS1 = `!x. --x = (--(&1)) * x`;;\n\nlet REAL_INV_NZ = `!x. ~(x = &0) ==> ~(inv x = &0)`;;\n\nlet REAL_INVINV = `!x. ~(x = &0) ==> (inv (inv x) = x)`;;\n\nlet REAL_LT_IMP_NE = `!x y. x < y ==> ~(x = y)`;;\n\nlet REAL_INV_POS = `!x. &0 < x ==> &0 < inv x`;;\n\nlet REAL_LT_LMUL_0 = `!x y. &0 < x ==> (&0 < (x * y) <=> &0 < y)`;;\n\nlet REAL_LT_RMUL_0 = `!x y. &0 < y ==> (&0 < (x * y) <=> &0 < x)`;;\n\nlet REAL_LT_LMUL_EQ = `!x y z. &0 < x ==> ((x * y) < (x * z) <=> y < z)`;;\n\nlet REAL_LT_RMUL_EQ = `!x y z. &0 < z ==> ((x * z) < (y * z) <=> x < y)`;;\n\nlet REAL_LT_RMUL_IMP = `!x y z. x < y /\\ &0 < z ==> (x * z) < (y * z)`;;\n\nlet REAL_LT_LMUL_IMP = `!x y z. y < z /\\ &0 < x ==> (x * y) < (x * z)`;;\n\nlet REAL_LINV_UNIQ = `!x y. (x * y = &1) ==> (x = inv y)`;;\n\nlet REAL_RINV_UNIQ = `!x y. (x * y = &1) ==> (y = inv x)`;;\n\nlet REAL_NEG_INV = `!x. ~(x = &0) ==> (--(inv x) = inv(--x))`;;\n\nlet REAL_INV_1OVER = `!x. inv x = &1 / x`;;\n\nlet REAL = `!n. &(SUC n) = &n + &1`;;\n\nlet REAL_POS = `!n. &0 <= &n`;;\n\nlet REAL_LE = `!m n. &m <= &n <=> m <= n`;;\n\nlet REAL_LT = `!m n. &m < &n <=> m < n`;;\n\nlet REAL_INJ = `!m n. (&m = &n) <=> (m = n)`;;\n\nlet REAL_ADD = `!m n. &m + &n = &(m + n)`;;\n\nlet REAL_MUL = `!m n. &m * &n = &(m * n)`;;\n\nlet REAL_INV1 = `inv(&1) = &1`;;\n\nlet REAL_DIV_LZERO = `!x. &0 / x = &0`;;\n\nlet REAL_LT_NZ = `!n. ~(&n = &0) <=> (&0 < &n)`;;\n\nlet REAL_NZ_IMP_LT = `!n. ~(n = 0) ==> &0 < &n`;;\n\nlet REAL_LT_RDIV_0 = `!y z. &0 < z ==> (&0 < (y / z) <=> &0 < y)`;;\n\nlet REAL_LT_RDIV = `!x y z. &0 < z ==> ((x / z) < (y / z) <=> x < y)`;;\n\nlet REAL_LT_FRACTION_0 = `!n d. ~(n = 0) ==> (&0 < (d / &n) <=> &0 < d)`;;\n\nlet REAL_LT_MULTIPLE = `!n d. 1 < n ==> (d < (&n * d) <=> &0 < d)`;;\n\nlet REAL_LT_FRACTION = `!n d. (1 < n) ==> ((d / &n) < d <=> &0 < d)`;;\n\nlet REAL_LT_HALF1 = `!d. &0 < (d / &2) <=> &0 < d`;;\n\nlet REAL_LT_HALF2 = `!d. (d / &2) < d <=> &0 < d`;;\n\nlet REAL_DOUBLE = `!x. x + x = &2 * x`;;\n\nlet REAL_HALF_DOUBLE = `!x. (x / &2) + (x / &2) = x`;;\n\nlet REAL_SUB_SUB = `!x y. (x - y) - x = --y`;;\n\nlet REAL_LT_ADD_SUB = `!x y z. (x + y) < z <=> x < (z - y)`;;\n\nlet REAL_LT_SUB_RADD = `!x y z. (x - y) < z <=> x < z + y`;;\n\nlet REAL_LT_SUB_LADD = `!x y z. x < (y - z) <=> (x + z) < y`;;\n\nlet REAL_LE_SUB_LADD = `!x y z. x <= (y - z) <=> (x + z) <= y`;;\n\nlet REAL_LE_SUB_RADD = `!x y z. (x - y) <= z <=> x <= z + y`;;\n\nlet REAL_LT_NEG2 = `!x y. --x < --y <=> y < x`;;\n\nlet REAL_LE_NEG2 = `!x y. --x <= --y <=> y <= x`;;\n\nlet REAL_SUB_LZERO = `!x. &0 - x = --x`;;\n\nlet REAL_SUB_RZERO = `!x. x - &0 = x`;;\n\nlet REAL_LTE_ADD2 = `!w x y z. w < x /\\ y <= z ==> (w + y) < (x + z)`;;\n\nlet REAL_LTE_ADD = `!x y. &0 < x /\\ &0 <= y ==> &0 < (x + y)`;;\n\nlet REAL_LT_MUL2_ALT = `!x1 x2 y1 y2. &0 <= x1 /\\ &0 <= y1 /\\ x1 < x2 /\\ y1 < y2 ==>\n (x1 * y1) < (x2 * y2)`;;\n\nlet REAL_SUB_LNEG = `!x y. (--x) - y = --(x + y)`;;\n\nlet REAL_SUB_RNEG = `!x y. x - (--y) = x + y`;;\n\nlet REAL_SUB_NEG2 = `!x y. (--x) - (--y) = y - x`;;\n\nlet REAL_SUB_TRIANGLE = `!a b c. (a - b) + (b - c) = a - c`;;\n\nlet REAL_INV_MUL_WEAK = `!x y. ~(x = &0) /\\ ~(y = &0) ==>\n (inv(x * y) = inv(x) * inv(y))`;;\n\nlet REAL_LE_LMUL_LOCAL = `!x y z. &0 < x ==> ((x * y) <= (x * z) <=> y <= z)`;;\n\nlet REAL_LE_RMUL_EQ = `!x y z. &0 < z ==> ((x * z) <= (y * z) <=> x <= y)`;;\n\nlet REAL_SUB_INV2 = `!x y. ~(x = &0) /\\ ~(y = &0) ==>\n (inv(x) - inv(y) = (y - x) / (x * y))`;;\n\nlet REAL_SUB_SUB2 = `!x y. x - (x - y) = y`;;\n\nlet REAL_MEAN = `!x y. x < y ==> ?z. x < z /\\ z < y`;;\n\nlet REAL_EQ_LMUL2 = `!x y z. ~(x = &0) ==> ((y = z) <=> (x * y = x * z))`;;\n\nlet REAL_LE_MUL2V = `!x1 x2 y1 y2.\n (& 0) <= x1 /\\ (& 0) <= y1 /\\ x1 <= x2 /\\ y1 <= y2 ==>\n (x1 * y1) <= (x2 * y2)`;;\n\nlet REAL_LE_LDIV = `!x y z. &0 < x /\\ y <= (z * x) ==> (y / x) <= z`;;\n\nlet REAL_LE_RDIV = `!x y z. &0 < x /\\ (y * x) <= z ==> y <= (z / x)`;;\n\nlet REAL_LT_1 = `!x y. &0 <= x /\\ x < y ==> (x / y) < &1`;;\n\nlet REAL_LE_LMUL_IMP = `!x y z. &0 <= x /\\ y <= z ==> (x * y) <= (x * z)`;;\n\nlet REAL_LE_RMUL_IMP = `!x y z. &0 <= x /\\ y <= z ==> (y * x) <= (z * x)`;;\n\nlet REAL_INV_LT1 = `!x. &0 < x /\\ x < &1 ==> &1 < inv(x)`;;\n\nlet REAL_LT_IMP_NZ = `!x. &0 < x ==> ~(x = &0)`;;\n\nlet REAL_EQ_RMUL_IMP = `!x y z. ~(z = &0) /\\ (x * z = y * z) ==> (x = y)`;;\n\nlet REAL_EQ_LMUL_IMP = `!x y z. ~(x = &0) /\\ (x * y = x * z) ==> (y = z)`;;\n\nlet REAL_FACT_NZ = `!n. ~(&(FACT n) = &0)`;;\n\nlet REAL_POSSQ = `!x. &0 < (x * x) <=> ~(x = &0)`;;\n\nlet REAL_SUMSQ = `!x y. ((x * x) + (y * y) = &0) <=> (x = &0) /\\ (y = &0)`;;\n\nlet REAL_EQ_NEG = `!x y. (--x = --y) <=> (x = y)`;;\n\nlet REAL_DIV_MUL2 = `!x z. ~(x = &0) /\\ ~(z = &0) ==> !y. y / z = (x * y) / (x * z)`;;\n\nlet REAL_MIDDLE1 = `!a b. a <= b ==> a <= (a + b) / &2`;;\n\nlet REAL_MIDDLE2 = `!a b. a <= b ==> ((a + b) / &2) <= b`;;\n\nlet ABS_ZERO = `!x. (abs(x) = &0) <=> (x = &0)`;;\n\nlet ABS_0 = `abs(&0) = &0`;;\n\nlet ABS_1 = `abs(&1) = &1`;;\n\nlet ABS_NEG = `!x. abs(--x) = abs(x)`;;\n\nlet ABS_TRIANGLE = `!x y. abs(x + y) <= abs(x) + abs(y)`;;\n\nlet ABS_POS = `!x. &0 <= abs(x)`;;\n\nlet ABS_MUL = `!x y. abs(x * y) = abs(x) * abs(y)`;;\n\nlet ABS_LT_MUL2 = `!w x y z. abs(w) < y /\\ abs(x) < z ==> abs(w * x) < (y * z)`;;\n\nlet ABS_SUB = `!x y. abs(x - y) = abs(y - x)`;;\n\nlet ABS_NZ = `!x. ~(x = &0) <=> &0 < abs(x)`;;\n\nlet ABS_INV = `!x. ~(x = &0) ==> (abs(inv x) = inv(abs(x)))`;;\n\nlet ABS_ABS = `!x. abs(abs(x)) = abs(x)`;;\n\nlet ABS_LE = `!x. x <= abs(x)`;;\n\nlet ABS_REFL = `!x. (abs(x) = x) <=> &0 <= x`;;\n\nlet ABS_N = `!n. abs(&n) = &n`;;\n\nlet ABS_BETWEEN = `!x y d. &0 < d /\\ ((x - d) < y) /\\ (y < (x + d)) <=> abs(y - x) < d`;;\n\nlet ABS_BOUND = `!x y d. abs(x - y) < d ==> y < (x + d)`;;\n\nlet ABS_STILLNZ = `!x y. abs(x - y) < abs(y) ==> ~(x = &0)`;;\n\nlet ABS_CASES = `!x. (x = &0) \\/ &0 < abs(x)`;;\n\nlet ABS_BETWEEN1 = `!x y z. x < z /\\ (abs(y - x)) < (z - x) ==> y < z`;;\n\nlet ABS_SIGN = `!x y. abs(x - y) < y ==> &0 < x`;;\n\nlet ABS_SIGN2 = `!x y. abs(x - y) < --y ==> x < &0`;;\n\nlet ABS_DIV = `!y. ~(y = &0) ==> !x. abs(x / y) = abs(x) / abs(y)`;;\n\nlet ABS_CIRCLE = `!x y h. abs(h) < (abs(y) - abs(x)) ==> abs(x + h) < abs(y)`;;\n\nlet REAL_SUB_ABS = `!x y. (abs(x) - abs(y)) <= abs(x - y)`;;\n\nlet ABS_SUB_ABS = `!x y. abs(abs(x) - abs(y)) <= abs(x - y)`;;\n\nlet ABS_BETWEEN2 = `!x0 x y0 y. x0 < y0 /\\ abs(x - x0) < (y0 - x0) / &2 /\\\n abs(y - y0) < (y0 - x0) / &2\n ==> x < y`;;\n\nlet ABS_BOUNDS = `!x k. abs(x) <= k <=> --k <= x /\\ x <= k`;;\n\nlet pow = real_pow;;\n\nlet POW_0 = `!n. &0 pow (SUC n) = &0`;;\n\nlet POW_NZ = `!c n. ~(c = &0) ==> ~(c pow n = &0)`;;\n\nlet POW_INV = `!c n. ~(c = &0) ==> (inv(c pow n) = (inv c) pow n)`;;\n\nlet POW_ABS = `!c n. abs(c) pow n = abs(c pow n)`;;\n\nlet POW_PLUS1 = `!e n. &0 < e ==> (&1 + (&n * e)) <= (&1 + e) pow n`;;\n\nlet POW_ADD = `!c m n. c pow (m + n) = (c pow m) * (c pow n)`;;\n\nlet POW_1 = `!x. x pow 1 = x`;;\n\nlet POW_2 = `!x. x pow 2 = x * x`;;\n\nlet POW_POS = `!x n. &0 <= x ==> &0 <= (x pow n)`;;\n\nlet POW_LE = `!n x y. &0 <= x /\\ x <= y ==> (x pow n) <= (y pow n)`;;\n\nlet POW_M1 = `!n. abs((--(&1)) pow n) = &1`;;\n\nlet POW_MUL = `!n x y. (x * y) pow n = (x pow n) * (y pow n)`;;\n\nlet REAL_LE_SQUARE_POW = `!x. &0 <= x pow 2`;;\n\nlet ABS_POW2 = `!x. abs(x pow 2) = x pow 2`;;\n\nlet REAL_LE1_POW2 = `!x. &1 <= x ==> &1 <= (x pow 2)`;;\n\nlet REAL_LT1_POW2 = `!x. &1 < x ==> &1 < (x pow 2)`;;\n\nlet POW_POS_LT = `!x n. &0 < x ==> &0 < (x pow (SUC n))`;;\n\nlet POW_2_LE1 = `!n. &1 <= &2 pow n`;;\n\nlet POW_2_LT = `!n. &n < &2 pow n`;;\n\nlet POW_MINUS1 = `!n. (--(&1)) pow (2 * n) = &1`;;\n\nlet REAL_SUP_EXISTS = `!P. (?x. P x) /\\ (?z. !x. P x ==> x < z) ==>\n (?s. !y. (?x. P x /\\ y < x) <=> y < s)`;;\n\nlet sup_def = new_definition\n `sup s = @a. (!x. x IN s ==> x <= a) /\\\n (!b. (!x. x IN s ==> x <= b) ==> a <= b)`;;\n\nlet sup = `sup P = @s. !y. (?x. P x /\\ y < x) <=> y < s`;;\n\nlet REAL_SUP = `!P. (?x. P x) /\\ (?z. !x. P x ==> x < z) ==>\n (!y. (?x. P x /\\ y < x) <=> y < sup P)`;;\n\nlet REAL_SUP_UBOUND = `!P. (?x. P x) /\\ (?z. !x. P x ==> x < z) ==>\n (!y. P y ==> y <= sup P)`;;\n\nlet SETOK_LE_LT = `!P. (?x. P x) /\\ (?z. !x. P x ==> x <= z) <=>\n (?x. P x) /\\ (?z. !x. P x ==> x < z)`;;\n\nlet REAL_SUP_LE = `!P. (?x. P x) /\\ (?z. !x. P x ==> x <= z) ==>\n (!y. (?x. P x /\\ y < x) <=> y < sup P)`;;\n\nlet REAL_SUP_UBOUND_LE = `!P. (?x. P x) /\\ (?z. !x. P x ==> x <= z) ==>\n (!y. P y ==> y <= sup P)`;;\n\nlet REAL_ARCH_SIMPLE = `!x. ?n. x <= &n`;;\n\nlet REAL_ARCH = `!x. &0 < x ==> !y. ?n. y < &n * x`;;\n\nlet REAL_ARCH_LEAST = `!y. &0 < y ==> !x. &0 <= x ==>\n ?n. (&n * y) <= x /\\ x < (&(SUC n) * y)`;;\n\nlet REAL_POW_LBOUND = `!x n. &0 <= x ==> &1 + &n * x <= (&1 + x) pow n`;;\n\nlet REAL_ARCH_POW = `!x y. &1 < x ==> ?n. y < x pow n`;;\n\nlet REAL_ARCH_POW2 = `!x. ?n. x < &2 pow n`;;\n\nprioritize_real();;\n\nmake_overloadable \"sum\" `:A->(B->real)->real`;;\n\noverload_interface(\"sum\",`sum:(A->bool)->(A->real)->real`);;\noverload_interface(\"sum\",`psum:(num#num)->(num->real)->real`);;\n\nlet sum_EXISTS = `?sum. (!f n. sum(n,0) f = &0) /\\\n (!f m n. sum(n,SUC m) f = sum(n,m) f + f(n + m))`;;\n\nlet sum_DEF = new_specification [\"psum\"] sum_EXISTS;;\n\nlet sum = `(sum(n,0) f = &0) /\\\n (sum(n,SUC m) f = sum(n,m) f + f(n + m))`;;\n\nlet PSUM_SUM = `!f m n. sum(m,n) f = sum {i | m <= i /\\ i < m + n} f`;;\n\nlet PSUM_SUM_NUMSEG = `!f m n. ~(m = 0 /\\ n = 0) ==> sum(m,n) f = sum(m..(m+n)-1) f`;;\n\nlet SUM_TWO = `!f n p. sum(0,n) f + sum(n,p) f = sum(0,n + p) f`;;\n\nlet SUM_DIFF = `!f m n. sum(m,n) f = sum(0,m + n) f - sum(0,m) f`;;\n\nlet ABS_SUM = `!f m n. abs(sum(m,n) f) <= sum(m,n) (\\n. abs(f n))`;;\n\nlet SUM_LE = `!f g m n. (!r. m <= r /\\ r < n + m ==> f(r) <= g(r))\n ==> (sum(m,n) f <= sum(m,n) g)`;;\n\nlet SUM_EQ = `!f g m n. (!r. m <= r /\\ r < (n + m) ==> (f(r) = g(r)))\n ==> (sum(m,n) f = sum(m,n) g)`;;\n\nlet SUM_POS = `!f. (!n. &0 <= f(n)) ==> !m n. &0 <= sum(m,n) f`;;\n\nlet SUM_POS_GEN = `!f m n.\n (!n. m <= n ==> &0 <= f(n))\n ==> &0 <= sum(m,n) f`;;\n\nlet SUM_ABS = `!f m n. abs(sum(m,n) (\\m. abs(f m))) = sum(m,n) (\\m. abs(f m))`;;\n\nlet SUM_ABS_LE = `!f m n. abs(sum(m,n) f) <= sum(m,n)(\\n. abs(f n))`;;\n\nlet SUM_ZERO = `!f N. (!n. n >= N ==> (f(n) = &0)) ==>\n (!m n. m >= N ==> (sum(m,n) f = &0))`;;\n\nlet SUM_ADD = `!f g m n. sum(m,n) (\\n. f(n) + g(n)) = sum(m,n) f + sum(m,n) g`;;\n\nlet SUM_CMUL = `!f c m n. sum(m,n) (\\n. c * f(n)) = c * sum(m,n) f`;;\n\nlet SUM_NEG = `!f n d. sum(n,d) (\\n. --(f n)) = --(sum(n,d) f)`;;\n\nlet SUM_SUB = `!f g m n. sum(m,n)(\\n. (f n) - (g n)) = sum(m,n) f - sum(m,n) g`;;\n\nlet SUM_SUBST = `!f g m n. (!p. m <= p /\\ p < (m + n) ==> (f p = g p))\n ==> (sum(m,n) f = sum(m,n) g)`;;\n\nlet SUM_NSUB = `!n f c. sum(0,n) f - (&n * c) = sum(0,n)(\\p. f(p) - c)`;;\n\nlet SUM_BOUND = `!f K m n. (!p. m <= p /\\ p < (m + n) ==> (f(p) <= K))\n ==> (sum(m,n) f <= (&n * K))`;;\n\nlet SUM_GROUP = `!n k f. sum(0,n)(\\m. sum(m * k,k) f) = sum(0,n * k) f`;;\n\nlet SUM_1 = `!f n. sum(n,1) f = f(n)`;;\n\nlet SUM_2 = `!f n. sum(n,2) f = f(n) + f(n + 1)`;;\n\nlet SUM_OFFSET = `!f n k. sum(0,n)(\\m. f(m + k)) = sum(0,n + k) f - sum(0,k) f`;;\n\nlet SUM_REINDEX = `!f m k n. sum(m + k,n) f = sum(m,n)(\\r. f(r + k))`;;\n\nlet SUM_0 = `!m n. sum(m,n)(\\r. &0) = &0`;;\n\nlet SUM_CANCEL = `!f n d. sum(n,d) (\\n. f(SUC n) - f(n)) = f(n + d) - f(n)`;;\n\nlet SUM_HORNER = `!f n x. sum(0,SUC n)(\\i. f(i) * x pow i) =\n f(0) + x * sum(0,n)(\\i. f(SUC i) * x pow i)`;;\n\nlet SUM_CONST = `!c n. sum(0,n) (\\m. c) = &n * c`;;\n\nlet SUM_SPLIT = `!f n p. sum(m,n) f + sum(m + n,p) f = sum(m,n + p) f`;;\n\nlet SUM_SWAP = `!f m1 n1 m2 n2.\n sum(m1,n1) (\\a. sum(m2,n2) (\\b. f a b)) =\n sum(m2,n2) (\\b. sum(m1,n1) (\\a. f a b))`;;\n\nlet SUM_EQ_0 = `(!r. m <= r /\\ r < m + n ==> (f(r) = &0)) ==> (sum(m,n) f = &0)`;;\n\nlet SUM_MORETERMS_EQ = `!m n p.\n n <= p /\\ (!r. m + n <= r /\\ r < m + p ==> (f(r) = &0))\n ==> (sum(m,p) f = sum(m,n) f)`;;\n\nlet SUM_DIFFERENCES_EQ = `!m n p.\n n <= p /\\ (!r. m + n <= r /\\ r < m + p ==> (f(r) = g(r)))\n ==> (sum(m,p) f - sum(m,n) f = sum(m,p) g - sum(m,n) g)`;;\n\nlet REAL_SUM_CONV =\n let sum_tm = `sum` in\n let pth = `sum(0,1) f = f 0`;;\nparse_as_infix(\"re_intersect\",(17,\"right\"));;\nparse_as_infix(\"re_subset\",(12,\"right\"));;\n\nlet re_Union = new_definition(\n `re_Union S = \\x:A. ?s. S s /\\ s x`);;\n\nlet re_union = new_definition(\n `P re_union Q = \\x:A. P x \\/ Q x`);;\n\nlet re_intersect = new_definition\n `P re_intersect Q = \\x:A. P x /\\ Q x`;;\n\nlet re_null = new_definition(\n `re_null = \\x:A. F`);;\n\nlet re_universe = new_definition(\n `re_universe = \\x:A. T`);;\n\nlet re_subset = new_definition(\n `P re_subset Q <=> !x:A. P x ==> Q x`);;\n\nlet re_compl = new_definition(\n `re_compl S = \\x:A. ~(S x)`);;\n\nlet SUBSETA_REFL = `!S:A->bool. S re_subset S`;;\n\nlet COMPL_MEM = `!S:A->bool. !x. S x <=> ~(re_compl S x)`;;\n\nlet SUBSETA_ANTISYM = `!P:A->bool. !Q. P re_subset Q /\\ Q re_subset P <=> (P = Q)`;;\n\nlet SUBSETA_TRANS = `!P:A->bool. !Q R. P re_subset Q /\\ Q re_subset R ==> P re_subset R`;;\n\nlet istopology = new_definition(\n `!L:(A->bool)->bool. istopology L <=>\n L re_null /\\\n L re_universe /\\\n (!a b. L a /\\ L b ==> L (a re_intersect b)) /\\\n (!P. P re_subset L ==> L (re_Union P))`);;\n\nlet topology_tybij = new_type_definition \"topology\" (\"topology\",\"open\")\n (prove(`?t:(A->bool)->bool. istopology t`,\n EXISTS_TAC `re_universe:(A->bool)->bool` THEN\n REWRITE_TAC[istopology; re_universe]));;\n\nlet TOPOLOGY = `!L:(A)topology. open(L) re_null /\\\n open(L) re_universe /\\\n (!x y. open(L) x /\\ open(L) y ==> open(L) (x re_intersect y)) /\\\n (!P. P re_subset (open L) ==> open(L) (re_Union P))`;;\n\nlet TOPOLOGY_UNION = `!L:(A)topology. !P. P re_subset (open L) ==> open(L) (re_Union P)`;;\n\nlet neigh = new_definition(\n `neigh(top)(N,(x:A)) = ?P. open(top) P /\\ P re_subset N /\\ P x`);;\n\nlet OPEN_OWN_NEIGH = `!S top. !x:A. open(top) S /\\ S x ==> neigh(top)(S,x)`;;\n\nlet OPEN_UNOPEN = `!S top. open(top) S <=>\n (re_Union (\\P:A->bool. open(top) P /\\ P re_subset S) = S)`;;\n\nlet OPEN_SUBOPEN = `!S top. open(top) S <=>\n !x:A. S x ==> ?P. P x /\\ open(top) P /\\ P re_subset S`;;\n\nlet OPEN_NEIGH = `!S top. open(top) S = !x:A. S x ==> ?N. neigh(top)(N,x) /\\ N re_subset S`;;\n\nlet closed = new_definition(\n `closed(L:(A)topology) S = open(L)(re_compl S)`);;\n\nlet limpt = new_definition(\n `limpt(top) x S <=>\n !N:A->bool. neigh(top)(N,x) ==> ?y. ~(x = y) /\\ S y /\\ N y`);;\n\nlet CLOSED_LIMPT = `!top S. closed(top) S <=> (!x:A. limpt(top) x S ==> S x)`;;\n\nlet ismet = new_definition(\n `ismet (m:A#A->real) <=> (!x y. (m(x,y) = &0) <=> (x = y)) /\\\n (!x y z. m(y,z) <= m(x,y) + m(x,z))`);;\n\nlet metric_tybij = new_type_definition \"metric\" (\"metric\",\"mdist\")\n (prove(`?m:(A#A->real). ismet m`,\n EXISTS_TAC `\\((x:A),(y:A)). if x = y then &0 else &1` THEN\n REWRITE_TAC[ismet] THEN\n CONV_TAC(ONCE_DEPTH_CONV GEN_BETA_CONV) THEN\n CONJ_TAC THEN REPEAT GEN_TAC THENL\n [BOOL_CASES_TAC `x:A = y` THEN REWRITE_TAC[REAL_10];\n REPEAT COND_CASES_TAC THEN\n ASM_REWRITE_TAC[REAL_ADD_LID; REAL_ADD_RID; REAL_LE_REFL; REAL_LE_01]\n THEN GEN_REWRITE_TAC LAND_CONV [GSYM REAL_ADD_LID] THEN\n TRY(MATCH_MP_TAC REAL_LE_ADD2) THEN\n REWRITE_TAC[REAL_LE_01; REAL_LE_REFL] THEN\n FIRST_ASSUM(UNDISCH_TAC o check is_neg o concl) THEN\n EVERY_ASSUM(SUBST1_TAC o SYM) THEN REWRITE_TAC[]]));;\n\nlet METRIC_ISMET = `!m:(A)metric. ismet (mdist m)`;;\n\nlet METRIC_ZERO = `!m:(A)metric. !x y. ((mdist m)(x,y) = &0) <=> (x = y)`;;\n\nlet METRIC_SAME = `!m:(A)metric. !x. (mdist m)(x,x) = &0`;;\n\nlet METRIC_POS = `!m:(A)metric. !x y. &0 <= (mdist m)(x,y)`;;\n\nlet METRIC_SYM = `!m:(A)metric. !x y. (mdist m)(x,y) = (mdist m)(y,x)`;;\n\nlet METRIC_TRIANGLE = `!m:(A)metric. !x y z. (mdist m)(x,z) <= (mdist m)(x,y) + (mdist m)(y,z)`;;\n\nlet METRIC_NZ = `!m:(A)metric. !x y. ~(x = y) ==> &0 < (mdist m)(x,y)`;;\n\nlet mtop = new_definition(\n `!m:(A)metric. mtop m =\n topology(\\S. !x. S x ==> ?e. &0 < e /\\ (!y. (mdist m)(x,y) < e ==> S y))`);;\n\nlet mtop_istopology = `!m:(A)metric. istopology\n (\\S. !x. S x ==> ?e. &0 < e /\\ (!y. (mdist m)(x,y) < e ==> S y))`;;\n\nlet MTOP_OPEN = `!m:(A)metric. open(mtop m) S <=>\n (!x. S x ==> ?e. &0 < e /\\ (!y. (mdist m(x,y)) < e ==> S y))`;;\n\nlet ball = new_definition(\n `!m:(A)metric. !x e. ball(m)(x,e) = \\y. (mdist m)(x,y) < e`);;\n\nlet BALL_OPEN = `!m:(A)metric. !x e. &0 < e ==> open(mtop(m))(ball(m)(x,e))`;;\n\nlet BALL_NEIGH = `!m:(A)metric. !x e. &0 < e ==> neigh(mtop(m))(ball(m)(x,e),x)`;;\n\nlet MTOP_LIMPT = `!m:(A)metric. !x S. limpt(mtop m) x S <=>\n !e. &0 < e ==> ?y. ~(x = y) /\\ S y /\\ (mdist m)(x,y) < e`;;\n\nlet ISMET_R1 = `ismet (\\(x,y). abs(y - x))`;;\n\nlet mr1 = new_definition(\n `mr1 = metric(\\(x,y). abs(y - x))`);;\n\nlet MR1_DEF = `!x y. (mdist mr1)(x,y) = abs(y - x)`;;\n\nlet MR1_ADD = `!x d. (mdist mr1)(x,x+d) = abs(d)`;;\n\nlet MR1_SUB = `!x d. (mdist mr1)(x,x-d) = abs(d)`;;\n\nlet MR1_ADD_LE = `!x d. &0 <= d ==> ((mdist mr1)(x,x+d) = d)`;;\n\nlet MR1_SUB_LE = `!x d. &0 <= d ==> ((mdist mr1)(x,x-d) = d)`;;\n\nlet MR1_ADD_LT = `!x d. &0 < d ==> ((mdist mr1)(x,x+d) = d)`;;\n\nlet MR1_SUB_LT = `!x d. &0 < d ==> ((mdist mr1)(x,x-d) = d)`;;\n\nlet MR1_BETWEEN1 = `!x y z. x < z /\\ (mdist mr1)(x,y) < (z - x) ==> y < z`;;\n\nlet MR1_LIMPT = `!x. limpt(mtop mr1) x re_universe`;;\n\nparse_as_infix (\"tends\",(12,\"right\"));;\n\nlet dorder = new_definition(\n `dorder (g:A->A->bool) <=>\n !x y. g x x /\\ g y y ==> ?z. g z z /\\ (!w. g w z ==> g w x /\\ g w y)`);;\n\nlet tends = new_definition\n `(s tends l)(top,g) <=>\n !N:A->bool. neigh(top)(N,l) ==>\n ?n:B. g n n /\\ !m:B. g m n ==> N(s m)`;;\n\nlet bounded = new_definition(\n `bounded((m:(A)metric),(g:B->B->bool)) f <=>\n ?k x N. g N N /\\ (!n. g n N ==> (mdist m)(f(n),x) < k)`);;\n\nlet tendsto = new_definition(\n `tendsto((m:(A)metric),x) y z <=>\n &0 < (mdist m)(x,y) /\\ (mdist m)(x,y) <= (mdist m)(x,z)`);;\n\nparse_as_infix(\"-->\",(12,\"right\"));;\n\noverride_interface (\"-->\",`(tends)`);;\n\nlet DORDER_LEMMA = `!g:A->A->bool.\n dorder g ==>\n !P Q. (?n. g n n /\\ (!m. g m n ==> P m)) /\\\n (?n. g n n /\\ (!m. g m n ==> Q m))\n ==> (?n. g n n /\\ (!m. g m n ==> P m /\\ Q m))`;;\n\nlet DORDER_THEN tac th =\n let [t1;t2] = map (rand o rand o body o rand) (conjuncts(concl th)) in\n let dog = (rator o rator o rand o rator o body) t1 in\n let thl = map ((uncurry X_BETA_CONV) o (I F_F rand) o dest_abs) [t1;t2] in\n let th1 = CONV_RULE(EXACT_CONV thl) th in\n let th2 = MATCH_MP DORDER_LEMMA (ASSUME (list_mk_icomb \"dorder\" [dog])) in\n let th3 = MATCH_MP th2 th1 in\n let th4 = CONV_RULE(EXACT_CONV(map SYM thl)) th3 in\n tac th4;;\n\nlet DORDER_NGE = `dorder ((>=) :num->num->bool)`;;\n\nlet DORDER_TENDSTO = `!m:(A)metric. !x. dorder(tendsto(m,x))`;;\n\nlet MTOP_TENDS = `!d g. !x:B->A. !x0. (x --> x0)(mtop(d),g) <=>\n !e. &0 < e ==> ?n. g n n /\\ !m. g m n ==> mdist(d)(x(m),x0) < e`;;\n\nlet MTOP_TENDS_UNIQ = `!g d. dorder (g:B->B->bool) ==>\n (x --> x0)(mtop(d),g) /\\ (x --> x1)(mtop(d),g) ==> (x0:A = x1)`;;\n\nlet SEQ_TENDS = `!d:(A)metric. !x x0. (x --> x0)(mtop(d), (>=) :num->num->bool) <=>\n !e. &0 < e ==> ?N. !n. n >= N ==> mdist(d)(x(n),x0) < e`;;\n\nlet LIM_TENDS = `!m1:(A)metric. !m2:(B)metric. !f x0 y0.\n limpt(mtop m1) x0 re_universe ==>\n ((f --> y0)(mtop(m2),tendsto(m1,x0)) <=>\n !e. &0 < e ==>\n ?d. &0 < d /\\ !x. &0 < (mdist m1)(x,x0) /\\ (mdist m1)(x,x0) <= d\n ==> (mdist m2)(f(x),y0) < e)`;;\n\nlet LIM_TENDS2 = `!m1:(A)metric. !m2:(B)metric. !f x0 y0.\n limpt(mtop m1) x0 re_universe ==>\n ((f --> y0)(mtop(m2),tendsto(m1,x0)) <=>\n !e. &0 < e ==>\n ?d. &0 < d /\\ !x. &0 < (mdist m1)(x,x0) /\\ (mdist m1)(x,x0) < d ==>\n (mdist m2)(f(x),y0) < e)`;;\n\nlet MR1_BOUNDED = `!(g:A->A->bool) f. bounded(mr1,g) f <=>\n ?k N. g N N /\\ (!n. g n N ==> abs(f n) < k)`;;\n\nlet NET_NULL = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) <=> ((\\n. x(n) - x0) --> &0)(mtop(mr1),g)`;;\n\nlet NET_CONV_BOUNDED = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) ==> bounded(mr1,g) x`;;\n\nlet NET_CONV_NZ = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) /\\ ~(x0 = &0) ==>\n ?N. g N N /\\ (!n. g n N ==> ~(x n = &0))`;;\n\nlet NET_CONV_IBOUNDED = `!g:A->A->bool. !x x0.\n (x --> x0)(mtop(mr1),g) /\\ ~(x0 = &0) ==>\n bounded(mr1,g) (\\n. inv(x n))`;;\n\nlet NET_NULL_ADD = `!g:A->A->bool. dorder g ==>\n !x y. (x --> &0)(mtop(mr1),g) /\\ (y --> &0)(mtop(mr1),g) ==>\n ((\\n. x(n) + y(n)) --> &0)(mtop(mr1),g)`;;\n\nlet NET_NULL_MUL = `!g:A->A->bool. dorder g ==>\n !x y. bounded(mr1,g) x /\\ (y --> &0)(mtop(mr1),g) ==>\n ((\\n. x(n) * y(n)) --> &0)(mtop(mr1),g)`;;\n\nlet NET_NULL_CMUL = `!g:A->A->bool. !k x.\n (x --> &0)(mtop(mr1),g) ==> ((\\n. k * x(n)) --> &0)(mtop(mr1),g)`;;\n\nlet NET_ADD = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ (y --> y0)(mtop(mr1),g)\n ==> ((\\n. x(n) + y(n)) --> (x0 + y0))(mtop(mr1),g)`;;\n\nlet NET_NEG = `!g:A->A->bool x x0.\n dorder g\n ==> ((x --> x0)(mtop(mr1),g) <=>\n ((\\n. --(x n)) --> --x0)(mtop(mr1),g))`;;\n\nlet NET_SUB = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ (y --> y0)(mtop(mr1),g)\n ==> ((\\n. x(n) - y(n)) --> (x0 - y0))(mtop(mr1),g)`;;\n\nlet NET_MUL = `!g:A->A->bool x y x0 y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ (y --> y0)(mtop(mr1),g)\n ==> ((\\n. x(n) * y(n)) --> (x0 * y0))(mtop(mr1),g)`;;\n\nlet NET_INV = `!g:A->A->bool x x0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\ ~(x0 = &0)\n ==> ((\\n. inv(x(n))) --> inv x0)(mtop(mr1),g)`;;\n\nlet NET_DIV = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\\n (y --> y0)(mtop(mr1),g) /\\ ~(y0 = &0)\n ==> ((\\n. x(n) / y(n)) --> (x0 / y0))(mtop(mr1),g)`;;\n\nlet NET_ABS = `!x x0. (x --> x0)(mtop(mr1),g) ==>\n ((\\n:A. abs(x n)) --> abs(x0))(mtop(mr1),g)`;;\n\nlet NET_SUM = `!g. dorder g /\\\n ((\\x. &0) --> &0)(mtop(mr1),g)\n ==> !m n. (!r. m <= r /\\ r < m + n ==> (f r --> l r)(mtop(mr1),g))\n ==> ((\\x. sum(m,n) (\\r. f r x)) --> sum(m,n) l)\n (mtop(mr1),g)`;;\n\nlet NET_LE = `!g:A->A->bool x x0 y y0.\n dorder g\n ==> (x --> x0)(mtop(mr1),g) /\\\n (y --> y0)(mtop(mr1),g) /\\\n (?N. g N N /\\ !n. g n N ==> x(n) <= y(n))\n ==> x0 <= y0`;;\n\nparse_as_infix (\"tends_num_real\",(12,\"right\"));;\n\nparse_as_infix (\"sums\",(12,\"right\"));;\n\nlet tends_num_real = new_definition(\n `x tends_num_real x0 <=> (x tends x0)(mtop(mr1), (>=) :num->num->bool)`);;\n\noverride_interface (\"-->\",`(tends_num_real)`);;\n\nlet SEQ = `!x x0. (x --> x0) <=>\n !e. &0 < e ==> ?N. !n. n >= N ==> abs(x(n) - x0) < e`;;\n\nlet SEQ_CONST = `!k. (\\x. k) --> k`;;\n\nlet SEQ_ADD = `!x x0 y y0. x --> x0 /\\ y --> y0 ==> (\\n. x(n) + y(n)) --> (x0 + y0)`;;\n\nlet SEQ_MUL = `!x x0 y y0. x --> x0 /\\ y --> y0 ==> (\\n. x(n) * y(n)) --> (x0 * y0)`;;\n\nlet SEQ_NEG = `!x x0. x --> x0 <=> (\\n. --(x n)) --> --x0`;;\n\nlet SEQ_INV = `!x x0. x --> x0 /\\ ~(x0 = &0) ==> (\\n. inv(x n)) --> inv x0`;;\n\nlet SEQ_SUB = `!x x0 y y0. x --> x0 /\\ y --> y0 ==> (\\n. x(n) - y(n)) --> (x0 - y0)`;;\n\nlet SEQ_DIV = `!x x0 y y0. x --> x0 /\\ y --> y0 /\\ ~(y0 = &0) ==>\n (\\n. x(n) / y(n)) --> (x0 / y0)`;;\n\nlet SEQ_UNIQ = `!x x1 x2. x --> x1 /\\ x --> x2 ==> (x1 = x2)`;;\n\nlet SEQ_NULL = `!s l. s --> l <=> (\\n. s(n) - l) --> &0`;;\n\nlet SEQ_SUM = `!f l m n.\n (!r. m <= r /\\ r < m + n ==> f r --> l r)\n ==> (\\k. sum(m,n) (\\r. f r k)) --> sum(m,n) l`;;\n\nlet SEQ_TRANSFORM = `!s t l N. (!n. N <= n ==> (s n = t n)) /\\ s --> l ==> t --> l`;;\n\nlet convergent = new_definition(\n `convergent f <=> ?l. f --> l`);;\n\nlet cauchy = new_definition(\n `cauchy f <=> !e. &0 < e ==>\n ?N:num. !m n. m >= N /\\ n >= N ==> abs(f(m) - f(n)) < e`);;\n\nlet lim = new_definition(\n `lim f = @l. f --> l`);;\n\nlet SEQ_LIM = `!f. convergent f <=> (f --> lim f)`;;\n\nlet subseq = new_definition(\n `subseq (f:num->num) <=> !m n. m < n ==> (f m) < (f n)`);;\n\nlet SUBSEQ_SUC = `!f. subseq f <=> !n. f(n) < f(SUC n)`;;\n\nlet mono = new_definition(\n `mono (f:num->real) <=>\n (!m n. m <= n ==> f(m) <= f(n)) \\/\n (!m n. m <= n ==> f(m) >= f(n))`);;\n\nlet MONO_SUC = `!f. mono f <=> (!n. f(SUC n) >= f(n)) \\/ (!n. f(SUC n) <= f(n))`;;\n\nlet MAX_LEMMA = `!s N. ?k. !n:num. n < N ==> abs(s n) < k`;;\n\nlet SEQ_BOUNDED = `!s. bounded(mr1, (>=)) s <=> ?k. !n:num. abs(s n) < k`;;\n\nlet SEQ_BOUNDED_2 = `!f k K. (!n:num. k <= f(n) /\\ f(n) <= K) ==> bounded(mr1, (>=)) f`;;\n\nlet SEQ_CBOUNDED = `!f. cauchy f ==> bounded(mr1, (>=)) f`;;\n\nlet SEQ_ICONV = `!f. bounded(mr1, (>=)) f /\\ (!m n. m >= n ==> f(m) >= f(n))\n ==> convergent f`;;\n\nlet SEQ_NEG_CONV = `!f. convergent f <=> convergent (\\n. --(f n))`;;\n\nlet SEQ_NEG_BOUNDED = `!f. bounded(mr1, (>=))(\\n:num. --(f n)) <=> bounded(mr1, (>=)) f`;;\n\nlet SEQ_BCONV = `!f. bounded(mr1, (>=)) f /\\ mono f ==> convergent f`;;\n\nlet SEQ_MONOSUB = `!s:num->real. ?f. subseq f /\\ mono(\\n.s(f n))`;;\n\nlet SEQ_SBOUNDED = `!s (f:num->num). bounded(mr1, (>=)) s ==> bounded(mr1, (>=)) (\\n. s(f n))`;;\n\nlet SEQ_SUBLE = `!f n. subseq f ==> n <= f(n)`;;\n\nlet SEQ_DIRECT = `!f. subseq f ==> !N1 N2. ?n. n >= N1 /\\ f(n) >= N2`;;\n\nlet SEQ_CAUCHY = `!f. cauchy f <=> convergent f`;;\n\nlet SEQ_LE = `!f g l m. f --> l /\\ g --> m /\\ (?N. !n. n >= N ==> f(n) <= g(n))\n ==> l <= m`;;\n\nlet SEQ_LE_0 = `!f g. f --> &0 /\\ (?N. !n. n >= N ==> abs(g n) <= abs(f n))\n ==> g --> &0`;;\n\nlet SEQ_SUC = `!f l. f --> l <=> (\\n. f(SUC n)) --> l`;;\n\nlet SEQ_ABS = `!f. (\\n. abs(f n)) --> &0 <=> f --> &0`;;\n\nlet SEQ_ABS_IMP = `!f l. f --> l ==> (\\n. abs(f n)) --> abs(l)`;;\n\nlet SEQ_INV0 = `!f. (!y. ?N. !n. n >= N ==> f(n) > y)\n ==> (\\n. inv(f n)) --> &0`;;\n\nlet SEQ_POWER_ABS = `!c. abs(c) < &1 ==> (\\n. abs(c) pow n) --> &0`;;\n\nlet SEQ_POWER = `!c. abs(c) < &1 ==> (\\n. c pow n) --> &0`;;\n\nlet SEQ_HARMONIC = `!a. (\\n. a / &n) --> &0`;;\n\nlet SEQ_SUBSEQ = `!f l. f --> l ==> !a b. ~(a = 0) ==> (\\n. f(a * n + b)) --> l`;;\n\nlet SEQ_POW = `!f l. (f --> l) ==> !n. (\\i. f(i) pow n) --> l pow n`;;\n\nlet NEST_LEMMA = `!f g. (!n. f(SUC n) >= f(n)) /\\\n (!n. g(SUC n) <= g(n)) /\\\n (!n. f(n) <= g(n)) ==>\n ?l m. l <= m /\\ ((!n. f(n) <= l) /\\ f --> l) /\\\n ((!n. m <= g(n)) /\\ g --> m)`;;\n\nlet NEST_LEMMA_UNIQ = `!f g. (!n. f(SUC n) >= f(n)) /\\\n (!n. g(SUC n) <= g(n)) /\\\n (!n. f(n) <= g(n)) /\\\n (\\n. f(n) - g(n)) --> &0 ==>\n ?l. ((!n. f(n) <= l) /\\ f --> l) /\\\n ((!n. l <= g(n)) /\\ g --> l)`;;\n\nlet BOLZANO_LEMMA = `!P. (!a b c. a <= b /\\ b <= c /\\ P(a,b) /\\ P(b,c) ==> P(a,c)) /\\\n (!x. ?d. &0 < d /\\ !a b. a <= x /\\ x <= b /\\ (b - a) < d ==> P(a,b))\n ==> !a b. a <= b ==> P(a,b)`;;\n\nlet BOLZANO_LEMMA_ALT = `!P. (!a b c. a <= b /\\ b <= c /\\ P a b /\\ P b c ==> P a c) /\\\n (!x. ?d. &0 < d /\\ (!a b. a <= x /\\ x <= b /\\ b - a < d ==> P a b))\n ==> !a b. a <= b ==> P a b`;;\n\nlet sums = new_definition\n `f sums s <=> (\\n. sum(0,n) f) --> s`;;\n\nlet summable = new_definition(\n `summable f <=> ?s. f sums s`);;\n\nlet suminf = new_definition(\n `suminf f = @s. f sums s`);;\n\nlet SUM_SUMMABLE = `!f l. f sums l ==> summable f`;;\n\nlet SUMMABLE_SUM = `!f. summable f ==> f sums (suminf f)`;;\n\nlet SUM_UNIQ = `!f x. f sums x ==> (x = suminf f)`;;\n\nlet SER_UNIQ = `!f x y. f sums x /\\ f sums y ==> (x = y)`;;\n\nlet SER_0 = `!f n. (!m. n <= m ==> (f(m) = &0)) ==>\n f sums (sum(0,n) f)`;;\n\nlet SER_POS_LE = `!f n. summable f /\\ (!m. n <= m ==> &0 <= f(m))\n ==> sum(0,n) f <= suminf f`;;\n\nlet SER_POS_LT = `!f n. summable f /\\ (!m. n <= m ==> &0 < f(m))\n ==> sum(0,n) f < suminf f`;;\n\nlet SER_GROUP = `!f k. summable f /\\ 0 < k ==>\n (\\n. sum(n * k,k) f) sums (suminf f)`;;\n\nlet SER_PAIR = `!f. summable f ==> (\\n. sum(2 * n,2) f) sums (suminf f)`;;\n\nlet SER_OFFSET = `!f. summable f ==> !k. (\\n. f(n + k)) sums (suminf f - sum(0,k) f)`;;\n\nlet SER_OFFSET_REV = `!f k. summable(\\n. f(n + k)) ==>\n f sums (sum(0,k) f) + suminf (\\n. f(n + k))`;;\n\nlet SER_POS_LT_PAIR = `!f n. summable f /\\\n (!d. &0 < (f(n + (2 * d))) +\n f(n + ((2 * d) + 1)))\n ==> sum(0,n) f < suminf f`;;\n\nlet SER_ADD = `!x x0 y y0. x sums x0 /\\ y sums y0 ==> (\\n. x(n) + y(n)) sums (x0 + y0)`;;\n\nlet SER_CMUL = `!x x0 c. x sums x0 ==> (\\n. c * x(n)) sums (c * x0)`;;\n\nlet SER_NEG = `!x x0. x sums x0 ==> (\\n. --(x n)) sums --x0`;;\n\nlet SER_SUB = `!x x0 y y0. x sums x0 /\\ y sums y0 ==> (\\n. x(n) - y(n)) sums (x0 - y0)`;;\n\nlet SER_CDIV = `!x x0 c. x sums x0 ==> (\\n. x(n) / c) sums (x0 / c)`;;\n\nlet SER_CAUCHY = `!f. summable f <=>\n !e. &0 < e ==> ?N. !m n. m >= N ==> abs(sum(m,n) f) < e`;;\n\nlet SER_ZERO = `!f. summable f ==> f --> &0`;;\n\nlet SER_COMPAR = `!f g. (?N. !n. n >= N ==> abs(f(n)) <= g(n)) /\\ summable g ==>\n summable f`;;\n\nlet SER_COMPARA = `!f g. (?N. !n. n >= N ==> abs(f(n)) <= g(n)) /\\ summable g ==>\n summable (\\k. abs(f k))`;;\n\nlet SER_LE = `!f g. (!n. f(n) <= g(n)) /\\ summable f /\\ summable g\n ==> suminf f <= suminf g`;;\n\nlet SER_LE2 = `!f g. (!n. abs(f n) <= g(n)) /\\ summable g ==>\n summable f /\\ suminf f <= suminf g`;;\n\nlet SER_ACONV = `!f. summable (\\n. abs(f n)) ==> summable f`;;\n\nlet SER_ABS = `!f. summable(\\n. abs(f n)) ==> abs(suminf f) <= suminf(\\n. abs(f n))`;;\n\nlet GP_FINITE = `!x. ~(x = &1) ==>\n !n. (sum(0,n) (\\n. x pow n) = ((x pow n) - &1) / (x - &1))`;;\n\nlet GP = `!x. abs(x) < &1 ==> (\\n. x pow n) sums inv(&1 - x)`;;\n\nlet ABS_NEG_LEMMA = `!c x y. c <= &0 ==> abs(x) <= c * abs(y) ==> (x = &0)`;;\n\nlet SER_RATIO = `!f c N. c < &1 /\\\n (!n. n >= N ==> abs(f(SUC n)) <= c * abs(f(n))) ==>\n summable f`;;\n\nlet SEQ_TRUNCATION = `!f l n b.\n f sums l /\\ (!m. abs(sum(n,m) f) <= b)\n ==> abs(l - sum(0,n) f) <= b`;;\n\nparse_as_infix (\"tends_real_real\",(12,\"right\"));;\n\nparse_as_infix (\"diffl\",(12,\"right\"));;\nparse_as_infix (\"contl\",(12,\"right\"));;\nparse_as_infix (\"differentiable\",(12,\"right\"));;\n\nlet tends_real_real = new_definition\n `(f tends_real_real l)(x0) <=>\n (f tends l)(mtop(mr1),tendsto(mr1,x0))`;;\n\noverride_interface (\"-->\",`(tends_real_real)`);;\n\nlet LIM = `!f y0 x0. (f --> y0)(x0) <=>\n !e. &0 < e ==>\n ?d. &0 < d /\\ !x. &0 < abs(x - x0) /\\ abs(x - x0) < d ==>\n abs(f(x) - y0) < e`;;\n\nlet LIM_CONST = `!k x. ((\\x. k) --> k)(x)`;;\n\nlet LIM_ADD = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) ==>\n ((\\x. f(x) + g(x)) --> (l + m))(x)`;;\n\nlet LIM_MUL = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) ==>\n ((\\x. f(x) * g(x)) --> (l * m))(x)`;;\n\nlet LIM_NEG = `!f l. (f --> l)(x) <=> ((\\x. --(f(x))) --> --l)(x)`;;\n\nlet LIM_INV = `!f l. (f --> l)(x) /\\ ~(l = &0) ==>\n ((\\x. inv(f(x))) --> inv l)(x)`;;\n\nlet LIM_SUB = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) ==>\n ((\\x. f(x) - g(x)) --> (l - m))(x)`;;\n\nlet LIM_DIV = `!f g l m. (f --> l)(x) /\\ (g --> m)(x) /\\ ~(m = &0) ==>\n ((\\x. f(x) / g(x)) --> (l / m))(x)`;;\n\nlet LIM_NULL = `!f l x. (f --> l)(x) <=> ((\\x. f(x) - l) --> &0)(x)`;;\n\nlet LIM_SUM = `!f l m n x.\n (!r. m <= r /\\ r < m + n ==> (f r --> l r)(x))\n ==> ((\\x. sum(m,n) (\\r. f r x)) --> sum(m,n) l)(x)`;;\n\nlet LIM_X = `!x0. ((\\x. x) --> x0)(x0)`;;\n\nlet LIM_UNIQ = `!f l m x. (f --> l)(x) /\\ (f --> m)(x) ==> (l = m)`;;\n\nlet LIM_EQUAL = `!f g l x0. (!x. ~(x = x0) ==> (f x = g x)) ==>\n ((f --> l)(x0) <=> (g --> l)(x0))`;;\n\nlet LIM_TRANSFORM = `!f g x0 l. ((\\x. f(x) - g(x)) --> &0)(x0) /\\ (g --> l)(x0)\n ==> (f --> l)(x0)`;;\n\nlet diffl = new_definition\n `(f diffl l)(x) <=> ((\\h. (f(x+h) - f(x)) / h) --> l)(&0)`;;\n\nlet contl = new_definition\n `f contl x <=> ((\\h. f(x + h)) --> f(x))(&0)`;;\n\nlet differentiable = new_definition\n `f differentiable x <=> ?l. (f diffl l)(x)`;;\n\nlet DIFF_UNIQ = `!f l m x. (f diffl l)(x) /\\ (f diffl m)(x) ==> (l = m)`;;\n\nlet DIFF_CONT = `!f l x. (f diffl l)(x) ==> f contl x`;;\n\nlet CONTL_LIM = `!f x. f contl x <=> (f --> f(x))(x)`;;\n\nlet CONT_X = `!x. (\\x. x) contl x`;;\n\nlet CONT_CONST = `!x. (\\x. k) contl x`;;\n\nlet CONT_ADD = `!x. f contl x /\\ g contl x ==> (\\x. f(x) + g(x)) contl x`;;\n\nlet CONT_MUL = `!x. f contl x /\\ g contl x ==> (\\x. f(x) * g(x)) contl x`;;\n\nlet CONT_NEG = `!x. f contl x ==> (\\x. --(f(x))) contl x`;;\n\nlet CONT_INV = `!x. f contl x /\\ ~(f x = &0) ==> (\\x. inv(f(x))) contl x`;;\n\nlet CONT_SUB = `!x. f contl x /\\ g contl x ==> (\\x. f(x) - g(x)) contl x`;;\n\nlet CONT_DIV = `!x. f contl x /\\ g contl x /\\ ~(g x = &0) ==>\n (\\x. f(x) / g(x)) contl x`;;\n\nlet CONT_ABS = `!f x. f contl x ==> (\\x. abs(f x)) contl x`;;\n\nlet CONT_COMPOSE = `!f g x. f contl x /\\ g contl (f x) ==> (\\x. g(f x)) contl x`;;\n\nlet IVT = `!f a b y. a <= b /\\\n (f(a) <= y /\\ y <= f(b)) /\\\n (!x. a <= x /\\ x <= b ==> f contl x)\n ==> (?x. a <= x /\\ x <= b /\\ (f(x) = y))`;;\n\nlet IVT2 = `!f a b y. (a <= b) /\\ (f(b) <= y /\\ y <= f(a)) /\\\n (!x. a <= x /\\ x <= b ==> f contl x) ==>\n ?x. a <= x /\\ x <= b /\\ (f(x) = y)`;;\n\nlet DIFF_CONST = `!k x. ((\\x. k) diffl &0)(x)`;;\n\nlet DIFF_ADD = `!f g l m x. (f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) + g(x)) diffl (l + m))(x)`;;\n\nlet DIFF_MUL = `!f g l m x. (f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) * g(x)) diffl ((l * g(x)) + (m * f(x))))(x)`;;\n\nlet DIFF_CMUL = `!f c l x. (f diffl l)(x) ==> ((\\x. c * f(x)) diffl (c * l))(x)`;;\n\nlet DIFF_NEG = `!f l x. (f diffl l)(x) ==> ((\\x. --(f x)) diffl --l)(x)`;;\n\nlet DIFF_SUB = `!f g l m x. (f diffl l)(x) /\\ (g diffl m)(x) ==>\n ((\\x. f(x) - g(x)) diffl (l - m))(x)`;;\n\nlet DIFF_CARAT = `!f l x. (f diffl l)(x) <=>\n ?g. (!z. f(z) - f(x) = g(z) * (z - x)) /\\ g contl x /\\ (g(x) = l)`;;\n\nlet DIFF_CHAIN = `!f g l m x.\n (f diffl l)(g x) /\\ (g diffl m)(x) ==> ((\\x. f(g x)) diffl (l * m))(x)`;;\n\nlet DIFF_X = `!x. ((\\x. x) diffl &1)(x)`;;\n\nlet DIFF_POW = `!n x. ((\\x. x pow n) diffl (&n * (x pow (n - 1))))(x)`;;\n\nlet DIFF_XM1 = `!x. ~(x = &0) ==> ((\\x. inv(x)) diffl (--(inv(x) pow 2)))(x)`;;\n\nlet DIFF_INV = `!f l x. (f diffl l)(x) /\\ ~(f(x) = &0) ==>\n ((\\x. inv(f x)) diffl --(l / (f(x) pow 2)))(x)`;;\n\nlet DIFF_DIV = `!f g l m. (f diffl l)(x) /\\ (g diffl m)(x) /\\ ~(g(x) = &0) ==>\n ((\\x. f(x) / g(x)) diffl (((l * g(x)) - (m * f(x))) / (g(x) pow 2)))(x)`;;\n\nlet DIFF_SUM = `!f f' m n x. (!r. m <= r /\\ r < (m + n)\n ==> ((\\x. f r x) diffl (f' r x))(x))\n ==> ((\\x. sum(m,n)(\\n. f n x)) diffl (sum(m,n) (\\r. f' r x)))(x)`;;\n\nlet CONT_BOUNDED = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. !x. a <= x /\\ x <= b ==> f(x) <= M`;;\n\nlet CONT_BOUNDED_ABS = `!f a b. (!x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. !x. a <= x /\\ x <= b ==> abs(f(x)) <= M`;;\n\nlet CONT_HASSUP = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. (!x. a <= x /\\ x <= b ==> f(x) <= M) /\\\n (!N. N < M ==> ?x. a <= x /\\ x <= b /\\ N < f(x))`;;\n\nlet CONT_ATTAINS = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. (!x. a <= x /\\ x <= b ==> f(x) <= M) /\\\n (?x. a <= x /\\ x <= b /\\ (f(x) = M))`;;\n\nlet CONT_ATTAINS2 = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?M. (!x. a <= x /\\ x <= b ==> M <= f(x)) /\\\n (?x. a <= x /\\ x <= b /\\ (f(x) = M))`;;\n\nlet CONT_ATTAINS_ALL = `!f a b. (a <= b /\\ !x. a <= x /\\ x <= b ==> f contl x)\n ==> ?L M. (!x. a <= x /\\ x <= b ==> L <= f(x) /\\ f(x) <= M) /\\\n !y. L <= y /\\ y <= M ==> ?x. a <= x /\\ x <= b /\\ (f(x) = y)`;;\n\nlet DIFF_LINC = `!f x l. (f diffl l)(x) /\\ &0 < l ==>\n ?d. &0 < d /\\ !h. &0 < h /\\ h < d ==> f(x) < f(x + h)`;;\n\nlet DIFF_LDEC = `!f x l. (f diffl l)(x) /\\ l < &0 ==>\n ?d. &0 < d /\\ !h. &0 < h /\\ h < d ==> f(x) < f(x - h)`;;\n\nlet DIFF_LMAX = `!f x l. (f diffl l)(x) /\\\n (?d. &0 < d /\\ (!y. abs(x - y) < d ==> f(y) <= f(x))) ==> (l = &0)`;;\n\nlet DIFF_LMIN = `!f x l. (f diffl l)(x) /\\\n (?d. &0 < d /\\ (!y. abs(x - y) < d ==> f(x) <= f(y))) ==> (l = &0)`;;\n\nlet DIFF_LCONST = `!f x l. (f diffl l)(x) /\\\n (?d. &0 < d /\\ (!y. abs(x - y) < d ==> (f(y) = f(x)))) ==> (l = &0)`;;\n\nlet INTERVAL_LEMMA_LT = `!a b x. a < x /\\ x < b ==>\n ?d. &0 < d /\\ !y. abs(x - y) < d ==> a < y /\\ y < b`;;\n\nlet INTERVAL_LEMMA = `!a b x. a < x /\\ x < b ==>\n ?d. &0 < d /\\ !y. abs(x - y) < d ==> a <= y /\\ y <= b`;;\n\nlet ROLLE = `!f a b. a < b /\\\n (f(a) = f(b)) /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> f differentiable x)\n ==> ?z. a < z /\\ z < b /\\ (f diffl &0)(z)`;;\n\nlet MVT_LEMMA = `!(f:real->real) a b.\n (\\x. f(x) - (((f(b) - f(a)) / (b - a)) * x))(a) =\n (\\x. f(x) - (((f(b) - f(a)) / (b - a)) * x))(b)`;;\n\nlet MVT = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> f differentiable x)\n ==> ?l z. a < z /\\ z < b /\\ (f diffl l)(z) /\\\n (f(b) - f(a) = (b - a) * l)`;;\n\nlet MVT_ALT = `!f f' a b.\n a < b /\\ (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x))\n ==> ?z. a < z /\\ z < b /\\ (f b - f a = (b - a) * f'(z))`;;\n\nlet DIFF_ISCONST_END = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> (f diffl &0)(x))\n ==> (f b = f a)`;;\n\nlet DIFF_ISCONST = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> f contl x) /\\\n (!x. a < x /\\ x < b ==> (f diffl &0)(x))\n ==> !x. a <= x /\\ x <= b ==> (f x = f a)`;;\n\nlet DIFF_ISCONST_END_SIMPLE = `!f a b. a < b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl &0)(x))\n ==> (f b = f a)`;;\n\nlet DIFF_ISCONST_ALL = `!f x y. (!x. (f diffl &0)(x)) ==> (f(x) = f(y))`;;\n\nlet INTERVAL_ABS = REAL_ARITH\n `!x z d. (x - d) <= z /\\ z <= (x + d) <=> abs(z - x) <= d`;;\n\nlet CONT_INJ_LEMMA = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) ==>\n ~(!z. abs(z - x) <= d ==> f(z) <= f(x))`;;\n\nlet CONT_INJ_LEMMA2 = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) ==>\n ~(!z. abs(z - x) <= d ==> f(x) <= f(z))`;;\n\nlet CONT_INJ_RANGE = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) ==>\n ?e. &0 < e /\\\n (!y. abs(y - f(x)) <= e ==> ?z. abs(z - x) <= d /\\ (f z = y))`;;\n\nlet CONT_INVERSE = `!f g x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z)\n ==> g contl (f x)`;;\n\nlet DIFF_INVERSE = `!f g l x d. &0 < d /\\\n (!z. abs(z - x) <= d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) <= d ==> f contl z) /\\\n (f diffl l)(x) /\\\n ~(l = &0)\n ==> (g diffl (inv l))(f x)`;;\n\nlet DIFF_INVERSE_LT = `!f g l x d. &0 < d /\\\n (!z. abs(z - x) < d ==> (g(f(z)) = z)) /\\\n (!z. abs(z - x) < d ==> f contl z) /\\\n (f diffl l)(x) /\\\n ~(l = &0)\n ==> (g diffl (inv l))(f x)`;;\n\nlet IVT_DERIVATIVE_0 = `!f f' a b.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n f'(a) > &0 /\\ f'(b) < &0\n ==> ?z. a < z /\\ z < b /\\ (f'(z) = &0)`;;\n\nlet IVT_DERIVATIVE_POS = `!f f' a b y.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n f'(a) > y /\\ f'(b) < y\n ==> ?z. a < z /\\ z < b /\\ (f'(z) = y)`;;\n\nlet IVT_DERIVATIVE_NEG = `!f f' a b y.\n a <= b /\\\n (!x. a <= x /\\ x <= b ==> (f diffl f'(x))(x)) /\\\n f'(a) < y /\\ f'(b) > y\n ==> ?z. a < z /\\ z < b /\\ (f'(z) = y)`;;\n\nlet SEQ_CONT_UNIFORM = `!s f x0. (!e. &0 < e\n ==> ?N d. &0 < d /\\\n !x n. abs(x - x0) < d /\\ n >= N\n ==> abs(s n x - f(x)) < e) /\\\n (?N:num. !n. n >= N ==> (s n) contl x0)\n ==> f contl x0`;;\n\nlet SER_COMPARA_UNIFORM = `!s x0 g.\n (?N d. &0 < d /\\\n !n x. abs(x - x0) < d /\\ n >= N\n ==> abs(s x n) <= g n) /\\ summable g\n ==> ?f d. &0 < d /\\\n !e. &0 < e\n ==> ?N. !x n. abs(x - x0) < d /\\ n >= N\n ==> abs(sum(0,n) (s x) - f(x)) < e`;;\n\nlet SER_COMPARA_UNIFORM_WEAK = `!s x0 g.\n (?N d. &0 < d /\\\n !n x. abs(x - x0) < d /\\ n >= N\n ==> abs(s x n) <= g n) /\\ summable g\n ==> ?f. !e. &0 < e\n ==> ?N d. &0 < d /\\\n !x n. abs(x - x0) < d /\\ n >= N\n ==> abs(sum(0,n) (s x) - f(x)) < e`;;\n\nlet CONTL = `!f x. f contl x <=>\n !e. &0 < e ==> ?d. &0 < d /\\ !x'. abs(x' - x) < d\n ==> abs(f(x') - f(x)) < e`;;\n\nlet CONTL_SEQ = `!f x l. f contl l /\\ x tends_num_real l\n\n ==> (\\n. f(x n)) tends_num_real f(l)`;;\n\nlet SUP_INTERVAL = `!P a b.\n (?x. a <= x /\\ x <= b /\\ P x)\n ==> ?s. a <= s /\\ s <= b /\\\n !y. y < s <=> (?x. a <= x /\\ x <= b /\\ P x /\\ y < x)`;;\n\nlet CONT_UNIFORM = `!f a b. a <= b /\\ (!x. a <= x /\\ x <= b ==> f contl x)\n ==> !e. &0 < e ==> ?d. &0 < d /\\\n !x y. a <= x /\\ x <= b /\\\n a <= y /\\ y <= b /\\\n abs(x - y) < d\n ==> abs(f(x) - f(y)) < e`;;\n\nlet CONT_UNIFORM_STRONG = `!f a b. (!x. a <= x /\\ x <= b ==> f contl x)\n ==> !e. &0 < e\n ==> ?d. &0 < d /\\\n !x y. (a <= x /\\ x <= b \\/ a <= y /\\ y <= b) /\\\n abs(x - y) < d\n ==> abs(f(x) - f(y)) < e`;;\n\nremove_interface \"-->\";;" }, { "theorem_id": 62, "title": "079_the_intermediate_value_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "chapter \\Vector Analysis\\\n\ntheory Topology_Euclidean_Space\n imports\n Elementary_Normed_Spaces\n Linear_Algebra\n Norm_Arith\nbegin\n\nsection \\Elementary Topology in Euclidean Space\\\n\nlemma euclidean_dist_l2:\n fixes x y :: \"'a :: euclidean_space\"\n shows \"dist x y = L2_set (\\i. dist (x \\ i) (y \\ i)) Basis\"\n by sorry\n\nlemma norm_nth_le: \"norm (x \\ i) \\ norm x\" if \"i \\ Basis\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Continuity of the representation WRT an orthogonal basis\\\n\nlemma orthogonal_Basis: \"pairwise orthogonal Basis\"\n by sorry\n\nlemma representation_bound:\n fixes B :: \"'N::real_inner set\"\n assumes \"finite B\" \"independent B\" \"b \\ B\" and orth: \"pairwise orthogonal B\"\n obtains m where \"m > 0\" \"\\x. x \\ span B \\ \\representation B x b\\ \\ m * norm x\"\n by sorry\n\nlemma continuous_on_representation:\n fixes B :: \"'N::euclidean_space set\"\n assumes \"finite B\" \"independent B\" \"b \\ B\" \"pairwise orthogonal B\" \n shows \"continuous_on (span B) (\\x. representation B x b)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Balls in Euclidean Space\\\n\nlemma cball_subset_cball_iff:\n fixes a :: \"'a :: euclidean_space\"\n shows \"cball a r \\ cball a' r' \\ dist a a' + r \\ r' \\ r < 0\"\n (is \"?lhs \\ ?rhs\")\n by sorry\n\nlemma cball_subset_ball_iff: \"cball a r \\ ball a' r' \\ dist a a' + r < r' \\ r < 0\"\n (is \"?lhs \\ ?rhs\")\n for a :: \"'a::euclidean_space\"\n by sorry\n\nlemma ball_subset_cball_iff: \"ball a r \\ cball a' r' \\ dist a a' + r \\ r' \\ r \\ 0\"\n (is \"?lhs = ?rhs\")\n for a :: \"'a::euclidean_space\"\n by sorry\n\nlemma ball_subset_ball_iff:\n fixes a :: \"'a :: euclidean_space\"\n shows \"ball a r \\ ball a' r' \\ dist a a' + r \\ r' \\ r \\ 0\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma ball_eq_ball_iff:\n fixes x :: \"'a :: euclidean_space\"\n shows \"ball x d = ball y e \\ d \\ 0 \\ e \\ 0 \\ x=y \\ d=e\"\n by sorry\n\nlemma cball_eq_cball_iff:\n fixes x :: \"'a :: euclidean_space\"\n shows \"cball x d = cball y e \\ d < 0 \\ e < 0 \\ x=y \\ d=e\"\n by sorry\n\nlemma ball_eq_cball_iff:\n fixes x :: \"'a :: euclidean_space\"\n shows \"ball x d = cball y e \\ d \\ 0 \\ e < 0\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma cball_eq_ball_iff:\n fixes x :: \"'a :: euclidean_space\"\n shows \"cball x d = ball y e \\ d < 0 \\ e \\ 0\"\n by sorry\n\nlemma finite_ball_avoid:\n fixes S :: \"'a :: euclidean_space set\"\n assumes \"open S\" \"finite X\" \"p \\ S\"\n shows \"\\e>0. \\w\\ball p e. w\\S \\ (w\\p \\ w\\X)\"\n by sorry\n\nlemma finite_cball_avoid:\n fixes S :: \"'a :: euclidean_space set\"\n assumes \"open S\" \"finite X\" \"p \\ S\"\n shows \"\\e>0. \\w\\cball p e. w\\S \\ (w\\p \\ w\\X)\"\n by sorry\n\nlemma dim_cball:\n assumes \"e > 0\"\n shows \"dim (cball (0 :: 'n::euclidean_space) e) = DIM('n)\"\n by sorry\n\nsubsection \\Boxes\\\n\nabbreviation\\<^marker>\\tag important\\ One :: \"'a::euclidean_space\" where\n\"One \\ \\Basis\"\n\nlemma One_non_0: assumes \"One = (0::'a::euclidean_space)\" shows False\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ One_neq_0[iff]: \"One \\ 0\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ Zero_neq_One[iff]: \"0 \\ One\"\n by sorry\n\ndefinition\\<^marker>\\tag important\\ (in euclidean_space) eucl_less (infix \\ 50) where \n\"eucl_less a b \\ (\\i\\Basis. a \\ i < b \\ i)\"\n\ndefinition\\<^marker>\\tag important\\ box_eucl_less: \"box a b = {x. a x \\tag important\\ \"cbox a b = {x. \\i\\Basis. a \\ i \\ x \\ i \\ x \\ i \\ b \\ i}\"\n\nlemma box_def: \"box a b = {x. \\i\\Basis. a \\ i < x \\ i \\ x \\ i < b \\ i}\"\n and in_box_eucl_less: \"x \\ box a b \\ a x box a b \\ (\\i\\Basis. a \\ i < x \\ i \\ x \\ i < b \\ i)\"\n \"x \\ cbox a b \\ (\\i\\Basis. a \\ i \\ x \\ i \\ x \\ i \\ b \\ i)\"\n by sorry\n\nlemma cbox_Pair_eq: \"cbox (a, c) (b, d) = cbox a b \\ cbox c d\"\n by sorry\n\nlemma cbox_Pair_iff [iff]: \"(x, y) \\ cbox (a, c) (b, d) \\ x \\ cbox a b \\ y \\ cbox c d\"\n by sorry\n\nlemma cbox_Complex_eq: \"cbox (Complex a c) (Complex b d) = (\\(x,y). Complex x y) ` (cbox a b \\ cbox c d)\"\n by sorry\n\nlemma cbox_Pair_eq_0: \"cbox (a, c) (b, d) = {} \\ cbox a b = {} \\ cbox c d = {}\"\n by sorry\n\nlemma swap_cbox_Pair [simp]: \"prod.swap ` cbox (c, a) (d, b) = cbox (a,c) (b,d)\"\n by sorry\n\nlemma mem_box_real[simp]:\n \"(x::real) \\ box a b \\ a < x \\ x < b\"\n \"(x::real) \\ cbox a b \\ a \\ x \\ x \\ b\"\n by sorry\n\nlemma box_real[simp]:\n fixes a b:: real\n shows \"box a b = {a <..< b}\" \"cbox a b = {a .. b}\"\n by sorry\n\nlemma box_Int_box:\n fixes a :: \"'a::euclidean_space\"\n shows \"box a b \\ box c d =\n box (\\i\\Basis. max (a\\i) (c\\i) *\\<^sub>R i) (\\i\\Basis. min (b\\i) (d\\i) *\\<^sub>R i)\"\n by sorry\n\nlemma cbox_prod: \"cbox a b = cbox (fst a) (fst b) \\ cbox (snd a) (snd b)\"\n by sorry\n\nlemma box_prod: \"box a b = box (fst a) (fst b) \\ box (snd a) (snd b)\"\n by sorry\n\nlemma rational_boxes:\n fixes x :: \"'a::euclidean_space\"\n assumes \"e > 0\"\n shows \"\\a b. (\\i\\Basis. a \\ i \\ \\ \\ b \\ i \\ \\) \\ x \\ box a b \\ box a b \\ ball x e\"\n by sorry\n\nlemma open_UNION_box:\n fixes M :: \"'a::euclidean_space set\"\n assumes \"open M\"\n defines \"a' \\ \\f :: 'a \\ real \\ real. (\\(i::'a)\\Basis. fst (f i) *\\<^sub>R i)\"\n defines \"b' \\ \\f :: 'a \\ real \\ real. (\\(i::'a)\\Basis. snd (f i) *\\<^sub>R i)\"\n defines \"I \\ {f\\Basis \\\\<^sub>E \\ \\ \\. box (a' f) (b' f) \\ M}\"\n shows \"M = (\\f\\I. box (a' f) (b' f))\"\n by sorry\n\ncorollary open_countable_Union_open_box:\n fixes S :: \"'a :: euclidean_space set\"\n assumes \"open S\"\n obtains \\ where \"countable \\\" \"\\ \\ Pow S\" \"\\X. X \\ \\ \\ \\a b. X = box a b\" \"\\\\ = S\"\n by sorry\n\nlemma rational_cboxes:\n fixes x :: \"'a::euclidean_space\"\n assumes \"e > 0\"\n shows \"\\a b. (\\i\\Basis. a \\ i \\ \\ \\ b \\ i \\ \\) \\ x \\ cbox a b \\ cbox a b \\ ball x e\"\n by sorry\n\nlemma open_UNION_cbox:\n fixes M :: \"'a::euclidean_space set\"\n assumes \"open M\"\n defines \"a' \\ \\f. (\\(i::'a)\\Basis. fst (f i) *\\<^sub>R i)\"\n defines \"b' \\ \\f. (\\(i::'a)\\Basis. snd (f i) *\\<^sub>R i)\"\n defines \"I \\ {f\\Basis \\\\<^sub>E \\ \\ \\. cbox (a' f) (b' f) \\ M}\"\n shows \"M = (\\f\\I. cbox (a' f) (b' f))\"\n by sorry\n\ncorollary open_countable_Union_open_cbox:\n fixes S :: \"'a :: euclidean_space set\"\n assumes \"open S\"\n obtains \\ where \"countable \\\" \"\\ \\ Pow S\" \"\\X. X \\ \\ \\ \\a b. X = cbox a b\" \"\\\\ = S\"\n by sorry\n\nlemma box_eq_empty:\n fixes a :: \"'a::euclidean_space\"\n shows \"(box a b = {} \\ (\\i\\Basis. b\\i \\ a\\i))\" (is ?th1)\n and \"(cbox a b = {} \\ (\\i\\Basis. b\\i < a\\i))\" (is ?th2)\n by sorry\n\nlemma box_ne_empty:\n fixes a :: \"'a::euclidean_space\"\n shows \"cbox a b \\ {} \\ (\\i\\Basis. a\\i \\ b\\i)\"\n and \"box a b \\ {} \\ (\\i\\Basis. a\\i < b\\i)\"\n by sorry\n\nlemma\n fixes a :: \"'a::euclidean_space\"\n shows cbox_idem [simp]: \"cbox a a = {a}\"\n and box_idem [simp]: \"box a a = {}\"\n by sorry\n\nlemma subset_box_imp:\n fixes a :: \"'a::euclidean_space\"\n shows \"(\\i\\Basis. a\\i \\ c\\i \\ d\\i \\ b\\i) \\ cbox c d \\ cbox a b\"\n and \"(\\i\\Basis. a\\i < c\\i \\ d\\i < b\\i) \\ cbox c d \\ box a b\"\n and \"(\\i\\Basis. a\\i \\ c\\i \\ d\\i \\ b\\i) \\ box c d \\ cbox a b\"\n and \"(\\i\\Basis. a\\i \\ c\\i \\ d\\i \\ b\\i) \\ box c d \\ box a b\"\n by sorry\n\nlemma box_subset_cbox:\n fixes a :: \"'a::euclidean_space\"\n shows \"box a b \\ cbox a b\"\n by sorry\n\nlemma subset_box:\n fixes a :: \"'a::euclidean_space\"\n shows \"cbox c d \\ cbox a b \\ (\\i\\Basis. c\\i \\ d\\i) \\ (\\i\\Basis. a\\i \\ c\\i \\ d\\i \\ b\\i)\" (is ?th1)\n and \"cbox c d \\ box a b \\ (\\i\\Basis. c\\i \\ d\\i) \\ (\\i\\Basis. a\\i < c\\i \\ d\\i < b\\i)\" (is ?th2)\n and \"box c d \\ cbox a b \\ (\\i\\Basis. c\\i < d\\i) \\ (\\i\\Basis. a\\i \\ c\\i \\ d\\i \\ b\\i)\" (is ?th3)\n and \"box c d \\ box a b \\ (\\i\\Basis. c\\i < d\\i) \\ (\\i\\Basis. a\\i \\ c\\i \\ d\\i \\ b\\i)\" (is ?th4)\n by sorry\n\nlemma eq_cbox: \"cbox a b = cbox c d \\ cbox a b = {} \\ cbox c d = {} \\ a = c \\ b = d\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma eq_cbox_box [simp]: \"cbox a b = box c d \\ cbox a b = {} \\ box c d = {}\"\n (is \"?lhs \\ ?rhs\")\n by sorry\n\nlemma eq_box_cbox [simp]: \"box a b = cbox c d \\ box a b = {} \\ cbox c d = {}\"\n by sorry\n\nlemma eq_box: \"box a b = box c d \\ box a b = {} \\ box c d = {} \\ a = c \\ b = d\"\n (is \"?lhs \\ ?rhs\")\n by sorry\n\nlemma subset_box_complex:\n \"cbox a b \\ cbox c d \\\n (Re a \\ Re b \\ Im a \\ Im b) \\ Re a \\ Re c \\ Im a \\ Im c \\ Re b \\ Re d \\ Im b \\ Im d\"\n \"cbox a b \\ box c d \\\n (Re a \\ Re b \\ Im a \\ Im b) \\ Re a > Re c \\ Im a > Im c \\ Re b < Re d \\ Im b < Im d\"\n \"box a b \\ cbox c d \\\n (Re a < Re b \\ Im a < Im b) \\ Re a \\ Re c \\ Im a \\ Im c \\ Re b \\ Re d \\ Im b \\ Im d\"\n \"box a b \\ box c d \\\n (Re a < Re b \\ Im a < Im b) \\ Re a \\ Re c \\ Im a \\ Im c \\ Re b \\ Re d \\ Im b \\ Im d\"\n by sorry\n\nlemma in_cbox_complex_iff:\n \"x \\ cbox a b \\ Re x \\ {Re a..Re b} \\ Im x \\ {Im a..Im b}\"\n by sorry\n\nlemma cbox_complex_of_real: \"cbox (complex_of_real x) (complex_of_real y) = complex_of_real ` {x..y}\"\n by sorry\n\nlemma box_Complex_eq:\n \"box (Complex a c) (Complex b d) = (\\(x,y). Complex x y) ` (box a b \\ box c d)\"\n by sorry\n\nlemma in_box_complex_iff:\n \"x \\ box a b \\ Re x \\ {Re a<.. Im x \\ {Im a<.. {Re a..Re b} \\ Im x \\ {Im a..Im b}}\"\n by sorry\n\nlemma box_complex_eq: \"box a b = {x. Re x \\ {Re a<.. Im x \\ {Im a<.. cbox c d =\n cbox (\\i\\Basis. max (a\\i) (c\\i) *\\<^sub>R i) (\\i\\Basis. min (b\\i) (d\\i) *\\<^sub>R i)\"\n by sorry\n\nlemma disjoint_interval:\n fixes a::\"'a::euclidean_space\"\n shows \"cbox a b \\ cbox c d = {} \\ (\\i\\Basis. (b\\i < a\\i \\ d\\i < c\\i \\ b\\i < c\\i \\ d\\i < a\\i))\" (is ?th1)\n and \"cbox a b \\ box c d = {} \\ (\\i\\Basis. (b\\i < a\\i \\ d\\i \\ c\\i \\ b\\i \\ c\\i \\ d\\i \\ a\\i))\" (is ?th2)\n and \"box a b \\ cbox c d = {} \\ (\\i\\Basis. (b\\i \\ a\\i \\ d\\i < c\\i \\ b\\i \\ c\\i \\ d\\i \\ a\\i))\" (is ?th3)\n and \"box a b \\ box c d = {} \\ (\\i\\Basis. (b\\i \\ a\\i \\ d\\i \\ c\\i \\ b\\i \\ c\\i \\ d\\i \\ a\\i))\" (is ?th4)\n by sorry\n\nlemma UN_box_eq_UNIV: \"(\\i::nat. box (- (real i *\\<^sub>R One)) (real i *\\<^sub>R One)) = UNIV\"\n by sorry\n\nlemma cbox_shift: \"(+) c ` cbox a b = cbox (a + c) (b + c)\"\n by sorry\n\nlemma cbox_shift': \"(\\x. x + c) ` cbox a b = cbox (a + c) (b + c)\"\n by sorry\n\nlemma cbox_shift'': \"(\\x. x - c) ` cbox a b = cbox (a - c) (b - c)\"\n by sorry\n\nlemma image_affinity_cbox: fixes m::real\n fixes a b c :: \"'a::euclidean_space\"\n shows \"(\\x. m *\\<^sub>R x + c) ` cbox a b =\n (if cbox a b = {} then {}\n else (if 0 \\ m then cbox (m *\\<^sub>R a + c) (m *\\<^sub>R b + c)\n else cbox (m *\\<^sub>R b + c) (m *\\<^sub>R a + c)))\"\n by sorry\n\nlemma image_smult_cbox:\"(\\x. m *\\<^sub>R (x::_::euclidean_space)) ` cbox a b =\n (if cbox a b = {} then {} else if 0 \\ m then cbox (m *\\<^sub>R a) (m *\\<^sub>R b) else cbox (m *\\<^sub>R b) (m *\\<^sub>R a))\"\n by sorry\n\nlemma swap_continuous:\n assumes \"continuous_on (cbox (a,c) (b,d)) (\\(x,y). f x y)\"\n shows \"continuous_on (cbox (c,a) (d,b)) (\\(x, y). f y x)\"\n by sorry\n\nlemma open_contains_cbox:\n fixes x :: \"'a :: euclidean_space\"\n assumes \"open A\" \"x \\ A\"\n obtains a b where \"cbox a b \\ A\" \"x \\ box a b\" \"\\i\\Basis. a \\ i < b \\ i\"\n by sorry\n\nlemma open_contains_box:\n fixes x :: \"'a :: euclidean_space\"\n assumes \"open A\" \"x \\ A\"\n obtains a b where \"box a b \\ A\" \"x \\ box a b\" \"\\i\\Basis. a \\ i < b \\ i\"\n by sorry\n\nlemma inner_image_box:\n assumes \"(i :: 'a :: euclidean_space) \\ Basis\"\n assumes \"\\i\\Basis. a \\ i < b \\ i\"\n shows \"(\\x. x \\ i) ` box a b = {a \\ i<.. i}\"\n by sorry\n\nlemma inner_image_cbox:\n assumes \"(i :: 'a :: euclidean_space) \\ Basis\"\n assumes \"\\i\\Basis. a \\ i \\ b \\ i\"\n shows \"(\\x. x \\ i) ` cbox a b = {a \\ i..b \\ i}\"\n by sorry\n\nsubsection \\General Intervals\\\n\ndefinition\\<^marker>\\tag important\\ \"is_interval (s::('a::euclidean_space) set) \\\n (\\a\\s. \\b\\s. \\x. (\\i\\Basis. ((a\\i \\ x\\i \\ x\\i \\ b\\i) \\ (b\\i \\ x\\i \\ x\\i \\ a\\i))) \\ x \\ s)\"\n\nlemma is_interval_1:\n \"is_interval (s::real set) \\ (\\a\\s. \\b\\s. \\ x. a \\ x \\ x \\ b \\ x \\ s)\"\n by sorry\n\nlemma is_interval_Int: \"is_interval X \\ is_interval Y \\ is_interval (X \\ Y)\"\n by sorry\n\nlemma is_interval_cbox [simp]: \"is_interval (cbox a (b::'a::euclidean_space))\" (is ?th1)\n and is_interval_box [simp]: \"is_interval (box a b)\" (is ?th2)\n by sorry\n\nlemma is_interval_empty [iff]: \"is_interval {}\"\n by sorry\n\nlemma is_interval_univ [iff]: \"is_interval UNIV\"\n by sorry\n\nlemma mem_is_intervalI:\n assumes \"is_interval S\"\n and \"a \\ S\" \"b \\ S\"\n and \"\\i. i \\ Basis \\ a \\ i \\ x \\ i \\ x \\ i \\ b \\ i \\ b \\ i \\ x \\ i \\ x \\ i \\ a \\ i\"\n shows \"x \\ S\"\n by sorry\n\nlemma interval_subst:\n fixes S::\"'a::euclidean_space set\"\n assumes \"is_interval S\"\n and \"x \\ S\" \"y j \\ S\"\n and \"j \\ Basis\"\n shows \"(\\i\\Basis. (if i = j then y i \\ i else x \\ i) *\\<^sub>R i) \\ S\"\n by sorry\n\nlemma mem_box_componentwiseI:\n fixes S::\"'a::euclidean_space set\"\n assumes \"is_interval S\"\n assumes \"\\i. i \\ Basis \\ x \\ i \\ ((\\x. x \\ i) ` S)\"\n shows \"x \\ S\"\n by sorry\n\nlemma cbox01_nonempty [simp]: \"cbox 0 One \\ {}\"\n by sorry\n\nlemma box01_nonempty [simp]: \"box 0 One \\ {}\"\n by sorry\n\nlemma empty_as_interval: \"{} = cbox One (0::'a::euclidean_space)\"\n by sorry\n\nlemma interval_subset_is_interval:\n assumes \"is_interval S\"\n shows \"cbox a b \\ S \\ cbox a b = {} \\ a \\ S \\ b \\ S\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma is_real_interval_union:\n \"is_interval (X \\ Y)\"\n if X: \"is_interval X\" and Y: \"is_interval Y\" and I: \"(X \\ {} \\ Y \\ {} \\ X \\ Y \\ {})\"\n for X Y::\"real set\"\n by sorry\n\nlemma is_interval_translationI:\n assumes \"is_interval X\"\n shows \"is_interval ((+) x ` X)\"\n by sorry\n\nlemma is_interval_uminusI:\n assumes \"is_interval X\"\n shows \"is_interval (uminus ` X)\"\n by sorry\n\nlemma is_interval_uminus[simp]: \"is_interval (uminus ` x) = is_interval x\"\n by sorry\n\nlemma is_interval_neg_translationI:\n assumes \"is_interval X\"\n shows \"is_interval ((-) x ` X)\"\n by sorry\n\nlemma is_interval_translation[simp]:\n \"is_interval ((+) x ` X) = is_interval X\"\n by sorry\n\nlemma is_interval_minus_translation[simp]:\n shows \"is_interval ((-) x ` X) = is_interval X\"\n by sorry\n\nlemma is_interval_minus_translation'[simp]:\n shows \"is_interval ((\\x. x - c) ` X) = is_interval X\"\n by sorry\n\nlemma is_interval_cball_1[intro, simp]: \"is_interval (cball a b)\" for a b::real\n by sorry\n\nlemma is_interval_ball_real: \"is_interval (ball a b)\" for a b::real\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Bounded Projections\\\n\nlemma bounded_inner_imp_bdd_above:\n assumes \"bounded s\"\n shows \"bdd_above ((\\x. x \\ a) ` s)\"\n by sorry\n\nlemma bounded_inner_imp_bdd_below:\n assumes \"bounded s\"\n shows \"bdd_below ((\\x. x \\ a) ` s)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Structural rules for pointwise continuity\\\n\nlemma continuous_infnorm[continuous_intros]:\n \"continuous F f \\ continuous F (\\x. infnorm (f x))\"\n by sorry\n\nlemma continuous_inner[continuous_intros]:\n assumes \"continuous F f\"\n and \"continuous F g\"\n shows \"continuous F (\\x. inner (f x) (g x))\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Structural rules for setwise continuity\\\n\nlemma continuous_on_infnorm[continuous_intros]:\n \"continuous_on s f \\ continuous_on s (\\x. infnorm (f x))\"\n by sorry\n\nlemma continuous_on_inner[continuous_intros]:\n fixes g :: \"'a::topological_space \\ 'b::real_inner\"\n assumes \"continuous_on s f\"\n and \"continuous_on s g\"\n shows \"continuous_on s (\\x. inner (f x) (g x))\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Openness of halfspaces.\\\n\nlemma open_halfspace_lt: \"open {x. inner a x < b}\"\n by sorry\n\nlemma open_halfspace_gt: \"open {x. inner a x > b}\"\n by sorry\n\nlemma open_halfspace_component_lt: \"open {x::'a::euclidean_space. x\\i < a}\"\n by sorry\n\nlemma open_halfspace_component_gt: \"open {x::'a::euclidean_space. x\\i > a}\"\n by sorry\n\nlemma eucl_less_eq_halfspaces:\n fixes a :: \"'a::euclidean_space\"\n shows \"{x. x i\\Basis. {x. x \\ i < a \\ i})\"\n \"{x. a i\\Basis. {x. a \\ i < x \\ i})\"\n by sorry\n\nlemma open_Collect_eucl_less[simp, intro]:\n fixes a :: \"'a::euclidean_space\"\n shows \"open {x. x \\tag unimportant\\ \\Closure and Interior of halfspaces and hyperplanes\\\n\nlemma continuous_at_inner: \"continuous (at x) (inner a)\"\n by sorry\n\nlemma closed_halfspace_le: \"closed {x. inner a x \\ b}\"\n by sorry\n\nlemma closed_halfspace_ge: \"closed {x. inner a x \\ b}\"\n by sorry\n\nlemma closed_hyperplane: \"closed {x. inner a x = b}\"\n by sorry\n\nlemma closed_halfspace_component_le: \"closed {x::'a::euclidean_space. x\\i \\ a}\"\n by sorry\n\nlemma closed_halfspace_component_ge: \"closed {x::'a::euclidean_space. x\\i \\ a}\"\n by sorry\n\nlemma closed_interval_left:\n fixes b :: \"'a::euclidean_space\"\n shows \"closed {x::'a. \\i\\Basis. x\\i \\ b\\i}\"\n by sorry\n\nlemma closed_interval_right:\n fixes a :: \"'a::euclidean_space\"\n shows \"closed {x::'a. \\i\\Basis. a\\i \\ x\\i}\"\n by sorry\n\nlemma interior_halfspace_le [simp]:\n assumes \"a \\ 0\"\n shows \"interior {x. a \\ x \\ b} = {x. a \\ x < b}\"\n by sorry\n\nlemma interior_halfspace_ge [simp]:\n \"a \\ 0 \\ interior {x. a \\ x \\ b} = {x. a \\ x > b}\"\n by sorry\n\nlemma closure_halfspace_lt [simp]:\n assumes \"a \\ 0\"\n shows \"closure {x. a \\ x < b} = {x. a \\ x \\ b}\"\n by sorry\n\nlemma closure_halfspace_gt [simp]:\n \"a \\ 0 \\ closure {x. a \\ x > b} = {x. a \\ x \\ b}\"\n by sorry\n\nlemma interior_hyperplane [simp]:\n assumes \"a \\ 0\"\n shows \"interior {x. a \\ x = b} = {}\"\n by sorry\n\nlemma frontier_halfspace_le:\n assumes \"a \\ 0 \\ b \\ 0\"\n shows \"frontier {x. a \\ x \\ b} = {x. a \\ x = b}\"\n by sorry\n\nlemma frontier_halfspace_ge:\n assumes \"a \\ 0 \\ b \\ 0\"\n shows \"frontier {x. a \\ x \\ b} = {x. a \\ x = b}\"\n by sorry\n\nlemma frontier_halfspace_lt:\n assumes \"a \\ 0 \\ b \\ 0\"\n shows \"frontier {x. a \\ x < b} = {x. a \\ x = b}\"\n by sorry\n\nlemma frontier_halfspace_gt:\n assumes \"a \\ 0 \\ b \\ 0\"\n shows \"frontier {x. a \\ x > b} = {x. a \\ x = b}\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Some more convenient intermediate-value theorem formulations\\\n\nlemma connected_ivt_hyperplane:\n assumes \"connected S\" and xy: \"x \\ S\" \"y \\ S\" and b: \"inner a x \\ b\" \"b \\ inner a y\"\n shows \"\\z \\ S. inner a z = b\"\n by sorry\n\nlemma connected_ivt_component:\n fixes x::\"'a::euclidean_space\"\n shows \"connected S \\ x \\ S \\ y \\ S \\ x\\k \\ a \\ a \\ y\\k \\ (\\z\\S. z\\k = a)\"\n by sorry\n\nsubsection \\Limit Component Bounds\\\n\nlemma Lim_component_le:\n fixes f :: \"'a \\ 'b::euclidean_space\"\n assumes \"(f \\ l) net\"\n and \"\\ (trivial_limit net)\"\n and \"eventually (\\x. f(x)\\i \\ b) net\"\n shows \"l\\i \\ b\"\n by sorry\n\nlemma Lim_component_ge:\n fixes f :: \"'a \\ 'b::euclidean_space\"\n assumes \"(f \\ l) net\"\n and \"\\ (trivial_limit net)\"\n and \"eventually (\\x. b \\ (f x)\\i) net\"\n shows \"b \\ l\\i\"\n by sorry\n\nlemma Lim_component_eq:\n fixes f :: \"'a \\ 'b::euclidean_space\"\n assumes net: \"(f \\ l) net\" \"\\ trivial_limit net\"\n and ev:\"eventually (\\x. f(x)\\i = b) net\"\n shows \"l\\i = b\"\n by sorry\n\nlemma open_box[intro]: \"open (box a b)\"\n by sorry\n\nlemma closed_cbox[intro]:\n fixes a b :: \"'a::euclidean_space\"\n shows \"closed (cbox a b)\"\n by sorry\n\nlemma interior_cbox [simp]:\n fixes a b :: \"'a::euclidean_space\"\n shows \"interior (cbox a b) = box a b\" (is \"?L = ?R\")\n by sorry\n\nlemma bounded_cbox [simp]:\n fixes a :: \"'a::euclidean_space\"\n shows \"bounded (cbox a b)\"\n by sorry\n\nlemma bounded_box [simp]:\n fixes a :: \"'a::euclidean_space\"\n shows \"bounded (box a b)\"\n by sorry\n\nlemma not_interval_UNIV [simp]:\n fixes a :: \"'a::euclidean_space\"\n shows \"cbox a b \\ UNIV\" \"box a b \\ UNIV\"\n by sorry\n\nlemma not_interval_UNIV2 [simp]:\n fixes a :: \"'a::euclidean_space\"\n shows \"UNIV \\ cbox a b\" \"UNIV \\ box a b\"\n by sorry\n\nlemma box_midpoint:\n fixes a :: \"'a::euclidean_space\"\n assumes \"box a b \\ {}\"\n shows \"((1/2) *\\<^sub>R (a + b)) \\ box a b\"\n by sorry\n\nlemma open_cbox_convex:\n fixes x :: \"'a::euclidean_space\"\n assumes x: \"x \\ box a b\"\n and y: \"y \\ cbox a b\"\n and e: \"0 < e\" \"e \\ 1\"\n shows \"(e *\\<^sub>R x + (1 - e) *\\<^sub>R y) \\ box a b\"\n by sorry\n\nlemma closure_cbox [simp]: \"closure (cbox a b) = cbox a b\"\n by sorry\n\nlemma closure_box [simp]:\n fixes a :: \"'a::euclidean_space\"\n assumes \"box a b \\ {}\"\n shows \"closure (box a b) = cbox a b\"\n by sorry\n\nlemma bounded_subset_box_symmetric:\n fixes S :: \"('a::euclidean_space) set\"\n assumes \"bounded S\"\n obtains a where \"S \\ box (-a) a\"\n by sorry\n\nlemma bounded_subset_cbox_symmetric:\n fixes S :: \"('a::euclidean_space) set\"\n assumes \"bounded S\"\n obtains a where \"S \\ cbox (-a) a\"\n by sorry\n\nlemma frontier_cbox:\n fixes a b :: \"'a::euclidean_space\"\n shows \"frontier (cbox a b) = cbox a b - box a b\"\n by sorry\n\nlemma frontier_box:\n fixes a b :: \"'a::euclidean_space\"\n shows \"frontier (box a b) = (if box a b = {} then {} else cbox a b - box a b)\"\n by sorry\n\nlemma Int_interval_mixed_eq_empty:\n fixes a :: \"'a::euclidean_space\"\n assumes \"box c d \\ {}\"\n shows \"box a b \\ cbox c d = {} \\ box a b \\ box c d = {}\"\n by sorry\n\nsubsection \\Class Instances\\\n\nlemma compact_lemma:\n fixes f :: \"nat \\ 'a::euclidean_space\"\n assumes \"bounded (range f)\"\n shows \"\\d\\Basis. \\l::'a. \\ r.\n strict_mono r \\ (\\e>0. eventually (\\n. \\i\\d. dist (f (r n) \\ i) (l \\ i) < e) sequentially)\"\n by sorry\n\ninstance\\<^marker>\\tag important\\ euclidean_space \\ heine_borel\nproof\n fix f :: \"nat \\ 'a\"\n assume f: \"bounded (range f)\"\n then obtain l::'a and r where r: \"strict_mono r\"\n and l: \"\\e>0. eventually (\\n. \\i\\Basis. dist (f (r n) \\ i) (l \\ i) < e) sequentially\"\n using compact_lemma [OF f] by blast\n have \"\\\\<^sub>F n in sequentially. dist (f (r n)) l < e\" if \"e > 0\" for e::real\n proof -\n from that have \"e / real_of_nat DIM('a) > 0\" by (simp)\n with l have \"eventually (\\n. \\i\\Basis. dist (f (r n) \\ i) (l \\ i) < e / (real_of_nat DIM('a))) sequentially\"\n by simp\n moreover\n have \"dist (f (r n)) l < e\"\n if n: \"\\i\\Basis. dist (f (r n) \\ i) (l \\ i) < e / (real_of_nat DIM('a))\" for n\n proof -\n have \"dist (f (r n)) l \\ (\\i\\Basis. dist (f (r n) \\ i) (l \\ i))\"\n using L2_set_le_sum [OF zero_le_dist] by (subst euclidean_dist_l2)\n also have \"\\ < (\\i\\(Basis::'a set). e / (real_of_nat DIM('a)))\"\n by (meson eucl.finite_Basis n nonempty_Basis sum_strict_mono)\n finally show ?thesis\n by auto\n qed\n ultimately show ?thesis\n by (rule eventually_mono)\n qed\n then have *: \"(f \\ r) \\ l\"\n unfolding o_def tendsto_iff by simp\n with r show \"\\l r. strict_mono r \\ (f \\ r) \\ l\"\n by auto\nqed\n\ninstance\\<^marker>\\tag important\\ euclidean_space \\ banach ..\n\ninstance euclidean_space \\ second_countable_topology\nproof\n define a where \"a f = (\\i\\Basis. fst (f i) *\\<^sub>R i)\" for f :: \"'a \\ real \\ real\"\n then have a: \"\\f. (\\i\\Basis. fst (f i) *\\<^sub>R i) = a f\"\n by simp\n define b where \"b f = (\\i\\Basis. snd (f i) *\\<^sub>R i)\" for f :: \"'a \\ real \\ real\"\n then have b: \"\\f. (\\i\\Basis. snd (f i) *\\<^sub>R i) = b f\"\n by simp\n define B where \"B = (\\f. box (a f) (b f)) ` (Basis \\\\<^sub>E (\\ \\ \\))\"\n\n have \"Ball B open\" by (simp add: B_def open_box)\n moreover have \"(\\A. open A \\ (\\B'\\B. \\B' = A))\"\n proof safe\n fix A::\"'a set\"\n assume \"open A\"\n show \"\\B'\\B. \\B' = A\"\n using open_UNION_box[OF \\open A\\]\n by (smt (verit, ccfv_threshold) B_def a b image_iff mem_Collect_eq subsetI)\n qed\n ultimately\n have \"topological_basis B\"\n unfolding topological_basis_def by blast\n moreover\n have \"countable B\"\n unfolding B_def\n by (intro countable_image countable_PiE finite_Basis countable_SIGMA countable_rat)\n ultimately show \"\\B::'a set set. countable B \\ open = generate_topology B\"\n by (blast intro: topological_basis_imp_subbasis)\nqed\n\ninstance euclidean_space \\ polish_space ..\n\nsubsection \\Compact Boxes\\\n\nlemma compact_cbox [simp]:\n fixes a :: \"'a::euclidean_space\"\n shows \"compact (cbox a b)\"\n by sorry\n\nproposition is_interval_compact:\n \"is_interval S \\ compact S \\ (\\a b. S = cbox a b)\" (is \"?lhs = ?rhs\")\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Componentwise limits and continuity\\\n\ntext\\But is the premise really necessary? Need to generalise @{thm euclidean_dist_l2}\\\nlemma Euclidean_dist_upper: \"i \\ Basis \\ dist (x \\ i) (y \\ i) \\ dist x y\"\n by sorry\n\ntext\\But is the premise \\<^term>\\i \\ Basis\\ really necessary?\\\nlemma open_preimage_inner:\n assumes \"open S\" \"i \\ Basis\"\n shows \"open {x. x \\ i \\ S}\"\n by sorry\n\nproposition tendsto_componentwise_iff:\n fixes f :: \"_ \\ 'b::euclidean_space\"\n shows \"(f \\ l) F \\ (\\i \\ Basis. ((\\x. (f x \\ i)) \\ (l \\ i)) F)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\ncorollary continuous_componentwise:\n \"continuous F f \\ (\\i \\ Basis. continuous F (\\x. (f x \\ i)))\"\n by sorry\n\ncorollary continuous_on_componentwise:\n fixes S :: \"'a :: t2_space set\"\n shows \"continuous_on S f \\ (\\i \\ Basis. continuous_on S (\\x. (f x \\ i)))\"\n by sorry\n\nlemma linear_componentwise_iff:\n \"linear f' \\ (\\i\\Basis. linear (\\x. f' x \\ i))\" (is \"?lhs \\ ?rhs\")\n by sorry\n\nlemma bounded_linear_componentwise_iff:\n \"(bounded_linear f') \\ (\\i\\Basis. bounded_linear (\\x. f' x \\ i))\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Continuous Extension\\\n\ndefinition clamp :: \"'a::euclidean_space \\ 'a \\ 'a \\ 'a\" where\n \"clamp a b x = (if (\\i\\Basis. a \\ i \\ b \\ i)\n then (\\i\\Basis. (if x\\i < a\\i then a\\i else if x\\i \\ b\\i then x\\i else b\\i) *\\<^sub>R i)\n else a)\"\n\nlemma clamp_in_interval[simp]:\n assumes \"\\i. i \\ Basis \\ a \\ i \\ b \\ i\"\n shows \"clamp a b x \\ cbox a b\"\n by sorry\n\nlemma clamp_cancel_cbox[simp]:\n fixes x a b :: \"'a::euclidean_space\"\n assumes x: \"x \\ cbox a b\"\n shows \"clamp a b x = x\"\n by sorry\n\nlemma clamp_empty_interval:\n assumes \"i \\ Basis\" \"a \\ i > b \\ i\"\n shows \"clamp a b = (\\_. a)\"\n by sorry\n\nlemma dist_clamps_le_dist_args:\n fixes x :: \"'a::euclidean_space\"\n shows \"dist (clamp a b y) (clamp a b x) \\ dist y x\"\n by sorry\n\nlemma clamp_continuous_at:\n fixes f :: \"'a::euclidean_space \\ 'b::metric_space\"\n and x :: 'a\n assumes f_cont: \"continuous_on (cbox a b) f\"\n shows \"continuous (at x) (\\x. f (clamp a b x))\"\n by sorry\n\nlemma clamp_continuous_on:\n fixes f :: \"'a::euclidean_space \\ 'b::metric_space\"\n assumes f_cont: \"continuous_on (cbox a b) f\"\n shows \"continuous_on S (\\x. f (clamp a b x))\"\n by sorry\n\nlemma clamp_bounded:\n fixes f :: \"'a::euclidean_space \\ 'b::metric_space\"\n assumes bounded: \"bounded (f ` (cbox a b))\"\n shows \"bounded (range (\\x. f (clamp a b x)))\"\n by sorry\n\ndefinition ext_cont :: \"('a::euclidean_space \\ 'b::metric_space) \\ 'a \\ 'a \\ 'a \\ 'b\"\n where \"ext_cont f a b = (\\x. f (clamp a b x))\"\n\nlemma ext_cont_cancel_cbox[simp]:\n fixes x a b :: \"'a::euclidean_space\"\n assumes x: \"x \\ cbox a b\"\n shows \"ext_cont f a b x = f x\"\n by sorry\n\nlemma continuous_on_ext_cont[continuous_intros]:\n \"continuous_on (cbox a b) f \\ continuous_on S (ext_cont f a b)\"\n by sorry\n\nsubsection \\Separability\\\n\nlemma univ_second_countable_sequence:\n obtains B :: \"nat \\ 'a::euclidean_space set\"\n where \"inj B\" \"\\n. open(B n)\" \"\\S. open S \\ \\k. S = \\{B n |n. n \\ k}\"\n by sorry\n\nproposition separable:\n fixes S :: \"'a::{metric_space, second_countable_topology} set\"\n obtains T where \"countable T\" \"T \\ S\" \"S \\ closure T\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Diameter\\\n\nlemma diameter_cball [simp]:\n fixes a :: \"'a::euclidean_space\"\n shows \"diameter(cball a r) = (if r < 0 then 0 else 2*r)\"\n by sorry\n\nlemma diameter_ball [simp]:\n fixes a :: \"'a::euclidean_space\"\n shows \"diameter(ball a r) = (if r < 0 then 0 else 2*r)\"\n by sorry\n\nlemma diameter_closed_interval [simp]: \"diameter {a..b} = (if b < a then 0 else b-a)\"\n by sorry\n\nlemma diameter_open_interval [simp]: \"diameter {a<..i \\ Basis. a \\ i \\ b \\ i) \\ diameter (cbox a b) = dist a b\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\\\Relating linear images to open/closed/interior/closure/connected\\\n\nproposition open_surjective_linear_image:\n fixes f :: \"'a::real_normed_vector \\ 'b::euclidean_space\"\n assumes \"open A\" \"linear f\" \"surj f\"\n shows \"open(f ` A)\"\n by sorry\n\ncorollary open_bijective_linear_image_eq:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"linear f\" \"bij f\"\n shows \"open(f ` A) \\ open A\"\n by sorry\n\ncorollary interior_bijective_linear_image:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"linear f\" \"bij f\"\n shows \"interior (f ` S) = f ` interior S\" \n by sorry\n\nlemma interior_injective_linear_image:\n fixes f :: \"'a::euclidean_space \\ 'a::euclidean_space\"\n assumes \"linear f\" \"inj f\"\n shows \"interior(f ` S) = f ` (interior S)\"\n by sorry\n\nlemma interior_surjective_linear_image:\n fixes f :: \"'a::euclidean_space \\ 'a::euclidean_space\"\n assumes \"linear f\" \"surj f\"\n shows \"interior(f ` S) = f ` (interior S)\"\n by sorry\n\nlemma interior_negations:\n fixes S :: \"'a::euclidean_space set\"\n shows \"interior(uminus ` S) = image uminus (interior S)\"\n by sorry\n\nlemma connected_linear_image:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n assumes \"linear f\" and \"connected s\"\n shows \"connected (f ` s)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\\"Isometry\" (up to constant bounds) of Injective Linear Map\\\n\nproposition injective_imp_isometric:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes s: \"closed s\" \"subspace s\"\n and f: \"bounded_linear f\" \"\\x\\s. f x = 0 \\ x = 0\"\n shows \"\\e>0. \\x\\s. norm (f x) \\ e * norm x\"\n by sorry\n\nproposition closed_injective_image_subspace:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"subspace s\" \"bounded_linear f\" \"\\x\\s. f x = 0 \\ x = 0\" \"closed s\"\n shows \"closed(f ` s)\"\n by sorry\n \nlemma closure_bounded_linear_image_subset:\n assumes f: \"bounded_linear f\"\n shows \"f ` closure S \\ closure (f ` S)\"\n by sorry\n\nlemma closure_linear_image_subset:\n fixes f :: \"'m::euclidean_space \\ 'n::real_normed_vector\"\n assumes \"linear f\"\n shows \"f ` (closure S) \\ closure (f ` S)\"\n by sorry\n\nlemma closed_injective_linear_image:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes S: \"closed S\" and f: \"linear f\" \"inj f\"\n shows \"closed (f ` S)\"\n by sorry\n\nlemma closed_injective_linear_image_eq:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes f: \"linear f\" \"inj f\"\n shows \"(closed(image f s) \\ closed s)\"\n by sorry\n\nlemma closure_injective_linear_image:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n shows \"\\linear f; inj f\\ \\ f ` (closure S) = closure (f ` S)\"\n by sorry\n\nlemma closure_bounded_linear_image:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\"\n assumes \"linear f\" \"bounded S\"\n shows \"f ` (closure S) = closure (f ` S)\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma closure_scaleR:\n fixes S :: \"'a::real_normed_vector set\"\n shows \"(" }, { "theorem_id": 62, "title": "079_the_intermediate_value_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2021 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Alistair Tucker, Wen Yang\n-/\nmodule\n\npublic import Mathlib.Order.Interval.Set.Image\npublic import Mathlib.Order.CompleteLatticeIntervals\npublic import Mathlib.Topology.Order.DenselyOrdered\npublic import Mathlib.Topology.Order.Monotone\npublic import Mathlib.Topology.Connected.TotallyDisconnected\n\n/-!\n# Intermediate Value Theorem\n\nIn this file we prove the Intermediate Value Theorem: if `f : α → β` is a function defined on a\nconnected set `s` that takes both values `≤ a` and values `≥ a` on `s`, then it is equal to `a` at\nsome point of `s`. We also prove that intervals in a dense conditionally complete order are\npreconnected and any preconnected set is an interval. Then we specialize IVT to functions continuous\non intervals.\n\n## Main results\n\n* `IsPreconnected_I??` : all intervals `I??` are preconnected,\n* `IsPreconnected.intermediate_value`, `intermediate_value_univ` : Intermediate Value Theorem for\n connected sets and connected spaces, respectively;\n* `intermediate_value_Icc`, `intermediate_value_Icc'`: Intermediate Value Theorem for functions\n on closed intervals.\n\n### Miscellaneous facts\n\n* `IsClosed.Icc_subset_of_forall_mem_nhdsWithin` : “Continuous induction” principle;\n if `s ∩ [a, b]` is closed, `a ∈ s`, and for each `x ∈ [a, b) ∩ s` some of its right neighborhoods\n is included in `s`, then `[a, b] ⊆ s`.\n* `IsClosed.Icc_subset_of_forall_exists_gt`, `IsClosed.mem_of_ge_of_forall_exists_gt` : two\n other versions of the “continuous induction” principle.\n* `ContinuousOn.StrictMonoOn_of_InjOn_Ioo` :\n Every continuous injective `f : (a, b) → δ` is strictly monotone\n or antitone (increasing or decreasing).\n\n## Tags\n\nintermediate value theorem, connected space, connected set\n-/\n\n@[expose] public section\n\n\nopen Filter OrderDual TopologicalSpace Function Set\nopen scoped Topology Filter Interval\n\nuniverse u v\n\n/-!\n### Intermediate value theorem on a (pre)connected space\n\nIn this section we prove the following theorem (see `IsPreconnected.intermediate_value₂`): if `f`\nand `g` are two functions continuous on a preconnected set `s`, `f a ≤ g a` at some `a ∈ s` and\n`g b ≤ f b` at some `b ∈ s`, then `f c = g c` at some `c ∈ s`. We prove several versions of this\nstatement, including the classical IVT that corresponds to a constant function `g`.\n-/\n\nsection\n\nvariable {X : Type u} {α : Type v} [TopologicalSpace X] [LinearOrder α] [TopologicalSpace α]\n [OrderClosedTopology α]\n\n/-- Intermediate value theorem for two functions: if `f` and `g` are two continuous functions\non a preconnected space and `f a ≤ g a` and `g b ≤ f b`, then for some `x` we have `f x = g x`. -/\ntheorem intermediate_value_univ₂ [PreconnectedSpace X] {a b : X} {f g : X → α} (hf : Continuous f)\n (hg : Continuous g) (ha : f a ≤ g a) (hb : g b ≤ f b) : ∃ x, f x = g x := by sorry\ntheorem intermediate_value_univ₂_eventually₁ [PreconnectedSpace X] {a : X} {l : Filter X} [NeBot l]\n {f g : X → α} (hf : Continuous f) (hg : Continuous g) (ha : f a ≤ g a) (he : g ≤ᶠ[l] f) :\n ∃ x, f x = g x :=\n let ⟨_, h⟩ := he.exists; intermediate_value_univ₂ hf hg ha h\n\ntheorem intermediate_value_univ₂_eventually₂ [PreconnectedSpace X] {l₁ l₂ : Filter X} [NeBot l₁]\n [NeBot l₂] {f g : X → α} (hf : Continuous f) (hg : Continuous g) (he₁ : f ≤ᶠ[l₁] g)\n (he₂ : g ≤ᶠ[l₂] f) : ∃ x, f x = g x :=\n let ⟨_, h₁⟩ := he₁.exists\n let ⟨_, h₂⟩ := he₂.exists\n intermediate_value_univ₂ hf hg h₁ h₂\n\n/-- Intermediate value theorem for two functions: if `f` and `g` are two functions continuous\non a preconnected set `s` and for some `a b ∈ s` we have `f a ≤ g a` and `g b ≤ f b`,\nthen for some `x ∈ s` we have `f x = g x`. -/\ntheorem IsPreconnected.intermediate_value₂ {s : Set X} (hs : IsPreconnected s) {a b : X}\n (ha : a ∈ s) (hb : b ∈ s) {f g : X → α} (hf : ContinuousOn f s) (hg : ContinuousOn g s)\n (ha' : f a ≤ g a) (hb' : g b ≤ f b) : ∃ x ∈ s, f x = g x :=\n let ⟨x, hx⟩ :=\n @intermediate_value_univ₂ s α _ _ _ _ (Subtype.preconnectedSpace hs) ⟨a, ha⟩ ⟨b, hb⟩ _ _\n (continuousOn_iff_continuous_restrict.1 hf) (continuousOn_iff_continuous_restrict.1 hg) ha'\n hb'\n ⟨x, x.2, hx⟩\n\ntheorem IsPreconnected.intermediate_value₂_eventually₁ {s : Set X} (hs : IsPreconnected s) {a : X}\n {l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f g : X → α} (hf : ContinuousOn f s)\n (hg : ContinuousOn g s) (ha' : f a ≤ g a) (he : g ≤ᶠ[l] f) : ∃ x ∈ s, f x = g x := by sorry\ntheorem IsPreconnected.intermediate_value₂_eventually₂ {s : Set X} (hs : IsPreconnected s)\n {l₁ l₂ : Filter X} [NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f g : X → α}\n (hf : ContinuousOn f s) (hg : ContinuousOn g s) (he₁ : f ≤ᶠ[l₁] g) (he₂ : g ≤ᶠ[l₂] f) :\n ∃ x ∈ s, f x = g x := by sorry\ntheorem IsPreconnected.intermediate_value {s : Set X} (hs : IsPreconnected s) {a b : X} (ha : a ∈ s)\n (hb : b ∈ s) {f : X → α} (hf : ContinuousOn f s) : Icc (f a) (f b) ⊆ f '' s := fun _x hx =>\n hs.intermediate_value₂ ha hb hf continuousOn_const hx.1 hx.2\n\ntheorem IsPreconnected.intermediate_value_Ico {s : Set X} (hs : IsPreconnected s) {a : X}\n {l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s) {v : α}\n (ht : Tendsto f l (𝓝 v)) : Ico (f a) v ⊆ f '' s := fun _ h =>\n hs.intermediate_value₂_eventually₁ ha hl hf continuousOn_const h.1 (ht.eventually_const_le h.2)\n\ntheorem IsPreconnected.intermediate_value_Ioc {s : Set X} (hs : IsPreconnected s) {a : X}\n {l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s) {v : α}\n (ht : Tendsto f l (𝓝 v)) : Ioc v (f a) ⊆ f '' s := fun _ h =>\n (hs.intermediate_value₂_eventually₁ ha hl continuousOn_const hf h.2\n (ht.eventually_le_const h.1)).imp fun _ h => h.imp_right Eq.symm\n\ntheorem IsPreconnected.intermediate_value_Ioo {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}\n [NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)\n {v₁ v₂ : α} (ht₁ : Tendsto f l₁ (𝓝 v₁)) (ht₂ : Tendsto f l₂ (𝓝 v₂)) :\n Ioo v₁ v₂ ⊆ f '' s := fun _ h =>\n hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const\n (ht₁.eventually_le_const h.1) (ht₂.eventually_const_le h.2)\n\ntheorem IsPreconnected.intermediate_value_Ici {s : Set X} (hs : IsPreconnected s) {a : X}\n {l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)\n (ht : Tendsto f l atTop) : Ici (f a) ⊆ f '' s := fun y h =>\n hs.intermediate_value₂_eventually₁ ha hl hf continuousOn_const h (tendsto_atTop.1 ht y)\n\ntheorem IsPreconnected.intermediate_value_Iic {s : Set X} (hs : IsPreconnected s) {a : X}\n {l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)\n (ht : Tendsto f l atBot) : Iic (f a) ⊆ f '' s := fun y h =>\n (hs.intermediate_value₂_eventually₁ ha hl continuousOn_const hf h (tendsto_atBot.1 ht y)).imp\n fun _ h => h.imp_right Eq.symm\n\ntheorem IsPreconnected.intermediate_value_Ioi {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}\n [NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)\n {v : α} (ht₁ : Tendsto f l₁ (𝓝 v)) (ht₂ : Tendsto f l₂ atTop) : Ioi v ⊆ f '' s := fun y h =>\n hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const\n (ht₁.eventually_le_const h) (ht₂.eventually_ge_atTop y)\n\ntheorem IsPreconnected.intermediate_value_Iio {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}\n [NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)\n {v : α} (ht₁ : Tendsto f l₁ atBot) (ht₂ : Tendsto f l₂ (𝓝 v)) : Iio v ⊆ f '' s := fun y h =>\n hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const (ht₁.eventually_le_atBot y)\n (ht₂.eventually_const_le h)\n\ntheorem IsPreconnected.intermediate_value_Iii {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}\n [NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)\n (ht₁ : Tendsto f l₁ atBot) (ht₂ : Tendsto f l₂ atTop) : univ ⊆ f '' s := fun y _ =>\n hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const (ht₁.eventually_le_atBot y)\n (ht₂.eventually_ge_atTop y)\n\n/-- **Intermediate Value Theorem** for continuous functions on connected spaces. -/\ntheorem intermediate_value_univ [PreconnectedSpace X] (a b : X) {f : X → α} (hf : Continuous f) :\n Icc (f a) (f b) ⊆ range f := fun _ hx => intermediate_value_univ₂ hf continuous_const hx.1 hx.2\n\n/-- **Intermediate Value Theorem** for continuous functions on connected spaces. -/\ntheorem mem_range_of_exists_le_of_exists_ge [PreconnectedSpace X] {c : α} {f : X → α}\n (hf : Continuous f) (h₁ : ∃ a, f a ≤ c) (h₂ : ∃ b, c ≤ f b) : c ∈ range f :=\n let ⟨a, ha⟩ := h₁; let ⟨b, hb⟩ := h₂; intermediate_value_univ a b hf ⟨ha, hb⟩\n\n/-!\n### (Pre)connected sets in a linear order\n\nIn this section we prove the following results:\n\n* `IsPreconnected.ordConnected`: any preconnected set `s` in a linear order is `OrdConnected`,\n i.e. `a ∈ s` and `b ∈ s` imply `Icc a b ⊆ s`;\n\n* `IsPreconnected.mem_intervals`: any preconnected set `s` in a conditionally complete linear order\n is one of the intervals `Set.Icc`, `Set.Ico`, `Set.Ioc`, `Set.Ioo`, `Set.Ici`, `Set.Iic`,\n `Set.Ioi`, `Set.Iio`; note that this is false for non-complete orders: e.g., in `ℝ \\ {0}`, the set\n of positive numbers cannot be represented as `Set.Ioi _`.\n\n-/\n\n\n/-- If a preconnected set contains endpoints of an interval, then it includes the whole interval. -/\ntheorem IsPreconnected.Icc_subset {s : Set α} (hs : IsPreconnected s) {a b : α} (ha : a ∈ s)\n (hb : b ∈ s) : Icc a b ⊆ s := by sorry\ntheorem IsPreconnected.ordConnected {s : Set α} (h : IsPreconnected s) : OrdConnected s :=\n ⟨fun _ hx _ hy => h.Icc_subset hx hy⟩\n\n/-- If a preconnected set contains endpoints of an interval, then it includes the whole interval. -/\ntheorem IsConnected.Icc_subset {s : Set α} (hs : IsConnected s) {a b : α} (ha : a ∈ s)\n (hb : b ∈ s) : Icc a b ⊆ s :=\n hs.2.Icc_subset ha hb\n\n/-- If a preconnected set in a linear order space is unbounded below and above, then it is the whole\nspace. -/\ntheorem IsPreconnected.eq_univ_of_unbounded {s : Set α} (hs : IsPreconnected s) (hb : ¬BddBelow s)\n (ha : ¬BddAbove s) : s = univ := by sorry\nend\n\nvariable {α : Type u} [ConditionallyCompleteLinearOrder α] [TopologicalSpace α] [OrderTopology α]\n\n/-- A bounded connected subset of a conditionally complete linear order includes the open interval\n`(Inf s, Sup s)`. -/\ntheorem IsConnected.Ioo_csInf_csSup_subset {s : Set α} (hs : IsConnected s) (hb : BddBelow s)\n (ha : BddAbove s) : Ioo (sInf s) (sSup s) ⊆ s := fun _x hx =>\n let ⟨_y, ys, hy⟩ := (isGLB_lt_iff (isGLB_csInf hs.nonempty hb)).1 hx.1\n let ⟨_z, zs, hz⟩ := (lt_isLUB_iff (isLUB_csSup hs.nonempty ha)).1 hx.2\n hs.Icc_subset ys zs ⟨hy.le, hz.le⟩\n\ntheorem eq_Icc_csInf_csSup_of_connected_bdd_closed {s : Set α} (hc : IsConnected s)\n (hb : BddBelow s) (ha : BddAbove s) (hcl : IsClosed s) : s = Icc (sInf s) (sSup s) :=\n (subset_Icc_csInf_csSup hb ha).antisymm <|\n hc.Icc_subset (hcl.csInf_mem hc.nonempty hb) (hcl.csSup_mem hc.nonempty ha)\n\ntheorem IsPreconnected.Ioi_csInf_subset {s : Set α} (hs : IsPreconnected s) (hb : BddBelow s)\n (ha : ¬BddAbove s) : Ioi (sInf s) ⊆ s := fun x hx =>\n have sne : s.Nonempty := nonempty_of_not_bddAbove ha\n let ⟨_y, ys, hy⟩ : ∃ y ∈ s, y < x := (isGLB_lt_iff (isGLB_csInf sne hb)).1 hx\n let ⟨_z, zs, hz⟩ : ∃ z ∈ s, x < z := not_bddAbove_iff.1 ha x\n hs.Icc_subset ys zs ⟨hy.le, hz.le⟩\n\ntheorem IsPreconnected.Iio_csSup_subset {s : Set α} (hs : IsPreconnected s) (hb : ¬BddBelow s)\n (ha : BddAbove s) : Iio (sSup s) ⊆ s :=\n IsPreconnected.Ioi_csInf_subset (α := αᵒᵈ) hs ha hb\n\n/-- A preconnected set in a conditionally complete linear order is either one of the intervals\n`[Inf s, Sup s]`, `[Inf s, Sup s)`, `(Inf s, Sup s]`, `(Inf s, Sup s)`, `[Inf s, +∞)`,\n`(Inf s, +∞)`, `(-∞, Sup s]`, `(-∞, Sup s)`, `(-∞, +∞)`, or `∅`. The converse statement requires\n`α` to be densely ordered. -/\ntheorem IsPreconnected.mem_intervals {s : Set α} (hs : IsPreconnected s) :\n s ∈\n ({Icc (sInf s) (sSup s), Ico (sInf s) (sSup s), Ioc (sInf s) (sSup s), Ioo (sInf s) (sSup s),\n Ici (sInf s), Ioi (sInf s), Iic (sSup s), Iio (sSup s), univ, ∅} : Set (Set α)) := by sorry\ntheorem setOf_isPreconnected_subset_of_ordered :\n { s : Set α | IsPreconnected s } ⊆\n -- bounded intervals\n (range (uncurry Icc) ∪ range (uncurry Ico) ∪ range (uncurry Ioc) ∪ range (uncurry Ioo)) ∪\n -- unbounded intervals and `univ`\n (range Ici ∪ range Ioi ∪ range Iic ∪ range Iio ∪ {univ, ∅}) := by sorry\ntheorem IsClosed.mem_of_ge_of_forall_exists_gt {a b : α} {s : Set α} (hs : IsClosed (s ∩ Icc a b))\n (ha : a ∈ s) (hab : a ≤ b) (hgt : ∀ x ∈ s ∩ Ico a b, (s ∩ Ioc x b).Nonempty) : b ∈ s := by sorry\ntheorem IsClosed.Icc_subset_of_forall_exists_gt {a b : α} {s : Set α} (hs : IsClosed (s ∩ Icc a b))\n (ha : a ∈ s) (hgt : ∀ x ∈ s ∩ Ico a b, ∀ y ∈ Ioi x, (s ∩ Ioc x y).Nonempty) : Icc a b ⊆ s := by sorry\ntheorem IsClosed.mem_of_ge_of_forall_exists_lt {a b : α} {s : Set α} (hs : IsClosed (s ∩ Icc a b))\n (hb : b ∈ s) (hab : a ≤ b) (hgt : ∀ x ∈ s ∩ Ioc a b, (s ∩ Ico a x).Nonempty) : a ∈ s := by sorry\ntheorem IsClosed.Icc_subset_of_forall_exists_lt {a b : α} {s : Set α} (hs : IsClosed (s ∩ Icc a b))\n (hb : b ∈ s) (hgt : ∀ x ∈ s ∩ Ioc a b, ∀ y ∈ Iio x, (s ∩ Ico y x).Nonempty) : Icc a b ⊆ s := by sorry\nvariable [DenselyOrdered α] {a b : α}\n\n/-- A \"continuous induction principle\" for a closed interval: if a set `s` meets `[a, b]`\non a closed subset, contains `a`, and for any `x ∈ [a, b)` such that `[a, x]` is included in `s`,\nthe set `s` includes some open neighborhood of `x` within `(x, +∞)`, then `[a, b] ⊆ s`. -/\nlemma IsClosed.Icc_subset_of_forall_mem_nhdsGT_of_Icc_subset {a b : α} {s : Set α}\n (hs : IsClosed (s ∩ Icc a b)) (ha : a ∈ s)\n (h : ∀ t ∈ Ico a b, Icc a t ⊆ s → s ∈ 𝓝[>] t) :\n Icc a b ⊆ s := by sorry\ntheorem IsClosed.Icc_subset_of_forall_mem_nhdsWithin {a b : α} {s : Set α}\n (hs : IsClosed (s ∩ Icc a b)) (ha : a ∈ s) (hgt : ∀ x ∈ s ∩ Ico a b, s ∈ 𝓝[>] x) :\n Icc a b ⊆ s :=\n hs.Icc_subset_of_forall_mem_nhdsGT_of_Icc_subset ha\n (fun _t ht h't ↦ hgt _ ⟨h't ⟨ht.1, le_rfl⟩, ht⟩)\n\ntheorem isPreconnected_Icc_aux (x y : α) (s t : Set α) (hxy : x ≤ y) (hs : IsClosed s)\n (ht : IsClosed t) (hab : Icc a b ⊆ s ∪ t) (hx : x ∈ Icc a b ∩ s) (hy : y ∈ Icc a b ∩ t) :\n (Icc a b ∩ (s ∩ t)).Nonempty := by sorry\ntheorem isPreconnected_Icc : IsPreconnected (Icc a b) :=\n isPreconnected_closed_iff.2\n (by\n rintro s t hs ht hab ⟨x, hx⟩ ⟨y, hy⟩\n -- This used to use `wlog`, but it was causing timeouts.\n rcases le_total x y with h | h\n · exact isPreconnected_Icc_aux x y s t h hs ht hab hx hy\n · rw [inter_comm s t]\n rw [union_comm s t] at hab\n exact isPreconnected_Icc_aux y x t s h ht hs hab hy hx)\n\ntheorem isPreconnected_uIcc : IsPreconnected ([[a, b]]) :=\n isPreconnected_Icc\n\ntheorem Set.OrdConnected.isPreconnected {s : Set α} (h : s.OrdConnected) : IsPreconnected s :=\n isPreconnected_of_forall_pair fun x hx y hy =>\n ⟨[[x, y]], h.uIcc_subset hx hy, left_mem_uIcc, right_mem_uIcc, isPreconnected_uIcc⟩\n\ntheorem isPreconnected_iff_ordConnected {s : Set α} : IsPreconnected s ↔ OrdConnected s :=\n ⟨IsPreconnected.ordConnected, Set.OrdConnected.isPreconnected⟩\n\ntheorem isPreconnected_Ici : IsPreconnected (Ici a) :=\n ordConnected_Ici.isPreconnected\n\ntheorem isPreconnected_Iic : IsPreconnected (Iic a) :=\n ordConnected_Iic.isPreconnected\n\ntheorem isPreconnected_Iio : IsPreconnected (Iio a) :=\n ordConnected_Iio.isPreconnected\n\ntheorem isPreconnected_Ioi : IsPreconnected (Ioi a) :=\n ordConnected_Ioi.isPreconnected\n\ntheorem isPreconnected_Ioo : IsPreconnected (Ioo a b) :=\n ordConnected_Ioo.isPreconnected\n\ntheorem isPreconnected_uIoo : IsPreconnected (uIoo a b) :=\n isPreconnected_Ioo\n\ntheorem isPreconnected_Ioc : IsPreconnected (Ioc a b) :=\n ordConnected_Ioc.isPreconnected\n\ntheorem isPreconnected_uIoc : IsPreconnected (uIoc a b) :=\n isPreconnected_Ioc\n\ntheorem isPreconnected_Ico : IsPreconnected (Ico a b) :=\n ordConnected_Ico.isPreconnected\n\ntheorem isConnected_Ici : IsConnected (Ici a) :=\n ⟨nonempty_Ici, isPreconnected_Ici⟩\n\ntheorem isConnected_Iic : IsConnected (Iic a) :=\n ⟨nonempty_Iic, isPreconnected_Iic⟩\n\ntheorem isConnected_Ioi [NoMaxOrder α] : IsConnected (Ioi a) :=\n ⟨nonempty_Ioi, isPreconnected_Ioi⟩\n\ntheorem isConnected_Iio [NoMinOrder α] : IsConnected (Iio a) :=\n ⟨nonempty_Iio, isPreconnected_Iio⟩\n\ntheorem isConnected_Icc (h : a ≤ b) : IsConnected (Icc a b) :=\n ⟨nonempty_Icc.2 h, isPreconnected_Icc⟩\n\ntheorem isConnected_Ioo (h : a < b) : IsConnected (Ioo a b) :=\n ⟨nonempty_Ioo.2 h, isPreconnected_Ioo⟩\n\ntheorem isConnected_uIoo (h : a ≠ b) : IsConnected (uIoo a b) :=\n ⟨nonempty_uIoo.2 h, isPreconnected_uIoo⟩\n\ntheorem isConnected_Ioc (h : a < b) : IsConnected (Ioc a b) :=\n ⟨nonempty_Ioc.2 h, isPreconnected_Ioc⟩\n\ntheorem isConnected_uIoc (h : a ≠ b) : IsConnected (uIoc a b) :=\n ⟨nonempty_uIoc.2 h, isPreconnected_uIoc⟩\n\ntheorem isConnected_Ico (h : a < b) : IsConnected (Ico a b) :=\n ⟨nonempty_Ico.2 h, isPreconnected_Ico⟩\n\ninstance (priority := 100) ordered_connected_space : PreconnectedSpace α :=\n ⟨ordConnected_univ.isPreconnected⟩\n\n/-- In a dense conditionally complete linear order, the set of preconnected sets is exactly\nthe set of the intervals `Icc`, `Ico`, `Ioc`, `Ioo`, `Ici`, `Ioi`, `Iic`, `Iio`, `(-∞, +∞)`,\nor `∅`. Though one can represent `∅` as `(sInf s, sInf s)`, we include it into the list of\npossible cases to improve readability. -/\ntheorem setOf_isPreconnected_eq_of_ordered :\n { s : Set α | IsPreconnected s } =\n -- bounded intervals\n range (uncurry Icc) ∪ range (uncurry Ico) ∪ range (uncurry Ioc) ∪ range (uncurry Ioo) ∪\n -- unbounded intervals and `univ`\n (range Ici ∪ range Ioi ∪ range Iic ∪ range Iio ∪ {univ, ∅}) := by sorry\nlemma isTotallyDisconnected_iff_lt {s : Set α} :\n IsTotallyDisconnected s ↔ ∀ x ∈ s, ∀ y ∈ s, x < y → ∃ z ∉ s, z ∈ Ioo x y := by sorry\nvariable {δ : Type*} [LinearOrder δ] [TopologicalSpace δ] [OrderClosedTopology δ]\n\n/-- **Intermediate Value Theorem** for continuous functions on closed intervals, case\n`f a ≤ t ≤ f b`. -/\ntheorem intermediate_value_Icc {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :\n Icc (f a) (f b) ⊆ f '' Icc a b :=\n isPreconnected_Icc.intermediate_value (left_mem_Icc.2 hab) (right_mem_Icc.2 hab) hf\n\n/-- **Intermediate Value Theorem** for continuous functions on closed intervals, case\n`f a ≥ t ≥ f b`. -/\ntheorem intermediate_value_Icc' {a b : α} (hab : a ≤ b) {f : α → δ}\n (hf : ContinuousOn f (Icc a b)) : Icc (f b) (f a) ⊆ f '' Icc a b :=\n isPreconnected_Icc.intermediate_value (right_mem_Icc.2 hab) (left_mem_Icc.2 hab) hf\n\n/-- **Intermediate Value Theorem** for continuous functions on closed intervals, unordered case. -/\ntheorem intermediate_value_uIcc {a b : α} {f : α → δ} (hf : ContinuousOn f [[a, b]]) :\n [[f a, f b]] ⊆ f '' uIcc a b := by sorry\ntheorem exists_mem_uIcc_isFixedPt {a b : α} {f : α → α} (hf : ContinuousOn f (uIcc a b))\n (ha : a ≤ f a) (hb : f b ≤ b) : ∃ c ∈ [[a, b]], IsFixedPt f c :=\n isPreconnected_uIcc.intermediate_value₂ right_mem_uIcc left_mem_uIcc hf continuousOn_id hb ha\n\n/-- If `f : α → α` is continuous on `[a, b]`, `a ≤ b`, `a ≤ f a`, and `f b ≤ b`,\nthen `f` has a fixed point on `[a, b]`.\n\nIn particular, if `[a, b]` is forward-invariant under `f`,\nthen `f` has a fixed point on `[a, b]`, see `exists_mem_Icc_isFixedPt_of_mapsTo`. -/\ntheorem exists_mem_Icc_isFixedPt {a b : α} {f : α → α} (hf : ContinuousOn f (Icc a b))\n (hle : a ≤ b) (ha : a ≤ f a) (hb : f b ≤ b) : ∃ c ∈ Icc a b, IsFixedPt f c :=\n isPreconnected_Icc.intermediate_value₂\n (right_mem_Icc.2 hle) (left_mem_Icc.2 hle) hf continuousOn_id hb ha\n\n/-- If a closed interval is forward-invariant under a continuous map `f : α → α`,\nthen this map has a fixed point on this interval. -/\ntheorem exists_mem_Icc_isFixedPt_of_mapsTo {a b : α} {f : α → α} (hf : ContinuousOn f (Icc a b))\n (hle : a ≤ b) (hmaps : MapsTo f (Icc a b) (Icc a b)) : ∃ c ∈ Icc a b, IsFixedPt f c :=\n exists_mem_Icc_isFixedPt hf hle (hmaps <| left_mem_Icc.2 hle).1 (hmaps <| right_mem_Icc.2 hle).2\n\ntheorem intermediate_value_Ico {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :\n Ico (f a) (f b) ⊆ f '' Ico a b :=\n Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.2 (not_lt_of_ge (he ▸ h.1))) fun hlt =>\n @IsPreconnected.intermediate_value_Ico _ _ _ _ _ _ _ isPreconnected_Ico _ _ ⟨refl a, hlt⟩\n (right_nhdsWithin_Ico_neBot hlt) inf_le_right _ (hf.mono Ico_subset_Icc_self) _\n ((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ico_subset_Icc_self)\n\ntheorem intermediate_value_Ico' {a b : α} (hab : a ≤ b) {f : α → δ}\n (hf : ContinuousOn f (Icc a b)) : Ioc (f b) (f a) ⊆ f '' Ico a b :=\n Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.1 (not_lt_of_ge (he ▸ h.2))) fun hlt =>\n @IsPreconnected.intermediate_value_Ioc _ _ _ _ _ _ _ isPreconnected_Ico _ _ ⟨refl a, hlt⟩\n (right_nhdsWithin_Ico_neBot hlt) inf_le_right _ (hf.mono Ico_subset_Icc_self) _\n ((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ico_subset_Icc_self)\n\ntheorem intermediate_value_Ioc {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :\n Ioc (f a) (f b) ⊆ f '' Ioc a b :=\n Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.2 (not_le_of_gt (he ▸ h.1))) fun hlt =>\n @IsPreconnected.intermediate_value_Ioc _ _ _ _ _ _ _ isPreconnected_Ioc _ _ ⟨hlt, refl b⟩\n (left_nhdsWithin_Ioc_neBot hlt) inf_le_right _ (hf.mono Ioc_subset_Icc_self) _\n ((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioc_subset_Icc_self)\n\ntheorem intermediate_value_Ioc' {a b : α} (hab : a ≤ b) {f : α → δ}\n (hf : ContinuousOn f (Icc a b)) : Ico (f b) (f a) ⊆ f '' Ioc a b :=\n Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.1 (not_le_of_gt (he ▸ h.2))) fun hlt =>\n @IsPreconnected.intermediate_value_Ico _ _ _ _ _ _ _ isPreconnected_Ioc _ _ ⟨hlt, refl b⟩\n (left_nhdsWithin_Ioc_neBot hlt) inf_le_right _ (hf.mono Ioc_subset_Icc_self) _\n ((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioc_subset_Icc_self)\n\ntheorem intermediate_value_Ioo {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :\n Ioo (f a) (f b) ⊆ f '' Ioo a b :=\n Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.2 (not_lt_of_gt (he ▸ h.1))) fun hlt =>\n @IsPreconnected.intermediate_value_Ioo _ _ _ _ _ _ _ isPreconnected_Ioo _ _\n (left_nhdsWithin_Ioo_neBot hlt) (right_nhdsWithin_Ioo_neBot hlt) inf_le_right inf_le_right _\n (hf.mono Ioo_subset_Icc_self) _ _\n ((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioo_subset_Icc_self)\n ((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ioo_subset_Icc_self)\n\ntheorem intermediate_value_Ioo' {a b : α} (hab : a ≤ b) {f : α → δ}\n (hf : ContinuousOn f (Icc a b)) : Ioo (f b) (f a) ⊆ f '' Ioo a b :=\n Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.1 (not_lt_of_gt (he ▸ h.2))) fun hlt =>\n @IsPreconnected.intermediate_value_Ioo _ _ _ _ _ _ _ isPreconnected_Ioo _ _\n (right_nhdsWithin_Ioo_neBot hlt) (left_nhdsWithin_Ioo_neBot hlt) inf_le_right inf_le_right _\n (hf.mono Ioo_subset_Icc_self) _ _\n ((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ioo_subset_Icc_self)\n ((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioo_subset_Icc_self)\n\n/-- **Intermediate value theorem**: if `f` is continuous on an order-connected set `s` and `a`,\n`b` are two points of this set, then `f` sends `s` to a superset of `Icc (f a) (f b)`. -/\ntheorem ContinuousOn.surjOn_Icc {s : Set α} [hs : OrdConnected s] {f : α → δ}\n (hf : ContinuousOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) : SurjOn f s (Icc (f a) (f b)) :=\n hs.isPreconnected.intermediate_value ha hb hf\n\n/-- **Intermediate value theorem**: if `f` is continuous on an order-connected set `s` and `a`,\n`b` are two points of this set, then `f` sends `s` to a superset of `[f a, f b]`. -/\ntheorem ContinuousOn.surjOn_uIcc {s : Set α} [hs : OrdConnected s] {f : α → δ}\n (hf : ContinuousOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :\n SurjOn f s (uIcc (f a) (f b)) := by sorry\ntheorem Continuous.surjective {f : α → δ} (hf : Continuous f) (h_top : Tendsto f atTop atTop)\n (h_bot : Tendsto f atBot atBot) : Function.Surjective f := fun p =>\n mem_range_of_exists_le_of_exists_ge hf (h_bot.eventually (eventually_le_atBot p)).exists\n (h_top.eventually (eventually_ge_atTop p)).exists\n\n/-- A continuous function which tends to `Filter.atBot` along `Filter.atTop` and to `Filter.atTop`\nalong `Filter.atBot` is surjective. -/\ntheorem Continuous.surjective' {f : α → δ} (hf : Continuous f) (h_top : Tendsto f atBot atTop)\n (h_bot : Tendsto f atTop atBot) : Function.Surjective f :=\n Continuous.surjective (α := αᵒᵈ) hf h_top h_bot\n\n/-- If a function `f : α → β` is continuous on a nonempty interval `s`, its restriction to `s`\ntends to `Filter.atBot : Filter β` along `Filter.atBot : Filter ↥s` and tends to\n`Filter.atTop : Filter β` along `Filter.atTop : Filter ↥s`, then the restriction of `f` to `s` is\nsurjective. We formulate the conclusion as `Function.surjOn f s Set.univ`. -/\ntheorem ContinuousOn.surjOn_of_tendsto {f : α → δ} {s : Set α} [OrdConnected s] (hs : s.Nonempty)\n (hf : ContinuousOn f s) (hbot : Tendsto (fun x : s => f x) atBot atBot)\n (htop : Tendsto (fun x : s => f x) atTop atTop) : SurjOn f s univ :=\n haveI := Classical.inhabited_of_nonempty hs.to_subtype\n surjOn_iff_surjective.2 <| hf.restrict.surjective htop hbot\n\n/-- If a function `f : α → β` is continuous on a nonempty interval `s`, its restriction to `s`\ntends to `Filter.atTop : Filter β` along `Filter.atBot : Filter ↥s` and tends to\n`Filter.atBot : Filter β` along `Filter.atTop : Filter ↥s`, then the restriction of `f` to `s` is\nsurjective. We formulate the conclusion as `Function.surjOn f s Set.univ`. -/\ntheorem ContinuousOn.surjOn_of_tendsto' {f : α → δ} {s : Set α} [OrdConnected s] (hs : s.Nonempty)\n (hf : ContinuousOn f s) (hbot : Tendsto (fun x : s => f x) atBot atTop)\n (htop : Tendsto (fun x : s => f x) atTop atBot) : SurjOn f s univ :=\n ContinuousOn.surjOn_of_tendsto (δ := δᵒᵈ) hs hf hbot htop\n\ntheorem Continuous.strictMono_of_inj_boundedOrder [BoundedOrder α] {f : α → δ}\n (hf_c : Continuous f) (hf : f ⊥ ≤ f ⊤) (hf_i : Injective f) : StrictMono f := by sorry\ntheorem Continuous.strictAnti_of_inj_boundedOrder [BoundedOrder α] {f : α → δ}\n (hf_c : Continuous f) (hf : f ⊤ ≤ f ⊥) (hf_i : Injective f) : StrictAnti f :=\n hf_c.strictMono_of_inj_boundedOrder (δ := δᵒᵈ) hf hf_i\n\ntheorem Continuous.strictMono_of_inj_boundedOrder' [BoundedOrder α] {f : α → δ}\n (hf_c : Continuous f) (hf_i : Injective f) : StrictMono f ∨ StrictAnti f :=\n (le_total (f ⊥) (f ⊤)).imp\n (hf_c.strictMono_of_inj_boundedOrder · hf_i)\n (hf_c.strictAnti_of_inj_boundedOrder · hf_i)\n\n/-- Suppose `α` is equipped with a conditionally complete linear dense order and `f : α → δ` is\ncontinuous and injective. Then `f` is strictly monotone (increasing) if\nit is strictly monotone (increasing) on some closed interval `[a, b]`. -/\ntheorem Continuous.strictMonoOn_of_inj_rigidity {f : α → δ}\n (hf_c : Continuous f) (hf_i : Injective f) {a b : α} (hab : a < b)\n (hf_mono : StrictMonoOn f (Icc a b)) : StrictMono f := by sorry\ntheorem ContinuousOn.strictMonoOn_of_injOn_Icc {a b : α} {f : α → δ}\n (hab : a ≤ b) (hfab : f a ≤ f b)\n (hf_c : ContinuousOn f (Icc a b)) (hf_i : InjOn f (Icc a b)) :\n StrictMonoOn f (Icc a b) := by sorry\ntheorem ContinuousOn.strictAntiOn_of_injOn_Icc {a b : α} {f : α → δ}\n (hab : a ≤ b) (hfab : f b ≤ f a)\n (hf_c : ContinuousOn f (Icc a b)) (hf_i : InjOn f (Icc a b)) :\n StrictAntiOn f (Icc a b) := ContinuousOn.strictMonoOn_of_injOn_Icc (δ := δᵒᵈ) hab hfab hf_c hf_i\n\n/-- Suppose `f : [a, b] → δ` is continuous and injective. Then `f` is strictly monotone\nor antitone (increasing or decreasing). -/\ntheorem ContinuousOn.strictMonoOn_of_injOn_Icc' {a b : α} {f : α → δ} (hab : a ≤ b)\n (hf_c : ContinuousOn f (Icc a b)) (hf_i : InjOn f (Icc a b)) :\n StrictMonoOn f (Icc a b) ∨ StrictAntiOn f (Icc a b) :=\n (le_total (f a) (f b)).imp\n (ContinuousOn.strictMonoOn_of_injOn_Icc hab · hf_c hf_i)\n (ContinuousOn.strictAntiOn_of_injOn_Icc hab · hf_c hf_i)\n\n/-- Suppose `α` is equipped with a conditionally complete linear dense order and `f : α → δ` is\ncontinuous and injective. Then `f` is strictly monotone or antitone (increasing or decreasing). -/\ntheorem Continuous.strictMono_of_inj {f : α → δ}\n (hf_c : Continuous f) (hf_i : Injective f) : StrictMono f ∨ StrictAnti f := by sorry\ntheorem ContinuousOn.strictMonoOn_of_injOn_Ioo {a b : α} {f : α → δ} (hab : a < b)\n (hf_c : ContinuousOn f (Ioo a b)) (hf_i : InjOn f (Ioo a b)) :\n StrictMonoOn f (Ioo a b) ∨ StrictAntiOn f (Ioo a b) := by sorry\n" }, { "theorem_id": 62, "title": "079_the_intermediate_value_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From Stdlib Require Import Sumbool.\nFrom Stdlib Require Import Rbase.\nFrom Stdlib Require Import Rfunctions.\nFrom Stdlib Require Import SeqSeries.\nFrom Stdlib Require Import Ranalysis1.\nFrom Stdlib Require Import Lra.\n#[local] Open Scope R_scope.\n\nFixpoint Dichotomy_lb (x y:R) (P:R -> bool) (N:nat) {struct N} : R :=\n match N with\n | O => x\n | S n =>\n let down := Dichotomy_lb x y P n in\n let up := Dichotomy_ub x y P n in\n let z := (down + up) / 2 in if P z then down else z\n end\n\n with Dichotomy_ub (x y:R) (P:R -> bool) (N:nat) {struct N} : R :=\n match N with\n | O => y\n | S n =>\n let down := Dichotomy_lb x y P n in\n let up := Dichotomy_ub x y P n in\n let z := (down + up) / 2 in if P z then z else up\n end.\n\nDefinition dicho_lb (x y:R) (P:R -> bool) (N:nat) : R := Dichotomy_lb x y P N.\nDefinition dicho_up (x y:R) (P:R -> bool) (N:nat) : R := Dichotomy_ub x y P N.\n\nLemma dicho_comp :\n forall (x y:R) (P:R -> bool) (n:nat),\n x <= y -> dicho_lb x y P n <= dicho_up x y P n.\nProof.\nAdmitted.\n\nLemma dicho_lb_growing :\n forall (x y:R) (P:R -> bool), x <= y -> Un_growing (dicho_lb x y P).\nProof.\nAdmitted.\n\nLemma dicho_up_decreasing :\n forall (x y:R) (P:R -> bool), x <= y -> Un_decreasing (dicho_up x y P).\nProof.\nAdmitted.\n\nLemma dicho_lb_maj_y :\n forall (x y:R) (P:R -> bool), x <= y -> forall n:nat, dicho_lb x y P n <= y.\nProof.\nAdmitted.\n\nLemma dicho_lb_maj :\n forall (x y:R) (P:R -> bool), x <= y -> has_ub (dicho_lb x y P).\nProof.\nAdmitted.\n\nLemma dicho_up_min_x :\n forall (x y:R) (P:R -> bool), x <= y -> forall n:nat, x <= dicho_up x y P n.\nProof.\nAdmitted.\n\nLemma dicho_up_min :\n forall (x y:R) (P:R -> bool), x <= y -> has_lb (dicho_up x y P).\nProof.\nAdmitted.\n\nLemma dicho_lb_cv :\n forall (x y:R) (P:R -> bool),\n x <= y -> { l:R | Un_cv (dicho_lb x y P) l }.\nProof.\nAdmitted.\n\nLemma dicho_up_cv :\n forall (x y:R) (P:R -> bool),\n x <= y -> { l:R | Un_cv (dicho_up x y P) l }.\nProof.\nAdmitted.\n\nLemma dicho_lb_dicho_up :\n forall (x y:R) (P:R -> bool) (n:nat),\n x <= y -> dicho_up x y P n - dicho_lb x y P n = (y - x) / 2 ^ n.\nProof.\nAdmitted.\n\nDefinition pow_2_n (n:nat) := 2 ^ n.\n\nLemma pow_2_n_neq_R0 : forall n:nat, pow_2_n n <> 0.\nProof.\nAdmitted.\n\nLemma pow_2_n_growing : Un_growing pow_2_n.\nProof.\nAdmitted.\n\nLemma pow_2_n_infty : cv_infty pow_2_n.\nProof.\nAdmitted.\n\nLemma cv_dicho :\n forall (x y l1 l2:R) (P:R -> bool),\n x <= y ->\n Un_cv (dicho_lb x y P) l1 -> Un_cv (dicho_up x y P) l2 -> l1 = l2.\nProof.\nAdmitted.\n\nDefinition cond_positivity (x:R) : bool :=\n match Rle_dec 0 x with\n | left _ => true\n | right _ => false\n end.\n\nLemma continuity_seq :\n forall (f:R -> R) (Un:nat -> R) (l:R),\n continuity_pt f l -> Un_cv Un l -> Un_cv (fun i:nat => f (Un i)) (f l).\nProof.\nAdmitted.\n\nLemma dicho_lb_car :\n forall (x y:R) (P:R -> bool) (n:nat),\n P x = false -> P (dicho_lb x y P n) = false.\nProof.\nAdmitted.\n\nLemma dicho_up_car :\n forall (x y:R) (P:R -> bool) (n:nat),\n P y = true -> P (dicho_up x y P n) = true.\nProof.\nAdmitted.\n\nLemma cv_pow_half : forall a, Un_cv (fun n => a/2^n) 0.\nProof.\nAdmitted.\n\nLemma IVT :\n forall (f:R -> R) (x y:R),\n continuity f ->\n x < y -> f x < 0 -> 0 < f y -> { z:R | x <= z <= y /\\ f z = 0 }.\nProof.\nAdmitted.\n\nLemma IVT_cor :\n forall (f:R -> R) (x y:R),\n continuity f ->\n x <= y -> f x * f y <= 0 -> { z:R | x <= z <= y /\\ f z = 0 }.\nProof.\nAdmitted.\n\nLemma Rsqrt_exists :\n forall y:R, 0 <= y -> { z:R | 0 <= z /\\ y = Rsqr z }.\nProof.\nAdmitted.\n\nDefinition Rsqrt (y:nonnegreal) : R :=\n let (a,_) := Rsqrt_exists (nonneg y) (cond_nonneg y) in a.\n\nLemma Rsqrt_positivity : forall x:nonnegreal, 0 <= Rsqrt x.\nProof.\nAdmitted.\n\nLemma Rsqrt_Rsqrt : forall x:nonnegreal, Rsqrt x * Rsqrt x = x.\nProof.\nAdmitted." }, { "theorem_id": 63, "title": "083_the_friendship_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";;\nneeds \"Library/pocklington.ml\";;\n\nlet GCD_INDUCT = `!P. (!m n. P m /\\ P (m + n) ==> P n)\n ==> !m n. P m /\\ P n ==> P (gcd(m,n))`;;\n\nlet LOOP_GCD = `!x m n. (!i. x(i + m) = x(i)) /\\ (!i. x(i + n) = x(i))\n ==> !i. x(i + gcd(m,n)) = x(i)`;;\n\nlet LOOP_COPRIME = `!x m n. (!i. x(i + m) = x(i)) /\\ (!i. x(i + n) = x(i)) /\\ coprime(m,n)\n ==> !i. x i = x 0`;;\n\nlet EQUIVALENCE_UNIFORM_PARTITION = `!R s k. FINITE s /\\\n (!x. x IN s ==> R x x) /\\\n (!x y. R x y ==> R y x) /\\\n (!x y z. R x y /\\ R y z ==> R x z) /\\\n (!x:A. x IN s ==> CARD {y | y IN s /\\ R x y} = k)\n ==> k divides (CARD s)`;;\n\nlet EQUIVALENCE_UNIFORM_PARTITION_RESTRICT = `!R s k. FINITE s /\\\n (!x. x IN s ==> R x x) /\\\n (!x y. x IN s /\\ y IN s /\\ R x y ==> R y x) /\\\n (!x y z. x IN s /\\ y IN s /\\ z IN s /\\ R x y /\\ R y z ==> R x z) /\\\n (!x:A. x IN s ==> CARD {y | y IN s /\\ R x y} = k)\n ==> k divides (CARD s)`;;\n\nlet ELEMENTS_PAIR_UP = `!s r. FINITE s /\\\n (!x. x IN s ==> ~(r x x)) /\\\n (!x y. x IN s /\\ y IN s /\\ r x y ==> r y x) /\\\n (!x:A. x IN s ==> ?!y. y IN s /\\ r x y)\n ==> EVEN(CARD s)`;;\n\nlet cycle = new_definition\n `cycle r k x <=> (!i. r (x i) (x(i + 1))) /\\ (!i. x(i + k) = x(i))`;;\n\nlet path = new_definition\n `path r k x <=> (!i. i < k ==> r (x i) (x(i + 1))) /\\\n (!i. k < i ==> x(i) = @x. T)`;;\n\nlet CYCLE_OFFSET = `!r k x:num->A. cycle r k x ==> !i m. x(m * k + i) = x(i)`;;\n\nlet CYCLE_MOD = `!r k x:num->A. cycle r k x /\\ ~(k = 0) ==> !i. x(i MOD k) = x(i)`;;\n\nlet PATHS_MONO = `(!x y. r x y ==> s x y) ==> {x | path r k x} SUBSET {x | path s k x}`;;\n\nlet HAS_SIZE_PATHS = `!N m r k. (:A) HAS_SIZE N /\\ (!x. {y | r x y} HAS_SIZE m)\n ==> {x:num->A | path r k x} HAS_SIZE (N * m EXP k)`;;\n\nlet FINITE_PATHS = `!r k. FINITE(:A) ==> FINITE {x:num->A | path r k x}`;;\n\nlet HAS_SIZE_CYCLES = `!r k. FINITE(:A) /\\ ~(k = 0)\n ==> {x:num->A | cycle r k x} HAS_SIZE\n CARD{x:num->A | path r k x /\\ x(k) = x(0)}`;;\n\nlet FINITE_CYCLES = `!r k. FINITE(:A) /\\ ~(k = 0) ==> FINITE {x:num->A | cycle r k x}`;;\n\nlet CARD_PATHCYCLES_STEP = `!N m r k.\n (:A) HAS_SIZE N /\\ ~(k = 0) /\\ ~(m = 0) /\\\n (!x:A. {y | r x y} HAS_SIZE m) /\\\n (!x y. r x y ==> r y x) /\\\n (!x y. ~(x = y) ==> ?!z. r x z /\\ r z y)\n ==> {x | path r (k + 2) x /\\ x(k + 2) = x(0)} HAS_SIZE\n (m * CARD {x | path r k x /\\ x(k) = x(0)} +\n CARD {x | path r (k) x /\\ ~(x(k) = x(0))})`;;\n\nlet shiftable = new_definition\n `shiftable x y <=> ?k. !i. x(i) = y(i + k)`;;\n\nlet SHIFTABLE_REFL = `!x. shiftable x x`;;\n\nlet SHIFTABLE_TRANS = `!x y z. shiftable x y /\\ shiftable y z ==> shiftable x z`;;\n\nlet SHIFTABLE_LOCAL = `!x y p r. cycle r p x /\\ cycle r p y /\\ ~(p = 0)\n ==> (shiftable x y <=> ?k. k < p /\\ !i. x(i) = y(i + k))`;;\n\nlet SHIFTABLE_SYM = `!x y p r. cycle r p x /\\ cycle r p y /\\ ~(p = 0) /\\ shiftable x y\n ==> shiftable y x`;;\n\nlet CYCLES_PRIME_LEMMA = `!r p x. FINITE(:A) /\\ prime p /\\ (!x. ~(r x x))\n ==> p divides CARD {x:num->A | cycle r p x}`;;\n\nlet FRIENDSHIP = `!friend:person->person->bool.\n FINITE(:person) /\\\n (!x. ~(friend x x)) /\\\n (!x y. friend x y ==> friend y x) /\\\n (!x y. ~(x = y) ==> ?!z. friend x z /\\ friend y z)\n ==> ?u. !v. ~(v = u) ==> friend u v`;;" }, { "theorem_id": 63, "title": "083_the_friendship_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory FriendshipTheory \n imports MoreGraph \"HOL-Number_Theory.Number_Theory\"\nbegin\n\nsection\\Common steps\\\n\ndefinition (in valid_unSimpGraph) non_adj :: \"'v \\ 'v \\ bool\" where\n \"non_adj v v' \\ v\\V \\ v'\\V \\ v\\v' \\ \\adjacent v v'\" \n\nlemma (in valid_unSimpGraph) no_quad:\n assumes \"\\v u. v\\V \\ u\\V \\ v\\u \\ \\! n. adjacent v n \\ adjacent u n\"\n shows \"\\ (\\v1 v2 v3 v4. v2\\v4 \\ v1\\v3 \\ adjacent v1 v2 \\ adjacent v2 v3 \\ adjacent v3 v4 \n \\ adjacent v4 v1)\"\n by sorry\n\nlemma even_card_set: \n assumes \"finite A\" and \"\\x\\A. f x\\A \\ f x\\ x \\ f (f x)=x\"\n shows \"even(card A)\" using assms\n by sorry\n\nlemma (in valid_unSimpGraph) even_degree:\n assumes friend_assm:\"\\v u. v\\V \\ u\\V \\ v\\u \\ \\! n. adjacent v n \\ adjacent u n\" \n and \"finite E\"\n shows \"\\v\\V. even(degree v G)\"\n by sorry\n\nlemma (in valid_unSimpGraph) degree_two_windmill:\n assumes friend_assm:\"\\v u. v\\V \\ u\\V \\ v\\u \\ \\! n. adjacent v n \\ adjacent u n\"\n and \"finite E\" and \"card V\\2\"\n shows \"(\\v\\V. degree v G = 2) \\(\\v. \\n\\V. n\\v \\ adjacent v n)\"\n by sorry\n\nlemma (in valid_unSimpGraph) regular:\n assumes friend_assm:\"\\v u. v\\V \\ u\\V \\ v\\u \\ \\! n. adjacent v n \\ adjacent u n\" \n and \"finite E\" and \"finite V\" and \"\\(\\v\\V. degree v G = 2)\"\n shows \"\\k. \\v\\V. degree v G = k\"\n by sorry\n\nsection\\Exclusive steps for combinatorial proofs\\\n\nfun (in valid_unSimpGraph) adj_path:: \"'v \\ 'v list \\bool\" where\n \"adj_path v [] = (v\\V)\" \n | \"adj_path v (u#us)= (adjacent v u \\ adj_path u us)\"\n\nlemma (in valid_unSimpGraph) adj_path_butlast:\n \"adj_path v ps \\ adj_path v (butlast ps)\"\n by sorry\n\nlemma (in valid_unSimpGraph) adj_path_V:\n \"adj_path v ps \\ set ps \\ V\"\n by sorry\n\nlemma (in valid_unSimpGraph) adj_path_V':\n \"adj_path v ps \\ v\\ V\"\n by sorry\n\nlemma (in valid_unSimpGraph) adj_path_app:\n \"adj_path v ps \\ ps\\[] \\ adjacent (last ps) u \\ adj_path v (ps@[u])\"\n by sorry\n\nlemma (in valid_unSimpGraph) adj_path_app':\n \"adj_path v (ps @ [q] ) \\ ps \\ [] \\ adjacent (last ps) q\"\n by sorry\n\nlemma card_partition':\n assumes \"\\v\\A. card {n. R v n} = k\" \"k>0\" \"finite A\" \n \"\\v1 v2. v1\\v2 \\ {n. R v1 n} \\ {n. R v2 n}={}\"\n shows \"card (\\v\\A. {n. R v n}) = k * card A\"\n by sorry\n\nlemma (in valid_unSimpGraph) path_count:\n assumes k_adj:\"\\v. v\\V \\ card {n. adjacent v n} = k\" and \"v\\V\" and \"finite V\" and \"k>0\"\n shows \"card {ps. length ps=l \\ adj_path v ps}=k^l\"\n by sorry\n\nlemma (in valid_unSimpGraph) total_v_num:\n assumes friend_assm:\"\\v u. v\\V \\ u\\V \\ v\\u \\ \\! n. adjacent v n \\ adjacent u n\" \n and \"finite E\" and \"finite V\" and \"V\\{}\" and \" \\v\\V. degree v G = k\" and \"k>0\"\n shows \"card V= k*k - k +1\"\n by sorry\n\nlemma rotate_eq:\"rotate1 xs=rotate1 ys \\ xs=ys\" \n by sorry\n \nlemma rotate_diff:\"rotate m xs=rotate n xs \\rotate (m-n) xs = xs\"\n by sorry\n\nlemma (in valid_unSimpGraph) exist_degree_two:\n assumes friend_assm:\"\\v u. v\\V \\ u\\V \\ v\\u \\ \\! n. adjacent v n \\ adjacent u n\"\n and \"finite E\" and \"finite V\" and \"card V\\2\" \n shows \"\\v\\V. degree v G = 2\"\n by sorry\n\ntheorem (in valid_unSimpGraph) friendship_thm:\n assumes friend_assm:\"\\v u. v\\V \\ u\\V \\ v\\u \\ \\! n. adjacent v n \\ adjacent u n\"\n and \"finite V\" \n shows \"\\v. \\n\\V. n\\v \\ adjacent v n\" \n by sorry\n\nend" }, { "theorem_id": 63, "title": "083_the_friendship_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Aaron Anderson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Aaron Anderson, Jalex Stark, Kyle Miller\n-/\nimport Mathlib.Combinatorics.SimpleGraph.AdjMatrix\nimport Mathlib.LinearAlgebra.Matrix.Charpoly.FiniteField\n\n/-!\n# The Friendship Theorem\n\n## Definitions and Statement\n- A `Friendship` graph is one in which any two distinct vertices have exactly one neighbor in common\n- A `Politician`, at least in the context of this problem, is a vertex in a graph which is adjacent\n to every other vertex.\n- The friendship theorem (Erdős, Rényi, Sós 1966) states that every finite friendship graph has a\n politician.\n\n## Proof outline\nThe proof revolves around the theory of adjacency matrices, although some steps could equivalently\nbe phrased in terms of counting walks.\n- Assume `G` is a finite friendship graph.\n- First we show that any two nonadjacent vertices have the same degree\n- Assume for contradiction that `G` does not have a politician.\n- Conclude from the last two points that `G` is `d`-regular for some `d : ℕ`.\n- Show that `G` has `d ^ 2 - d + 1` vertices.\n- By casework, show that if `d = 0, 1, 2`, then `G` has a politician.\n- If `3 ≤ d`, let `p` be a prime factor of `d - 1`.\n- If `A` is the adjacency matrix of `G` with entries in `ℤ/pℤ`, we show that `A ^ p` has trace `1`.\n- This gives a contradiction, as `A` has trace `0`, and thus `A ^ p` has trace `0`.\n\n## References\n- [P. Erdős, A. Rényi, V. Sós, *On A Problem of Graph Theory*][erdosrenyisos]\n- [C. Huneke, *The Friendship Theorem*][huneke2002]\n\n-/\n\nnamespace Theorems100\n\nnoncomputable section\n\nopen Finset SimpleGraph Matrix\n\nuniverse u v\n\nvariable {V : Type u} {R : Type v} [Semiring R]\n\nsection FriendshipDef\n\nvariable (G : SimpleGraph V)\n\nopen scoped Classical in\n/-- This property of a graph is the hypothesis of the friendship theorem:\nevery pair of nonadjacent vertices has exactly one common friend,\na vertex to which both are adjacent.\n-/\ndef Friendship [Fintype V] : Prop :=\n ∀ ⦃v w : V⦄, v ≠ w → Fintype.card (G.commonNeighbors v w) = 1\n\n/-- A politician is a vertex that is adjacent to all other vertices.\n-/\ndef ExistsPolitician : Prop :=\n ∃ v : V, ∀ w : V, v ≠ w → G.Adj v w\n\nend FriendshipDef\n\nvariable [Fintype V] {G : SimpleGraph V} {d : ℕ} (hG : Friendship G)\n\nnamespace Friendship\n\nvariable (R)\n\nset_option backward.isDefEq.respectTransparency false in\nopen scoped Classical in\ninclude hG in\n/-- One characterization of a friendship graph is that there is exactly one walk of length 2\n between distinct vertices. These walks are counted in off-diagonal entries of the square of\n the adjacency matrix, so for a friendship graph, those entries are all 1. -/\ntheorem adjMatrix_sq_of_ne {v w : V} (hvw : v ≠ w) :\n (G.adjMatrix R ^ 2 : Matrix V V R) v w = 1 := by sorry\nopen scoped Classical in\ninclude hG in\n/-- This calculation amounts to counting the number of length 3 walks between nonadjacent vertices.\n We use it to show that nonadjacent vertices have equal degrees. -/\ntheorem adjMatrix_pow_three_of_not_adj {v w : V} (non_adj : ¬G.Adj v w) :\n (G.adjMatrix R ^ 3 : Matrix V V R) v w = degree G v := by sorry\nvariable {R}\n\nopen scoped Classical in\ninclude hG in\n/-- As `v` and `w` not being adjacent implies\n `degree G v = ((G.adjMatrix R) ^ 3) v w` and `degree G w = ((G.adjMatrix R) ^ 3) v w`,\n the degrees are equal if `((G.adjMatrix R) ^ 3) v w = ((G.adjMatrix R) ^ 3) w v`\n\n This is true as the adjacency matrix is symmetric. -/\ntheorem degree_eq_of_not_adj {v w : V} (hvw : ¬G.Adj v w) : degree G v = degree G w := by sorry\nopen scoped Classical in\ninclude hG in\n/-- Let `A` be the adjacency matrix of a graph `G`.\n If `G` is a friendship graph, then all of the off-diagonal entries of `A^2` are 1.\n If `G` is `d`-regular, then all of the diagonal entries of `A^2` are `d`.\n Putting these together determines `A^2` exactly for a `d`-regular friendship graph. -/\ntheorem adjMatrix_sq_of_regular (hd : G.IsRegularOfDegree d) :\n G.adjMatrix R ^ 2 = of fun v w => if v = w then (d : R) else (1 : R) := by sorry\nopen scoped Classical in\ninclude hG in\ntheorem adjMatrix_sq_mod_p_of_regular {p : ℕ} (dmod : (d : ZMod p) = 1)\n (hd : G.IsRegularOfDegree d) : G.adjMatrix (ZMod p) ^ 2 = of fun _ _ => 1 := by sorry\nsection Nonempty\n\nvariable [Nonempty V]\n\nopen scoped Classical in\ninclude hG in\n/-- If `G` is a friendship graph without a politician (a vertex adjacent to all others), then\n it is regular. We have shown that nonadjacent vertices of a friendship graph have the same degree,\n and if there isn't a politician, we can show this for adjacent vertices by finding a vertex\n neither is adjacent to, and then using transitivity. -/\ntheorem isRegularOf_not_existsPolitician (hG' : ¬ExistsPolitician G) :\n ∃ d : ℕ, G.IsRegularOfDegree d := by sorry\nopen scoped Classical in\ninclude hG in\n/-- Let `A` be the adjacency matrix of a `d`-regular friendship graph, and let `v` be a vector\n all of whose components are `1`. Then `v` is an eigenvector of `A ^ 2`, and we can compute\n the eigenvalue to be `d * d`, or as `d + (Fintype.card V - 1)`, so those quantities must be equal.\n\n This essentially means that the graph has `d ^ 2 - d + 1` vertices. -/\ntheorem card_of_regular (hd : G.IsRegularOfDegree d) : d + (Fintype.card V - 1) = d * d := by sorry\nopen scoped Classical in\ninclude hG in\n/-- The size of a `d`-regular friendship graph is `1 mod (d-1)`, and thus `1 mod p` for a\n factor `p ∣ d-1`. -/\ntheorem card_mod_p_of_regular {p : ℕ} (dmod : (d : ZMod p) = 1) (hd : G.IsRegularOfDegree d) :\n (Fintype.card V : ZMod p) = 1 := by sorry\nend Nonempty\n\nopen scoped Classical in\ntheorem adjMatrix_sq_mul_const_one_of_regular (hd : G.IsRegularOfDegree d) :\n G.adjMatrix R * of (fun _ _ => 1) = of (fun _ _ => (d : R)) := by sorry\nopen scoped Classical in\ntheorem adjMatrix_mul_const_one_mod_p_of_regular {p : ℕ} (dmod : (d : ZMod p) = 1)\n (hd : G.IsRegularOfDegree d) :\n G.adjMatrix (ZMod p) * of (fun _ _ => 1) = of (fun _ _ => 1) := by sorry\nopen scoped Classical in\ninclude hG in\n/-- Modulo a factor of `d-1`, the square and all higher powers of the adjacency matrix\n of a `d`-regular friendship graph reduce to the matrix whose entries are all 1. -/\ntheorem adjMatrix_pow_mod_p_of_regular {p : ℕ} (dmod : (d : ZMod p) = 1)\n (hd : G.IsRegularOfDegree d) {k : ℕ} (hk : 2 ≤ k) :\n G.adjMatrix (ZMod p) ^ k = of (fun _ _ => 1) := by sorry\nvariable [Nonempty V]\n\nopen scoped Classical in\ninclude hG in\n/-- This is the main proof. Assuming that `3 ≤ d`, we take `p` to be a prime factor of `d-1`.\n Then the `p`th power of the adjacency matrix of a `d`-regular friendship graph must have trace 1\n mod `p`, but we can also show that the trace must be the `p`th power of the trace of the original\n adjacency matrix, which is 0, a contradiction.\n-/\ntheorem false_of_three_le_degree (hd : G.IsRegularOfDegree d) (h : 3 ≤ d) : False := by sorry\nopen scoped Classical in\ninclude hG in\n/-- If `d ≤ 1`, a `d`-regular friendship graph has at most one vertex, which is\n trivially a politician. -/\ntheorem existsPolitician_of_degree_le_one (hd : G.IsRegularOfDegree d) (hd1 : d ≤ 1) :\n ExistsPolitician G := by sorry\nopen scoped Classical in\ninclude hG in\n/-- If `d = 2`, a `d`-regular friendship graph has 3 vertices, so it must be complete graph,\n and all the vertices are politicians. -/\ntheorem neighborFinset_eq_of_degree_eq_two (hd : G.IsRegularOfDegree 2) (v : V) :\n G.neighborFinset v = Finset.univ.erase v := by sorry\nopen scoped Classical in\ninclude hG in\ntheorem existsPolitician_of_degree_eq_two (hd : G.IsRegularOfDegree 2) : ExistsPolitician G := by sorry\nopen scoped Classical in\ninclude hG in\ntheorem existsPolitician_of_degree_le_two (hd : G.IsRegularOfDegree d) (h : d ≤ 2) :\n ExistsPolitician G := by sorry\nend Friendship\n\ninclude hG in\n/-- **Friendship theorem**: We wish to show that a friendship graph has a politician (a vertex\n adjacent to all others). We proceed by contradiction, and assume the graph has no politician.\n We have already proven that a friendship graph with no politician is `d`-regular for some `d`,\n and now we do casework on `d`.\n If the degree is at most 2, we observe by casework that it has a politician anyway.\n If the degree is at least 3, the graph cannot exist. -/\ntheorem friendship_theorem [Nonempty V] : ExistsPolitician G := by sorry\nend\n\nend Theorems100\n" }, { "theorem_id": 63, "title": "083_the_friendship_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From mathcomp Require Import all_ssreflect.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nRequire Import Friendship.combinatorics.\nRequire Import Friendship.statement_reduction.\n\nTheorem Friendship'\n (T: finType) (T_nonempty: [set: T] != set0)\n (F : rel T) (Fsym: symmetric F) (Firr: irreflexive F)\n (Co: T -> T -> T) (Col: forall u v : T, u != v -> F u (Co u v))\n (Cor: forall u v : T, u != v -> F v (Co u v))\n (CoUnique: forall u v w : T, u != v -> F u w -> F v w -> w = Co u v):\n {u : T | forall v : T, u != v -> F u v}.\nProof.\nAdmitted.\n\nTheorem Friendship\n (T: finType) (T_nonempty: [set: T] != set0)\n (F : rel T) (Fsym: symmetric F) (Firr: irreflexive F) :\n\n (forall (u v: T), u != v -> #|[set w | F u w & F v w]| == 1) ->\n {u : T | forall v : T, u != v -> F u v}.\nProof.\nAdmitted." }, { "theorem_id": 64, "title": "085_divisibility_by_3_rule", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";;\nneeds \"Library/pocklington.ml\";;\n\nlet EXP_10_CONG_3 = `!n. (10 EXP n == 1) (mod 3)`;;\n\nlet SUM_CONG_3 = `!d n. (nsum(0..n) (\\i. 10 EXP i * d(i)) == nsum(0..n) (\\i. d i)) (mod 3)`;;\n\nlet DIVISIBILITY_BY_3 = `3 divides (nsum(0..n) (\\i. 10 EXP i * d(i))) <=>\n 3 divides (nsum(0..n) (\\i. d i))`;;" }, { "theorem_id": 64, "title": "085_divisibility_by_3_rule", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Congruence\\\n\ntheory Cong\n imports \"HOL-Computational_Algebra.Primes\"\nbegin\n\nsubsection \\Generic congruences\\\n \ncontext unique_euclidean_semiring\nbegin\n\ndefinition cong :: \"'a \\ 'a \\ 'a \\ bool\"\n (\\(\\indent=1 notation=\\mixfix cong\\\\[_ = _] '(' mod _'))\\)\n where \"[b = c] (mod a) \\ b mod a = c mod a\"\n \nabbreviation notcong :: \"'a \\ 'a \\ 'a \\ bool\"\n (\\(\\indent=1 notation=\\mixfix notcong\\\\[_ \\ _] '(' mod _'))\\)\n where \"[b \\ c] (mod a) \\ \\ cong b c a\"\n\nlemma cong_refl [simp]:\n \"[b = b] (mod a)\"\n by sorry\n\nlemma cong_sym: \n \"[b = c] (mod a) \\ [c = b] (mod a)\"\n by sorry\n\nlemma cong_sym_eq:\n \"[b = c] (mod a) \\ [c = b] (mod a)\"\n by sorry\n\nlemma cong_trans [trans]:\n \"[b = c] (mod a) \\ [c = d] (mod a) \\ [b = d] (mod a)\"\n by sorry\n\nlemma cong_mult_self_right:\n \"[b * a = 0] (mod a)\"\n by sorry\n\nlemma cong_mult_self_left:\n \"[a * b = 0] (mod a)\"\n by sorry\n\nlemma cong_mod_left [simp]:\n \"[b mod a = c] (mod a) \\ [b = c] (mod a)\"\n by sorry\n\nlemma cong_mod_right [simp]:\n \"[b = c mod a] (mod a) \\ [b = c] (mod a)\"\n by sorry\n\nlemma cong_0 [simp, presburger]:\n \"[b = c] (mod 0) \\ b = c\"\n by sorry\n\nlemma cong_1 [simp, presburger]:\n \"[b = c] (mod 1)\"\n by sorry\n\nlemma cong_dvd_iff:\n \"a dvd b \\ a dvd c\" if \"[b = c] (mod a)\"\n by sorry\n\nlemma cong_0_iff: \"[b = 0] (mod a) \\ a dvd b\"\n by sorry\n\nlemma cong_add:\n \"[b = c] (mod a) \\ [d = e] (mod a) \\ [b + d = c + e] (mod a)\"\n by sorry\n\nlemma cong_mult:\n \"[b = c] (mod a) \\ [d = e] (mod a) \\ [b * d = c * e] (mod a)\"\n by sorry\n\nlemma cong_scalar_right:\n \"[b = c] (mod a) \\ [b * d = c * d] (mod a)\"\n by sorry\n\nlemma cong_scalar_left:\n \"[b = c] (mod a) \\ [d * b = d * c] (mod a)\"\n by sorry\n\nlemma cong_pow:\n \"[b = c] (mod a) \\ [b ^ n = c ^ n] (mod a)\"\n by sorry\n\nlemma cong_sum:\n \"[sum f A = sum g A] (mod a)\" if \"\\x. x \\ A \\ [f x = g x] (mod a)\"\n by sorry\n\nlemma cong_prod:\n \"[prod f A = prod g A] (mod a)\" if \"(\\x. x \\ A \\ [f x = g x] (mod a))\"\n by sorry\n\nlemma mod_mult_cong_right:\n \"[c mod (a * b) = d] (mod a) \\ [c = d] (mod a)\"\n by sorry\n\nlemma mod_mult_cong_left:\n \"[c mod (b * a) = d] (mod a) \\ [c = d] (mod a)\"\n by sorry\n\nlemma cong_mod_leftI [simp]:\n \"[b = c] (mod a) \\ [b mod a = c] (mod a)\"\n by sorry\n\nlemma cong_mod_rightI [simp]:\n \"[b = c] (mod a) \\ [b = c mod a] (mod a)\"\n by sorry\n\nlemma cong_cmult_leftI: \"[a = b] (mod m) \\ [c * a = c * b] (mod (c * m))\"\n by sorry\n\nlemma cong_cmult_rightI: \"[a = b] (mod m) \\ [a * c = b * c] (mod (m * c))\"\n by sorry\n\nlemma cong_dvd_mono_modulus:\n assumes \"[a = b] (mod m)\" \"m' dvd m\"\n shows \"[a = b] (mod m')\"\n by sorry\n\nlemma coprime_cong_transfer_left:\n assumes \"coprime a b\" \"[a = a'] (mod b)\"\n shows \"coprime a' b\"\n by sorry\n\nlemma coprime_cong_transfer_right:\n assumes \"coprime a b\" \"[b = b'] (mod a)\"\n shows \"coprime a b'\"\n by sorry\n\nlemma coprime_cong_cong_left:\n assumes \"[a = a'] (mod b)\"\n shows \"coprime a b \\ coprime a' b\"\n by sorry\n\nlemma coprime_cong_cong_right:\n assumes \"[b = b'] (mod a)\"\n shows \"coprime a b \\ coprime a b'\"\n by sorry\n\nend\n\ncontext unique_euclidean_ring\nbegin\n\nlemma cong_diff:\n \"[b = c] (mod a) \\ [d = e] (mod a) \\ [b - d = c - e] (mod a)\"\n by sorry\n\nlemma cong_diff_iff_cong_0:\n \"[b - c = 0] (mod a) \\ [b = c] (mod a)\" (is \"?P \\ ?Q\")\n by sorry\n\nlemma cong_minus_minus_iff:\n \"[- b = - c] (mod a) \\ [b = c] (mod a)\"\n by sorry\n\nlemma cong_modulus_minus_iff [iff]:\n \"[b = c] (mod - a) \\ [b = c] (mod a)\"\n by sorry\n\nlemma cong_iff_dvd_diff:\n \"[a = b] (mod m) \\ m dvd (a - b)\"\n by sorry\n\nlemma cong_iff_lin:\n \"[a = b] (mod m) \\ (\\k. b = a + m * k)\" (is \"?P \\ ?Q\")\n by sorry\n\nlemma cong_add_lcancel:\n \"[a + x = a + y] (mod n) \\ [x = y] (mod n)\"\n by sorry\n\nlemma cong_add_rcancel:\n \"[x + a = y + a] (mod n) \\ [x = y] (mod n)\"\n by sorry\n\nlemma cong_add_lcancel_0:\n \"[a + x = a] (mod n) \\ [x = 0] (mod n)\"\n by sorry\n\nlemma cong_add_rcancel_0:\n \"[x + a = a] (mod n) \\ [x = 0] (mod n)\"\n by sorry\n\nlemma cong_dvd_modulus:\n \"[x = y] (mod n)\" if \"[x = y] (mod m)\" and \"n dvd m\"\n by sorry\n\nlemma cong_modulus_mult:\n \"[x = y] (mod m)\" if \"[x = y] (mod m * n)\"\n by sorry\n\nlemma cong_uminus: \"[x = y] (mod m) \\ [-x = -y] (mod m)\"\n by sorry\n\nend\n\nlemma cong_abs [simp]:\n \"[x = y] (mod \\m\\) \\ [x = y] (mod m)\"\n for x y :: \"'a :: {unique_euclidean_ring, linordered_idom}\"\n by sorry\n\nlemma cong_square:\n \"prime p \\ 0 < a \\ [a * a = 1] (mod p) \\ [a = 1] (mod p) \\ [a = - 1] (mod p)\"\n for a p :: \"'a :: {normalization_semidom, linordered_idom, unique_euclidean_ring}\"\n by sorry\n\nlemma cong_mult_rcancel:\n \"[a * k = b * k] (mod m) \\ [a = b] (mod m)\"\n if \"coprime k m\" for a k m :: \"'a::{unique_euclidean_ring, ring_gcd}\"\n by sorry\n\nlemma cong_mult_lcancel:\n \"[k * a = k * b] (mod m) = [a = b] (mod m)\"\n if \"coprime k m\" for a k m :: \"'a::{unique_euclidean_ring, ring_gcd}\"\n by sorry\n\nlemma coprime_cong_mult:\n \"[a = b] (mod m) \\ [a = b] (mod n) \\ coprime m n \\ [a = b] (mod m * n)\"\n for a b :: \"'a :: {unique_euclidean_ring, semiring_gcd}\"\n by sorry\n\nlemma cong_gcd_eq:\n \"gcd a m = gcd b m\" if \"[a = b] (mod m)\"\n for a b :: \"'a :: {unique_euclidean_semiring, euclidean_semiring_gcd}\"\n by sorry\n\nlemma cong_imp_coprime:\n \"[a = b] (mod m) \\ coprime a m \\ coprime b m\"\n for a b :: \"'a :: {unique_euclidean_semiring, euclidean_semiring_gcd}\"\n by sorry\n\nlemma cong_cong_prod_coprime:\n \"[x = y] (mod (\\i\\A. m i))\" if\n \"(\\i\\A. [x = y] (mod m i))\"\n \"(\\i\\A. (\\j\\A. i \\ j \\ coprime (m i) (m j)))\"\n for x y :: \"'a :: {unique_euclidean_ring, semiring_gcd}\"\n by sorry\n\nsubsection \\Congruences on \\<^typ>\\nat\\ and \\<^typ>\\int\\\\\n\nlemma cong_int_iff:\n \"[int m = int q] (mod int n) \\ [m = q] (mod n)\"\n by sorry\n\nlemma cong_Suc_0 [simp, presburger]:\n \"[m = n] (mod Suc 0)\"\n by sorry\n\nlemma cong_diff_nat:\n \"[a - c = b - d] (mod m)\" if \"[a = b] (mod m)\" \"[c = d] (mod m)\"\n and \"a \\ c\" \"b \\ d\" for a b c d m :: nat\n by sorry\n\nlemma cong_diff_iff_cong_0_nat:\n \"[a - b = 0] (mod m) \\ [a = b] (mod m)\" if \"a \\ b\" for a b :: nat\n by sorry\n\nlemma cong_diff_iff_cong_0_nat':\n \"[nat \\int a - int b\\ = 0] (mod m) \\ [a = b] (mod m)\"\n by sorry\n\nlemma cong_altdef_nat:\n \"a \\ b \\ [a = b] (mod m) \\ m dvd (a - b)\"\n for a b :: nat\n by sorry\n\nlemma cong_altdef_nat':\n \"[a = b] (mod m) \\ m dvd nat \\int a - int b\\\"\n by sorry\n\nlemma cong_mult_rcancel_nat:\n \"[a * k = b * k] (mod m) \\ [a = b] (mod m)\"\n if \"coprime k m\" for a k m :: nat\n by sorry\n\nlemma cong_mult_lcancel_nat:\n \"[k * a = k * b] (mod m) = [a = b] (mod m)\"\n if \"coprime k m\" for a k m :: nat\n by sorry\n\nlemma coprime_cong_mult_nat:\n \"[a = b] (mod m) \\ [a = b] (mod n) \\ coprime m n \\ [a = b] (mod m * n)\"\n for a b :: nat\n by sorry\n\nlemma cong_less_imp_eq_nat: \"0 \\ a \\ a < m \\ 0 \\ b \\ b < m \\ [a = b] (mod m) \\ a = b\"\n for a b :: nat\n by sorry\n\nlemma cong_less_imp_eq_int: \"0 \\ a \\ a < m \\ 0 \\ b \\ b < m \\ [a = b] (mod m) \\ a = b\"\n for a b :: int\n by sorry\n\nlemma cong_less_unique_nat: \"0 < m \\ (\\!b. 0 \\ b \\ b < m \\ [a = b] (mod m))\"\n for a m :: nat\n by sorry\n\nlemma cong_less_unique_int: \"0 < m \\ (\\!b. 0 \\ b \\ b < m \\ [a = b] (mod m))\"\n for a m :: int\n by sorry\n\nlemma cong_iff_lin_nat: \"[a = b] (mod m) \\ (\\k1 k2. b + k1 * m = a + k2 * m)\"\n for a b :: nat\n by sorry\n\nlemma cong_cong_mod_nat: \"[a = b] (mod m) \\ [a mod m = b mod m] (mod m)\"\n for a b :: nat\n by sorry\n\nlemma cong_cong_mod_int: \"[a = b] (mod m) \\ [a mod m = b mod m] (mod m)\"\n for a b :: int\n by sorry\n\nlemma cong_add_lcancel_nat: \"[a + x = a + y] (mod n) \\ [x = y] (mod n)\"\n for a x y :: nat\n by sorry\n\nlemma cong_add_rcancel_nat: \"[x + a = y + a] (mod n) \\ [x = y] (mod n)\"\n for a x y :: nat\n by sorry\n\nlemma cong_add_lcancel_0_nat: \"[a + x = a] (mod n) \\ [x = 0] (mod n)\"\n for a x :: nat\n by sorry\n\nlemma cong_add_rcancel_0_nat: \"[x + a = a] (mod n) \\ [x = 0] (mod n)\"\n for a x :: nat\n by sorry\n\nlemma cong_dvd_modulus_nat: \"[x = y] (mod m) \\ n dvd m \\ [x = y] (mod n)\"\n for x y :: nat\n by sorry\n\nlemma cong_to_1_nat:\n fixes a :: nat\n assumes \"[a = 1] (mod n)\"\n shows \"n dvd (a - 1)\"\n by sorry\n\nlemma cong_0_1_nat': \"[0 = Suc 0] (mod n) \\ n = Suc 0\"\n by sorry\n\nlemma cong_0_1_nat: \"[0 = 1] (mod n) \\ n = 1\"\n for n :: nat\n by sorry\n\nlemma cong_0_1_int: \"[0 = 1] (mod n) \\ n = 1 \\ n = - 1\"\n for n :: int\n by sorry\n\nlemma cong_to_1'_nat: \"[a = 1] (mod n) \\ a = 0 \\ n = 1 \\ (\\m. a = 1 + m * n)\"\n for a :: nat\n by sorry\n\nlemma cong_le_nat: \"y \\ x \\ [x = y] (mod n) \\ (\\q. x = q * n + y)\"\n for x y :: nat\n by sorry\n\nlemma cong_solve_nat:\n fixes a :: nat\n shows \"\\x. [a * x = gcd a n] (mod n)\"\n by sorry\n\nlemma cong_solve_int:\n fixes a :: int\n shows \"\\x. [a * x = gcd a n] (mod n)\"\n by sorry\n\nlemma cong_solve_dvd_nat:\n fixes a :: nat\n assumes \"gcd a n dvd d\"\n shows \"\\x. [a * x = d] (mod n)\"\n by sorry\n\nlemma cong_solve_dvd_int:\n fixes a::int\n assumes b: \"gcd a n dvd d\"\n shows \"\\x. [a * x = d] (mod n)\"\n by sorry\n\nlemma cong_solve_coprime_nat:\n \"\\x. [a * x = Suc 0] (mod n)\" if \"coprime a n\"\n by sorry\n\nlemma cong_solve_coprime_int:\n \"\\x. [a * x = 1] (mod n)\" if \"coprime a n\" for a n x :: int\n by sorry\n\nlemma coprime_iff_invertible_nat:\n \"coprime a m \\ (\\x. [a * x = Suc 0] (mod m))\" (is \"?P \\ ?Q\")\n by sorry\n\nlemma coprime_iff_invertible_int:\n \"coprime a m \\ (\\x. [a * x = 1] (mod m))\" (is \"?P \\ ?Q\") for m :: int\n by sorry\n\nlemma coprime_iff_invertible'_nat:\n assumes \"m > 0\"\n shows \"coprime a m \\ (\\x. 0 \\ x \\ x < m \\ [a * x = Suc 0] (mod m))\"\n by sorry\n\nlemma coprime_iff_invertible'_int:\n fixes m :: int\n assumes \"m > 0\"\n shows \"coprime a m \\ (\\x. 0 \\ x \\ x < m \\ [a * x = 1] (mod m))\"\n by sorry\n\nlemma cong_cong_lcm_nat: \"[x = y] (mod a) \\ [x = y] (mod b) \\ [x = y] (mod lcm a b)\"\n for x y :: nat\n by sorry\n\nlemma cong_cong_lcm_int: \"[x = y] (mod a) \\ [x = y] (mod b) \\ [x = y] (mod lcm a b)\"\n for x y :: int\n by sorry\n\nlemma cong_cong_prod_coprime_nat:\n \"[x = y] (mod (\\i\\A. m i))\" if\n \"(\\i\\A. [x = y] (mod m i))\"\n \"(\\i\\A. (\\j\\A. i \\ j \\ coprime (m i) (m j)))\"\n for x y :: nat\n by sorry\n\nlemma binary_chinese_remainder_nat:\n fixes m1 m2 :: nat\n assumes a: \"coprime m1 m2\"\n shows \"\\x. [x = u1] (mod m1) \\ [x = u2] (mod m2)\"\n by sorry\n\nlemma binary_chinese_remainder_int:\n fixes m1 m2 :: int\n assumes a: \"coprime m1 m2\"\n shows \"\\x. [x = u1] (mod m1) \\ [x = u2] (mod m2)\"\n by sorry\n\nlemma cong_modulus_mult_nat: \"[x = y] (mod m * n) \\ [x = y] (mod m)\"\n for x y :: nat\n by sorry\n\nlemma cong_less_modulus_unique_nat: \"[x = y] (mod m) \\ x < m \\ y < m \\ x = y\"\n for x y :: nat\n by sorry\n\nlemma binary_chinese_remainder_unique_nat:\n fixes m1 m2 :: nat\n assumes a: \"coprime m1 m2\"\n and nz: \"m1 \\ 0\" \"m2 \\ 0\"\n shows \"\\!x. x < m1 * m2 \\ [x = u1] (mod m1) \\ [x = u2] (mod m2)\"\n by sorry\n\nlemma chinese_remainder_nat:\n fixes A :: \"'a set\"\n and m :: \"'a \\ nat\"\n and u :: \"'a \\ nat\"\n assumes fin: \"finite A\"\n and cop: \"\\i \\ A. \\j \\ A. i \\ j \\ coprime (m i) (m j)\"\n shows \"\\x. \\i \\ A. [x = u i] (mod m i)\"\n by sorry\n\nlemma coprime_cong_prod_nat: \"[x = y] (mod (\\i\\A. m i))\"\n if \"\\i j. \\i \\ A; j \\ A; i \\ j\\ \\ coprime (m i) (m j)\"\n and \"\\i. i \\ A \\ [x = y] (mod m i)\" for x y :: nat\n by sorry\n\nlemma chinese_remainder_unique_nat:\n fixes A :: \"'a set\"\n and m :: \"'a \\ nat\"\n and u :: \"'a \\ nat\"\n assumes fin: \"finite A\"\n and nz: \"\\i\\A. m i \\ 0\"\n and cop: \"\\i\\A. \\j\\A. i \\ j \\ coprime (m i) (m j)\"\n shows \"\\!x. x < (\\i\\A. m i) \\ (\\i\\A. [x = u i] (mod m i))\"\n by sorry\n\nlemma (in semiring_1_cancel) of_nat_eq_iff_cong_CHAR:\n \"of_nat x = (of_nat y :: 'a) \\ [x = y] (mod CHAR('a))\"\n by sorry\n\nlemma (in ring_1) of_int_eq_iff_cong_CHAR:\n \"of_int x = (of_int y :: 'a) \\ [x = y] (mod int CHAR('a))\"\n by sorry\n\ntext \\Thanks to Manuel Eberl\\\nlemma prime_cong_4_nat_cases [consumes 1, case_names 2 cong_1 cong_3]:\n assumes \"prime (p :: nat)\"\n obtains \"p = 2\" | \"[p = 1] (mod 4)\" | \"[p = 3] (mod 4)\"\n by sorry\n\nend" }, { "theorem_id": 64, "title": "085_divisibility_by_3_rule", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Kim Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison, Shing Tak Lam, Mario Carneiro\n-/\nmodule\n\npublic import Mathlib.Data.List.Palindrome\npublic import Mathlib.Data.Nat.Digits.Lemmas\n\n/-!\n# Divisibility tests for natural numbers in terms of digits.\n\nWe prove some divisibility tests based on digits, in particular completing\nTheorem #85 from https://www.cs.ru.nl/~freek/100/.\n\n-/\n\npublic section\n\nnamespace Nat\n\nvariable {n : ℕ}\n\ntheorem modEq_three_digits_sum (n : ℕ) : n ≡ (digits 10 n).sum [MOD 3] :=\n modEq_digits_sum 3 10 (by simp) n\n\ntheorem modEq_nine_digits_sum (n : ℕ) : n ≡ (digits 10 n).sum [MOD 9] :=\n modEq_digits_sum 9 10 (by simp) n\n\ntheorem modEq_eleven_digits_sum (n : ℕ) :\n n ≡ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum [ZMOD 11] := by sorry\ntheorem dvd_iff_dvd_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) :\n b ∣ n ↔ b ∣ (digits b' n).sum := by sorry\ntheorem three_dvd_iff (n : ℕ) : 3 ∣ n ↔ 3 ∣ (digits 10 n).sum :=\n dvd_iff_dvd_digits_sum 3 10 (by simp) n\n\ntheorem nine_dvd_iff (n : ℕ) : 9 ∣ n ↔ 9 ∣ (digits 10 n).sum :=\n dvd_iff_dvd_digits_sum 9 10 (by simp) n\n\ntheorem dvd_iff_dvd_ofDigits (b b' : ℕ) (c : ℤ) (h : (b : ℤ) ∣ (b' : ℤ) - c) (n : ℕ) :\n b ∣ n ↔ (b : ℤ) ∣ ofDigits c (digits b' n) := by sorry\ntheorem eleven_dvd_iff :\n 11 ∣ n ↔ (11 : ℤ) ∣ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum := by sorry\ntheorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) :\n 11 ∣ n := by sorry\nend Nat\n" }, { "theorem_id": 64, "title": "085_divisibility_by_3_rule", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Znumtheory.\nOpen Scope Z_scope.\n\nFixpoint sumdigits n (f : nat -> Z) :=\n match n with\n | O => f O\n | S n => f (S n) + sumdigits n f\n end.\n\nFixpoint number n (f : nat -> Z) :=\n match n with\n | O => f O\n | S n => f (S n) + 10 * number n f\n end.\n\nTheorem div3 : forall n d,\n (number n d) mod 3 = (sumdigits n d) mod 3.\nProof.\nAdmitted." }, { "theorem_id": 65, "title": "088_derangements_formula", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/transc.ml\";;\nneeds \"Library/calc_real.ml\";;\nneeds \"Library/floor.ml\";;\n\nlet PAIR_BETA_THM = GEN_BETA_CONV `(\\(x,y). P x y) (a,b)`;;\n\nlet domain = new_definition\n `domain r = {x | ?y. r(x,y)}`;;\n\nlet range = new_definition\n `range r = {y | ?x. r(x,y)}`;;\n\nparse_as_infix(\"%\",(26, \"right\"));;\n\nlet compose = new_definition\n `(r % s) (x,y) <=> ?z. r(x,z) /\\ s(z,y)`;;\n\nlet id = new_definition\n `id(s) (x,y) <=> x IN s /\\ x = y`;;\n\nlet converse = new_definition\n `converse(r) (x,y) = r(y,x)`;;\n\nlet swap = new_definition\n `swap(a,b) (x,y) <=> x = a /\\ y = b \\/ x = b /\\ y = a`;;\n\nparse_as_infix(\"pairsup\",(12,\"right\"));;\n\nlet pairsup = new_definition\n `r pairsup (s,t) <=> (r % converse(r) = id(s)) /\\ (converse(r) % r = id(t))`;;\n\nparse_as_infix(\"permutes\",(12,\"right\"));;\n\nlet permutes = new_definition\n `r permutes s <=> r pairsup (s,s)`;;\n\nparse_as_infix(\"deranges\",(12,\"right\"));;\n\nlet deranges = new_definition\n `r deranges s <=> r permutes s /\\ !x. ~(r(x,x))`;;\n\nlet REL_TAC =\n POP_ASSUM_LIST(K ALL_TAC) THEN\n REWRITE_TAC[FUN_EQ_THM; FORALL_PAIR_THM; EXISTS_PAIR_THM; PAIR_BETA_THM;\n permutes; pairsup; domain; range; compose; id; converse; swap;\n deranges; IN_INSERT; IN_DELETE; NOT_IN_EMPTY; IN_ELIM_THM] THEN\n REWRITE_TAC[IN; EMPTY; INSERT; DELETE; UNION; IN_ELIM_THM; PAIR_EQ;\n id; converse; swap] THEN\n REPEAT(STRIP_TAC ORELSE EQ_TAC) THEN\n REPEAT(FIRST_X_ASSUM(SUBST_ALL_TAC o check (is_var o lhs o concl))) THEN\n REPEAT(FIRST_X_ASSUM(SUBST_ALL_TAC o SYM o check (is_var o rhs o concl))) THEN\n ASM_MESON_TAC[];;\n\nlet REL_RULE tm = prove(tm,REL_TAC);;\n\nlet CONVERSE_COMPOSE = `!r s. converse(r % s) = converse(s) % converse(r)`;;\n\nlet CONVERSE_CONVERSE = `!r. converse(converse r) = r`;;\n\nlet PAIRSUP_EXPLICIT = `!p s t.\n p pairsup (s,t) <=>\n (!x y. p(x,y) ==> x IN s /\\ y IN t) /\\\n (!x. x IN s ==> ?!y. y IN t /\\ p(x,y)) /\\\n (!y. y IN t ==> ?!x. x IN s /\\ p(x,y))`;;\n\nlet PERMUTES_EXPLICIT = `!p s. p permutes s <=>\n (!x y. p(x,y) ==> x IN s /\\ y IN s) /\\\n (!x. x IN s ==> ?!y. y IN s /\\ p(x,y)) /\\\n (!y. y IN s ==> ?!x. x IN s /\\ p(x,y))`;;\n\nlet PAIRSUP_DOMRAN = `!p s t. p pairsup (s,t) ==> domain p = s /\\ range p = t`;;\n\nlet PERMUTES_DOMRAN = `!p s. p permutes s ==> domain p = s /\\ range p = s`;;\n\nlet PAIRSUP_FUNCTIONAL = `!p s t. p pairsup (s,t) ==> !x y y'. p(x,y) /\\ p(x,y') ==> y = y'`;;\n\nlet PERMUTES_FUNCTIONAL = `!p s. p permutes s ==> !x y y'. p(x,y) /\\ p(x,y') ==> y = y'`;;\n\nlet PAIRSUP_COFUNCTIONAL = `!p s t. p pairsup (s,t) ==> !x x' y. p(x,y) /\\ p(x',y) ==> x = x'`;;\n\nlet PERMUTES_COFUNCTIONAL = `!p s. p permutes s ==> !x x' y. p(x,y) /\\ p(x',y) ==> x = x'`;;\n\nlet PAIRSUP_ID = `!s. id(s) pairsup (s,s)`;;\n\nlet PERMUTES_ID = `!s. id(s) permutes s`;;\n\nlet PAIRSUP_CONVERSE = `!p s t. p pairsup (s,t) ==> converse(p) pairsup (t,s)`;;\n\nlet PERMUTES_CONVERSE = `!p s. p permutes s ==> converse(p) permutes s`;;\n\nlet PAIRSUP_COMPOSE = `!p p' s t u. p pairsup (s,t) /\\ p' pairsup (t,u) ==> (p % p') pairsup (s,u)`;;\n\nlet PERMUTES_COMPOSE = `!p p' s. p permutes s /\\ p' permutes s ==> (p % p') permutes s`;;\n\nlet PERMUTES_SWAP = `swap(a,b) permutes {a,b}`;;\n\nlet PAIRSUP_EMPTY = `p pairsup ({},{}) <=> (p = {})`;;\n\nlet PAIRSUP_INSERT = `!x:A s t:B->bool p.\n p pairsup (x INSERT s,t) <=>\n if x IN s then p pairsup (s,t)\n else ?y q. y IN t /\\ p = (x,y) INSERT q /\\ q pairsup (s,t DELETE y)`;;\n\nlet NUMBER_OF_PAIRINGS = `!n s:A->bool t:B->bool.\n s HAS_SIZE n /\\ t HAS_SIZE n\n ==> {p | p pairsup (s,t)} HAS_SIZE (FACT n)`;;\n\nlet NUMBER_OF_PERMUTATIONS = `!s n. s HAS_SIZE n ==> {p | p permutes s} HAS_SIZE (FACT n)`;;\n\nlet derangements = define\n `(derangements 0 = 1) /\\\n (derangements 1 = 0) /\\\n (derangements(n + 2) = (n + 1) * (derangements n + derangements(n + 1)))`;;\n\nlet DERANGEMENT_INDUCT = `!P. P 0 /\\ P 1 /\\ (!n. P n /\\ P(n + 1) ==> P(n + 2)) ==> !n. P n`;;\n\nlet DERANGEMENT_ADD2 = `!p s x y.\n p deranges s /\\ ~(x IN s) /\\ ~(y IN s) /\\ ~(x = y)\n ==> ((x,y) INSERT (y,x) INSERT p) deranges (x INSERT y INSERT s)`;;\n\nlet DERANGEMENT_ADD1 = `!p s y x. p deranges s /\\ ~(y IN s) /\\ p(x,z)\n ==> ((x,y) INSERT (y,z) INSERT (p DELETE (x,z)))\n deranges (y INSERT s)`;;\n\nlet DERANGEMENT_EMPTY = `!p. p deranges {} <=> p = {}`;;\n\nlet DERANGEMENT_SING = `!x p. ~(p deranges {x})`;;\n\nlet NUMBER_OF_DERANGEMENTS = `!n s:A->bool. s HAS_SIZE n ==> {p | p deranges s} HAS_SIZE (derangements n)`;;\n\nlet SUM_1 = `sum(0..1) f = f 0 + f 1`;;\n\nlet SUM_2 = `sum(0..2) f = f 0 + f 1 + f 2`;;\n\nlet DERANGEMENTS = `!n. ~(n = 0)\n ==> &(derangements n) =\n &(FACT n) * sum(0..n) (\\k. --(&1) pow k / &(FACT k))`;;\n\nlet DERANGEMENTS_EXP = `!n. ~(n = 0)\n ==> let e = exp(&1) in\n abs(&(derangements n) - &(FACT n) / e) < &1 / &2`;;\n\nlet round = new_definition\n `round x = @n. integer(n) /\\ n - &1 / &2 <= x /\\ x < n + &1 / &2`;;\n\nlet ROUND_WORKS = `!x. integer(round x) /\\ round x - &1 / &2 <= x /\\ x < round x + &1 / &2`;;\n\nlet DERANGEMENTS_EXP = `!n. ~(n = 0)\n ==> let e = exp(&1) in &(derangements n) = round(&(FACT n) / e)`;;\n\nlet THE_DERANGEMENTS_FORMULA = `!n s. s HAS_SIZE n /\\ ~(n = 0)\n ==> FINITE {p | p deranges s} /\\\n let e = exp(&1) in\n &(CARD {p | p deranges s}) = round(&(FACT n) / e)`;;" }, { "theorem_id": 65, "title": "088_derangements_formula", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Derangements\\\n\ntheory Derangements\nimports\n Complex_Main\n \"HOL-Combinatorics.Permutations\"\nbegin\n\nsubsection \\Preliminaries\\\n\nsubsubsection \\Additions to @{theory HOL.Finite_Set} Theory\\\n\nlemma card_product_dependent:\n assumes \"finite S\" \"\\x \\ S. finite (T x)\"\n shows \"card {(x, y). x \\ S \\ y \\ T x} = (\\x \\ S. card (T x))\"\n by sorry\n\nsubsubsection \\Additions to @{theory \"HOL-Combinatorics.Permutations\"} Theory\\\n\nlemma permutes_imp_bij':\n assumes \"p permutes S\"\n shows \"bij p\"\n by sorry\n\nlemma permutesE:\n assumes \"p permutes S\"\n obtains \"bij p\" \"\\x. x \\ S \\ p x = x\"\n by sorry\n\nlemma bij_imp_permutes':\n assumes \"bij p\" \"\\x. x \\ A \\ p x = x\"\n shows \"p permutes A\"\n by sorry\n\nlemma permutes_swap:\n assumes \"p permutes S\"\n shows \"Fun.swap x y p permutes (insert x (insert y S))\"\n by sorry\n\nlemma bij_extends:\n \"bij p \\ p x = x \\ bij (p(x := y, inv p y := x))\"\n by sorry\n\nlemma permutes_add_one:\n assumes \"p permutes S\" \"x \\ S\" \"y \\ S\"\n shows \"p(x := y, inv p y := x) permutes (insert x S)\"\n by sorry\n\nlemma permutations_skip_one:\n assumes \"p permutes S\" \"x : S\"\n shows \"p(x := x, inv p x := p x) permutes (S - {x})\"\n by sorry\n\nlemma permutes_drop_cycle_size_two:\n \\p \\ Transposition.transpose x (p x) permutes (S - {x, p x})\\\n if \\p permutes S\\ \\p (p x) = x\\\n by sorry\n\nsubsection \\Fixpoint-Free Permutations\\\n\ndefinition derangements :: \"nat set \\ (nat \\ nat) set\"\nwhere\n \"derangements S = {p. p permutes S \\ (\\x \\ S. p x \\ x)}\"\n\nlemma derangementsI:\n assumes \"p permutes S\" \"\\x. x \\ S \\ p x \\ x\"\n shows \"p \\ derangements S\"\n by sorry\n\nlemma derangementsE:\n assumes \"d : derangements S\"\n obtains \"d permutes S\" \"\\x\\S. d x \\ x\"\n by sorry\n\nsubsection \\Properties of Derangements\\\n\nlemma derangements_inv:\n assumes d: \"d \\ derangements S\"\n shows \"inv d \\ derangements S\"\n by sorry\n\nlemma derangements_in_image:\n assumes \"d \\ derangements A\" \"x \\ A\"\n shows \"d x \\ A\"\n by sorry\n\nlemma derangements_in_image_strong:\n assumes \"d \\ derangements A\" \"x \\ A\"\n shows \"d x \\ A - {x}\"\n by sorry\n\nlemma derangements_inverse_in_image:\n assumes \"d \\ derangements A\" \"x \\ A\"\n shows \"inv d x \\ A\"\n by sorry\n\nlemma derangements_fixpoint:\n assumes \"d \\ derangements A\" \"x \\ A\"\n shows \"d x = x\"\n by sorry\n\nlemma derangements_no_fixpoint:\n assumes \"d \\ derangements A\" \"x \\ A\"\n shows \"d x \\ x\"\n by sorry\n\nlemma finite_derangements:\n assumes \"finite A\"\n shows \"finite (derangements A)\"\n by sorry\n\nsubsection \\Construction of Derangements\\\n\nlemma derangements_empty[simp]:\n \"derangements {} = {id}\"\n by sorry\n\nlemma derangements_singleton[simp]:\n \"derangements {x} = {}\"\n by sorry\n\nlemma derangements_swap:\n assumes \"d \\ derangements S\" \"x \\ S\" \"y \\ S\" \"x \\ y\"\n shows \"Fun.swap x y d \\ derangements (insert x (insert y S))\"\n by sorry\n\nlemma derangements_skip_one:\n assumes d: \"d \\ derangements S\" and \"x \\ S\" \"d (d x) \\ x\"\n shows \"d(x := x, inv d x := d x) \\ derangements (S - {x})\"\n by sorry\n\nlemma derangements_add_one:\n assumes \"d \\ derangements S\" \"x \\ S\" \"y \\ S\"\n shows \"d(x := y, inv d y := x) \\ derangements (insert x S)\"\n by sorry\n\nlemma derangements_drop_minimal_cycle:\n assumes \"d \\ derangements S\" \"d (d x) = x\"\n shows \"Fun.swap x (d x) d \\ derangements (S - {x, d x})\"\n by sorry\n\nsubsection \\Cardinality of Derangements\\\n\nsubsubsection \\Recursive Characterization\\\n\nfun count_derangements :: \"nat \\ nat\"\nwhere\n \"count_derangements 0 = 1\"\n| \"count_derangements (Suc 0) = 0\"\n| \"count_derangements (Suc (Suc n)) = (n + 1) * (count_derangements (Suc n) + count_derangements n)\"\n\nlemma card_derangements:\n assumes \"finite S\" \"card S = n\"\n shows \"card (derangements S) = count_derangements n\"\n by sorry\n\nsubsubsection \\Closed-Form Characterization\\\n\nlemma count_derangements:\n \"real (count_derangements n) = fact n * (\\k \\ {0..n}. (-1) ^ k / fact k)\"\n by sorry\n\nsubsubsection \\Approximation of Cardinality\\\n\nlemma two_power_fact_le_fact:\n assumes \"n \\ 1\"\n shows \"2^k * fact n \\ (fact (n + k) :: 'a :: {semiring_char_0,linordered_semidom})\"\n by sorry\n\nlemma exp1_approx:\n assumes \"n > 0\"\n shows \"exp (1::real) - (\\k {0..2 / fact n}\"\n by sorry\n\nlemma exp1_bounds: \"exp 1 \\ {8 / 3..11 / 4 :: real}\"\n by sorry\n\nlemma count_derangements_approximation:\n assumes \"n \\ 0\"\n shows \"abs(real (count_derangements n) - fact n / exp 1) < 1 / 2\"\n by sorry\n\ntheorem derangements_formula:\n assumes \"n \\ 0\" \"finite S\" \"card S = n\"\n shows \"int (card (derangements S)) = round (fact n / exp 1 :: real)\"\n by sorry\n\ntheorem derangements_formula':\n assumes \"n \\ 0\" \"finite S\" \"card S = n\"\n shows \"card (derangements S) = nat (round (fact n / exp 1 :: real))\"\n by sorry\n\nend" }, { "theorem_id": 65, "title": "088_derangements_formula", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2021 Henry Swanson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henry Swanson\n-/\nmodule\n\npublic import Mathlib.Algebra.BigOperators.Ring.Finset\npublic import Mathlib.Combinatorics.Derangements.Basic\npublic import Mathlib.Data.Fintype.BigOperators\npublic import Mathlib.Tactic.Ring\n\n/-!\n# Derangements on fintypes\n\nThis file contains lemmas that describe the cardinality of `derangements α` when `α` is a fintype.\n\n## Main definitions\n\n* `card_derangements_invariant`: A lemma stating that the number of derangements on a type `α`\n depends only on the cardinality of `α`.\n* `numDerangements n`: The number of derangements on an n-element set, defined in a computation-\n friendly way.\n* `card_derangements_eq_numDerangements`: Proof that `numDerangements` really does compute the\n number of derangements.\n* `numDerangements_sum`: A lemma giving an expression for `numDerangements n` in terms of\n factorials.\n-/\n\n@[expose] public section\n\n\nopen derangements Equiv Fintype\n\nvariable {α : Type*} [DecidableEq α] [Fintype α]\n\ninstance : DecidablePred (· ∈ derangements α) := fun _ => Fintype.decidableForallFintype\n\ninstance : Fintype (derangements α) :=\n inferInstanceAs <| Fintype { f : Perm α | ∀ x : α, f x ≠ x }\n\n\ntheorem card_derangements_invariant {α β : Type*} [Fintype α] [DecidableEq α] [Fintype β]\n [DecidableEq β] (h : card α = card β) : card (derangements α) = card (derangements β) :=\n Fintype.card_congr (Equiv.derangementsCongr <| equivOfCardEq h)\n\ntheorem card_derangements_fin_add_two (n : ℕ) :\n card (derangements (Fin (n + 2))) =\n (n + 1) * card (derangements (Fin n)) + (n + 1) * card (derangements (Fin (n + 1))) := by sorry\ndef numDerangements : ℕ → ℕ\n | 0 => 1\n | 1 => 0\n | n + 2 => (n + 1) * (numDerangements n + numDerangements (n + 1))\n\n@[simp]\ntheorem numDerangements_zero : numDerangements 0 = 1 :=\n rfl\n\n@[simp]\ntheorem numDerangements_one : numDerangements 1 = 0 :=\n rfl\n\ntheorem numDerangements_add_two (n : ℕ) :\n numDerangements (n + 2) = (n + 1) * (numDerangements n + numDerangements (n + 1)) :=\n rfl\n\ntheorem numDerangements_succ (n : ℕ) :\n (numDerangements (n + 1) : ℤ) = (n + 1) * (numDerangements n : ℤ) - (-1) ^ n := by sorry\ntheorem card_derangements_fin_eq_numDerangements {n : ℕ} :\n card (derangements (Fin n)) = numDerangements n := by sorry\ntheorem card_derangements_eq_numDerangements (α : Type*) [Fintype α] [DecidableEq α] :\n card (derangements α) = numDerangements (card α) := by sorry\ntheorem numDerangements_sum (n : ℕ) :\n (numDerangements n : ℤ) =\n ∑ k ∈ Finset.range (n + 1), (-1 : ℤ) ^ k * Nat.ascFactorial (k + 1) (n - k) := by sorry\n" }, { "theorem_id": 65, "title": "088_derangements_formula", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Exp_prop Rbase Rdefinitions Rfunctions Reals Lia.\n\nLemma lt_onehalf_if: forall a b: R,\n (0 < a)%R -> (0 < b)%R ->\n (b > 2 * a)%R -> ((a / b) < / 2)%R.\nProof.\nAdmitted.\n\nLemma INR_lt_onehalf_if: forall a b,\n (b > 2 * a) -> (((INR a) / (INR b)) < / 2)%R.\nProof.\nAdmitted.\n\nDefinition drm_count_as_sum (n: nat) := ((INR (fact n)) * (E1 (-1) n))%R.\n\nFixpoint fact_n_k (n k: nat): nat :=\n match k with\n | 0 => 1\n | S k' => ((Nat.max 1 n) + k - 1) * (fact_n_k n k')\n end.\n\nLemma fact_1_k: forall k, (fact_n_k 1 k) = (fact k).\nProof.\nAdmitted.\n\nLemma INR_S_neq_0: forall n, ((INR (S n)) <> 0)%R.\nProof.\nAdmitted.\n\nLemma INR_fact_n_k_gt_0: forall n k, ((INR (fact_n_k n k)) > 0)%R.\nProof.\nAdmitted.\n\nCorollary INR_fact_n_k_neq_0: forall n k, ((INR (fact_n_k n k)) <> 0)%R.\nProof.\nAdmitted.\n\nLemma Rinv_eq_compat: forall r1 r2: R, r1 <> 0%R -> r2 <> 0%R -> (r1 = r2 <-> / r1 = / r2)%R.\nProof.\nAdmitted.\n\nLemma eq_INR: forall n m, n = m -> INR n = INR m.\nProof.\nAdmitted.\n\nLemma neg_1_mult_neg_1: ((-1) * (-1) = 1)%R.\nProof.\nAdmitted.\n\nLemma neg_1_mult: forall a, (((-1) * a) = - a)%R.\nProof.\nAdmitted.\n\nDefinition inv_fact_n_k (n k: nat): R := (/ (INR (fact_n_k n k)))%R.\n\nLemma fact_fact_n_k: forall n k: nat, (((INR (fact n)) / (INR (fact (n + k)))) = (inv_fact_n_k (n + 1) k))%R.\nProof.\nAdmitted.\n\nLemma fact_n_k_gt_0: forall n k, (fact_n_k n k) > 0.\nProof.\nAdmitted.\n\nLemma fact_n_k_lt: forall n k k', k > k' -> n > 1 -> ((fact_n_k n k) > (fact_n_k n k')).\nProof.\nAdmitted.\n\nCorollary INR_fact_n_k_lt: forall n k k', k > k' -> n > 1 -> (INR (fact_n_k n k) > INR (fact_n_k n k'))%R.\nProof.\nAdmitted.\n\nLemma even_exists: forall n: nat, (Nat.\nProof.\nAdmitted.\n\nLemma not_even_S_n: forall n: nat, (Nat.\nProof.\nAdmitted.\n\nDefinition rest_sum (n N: nat) :=\n sum_f_R0 (fun k => (inv_fact_n_k (n + 1) (k + 1)) * ((-1) ^ k))%R (N - n - 1).\n\nLemma drm_count_rest_sum: forall N n, N > n ->\n ( (((INR (fact n)) * (E1 (-1) N)) - (drm_count_as_sum n)))%R =\n ( (rest_sum n N) * (if Nat.\nProof.\nAdmitted.\n\nFact Rplus_mult_neg_1_r_gt_0: forall a b, (a + b * (-1) > 0)%R <-> (a > b)%R.\nProof.\nAdmitted.\n\nFact Rplus_mult_neg_1_r_lt_0: forall a b, (a * (-1) + b < 0)%R <-> (a > b)%R.\nProof.\nAdmitted.\n\nFact Rplus_neg_gt_0: forall a b, (a + - b > 0)%R <-> (a > b)%R.\nProof.\nAdmitted.\n\nLemma inv_fact_n_k_gt: forall n k k', k < k' -> n > 1 -> (inv_fact_n_k n k > inv_fact_n_k n k')%R.\nProof.\nAdmitted.\n\nLemma inv_fact_n_k_gt_0: forall n k, (inv_fact_n_k n k > 0)%R.\nProof.\nAdmitted.\n\nLemma rest_sum_gt_0_odd: forall n N,\n n > 0 -> N > n + 2 -> (Nat.\nProof.\nAdmitted.\n\nLemma rest_sum_gt_0_even: forall n N,\n n > 0 -> N > n + 3 -> (Nat.\nProof.\nAdmitted.\n\nLemma rest_sum_gt_0: forall n N,\n n > 0 -> N > n + 3 -> ((rest_sum n N) > 0)%R.\nProof.\nAdmitted.\n\nLemma rest_sum_even: forall n N,\n n > 0 -> N > n + 3 -> (Nat.\nProof.\nAdmitted.\n\nLemma rest_sum_odd: forall n N,\n n > 0 -> N > n + 4 -> (Nat.\nProof.\nAdmitted.\n\nLemma rest_sum_lt: forall n N,\n n > 0 -> N > n + 4 -> ((rest_sum n N) < (rest_sum n (n + 1)))%R.\nProof.\nAdmitted.\n\nLemma R_dist_lt_swap: forall a b c eps, (R_dist a b < eps)%R -> ((Rabs (a + c)) < (Rabs (b + c)) + eps)%R.\nProof.\nAdmitted.\n\nLemma inv_fact_n_k_le: forall n n' k, n >= n' -> n' > 0 -> (inv_fact_n_k n k <= inv_fact_n_k n' k)%R.\nProof.\nAdmitted.\n\nLemma Rinv_1_l: forall r, r <> 0%R -> (/ r * r = 1)%R.\nProof.\nAdmitted.\n\nCorollary Rinv_1_r: forall r, r <> 0%R -> (r * / r = 1)%R.\nProof.\nAdmitted.\n\nLemma drm_count_as_sum_e_diff_N: forall n: nat,\n n > 0 -> exists eps: R,\n (eps > 0)%R /\\ exists N0: nat, forall N: nat,\n N > N0 ->\n ((Rabs (((INR (fact n)) * (E1 (-1) N)) - (drm_count_as_sum n))) + eps < (/ INR 2))%R.\nProof.\nAdmitted.\n\nLemma drm_count_as_sum_e_diff: forall n: nat, n > 0 ->\n ((Rabs (((INR (fact n)) * (exp (-1))) - (drm_count_as_sum n))) < (/ INR 2))%R.\nProof.\nAdmitted.\n\n\nRequire Import drmcorrect drmnodup List SetoidList SetoidPermutation FMapWeakList OrderedTypeEx Compare_dec.\nImport ListNotations.\n\nFixpoint drm_count (n: nat) :=\n match n with\n | 0 => 1\n | 1 => 0\n | S k => (n - 1) * ((drm_count k) + (drm_count (Nat.pred k)))\n end.\n\n\nLemma drm_construct_1_count: forall n m, length (drm_construct_1 n m) = (card m).\nProof.\nAdmitted.\n\nLemma concat_map_length: forall {A B: Type} (l: list A) (f: A -> list B) c,\n (forall x, In x l -> (length (f x) = c)) ->\n (length (concat (List.\nProof.\nAdmitted.\n\nLemma drm_construct_2_count: forall n m,\n drm m (Nat.\nProof.\nAdmitted.\n\nLemma drm_count_correct: forall n, (drm_count n) = length (drm_construct n).\nProof.\nAdmitted.\n\nLemma drm_count_closed_form: forall n,\n INR (drm_count n) = drm_count_as_sum n.\nProof.\nAdmitted.\n\n\nDefinition round (r: R) :=\n if (Rlt_dec (R_dist r (IZR (Int_part r))) (/ INR 2)) then\n Some (Int_part r)\n else if (Rlt_dec (R_dist (IZR (up r)) r) (/ INR 2)) then\n Some (up r)\n else\n None.\n\nLemma round_dist: forall r n,\n (Rabs (r - INR n) < / INR 2)%R -> (round r) = Some (Z.\nProof.\nAdmitted.\n\nTheorem drm_formula: forall n,\n n > 0 ->\n round ((INR (fact n)) * (exp (-1))) = Some (Z.\nProof.\nAdmitted.\n" }, { "theorem_id": 66, "title": "089_the_factor_and_remainder_theorems", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/analysis.ml\";;\n\nprioritize_real();;\n\nparse_as_infix(\"++\",(16,\"right\"));;\nparse_as_infix(\"**\",(20,\"right\"));;\nparse_as_infix(\"##\",(20,\"right\"));;\nparse_as_infix(\"divides\",(14,\"right\"));;\nparse_as_infix(\"exp\",(22,\"right\"));;\n\ndo_list override_interface\n [\"++\",`poly_add:real list->real list->real list`;\n \"**\",`poly_mul:real list->real list->real list`;\n \"##\",`poly_cmul:real->real list->real list`;\n \"neg\",`poly_neg:real list->real list`;\n \"exp\",`poly_exp:real list -> num -> real list`;\n \"diff\",`poly_diff:real list->real list`];;\n\noverload_interface (\"divides\",`poly_divides:real list->real list->bool`);;\n\nlet poly = new_recursive_definition list_RECURSION\n `(poly [] x = &0) /\\\n (poly (CONS h t) x = h + x * poly t x)`;;\n\nlet POLY_CONST = `!c x. poly [c] x = c`;;\n\nlet POLY_X = `!c x. poly [&0; &1] x = x`;;\n\nlet poly_add = new_recursive_definition list_RECURSION\n `([] ++ l2 = l2) /\\\n ((CONS h t) ++ l2 =\n (if l2 = [] then CONS h t\n else CONS (h + HD l2) (t ++ TL l2)))`;;\n\nlet poly_cmul = new_recursive_definition list_RECURSION\n `(c ## [] = []) /\\\n (c ## (CONS h t) = CONS (c * h) (c ## t))`;;\n\nlet poly_neg = new_definition\n `neg = (##) (--(&1))`;;\n\nlet poly_mul = new_recursive_definition list_RECURSION\n `([] ** l2 = []) /\\\n ((CONS h t) ** l2 =\n (if t = [] then h ## l2\n else (h ## l2) ++ CONS (&0) (t ** l2)))`;;\n\nlet poly_exp = new_recursive_definition num_RECURSION\n `(p exp 0 = [&1]) /\\\n (p exp (SUC n) = p ** p exp n)`;;\n\nlet poly_diff_aux = new_recursive_definition list_RECURSION\n `(poly_diff_aux n [] = []) /\\\n (poly_diff_aux n (CONS h t) = CONS (&n * h) (poly_diff_aux (SUC n) t))`;;\n\nlet poly_diff = new_definition\n `diff l = (if l = [] then [] else (poly_diff_aux 1 (TL l)))`;;\n\nlet LENGTH_POLY_DIFF_AUX = `!l n. LENGTH(poly_diff_aux n l) = LENGTH l`;;\n\nlet LENGTH_POLY_DIFF = `!l. LENGTH(poly_diff l) = PRE(LENGTH l)`;;\n\nlet POLY_ADD_CLAUSES = `([] ++ p2 = p2) /\\\n (p1 ++ [] = p1) /\\\n ((CONS h1 t1) ++ (CONS h2 t2) = CONS (h1 + h2) (t1 ++ t2))`;;\n\nlet POLY_CMUL_CLAUSES = `(c ## [] = []) /\\\n (c ## (CONS h t) = CONS (c * h) (c ## t))`;;\n\nlet POLY_NEG_CLAUSES = `(neg [] = []) /\\\n (neg (CONS h t) = CONS (--h) (neg t))`;;\n\nlet POLY_MUL_CLAUSES = `([] ** p2 = []) /\\\n ([h1] ** p2 = h1 ## p2) /\\\n ((CONS h1 (CONS k1 t1)) ** p2 = h1 ## p2 ++ CONS (&0) (CONS k1 t1 ** p2))`;;\n\nlet POLY_DIFF_CLAUSES = `(diff [] = []) /\\\n (diff [c] = []) /\\\n (diff (CONS h t) = poly_diff_aux 1 t)`;;\n\nlet POLY_ADD = `!p1 p2 x. poly (p1 ++ p2) x = poly p1 x + poly p2 x`;;\n\nlet POLY_CMUL = `!p c x. poly (c ## p) x = c * poly p x`;;\n\nlet POLY_NEG = `!p x. poly (neg p) x = --(poly p x)`;;\n\nlet POLY_MUL = `!x p1 p2. poly (p1 ** p2) x = poly p1 x * poly p2 x`;;\n\nlet POLY_EXP = `!p n x. poly (p exp n) x = (poly p x) pow n`;;\n\nlet POLY_DIFF_LEMMA = `!l n x. ((\\x. (x pow (SUC n)) * poly l x) diffl\n ((x pow n) * poly (poly_diff_aux (SUC n) l) x))(x)`;;\n\nlet POLY_DIFF = `!l x. ((\\x. poly l x) diffl (poly (diff l) x))(x)`;;\n\nlet POLY_DIFFERENTIABLE = `!l x. (\\x. poly l x) differentiable x`;;\n\nlet POLY_CONT = `!l x. (\\x. poly l x) contl x`;;\n\nlet POLY_IVT_POS = `!p a b. a < b /\\ poly p a < &0 /\\ poly p b > &0\n ==> ?x. a < x /\\ x < b /\\ (poly p x = &0)`;;\n\nlet POLY_IVT_NEG = `!p a b. a < b /\\ poly p a > &0 /\\ poly p b < &0\n ==> ?x. a < x /\\ x < b /\\ (poly p x = &0)`;;\n\nlet POLY_MVT = `!p a b. a < b ==>\n ?x. a < x /\\ x < b /\\\n (poly p b - poly p a = (b - a) * poly (diff p) x)`;;\n\nlet POLY_MVT_ADD = `!p a x. ?y. abs(y) <= abs(x) /\\\n (poly p (a + x) = poly p a + x * poly (diff p) (a + y))`;;\n\nlet POLY_ADD_RZERO = `!p. poly (p ++ []) = poly p`;;\n\nlet POLY_MUL_ASSOC = `!p q r. poly (p ** (q ** r)) = poly ((p ** q) ** r)`;;\n\nlet POLY_EXP_ADD = `!d n p. poly(p exp (n + d)) = poly(p exp n ** p exp d)`;;\n\nlet POLY_DIFF_AUX_ADD = `!p1 p2 n. poly (poly_diff_aux n (p1 ++ p2)) =\n poly (poly_diff_aux n p1 ++ poly_diff_aux n p2)`;;\n\nlet POLY_DIFF_AUX_CMUL = `!p c n. poly (poly_diff_aux n (c ## p)) =\n poly (c ## poly_diff_aux n p)`;;\n\nlet POLY_DIFF_AUX_NEG = `!p n. poly (poly_diff_aux n (neg p)) =\n poly (neg (poly_diff_aux n p))`;;\n\nlet POLY_DIFF_AUX_MUL_LEMMA = `!p n. poly (poly_diff_aux (SUC n) p) = poly (poly_diff_aux n p ++ p)`;;\n\nlet POLY_DIFF_ADD = `!p1 p2. poly (diff (p1 ++ p2)) =\n poly (diff p1 ++ diff p2)`;;\n\nlet POLY_DIFF_CMUL = `!p c. poly (diff (c ## p)) = poly (c ## diff p)`;;\n\nlet POLY_DIFF_NEG = `!p. poly (diff (neg p)) = poly (neg (diff p))`;;\n\nlet POLY_DIFF_MUL_LEMMA = `!t h. poly (diff (CONS h t)) =\n poly (CONS (&0) (diff t) ++ t)`;;\n\nlet POLY_DIFF_MUL = `!p1 p2. poly (diff (p1 ** p2)) =\n poly (p1 ** diff p2 ++ diff p1 ** p2)`;;\n\nlet POLY_DIFF_EXP = `!p n. poly (diff (p exp (SUC n))) =\n poly ((&(SUC n) ## (p exp n)) ** diff p)`;;\n\nlet POLY_DIFF_EXP_PRIME = `!n a. poly (diff ([--a; &1] exp (SUC n))) =\n poly (&(SUC n) ## ([--a; &1] exp n))`;;\n\nlet POLY_LINEAR_REM = `!t h. ?q r. CONS h t = [r] ++ [--a; &1] ** q`;;\n\nlet POLY_LINEAR_DIVIDES = `!a p. (poly p a = &0) <=> (p = []) \\/ ?q. p = [--a; &1] ** q`;;\n\nlet POLY_LENGTH_MUL = `!q. LENGTH([--a; &1] ** q) = SUC(LENGTH q)`;;\n\nlet POLY_ROOTS_INDEX_LEMMA = `!n. !p. ~(poly p = poly []) /\\ (LENGTH p = n)\n ==> ?i. !x. (poly p (x) = &0) ==> ?m. m <= n /\\ (x = i m)`;;\n\nlet POLY_ROOTS_INDEX_LENGTH = `!p. ~(poly p = poly [])\n ==> ?i. !x. (poly p(x) = &0) ==> ?n. n <= LENGTH p /\\ (x = i n)`;;\n\nlet POLY_ROOTS_FINITE_LEMMA = `!p. ~(poly p = poly [])\n ==> ?N i. !x. (poly p(x) = &0) ==> ?n:num. n < N /\\ (x = i n)`;;\n\nlet FINITE_LEMMA = `!i N P. (!x. P x ==> ?n:num. n < N /\\ (x = i n))\n ==> ?a. !x. P x ==> x < a`;;\n\nlet POLY_ROOTS_FINITE = `!p. ~(poly p = poly []) <=>\n ?N i. !x. (poly p(x) = &0) ==> ?n:num. n < N /\\ (x = i n)`;;\n\nlet POLY_ENTIRE_LEMMA = `!p q. ~(poly p = poly []) /\\ ~(poly q = poly [])\n ==> ~(poly (p ** q) = poly [])`;;\n\nlet POLY_ENTIRE = `!p q. (poly (p ** q) = poly []) <=>\n (poly p = poly []) \\/ (poly q = poly [])`;;\n\nlet POLY_MUL_LCANCEL = `!p q r. (poly (p ** q) = poly (p ** r)) <=>\n (poly p = poly []) \\/ (poly q = poly r)`;;\n\nlet POLY_EXP_EQ_0 = `!p n. (poly (p exp n) = poly []) <=> (poly p = poly []) /\\ ~(n = 0)`;;\n\nlet POLY_PRIME_EQ_0 = `!a. ~(poly [a ; &1] = poly [])`;;\n\nlet POLY_EXP_PRIME_EQ_0 = `!a n. ~(poly ([a ; &1] exp n) = poly [])`;;\n\nlet POLY_ZERO_LEMMA = `!h t. (poly (CONS h t) = poly []) ==> (h = &0) /\\ (poly t = poly [])`;;\n\nlet POLY_ZERO = `!p. (poly p = poly []) <=> ALL (\\c. c = &0) p`;;\n\nlet POLY_DIFF_AUX_ISZERO = `!p n. ALL (\\c. c = &0) (poly_diff_aux (SUC n) p) <=>\n ALL (\\c. c = &0) p`;;\n\nlet POLY_DIFF_ISZERO = `!p. (poly (diff p) = poly []) ==> ?h. poly p = poly [h]`;;\n\nlet POLY_DIFF_ZERO = `!p. (poly p = poly []) ==> (poly (diff p) = poly [])`;;\n\nlet POLY_DIFF_WELLDEF = `!p q. (poly p = poly q) ==> (poly (diff p) = poly (diff q))`;;\n\nlet divides = new_definition\n `p1 divides p2 <=> ?q. poly p2 = poly (p1 ** q)`;;\n\nlet POLY_PRIMES = `!a p q. [a; &1] divides (p ** q) <=>\n [a; &1] divides p \\/ [a; &1] divides q`;;\n\nlet POLY_DIVIDES_REFL = `!p. p divides p`;;\n\nlet POLY_DIVIDES_TRANS = `!p q r. p divides q /\\ q divides r ==> p divides r`;;\n\nlet POLY_DIVIDES_EXP = `!p m n. m <= n ==> (p exp m) divides (p exp n)`;;\n\nlet POLY_EXP_DIVIDES = `!p q m n. (p exp n) divides q /\\ m <= n ==> (p exp m) divides q`;;\n\nlet POLY_DIVIDES_ADD = `!p q r. p divides q /\\ p divides r ==> p divides (q ++ r)`;;\n\nlet POLY_DIVIDES_SUB = `!p q r. p divides q /\\ p divides (q ++ r) ==> p divides r`;;\n\nlet POLY_DIVIDES_SUB2 = `!p q r. p divides r /\\ p divides (q ++ r) ==> p divides q`;;\n\nlet POLY_DIVIDES_ZERO = `!p q. (poly p = poly []) ==> q divides p`;;\n\nlet POLY_ORDER_EXISTS = `!a d. !p. (LENGTH p = d) /\\ ~(poly p = poly [])\n ==> ?n. ([--a; &1] exp n) divides p /\\\n ~(([--a; &1] exp (SUC n)) divides p)`;;\n\nlet POLY_ORDER = `!p a. ~(poly p = poly [])\n ==> ?!n. ([--a; &1] exp n) divides p /\\\n ~(([--a; &1] exp (SUC n)) divides p)`;;\n\nlet order = new_definition\n `order a p = @n. ([--a; &1] exp n) divides p /\\\n ~(([--a; &1] exp (SUC n)) divides p)`;;\n\nlet ORDER = `!p a n. ([--a; &1] exp n) divides p /\\\n ~(([--a; &1] exp (SUC n)) divides p) <=>\n (n = order a p) /\\\n ~(poly p = poly [])`;;\n\nlet ORDER_THM = `!p a. ~(poly p = poly [])\n ==> ([--a; &1] exp (order a p)) divides p /\\\n ~(([--a; &1] exp (SUC(order a p))) divides p)`;;\n\nlet ORDER_UNIQUE = `!p a n. ~(poly p = poly []) /\\\n ([--a; &1] exp n) divides p /\\\n ~(([--a; &1] exp (SUC n)) divides p)\n ==> (n = order a p)`;;\n\nlet ORDER_POLY = `!p q a. (poly p = poly q) ==> (order a p = order a q)`;;\n\nlet ORDER_ROOT = `!p a. (poly p a = &0) <=> (poly p = poly []) \\/ ~(order a p = 0)`;;\n\nlet ORDER_DIVIDES = `!p a n. ([--a; &1] exp n) divides p <=>\n (poly p = poly []) \\/ n <= order a p`;;\n\nlet ORDER_DECOMP = `!p a. ~(poly p = poly [])\n ==> ?q. (poly p = poly (([--a; &1] exp (order a p)) ** q)) /\\\n ~([--a; &1] divides q)`;;\n\nlet ORDER_MUL = `!a p q. ~(poly (p ** q) = poly []) ==>\n (order a (p ** q) = order a p + order a q)`;;\n\nlet ORDER_DIFF = `!p a. ~(poly (diff p) = poly []) /\\\n ~(order a p = 0)\n ==> (order a p = SUC (order a (diff p)))`;;\n\nlet POLY_SQUAREFREE_DECOMP_ORDER = `!p q d e r s.\n ~(poly (diff p) = poly []) /\\\n (poly p = poly (q ** d)) /\\\n (poly (diff p) = poly (e ** d)) /\\\n (poly d = poly (r ** p ++ s ** diff p))\n ==> !a. order a q = (if order a p = 0 then 0 else 1)`;;\n\nlet rsquarefree = new_definition\n `rsquarefree p <=> ~(poly p = poly []) /\\\n !a. (order a p = 0) \\/ (order a p = 1)`;;\n\nlet RSQUAREFREE_ROOTS = `!p. rsquarefree p <=> !a. ~((poly p a = &0) /\\ (poly (diff p) a = &0))`;;\n\nlet RSQUAREFREE_DECOMP = `!p a. rsquarefree p /\\ (poly p a = &0)\n ==> ?q. (poly p = poly ([--a; &1] ** q)) /\\\n ~(poly q a = &0)`;;\n\nlet POLY_SQUAREFREE_DECOMP = `!p q d e r s.\n ~(poly (diff p) = poly []) /\\\n (poly p = poly (q ** d)) /\\\n (poly (diff p) = poly (e ** d)) /\\\n (poly d = poly (r ** p ++ s ** diff p))\n ==> rsquarefree q /\\ (!a. (poly q a = &0) <=> (poly p a = &0))`;;\n\nlet normalize = new_recursive_definition list_RECURSION\n `(normalize [] = []) /\\\n (normalize (CONS h t) =\n if normalize t = [] then if h = &0 then [] else [h]\n else CONS h (normalize t))`;;\n\nlet POLY_NORMALIZE = `!p. poly (normalize p) = poly p`;;\n\nlet degree = new_definition\n `degree p = PRE(LENGTH(normalize p))`;;\n\nlet DEGREE_ZERO = `!p. (poly p = poly []) ==> (degree p = 0)`;;\n\nlet POLY_ROOTS_FINITE_SET = `!p. ~(poly p = poly []) ==> FINITE { x | poly p x = &0}`;;\n\nlet POLY_MONO = `!x k p. abs(x) <= k ==> abs(poly p x) <= poly (MAP abs p) k`;;\n\nlet POLY_DIFF_CONV =\n let aux_conv0 = GEN_REWRITE_CONV I [CONJUNCT1 poly_diff_aux]\n and aux_conv1 = GEN_REWRITE_CONV I [CONJUNCT2 poly_diff_aux]\n and diff_conv0 = GEN_REWRITE_CONV I (butlast (CONJUNCTS POLY_DIFF_CLAUSES))\n and diff_conv1 = GEN_REWRITE_CONV I [last (CONJUNCTS POLY_DIFF_CLAUSES)] in\n let rec POLY_DIFF_AUX_CONV tm =\n (aux_conv0 ORELSEC\n (aux_conv1 THENC\n LAND_CONV REAL_RAT_MUL_CONV THENC\n RAND_CONV (LAND_CONV NUM_SUC_CONV THENC POLY_DIFF_AUX_CONV))) tm in\n diff_conv0 ORELSEC\n (diff_conv1 THENC POLY_DIFF_AUX_CONV);;\n\nlet POLY_CMUL_CONV =\n let cmul_conv0 = GEN_REWRITE_CONV I [CONJUNCT1 poly_cmul]\n and cmul_conv1 = GEN_REWRITE_CONV I [CONJUNCT2 poly_cmul] in\n let rec POLY_CMUL_CONV tm =\n (cmul_conv0 ORELSEC\n (cmul_conv1 THENC\n LAND_CONV REAL_RAT_MUL_CONV THENC\n RAND_CONV POLY_CMUL_CONV)) tm in\n POLY_CMUL_CONV;;\n\nlet POLY_ADD_CONV =\n let add_conv0 = GEN_REWRITE_CONV I (butlast (CONJUNCTS POLY_ADD_CLAUSES))\n and add_conv1 = GEN_REWRITE_CONV I [last (CONJUNCTS POLY_ADD_CLAUSES)] in\n let rec POLY_ADD_CONV tm =\n (add_conv0 ORELSEC\n (add_conv1 THENC\n LAND_CONV REAL_RAT_ADD_CONV THENC\n RAND_CONV POLY_ADD_CONV)) tm in\n POLY_ADD_CONV;;\n\nlet POLY_MUL_CONV =\n let mul_conv0 = GEN_REWRITE_CONV I [CONJUNCT1 POLY_MUL_CLAUSES]\n and mul_conv1 = GEN_REWRITE_CONV I [CONJUNCT1(CONJUNCT2 POLY_MUL_CLAUSES)]\n and mul_conv2 = GEN_REWRITE_CONV I [CONJUNCT2(CONJUNCT2 POLY_MUL_CLAUSES)] in\n let rec POLY_MUL_CONV tm =\n (mul_conv0 ORELSEC\n (mul_conv1 THENC POLY_CMUL_CONV) ORELSEC\n (mul_conv2 THENC\n LAND_CONV POLY_CMUL_CONV THENC\n RAND_CONV(RAND_CONV POLY_MUL_CONV) THENC\n POLY_ADD_CONV)) tm in\n POLY_MUL_CONV;;\n\nlet POLY_NORMALIZE_CONV =\n let pth = `normalize (CONS h t) =\n (\\n. if n = [] then if h = &0 then [] else [h] else CONS h n)\n (normalize t)`;;\n\nlet NOT_POLY_MUL_NIL = `!p1 p2. ~(p1 = []) /\\ ~(p2 = []) ==> ~((p1 ** p2) = [])`;;\n\nlet NOT_POLY_EXP_NIL = `!n p . ~(p = []) ==> ~((poly_exp p n) = [])`;;\n\nlet NOT_POLY_EXP_X_NIL = `!n. ~((poly_exp [&0;&1] n) = [])`;;\n\nlet POLY_CMUL_LID = `!p. &1 ## p = p`;;\n\nlet POLY_MUL_LID = `!p. [&1] ** p = p`;;\n\nlet POLY_MUL_RID = `!p. p ** [&1] = p`;;\n\nlet POLY_ADD_SYM = `!x y . x ++ y = y ++ x`;;\n\nlet POLY_ADD_ASSOC = `!x y z . x ++ (y ++ z) = (x ++ y) ++ z`;;\n\nlet TL_POLY_MUL_X = `!p. TL ([&0;&1] ** p) = p`;;\n\nlet HD_POLY_MUL_X = `!p. HD ([&0;&1] ** p) = &0`;;\n\nlet TL_POLY_EXP_X_SUC = `!n . TL (poly_exp [&0;&1] (SUC n)) = poly_exp [&0;&1] n`;;\n\nlet HD_POLY_EXP_X_SUC = `!n . HD (poly_exp [&0;&1] (SUC n)) = &0`;;\n\nlet HD_POLY_ADD = `!p1 p2. ~(p1 = []) /\\ ~(p2 = []) ==> HD (p1 ++ p2) = (HD p1) + (HD p2)`;;\n\nlet HD_POLY_CMUL = `!x p . ~(p = []) ==> HD (x ## p) = x * (HD p)`;;\n\nlet TL_POLY_CMUL = `!x p . ~(p = []) ==> TL (x ## p) = x ## (TL p)`;;\n\nlet HD_POLY_MUL = `!p1 p2 . ~(p1 = []) /\\ ~(p2 = []) ==> HD (p1 ** p2) = (HD p1) * (HD p2)`;;\n\nlet HD_POLY_EXP = `!n p . ~(p = []) ==> HD (poly_exp p n) = (HD p) pow n`;;\n\nlet POLY_ADD_IDENT = `neutral (++) = []`;;\n\nlet POLY_ADD_NEUTRAL = `!x. neutral (++) ++ x = x`;;\n\nlet MONOIDAL_POLY_ADD = `monoidal poly_add`;;\n\nlet POLY_DIFF_AUX_ADD_LEMMA = `!t1 t2 n. poly_diff_aux n (t1 ++ t2) =\n (poly_diff_aux n t1) ++ (poly_diff_aux n t2)`;;\n\nlet POLYDIFF_ADD = `!p1 p2. (poly_diff (p1 ++ p2)) = (poly_diff p1 ++ poly_diff p2)`;;\n\nlet POLY_DIFF_AUX_POLY_CMUL = `!p c n. poly_diff_aux n (c ## p) = c ## (poly_diff_aux n p)`;;\n\nlet POLY_CMUL_POLY_DIFF = `!p c. poly_diff (c ## p) = c ## (poly_diff p)`;;\n\nlet POLY_CMUL_LENGTH = `!c p. LENGTH (c ## p) = LENGTH p`;;\n\nlet POLY_ADD_LENGTH = `!p q. LENGTH (p ++ q) = MAX (LENGTH p) (LENGTH q)`;;\n\nlet POLY_MUL_LENGTH = `!p h t. LENGTH (p ** (CONS h t)) >= LENGTH p`;;\n\nlet POLY_EXP_X_REC = `!n. poly_exp [&0;&1] (SUC n) = CONS (&0) (poly_exp [&0;&1] n)`;;\n\nlet POLY_MUL_LENGTH2 = `!q p. ~(q = []) ==> LENGTH (p ** q) >= LENGTH p`;;\n\nlet POLY_EXP_X_LENGTH = `!n. LENGTH (poly_exp [&0;&1] n) = SUC n`;;\n\nlet POLY_SUM_EQUIV = `!p x.\n ~(p = []) ==>\n poly p x = sum (0..(PRE (LENGTH p))) (\\i. (EL i p)*(x pow i))`;;\n\nlet ITERATE_RADD_POLYADD = `!n x f. iterate (+) (0..n) (\\i.poly (f i) x) =\n poly (iterate (++) (0..n) f) x`;;\n\ndo_list reduce_interface\n [\"divides\",`poly_divides:real list->real list->bool`;\n \"exp\",`poly_exp:real list -> num -> real list`;\n \"diff\",`poly_diff:real list->real list`];;\n\nunparse_as_infix \"exp\";;" }, { "theorem_id": 66, "title": "089_the_factor_and_remainder_theorems", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Polynomials as type over a ring structure\\\n\ntheory Polynomial\nimports\n Complex_Main\n \"HOL-Library.More_List\"\n \"HOL-Library.Infinite_Set\"\n Primes\nbegin\n\ncontext semidom_modulo\nbegin\n\nlemma not_dvd_imp_mod_neq_0:\n \\a mod b \\ 0\\ if \\\\ b dvd a\\\n by sorry\n\nend\n\nsubsection \\Auxiliary: operations for lists (later) representing coefficients\\\n\ndefinition cCons :: \"'a::zero \\ 'a list \\ 'a list\" (infixr \\##\\ 65)\n where \"x ## xs = (if xs = [] \\ x = 0 then [] else x # xs)\"\n\nlemma cCons_0_Nil_eq [simp]: \"0 ## [] = []\"\n by sorry\n\nlemma cCons_Cons_eq [simp]: \"x ## y # ys = x # y # ys\"\n by sorry\n\nlemma cCons_append_Cons_eq [simp]: \"x ## xs @ y # ys = x # xs @ y # ys\"\n by sorry\n\nlemma cCons_not_0_eq [simp]: \"x \\ 0 \\ x ## xs = x # xs\"\n by sorry\n\nlemma strip_while_not_0_Cons_eq [simp]:\n \"strip_while (\\x. x = 0) (x # xs) = x ## strip_while (\\x. x = 0) xs\"\n by sorry\n\nlemma tl_cCons [simp]: \"tl (x ## xs) = xs\"\n by sorry\n\nsubsection \\Definition of type \\poly\\\\\n\ntypedef (overloaded) 'a poly = \"{f :: nat \\ 'a::zero. \\\\<^sub>\\ n. f n = 0}\"\n morphisms coeff Abs_poly\n by (auto intro!: ALL_MOST)\n\nsetup_lifting type_definition_poly\n\nlemma poly_eq_iff: \"p = q \\ (\\n. coeff p n = coeff q n)\"\n by sorry\n\nlemma poly_eqI: \"(\\n. coeff p n = coeff q n) \\ p = q\"\n by sorry\n\nlemma MOST_coeff_eq_0: \"\\\\<^sub>\\ n. coeff p n = 0\"\n by sorry\n\nlemma coeff_Abs_poly:\n assumes \"\\i. i > n \\ f i = 0\"\n shows \"coeff (Abs_poly f) = f\"\n by sorry\n\nsubsection \\Degree of a polynomial\\\n\ndefinition degree :: \"'a::zero poly \\ nat\"\n where \"degree p = (LEAST n. \\i>n. coeff p i = 0)\"\n\nlemma degree_cong:\n assumes \"\\i. coeff p i = 0 \\ coeff q i = 0\"\n shows \"degree p = degree q\"\n by sorry\n\nlemma coeff_Abs_poly_If_le:\n \"coeff (Abs_poly (\\i. if i \\ n then f i else 0)) = (\\i. if i \\ n then f i else 0)\"\n by sorry\n\nlemma coeff_eq_0:\n assumes \"degree p < n\"\n shows \"coeff p n = 0\"\n by sorry\n\nlemma le_degree: \"coeff p n \\ 0 \\ n \\ degree p\"\n by sorry\n\nlemma degree_le: \"\\i>n. coeff p i = 0 \\ degree p \\ n\"\n by sorry\n\nlemma less_degree_imp: \"n < degree p \\ \\i>n. coeff p i \\ 0\"\n by sorry\n\nlemma poly_eqI2:\n assumes \"degree p = degree q\" and \"\\i. i \\ degree p \\ coeff p i = coeff q i\"\n shows \"p = q\"\n by sorry\n\nsubsection \\The zero polynomial\\\n\ninstantiation poly :: (zero) zero\nbegin\n\nlift_definition zero_poly :: \"'a poly\"\n is \"\\_. 0\"\n by (rule MOST_I) simp\n\ninstance ..\n\nend\n\nlemma coeff_0 [simp]: \"coeff 0 n = 0\"\n by sorry\n\nlemma degree_0 [simp]: \"degree 0 = 0\"\n by sorry\n\nlemma leading_coeff_neq_0:\n assumes \"p \\ 0\"\n shows \"coeff p (degree p) \\ 0\"\n by sorry\n\nlemma leading_coeff_0_iff [simp]: \"coeff p (degree p) = 0 \\ p = 0\"\n by sorry\n\nlemma degree_lessI:\n assumes \"p \\ 0 \\ n > 0\" \"\\k\\n. coeff p k = 0\"\n shows \"degree p < n\"\n by sorry\n\nlemma eq_zero_or_degree_less: \n assumes \"degree p \\ n\" and \"coeff p n = 0\"\n shows \"p = 0 \\ degree p < n\"\n by sorry\n\nlemma coeff_0_degree_minus_1: \"coeff rrr dr = 0 \\ degree rrr \\ dr \\ degree rrr \\ dr - 1\"\n by sorry\n\nsubsection \\List-style constructor for polynomials\\\n\nlift_definition pCons :: \"'a::zero \\ 'a poly \\ 'a poly\"\n is \"\\a p. case_nat a (coeff p)\"\n by (rule MOST_SucD) (simp add: MOST_coeff_eq_0)\n\nlemmas coeff_pCons = pCons.rep_eq\n\nlemma coeff_pCons': \"poly.coeff (pCons c p) n = (if n = 0 then c else poly.coeff p (n - 1))\"\n by sorry\n\nlemma coeff_pCons_0 [simp]: \"coeff (pCons a p) 0 = a\"\n by sorry\n\nlemma coeff_pCons_Suc [simp]: \"coeff (pCons a p) (Suc n) = coeff p n\"\n by sorry\n\nlemma degree_pCons_le: \"degree (pCons a p) \\ Suc (degree p)\"\n by sorry\n\nlemma degree_pCons_eq: \"p \\ 0 \\ degree (pCons a p) = Suc (degree p)\"\n by sorry\n\nlemma degree_pCons_0: \"degree (pCons a 0) = 0\"\n by sorry\n\nlemma degree_pCons_eq_if [simp]: \"degree (pCons a p) = (if p = 0 then 0 else Suc (degree p))\"\n by sorry\n\nlemma pCons_0_0 [simp]: \"pCons 0 0 = 0\"\n by sorry\n\nlemma pCons_eq_iff [simp]: \"pCons a p = pCons b q \\ a = b \\ p = q\"\n by sorry\n\nlemma pCons_eq_0_iff [simp]: \"pCons a p = 0 \\ a = 0 \\ p = 0\"\n by sorry\n\nlemma pCons_cases [cases type: poly]:\n obtains (pCons) a q where \"p = pCons a q\"\n by sorry\n\nlemma pCons_induct [case_names 0 pCons, induct type: poly]:\n assumes zero: \"P 0\"\n assumes pCons: \"\\a p. a \\ 0 \\ p \\ 0 \\ P p \\ P (pCons a p)\"\n shows \"P p\"\n by sorry\n\nlemma degree_eq_zeroE:\n fixes p :: \"'a::zero poly\"\n assumes \"degree p = 0\"\n obtains a where \"p = pCons a 0\"\n by sorry\n\nsubsection \\Quickcheck generator for polynomials\\\n\nquickcheck_generator poly constructors: \"0 :: _ poly\", pCons\n\nsubsection \\List-style syntax for polynomials\\\n\nsyntax\n \"_poly\" :: \"args \\ 'a poly\" (\\(\\indent=2 notation=\\mixfix polynomial enumeration\\\\[:_:])\\)\nsyntax_consts\n \"_poly\" \\ pCons\ntranslations\n \"[:x, xs:]\" \\ \"CONST pCons x [:xs:]\"\n \"[:x:]\" \\ \"CONST pCons x 0\"\n\nlemma degree_0_id: \n assumes \"degree p = 0\"\n shows \"[: coeff p 0 :] = p\"\n by sorry\n\nlemma degree0_coeffs: \"degree p = 0 \\ \\ a. p = [: a :]\"\n by sorry\n\nlemma degree1_coeffs:\n fixes p :: \"'a::zero poly\"\n assumes \"degree p = 1\"\n obtains a b where \"p = [: b, a :]\" \"a \\ 0\"\n by sorry\n\nlemma degree2_coeffs:\n fixes p :: \"'a::zero poly\"\n assumes \"degree p = 2\"\n obtains a b c where \"p = [: c, b, a :]\" \"a \\ 0\"\n by sorry\n\nsubsection \\Representation of polynomials by lists of coefficients\\\n\nprimrec Poly :: \"'a::zero list \\ 'a poly\"\n where\n [code_post]: \"Poly [] = 0\"\n | [code_post]: \"Poly (a # as) = pCons a (Poly as)\"\n\nlemma Poly_replicate_0 [simp]: \"Poly (replicate n 0) = 0\"\n by sorry\n\nlemma Poly_eq_0: \"Poly as = 0 \\ (\\n. as = replicate n 0)\"\n by sorry\n\nlemma Poly_append_replicate_0 [simp]: \"Poly (as @ replicate n 0) = Poly as\"\n by sorry\n\nlemma Poly_snoc_zero [simp]: \"Poly (as @ [0]) = Poly as\"\n by sorry\n\nlemma Poly_cCons_eq_pCons_Poly [simp]: \"Poly (a ## p) = pCons a (Poly p)\"\n by sorry\n\nlemma Poly_on_rev_starting_with_0 [simp]: \"hd as = 0 \\ Poly (rev (tl as)) = Poly (rev as)\"\n by sorry\n\nlemma degree_Poly: \"degree (Poly xs) \\ length xs\"\n by sorry\n\nlemma coeff_Poly_eq [simp]: \"coeff (Poly xs) = nth_default 0 xs\"\n by sorry\n\ndefinition coeffs :: \"'a poly \\ 'a::zero list\"\n where \"coeffs p = (if p = 0 then [] else map (\\i. coeff p i) [0 ..< Suc (degree p)])\"\n\nlemma coeffs_eq_Nil [simp]: \"coeffs p = [] \\ p = 0\"\n by sorry\n\nlemma not_0_coeffs_not_Nil: \"p \\ 0 \\ coeffs p \\ []\"\n by sorry\n\nlemma coeffs_0_eq_Nil [simp]: \"coeffs 0 = []\"\n by sorry\n\nlemma coeffs_pCons_eq_cCons [simp]: \"coeffs (pCons a p) = a ## coeffs p\"\n by sorry\n\nlemma length_coeffs: \"p \\ 0 \\ length (coeffs p) = degree p + 1\"\n by sorry\n\nlemma coeffs_nth: \"p \\ 0 \\ n \\ degree p \\ coeffs p ! n = coeff p n\"\n by sorry\n\nlemma coeff_in_coeffs: \"p \\ 0 \\ n \\ degree p \\ coeff p n \\ set (coeffs p)\"\n by sorry\n\nlemma not_0_cCons_eq [simp]: \"p \\ 0 \\ a ## coeffs p = a # coeffs p\"\n by sorry\n\nlemma Poly_coeffs [simp, code abstype]: \"Poly (coeffs p) = p\"\n by sorry\n\nlemma coeffs_Poly [simp]: \"coeffs (Poly as) = strip_while (HOL.eq 0) as\"\n by sorry\n\nlemma no_trailing_coeffs [simp]:\n \"no_trailing (HOL.eq 0) (coeffs p)\"\n by sorry\n\nlemma strip_while_coeffs [simp]:\n \"strip_while (HOL.eq 0) (coeffs p) = coeffs p\"\n by sorry\n\nlemma coeffs_eq_iff: \"p = q \\ coeffs p = coeffs q\"\n (is \"?P \\ ?Q\")\n by sorry\n\nlemma nth_default_coeffs_eq: \"nth_default 0 (coeffs p) = coeff p\"\n by sorry\n\nlemma range_coeff: \"range (coeff p) = insert 0 (set (coeffs p))\" \n by sorry\n\nlemma [code]: \"coeff p = nth_default 0 (coeffs p)\"\n by sorry\n\nlemma coeffs_eqI:\n assumes coeff: \"\\n. coeff p n = nth_default 0 xs n\"\n assumes zero: \"no_trailing (HOL.eq 0) xs\"\n shows \"coeffs p = xs\"\n by sorry\n\nlemma degree_eq_length_coeffs [code]: \"degree p = length (coeffs p) - 1\"\n by sorry\n\nlemma length_coeffs_degree: \"p \\ 0 \\ length (coeffs p) = Suc (degree p)\"\n by sorry\n\nlemma [code abstract]: \"coeffs 0 = []\"\n by sorry\n\nlemma [code abstract]: \"coeffs (pCons a p) = a ## coeffs p\"\n by sorry\n\nlemma set_coeffs_subset_singleton_0_iff [simp]:\n \"set (coeffs p) \\ {0} \\ p = 0\"\n by sorry\n\nlemma set_coeffs_not_only_0 [simp]:\n \"set (coeffs p) \\ {0}\"\n by sorry\n\nlemma forall_coeffs_conv:\n \"(\\n. P (coeff p n)) \\ (\\c \\ set (coeffs p). P c)\" if \"P 0\"\n by sorry\n\ninstantiation poly :: (\"{zero, equal}\") equal\nbegin\n\ndefinition [code]: \"HOL.equal (p::'a poly) q \\ HOL.equal (coeffs p) (coeffs q)\"\n\ninstance\n by standard (simp add: equal equal_poly_def coeffs_eq_iff)\n\nend\n\nlemma [code nbe]: \"HOL.equal (p :: _ poly) p \\ True\"\n by sorry\n\ndefinition is_zero :: \"'a::zero poly \\ bool\"\n where [code]: \"is_zero p \\ List.null (coeffs p)\"\n\nlemma is_zero_null [code_abbrev]: \"is_zero p \\ p = 0\"\n by sorry\n\ntext \\Reconstructing the polynomial from the list\\\n \\ \\contributed by Sebastiaan J.C. Joosten and René Thiemann\\\n\ndefinition poly_of_list :: \"'a::comm_monoid_add list \\ 'a poly\"\n where [simp]: \"poly_of_list = Poly\"\n\nlemma poly_of_list_impl [code abstract]: \"coeffs (poly_of_list as) = strip_while (HOL.eq 0) as\"\n by sorry\n\nsubsection \\Fold combinator for polynomials\\\n\ndefinition fold_coeffs :: \"('a::zero \\ 'b \\ 'b) \\ 'a poly \\ 'b \\ 'b\"\n where \"fold_coeffs f p = foldr f (coeffs p)\"\n\nlemma fold_coeffs_0_eq [simp]: \"fold_coeffs f 0 = id\"\n by sorry\n\nlemma fold_coeffs_pCons_eq [simp]: \"f 0 = id \\ fold_coeffs f (pCons a p) = f a \\ fold_coeffs f p\"\n by sorry\n\nlemma fold_coeffs_pCons_0_0_eq [simp]: \"fold_coeffs f (pCons 0 0) = id\"\n by sorry\n\nlemma fold_coeffs_pCons_coeff_not_0_eq [simp]:\n \"a \\ 0 \\ fold_coeffs f (pCons a p) = f a \\ fold_coeffs f p\"\n by sorry\n\nlemma fold_coeffs_pCons_not_0_0_eq [simp]:\n \"p \\ 0 \\ fold_coeffs f (pCons a p) = f a \\ fold_coeffs f p\"\n by sorry\n\nsubsection \\Canonical morphism on polynomials -- evaluation\\\n\ndefinition poly :: \\'a::comm_semiring_0 poly \\ 'a \\ 'a\\\n where \\poly p a = horner_sum id a (coeffs p)\\\n\nlemma poly_eq_fold_coeffs:\n \\poly p = fold_coeffs (\\a f x. a + x * f x) p (\\x. 0)\\\n by sorry\n\nlemma poly_0 [simp]: \"poly 0 x = 0\"\n by sorry\n\nlemma poly_pCons [simp]: \"poly (pCons a p) x = a + x * poly p x\"\n by sorry\n\nlemma poly_altdef: \"poly p x = (\\i\\degree p. coeff p i * x ^ i)\"\n for x :: \"'a::{comm_semiring_0,semiring_1}\"\n by sorry\n\nlemma poly_as_sum:\n fixes p :: \"'a::comm_semiring_1 poly\"\n shows \"poly p x = (\\i\\degree p. x ^ i * coeff p i)\"\n by sorry\n\nlemma poly_0_coeff_0: \"poly p 0 = coeff p 0\"\n by sorry\n\nlemma poly_zero:\n fixes p :: \"'a :: comm_ring_1 poly\"\n assumes x: \"poly p x = 0\" shows \"p = 0 \\ degree p = 0\"\n by sorry\n\nsubsection \\Monomials\\\n\nlift_definition monom :: \"'a \\ nat \\ 'a::zero poly\"\n is \"\\a m n. if m = n then a else 0\"\n by (simp add: MOST_iff_cofinite)\n\nlemma coeff_monom [simp]: \"coeff (monom a m) n = (if m = n then a else 0)\"\n by sorry\n\nlemma monom_0: \"monom a 0 = [:a:]\"\n by sorry\n\nlemma monom_Suc: \"monom a (Suc n) = pCons 0 (monom a n)\"\n by sorry\n\nlemma monom_eq_0 [simp]: \"monom 0 n = 0\"\n by sorry\n\nlemma monom_eq_0_iff [simp]: \"monom a n = 0 \\ a = 0\"\n by sorry\n\nlemma monom_eq_iff [simp]: \"monom a n = monom b n \\ a = b\"\n by sorry\n\nlemma degree_monom_le: \"degree (monom a n) \\ n\"\n by sorry\n\nlemma degree_monom_eq: \"a \\ 0 \\ degree (monom a n) = n\"\n by sorry\n\nlemma coeffs_monom [code abstract]:\n \"coeffs (monom a n) = (if a = 0 then [] else replicate n 0 @ [a])\"\n by sorry\n\nlemma fold_coeffs_monom [simp]: \"a \\ 0 \\ fold_coeffs f (monom a n) = f 0 ^^ n \\ f a\"\n by sorry\n\nlemma poly_monom: \"poly (monom a n) x = a * x ^ n\"\n for a x :: \"'a::comm_semiring_1\"\n by sorry\n\nlemma monom_eq_iff': \"monom c n = monom d m \\ c = d \\ (c = 0 \\ n = m)\"\n by sorry\n\nlemma monom_eq_const_iff: \"monom c n = [:d:] \\ c = d \\ (c = 0 \\ n = 0)\"\n by sorry\n\nsubsection \\Leading coefficient\\\n\nabbreviation lead_coeff:: \"'a::zero poly \\ 'a\"\n where \"lead_coeff p \\ coeff p (degree p)\"\n\nlemma lead_coeff_pCons[simp]:\n \"p \\ 0 \\ lead_coeff (pCons a p) = lead_coeff p\"\n \"p = 0 \\ lead_coeff (pCons a p) = a\"\n by sorry\n\nlemma lead_coeff_monom [simp]: \"lead_coeff (monom c n) = c\"\n by sorry\n\nlemma last_coeffs_eq_coeff_degree:\n \"last (coeffs p) = lead_coeff p\" if \"p \\ 0\"\n by sorry\n\nlemma lead_coeff_list_def:\n \"lead_coeff p = (if coeffs p=[] then 0 else last (coeffs p))\"\n by sorry\n\nsubsection \\Addition and subtraction\\\n\ninstantiation poly :: (comm_monoid_add) comm_monoid_add\nbegin\n\nlift_definition plus_poly :: \"'a poly \\ 'a poly \\ 'a poly\"\n is \"\\p q n. coeff p n + coeff q n\"\nproof -\n fix q p :: \"'a poly\"\n show \"\\\\<^sub>\\n. coeff p n + coeff q n = 0\"\n using MOST_coeff_eq_0[of p] MOST_coeff_eq_0[of q] by eventually_elim simp\nqed\n\nlemma coeff_add [simp]: \"coeff (p + q) n = coeff p n + coeff q n\"\n by sorry\n\ninstance\nproof\n fix p q r :: \"'a poly\"\n show \"(p + q) + r = p + (q + r)\"\n by (simp add: poly_eq_iff add.assoc)\n show \"p + q = q + p\"\n by (simp add: poly_eq_iff add.commute)\n show \"0 + p = p\"\n by (simp add: poly_eq_iff)\nqed\n\nend\n\ninstantiation poly :: (cancel_comm_monoid_add) cancel_comm_monoid_add\nbegin\n\nlift_definition minus_poly :: \"'a poly \\ 'a poly \\ 'a poly\"\n is \"\\p q n. coeff p n - coeff q n\"\nproof -\n fix q p :: \"'a poly\"\n show \"\\\\<^sub>\\n. coeff p n - coeff q n = 0\"\n using MOST_coeff_eq_0[of p] MOST_coeff_eq_0[of q] by eventually_elim simp\nqed\n\nlemma coeff_diff [simp]: \"coeff (p - q) n = coeff p n - coeff q n\"\n by sorry\n\ninstance\nproof\n fix p q r :: \"'a poly\"\n show \"p + q - p = q\"\n by (simp add: poly_eq_iff)\n show \"p - q - r = p - (q + r)\"\n by (simp add: poly_eq_iff diff_diff_eq)\nqed\n\nend\n\ninstantiation poly :: (ab_group_add) ab_group_add\nbegin\n\nlift_definition uminus_poly :: \"'a poly \\ 'a poly\"\n is \"\\p n. - coeff p n\"\nproof -\n fix p :: \"'a poly\"\n show \"\\\\<^sub>\\n. - coeff p n = 0\"\n using MOST_coeff_eq_0 by simp\nqed\n\nlemma coeff_minus [simp]: \"coeff (- p) n = - coeff p n\"\n by sorry\n\ninstance\nproof\n fix p q :: \"'a poly\"\n show \"- p + p = 0\"\n by (simp add: poly_eq_iff)\n show \"p - q = p + - q\"\n by (simp add: poly_eq_iff)\nqed\n\nend\n\nlemma add_pCons [simp]: \"pCons a p + pCons b q = pCons (a + b) (p + q)\"\n by sorry\n\nlemma minus_pCons [simp]: \"- pCons a p = pCons (- a) (- p)\"\n by sorry\n\nlemma diff_pCons [simp]: \"pCons a p - pCons b q = pCons (a - b) (p - q)\"\n by sorry\n\nlemma degree_add_le_max: \"degree (p + q) \\ max (degree p) (degree q)\"\n by sorry\n\nlemma degree_add_le: \"degree p \\ n \\ degree q \\ n \\ degree (p + q) \\ n\"\n by sorry\n\nlemma degree_add_less: \"degree p < n \\ degree q < n \\ degree (p + q) < n\"\n by sorry\n\nlemma degree_add_eq_right: assumes \"degree p < degree q\" shows \"degree (p + q) = degree q\"\n by sorry\n\nlemma degree_add_eq_left: \"degree q < degree p \\ degree (p + q) = degree p\"\n by sorry\n\nlemma degree_minus [simp]: \"degree (- p) = degree p\"\n by sorry\n\nlemma lead_coeff_add_le: \"degree p < degree q \\ lead_coeff (p + q) = lead_coeff q\"\n by sorry\n\nlemma lead_coeff_minus: \"lead_coeff (- p) = - lead_coeff p\"\n by sorry\n\nlemma degree_diff_le_max: \"degree (p - q) \\ max (degree p) (degree q)\"\n for p q :: \"'a::ab_group_add poly\"\n by sorry\n\nlemma degree_diff_le: \"degree p \\ n \\ degree q \\ n \\ degree (p - q) \\ n\"\n for p q :: \"'a::ab_group_add poly\"\n by sorry\n\nlemma degree_diff_less: \"degree p < n \\ degree q < n \\ degree (p - q) < n\"\n for p q :: \"'a::ab_group_add poly\"\n by sorry\n\nlemma add_monom: \"monom a n + monom b n = monom (a + b) n\"\n by sorry\n\nlemma diff_monom: \"monom a n - monom b n = monom (a - b) n\"\n by sorry\n\nlemma minus_monom: \"- monom a n = monom (- a) n\"\n by sorry\n\nlemma coeff_sum: \"coeff (\\x\\A. p x) i = (\\x\\A. coeff (p x) i)\"\n by sorry\n\nlemma monom_sum: \"monom (\\x\\A. a x) n = (\\x\\A. monom (a x) n)\"\n by sorry\n\nfun plus_coeffs :: \"'a::comm_monoid_add list \\ 'a list \\ 'a list\"\n where\n \"plus_coeffs xs [] = xs\"\n | \"plus_coeffs [] ys = ys\"\n | \"plus_coeffs (x # xs) (y # ys) = (x + y) ## plus_coeffs xs ys\"\n\nlemma coeffs_plus_eq_plus_coeffs [code abstract]:\n \"coeffs (p + q) = plus_coeffs (coeffs p) (coeffs q)\"\n by sorry\n\nlemma coeffs_uminus [code abstract]:\n \"coeffs (- p) = map uminus (coeffs p)\"\n by sorry\n\nlemma [code]: \"p - q = p + - q\"\n for p q :: \"'a::ab_group_add poly\"\n by sorry\n\nlemma poly_add [simp]: \"poly (p + q) x = poly p x + poly q x\"\n by sorry\n\nlemma poly_minus [simp]: \"poly (- p) x = - poly p x\"\n for x :: \"'a::comm_ring\"\n by sorry\n\nlemma poly_diff [simp]: \"poly (p - q) x = poly p x - poly q x\"\n for x :: \"'a::comm_ring\"\n by sorry\n\nlemma poly_sum: \"poly (\\k\\A. p k) x = (\\k\\A. poly (p k) x)\"\n by sorry\n\nlemma poly_sum_list: \"poly (\\p\\ps. p) y = (\\p\\ps. poly p y)\"\n by sorry\n\nlemma poly_sum_mset: \"poly (\\x\\#A. p x) y = (\\x\\#A. poly (p x) y)\"\n by sorry\n\nlemma degree_sum_le: \"finite S \\ (\\p. p \\ S \\ degree (f p) \\ n) \\ degree (sum f S) \\ n\"\n by sorry\n\nlemma degree_sum_less:\n assumes \"\\x. x \\ A \\ degree (f x) < n\" \"n > 0\"\n shows \"degree (sum f A) < n\"\n by sorry\n\nlemma poly_as_sum_of_monoms':\n assumes \"degree p \\ n\"\n shows \"(\\i\\n. monom (coeff p i) i) = p\"\n by sorry\n\nlemma poly_as_sum_of_monoms: \"(\\i\\degree p. monom (coeff p i) i) = p\"\n by sorry\n\nlemma Poly_snoc: \"Poly (xs @ [x]) = Poly xs + monom x (length xs)\"\n by sorry\n\nsubsection \\Multiplication by a constant, polynomial multiplication and the unit polynomial\\\n\nlift_definition smult :: \"'a::comm_semiring_0 \\ 'a poly \\ 'a poly\"\n is \"\\a p n. a * coeff p n\"\nproof -\n fix a :: 'a and p :: \"'a poly\"\n show \"\\\\<^sub>\\ i. a * coeff p i = 0\"\n using MOST_coeff_eq_0[of p] by eventually_elim simp\nqed\n\nlemma coeff_smult [simp]: \"coeff (smult a p) n = a * coeff p n\"\n by sorry\n\nlemma degree_smult_le: \"degree (smult a p) \\ degree p\"\n by sorry\n\nlemma smult_smult [simp]: \"smult a (smult b p) = smult (a * b) p\"\n by sorry\n\nlemma smult_0_right [simp]: \"smult a 0 = 0\"\n by sorry\n\nlemma smult_0_left [simp]: \"smult 0 p = 0\"\n by sorry\n\nlemma smult_1_left [simp]: \"smult (1::'a::comm_semiring_1) p = p\"\n by sorry\n\nlemma smult_add_right: \"smult a (p + q) = smult a p + smult a q\"\n by sorry\n\nlemma smult_add_left: \"smult (a + b) p = smult a p + smult b p\"\n by sorry\n\nlemma smult_minus_right [simp]: \"smult a (- p) = - smult a p\"\n for a :: \"'a::comm_ring\"\n by sorry\n\nlemma smult_minus_left [simp]: \"smult (- a) p = - smult a p\"\n for a :: \"'a::comm_ring\"\n by sorry\n\nlemma smult_diff_right: \"smult a (p - q) = smult a p - smult a q\"\n for a :: \"'a::comm_ring\"\n by sorry\n\nlemma smult_diff_left: \"smult (a - b) p = smult a p - smult b p\"\n for a b :: \"'a::comm_ring\"\n by sorry\n\nlemmas smult_distribs =\n smult_add_left smult_add_right\n smult_diff_left smult_diff_right\n\nlemma smult_pCons [simp]: \"smult a (pCons b p) = pCons (a * b) (smult a p)\"\n by sorry\n\nlemma smult_monom: \"smult a (monom b n) = monom (a * b) n\"\n by sorry\n\nlemma smult_Poly: \"smult c (Poly xs) = Poly (map (\n then show ?thesis\n by (simp add: normalize_poly_def unit_factor_poly_def\n smult_conv_map_poly map_poly_map_poly o_def **\n qed\nnext\n fix p :: \"'a poly\"\n assume \"is_unit p\"\n then obtain c where p: \"p = [:c:]\" \"c dvd 1\"\n by (auto simp: is_unit_poly_iff)\n then show \"unit_factor p = p\"\n by (simp add: unit_factor_poly_def monom_0 is_unit_unit_factor)\nnext\n fix p :: \"'a poly\"\n assume \"p \\ 0\"\n then show \"is_unit (unit_factor p)\"\n by (simp add: unit_factor_poly_def monom_0 is_unit_poly_iff unit_factor_is_unit)\nnext\n fix a b :: \"'a poly\" assume \"is_unit a\"\n thus \"unit_factor (a * b) = a * unit_factor b\"\n by (auto simp: unit_factor_poly_def lead_coeff_mult unit_factor_mult elim!: is_unit_polyE)\nqed (simp_all add: normalize_poly_def unit_factor_poly_def monom_0 lead_coeff_mult unit_factor_mult)\n\nend\n\ninstance poly :: (\"{semidom_divide_unit_factor,idom_divide,normalization_semidom_multiplicative}\")\n normalization_semidom_multiplicative\n by intro_classes (auto simp: unit_factor_poly_def lead_coeff_mult unit_factor_mult)\n\nlemma normalize_poly_eq_map_poly: \"normalize p = map_poly (\\x. x div unit_factor (lead_coeff p)) p\"\n by sorry\n\nlemma coeff_normalize [simp]:\n \"coeff (normalize p) n = coeff p n div unit_factor (lead_coeff p)\"\n by sorry\n\nlemma lead_coeff_normalize_field:\n fixes p::\"'a::{field,semidom_divide_unit_factor} poly\"\n assumes \"p\\0\"\n shows \"lead_coeff (normalize p) = 1\"\n by sorry\n\nlemma smult_normalize_field_eq:\n fixes p::\"'a::{field,semidom_divide_unit_factor} poly\"\n shows \"smult (lead_coeff p) (normalize p) = p\"\n by sorry\n\nclass field_unit_factor = field + unit_factor +\n assumes unit_factor_field [simp]: \"unit_factor = id\"\nbegin\n\nsubclass semidom_divide_unit_factor\nproof\n fix a\n assume \"a \\ 0\"\n then have \"1 = a * inverse a\" by simp\n then have \"a dvd 1\" ..\n then show \"unit_factor a dvd 1\" by simp\nqed simp_all\n\nend\n\nlemma unit_factor_pCons:\n \"unit_factor (pCons a p) = (if p = 0 then [:unit_factor a:] else unit_factor p)\"\n by sorry\n\nlemma normalize_monom [simp]: \"normalize (monom a n) = monom (normalize a) n\"\n by sorry\n\nlemma unit_factor_monom [simp]: \"unit_factor (monom a n) = [:unit_factor a:]\"\n by sorry\n\nlemma normalize_const_poly: \"normalize [:c:] = [:normalize c:]\"\n by sorry\n\nlemma normalize_smult:\n fixes c :: \"'a :: {normalization_semidom_multiplicative, idom_divide}\"\n shows \"normalize (smult c p) = smult (normalize c) (normalize p)\"\n by sorry\n\ninstantiation poly :: (field) idom_modulo\nbegin\n\ndefinition modulo_poly :: \"'a poly \\ 'a poly \\ 'a poly\"\n where mod_poly_def: \"f mod g =\n (if g = 0 then f else pseudo_mod (smult ((1 / lead_coeff g) ^ (Suc (degree f) - degree g)) f) g)\"\n\ninstance\nproof\n fix x y :: \"'a poly\"\n show \"x div y * y + x mod y = x\"\n proof (cases \"y = 0\")\n case True\n then show ?thesis\n by (simp add: divide_poly_0 mod_poly_def)\n next\n case False\n then have \"pseudo_divmod (smult ((1 / lead_coeff y) ^ (Suc (degree x) - degree y)) x) y =\n (x div y, x mod y)\"\n by (simp add: divide_poly_field mod_poly_def pseudo_mod_def)\n with False pseudo_divmod [OF False this] show ?thesis\n by (simp add: power_mult_distrib [symmetric] ac_simps)\n qed\nqed\n\nend\n\nlemma pseudo_divmod_eq_div_mod:\n \\pseudo_divmod f g = (f div g, f mod g)\\ if \\lead_coeff g = 1\\\n by sorry\n\nlemma degree_mod_less_degree:\n \\degree (x mod y) < degree y\\ if \\y \\ 0\\ \\\\ y dvd x\\\n by sorry\n\ninstantiation poly :: (field) unique_euclidean_ring\nbegin\n\ndefinition euclidean_size_poly :: \"'a poly \\ nat\"\n where \"euclidean_size_poly p = (if p = 0 then 0 else 2 ^ degree p)\"\n\ndefinition division_segment_poly :: \"'a poly \\ 'a poly\"\n where [simp]: \"division_segment_poly p = 1\"\n\ninstance proof\n show \\(q * p + r) div p = q\\ if \\p \\ 0\\\n and \\euclidean_size r < euclidean_size p\\ for q p r :: \\'a poly\\\n proof (cases \\r = 0\\)\n case True\n with that show ?thesis\n by simp\n next\n case False\n with \\p \\ 0\\ \\euclidean_size r < euclidean_size p\\\n have \\degree r < degree p\\\n by (simp add: euclidean_size_poly_def)\n with \\r \\ 0\\ have \\\\ p dvd r\\\n by (auto dest: dvd_imp_degree)\n have \\(q * p + r) div p = q \\ (q * p + r) mod p = r\\\n proof (rule ccontr)\n assume \\\\ ?thesis\\\n moreover have *: \\((q * p + r) div p - q) * p = r - (q * p + r) mod p\\\n by (simp add: algebra_simps)\n ultimately have \\(q * p + r) div p \\ q\\ and \\(q * p + r) mod p \\ r\\\n using \\p \\ 0\\ by auto\n from \\\\ p dvd r\\ have \\\\ p dvd (q * p + r)\\\n by simp\n with \\p \\ 0\\ have \\degree ((q * p + r) mod p) < degree p\\\n by (rule degree_mod_less_degree)\n with \\degree r < degree p\\ \\(q * p + r) mod p \\ r\\\n have \\degree (r - (q * p + r) mod p) < degree p\\\n by (auto intro: degree_diff_less)\n also have \\degree p \\ degree ((q * p + r) div p - q) + degree p\\\n by simp\n also from \\(q * p + r) div p \\ q\\ \\p \\ 0\\\n have \\\\ = degree (((q * p + r) div p - q) * p)\\\n by (simp add: degree_mult_eq)\n also from * have \\\\ = degree (r - (q * p + r) mod p)\\\n by simp\n finally have \\degree (r - (q * p + r) mod p) < degree (r - (q * p + r) mod p)\\ .\n then show False\n by simp\n qed\n then show \\(q * p + r) div p = q\\ ..\n qed\nqed (auto simp: euclidean_size_poly_def degree_mult_eq power_add intro: degree_mod_less_degree)\n\nend\n\nlemma euclidean_relation_polyI [case_names by0 divides euclidean_relation]:\n \\(x div y, x mod y) = (q, r)\\\n if by0: \\y = 0 \\ q = 0 \\ r = x\\\n and divides: \\y \\ 0 \\ y dvd x \\ r = 0 \\ x = q * y\\\n and euclidean_relation: \\y \\ 0 \\ \\ y dvd x \\ degree r < degree y \\ x = q * y + r\\\n by sorry\n\nlemma div_poly_eq_0_iff:\n \\x div y = 0 \\ x = 0 \\ y = 0 \\ degree x < degree y\\ for x y :: \\'a::field poly\\\n by sorry\n\nlemma div_poly_less:\n \\x div y = 0\\ if \\degree x < degree y\\ for x y :: \\'a::field poly\\\n by sorry\n\nlemma mod_poly_less:\n \\x mod y = x\\ if \\degree x < degree y\\\n by sorry\n\nlemma degree_div_less:\n \\degree (x div y) < degree x\\\n if \\degree x > 0\\ \\degree y > 0\\\n for x y :: \\'a::field poly\\\n by sorry\n\nlemma degree_mod_less': \"b \\ 0 \\ a mod b \\ 0 \\ degree (a mod b) < degree b\"\n by sorry\n\nlemma degree_mod_less: \"y \\ 0 \\ x mod y = 0 \\ degree (x mod y) < degree y\"\n by sorry\n\nlemma div_smult_left: \\smult a x div y = smult a (x div y)\\ (is ?Q)\n and mod_smult_left: \\smult a x mod y = smult a (x mod y)\\ (is ?R)\n for x y :: \\'a::field poly\\\n by sorry\n\nlemma poly_div_minus_left [simp]: \"(- x) div y = - (x div y)\"\n for x y :: \"'a::field poly\"\n by sorry\n\nlemma poly_mod_minus_left [simp]: \"(- x) mod y = - (x mod y)\"\n for x y :: \"'a::field poly\"\n by sorry\n\nlemma poly_div_add_left: \\(x + y) div z = x div z + y div z\\ (is ?Q)\n and poly_mod_add_left: \\(x + y) mod z = x mod z + y mod z\\ (is ?R)\n for x y z :: \\'a::field poly\\\n by sorry\n\nlemma poly_div_diff_left: \"(x - y) div z = x div z - y div z\"\n for x y z :: \"'a::field poly\"\n by sorry\n\nlemma poly_mod_diff_left: \"(x - y) mod z = x mod z - y mod z\"\n for x y z :: \"'a::field poly\"\n by sorry\n\nlemma div_smult_right: \\x div smult a y = smult (inverse a) (x div y)\\ (is ?Q)\n and mod_smult_right: \\x mod smult a y = (if a = 0 then x else x mod y)\\ (is ?R)\n by sorry\n\nlemma mod_mult_unit_eq:\n \\x mod (z * y) = x mod y\\\n if \\is_unit z\\\n for x y z :: \\'a::field poly\\\n by sorry\n\nlemma poly_div_minus_right [simp]: \"x div (- y) = - (x div y)\"\n for x y :: \"'a::field poly\"\n by sorry\n\nlemma poly_mod_minus_right [simp]: \"x mod (- y) = x mod y\"\n for x y :: \"'a::field poly\"\n by sorry\n\nlemma poly_div_mult_right: \\x div (y * z) = (x div y) div z\\ (is ?Q)\n and poly_mod_mult_right: \\x mod (y * z) = y * (x div y mod z) + x mod y\\ (is ?R)\n for x y z :: \\'a::field poly\\\n by sorry\n\nlemma dvd_pCons_imp_dvd_pCons_mod:\n \\y dvd pCons a (x mod y)\\ if \\y dvd pCons a x\\\n by sorry\n\nlemma degree_less_if_less_eqI:\n \\degree x < degree y\\ if \\degree x \\ degree y\\ \\coeff x (degree y) = 0\\ \\x \\ 0\\\n by sorry\n\nlemma div_pCons_eq:\n \\pCons a p div q = (if q = 0 then 0 else pCons (coeff (pCons a (p mod q)) (degree q) / lead_coeff q) (p div q))\\ (is ?Q)\n and mod_pCons_eq:\n \\pCons a p mod q = (if q = 0 then pCons a p else pCons a (p mod q) - smult (coeff (pCons a (p mod q)) (degree q) / lead_coeff q) q)\\ (is ?R)\n for x y :: \\'a::field poly\\\n by sorry\n\nlemma div_mod_fold_coeffs:\n \"(p div q, p mod q) =\n (if q = 0 then (0, p)\n else\n fold_coeffs\n (\\a (s, r).\n let b = coeff (pCons a r) (degree q) / coeff q (degree q)\n in (pCons b s, pCons a r - smult b q)) p (0, 0))\"\n by sorry\n\nlemma mod_pCons:\n fixes a :: \"'a::field\"\n and x y :: \"'a::field poly\"\n assumes y: \"y \\ 0\"\n defines \"b \\ coeff (pCons a (x mod y)) (degree y) / coeff y (degree y)\"\n shows \"(pCons a x) mod y = pCons a (x mod y) - smult b y\"\n by sorry\n\nsubsubsection \\List-based versions for fast implementation\\\n\nfun minus_poly_rev_list :: \"'a :: group_add list \\ 'a list \\ 'a list\"\n where\n \"minus_poly_rev_list (x # xs) (y # ys) = (x - y) # (minus_poly_rev_list xs ys)\"\n | \"minus_poly_rev_list xs [] = xs\"\n | \"minus_poly_rev_list [] (y # ys) = []\"\n\nfun pseudo_divmod_main_list ::\n \"'a::comm_ring_1 \\ 'a list \\ 'a list \\ 'a list \\ nat \\ 'a list \\ 'a list\"\n where\n \"pseudo_divmod_main_list lc q r d (Suc n) =\n (let\n rr = map (" }, { "theorem_id": 66, "title": "089_the_factor_and_remainder_theorems", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Johannes Hölzl, Kim Morrison, Jens Wagemaker\n-/\nmodule\n\npublic import Mathlib.Algebra.Field.IsField\npublic import Mathlib.Algebra.Polynomial.Inductions\npublic import Mathlib.Algebra.Polynomial.Monic\npublic import Mathlib.RingTheory.Multiplicity\npublic import Mathlib.Data.Nat.Lattice\n\n/-!\n# Division of univariate polynomials\n\nThe main defs are `divByMonic` and `modByMonic`.\nThe compatibility between these is given by `modByMonic_add_div`.\nWe also define `rootMultiplicity`.\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Polynomial\n\nopen Finset\n\nnamespace Polynomial\n\nuniverse u v w z\n\nvariable {R : Type u} {S : Type v} {T : Type w} {A : Type z} {a b : R} {n : ℕ}\n\nsection Semiring\n\nvariable [Semiring R]\n\ntheorem X_dvd_iff {f : R[X]} : X ∣ f ↔ f.coeff 0 = 0 :=\n ⟨fun ⟨g, hfg⟩ => by rw [hfg, coeff_X_mul_zero], fun hf =>\n ⟨f.divX, by rw [← add_zero (X * f.divX), ← C_0, ← hf, X_mul_divX_add]⟩⟩\n\ntheorem X_pow_dvd_iff {f : R[X]} {n : ℕ} : X ^ n ∣ f ↔ ∀ d < n, f.coeff d = 0 :=\n ⟨fun ⟨g, hgf⟩ d hd => by\n simp only [hgf, coeff_X_pow_mul', ite_eq_right_iff, not_le_of_gt hd, IsEmpty.forall_iff],\n fun hd => by\n induction n with := by sorry\nvariable {p q : R[X]}\n\ntheorem finiteMultiplicity_of_degree_pos_of_monic (hp : (0 : WithBot ℕ) < degree p) (hmp : Monic p)\n (hq : q ≠ 0) : FiniteMultiplicity p q :=\n have zn0 : (0 : R) ≠ 1 :=\n haveI := Nontrivial.of_polynomial_ne hq\n zero_ne_one\n ⟨natDegree q, fun ⟨r, hr⟩ => by\n have hp0 : p ≠ 0 := fun hp0 => by simp [hp0] at hp\n have hr0 : r ≠ 0 := fun hr0 => by subst hr0; simp [hq] at hr\n have hpn1 : leadingCoeff p ^ (natDegree q + 1) = 1 := by simp [show _ = _ from hmp]\n have hpn0' : leadingCoeff p ^ (natDegree q + 1) ≠ 0 := hpn1.symm ▸ zn0.symm\n have hpnr0 : leadingCoeff (p ^ (natDegree q + 1)) * leadingCoeff r ≠ 0 := by sorry\nlemma eq_mul_leadingCoeff_of_monic_of_dvd_of_natDegree_le {p q : R[X]}\n (hp : p.Monic) (hdvd : p ∣ q) (hdeg : q.natDegree ≤ p.natDegree) :\n q = p * C q.leadingCoeff := by sorry\nlemma eq_of_monic_of_dvd_of_natDegree_le {p q : R[X]} (hp : p.Monic)\n (hq : q.Monic) (hdvd : p ∣ q) (hdeg : q.natDegree ≤ p.natDegree) : q = p := by sorry\nend Semiring\n\nsection Ring\n\nvariable [Ring R] {p q : R[X]}\n\ntheorem div_wf_lemma (h : degree q ≤ degree p ∧ p ≠ 0) (hq : Monic q) :\n degree (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) < degree p :=\n have hp : leadingCoeff p ≠ 0 := mt leadingCoeff_eq_zero.1 h.2\n have hq0 : q ≠ 0 := hq.ne_zero_of_polynomial_ne h.2\n have hlt : natDegree q ≤ natDegree p :=\n (Nat.cast_le (α := WithBot ℕ)).1\n (by rw [← degree_eq_natDegree h.2, ← degree_eq_natDegree hq0]; exact h.1)\n degree_sub_lt\n (by\n rw [hq.degree_mul_comm, hq.degree_mul, degree_C_mul_X_pow _ hp, degree_eq_natDegree h.2,\n degree_eq_natDegree hq0, ← Nat.cast_add, tsub_add_cancel_of_le hlt])\n h.2 (by rw [leadingCoeff_monic_mul hq, leadingCoeff_mul_X_pow, leadingCoeff_C])\n\n/-- See `divByMonic`. -/\nnoncomputable def divModByMonicAux : ∀ (_p : R[X]) {q : R[X]}, Monic q → R[X] × R[X]\n | p, q, hq =>\n letI := Classical.decEq R\n if h : degree q ≤ degree p ∧ p ≠ 0 then\n let z := C (leadingCoeff p) * X ^ (natDegree p - natDegree q)\n have _wf := div_wf_lemma h hq\n let dm := divModByMonicAux (p - q * z) hq\n ⟨z + dm.1, dm.2⟩\n else ⟨0, p⟩\n termination_by p => p\n\n/-- `divByMonic`, denoted as `p /ₘ q`, gives the quotient of `p` by a monic polynomial `q`. -/\ndef divByMonic (p q : R[X]) : R[X] :=\n letI := Classical.decEq R\n if hq : Monic q then (divModByMonicAux p hq).1 else 0\n\n/-- `modByMonic`, denoted as `p %ₘ q`, gives the remainder of `p` by a monic polynomial `q`. -/\ndef modByMonic (p q : R[X]) : R[X] :=\n letI := Classical.decEq R\n if hq : Monic q then (divModByMonicAux p hq).2 else p\n\n@[inherit_doc]\ninfixl:70 \" /ₘ \" => divByMonic\n\n@[inherit_doc]\ninfixl:70 \" %ₘ \" => modByMonic\n\ntheorem degree_modByMonic_lt [Nontrivial R] :\n ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q := by sorry\ntheorem natDegree_modByMonic_lt (p : R[X]) {q : R[X]} (hmq : Monic q) (hq : q ≠ 1) :\n natDegree (p %ₘ q) < q.natDegree := by sorry\ntheorem zero_modByMonic (p : R[X]) : 0 %ₘ p = 0 := by sorry\ntheorem zero_divByMonic (p : R[X]) : 0 /ₘ p = 0 := by sorry\ntheorem modByMonic_zero (p : R[X]) : p %ₘ 0 = p :=\n letI := Classical.decEq R\n if h : Monic (0 : R[X]) then by\n haveI := monic_zero_iff_subsingleton.mp h\n simp [eq_iff_true_of_subsingleton]\n else by unfold modByMonic divModByMonicAux; rw [dif_neg h]\n\n@[simp]\ntheorem divByMonic_zero (p : R[X]) : p /ₘ 0 = 0 :=\n letI := Classical.decEq R\n if h : Monic (0 : R[X]) then by\n haveI := monic_zero_iff_subsingleton.mp h\n simp [eq_iff_true_of_subsingleton]\n else by unfold divByMonic divModByMonicAux; rw [dif_neg h]\n\ntheorem divByMonic_eq_of_not_monic (p : R[X]) (hq : ¬Monic q) : p /ₘ q = 0 :=\n dif_neg hq\n\ntheorem modByMonic_eq_of_not_monic (p : R[X]) (hq : ¬Monic q) : p %ₘ q = p :=\n dif_neg hq\n\ntheorem modByMonic_eq_self_iff [Nontrivial R] (hq : Monic q) : p %ₘ q = p ↔ degree p < degree q :=\n ⟨fun h => h ▸ degree_modByMonic_lt _ hq, fun h => by\n classical\n have : ¬degree q ≤ degree p := not_le_of_gt h\n unfold modByMonic divModByMonicAux; dsimp; rw [dif_pos hq, if_neg (mt And.left this)]⟩\n\ntheorem degree_modByMonic_le (p : R[X]) {q : R[X]} (hq : Monic q) : degree (p %ₘ q) ≤ degree q := by sorry\ntheorem degree_modByMonic_le_left : degree (p %ₘ q) ≤ degree p := by sorry\ntheorem natDegree_modByMonic_le (p : Polynomial R) {g : Polynomial R} (hg : g.Monic) :\n natDegree (p %ₘ g) ≤ g.natDegree :=\n natDegree_le_natDegree (degree_modByMonic_le p hg)\n\ntheorem natDegree_modByMonic_le_left : natDegree (p %ₘ q) ≤ natDegree p :=\n natDegree_le_natDegree degree_modByMonic_le_left\n\ntheorem X_dvd_sub_C : X ∣ p - C (p.coeff 0) := by sorry\ntheorem modByMonic_eq_sub_mul_div :\n ∀ p q : R[X], p %ₘ q = p - q * (p /ₘ q) := by sorry\ntheorem modByMonic_add_div (p q : R[X]) : p %ₘ q + q * (p /ₘ q) = p :=\n eq_sub_iff_add_eq.1 (modByMonic_eq_sub_mul_div p q)\n\ntheorem divByMonic_eq_zero_iff [Nontrivial R] (hq : Monic q) : p /ₘ q = 0 ↔ degree p < degree q :=\n ⟨fun h => by\n have := modByMonic_add_div p q\n rwa [h, mul_zero, add_zero, modByMonic_eq_self_iff hq] at this,\n fun h => by\n classical\n have : ¬degree q ≤ degree p := not_le_of_gt h\n unfold divByMonic divModByMonicAux; dsimp; rw [dif_pos hq, if_neg (mt And.left this)]⟩\n\ntheorem degree_add_divByMonic (hq : Monic q) (h : degree q ≤ degree p) :\n degree q + degree (p /ₘ q) = degree p := by sorry\ntheorem degree_divByMonic_le (p q : R[X]) : degree (p /ₘ q) ≤ degree p :=\n letI := Classical.decEq R\n if hp0 : p = 0 then by simp only [hp0, zero_divByMonic, le_refl]\n else\n if hq : Monic q then\n if h : degree q ≤ degree p then by\n haveI := Nontrivial.of_polynomial_ne hp0\n rw [← degree_add_divByMonic hq h, degree_eq_natDegree hq.ne_zero,\n degree_eq_natDegree (mt (divByMonic_eq_zero_iff hq).1 (not_lt.2 h))]\n exact WithBot.coe_le_coe.2 (Nat.le_add_left _ _)\n else by\n unfold divByMonic divModByMonicAux\n simp [dif_pos hq, h, degree_zero, bot_le]\n else (divByMonic_eq_of_not_monic p hq).symm ▸ bot_le\n\ntheorem degree_divByMonic_lt (p q : R[X]) (hp0 : p ≠ 0)\n (h0q : 0 < degree q) : degree (p /ₘ q) < degree p :=\n letI := Classical.decEq R\n if hq : q.Monic then\n if hpq : degree p < degree q then by\n haveI := Nontrivial.of_polynomial_ne hp0\n rw [(divByMonic_eq_zero_iff hq).2 hpq, degree_eq_natDegree hp0]\n exact WithBot.bot_lt_coe _\n else by\n haveI := Nontrivial.of_polynomial_ne hp0\n rw [← degree_add_divByMonic hq (not_lt.1 hpq), degree_eq_natDegree hq.ne_zero,\n degree_eq_natDegree (mt (divByMonic_eq_zero_iff hq).1 hpq)]\n exact\n Nat.cast_lt.2\n (Nat.lt_add_of_pos_left (Nat.cast_lt.1 <|\n by simpa [degree_eq_natDegree hq.ne_zero] using h0q))\n else by\n rwa [divByMonic_eq_of_not_monic _ hq, degree_zero, bot_lt_iff_ne_bot, degree_ne_bot]\n\ntheorem natDegree_divByMonic (f : R[X]) {g : R[X]} (hg : g.Monic) :\n natDegree (f /ₘ g) = natDegree f - natDegree g := by sorry\ntheorem div_modByMonic_unique {f g} (q r : R[X]) (hg : Monic g)\n (h : r + g * q = f ∧ degree r < degree g) : f /ₘ g = q ∧ f %ₘ g = r := by sorry\ntheorem map_mod_divByMonic [Ring S] (f : R →+* S) (hq : Monic q) :\n (p /ₘ q).map f = p.map f /ₘ q.map f ∧ (p %ₘ q).map f = p.map f %ₘ q.map f := by sorry\ntheorem map_divByMonic [Ring S] (f : R →+* S) (hq : Monic q) :\n (p /ₘ q).map f = p.map f /ₘ q.map f :=\n (map_mod_divByMonic f hq).1\n\ntheorem map_modByMonic [Ring S] (f : R →+* S) (hq : Monic q) :\n (p %ₘ q).map f = p.map f %ₘ q.map f :=\n (map_mod_divByMonic f hq).2\n\ntheorem modByMonic_eq_zero_iff_dvd (hq : Monic q) : p %ₘ q = 0 ↔ q ∣ p :=\n ⟨fun h => by rw [← modByMonic_add_div p q, h, zero_add]; exact dvd_mul_right _ _, fun h => by\n nontriviality R\n obtain ⟨r, hr⟩ := exists_eq_mul_right_of_dvd h\n by_contra hpq0\n have hmod : p %ₘ q = q * (r - p /ₘ q) := by rw [modByMonic_eq_sub_mul_div, mul_sub, ← hr]\n have : degree (q * (r - p /ₘ q)) < degree q := hmod ▸ degree_modByMonic_lt _ hq\n have hrpq0 : leadingCoeff (r - p /ₘ q) ≠ 0 := fun h =>\n hpq0 <|\n leadingCoeff_eq_zero.1\n (by rw [hmod, leadingCoeff_eq_zero.1 h, mul_zero, leadingCoeff_zero])\n have hlc : leadingCoeff q * leadingCoeff (r - p /ₘ q) ≠ 0 := by rwa [Monic.def.1 hq, one_mul]\n rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero,\n degree_eq_natDegree (mt leadingCoeff_eq_zero.2 hrpq0)] at this\n exact not_lt_of_ge (Nat.le_add_right _ _) (WithBot.coe_lt_coe.1 this)⟩\n\n\n/-- See `Polynomial.mul_self_modByMonic` for the other multiplication order. That version, unlike\nthis one, requires commutativity. -/\n@[simp]\nlemma self_mul_modByMonic (hq : q.Monic) : (q * p) %ₘ q = 0 := by sorry\ntheorem map_dvd_map [Ring S] (f : R →+* S) (hf : Function.Injective f) {x y : R[X]}\n (hx : x.Monic) : x.map f ∣ y.map f ↔ x ∣ y := by sorry\ntheorem modByMonic_one (p : R[X]) : p %ₘ 1 = 0 :=\n (modByMonic_eq_zero_iff_dvd (by convert monic_one (R := R))).2 (one_dvd _)\n\n@[simp]\ntheorem divByMonic_one (p : R[X]) : p /ₘ 1 = p := by sorry\ntheorem sum_modByMonic_coeff (hq : q.Monic) {n : ℕ} (hn : q.degree ≤ n) :\n (∑ i : Fin n, monomial i ((p %ₘ q).coeff i)) = p %ₘ q := by sorry\ntheorem mul_divByMonic_cancel_left (p : R[X]) {q : R[X]} (hmo : q.Monic) :\n q * p /ₘ q = p := by sorry\nlemma coeff_divByMonic_X_sub_C_rec (p : R[X]) (a : R) (n : ℕ) :\n (p /ₘ (X - C a)).coeff n = coeff p (n + 1) + a * (p /ₘ (X - C a)).coeff (n + 1) := by sorry\ntheorem coeff_divByMonic_X_sub_C (p : R[X]) (a : R) (n : ℕ) :\n (p /ₘ (X - C a)).coeff n = ∑ i ∈ Icc (n + 1) p.natDegree, a ^ (i - (n + 1)) * p.coeff i := by sorry\nvariable (R) in\ntheorem not_isField : ¬IsField R[X] := by sorry\nsection multiplicity\n\n/-- An algorithm for deciding polynomial divisibility.\nPrefer `Classical.dec`, as the algorithm relies on `%ₘ` and so is `noncomputable`.\n-/\n@[deprecated Classical.dec (since := \"2026-02-07\")]\ndef decidableDvdMonic [DecidableEq R] (p : R[X]) (hq : Monic q) : Decidable (q ∣ p) :=\n decidable_of_iff (p %ₘ q = 0) (modByMonic_eq_zero_iff_dvd hq)\n\ntheorem finiteMultiplicity_X_sub_C (a : R) (h0 : p ≠ 0) : FiniteMultiplicity (X - C a) p := by sorry\ndef rootMultiplicity (a : R) (p : R[X]) : ℕ :=\n letI := Classical.decEq R\n if h0 : p = 0 then 0\n else\n let _ : DecidablePred fun n : ℕ => ¬(X - C a) ^ (n + 1) ∣ p := Classical.decPred _\n Nat.find (finiteMultiplicity_X_sub_C a h0)\n\ntheorem rootMultiplicity_eq_natFind_of_ne_zero {p : R[X]} (p0 : p ≠ 0) {a : R}\n [DecidablePred fun n : ℕ => ¬(X - C a) ^ (n + 1) ∣ p] :\n rootMultiplicity a p = Nat.find (finiteMultiplicity_X_sub_C a p0) := by sorry\ntheorem rootMultiplicity_eq_multiplicity [DecidableEq R]\n (p : R[X]) (a : R) :\n rootMultiplicity a p =\n if p = 0 then 0 else multiplicity (X - C a) p := by sorry\ntheorem rootMultiplicity_zero {x : R} : rootMultiplicity x 0 = 0 :=\n dif_pos rfl\n\n@[simp]\ntheorem rootMultiplicity_C (r a : R) : rootMultiplicity a (C r) = 0 := by sorry\ntheorem pow_rootMultiplicity_dvd (p : R[X]) (a : R) : (X - C a) ^ rootMultiplicity a p ∣ p :=\n letI := Classical.decEq R\n if h : p = 0 then by simp [h]\n else by\n classical\n rw [rootMultiplicity_eq_multiplicity, if_neg h]; apply pow_multiplicity_dvd\n\ntheorem pow_mul_divByMonic_rootMultiplicity_eq (p : R[X]) (a : R) :\n (X - C a) ^ rootMultiplicity a p * (p /ₘ (X - C a) ^ rootMultiplicity a p) = p := by sorry\ntheorem exists_eq_pow_rootMultiplicity_mul_and_not_dvd (p : R[X]) (hp : p ≠ 0) (a : R) :\n ∃ q : R[X], p = (X - C a) ^ p.rootMultiplicity a * q ∧ ¬ (X - C a) ∣ q := by sorry\nend multiplicity\n\nend Ring\n\nsection CommRing\n\nvariable [CommRing R] {p p₁ p₂ q : R[X]}\n\n@[simp]\ntheorem modByMonic_X_sub_C_eq_C_eval (p : R[X]) (a : R) : p %ₘ (X - C a) = C (p.eval a) := by sorry\ntheorem mul_divByMonic_eq_iff_isRoot : (X - C a) * (p /ₘ (X - C a)) = p ↔ IsRoot p a :=\n .trans\n ⟨fun h => by rw [← h, eval_mul, eval_sub, eval_X, eval_C, sub_self, zero_mul],\n fun h => by\n conv_rhs => rw [← modByMonic_add_div p, modByMonic_X_sub_C_eq_C_eval, h, C_0, zero_add]⟩\n IsRoot.def.symm\n\ntheorem dvd_iff_isRoot : X - C a ∣ p ↔ IsRoot p a :=\n ⟨fun h => by\n rwa [← modByMonic_eq_zero_iff_dvd (monic_X_sub_C _), modByMonic_X_sub_C_eq_C_eval, ← C_0,\n C_inj] at h,\n fun h => ⟨p /ₘ (X - C a), by rw [mul_divByMonic_eq_iff_isRoot.2 h]⟩⟩\n\ntheorem X_sub_C_dvd_sub_C_eval : X - C a ∣ p - C (p.eval a) := by sorry\ntheorem modByMonic_X (p : R[X]) : p %ₘ X = C (p.eval 0) := by sorry\ntheorem eval₂_modByMonic_eq_self_of_root [CommRing S] {f : R →+* S} {p q : R[X]}\n {x : S} (hx : q.eval₂ f x = 0) : (p %ₘ q).eval₂ f x = p.eval₂ f x := by sorry\ntheorem sub_dvd_eval_sub (a b : R) (p : R[X]) : a - b ∣ p.eval a - p.eval b := by sorry\nlemma IsRoot.dvd_coeff_zero {p : R[X]} {x : R} (h : p.IsRoot x) : x ∣ p.coeff 0 := by sorry\ntheorem rootMultiplicity_eq_zero_iff {p : R[X]} {x : R} :\n rootMultiplicity x p = 0 ↔ IsRoot p x → p = 0 := by sorry\ntheorem rootMultiplicity_eq_zero {p : R[X]} {x : R} (h : ¬IsRoot p x) : rootMultiplicity x p = 0 :=\n rootMultiplicity_eq_zero_iff.2 fun h' => (h h').elim\n\n@[simp]\ntheorem rootMultiplicity_pos' {p : R[X]} {x : R} :\n 0 < rootMultiplicity x p ↔ p ≠ 0 ∧ IsRoot p x := by sorry\ntheorem rootMultiplicity_pos {p : R[X]} (hp : p ≠ 0) {x : R} :\n 0 < rootMultiplicity x p ↔ IsRoot p x :=\n rootMultiplicity_pos'.trans (and_iff_right hp)\n\ntheorem eval_divByMonic_pow_rootMultiplicity_ne_zero {p : R[X]} (a : R) (hp : p ≠ 0) :\n eval a (p /ₘ (X - C a) ^ rootMultiplicity a p) ≠ 0 := by sorry\nlemma mul_self_modByMonic (hq : q.Monic) : (p * q) %ₘ q = 0 := by sorry\nlemma modByMonic_eq_of_dvd_sub (hq : q.Monic) (h : q ∣ p₁ - p₂) : p₁ %ₘ q = p₂ %ₘ q := by sorry\nlemma add_modByMonic (p₁ p₂ : R[X]) : (p₁ + p₂) %ₘ q = p₁ %ₘ q + p₂ %ₘ q := by sorry\nlemma neg_modByMonic (p q : R[X]) : (-p) %ₘ q = -(p %ₘ q) := by sorry\nlemma sub_modByMonic (p₁ p₂ q : R[X]) : (p₁ - p₂) %ₘ q = p₁ %ₘ q - p₂ %ₘ q := by sorry\nlemma mul_modByMonic (p₁ p₂ q : R[X]) : (p₁ * p₂) %ₘ q = (p₁ %ₘ q) * (p₂ %ₘ q) %ₘ q := by sorry\nlemma eval_divByMonic_eq_trailingCoeff_comp {p : R[X]} {t : R} :\n (p /ₘ (X - C t) ^ p.rootMultiplicity t).eval t = (p.comp (X + C t)).trailingCoeff := by sorry\nlemma le_rootMultiplicity_iff (p0 : p ≠ 0) {a : R} {n : ℕ} :\n n ≤ rootMultiplicity a p ↔ (X - C a) ^ n ∣ p := by sorry\nlemma rootMultiplicity_le_iff (p0 : p ≠ 0) (a : R) (n : ℕ) :\n rootMultiplicity a p ≤ n ↔ ¬(X - C a) ^ (n + 1) ∣ p := by sorry\nlemma rootMultiplicity_add {p q : R[X]} (a : R) (hzero : p + q ≠ 0) :\n min (rootMultiplicity a p) (rootMultiplicity a q) ≤ rootMultiplicity a (p + q) := by sorry\nlemma le_rootMultiplicity_mul {p q : R[X]} (x : R) (hpq : p * q ≠ 0) :\n rootMultiplicity x p + rootMultiplicity x q ≤ rootMultiplicity x (p * q) := by sorry\nlemma rootMultiplicity_le_rootMultiplicity_of_dvd {p q : R[X]} (hq : q ≠ 0) (hpq : p ∣ q) (x : R) :\n p.rootMultiplicity x ≤ q.rootMultiplicity x := by sorry\nlemma pow_rootMultiplicity_not_dvd (p0 : p ≠ 0) (a : R) :\n ¬(X - C a) ^ (rootMultiplicity a p + 1) ∣ p := by rw [← rootMultiplicity_le_iff p0]\n\n/-- See `Polynomial.rootMultiplicity_eq_natTrailingDegree` for the general case. -/\nlemma rootMultiplicity_eq_natTrailingDegree' : p.rootMultiplicity 0 = p.natTrailingDegree := by sorry\nlemma leadingCoeff_divByMonic_of_monic (hmonic : q.Monic)\n (hdegree : q.degree ≤ p.degree) : (p /ₘ q).leadingCoeff = p.leadingCoeff := by sorry\nvariable [IsDomain R]\n\nlemma degree_eq_one_of_irreducible_of_root (hi : Irreducible p) {x : R} (hx : IsRoot p x) :\n degree p = 1 :=\n let ⟨g, hg⟩ := dvd_iff_isRoot.2 hx\n have : IsUnit (X - C x) ∨ IsUnit g := hi.isUnit_or_isUnit hg\n this.elim\n (fun h => by\n have h₁ : degree (X - C x) = 1 := degree_X_sub_C x\n have h₂ : degree (X - C x) = 0 := degree_eq_zero_of_isUnit h\n rw [h₁] at h₂; exact absurd h₂ (by decide))\n fun hgu => by rw [hg, degree_mul, degree_X_sub_C, degree_eq_zero_of_isUnit hgu, add_zero]\n\nlemma _root_.Irreducible.not_isRoot_of_natDegree_ne_one\n (hi : Irreducible p) (hdeg : p.natDegree ≠ 1) {x : R} : ¬p.IsRoot x :=\n fun hr ↦ hdeg <| natDegree_eq_of_degree_eq_some <| degree_eq_one_of_irreducible_of_root hi hr\n\nlemma _root_.Irreducible.isRoot_eq_bot_of_natDegree_ne_one\n (hi : Irreducible p) (hdeg : p.natDegree ≠ 1) : p.IsRoot = ⊥ :=\n le_bot_iff.mp fun _ ↦ hi.not_isRoot_of_natDegree_ne_one hdeg\n\nlemma _root_.Irreducible.subsingleton_isRoot [IsLeftCancelMulZero R]\n (hi : Irreducible p) : { x | p.IsRoot x }.Subsingleton :=\n fun _ hx ↦ (subsingleton_isRoot_of_natDegree_eq_one <| natDegree_eq_of_degree_eq_some <|\n degree_eq_one_of_irreducible_of_root hi hx) hx\n\nlemma leadingCoeff_divByMonic_X_sub_C (p : R[X]) (hp : degree p ≠ 0) (a : R) :\n leadingCoeff (p /ₘ (X - C a)) = leadingCoeff p := by sorry\nlemma eq_of_dvd_of_natDegree_le_of_leadingCoeff {p q : R[X]} (hpq : p ∣ q)\n (h₁ : q.natDegree ≤ p.natDegree) (h₂ : p.leadingCoeff = q.leadingCoeff) :\n p = q := by sorry\nlemma associated_of_dvd_of_natDegree_le_of_leadingCoeff {p q : R[X]} (hpq : p ∣ q)\n (h₁ : q.natDegree ≤ p.natDegree) (h₂ : q.leadingCoeff ∣ p.leadingCoeff) :\n Associated p q :=\n have ⟨r, hr⟩ := hpq\n have ⟨u, hu⟩ := associated_of_dvd_dvd ⟨leadingCoeff r, hr ▸ leadingCoeff_mul p r⟩ h₂\n ⟨Units.map C.toMonoidHom u, eq_of_dvd_of_natDegree_le_of_leadingCoeff\n (by rwa [Units.mul_right_dvd]) (by simpa [natDegree_mul_C] using h₁) (by simpa using hu)⟩\n\nlemma associated_of_dvd_of_natDegree_le {K} [Field K] {p q : K[X]} (hpq : p ∣ q) (hq : q ≠ 0)\n (h₁ : q.natDegree ≤ p.natDegree) : Associated p q :=\n associated_of_dvd_of_natDegree_le_of_leadingCoeff hpq h₁\n (IsUnit.dvd (by rwa [← leadingCoeff_ne_zero, ← isUnit_iff_ne_zero] at hq))\n\nlemma associated_of_dvd_of_degree_eq {K} [Field K] {p q : K[X]} (hpq : p ∣ q)\n (h₁ : p.degree = q.degree) : Associated p q :=\n (Classical.em (q = 0)).elim (fun hq ↦ (show p = q by simpa [hq] using h₁) ▸ Associated.refl p)\n (associated_of_dvd_of_natDegree_le hpq · (natDegree_le_natDegree h₁.ge))\n\nlemma eq_leadingCoeff_mul_of_monic_of_dvd_of_natDegree_le {R} [CommSemiring R] {p q : R[X]}\n (hp : p.Monic) (hdvd : p ∣ q) (hdeg : q.natDegree ≤ p.natDegree) :\n q = C q.leadingCoeff * p := by sorry\nend CommRing\n\nend Polynomial\n" }, { "theorem_id": 66, "title": "089_the_factor_and_remainder_theorems", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice.\nFrom mathcomp Require Import fintype bigop nmodule algebra divalg decfield poly.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nImport GRing.Theory.\nLocal Open Scope ring_scope.\n\nReserved Notation \"p %= q\" (at level 70, no associativity).\n\nLocal Notation simp := Monoid.simpm.\n\nModule Pdiv.\n\nModule CommonRing.\n\nSection RingPseudoDivision.\n\nVariable R : nzRingType.\nImplicit Types d p q r : {poly R}.\n\nDefinition redivp_rec (q : {poly R}) :=\n let sq := size q in\n let cq := lead_coef q in\n fix loop (k : nat) (qq r : {poly R})(n : nat) {struct n} :=\n if size r < sq then (k, qq, r) else\n let m := (lead_coef r) *: 'X^(size r - sq) in\n let qq1 := qq * cq%:P + m in\n let r1 := r * cq%:P - m * q in\n if n is n1.+1 then loop k.+1 qq1 r1 n1 else (k.+1, qq1, r1).\n\nDefinition redivp_expanded_def p q :=\n if q == 0 then (0, 0, p) else redivp_rec q 0 0 p (size p).\nFact redivp_key : unit.\nProof.\nAdmitted.\nDefinition redivp : {poly R} -> {poly R} -> nat * {poly R} * {poly R} :=\n locked_with redivp_key redivp_expanded_def.\nCanonical redivp_unlockable := [unlockable fun redivp].\n\nDefinition rdivp p q := ((redivp p q).1).2.\nDefinition rmodp p q := (redivp p q).2.\nDefinition rscalp p q := ((redivp p q).1).1.\nDefinition rdvdp p q := rmodp q p == 0.\n\nLemma redivp_def p q : redivp p q = (rscalp p q, rdivp p q, rmodp p q).\nProof.\nAdmitted.\n\nLemma rdiv0p p : rdivp 0 p = 0.\nProof.\nAdmitted.\n\nLemma rdivp0 p : rdivp p 0 = 0.\nProof.\nAdmitted.\n\nLemma rdivp_small p q : size p < size q -> rdivp p q = 0.\nProof.\nAdmitted.\n\nLemma leq_rdivp p q : size (rdivp p q) <= size p.\nProof.\nAdmitted.\n\nLemma rmod0p p : rmodp 0 p = 0.\nProof.\nAdmitted.\n\nLemma rmodp0 p : rmodp p 0 = p.\nProof.\nAdmitted.\n\nLemma rscalp_small p q : size p < size q -> rscalp p q = 0.\nProof.\nAdmitted.\n\nLemma ltn_rmodp p q : (size (rmodp p q) < size q) = (q != 0).\nProof.\nAdmitted.\n\nLemma ltn_rmodpN0 p q : q != 0 -> size (rmodp p q) < size q.\nProof.\nAdmitted.\n\nLemma rmodp1 p : rmodp p 1 = 0.\nProof.\nAdmitted.\n\nLemma rmodp_small p q : size p < size q -> rmodp p q = p.\nProof.\nAdmitted.\n\nLemma leq_rmodp m d : size (rmodp m d) <= size m.\nProof.\nAdmitted.\n\nLemma rmodpC p c : c != 0 -> rmodp p c%:P = 0.\nProof.\nAdmitted.\n\nLemma rdvdp0 d : rdvdp d 0.\nProof.\nAdmitted.\n\nLemma rdvd0p n : rdvdp 0 n = (n == 0).\nProof.\nAdmitted.\n\nLemma rdvd0pP n : reflect (n = 0) (rdvdp 0 n).\nProof.\nAdmitted.\n\nLemma rdvdpN0 p q : rdvdp p q -> q != 0 -> p != 0.\nProof.\nAdmitted.\n\nLemma rdvdp1 d : rdvdp d 1 = (size d == 1).\nProof.\nAdmitted.\n\nLemma rdvd1p m : rdvdp 1 m.\nProof.\nAdmitted.\n\nLemma Nrdvdp_small (n d : {poly R}) :\n n != 0 -> size n < size d -> rdvdp d n = false.\nProof.\nAdmitted.\n\nLemma rmodp_eq0P p q : reflect (rmodp p q = 0) (rdvdp q p).\nProof.\nAdmitted.\n\nLemma rmodp_eq0 p q : rdvdp q p -> rmodp p q = 0.\nProof.\nAdmitted.\n\nLemma rdvdp_leq p q : rdvdp p q -> q != 0 -> size p <= size q.\nProof.\nAdmitted.\n\nDefinition rgcdp p q :=\n let: (p1, q1) := if size p < size q then (q, p) else (p, q) in\n if p1 == 0 then q1 else\n let fix loop (n : nat) (pp qq : {poly R}) {struct n} :=\n let rr := rmodp pp qq in\n if rr == 0 then qq else\n if n is n1.+1 then loop n1 qq rr else rr in\n loop (size p1) p1 q1.\n\nLemma rgcd0p : left_id 0 rgcdp.\nProof.\nAdmitted.\n\nLemma rgcdp0 : right_id 0 rgcdp.\nProof.\nAdmitted.\n\nLemma rgcdpE p q :\n rgcdp p q = if size p < size q\n then rgcdp (rmodp q p) p else rgcdp (rmodp p q) q.\nProof.\nAdmitted.\n\nVariant comm_redivp_spec m d : nat * {poly R} * {poly R} -> Type :=\n ComEdivnSpec k (q r : {poly R}) of\n (GRing.comm d (lead_coef d)%:P -> m * (lead_coef d ^+ k)%:P = q * d + r) &\n (d != 0 -> size r < size d) : comm_redivp_spec m d (k, q, r).\n\nLemma comm_redivpP m d : comm_redivp_spec m d (redivp m d).\nProof.\nAdmitted.\n\nLemma rmodpp p : GRing.\nProof.\nAdmitted.\n\nDefinition rcoprimep (p q : {poly R}) := size (rgcdp p q) == 1.\n\nFixpoint rgdcop_rec q p n :=\n if n is m.+1 then\n if rcoprimep p q then p\n else rgdcop_rec q (rdivp p (rgcdp p q)) m\n else (q == 0)%:R.\n\nDefinition rgdcop q p := rgdcop_rec q p (size p).\n\nLemma rgdcop0 q : rgdcop q 0 = (q == 0)%:R.\nProof.\nAdmitted.\n\nEnd RingPseudoDivision.\n\nEnd CommonRing.\n\nModule RingComRreg.\n\nImport CommonRing.\n\nSection ComRegDivisor.\n\nVariable R : nzRingType.\nVariable d : {poly R}.\nHypothesis Cdl : GRing.comm d (lead_coef d)%:P.\nHypothesis Rreg : GRing.rreg (lead_coef d).\n\nImplicit Types p q r : {poly R}.\n\nLemma redivp_eq q r :\n size r < size d ->\n let k := (redivp (q * d + r) d).\nProof.\nAdmitted.\n\nLemma rdivp_eq p :\n p * (lead_coef d ^+ (rscalp p d))%:P = (rdivp p d) * d + (rmodp p d).\nProof.\nAdmitted.\n\nLemma eq_rdvdp k q1 p:\n p * ((lead_coef d)^+ k)%:P = q1 * d -> rdvdp d p.\nProof.\nAdmitted.\n\nVariant rdvdp_spec p q : {poly R} -> bool -> Type :=\n | Rdvdp k q1 & p * ((lead_coef q)^+ k)%:P = q1 * q : rdvdp_spec p q 0 true\n | RdvdpN & rmodp p q != 0 : rdvdp_spec p q (rmodp p q) false.\n\nLemma rdvdp_eqP p : rdvdp_spec p d (rmodp p d) (rdvdp d p).\nProof.\nAdmitted.\n\nLemma rdvdp_mull p : rdvdp d (p * d).\nProof.\nAdmitted.\n\nLemma rmodp_mull p : rmodp (p * d) d = 0.\nProof.\nAdmitted.\n\nLemma rmodpp : rmodp d d = 0.\nProof.\nAdmitted.\n\nLemma rdivpp : rdivp d d = (lead_coef d ^+ rscalp d d)%:P.\nProof.\nAdmitted.\n\nLemma rdvdpp : rdvdp d d.\nProof.\nAdmitted.\n\nLemma rdivpK p : rdvdp d p ->\n rdivp p d * d = p * (lead_coef d ^+ rscalp p d)%:P.\nProof.\nAdmitted.\n\nEnd ComRegDivisor.\n\nEnd RingComRreg.\n\nModule RingMonic.\n\nImport CommonRing.\n\nImport RingComRreg.\n\nSection RingMonic.\n\nVariable R : nzRingType.\nImplicit Types p q r : {poly R}.\n\nSection MonicDivisor.\n\nVariable d : {poly R}.\nHypothesis mond : d \\is monic.\n\nLemma redivp_eq q r : size r < size d ->\n let k := (redivp (q * d + r) d).\nProof.\nAdmitted.\n\nLemma rdivp_eq p : p = rdivp p d * d + rmodp p d.\nProof.\nAdmitted.\n\nLemma rdivpp : rdivp d d = 1.\nProof.\nAdmitted.\n\nLemma rdivp_addl_mul_small q r : size r < size d -> rdivp (q * d + r) d = q.\nProof.\nAdmitted.\n\nLemma rdivp_addl_mul q r : rdivp (q * d + r) d = q + rdivp r d.\nProof.\nAdmitted.\n\nLemma rdivpDl q r : rdvdp d q -> rdivp (q + r) d = rdivp q d + rdivp r d.\nProof.\nAdmitted.\n\nLemma rdivpDr q r : rdvdp d r -> rdivp (q + r) d = rdivp q d + rdivp r d.\nProof.\nAdmitted.\n\nLemma rdivp_mull p : rdivp (p * d) d = p.\nProof.\nAdmitted.\n\nLemma rmodp_mull p : rmodp (p * d) d = 0.\nProof.\nAdmitted.\n\nLemma rmodpp : rmodp d d = 0.\nProof.\nAdmitted.\n\nLemma rmodp_addl_mul_small q r : size r < size d -> rmodp (q * d + r) d = r.\nProof.\nAdmitted.\n\nLemma rmodp_id (p : {poly R}) : rmodp (rmodp p d) d = rmodp p d.\nProof.\nAdmitted.\n\nLemma rmodpD p q : rmodp (p + q) d = rmodp p d + rmodp q d.\nProof.\nAdmitted.\n\nLemma rmodpN p : rmodp (- p) d = - (rmodp p d).\nProof.\nAdmitted.\n\nLemma rmodpB p q : rmodp (p - q) d = rmodp p d - rmodp q d.\nProof.\nAdmitted.\n\nLemma rmodpZ a p : rmodp (a *: p) d = a *: (rmodp p d).\nProof.\nAdmitted.\n\nLemma rmodp_sum (I : Type) (r : seq I) (P : pred I) (F : I -> {poly R}) :\n rmodp (\\sum_(i <- r | P i) F i) d = (\\sum_(i <- r | P i) (rmodp (F i) d)).\nProof.\nAdmitted.\n\nLemma rmodp_mulmr p q : rmodp (p * (rmodp q d)) d = rmodp (p * q) d.\nProof.\nAdmitted.\n\nLemma rdvdpp : rdvdp d d.\nProof.\nAdmitted.\n\nLemma eq_rdvdp q1 p : p = q1 * d -> rdvdp d p.\nProof.\nAdmitted.\n\nLemma rdvdp_mull p : rdvdp d (p * d).\nProof.\nAdmitted.\n\nLemma rdvdpP p : reflect (exists qq, p = qq * d) (rdvdp d p).\nProof.\nAdmitted.\n\nLemma rdivpK p : rdvdp d p -> (rdivp p d) * d = p.\nProof.\nAdmitted.\n\nEnd MonicDivisor.\n\nLemma drop_poly_rdivp n p : drop_poly n p = rdivp p 'X^n.\nProof.\nAdmitted.\n\nLemma take_poly_rmodp n p : take_poly n p = rmodp p 'X^n.\nProof.\nAdmitted.\n\nEnd RingMonic.\n\nSection ComRingMonic.\n\nVariable R : comNzRingType.\nImplicit Types p q r : {poly R}.\nVariable d : {poly R}.\nHypothesis mond : d \\is monic.\n\nLemma rmodp_mulml p q : rmodp (rmodp p d * q) d = rmodp (p * q) d.\nProof.\nAdmitted.\n\nLemma rmodpX p n : rmodp ((rmodp p d) ^+ n) d = rmodp (p ^+ n) d.\nProof.\nAdmitted.\n\nLemma rmodp_compr p q : rmodp (p \\Po (rmodp q d)) d = (rmodp (p \\Po q) d).\nProof.\nAdmitted.\n\nEnd ComRingMonic.\n\nEnd RingMonic.\n\nModule Ring.\n\nInclude CommonRing.\nImport RingMonic.\n\nSection ExtraMonicDivisor.\n\nVariable R : nzRingType.\n\nImplicit Types d p q r : {poly R}.\n\nLemma rdivp1 p : rdivp p 1 = p.\nProof.\nAdmitted.\n\nLemma rdvdp_XsubCl p x : rdvdp ('X - x%:P) p = root p x.\nProof.\nAdmitted.\n\nLemma polyXsubCP p x : reflect (p.\nProof.\nAdmitted.\n\nLemma root_factor_theorem p x : root p x = (rdvdp ('X - x%:P) p).\nProof.\nAdmitted.\n\nEnd ExtraMonicDivisor.\n\nEnd Ring.\n\nModule ComRing.\n\nImport Ring.\n\nImport RingComRreg.\n\nSection CommutativeRingPseudoDivision.\n\nVariable R : comNzRingType.\n\nImplicit Types d p q m n r : {poly R}.\n\nVariant redivp_spec (m d : {poly R}) : nat * {poly R} * {poly R} -> Type :=\n EdivnSpec k (q r: {poly R}) of\n (lead_coef d ^+ k) *: m = q * d + r &\n (d != 0 -> size r < size d) : redivp_spec m d (k, q, r).\n\nLemma redivpP m d : redivp_spec m d (redivp m d).\nProof.\nAdmitted.\n\nLemma rdivp_eq d p :\n (lead_coef d ^+ rscalp p d) *: p = rdivp p d * d + rmodp p d.\nProof.\nAdmitted.\n\nLemma rdvdp_eqP d p : rdvdp_spec p d (rmodp p d) (rdvdp d p).\nProof.\nAdmitted.\n\nLemma rdvdp_eq q p :\n rdvdp q p = (lead_coef q ^+ rscalp p q *: p == rdivp p q * q).\nProof.\nAdmitted.\n\nEnd CommutativeRingPseudoDivision.\n\nEnd ComRing.\n\nModule UnitRing.\n\nImport Ring.\n\nSection UnitRingPseudoDivision.\n\nVariable R : unitRingType.\nImplicit Type p q r d : {poly R}.\n\nLemma uniq_roots_rdvdp p rs :\n all (root p) rs -> uniq_roots rs -> rdvdp (\\prod_(z <- rs) ('X - z%:P)) p.\nProof.\nAdmitted.\n\nEnd UnitRingPseudoDivision.\n\nEnd UnitRing.\n\nModule IdomainDefs.\n\nImport Ring.\n\nSection IDomainPseudoDivisionDefs.\n\nVariable R : idomainType.\nImplicit Type p q r d : {poly R}.\n\nDefinition edivp_expanded_def p q :=\n let: (k, d, r) as edvpq := redivp p q in\n if lead_coef q \\in GRing.unit then\n (0, (lead_coef q)^-k *: d, (lead_coef q)^-k *: r)\n else edvpq.\nFact edivp_key : unit.\nProof.\nAdmitted.\nDefinition edivp := locked_with edivp_key edivp_expanded_def.\nCanonical edivp_unlockable := [unlockable fun edivp].\n\nDefinition divp p q := ((edivp p q).1).2.\nDefinition modp p q := (edivp p q).2.\nDefinition scalp p q := ((edivp p q).1).1.\nDefinition dvdp p q := modp q p == 0.\nDefinition eqp p q := (dvdp p q) && (dvdp q p).\n\nEnd IDomainPseudoDivisionDefs.\n\nNotation \"m %/ d\" := (divp m d) : ring_scope.\nNotation \"m %% d\" := (modp m d) : ring_scope.\nNotation \"p %| q\" := (dvdp p q) : ring_scope.\nNotation \"p %= q\" := (eqp p q) : ring_scope.\nEnd IdomainDefs.\n\nModule WeakIdomain.\n\nImport Ring ComRing UnitRing IdomainDefs.\n\nSection WeakTheoryForIDomainPseudoDivision.\n\nVariable R : idomainType.\nImplicit Type p q r d : {poly R}.\n\nLemma edivp_def p q : edivp p q = (scalp p q, divp p q, modp p q).\nProof.\nAdmitted.\n\nLemma edivp_redivp p q : (lead_coef q \\in GRing.\nProof.\nAdmitted.\n\nLemma divpE p q :\n p %/ q = if lead_coef q \\in GRing.\nProof.\nAdmitted.\n\nLemma modpE p q :\n p %% q = if lead_coef q \\in GRing.\nProof.\nAdmitted.\n\nLemma scalpE p q :\n scalp p q = if lead_coef q \\in GRing.\nProof.\nAdmitted.\n\nLemma dvdpE p q : (p %| q) = rdvdp p q.\nProof.\nAdmitted.\n\nLemma lc_expn_scalp_neq0 p q : lead_coef q ^+ scalp p q != 0.\nProof.\nAdmitted.\n\nHint Resolve lc_expn_scalp_neq0 : core.\n\nVariant edivp_spec (m d : {poly R}) :\n nat * {poly R} * {poly R} -> bool -> Type :=\n|Redivp_spec k (q r: {poly R}) of\n (lead_coef d ^+ k) *: m = q * d + r & lead_coef d \\notin GRing.unit &\n (d != 0 -> size r < size d) : edivp_spec m d (k, q, r) false\n|Fedivp_spec (q r: {poly R}) of m = q * d + r & (lead_coef d \\in GRing.unit) &\n (d != 0 -> size r < size d) : edivp_spec m d (0, q, r) true.\n\nLemma edivpP m d : edivp_spec m d (edivp m d) (lead_coef d \\in GRing.\nProof.\nAdmitted.\n\nLemma edivp_eq d q r : size r < size d -> lead_coef d \\in GRing.\nProof.\nAdmitted.\n\nLemma divp_eq p q : (lead_coef q ^+ scalp p q) *: p = (p %/ q) * q + (p %% q).\nProof.\nAdmitted.\n\nLemma dvdp_eq q p : (q %| p) = (lead_coef q ^+ scalp p q *: p == (p %/ q) * q).\nProof.\nAdmitted.\n\nLemma divpK d p : d %| p -> p %/ d * d = (lead_coef d ^+ scalp p d) *: p.\nProof.\nAdmitted.\n\nLemma divpKC d p : d %| p -> d * (p %/ d) = (lead_coef d ^+ scalp p d) *: p.\nProof.\nAdmitted.\n\nLemma dvdpP q p :\n reflect (exists2 cqq, cqq.\nProof.\nAdmitted.\n\nLemma mulpK p q : q != 0 -> p * q %/ q = lead_coef q ^+ scalp (p * q) q *: p.\nProof.\nAdmitted.\n\nLemma mulKp p q : q != 0 -> q * p %/ q = lead_coef q ^+ scalp (p * q) q *: p.\nProof.\nAdmitted.\n\nLemma divpp p : p != 0 -> p %/ p = (lead_coef p ^+ scalp p p)%:P.\nProof.\nAdmitted.\n\nEnd WeakTheoryForIDomainPseudoDivision.\n\n#[global] Hint Resolve lc_expn_scalp_neq0 : core.\n\nEnd WeakIdomain.\n\nModule CommonIdomain.\n\nImport Ring ComRing UnitRing IdomainDefs WeakIdomain.\n\nSection IDomainPseudoDivision.\n\nVariable R : idomainType.\nImplicit Type p q r d m n : {poly R}.\n\nLemma scalp0 p : scalp p 0 = 0.\nProof.\nAdmitted.\n\nLemma divp_small p q : size p < size q -> p %/ q = 0.\nProof.\nAdmitted.\n\nLemma leq_divp p q : (size (p %/ q) <= size p).\nProof.\nAdmitted.\n\nLemma div0p p : 0 %/ p = 0.\nProof.\nAdmitted.\n\nLemma divp0 p : p %/ 0 = 0.\nProof.\nAdmitted.\n\nLemma divp1 m : m %/ 1 = m.\nProof.\nAdmitted.\n\nLemma modp0 p : p %% 0 = p.\nProof.\nAdmitted.\n\nLemma mod0p p : 0 %% p = 0.\nProof.\nAdmitted.\n\nLemma modp1 p : p %% 1 = 0.\nProof.\nAdmitted.\n\nHint Resolve divp0 divp1 mod0p modp0 modp1 : core.\n\nLemma modp_small p q : size p < size q -> p %% q = p.\nProof.\nAdmitted.\n\nLemma modpC p c : c != 0 -> p %% c%:P = 0.\nProof.\nAdmitted.\n\nLemma modp_mull p q : (p * q) %% q = 0.\nProof.\nAdmitted.\n\nLemma modp_mulr d p : (d * p) %% d = 0.\nProof.\nAdmitted.\n\nLemma modpp d : d %% d = 0.\nProof.\nAdmitted.\n\nLemma ltn_modp p q : (size (p %% q) < size q) = (q != 0).\nProof.\nAdmitted.\n\nLemma ltn_divpl d q p : d != 0 ->\n (size (q %/ d) < size p) = (size q < size (p * d)).\nProof.\nAdmitted.\n\nLemma leq_divpr d p q : d != 0 ->\n (size p <= size (q %/ d)) = (size (p * d) <= size q).\nProof.\nAdmitted.\n\nLemma divpN0 d p : d != 0 -> (p %/ d != 0) = (size d <= size p).\nProof.\nAdmitted.\n\nLemma size_divp p q : q != 0 -> size (p %/ q) = (size p - (size q).\nProof.\nAdmitted.\n\nLemma ltn_modpN0 p q : q != 0 -> size (p %% q) < size q.\nProof.\nAdmitted.\n\nLemma modp_id p q : (p %% q) %% q = p %% q.\nProof.\nAdmitted.\n\nLemma leq_modp m d : size (m %% d) <= size m.\nProof.\nAdmitted.\n\nLemma dvdp0 d : d %| 0.\nProof.\nAdmitted.\n\nHint Resolve dvdp0 : core.\n\nLemma dvd0p p : (0 %| p) = (p == 0).\nProof.\nAdmitted.\n\nLemma dvd0pP p : reflect (p = 0) (0 %| p).\nProof.\nAdmitted.\n\nLemma dvdpN0 p q : p %| q -> q != 0 -> p != 0.\nProof.\nAdmitted.\n\nLemma dvdp1 d : (d %| 1) = (size d == 1).\nProof.\nAdmitted.\n\nLemma dvd1p m : 1 %| m.\nProof.\nAdmitted.\n\nLemma gtNdvdp p q : p != 0 -> size p < size q -> (q %| p) = false.\nProof.\nAdmitted.\n\nLemma modp_eq0P p q : reflect (p %% q = 0) (q %| p).\nProof.\nAdmitted.\n\nLemma modp_eq0 p q : (q %| p) -> p %% q = 0.\nProof.\nAdmitted.\n\nLemma leq_divpl d p q :\n d %| p -> (size (p %/ d) <= size q) = (size p <= size (q * d)).\nProof.\nAdmitted.\n\nLemma dvdp_leq p q : q != 0 -> p %| q -> size p <= size q.\nProof.\nAdmitted.\n\nLemma eq_dvdp c quo q p : c != 0 -> c *: p = quo * q -> q %| p.\nProof.\nAdmitted.\n\nLemma dvdpp d : d %| d.\nProof.\nAdmitted.\n\nHint Resolve dvdpp : core.\n\nLemma divp_dvd p q : p %| q -> (q %/ p) %| q.\nProof.\nAdmitted.\n\nLemma dvdp_mull m d n : d %| n -> d %| m * n.\nProof.\nAdmitted.\n\nLemma dvdp_mulr n d m : d %| m -> d %| m * n.\nProof.\nAdmitted.\n\nHint Resolve dvdp_mull dvdp_mulr : core.\n\nLemma dvdp_mul d1 d2 m1 m2 : d1 %| m1 -> d2 %| m2 -> d1 * d2 %| m1 * m2.\nProof.\nAdmitted.\n\nLemma dvdp_addr m d n : d %| m -> (d %| m + n) = (d %| n).\nProof.\nAdmitted.\n\nLemma dvdp_addl n d m : d %| n -> (d %| m + n) = (d %| m).\nProof.\nAdmitted.\n\nLemma dvdp_add d m n : d %| m -> d %| n -> d %| m + n.\nProof.\nAdmitted.\n\nLemma dvdp_add_eq d m n : d %| m + n -> (d %| m) = (d %| n).\nProof.\nAdmitted.\n\nLemma dvdp_subr d m n : d %| m -> (d %| m - n) = (d %| n).\nProof.\nAdmitted.\n\nLemma dvdp_subl d m n : d %| n -> (d %| m - n) = (d %| m).\nProof.\nAdmitted.\n\nLemma dvdp_sub d m n : d %| m -> d %| n -> d %| m - n.\nProof.\nAdmitted.\n\nLemma dvdp_mod d n m : d %| n -> (d %| m) = (d %| m %% n).\nProof.\nAdmitted.\n\nLemma dvdp_trans : transitive (@dvdp R).\nProof.\nAdmitted.\n\nLemma dvdp_mulIl p q : p %| p * q.\nProof.\nAdmitted.\n\nLemma dvdp_mulIr p q : q %| p * q.\nProof.\nAdmitted.\n\nLemma dvdp_mul2r r p q : r != 0 -> (p * r %| q * r) = (p %| q).\nProof.\nAdmitted.\n\nLemma dvdp_mul2l r p q: r != 0 -> (r * p %| r * q) = (p %| q).\nProof.\nAdmitted.\n\nLemma ltn_divpr d p q :\n d %| q -> (size p < size (q %/ d)) = (size (p * d) < size q).\nProof.\nAdmitted.\n\nLemma dvdp_exp d k p : 0 < k -> d %| p -> d %| (p ^+ k).\nProof.\nAdmitted.\n\nLemma dvdp_exp2l d k l : k <= l -> d ^+ k %| d ^+ l.\nProof.\nAdmitted.\n\nLemma dvdp_Pexp2l d k l : 1 < size d -> (d ^+ k %| d ^+ l) = (k <= l).\nProof.\nAdmitted.\n\nLemma dvdp_exp2r p q k : p %| q -> p ^+ k %| q ^+ k.\nProof.\nAdmitted.\n\nLemma dvdp_exp_sub p q k l: p != 0 ->\n (p ^+ k %| q * p ^+ l) = (p ^+ (k - l) %| q).\nProof.\nAdmitted.\n\nLemma dvdp_XsubCl p x : (('X - x%:P) %| p) = root p x.\nProof.\nAdmitted.\n\nLemma root_dvdp p q x : p %| q -> root p x -> root q x.\nProof.\nAdmitted.\n\nLemma polyXsubCP p x : reflect (p.\nProof.\nAdmitted.\n\nLemma eqp_div_XsubC p c :\n (p == (p %/ ('X - c%:P)) * ('X - c%:P)) = ('X - c%:P %| p).\nProof.\nAdmitted.\n\nLemma root_factor_theorem p x : root p x = (('X - x%:P) %| p).\nProof.\nAdmitted.\n\nLemma uniq_roots_dvdp p rs : all (root p) rs -> uniq_roots rs ->\n (\\prod_(z <- rs) ('X - z%:P)) %| p.\nProof.\nAdmitted.\n\nLemma root_bigmul x (ps : seq {poly R}) :\n ~~root (\\big[*%R/1]_(p <- ps) p) x = all (fun p => ~~ root p x) ps.\nProof.\nAdmitted.\n\nLemma eqpP m n :\n reflect (exists2 c12, (c12.\nProof.\nAdmitted.\n\nLemma eqp_eq p q: p %= q -> (lead_coef q) *: p = (lead_coef p) *: q.\nProof.\nAdmitted.\n\nLemma eqpxx : reflexive (@eqp R).\nProof.\nAdmitted.\n\nHint Resolve eqpxx : core.\n\nLemma eqpW p q : p = q -> p %= q.\nProof.\nAdmitted.\n\nLemma eqp_sym : symmetric (@eqp R).\nProof.\nAdmitted.\n\nLemma eqp_trans : transitive (@eqp R).\nProof.\nAdmitted.\n\nLemma eqp_ltrans : left_transitive (@eqp R).\nProof.\nAdmitted.\n\nLemma eqp_rtrans : right_transitive (@eqp R).\nProof.\nAdmitted.\n\nLemma eqp0 p : (p %= 0) = (p == 0).\nProof.\nAdmitted.\n\nLemma eqp01 : (0 %= (1 : {poly R})) = false.\nProof.\nAdmitted.\n\nLemma eqp_scale p c : c != 0 -> c *: p %= p.\nProof.\nAdmitted.\n\nLemma eqp_size p q : p %= q -> size p = size q.\nProof.\nAdmitted.\n\nLemma size_poly_eq1 p : (size p == 1) = (p %= 1).\nProof.\nAdmitted.\n\nLemma polyXsubC_eqp1 (x : R) : ('X - x%:P %= 1) = false.\nProof.\nAdmitted.\n\nLemma dvdp_eqp1 p q : p %| q -> q %= 1 -> p %= 1.\nProof.\nAdmitted.\n\nLemma eqp_dvdr q p d: p %= q -> (d %| p) = (d %| q).\nProof.\nAdmitted.\n\nLemma eqp_dvdl d2 d1 p : d1 %= d2 -> (d1 %| p) = (d2 %| p).\nProof.\nAdmitted.\n\nLemma dvdpZr c m n : c != 0 -> (m %| c *: n) = (m %| n).\nProof.\nAdmitted.\n\nLemma dvdpZl c m n : c != 0 -> (c *: m %| n) = (m %| n).\nProof.\nAdmitted.\n\nLemma dvdpNl d p : ((- d) %| p) = (d %| p).\nProof.\nAdmitted.\n\nLemma dvdpNr d p : (d %| (- p)) = (d %| p).\nProof.\nAdmitted.\n\nLemma eqp_mul2r r p q : r != 0 -> (p * r %= q * r) = (p %= q).\nProof.\nAdmitted.\n\nLemma eqp_mul2l r p q: r != 0 -> (r * p %= r * q) = (p %= q).\nProof.\nAdmitted.\n\nLemma eqp_mull r p q: q %= r -> p * q %= p * r.\nProof.\nAdmitted.\n\nLemma eqp_mulr q p r : p %= q -> p * r %= q * r.\nProof.\nAdmitted.\n\nLemma eqp_exp p q k : p %= q -> p ^+ k %= q ^+ k.\nProof.\nAdmitted.\n\nLemma polyC_eqp1 (c : R) : (c%:P %= 1) = (c != 0).\nProof.\nAdmitted.\n\nLemma dvdUp d p: d %= 1 -> d %| p.\nProof.\nAdmitted.\n\nLemma dvdp_size_eqp p q : p %| q -> (size p == size q) = (p %= q).\nProof.\nAdmitted.\n\nLemma eqp_root p q : p %= q -> root p =1 root q.\nProof.\nAdmitted.\n\nLemma eqp_rmod_mod p q : rmodp p q %= modp p q.\nProof.\nAdmitted.\n\nLemma eqp_rdiv_div p q : rdivp p q %= divp p q.\nProof.\nAdmitted.\n\nLemma dvd_eqp_divl d p q (dvd_dp : d %| q) (eq_pq : p %= q) :\n p %/ d %= q %/ d.\nProof.\nAdmitted.\n\nDefinition gcdp p q :=\n let: (p1, q1) := if size p < size q then (q, p) else (p, q) in\n if p1 == 0 then q1 else\n let fix loop (n : nat) (pp qq : {poly R}) {struct n} :=\n let rr := modp pp qq in\n if rr == 0 then qq else\n if n is n1.+1 then loop n1 qq rr else rr in\n loop (size p1) p1 q1.\nArguments gcdp : simpl never.\n\nLemma gcd0p : left_id 0 gcdp.\nProof.\nAdmitted.\n\nLemma gcdp0 : right_id 0 gcdp.\nProof.\nAdmitted.\n\nLemma gcdpE p q :\n gcdp p q = if size p < size q\n then gcdp (modp q p) p else gcdp (modp p q) q.\nProof.\nAdmitted.\n\nLemma size_gcd1p p : size (gcdp 1 p) = 1.\nProof.\nAdmitted.\n\nLemma size_gcdp1 p : size (gcdp p 1) = 1.\nProof.\nAdmitted.\n\nLemma gcdpp : idempotent_op gcdp.\nProof.\nAdmitted.\n\nLemma dvdp_gcdlr p q : (gcdp p q %| p) && (gcdp p q %| q).\nProof.\nAdmitted.\n\nLemma dvdp_gcdl p q : gcdp p q %| p.\nProof.\nAdmitted.\n\nLemma dvdp_gcdr p q :gcdp p q %| q.\nProof.\nAdmitted.\n\nLemma leq_gcdpl p q : p != 0 -> size (gcdp p q) <= size p.\nProof.\nAdmitted.\n\nLemma leq_gcdpr p q : q != 0 -> size (gcdp p q) <= size q.\nProof.\nAdmitted.\n\nLemma dvdp_gcd p m n : (p %| gcdp m n) = (p %| m) && (p %| n).\nProof.\nAdmitted.\n\nLemma gcdpC p q : gcdp p q %= gcdp q p.\nProof.\nAdmitted.\n\nLemma gcd1p p : gcdp 1 p %= 1.\nProof.\nAdmitted.\n\nLemma gcdp1 p : gcdp p 1 %= 1.\nProof.\nAdmitted.\n\nLemma gcdp_addl_mul p q r: gcdp r (p * r + q) %= gcdp r q.\nProof.\nAdmitted.\n\nLemma gcdp_addl m n : gcdp m (m + n) %= gcdp m n.\nProof.\nAdmitted.\n\nLemma gcdp_addr m n : gcdp m (n + m) %= gcdp m n.\nProof.\nAdmitted.\n\nLemma gcdp_mull m n : gcdp n (m * n) %= n.\nProof.\nAdmitted.\n\nLemma gcdp_mulr m n : gcdp n (n * m) %= n.\nProof.\nAdmitted.\n\nLemma gcdp_scalel c m n : c != 0 -> gcdp (c *: m) n %= gcdp m n.\nProof.\nAdmitted.\n\nLemma gcdp_scaler c m n : c != 0 -> gcdp m (c *: n) %= gcdp m n.\nProof.\nAdmitted.\n\nLemma dvdp_gcd_idl m n : m %| n -> gcdp m n %= m.\nProof.\nAdmitted.\n\nLemma dvdp_gcd_idr m n : n %| m -> gcdp m n %= n.\nProof.\nAdmitted.\n\nLemma gcdp_exp p k l : gcdp (p ^+ k) (p ^+ l) %= p ^+ minn k l.\nProof.\nAdmitted.\n\nLemma gcdp_eq0 p q : (gcdp p q == 0) = (p == 0) && (q == 0).\nProof.\nAdmitted.\n\nLemma eqp_gcdr p q r : q %= r -> gcdp p q %= gcdp p r.\nProof.\nAdmitted.\n\nLemma eqp_gcdl r p q : p %= q -> gcdp p r %= gcdp q r.\nProof.\nAdmitted.\n\nLemma eqp_gcd p1 p2 q1 q2 : p1 %= p2 -> q1 %= q2 -> gcdp p1 q1 %= gcdp p2 q2.\nProof.\nAdmitted.\n\nLemma eqp_rgcd_gcd p q : rgcdp p q %= gcdp p q.\nProof.\nAdmitted.\n\nLemma gcdp_modl m n : gcdp (m %% n) n %= gcdp m n.\nProof.\nAdmitted.\n\nLemma gcdp_modr m n : gcdp m (n %% m) %= gcdp m n.\nProof.\nAdmitted.\n\nLemma gcdp_def d m n :\n d %| m -> d %| n -> (forall d', d' %| m -> d' %| n -> d' %| d) ->\n gcdp m n %= d.\nProof.\nAdmitted.\n\nDefinition coprimep p q := size (gcdp p q) == 1%N.\n\nLemma coprimep_size_gcd p q : coprimep p q -> size (gcdp p q) = 1.\nProof.\nAdmitted.\n\nLemma coprimep_def p q : coprimep p q = (size (gcdp p q) == 1).\nProof.\nAdmitted.\n\nLemma coprimepZl c m n : c != 0 -> coprimep (c *: m) n = coprimep m n.\nProof.\nAdmitted.\n\nLemma coprimepZr c m n: c != 0 -> coprimep m (c *: n) = coprimep m n.\nProof.\nAdmitted.\n\nLemma coprimepp p : coprimep p p = (size p == 1).\nProof.\nAdmitted.\n\nLemma gcdp_eqp1 p q : (gcdp p q %= 1) = coprimep p q.\nProof.\nAdmitted.\n\nLemma coprimep_sym p q : coprimep p q = coprimep q p.\nProof.\nAdmitted.\n\nLemma coprime1p p : coprimep 1 p.\nProof.\nAdmitted.\n\nLemma coprimep1 p : coprimep p 1.\nProof.\nAdmitted.\n\nLemma coprimep0 p : coprimep p 0 = (p %= 1).\nProof.\nAdmitted.\n\nLemma coprime0p p : coprimep 0 p = (p %= 1).\nProof.\nAdmitted.\n\nLemma coprimepP p q :\n reflect (forall d, d %| p -> d %| q -> d %= 1) (coprimep p q).\nProof.\nAdmitted.\n\nLemma coprimepPn p q : p != 0 ->\n reflect (exists d, (d %| gcdp p q) && ~~ (d %= 1)) (~~ coprimep p q).\nProof.\nAdmitted.\n\nLemma coprimep_dvdl q p r : r %| q -> coprimep p q -> coprimep p r.\nProof.\nAdmitted.\n\nLemma coprimep_dvdr p q r : r %| p -> coprimep p q -> coprimep r q.\nProof.\nAdmitted.\n\nLemma coprimep_modl p q : coprimep (p %% q) q = coprimep p q.\nProof.\nAdmitted.\n\nLemma coprimep_modr q p : coprimep q (p %% q) = coprimep q p.\nProof.\nAdmitted.\n\nLemma rcoprimep_coprimep q p : rcoprimep q p = coprimep q p.\nProof.\nAdmitted.\n\nLemma eqp_coprimepr p q r : q %= r -> coprimep p q = coprimep p r.\nProof.\nAdmitted.\n\nLemma eqp_coprimepl p q r : q %= r -> coprimep q p = coprimep r p.\nProof.\nAdmitted.\n\nFixpoint egcdp_rec p q k {struct k} : {poly R} * {poly R} :=\n if k is k'.+1 then\n if q == 0 then (1, 0) else\n let: (u, v) := egcdp_rec q (p %% q) k' in\n (lead_coef q ^+ scalp p q *: v, (u - v * (p %/ q)))\n else (1, 0).\n\nDefinition egcdp p q :=\n if size q <= size p then egcdp_rec p q (size q)\n else let e := egcdp_rec q p (size p) in (e.2, e.1).\n\nLemma egcdp0 p : egcdp p 0 = (1, 0).\nProof.\nAdmitted.\n\nLemma egcdp_recP : forall k p q, q != 0 -> size q <= k -> size q <= size p ->\n let e := (egcdp_rec p q k) in\n [/\\ size e.\nProof.\nAdmitted.\n\nLemma egcdpP p q : p != 0 -> q != 0 -> forall (e := egcdp p q),\n [/\\ size e.\nProof.\nAdmitted.\n\nLemma egcdpE p q (e := egcdp p q) : gcdp p q %= e.\nProof.\nAdmitted.\n\nLemma Bezoutp p q : exists u, u.\nProof.\nAdmitted.\n\nLemma Bezout_coprimepP p q :\n reflect (exists u, u.\nProof.\nAdmitted.\n\nLemma coprimep_root p q x : coprimep p q -> root p x -> q.\nProof.\nAdmitted.\n\nLemma Gauss_dvdpl p q d: coprimep d q -> (d %| p * q) = (d %| p).\nProof.\nAdmitted.\n\nLemma Gauss_dvdpr p q d: coprimep d q -> (d %| q * p) = (d %| p).\nProof.\nAdmitted.\n\nLemma Gauss_dvdp m n p : coprimep m n -> (m * n %| p) = (m %| p) && (n %| p).\nProof.\nAdmitted.\n\nLemma Gauss_gcdpr p m n : coprimep p m -> gcdp p (m * n) %= gcdp p n.\nProof.\nAdmitted.\n\nLemma Gauss_gcdpl p m n : coprimep p n -> gcdp p (m * n) %= gcdp p m.\nProof.\nAdmitted.\n\nLemma coprimepMr p q r : coprimep p (q * r) = (coprimep p q && coprimep p r).\nProof.\nAdmitted.\n\nLemma coprimepMl p q r: coprimep (q * r) p = (coprimep q p && coprimep r p).\nProof.\nAdmitted.\n\nLemma modp_coprime k u n : k != 0 -> (k * u) %% n %= 1 -> coprimep k n.\nProof.\nAdmitted.\n\nLemma coprimep_pexpl k m n : 0 < k -> coprimep (m ^+ k) n = coprimep m n.\nProof.\nAdmitted.\n\nLemma coprimep_pexpr k m n : 0 < k -> coprimep m (n ^+ k) = coprimep m n.\nProof.\nAdmitted.\n\nLemma coprimep_expl k m n : coprimep m n -> coprimep (m ^+ k) n.\nProof.\nAdmitted.\n\nLemma coprimep_expr k m n : coprimep m n -> coprimep m (n ^+ k).\nProof.\nAdmitted.\n\nLemma gcdp_mul2l p q r : gcdp (p * q) (p * r) %= (p * gcdp q r).\nProof.\nAdmitted.\n\nLemma gcdp_mul2r q r p : gcdp (q * p) (r * p) %= gcdp q r * p.\nProof.\nAdmitted.\n\nLemma mulp_gcdr p q r : r * (gcdp p q) %= gcdp (r * p) (r * q).\nProof.\nAdmitted.\n\nLemma mulp_gcdl p q r : (gcdp p q) * r %= gcdp (p * r) (q * r).\nProof.\nAdmitted.\n\nLemma coprimep_div_gcd p q : (p != 0) || (q != 0) ->\n coprimep (p %/ (gcdp p q)) (q %/ gcdp p q).\nProof.\nAdmitted.\n\nLemma divp_eq0 p q : (p %/ q == 0) = [|| p == 0, q ==0 | size p < size q].\nProof.\nAdmitted.\n\nLemma dvdp_div_eq0 p q : q %| p -> (p %/ q == 0) = (p == 0).\nProof.\nAdmitted.\n\nLemma Bezout_coprimepPn p q : p != 0 -> q != 0 ->\n reflect (exists2 uv : {poly R} * {poly R},\n (0 < size uv.\nProof.\nAdmitted.\n\nLemma dvdp_pexp2r m n k : k > 0 -> (m ^+ k %| n ^+ k) = (m %| n).\nProof.\nAdmitted.\n\nLemma root_gcd p q x : root (gcdp p q) x = root p x && root q x.\nProof.\nAdmitted.\n\nLemma root_biggcd x (ps : seq {poly R}) :\n root (\\big[gcdp/0]_(p <- ps) p) x = all (fun p => root p x) ps.\nProof.\nAdmitted.\n\nFixpoint gdcop_rec q p k :=\n if k is m.+1 then\n if coprimep p q then p\n else gdcop_rec q (divp p (gcdp p q)) m\n else (q == 0)%:R.\n\nDefinition gdcop q p := gdcop_rec q p (size p).\n\nVariant gdcop_spec q p : {poly R} -> Type :=\n GdcopSpec r of (dvdp r p) & ((coprimep r q) || (p == 0))\n & (forall d, dvdp d p -> coprimep d q -> dvdp d r)\n : gdcop_spec q p r.\n\nLemma gdcop0 q : gdcop q 0 = (q == 0)%:R.\nProof.\nAdmitted.\n\nLemma gdcop_recP q p k : size p <= k -> gdcop_spec q p (gdcop_rec q p k).\nProof.\nAdmitted.\n\nLemma gdcopP q p : gdcop_spec q p (gdcop q p).\nProof.\nAdmitted.\n\nLemma coprimep_gdco p q : (q != 0)%B -> coprimep (gdcop p q) p.\nProof.\nAdmitted.\n\nLemma size2_dvdp_gdco p q d : p != 0 -> size d = 2 ->\n (d %| (gdcop q p)) = (d %| p) && ~~(d %| q).\nProof.\nAdmitted.\n\nLemma dvdp_gdco p q : (gdcop p q) %| q.\nProof.\nAdmitted.\n\nLemma root_gdco p q x : p != 0 -> root (gdcop q p) x = root p x && ~~(root q x).\nProof.\nAdmitted.\n\nLemma dvdp_comp_poly r p q : (p %| q) -> (p \\Po r) %| (q \\Po r).\nProof.\nAdmitted.\n\nLemma gcdp_comp_poly r p q : gcdp p q \\Po r %= gcdp (p \\Po r) (q \\Po r).\nProof.\nAdmitted.\n\nLemma coprimep_comp_poly r p q : coprimep p q -> coprimep (p \\Po r) (q \\Po r).\nProof.\nAdmitted.\n\nLemma coprimep_addl_mul p q r : coprimep r (p * r + q) = coprimep r q.\nProof.\nAdmitted.\n\nDefinition irreducible_poly p :=\n (size p > 1) * (forall q, size q != 1 -> q %| p -> q %= p) : Prop.\n\nLemma irredp_neq0 p : irreducible_poly p -> p != 0.\nProof.\nAdmitted.\n\nDefinition apply_irredp p (irr_p : irreducible_poly p) := irr_p.2.\nCoercion apply_irredp : irreducible_poly >-> Funclass.\n\nLemma modp_XsubC p c : p %% ('X - c%:P) = p.\nProof.\nAdmitted.\n\nLemma coprimep_XsubC p c : coprimep p ('X - c%:P) = ~~ root p c.\nProof.\nAdmitted.\n\nLemma coprimep_XsubC2 (a b : R) : b - a != 0 ->\n coprimep ('X - a%:P) ('X - b%:P).\nProof.\nAdmitted.\n\nLemma coprimepX p : coprimep p 'X = ~~ root p 0.\nProof.\nAdmitted.\n\nLemma eqp_monic : {in monic &, forall p q, (p %= q) = (p == q)}.\nProof.\nAdmitted.\n\nLemma dvdp_mul_XsubC p q c :\n (p %| ('X - c%:P) * q) = ((if root p c then p %/ ('X - c%:P) else p) %| q).\nProof.\nAdmitted.\n\nLemma dvdp_prod_XsubC (I : Type) (r : seq I) (F : I -> R) p :\n p %| \\prod_(i <- r) ('X - (F i)%:P) ->\n {m | p %= \\prod_(i <- mask m r) ('X - (F i)%:P)}.\nProof.\nAdmitted.\n\nLemma irredp_XsubC (x : R) : irreducible_poly ('X - x%:P).\nProof.\nAdmitted.\n\nLemma irredp_XaddC (x : R) : irreducible_poly ('X + x%:P).\nProof.\nAdmitted.\n\nLemma irredp_XsubCP d p :\n irreducible_poly p -> d %| p -> {d %= 1} + {d %= p}.\nProof.\nAdmitted.\n\nLemma dvdp_exp_XsubCP (p : {poly R}) (c : R) (n : nat) :\n reflect (exists2 k, (k <= n)%N & p %= ('X - c%:P) ^+ k)\n (p %| ('X - c%:P) ^+ n).\nProof.\nAdmitted.\n\nEnd IDomainPseudoDivision.\nArguments gcdp : simpl never.\n\n#[global] Hint Resolve eqpxx divp0 divp1 mod0p modp0 modp1 : core.\n#[global] Hint Resolve dvdp_mull dvdp_mulr dvdpp dvdp0 : core.\nArguments dvdp_exp_XsubCP {R p c n}.\n\nEnd CommonIdomain.\n\nModule Idomain.\n\nInclude IdomainDefs.\nExport IdomainDefs.\nInclude WeakIdomain.\nInclude CommonIdomain.\n\nEnd Idomain.\n\nModule IdomainMonic.\n\nImport Ring ComRing UnitRing IdomainDefs Idomain.\n\nSection IdomainMonic.\n\nVariable R : idomainType.\n\nImplicit Type p d r : {poly R}.\n\nSection MonicDivisor.\n\nVariable q : {poly R}.\nHypothesis monq : q \\is monic.\n\nLemma divpE p : p %/ q = rdivp p q.\nProof.\nAdmitted.\n\nLemma modpE p : p %% q = rmodp p q.\nProof.\nAdmitted.\n\nLemma scalpE p : scalp p q = 0.\nProof.\nAdmitted.\n\nLemma divp_eq p : p = (p %/ q) * q + (p %% q).\nProof.\nAdmitted.\n\nLemma divpp p : q %/ q = 1.\nProof.\nAdmitted.\n\nLemma dvdp_eq p : (q %| p) = (p == (p %/ q) * q).\nProof.\nAdmitted.\n\nLemma dvdpP p : reflect (exists qq, p = qq * q) (q %| p).\nProof.\nAdmitted.\n\nLemma mulpK p : p * q %/ q = p.\nProof.\nAdmitted.\n\nLemma mulKp p : q * p %/ q = p.\nProof.\nAdmitted.\n\nEnd MonicDivisor.\n\nLemma drop_poly_divp n p : drop_poly n p = p %/ 'X^n.\nProof.\nAdmitted.\n\nLemma take_poly_modp n p : take_poly n p = p %% 'X^n.\nProof.\nAdmitted.\n\nEnd IdomainMonic.\n\nEnd IdomainMonic.\n\nModule IdomainUnit.\n\nImport Ring ComRing UnitRing IdomainDefs Idomain.\n\nSection UnitDivisor.\n\nVariable R : idomainType.\nVariable d : {poly R}.\n\nHypothesis ulcd : lead_coef d \\in GRing.unit.\n\nImplicit Type p q r : {poly R}.\n\nLemma divp_eq p : p = (p %/ d) * d + (p %% d).\nProof.\nAdmitted.\n\nLemma edivpP p q r : p = q * d + r -> size r < size d ->\n q = (p %/ d) /\\ r = p %% d.\nProof.\nAdmitted.\n\nLemma divpP p q r : p = q * d + r -> size r < size d -> q = (p %/ d).\nProof.\nAdmitted.\n\nLemma modpP p q r : p = q * d + r -> size r < size d -> r = (p %% d).\nProof.\nAdmitted.\n\nLemma ulc_eqpP p q : lead_coef q \\is a GRing.\nProof.\nAdmitted.\n\nLemma dvdp_eq p : (d %| p) = (p == p %/ d * d).\nProof.\nAdmitted.\n\nLemma ucl_eqp_eq p q : lead_coef q \\is a GRing.\nProof.\nAdmitted.\n\nLemma modpZl c p : (c *: p) %% d = c *: (p %% d).\nProof.\nAdmitted.\n\nLemma divpZl c p : (c *: p) %/ d = c *: (p %/ d).\nProof.\nAdmitted.\n\nLemma eqp_modpl p q : p %= q -> (p %% d) %= (q %% d).\nProof.\nAdmitted.\n\nLemma eqp_divl p q : p %= q -> (p %/ d) %= (q %/ d).\nProof.\nAdmitted.\n\nLemma modpN p : (- p) %% d = - (p %% d).\nProof.\nAdmitted.\n\nLemma divpN p : (- p) %/ d = - (p %/ d).\nProof.\nAdmitted.\n\nLemma modpD p q : (p + q) %% d = p %% d + q %% d.\nProof.\nAdmitted.\n\nLemma divpD p q : (p + q) %/ d = p %/ d + q %/ d.\nProof.\nAdmitted.\n\nLemma mulpK q : (q * d) %/ d = q.\nProof.\nAdmitted.\n\nLemma mulKp q : (d * q) %/ d = q.\nProof.\nAdmitted.\n\nLemma divp_addl_mul_small q r : size r < size d -> (q * d + r) %/ d = q.\nProof.\nAdmitted.\n\nLemma modp_addl_mul_small q r : size r < size d -> (q * d + r) %% d = r.\nProof.\nAdmitted.\n\nLemma divp_addl_mul q r : (q * d + r) %/ d = q + r %/ d.\nProof.\nAdmitted.\n\nLemma divpp : d %/ d = 1.\nProof.\nAdmitted.\n\nLemma leq_divMp m : size (m %/ d * d) <= size m.\nProof.\nAdmitted.\n\nLemma dvdpP p : reflect (exists q, p = q * d) (d %| p).\nProof.\nAdmitted.\n\nLemma divpK p : d %| p -> p %/ d * d = p.\nProof.\nAdmitted.\n\nLemma divpKC p : d %| p -> d * (p %/ d) = p.\nProof.\nAdmitted.\n\nLemma dvdp_eq_div p q : d %| p -> (q == p %/ d) = (q * d == p).\nProof.\nAdmitted.\n\nLemma dvdp_eq_mul p q : d %| p -> (p == q * d) = (p %/ d == q).\nProof.\nAdmitted.\n\nLemma divp_mulA p q : d %| q -> p * (q %/ d) = p * q %/ d.\nProof.\nAdmitted.\n\nLemma divp_mulAC m n : d %| m -> m %/ d * n = m * n %/ d.\nProof.\nAdmitted.\n\nLemma divp_mulCA p q : d %| p -> d %| q -> p * (q %/ d) = q * (p %/ d).\nProof.\nAdmitted.\n\nLemma modp_mul p q : (p * (q %% d)) %% d = (p * q) %% d.\nProof.\nAdmitted.\n\nEnd UnitDivisor.\n\n#[deprecated(since=\"mathcomp 2.4.0\", use=leq_divMp)]\nNotation leq_trunc_divp := leq_divMp (only parsing).\n\nSection MoreUnitDivisor.\n\nVariable R : idomainType.\nVariable d : {poly R}.\nHypothesis ulcd : lead_coef d \\in GRing.unit.\n\nImplicit Types p q : {poly R}.\n\nLemma expp_sub m n : n <= m -> (d ^+ (m - n))%N = d ^+ m %/ d ^+ n.\nProof.\nAdmitted.\n\nLemma divp_pmul2l p q : lead_coef q \\in GRing.\nProof.\nAdmitted.\n\nLemma divp_pmul2r p q : lead_coef p \\in GRing.\nProof.\nAdmitted.\n\nLemma divp_divl r p q :\n lead_coef r \\in GRing.\nProof.\nAdmitted.\n\nLemma divpAC p q : lead_coef p \\in GRing.\nProof.\nAdmitted.\n\nLemma modpZr c p : c \\in GRing.\nProof.\nAdmitted.\n\nLemma divpZr c p : c \\in GRing.\nProof.\nAdmitted.\n\nEnd MoreUnitDivisor.\n\nEnd IdomainUnit.\n\nModule Field.\n\nImport Ring ComRing UnitRing.\nInclude IdomainDefs.\nExport IdomainDefs.\nInclude CommonIdomain.\n\nSection FieldDivision.\n\nVariable F : fieldType.\n\nImplicit Type p q r d : {poly F}.\n\nLemma divp_eq p q : p = (p %/ q) * q + (p %% q).\nProof.\nAdmitted.\n\nLemma divp_modpP p q d r : p = q * d + r -> size r < size d ->\n q = (p %/ d) /\\ r = p %% d.\nProof.\nAdmitted.\n\nLemma divpP p q d r : p = q * d + r -> size r < size d ->\n q = (p %/ d).\nProof.\nAdmitted.\n\nLemma modpP p q d r : p = q * d + r -> size r < size d -> r = (p %% d).\nProof.\nAdmitted.\n\nLemma eqpfP p q : p %= q -> p = (lead_coef p / lead_coef q) *: q.\nProof.\nAdmitted.\n\nLemma dvdp_eq q p : (q %| p) = (p == p %/ q * q).\nProof.\nAdmitted.\n\nLemma eqpf_eq p q : reflect (exists2 c, c != 0 & p = c *: q) (p %= q).\nProof.\nAdmitted.\n\nLemma modpZl c p q : (c *: p) %% q = c *: (p %% q).\nProof.\nAdmitted.\n\nLemma mulpK p q : q != 0 -> p * q %/ q = p.\nProof.\nAdmitted.\n\nLemma mulKp p q : q != 0 -> q * p %/ q = p.\nProof.\nAdmitted.\n\nLemma divpZl c p q : (c *: p) %/ q = c *: (p %/ q).\nProof.\nAdmitted.\n\nLemma modpZr c p d : c != 0 -> p %% (c *: d) = (p %% d).\nProof.\nAdmitted.\n\nLemma divpZr c p d : c != 0 -> p %/ (c *: d) = c^-1 *: (p %/ d).\nProof.\nAdmitted.\n\nLemma eqp_modpl d p q : p %= q -> (p %% d) %= (q %% d).\nProof.\nAdmitted.\n\nLemma eqp_divl d p q : p %= q -> (p %/ d) %= (q %/ d).\nProof.\nAdmitted.\n\nLemma eqp_modpr d p q : p %= q -> (d %% p) %= (d %% q).\nProof.\nAdmitted.\n\nLemma eqp_mod p1 p2 q1 q2 : p1 %= p2 -> q1 %= q2 -> p1 %% q1 %= p2 %% q2.\nProof.\nAdmitted.\n\nLemma eqp_divr (d m n : {poly F}) : m %= n -> (d %/ m) %= (d %/ n).\nProof.\nAdmitted.\n\nLemma eqp_div p1 p2 q1 q2 : p1 %= p2 -> q1 %= q2 -> p1 %/ q1 %= p2 %/ q2.\nProof.\nAdmitted.\n\nLemma eqp_gdcor p q r : q %= r -> gdcop p q %= gdcop p r.\nProof.\nAdmitted.\n\nLemma eqp_gdcol p q r : q %= r -> gdcop q p %= gdcop r p.\nProof.\nAdmitted.\n\nLemma eqp_rgdco_gdco q p : rgdcop q p %= gdcop q p.\nProof.\nAdmitted.\n\nLemma modpD d p q : (p + q) %% d = p %% d + q %% d.\nProof.\nAdmitted.\n\nLemma modpN p q : (- p) %% q = - (p %% q).\nProof.\nAdmitted.\n\nLemma modNp p q : (- p) %% q = - (p %% q).\nProof.\nAdmitted.\n\nLemma divpD d p q : (p + q) %/ d = p %/ d + q %/ d.\nProof.\nAdmitted.\n\nLemma divpN p q : (- p) %/ q = - (p %/ q).\nProof.\nAdmitted.\n\nLemma divp_addl_mul_small d q r : size r < size d -> (q * d + r) %/ d = q.\nProof.\nAdmitted.\n\nLemma modp_addl_mul_small d q r : size r < size d -> (q * d + r) %% d = r.\nProof.\nAdmitted.\n\nLemma divp_addl_mul d q r : d != 0 -> (q * d + r) %/ d = q + r %/ d.\nProof.\nAdmitted.\n\nLemma divpp d : d != 0 -> d %/ d = 1.\nProof.\nAdmitted.\n\nLemma leq_divMp d m : size (m %/ d * d) <= size m.\nProof.\nAdmitted.\n\nLemma divpK d p : d %| p -> p %/ d * d = p.\nProof.\nAdmitted.\n\nLemma divpKC d p : d %| p -> d * (p %/ d) = p.\nProof.\nAdmitted.\n\nLemma dvdp_eq_div d p q : d != 0 -> d %| p -> (q == p %/ d) = (q * d == p).\nProof.\nAdmitted.\n\nLemma dvdp_eq_mul d p q : d != 0 -> d %| p -> (p == q * d) = (p %/ d == q).\nProof.\nAdmitted.\n\nLemma divp_mulA d p q : d %| q -> p * (q %/ d) = p * q %/ d.\nProof.\nAdmitted.\n\nLemma divp_mulAC d m n : d %| m -> m %/ d * n = m * n %/ d.\nProof.\nAdmitted.\n\nLemma divp_mulCA d p q : d %| p -> d %| q -> p * (q %/ d) = q * (p %/ d).\nProof.\nAdmitted.\n\nLemma expp_sub d m n : d != 0 -> m >= n -> (d ^+ (m - n))%N = d ^+ m %/ d ^+ n.\nProof.\nAdmitted.\n\nLemma divp_pmul2l d q p : d != 0 -> q != 0 -> d * p %/ (d * q) = p %/ q.\nProof.\nAdmitted.\n\nLemma divp_pmul2r d p q : d != 0 -> p != 0 -> q * d %/ (p * d) = q %/ p.\nProof.\nAdmitted.\n\nLemma divp_divl r p q : q %/ p %/ r = q %/ (p * r).\nProof.\nAdmitted.\n\nLemma divpAC d p q : q %/ d %/ p = q %/ p %/ d.\nProof.\nAdmitted.\n\nLemma edivp_def p q : edivp p q = (0, p %/ q, p %% q).\nProof.\nAdmitted.\n\nLemma divpE p q : p %/ q = (lead_coef q)^-(rscalp p q) *: (rdivp p q).\nProof.\nAdmitted.\n\nLemma modpE p q : p %% q = (lead_coef q)^-(rscalp p q) *: (rmodp p q).\nProof.\nAdmitted.\n\nLemma scalpE p q : scalp p q = 0.\nProof.\nAdmitted.\n\nLemma dvdpE p q : (p %| q) = rdvdp p q.\nProof.\nAdmitted.\n\nVariant edivp_spec m d : nat * {poly F} * {poly F} -> Type :=\n EdivpSpec n q r of\n m = q * d + r & (d != 0) ==> (size r < size d) : edivp_spec m d (n, q, r).\n\nLemma edivpP m d : edivp_spec m d (edivp m d).\nProof.\nAdmitted.\n\nLemma edivp_eq d q r : size r < size d -> edivp (q * d + r) d = (0, q, r).\nProof.\nAdmitted.\n\nLemma modp_mul p q m : (p * (q %% m)) %% m = (p * q) %% m.\nProof.\nAdmitted.\n\nLemma horner_mod p q x : root q x -> (p %% q).\nProof.\nAdmitted.\n\nLemma dvdpP p q : reflect (exists qq, p = qq * q) (q %| p).\nProof.\nAdmitted.\n\nLemma Bezout_eq1_coprimepP p q :\n reflect (exists u, u.\nProof.\nAdmitted.\n\nLemma dvdp_gdcor p q : q != 0 -> p %| (gdcop q p) * (q ^+ size p).\nProof.\nAdmitted.\n\nLemma reducible_cubic_root p q :\n size p <= 4 -> 1 < size q < size p -> q %| p -> {r | root p r}.\nProof.\nAdmitted.\n\nLemma cubic_irreducible p :\n 1 < size p <= 4 -> (forall x, ~~ root p x) -> irreducible_poly p.\nProof.\nAdmitted.\n\nSection Multiplicity.\n\nDefinition mup x q :=\n [arg max_(n > (ord0 : 'I_(size q).+1) | ('X - x%:P) ^+ n %| q) n] : nat.\n\nLemma mup_geq x q n : q != 0 -> (n <= mup x q)%N = (('X - x%:P) ^+ n %| q).\nProof.\nAdmitted.\n\nLemma mup_leq x q n : q != 0 ->\n (mup x q <= n)%N = ~~ (('X - x%:P) ^+ n.\nProof.\nAdmitted.\n\nLemma mup_ltn x q n : q != 0 -> (mup x q < n)%N = ~~ (('X - x%:P) ^+ n %| q).\nProof.\nAdmitted.\n\nLemma XsubC_dvd x q : q != 0 -> ('X - x%:P %| q) = (0 < mup x q)%N.\nProof.\nAdmitted.\n\nLemma mup_XsubCX n x y :\n mup x (('X - y%:P) ^+ n) = (if (y == x) then n else 0)%N.\nProof.\nAdmitted.\n\nLemma mupNroot x q : ~~ root q x -> mup x q = 0%N.\nProof.\nAdmitted.\n\nLemma mupMr x q1 q2 : ~~ root q1 x -> mup x (q1 * q2) = mup x q2.\nProof.\nAdmitted.\n\nLemma mupMl x q1 q2 : ~~ root q2 x -> mup x (q1 * q2) = mup x q1.\nProof.\nAdmitted.\n\nLemma mupM x q1 q2 : q1 != 0 -> q2 != 0 ->\n mup x (q1 * q2) = (mup x q1 + mup x q2)%N.\nProof.\nAdmitted.\n\nLemma mu_prod_XsubC x (s : seq F) :\n mup x (\\prod_(y <- s) ('X - y%:P)) = count_mem x s.\nProof.\nAdmitted.\n\nLemma prod_XsubC_eq (s t : seq F) :\n \\prod_(x <- s) ('X - x%:P) = \\prod_(x <- t) ('X - x%:P) -> perm_eq s t.\nProof.\nAdmitted.\n\nEnd Multiplicity.\n\nSection FieldRingMap.\n\nVariable rR : nzRingType.\n\nVariable f : {rmorphism F -> rR}.\nLocal Notation \"p ^f\" := (map_poly f p) : ring_scope.\n\nImplicit Type a b : {poly F}.\n\nLemma redivp_map a b :\n redivp a^f b^f = (rscalp a b, (rdivp a b)^f, (rmodp a b)^f).\nProof.\nAdmitted.\n\nEnd FieldRingMap.\n\nSection FieldMap.\n\nVariable rR : idomainType.\n\nVariable f : {rmorphism F -> rR}.\nLocal Notation \"p ^f\" := (map_poly f p) : ring_scope.\n\nImplicit Type a b : {poly F}.\n\nLemma edivp_map a b :\n edivp a^f b^f = (0, (a %/ b)^f, (a %% b)^f).\nProof.\nAdmitted.\n\nLemma scalp_map p q : scalp p^f q^f = scalp p q.\nProof.\nAdmitted.\n\nLemma map_divp p q : (p %/ q)^f = p^f %/ q^f.\nProof.\nAdmitted.\n\nLemma map_modp p q : (p %% q)^f = p^f %% q^f.\nProof.\nAdmitted.\n\nLemma egcdp_map p q :\n egcdp (map_poly f p) (map_poly f q)\n = (map_poly f (egcdp p q).\nProof.\nAdmitted.\n\nLemma dvdp_map p q : (p^f %| q^f) = (p %| q).\nProof.\nAdmitted.\n\nLemma eqp_map p q : (p^f %= q^f) = (p %= q).\nProof.\nAdmitted.\n\nLemma gcdp_map p q : (gcdp p q)^f = gcdp p^f q^f.\nProof.\nAdmitted.\n\nLemma coprimep_map p q : coprimep p^f q^f = coprimep p q.\nProof.\nAdmitted.\n\nLemma gdcop_rec_map p q n : (gdcop_rec p q n)^f = gdcop_rec p^f q^f n.\nProof.\nAdmitted.\n\nLemma gdcop_map p q : (gdcop p q)^f = gdcop p^f q^f.\nProof.\nAdmitted.\n\nEnd FieldMap.\n\nEnd FieldDivision.\n\n#[deprecated(since=\"mathcomp 2.4.0\", use=leq_divMp)]\nNotation leq_trunc_divp := leq_divMp (only parsing).\n\nEnd Field.\n\nModule ClosedField.\n\nImport Field.\n\nSection closed.\n\nVariable F : closedFieldType.\n\nLemma root_coprimep (p q : {poly F}) :\n (forall x, root p x -> q.\nProof.\nAdmitted.\n\nLemma coprimepP (p q : {poly F}) :\n reflect (forall x, root p x -> q.\nProof.\nAdmitted.\n\nEnd closed.\n\nEnd ClosedField.\n\nEnd Pdiv.\n\nExport Pdiv.Field." }, { "theorem_id": 67, "title": "090_stirling_s_formula", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/analysis.ml\";;\nneeds \"Library/transc.ml\";;\n\noverride_interface(\"-->\",`(tends_num_real)`);;\n\nlet ODDEVEN_INDUCT = `!P. P 0 /\\ P 1 /\\ (!n. P n ==> P(n + 2)) ==> !n. P n`;;\n\nlet LN_LIM_BOUND = `!n. ~(n = 0) ==> abs(&n * ln(&1 + &1 / &n) - &1) <= &1 / (&2 * &n)`;;\n\nlet LN_LIM_LEMMA = `(\\n. &n * ln(&1 + &1 / &n)) --> &1`;;\n\nlet POSITIVE_DIFF_LEMMA = `!f f'. (!x. &0 < x ==> (f diffl f'(x)) x /\\ f'(x) < &0) /\\\n (\\n. f(&n)) --> &0\n ==> !n. ~(n = 0) ==> &0 < f(&n)`;;\n\nlet stirling = new_definition\n `stirling n = ln(&(FACT n)) - ((&n + &1 / &2) * ln(&n) - &n)`;;\n\nlet STIRLING_DIFF = `!n. ~(n = 0)\n ==> stirling(n) - stirling(n + 1) =\n (&n + &1 / &2) * ln((&n + &1) / &n) - &1`;;\n\nlet STIRLING_DELTA_DERIV = `!x. &0 < x\n ==> ((\\x. ln ((x + &1) / x) - &1 / (x + &1 / &2)) diffl\n (-- &1 / (x * (x + &1) * (&2 * x + &1) pow 2))) x`;;\n\nlet STIRLING_DELTA_LIMIT = `(\\n. ln ((&n + &1) / &n) - &1 / (&n + &1 / &2)) --> &0`;;\n\nlet STIRLING_DECREASES = `!n. ~(n = 0) ==> stirling(n + 1) < stirling(n)`;;\n\nlet OTHER_DERIV_LEMMA = `!x. &0 < x\n ==> ((\\x. &1 / (&12 * x * (x + &1) * (x + &1 / &2))) diffl\n --(&3 * x pow 2 + &3 * x + &1 / &2) /\n (&12 * (x * (x + &1) * (x + &1 / &2)) pow 2)) x`;;\n\nlet STIRLING_INCREASES = `!n. ~(n = 0)\n ==> stirling(n + 1) - &1 / (&12 * (&(n + 1)))\n > stirling(n) - &1 / (&12 * &n)`;;\n\nlet STIRLING_UPPERBOUND = `!n. stirling(SUC n) <= &1`;;\n\nlet STIRLING_LOWERBOUND = `!n. -- &1 <= stirling(SUC n)`;;\n\nlet STIRLING_MONO = `!m n. ~(m = 0) /\\ m <= n ==> stirling n <= stirling m`;;\n\nlet STIRLING_CONVERGES = `?c. stirling --> c`;;\n\nlet [PI2_LT; PI2_LE; PI2_NZ] = (CONJUNCTS o prove)\n (`&0 < pi / &2 /\\ &0 <= pi / &2 /\\ ~(pi / &2 = &0)`,\n MP_TAC PI_POS THEN REAL_ARITH_TAC);;\n\nlet WALLIS_PARTS = `!n. (&n + &2) * integral(&0,pi / &2) (\\x. sin(x) pow (n + 2)) =\n (&n + &1) * integral(&0,pi / &2) (\\x. sin(x) pow n)`;;\n\nlet WALLIS_PARTS' = `!n. integral(&0,pi / &2) (\\x. sin(x) pow (n + 2)) =\n (&n + &1) / (&n + &2) * integral(&0,pi / &2) (\\x. sin(x) pow n)`;;\n\nlet WALLIS_0 = `integral(&0,pi / &2) (\\x. sin(x) pow 0) = pi / &2`;;\n\nlet WALLIS_1 = `integral(&0,pi / &2) (\\x. sin(x) pow 1) = &1`;;\n\nlet WALLIS_EVEN = `!n. integral(&0,pi / &2) (\\x. sin(x) pow (2 * n)) =\n (&(FACT(2 * n)) / (&2 pow n * &(FACT n)) pow 2) * pi / &2`;;\n\nlet WALLIS_ODD = `!n. integral(&0,pi / &2) (\\x. sin(x) pow (2 * n + 1)) =\n (&2 pow n * &(FACT n)) pow 2 / &(FACT(2 * n + 1))`;;\n\nlet WALLIS_QUOTIENT = `!n. integral(&0,pi / &2) (\\x. sin(x) pow (2 * n)) /\n integral(&0,pi / &2) (\\x. sin(x) pow (2 * n + 1)) =\n (&(FACT(2 * n)) * &(FACT(2 * n + 1))) / (&2 pow n * &(FACT n)) pow 4 *\n pi / &2`;;\n\nlet WALLIS_QUOTIENT' = `!n. integral(&0,pi / &2) (\\x. sin(x) pow (2 * n)) /\n integral(&0,pi / &2) (\\x. sin(x) pow (2 * n + 1)) * &2 / pi =\n (&(FACT(2 * n)) * &(FACT(2 * n + 1))) / (&2 pow n * &(FACT n)) pow 4`;;\n\nlet WALLIS_MONO = `!m n. m <= n\n ==> integral(&0,pi / &2) (\\x. sin(x) pow n)\n <= integral(&0,pi / &2) (\\x. sin(x) pow m)`;;\n\nlet WALLIS_LT = `!n. &0 < integral(&0,pi / &2) (\\x. sin(x) pow n)`;;\n\nlet WALLIS_NZ = `!n. ~(integral(&0,pi / &2) (\\x. sin(x) pow n) = &0)`;;\n\nlet WALLIS_BOUNDS = `!n. integral(&0,pi / &2) (\\x. sin(x) pow (n + 1))\n <= integral(&0,pi / &2) (\\x. sin(x) pow n) /\\\n integral(&0,pi / &2) (\\x. sin(x) pow n) <=\n (&n + &2) / (&n + &1) * integral(&0,pi / &2) (\\x. sin(x) pow (n + 1))`;;\n\nlet WALLIS_RATIO_BOUNDS = `!n. &1 <= integral(&0,pi / &2) (\\x. sin(x) pow n) /\n integral(&0,pi / &2) (\\x. sin(x) pow (n + 1)) /\\\n integral(&0,pi / &2) (\\x. sin(x) pow n) /\n integral(&0,pi / &2) (\\x. sin(x) pow (n + 1)) <= (&n + &2) / (&n + &1)`;;\n\nlet WALLIS = `(\\n. (&2 pow n * &(FACT n)) pow 4 / (&(FACT(2 * n)) * &(FACT(2 * n + 1))))\n --> pi / &2`;;\n\nlet LN_WALLIS = `(\\n. &4 * &n * ln(&2) + &4 * ln(&(FACT n)) -\n (ln(&(FACT(2 * n))) + ln(&(FACT(2 * n + 1))))) --> ln(pi / &2)`;;\n\nlet STIRLING = `(\\n. ln(&(FACT n)) - ((&n + &1 / &2) * ln(&n) - &n + ln(&2 * pi) / &2))\n --> &0`;;" }, { "theorem_id": 67, "title": "090_stirling_s_formula", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Stirling's Formula\\\ntheory Stirling_Formula\nimports\n \"HOL-Analysis.Analysis\"\n \"Landau_Symbols.Landau_More\"\n \"HOL-Real_Asymp.Real_Asymp\"\nbegin\n\ncontext\nbegin\n\ntext \\\n First, we define the $S_n^*$ from Jameson's article:\n\\\nqualified definition S' :: \"nat \\ real \\ real\" where\n \"S' n x = 1/(2*x) + (\\r=1..\n Next, the trapezium (also called $T$ in Jameson's article):\n\\\nqualified definition T :: \"real \\ real\" where\n \"T x = 1/(2*x) + 1/(2*(x+1))\"\n\ntext \\\n Now we define The difference $\\Delta(x)$:\n\\\nqualified definition D :: \"real \\ real\" where\n \"D x = T x - ln (x + 1) + ln x\"\n\nqualified lemma S'_telescope_trapezium:\n assumes \"n > 0\"\n shows \"S' n x = (\\rrrrrrrr=0..r=0..r=Suc 0.. = (\\r=1.. + ?a + ?b = S' n x\" by (simp add: S'_def Suc)\n finally show ?thesis ..\nqed (insert assms, simp_all)\n\nqualified lemma stirling_trapezium:\n assumes x: \"(x::real) > 0\"\n shows \"D x \\ {0 .. 1/(12*x^2) - 1/(12 * (x+1)^2)}\"\nproof -\n define y where \"y = 1 / (2*x + 1)\"\n from x have y: \"y > 0\" \"y < 1\" by (simp_all add: divide_simps y_def)\n\n from x have \"D x = T x - ln ((x + 1) / x)\" by (subst ln_div) (simp_all add: D_def)\n also from x have \"(x + 1) / x = 1 + 1 / x\" by (simp add: field_simps)\n finally have D: \"D x = T x - ln (1 + 1/x)\" .\n\n from y have \"(\\n. y * y^n) sums (y * (1 / (1 - y)))\" \n by (intro geometric_sums sums_mult) simp_all\n hence \"(\\n. y ^ Suc n) sums (y / (1 - y))\" by simp\n also from x have \"y / (1 - y) = 1 / (2*x)\" by (simp add: y_def divide_simps)\n finally have *: \"(\\n. y ^ Suc n) sums (1 / (2*x))\" .\n\n from y have \"(\\n. (-y) * (-y)^n) sums ((-y) * (1 / (1 - (-y))))\" \n by (intro geometric_sums sums_mult) simp_all\n hence \"(\\n. (-y) ^ Suc n) sums (-(y / (1 + y)))\" by simp\n also from x have \"y / (1 + y) = 1 / (2*(x+1))\" by (simp add: y_def divide_simps)\n finally have **: \"(\\n. (-y) ^ Suc n) sums (-(1 / (2*(x+1))))\" .\n\n from sums_diff[OF * **] have sum1: \"(\\n. y ^ Suc n - (-y) ^ Suc n) sums T x\"\n by (simp add: T_def)\n \n from y have \"abs y < 1\" \"abs (-y) < 1\" by simp_all\n from sums_diff[OF this[THEN ln_series']]\n have \"(\\n. y ^ n / real n - (-y) ^ n / real n) sums (ln (1 + y) - ln (1 - y))\" by simp\n also from y have \"ln (1 + y) - ln (1 - y) = ln ((1 + y) / (1 - y))\" by (simp add: ln_div)\n also from x have \"(1 + y) / (1 - y) = 1 + 1/x\" by (simp add: divide_simps y_def)\n finally have \"(\\n. y^n / real n - (-y)^n / real n) sums ln (1 + 1/x)\" .\n hence sum2: \"(\\n. y^Suc n / real (Suc n) - (-y)^Suc n / real (Suc n)) sums ln (1 + 1/x)\"\n by (subst sums_Suc_iff) simp\n\n have \"ln (1 + 1/x) \\ T x\"\n proof (rule sums_le [OF _ sum2 sum1])\n fix n :: nat\n show \"y ^ Suc n / real (Suc n) - (-y) ^ Suc n / real (Suc n) \\ y^Suc n - (-y) ^ Suc n\"\n proof (cases \"even n\")\n case True\n hence eq: \"A - (-y) ^ Suc n / B = A + y ^ Suc n / B\" \"A - (-y) ^ Suc n = A + y ^ Suc n\"\n for A B by simp_all\n from y show ?thesis unfolding eq\n by (intro add_mono) (auto simp: divide_simps)\n qed simp_all\n qed\n hence \"D x \\ 0\" by (simp add: D)\n\n define c where \"c = (\\n. if even n then 2 * (1 - 1 / real (Suc n)) else 0)\"\n note sums_diff[OF sum1 sum2]\n also have \"(\\n. y ^ Suc n - (-y) ^ Suc n - (y ^ Suc n / real (Suc n) - \n (-y) ^ Suc n / real (Suc n))) = (\\n. c n * y ^ Suc n)\"\n by (intro ext) (simp add: c_def algebra_simps)\n finally have sum3: \"(\\n. c n * y ^ Suc n) sums D x\" by (simp add: D)\n \n from y have \"(\\n. y^2 * (of_nat (Suc n) * y^n)) sums (y^2 * (1 / (1 - y)^2))\"\n by (intro sums_mult geometric_deriv_sums) simp_all\n hence \"(\\n. of_nat (Suc n) * y^(n+2)) sums (y^2 / (1 - y)^2)\" \n by (simp add: algebra_simps power2_eq_square)\n also from x have \"y^2 / (1 - y)^2 = 1 / (4*x^2)\" by (simp add: y_def divide_simps)\n finally have *: \"(\\n. real (Suc n) * y ^ (Suc (Suc n))) sums (1 / (4 * x\\<^sup>2))\" by simp\n\n from y have \"(\\n. y^2 * (of_nat (Suc n) * (-y)^n)) sums (y^2 * (1 / (1 - -y)^2))\"\n by (intro sums_mult geometric_deriv_sums) simp_all\n hence \"(\\n. of_nat (Suc n) * (-y)^(n+2)) sums (y^2 / (1 + y)^2)\"\n by (simp add: algebra_simps power2_eq_square)\n also from x have \"y^2 / (1 + y)^2 = 1 / (2^2*(x+1)^2)\" \n unfolding power_mult_distrib [symmetric] by (simp add: y_def divide_simps add_ac)\n finally have **: \"(\\n. real (Suc n) * (- y) ^ (Suc (Suc n))) sums (1 / (4 * (x + 1)\\<^sup>2))\" by simp\n \n define d where \"d = (\\n. if even n then 2 * real n else 0)\"\n note sums_diff[OF * **]\n also have \"(\\n. real (Suc n) * y^(Suc (Suc n)) - real (Suc n) * (-y)^(Suc (Suc n))) = \n (\\n. d (Suc n) * y ^ Suc (Suc n))\"\n by (intro ext) (simp_all add: d_def)\n finally have \"(\\n. d n * y ^ Suc n) sums (1 / (4 * x\\<^sup>2) - 1 / (4 * (x + 1)\\<^sup>2))\" \n by (subst (asm) sums_Suc_iff) (simp add: d_def)\n from sums_mult[OF this, of \"1/3\"] x\n have sum4: \"(\\n. d n / 3 * y ^ Suc n) sums (1 / (12 * x^2) - 1 / (12 * (x + 1)^2))\"\n by (simp add: field_simps)\n \n have \"D x \\ (1 / (12 * x^2) - 1 / (12 * (x + 1)^2))\"\n proof (intro sums_le [OF _ sum3 sum4] allI)\n fix n :: nat\n define c' :: \"nat \\ real\" \n where \"c' = (\\n. if odd n \\ n = 0 then 0 else if n = 2 then 4/3 else 2)\"\n show \"c n * y ^ Suc n \\ d n / 3 * y ^ Suc n\"\n proof (intro mult_right_mono)\n have \"c n \\ c' n\" by (simp add: c_def c'_def)\n also consider \"n = 0\" | \"n = 1\" | \"n = 2\" | \"n \\ 3\" by force\n hence \"c' n \\ d n / 3\" by cases (simp_all add: c'_def d_def)\n finally show \"c n \\ d n / 3\" .\n qed (insert y, simp)\n qed\n\n with \\D x \\ 0\\ show ?thesis by simp\nqed \n\ntext \\\n The following functions correspond to the $p_n(x)$ from the article.\n The special case $n = 0$ would not, strictly speaking, be necessary, but \n it allows some theorems to work even without the precondition $n \\neq 0$:\n\\\nqualified definition p :: \"nat \\ real \\ real\" where\n \"p n x = (if n = 0 then 1/x else (\\r\n We can write the Digamma function in terms of @{term S'}:\n\\\nqualified lemma S'_LIMSEQ_Digamma:\n assumes x: \"x \\ 0\"\n shows \"(\\n. ln (real n) - S' n x - 1/(2*x)) \\ Digamma x\"\nproof -\n define c where \"c = (\\n. ln (real n) - (\\rn. 1 / (2 * (x + real n)) = c n - (ln (real n) - S' n x - 1/(2*x))) at_top\"\n using eventually_gt_at_top[of \"0::nat\"]\n proof eventually_elim\n fix n :: nat\n assume n: \"n > 0\"\n have \"c n - (ln (real n) - S' n x - 1/(2*x)) = \n -(\\rr=1..r=1..rn. 1 / (2 * (x + real n))) \\ 0\"\n by real_asymp\n ultimately have \"(\\n. c n - (ln (real n) - S' n x - 1/(2*x))) \\ 0\"\n by (blast intro: Lim_transform_eventually)\n from tendsto_minus[OF this] have \"(\\n. (ln (real n) - S' n x - 1/(2*x)) - c n) \\ 0\" by simp\n moreover from Digamma_LIMSEQ[OF x] have \"c \\ Digamma x\" by (simp add: c_def) \n ultimately show \"(\\n. ln (real n) - S' n x - 1/(2*x)) \\ Digamma x\"\n by (rule Lim_transform [rotated])\nqed\n\ntext \\\n Moreover, we can give an expansion of @{term S'} with the @{term p} as variation terms.\n\\\nqualified lemma S'_approx: \n \"S' n x = ln (real n + x) - ln x + p n x\"\nproof (cases \"n = 0\")\n case True\n thus ?thesis by (simp add: p_def S'_def)\nnext\n case False\n hence \"S' n x = (\\r = (\\r = (\\rr\n We define the limit of the @{term p} (simply called $p(x)$ in Jameson's article):\n\\\nqualified definition P :: \"real \\ real\" where\n \"P x = (\\n. D (real n + x))\"\n\nqualified lemma D_summable:\n assumes x: \"x > 0\"\n shows \"summable (\\n. D (real n + x))\"\nproof -\n have *: \"summable (\\n. 1 / (12 * (x + real n)\\<^sup>2) - 1 / (12 * (x + real (Suc n))\\<^sup>2))\"\n by (rule telescope_summable') real_asymp\n show \"summable (\\n. D (real n + x))\" \n proof (rule summable_comparison_test[OF _ *], rule exI[of _ 2], safe)\n fix n :: nat assume \"n \\ 2\"\n show \"norm (D (real n + x)) \\ 1 / (12 * (x + real n)^2) - 1 / (12 * (x + real (Suc n))^2)\"\n using stirling_trapezium[of \"real n + x\"] x by (auto simp: algebra_simps)\n qed\nqed\n\nqualified lemma p_LIMSEQ:\n assumes x: \"x > 0\"\n shows \"(\\n. p n x) \\ P x\"\nproof (rule Lim_transform_eventually)\n from D_summable[OF x] have \"(\\n. D (real n + x)) sums P x\" unfolding P_def\n by (simp add: sums_iff)\n then show \"(\\n. \\r P x\" by (simp add: sums_def)\n moreover from eventually_gt_at_top[of 1]\n show \"eventually (\\n. (\\r\n This gives us an expansion of the Digamma function:\n\\\nlemma Digamma_approx:\n assumes x: \"(x :: real) > 0\"\n shows \"Digamma x = ln x - 1 / (2 * x) - P x\"\n by sorry\n \ntext \\\n Next, we derive some bounds on @{term \"P\"}:\n\\\nqualified lemma p_ge_0: \"x > 0 \\ p n x \\ 0\"\n using stirling_trapezium[of \"real n + x\" for n]\n by (auto simp add: p_def intro!: sum_nonneg)\n\nqualified lemma P_ge_0: \"x > 0 \\ P x \\ 0\"\n by (rule tendsto_lowerbound[OF p_LIMSEQ]) \n (insert p_ge_0[of x], simp_all)\n\nqualified lemma p_upper_bound:\n assumes \"x > 0\" \"n > 0\"\n shows \"p n x \\ 1/(12*x^2)\"\nproof -\n from assms have \"p n x = (\\r \\ (\\r = 1 / (12 * x\\<^sup>2) - 1 / (12 * (real n + x)\\<^sup>2)\"\n by (subst sum_lessThan_telescope') simp\n also have \"\\ \\ 1 / (12 * x^2)\" by simp\n finally show ?thesis .\nqed\n\nqualified lemma P_upper_bound:\n assumes \"x > 0\"\n shows \"P x \\ 1/(12*x^2)\"\nproof (rule tendsto_upperbound)\n show \"eventually (\\n. p n x \\ 1 / (12 * x^2)) at_top\"\n using eventually_gt_at_top[of 0] \n by eventually_elim (use p_upper_bound[of x] assms in auto)\n show \"(\\n. p n x) \\ P x\"\n by (simp add: assms p_LIMSEQ)\nqed auto\n\ntext \\\n We can now use this approximation of the Digamma function to approximate\n @{term ln_Gamma} (since the former is the derivative of the latter). \n We therefore define the function $g$ from Jameson's article, which measures \n the difference between @{term ln_Gamma} and its approximation:\n\\\n\nqualified definition g :: \"real \\ real\" where\n \"g x = ln_Gamma x - (x - 1/2) * ln x + x\"\n\nqualified lemma DERIV_g: \"x > 0 \\ (g has_field_derivative -P x) (at x)\"\n unfolding g_def [abs_def] using Digamma_approx[of x]\n by (auto intro!: derivative_eq_intros simp: field_simps)\n\nqualified lemma isCont_P: \n assumes \"x > 0\"\n shows \"isCont P x\"\nproof -\n define D' :: \"real \\ real\"\n where \"D' = (\\x. - 1 / (2 * x^2 * (x+1)^2))\"\n have DERIV_D: \"(D has_field_derivative D' x) (at x)\" if \"x > 0\" for x\n unfolding D_def [abs_def] D'_def T_def\n by (insert that, (rule derivative_eq_intros refl | simp)+)\n (simp add: power2_eq_square divide_simps, (simp add: algebra_simps)?)\n note this [THEN DERIV_chain2, derivative_intros]\n \n have \"(P has_field_derivative (\\n. D' (real n + x))) (at x)\"\n unfolding P_def [abs_def]\n proof (rule has_field_derivative_series')\n show \"convex {x/2<..}\" by simp\n next\n fix n :: nat and y :: real assume y: \"y \\ {x/2<..}\"\n with assms have \"y > 0\" by simp\n thus \"((\\a. D (real n + a)) has_real_derivative D' (real n + y)) (at y within {x/2<..})\"\n by (auto intro!: derivative_eq_intros)\n next\n from assms D_summable[of x] show \"summable (\\n. D (real n + x))\" by simp\n next\n show \"uniformly_convergent_on {x/2<..} (\\n x. \\i {x/2<..}\"\n with assms have \"y > 0\" by auto\n have \"norm (D' (real n + y)) = (1 / (2 * (y + real n)^2)) * (1 / (y + real (Suc n))^2)\"\n by (simp add: D'_def add_ac)\n also from y assms have \"\\ \\ (1 / (2 * (x/2)^2)) * (1 / (real (Suc n))^2)\"\n by (intro mult_mono divide_left_mono power_mono) simp_all\n also have \"1 / (real (Suc n))^2 = inverse ((real (Suc n))^2)\" by (simp add: field_simps)\n finally show \"norm (D' (real n + y)) \\ (1 / (2 * (x/2)^2)) * inverse ((real (Suc n))^2)\" .\n next\n show \"summable (\\n. (1 / (2 * (x/2)^2)) * inverse ((real (Suc n))^2))\"\n by (subst summable_Suc_iff, intro summable_mult inverse_power_summable) simp_all\n qed\n qed (insert assms, simp_all add: interior_open)\n thus ?thesis by (rule DERIV_isCont)\nqed\n\nqualified lemma P_continuous_on [THEN continuous_on_subset]: \"continuous_on {0<..} P\"\n by (intro continuous_at_imp_continuous_on ballI isCont_P) auto\n\nqualified lemma P_integrable:\n assumes a: \"a > 0\"\n shows \"P integrable_on {a..}\"\nproof -\n define f where \"f = (\\n x. if x \\ {a..real n} then P x else 0)\"\n show \"P integrable_on {a..}\"\n proof (rule dominated_convergence)\n fix n :: nat\n from a have \"P integrable_on {a..real n}\"\n by (intro integrable_continuous_real P_continuous_on) auto\n hence \"f n integrable_on {a..real n}\"\n by (rule integrable_eq) (simp add: f_def)\n thus \"f n integrable_on {a..}\"\n by (rule integrable_on_superset) (auto simp: f_def)\n next\n fix n :: nat\n show \"norm (f n x) \\ of_real (1/12) * (1 / x^2)\" if \"x \\ {a..}\" for x\n using a P_ge_0 P_upper_bound by (auto simp: f_def)\n next\n show \"(\\x::real. of_real (1/12) * (1 / x^2)) integrable_on {a..}\"\n using has_integral_inverse_power_to_inf[of 2 a] a\n by (intro integrable_on_cmult_left) auto\n next\n show \"(\\n. f n x) \\ P x\" if \"x\\{a..}\" for x\n proof -\n have \"eventually (\\n. real n \\ x) at_top\"\n using filterlim_real_sequentially by (simp add: filterlim_at_top)\n with that not_frequently have \"eventually (\\n. f n x = P x) at_top\"\n by (force simp: f_def)\n thus \"(\\n. f n x) \\ P x\" by (simp add: tendsto_eventually)\n qed\n qed\nqed\n\nqualified definition c :: real where \"c = integral {1..} (\\x. -P x) + g 1\"\n\ntext \\\n We can now give bounds on @{term g}:\n\\\nqualified lemma g_bounds:\n assumes x: \"x \\ 1\"\n shows \"g x \\ {c..c + 1/(12*x)}\"\nproof -\n from assms have int_nonneg: \"integral {x..} P \\ 0\"\n by (intro Henstock_Kurzweil_Integration.integral_nonneg P_integrable)\n (auto simp: P_ge_0)\n have int_upper_bound: \"integral {x..} P \\ 1/(12*x)\"\n proof (rule has_integral_le)\n from x show \"(P has_integral integral {x..} P) {x..}\"\n by (intro integrable_integral P_integrable) simp_all\n from x has_integral_mult_right[OF has_integral_inverse_power_to_inf[of 2 x], of \"1/12\"]\n show \"((\\x. 1/(12*x^2)) has_integral (1/(12*x))) {x..}\" by (simp add: field_simps)\n qed (insert P_upper_bound x, simp_all)\n\n note DERIV_g [THEN DERIV_chain2, derivative_intros]\n from assms have int1: \"((\\x. -P x) has_integral (g x - g 1)) {1..x}\"\n by (intro fundamental_theorem_of_calculus)\n (auto simp: has_real_derivative_iff_has_vector_derivative [symmetric]\n intro!: derivative_eq_intros)\n from x have int2: \"((\\x. -P x) has_integral integral {x..} (\\x. -P x)) {x..}\"\n by (intro integrable_integral integrable_neg P_integrable) simp_all\n from has_integral_Un[OF int1 int2] x\n have \"((\\x. - P x) has_integral g x - g 1 - integral {x..} P) ({1..x} \\ {x..})\"\n by (simp add: max_def)\n also from x have \"{1..x} \\ {x..} = {1..}\" by auto\n finally have \"((\\x. -P x) has_integral g x - g 1 - integral {x..} P) {1..}\" .\n moreover have \"((\\x. -P x) has_integral integral {1..} (\\x. -P x)) {1..}\"\n by (intro integrable_integral integrable_neg P_integrable) simp_all\n ultimately have \"g x - g 1 - integral {x..} P = integral {1..} (\\x. -P x)\"\n by (simp add: has_integral_unique)\n hence \"g x = c + integral {x..} P\" by (simp add: c_def algebra_simps)\n with int_upper_bound int_nonneg show \"g x \\ {c..c + 1/(12*x)}\" by simp\nqed\n\ntext \\\n Finally, we have bounds on @{term ln_Gamma}, @{term Gamma}, and @{term fact}.\n\\\nqualified lemma ln_Gamma_bounds_aux:\n \"x \\ 1 \\ ln_Gamma x \\ c + (x - 1/2) * ln x - x\"\n \"x \\ 1 \\ ln_Gamma x \\ c + (x - 1/2) * ln x - x + 1/(12*x)\"\n using g_bounds[of x] by (simp_all add: g_def)\n\nqualified lemma Gamma_bounds_aux:\n assumes x: \"x \\ 1\"\n shows \"Gamma x \\ exp c * x powr (x - 1/2) / exp x\"\n \"Gamma x \\ exp c * x powr (x - 1/2) / exp x * exp (1/(12*x))\"\nproof -\n have \"exp (ln_Gamma x) \\ exp (c + (x - 1/2) * ln x - x)\"\n by (subst exp_le_cancel_iff, rule ln_Gamma_bounds_aux) (simp add: x)\n with x show \"Gamma x \\ exp c * x powr (x - 1/2) / exp x\"\n by (simp add: Gamma_real_pos_exp exp_add exp_diff powr_def del: exp_le_cancel_iff)\nnext\n have \"exp (ln_Gamma x) \\ exp (c + (x - 1/2) * ln x - x + 1/(12*x))\"\n by (subst exp_le_cancel_iff, rule ln_Gamma_bounds_aux) (simp add: x)\n with x show \"Gamma x \\ exp c * x powr (x - 1/2) / exp x * exp (1/(12*x))\"\n by (simp add: Gamma_real_pos_exp exp_add exp_diff powr_def del: exp_le_cancel_iff)\nqed\n\nqualified lemma Gamma_asymp_equiv_aux: \n \"Gamma \\[at_top] (\\x. exp c * x powr (x - 1/2) / exp x)\"\nproof (rule asymp_equiv_sandwich)\n include asymp_equiv_syntax\n show \"eventually (\\x. exp c * x powr (x - 1/2) / exp x \\ Gamma x) at_top\"\n \"eventually (\\x. exp c * x powr (x - 1/2) / exp x * exp (1/(12*x)) \\ Gamma x) at_top\"\n using eventually_ge_at_top[of \"1::real\"]\n by (eventually_elim; use Gamma_bounds_aux in force)+\n have \"((\\x::real. exp (1 / (12 * x))) \\ exp 0) at_top\"\n by real_asymp\n hence \"(\\x. exp (1 / (12 * x))) \\ (\\x. 1 :: real)\"\n by (intro asymp_equivI') simp_all\n hence \"(\\x. exp c * x powr (x - 1 / 2) / exp x * 1) \\\n (\\x. exp c * x powr (x - 1 / 2) / exp x * exp (1 / (12 * x)))\"\n by (intro asymp_equiv_mult asymp_equiv_refl) (simp add: asymp_equiv_sym)\n thus \"(\\x. exp c * x powr (x - 1 / 2) / exp x) \\\n (\\x. exp c * x powr (x - 1 / 2) / exp x * exp (1 / (12 * x)))\" by simp\nqed simp_all\n\nqualified lemma exp_1_powr_real [simp]: \"exp (1::real) powr x = exp x\"\n by (simp add: powr_def)\n\nqualified lemma fact_asymp_equiv_aux:\n \"fact \\[at_top] (\\x. exp c * sqrt (real x) * (real x / exp 1) powr real x)\"\nproof -\n include asymp_equiv_syntax\n have \"fact \\ (\\n. Gamma (real (Suc n)))\" by (simp add: Gamma_fact)\n also have \"eventually (\\n. Gamma (real (Suc n)) = real n * Gamma (real n)) at_top\"\n using eventually_gt_at_top[of \"0::nat\"]\n by eventually_elim (insert Gamma_plus1[of \"real n\" for n], \n auto simp: add_ac of_nat_in_nonpos_Ints_iff)\n also have \"(\\n. Gamma (real n)) \\ (\\n. exp c * real n powr (real n - 1/2) / exp (real n))\"\n by (rule asymp_equiv_compose'[OF Gamma_asymp_equiv_aux] filterlim_real_sequentially)+\n also have \"eventually (\\n. real n * (exp c * real n powr (real n - 1 / 2) / exp (real n)) =\n exp c * sqrt (real n) * (real n / exp 1) powr real n) at_top\"\n using eventually_gt_at_top[of \"0::nat\"]\n proof eventually_elim\n fix n :: nat assume n: \"n > 0\"\n thus \"real n * (exp c * real n powr (real n - 1 / 2) / exp (real n)) =\n exp c * sqrt (real n) * (real n / exp 1) powr real n\"\n by (subst powr_diff) (simp_all add: powr_divide powr_half_sqrt field_simps)\n qed\n finally show ?thesis by - (simp_all add: asymp_equiv_mult)\nqed\n\ntext \\\n We cal also bound @{term Digamma} above and below.\n\\\n \nlemma Digamma_plus_1_gt_ln:\n assumes x: \"x > (0 :: real)\"\n shows \"Digamma (x + 1) > ln x\"\n by sorry\n\nlemma Digamma_less_ln:\n assumes x: \"x > (0 :: real)\"\n shows \"Digamma x < ln x\"\n by sorry\n\ntext \\\n We still need to determine the constant term @{term c}, which we do using Wallis' \n product formula: $$\\prod_{n=1}^\\infty \\frac{4n^2}{4n^2-1} = \\frac{\\pi}{2}$$\n\\\nqualified lemma powr_mult_2: \"(x::real) > 0 \\ x powr (y * 2) = (x^2) powr y\"\n by (subst mult.commute, subst powr_powr [symmetric]) (simp add: powr_numeral)\n\nqualified lemma exp_mult_2: \"exp (y * 2 :: real) = exp y * exp y\"\n by (subst exp_add [symmetric]) simp\n\nqualified lemma exp_c: \"exp c = sqrt (2*pi)\"\nproof -\n include asymp_equiv_syntax\n define p where \"p = (\\n. \\k=1..n. (4*real k^2) / (4*real k^2 - 1))\"\n\n have p_0 [simp]: \"p 0 = 1\" by (simp add: p_def)\n have p_Suc: \"p (Suc n) = p n * (4 * real (Suc n)^2) / (4 * real (Suc n)^2 - 1)\"\n for n unfolding p_def by (subst prod.nat_ivl_Suc') simp_all\n have p: \"p = (\\n. 16 ^ n * fact n ^ 4 / (fact (2 * n))\\<^sup>2 / (2 * real n + 1))\"\n proof\n fix n :: nat\n have \"p n = (\\k=1..n. (2*real k)^2 / (2*real k - 1) / (2 * real k + 1))\"\n unfolding p_def by (intro prod.cong refl) (simp add: field_simps power2_eq_square)\n also have \"\\ = (\\k=1..n. (2*real k)^2 / (2*real k - 1)) / (\\k=1..n. (2 * real (Suc k) - 1))\"\n by (simp add: prod_dividef prod.distrib add_ac)\n also have \"(\\k=1..n. (2 * real (Suc k) - 1)) = (\\k=Suc 1..Suc n. (2 * real k - 1))\"\n by (subst prod.atLeast_Suc_atMost_Suc_shift) simp_all\n also have \"\\ = (\\k=1..n. (2 * real k - 1)) * (2 * real n + 1)\"\n by (induction n) (simp_all add: prod.nat_ivl_Suc')\n also have \"(\\k = 1..n. (2 * real k)\\<^sup>2 / (2 * real k - 1)) / \\ =\n (\\k = 1..n. (2 * real k)^2 / (2 * real k - 1)^2) / (2 * real n + 1)\"\n unfolding power2_eq_square by (simp add: prod.distrib prod_dividef)\n also have \"(\\k = 1..n. (2 * real k)^2 / (2 * real k - 1)^2) =\n (\\k = 1..n. (2 * real k)^4 / ((2*real k)*(2 * real k - 1))^2)\"\n by (rule prod.cong) (simp_all add: power2_eq_square eval_nat_numeral)\n also have \"\\ = 16^n * fact n^4 / (\\k=1..n. (2*real k) * (2*real k - 1))^2\"\n by (simp add: prod.distrib prod_dividef fact_prod\n prod_power_distrib [symmetric] prod_constant)\n also have \"(\\k=1..n. (2*real k) * (2*real k - 1)) = fact (2*n)\"\n by (induction n) (simp_all add: algebra_simps prod.nat_ivl_Suc')\n finally show \"p n = 16 ^ n * fact n ^ 4 / (fact (2 * n))\\<^sup>2 / (2 * real n + 1)\" .\n qed\n\n have \"p \\ (\\n. 16 ^ n * fact n ^ 4 / (fact (2 * n))\\<^sup>2 / (2 * real n + 1))\"\n by (simp add: p)\n also have \"\\ \\ (\\n. 16^n * (exp c * sqrt (real n) * (real n / exp 1) powr real n)^4 /\n (exp c * sqrt (real (2*n)) * (real (2*n) / exp 1) powr real (2*n))^2 /\n (2 * real n + 1))\" (is \"_ \\ ?f\")\n by (intro asymp_equiv_mult asymp_equiv_divide asymp_equiv_refl mult_nat_left_at_top\n fact_asymp_equiv_aux asymp_equiv_power asymp_equiv_compose'[OF fact_asymp_equiv_aux]) \n simp_all\n also have \"eventually (\\n. \\ n = exp c ^ 2 / (4 + 2/n)) at_top\"\n using eventually_gt_at_top[of \"0::nat\"]\n proof eventually_elim\n fix n :: nat assume n: \"n > 0\"\n have [simp]: \"16^n = 4^n * (4^n :: real)\" by (simp add: power_mult_distrib [symmetric])\n from n have \"?f n = exp c ^ 2 * (n / (2*(2*n+1)))\"\n by (simp add: power_mult_distrib divide_simps powr_mult real_sqrt_power_even)\n (simp add: field_simps power2_eq_square eval_nat_numeral powr_mult_2 \n exp_mult_2 powr_realpow)\n also from n have \"\\ = exp c ^ 2 / (4 + 2/n)\" by (simp add: field_simps)\n finally show \"?f n = \\\" .\n qed\n also have \"(\\x. 4 + 2 / real x) \\ (\\x. 4)\"\n by (subst asymp_equiv_add_right) auto\n finally have \"p \\ exp c ^ 2 / 4\" \n by (rule asymp_equivD_const) (simp_all add: asymp_equiv_divide)\n moreover have \"p \\ pi / 2\" unfolding p_def by (rule wallis)\n ultimately have \"exp c ^ 2 / 4 = pi / 2\" by (rule LIMSEQ_unique)\n hence \"2 * pi = exp c ^ 2\" by simp\n also have \"sqrt (exp c ^ 2) = exp c\" by simp\n finally show \"exp c = sqrt (2 * pi)\" ..\nqed\n\nqualified lemma c: \"c = ln (2*pi) / 2\"\nproof -\n note exp_c [symmetric]\n also have \"ln (exp c) = c\" by simp\n finally show ?thesis by (simp add: ln_sqrt)\nqed\n\ntext \\\n This gives us the final bounds:\n\\\ntheorem Gamma_bounds:\n assumes \"x \\ 1\"\n shows \"Gamma x \\ sqrt (2*pi/x) * (x / exp 1) powr x\" (is ?th1)\n \"Gamma x \\ sqrt (2*pi/x) * (x / exp 1) powr x * exp (1 / (12 * x))\" (is ?th2)\n by sorry\n\ntheorem ln_Gamma_bounds:\n assumes \"x \\ 1\"\n shows \"ln_Gamma x \\ ln (2*pi/x) / 2 + x * ln x - x\" (is ?th1)\n \"ln_Gamma x \\ ln (2*pi/x) / 2 + x * ln x - x + 1/(12*x)\" (is ?th2)\n by sorry\n\ntheorem fact_bounds:\n assumes \"n > 0\"\n shows \"(fact n :: real) \\ sqrt (2*pi*n) * (n / exp 1) ^ n\" (is ?th1)\n \"(fact n :: real) \\ sqrt (2*pi*n) * (n / exp 1) ^ n * exp (1 / (12 * n))\" (is ?th2)\n by sorry\n\ntheorem ln_fact_bounds:\n assumes \"n > 0\"\n shows \"ln (fact n :: real) \\ ln (2*pi*n)/2 + n * ln n - n\" (is ?th1)\n \"ln (fact n :: real) \\ ln (2*pi*n)/2 + n * ln n - n + 1/(12*real n)\" (is ?th2)\n by sorry\n\ntheorem Gamma_asymp_equiv: \n \"Gamma \\[at_top] (\\x. sqrt (2*pi/x) * (x / exp 1) powr x :: real)\"\n by sorry\n\ntheorem fact_asymp_equiv: \n \"fact \\[at_top] (\\n. sqrt (2*pi*n) * (n / exp 1) ^ n :: real)\"\n by sorry\n\ncorollary stirling_tendsto_sqrt_pi:\n \"(\\n. fact n / (sqrt (2 * n) * (n / exp 1) ^ n)) \\ sqrt pi\"\n by sorry\n\nend\n\nend" }, { "theorem_id": 67, "title": "090_stirling_s_formula", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2022 Moritz Firsching. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Moritz Firsching, Fabian Kruse, Nikolas Kuhn\n-/\nmodule\n\npublic import Mathlib.Analysis.PSeries\npublic import Mathlib.Analysis.Real.Pi.Wallis\npublic import Mathlib.Tactic.AdaptationNote\n\n/-!\n# Stirling's formula\n\nThis file proves Stirling's formula for the factorial.\nIt states that $n!$ grows asymptotically like $\\sqrt{2\\pi n}(\\frac{n}{e})^n$.\n\nAlso some _global_ bounds on the factorial function and the Stirling sequence are proved.\n\n## Proof outline\n\nThe proof follows: .\n\nWe proceed in two parts.\n\n**Part 1**: We consider the sequence $a_n$ of fractions $\\frac{n!}{\\sqrt{2n}(\\frac{n}{e})^n}$\nand prove that this sequence converges to a real, positive number $a$. For this the two main\ningredients are\n- taking the logarithm of the sequence and\n- using the series expansion of $\\log(1 + x)$.\n\n**Part 2**: We use the fact that the series defined in part 1 converges against a real number $a$\nand prove that $a = \\sqrt{\\pi}$. Here the main ingredient is the convergence of Wallis' product\nformula for `π`.\n-/\n\n@[expose] public section\n\n\nopen scoped Topology Real Nat Asymptotics\n\nopen Nat hiding log log_pow\nopen Finset Filter Real\n\nnamespace Stirling\n\n/-!\n### Part 1\nhttps://proofwiki.org/wiki/Stirling%27s_Formula#Part_1\n-/\n\n\n/-- Define `stirlingSeq n` as $\\frac{n!}{\\sqrt{2n}(\\frac{n}{e})^n}$.\nStirling's formula states that this sequence has limit $\\sqrt(π)$.\n-/\nnoncomputable def stirlingSeq (n : ℕ) : ℝ :=\n n ! / (√(2 * n : ℝ) * (n / exp 1) ^ n)\n\n@[simp]\ntheorem stirlingSeq_zero : stirlingSeq 0 = 0 := by sorry\ntheorem stirlingSeq_one : stirlingSeq 1 = exp 1 / √2 := by sorry\ntheorem log_stirlingSeq_formula (n : ℕ) :\n log (stirlingSeq n) = Real.log n ! - 1 / 2 * Real.log (2 * n) - n * log (n / exp 1) := by sorry\ntheorem log_stirlingSeq_diff_hasSum (m : ℕ) :\n HasSum (fun k : ℕ => (1 : ℝ) / (2 * ↑(k + 1) + 1) * ((1 / (2 * ↑(m + 1) + 1)) ^ 2) ^ ↑(k + 1))\n (log (stirlingSeq (m + 1)) - log (stirlingSeq (m + 2))) := by sorry\ntheorem log_stirlingSeq'_antitone : Antitone (Real.log ∘ stirlingSeq ∘ succ) :=\n antitone_nat_of_succ_le fun n =>\n sub_nonneg.mp <| (log_stirlingSeq_diff_hasSum n).nonneg fun m => by positivity\n\n/-- We have a bound for successive elements in the sequence `log (stirlingSeq k)`. -/\n@[deprecated \"Use `log_stirlingSeq_diff_le` instead.\" (since := \"2026-03-16\")]\ntheorem log_stirlingSeq_diff_le_geo_sum (n : ℕ) :\n log (stirlingSeq (n + 1)) - log (stirlingSeq (n + 2)) ≤\n ((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2 / (1 - ((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2) := by sorry\ntheorem log_stirlingSeq_diff_le (n : ℕ) :\n log (stirlingSeq n) - log (stirlingSeq (n + 1)) ≤ 1 / (12 * n * (n + 1)) := by sorry\ntheorem log_stirlingSeq_sub_log_stirlingSeq_succ (n : ℕ) :\n log (stirlingSeq n) - log (stirlingSeq (n + 1)) ≤ 1 / (4 * n ^ 2) := by sorry\ntheorem log_stirlingSeq_bounded_aux (n : ℕ) :\n log (stirlingSeq 1) - log (stirlingSeq (n + 1)) ≤ 12⁻¹ := by sorry\ntheorem log_stirlingSeq_bounded_by_constant (n : ℕ) :\n 1 - 12⁻¹ - log 2 / 2 ≤ log (stirlingSeq (n + 1)) := by sorry\ntheorem stirlingSeq'_pos (n : ℕ) : 0 < stirlingSeq (n + 1) := by unfold stirlingSeq; positivity\n\n/-- The sequence `stirlingSeq` has a positive lower bound. -/\ntheorem stirlingSeq'_bounded_by_pos_constant : ∃ a, 0 < a ∧ ∀ n : ℕ, a ≤ stirlingSeq (n + 1) := by sorry\ntheorem stirlingSeq'_antitone : Antitone (stirlingSeq ∘ succ) := fun n m h =>\n (log_le_log_iff (stirlingSeq'_pos m) (stirlingSeq'_pos n)).mp (log_stirlingSeq'_antitone h)\n\n/-- The limit `a` of the sequence `stirlingSeq` satisfies `0 < a` -/\ntheorem stirlingSeq_has_pos_limit_a : ∃ a : ℝ, 0 < a ∧ Tendsto stirlingSeq atTop (𝓝 a) := by sorry\ntheorem tendsto_self_div_two_mul_self_add_one :\n Tendsto (fun n : ℕ => (n : ℝ) / (2 * n + 1)) atTop (𝓝 (1 / 2)) := by sorry\ntheorem stirlingSeq_pow_four_div_stirlingSeq_pow_two_eq (n : ℕ) (hn : n ≠ 0) :\n stirlingSeq n ^ 4 / stirlingSeq (2 * n) ^ 2 * (n / (2 * n + 1)) = Wallis.W n := by sorry\ntheorem second_wallis_limit (a : ℝ) (hane : a ≠ 0) (ha : Tendsto stirlingSeq atTop (𝓝 a)) :\n Tendsto Wallis.W atTop (𝓝 (a ^ 2 / 2)) := by sorry\ntheorem tendsto_stirlingSeq_sqrt_pi : Tendsto stirlingSeq atTop (𝓝 (√π)) := by sorry\nlemma factorial_isEquivalent_stirling :\n (fun n ↦ n ! : ℕ → ℝ) ~[atTop] fun n ↦ Real.sqrt (2 * n * π) * (n / exp 1) ^ n := by sorry\ntheorem sqrt_pi_le_stirlingSeq {n : ℕ} (hn : n ≠ 0) : √π ≤ stirlingSeq n :=\n match n, hn with := by sorry\ntheorem le_factorial_stirling (n : ℕ) : √(2 * π * n) * (n / exp 1) ^ n ≤ n ! := by sorry\ntheorem le_log_factorial_stirling {n : ℕ} (hn : n ≠ 0) :\n n * log n - n + log n / 2 + log (2 * π) / 2 ≤ log n ! := by sorry\nend Stirling\n" }, { "theorem_id": 67, "title": "090_stirling_s_formula", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Rsequence_facts.\nRequire Import Rseries_def.\nRequire Import Rseries_facts.\nRequire Import Rseries_usual.\nRequire Import Rpser.\nRequire Import Rintegral.\nRequire Import RTaylor.\nRequire Import Lia.\nRequire Import Lra.\nRequire Import Wallis.\nOpen Scope R_scope.\n\nSection De_Moivre.\n\nLet Un n := (INR n) ^ n * exp (- (INR n)) * sqrt (INR n) / Rseq_fact n.\n\nLet Vn n :=\nmatch n with\n| 0 => 0\n| _ => ln (Un (S n) / Un n)\nend.\n\nHint Resolve lt_0_INR : stirling.\nHint Resolve sqrt_lt_R0 : stirling.\nHint Resolve exp_pos : stirling.\nHint Resolve lt_O_fact : stirling.\nHint Resolve pow_lt : stirling.\nHint Resolve Rmult_lt_0_compat : stirling.\nHint Resolve Rinv_0_lt_compat : stirling.\nHint Resolve Rgt_not_eq : stirling.\n\nLemma Vn_O : Vn 0 = 0.\nProof.\nAdmitted.\n\nLemma Vn_S : forall n, (0 < n)%nat -> Vn n = ln (Un (S n) / Un n).\nProof.\nAdmitted.\n\nLemma ln_pow : forall r n, 0 < r -> ln (r ^ n) = INR n * ln r.\nProof.\nAdmitted.\n\nLemma ln_sqrt : forall r, 0 < r -> ln (sqrt r) = ln r / 2.\nProof.\nAdmitted.\n\nLemma Un_pos : forall n, (0 < n)%nat -> 0 < Un n.\nProof.\nAdmitted.\n\nLemma Vn_simpl :\n forall n, (0 < n)%nat -> Vn n = (INR n + / 2) * ln (1 + / INR n) - 1.\nProof.\nAdmitted.\n\nLet Tn n :=\nmatch n with\n| 0 => 0 \n| _ => (- 1) ^ (S n) / (INR n)\nend.\n\nLet Rn n := (/ INR n + - / 2 * (/ INR n) ^ 2 + / 3 * (/ INR n) ^ 3).\n\nLet Sn n := ln (1 + / INR n) - Rn n.\n\nLet Qn d n := Rseq_inv_poly d n.\n\nLemma Qn_S : forall d n, (0 < n)%nat -> Qn d n = (/ INR n) ^ d.\nProof.\nAdmitted.\nLemma ln_taylor_3 : Sn = O(Qn 4).\nProof.\nAdmitted.\n\nLemma Vn_maj : Vn = O(Qn 2).\nProof.\nAdmitted.\n\nLemma Rser_cv_Riemann : {l | Rser_abs_cv (Qn 2) l}.\nProof.\nAdmitted.\n\nLemma Rser_cv_Vn : {l | Rser_cv Vn l}.\nProof.\nAdmitted.\n\nLemma Vn_ser_eq : forall n, sum_f_R0 Vn n = ln (Un (S n)) - ln (Un 1).\nProof.\nAdmitted.\n\nLemma Un_cv : {l | Rseq_cv Un l & 0 < l}.\nProof.\nAdmitted.\n\nLemma De_Moivre_equiv : {C | Rseq_fact ~ (fun n => C * (INR n) ^ n * exp (- (INR n)) * sqrt (INR n)) & 0 < C}.\nProof.\nAdmitted.\n\nEnd De_Moivre.\n\nLemma exp_pow x n : (exp x) ^ n = exp (x* (INR n)).\nProof.\nAdmitted.\n\nSection Stirling.\n\nLocal Coercion INR : nat >-> R.\n\nLemma Stirling_equiv : Rseq_fact ~ (fun n => sqrt (2 * PI) * (INR n) ^ n * exp (- (INR n)) * sqrt (INR n)).\nProof.\nAdmitted.\n\nEnd Stirling." }, { "theorem_id": 68, "title": "091_the_triangle_inequality", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/matroids.ml\";;\nneeds \"Multivariate/misc.ml\";;\n\nlet FORALL_1 = `(!i. 1 <= i /\\ i <= 1 ==> P i) <=> P 1`;;\n\nlet FORALL_2 = `!P. (!i. 1 <= i /\\ i <= 2 ==> P i) <=> P 1 /\\ P 2`;;\n\nlet FORALL_3 = `!P. (!i. 1 <= i /\\ i <= 3 ==> P i) <=> P 1 /\\ P 2 /\\ P 3`;;\n\nlet FORALL_4 = `!P. (!i. 1 <= i /\\ i <= 4 ==> P i) <=> P 1 /\\ P 2 /\\ P 3 /\\ P 4`;;\n\nlet SUM_1 = `sum(1..1) f = f(1)`;;\n\nlet SUM_2 = `!t. sum(1..2) t = t(1) + t(2)`;;\n\nlet SUM_3 = `!t. sum(1..3) t = t(1) + t(2) + t(3)`;;\n\nlet SUM_4 = `!t. sum(1..4) t = t(1) + t(2) + t(3) + t(4)`;;\n\nlet vector_add = new_definition\n `(vector_add:real^N->real^N->real^N) x y = lambda i. x$i + y$i`;;\n\nlet vector_sub = new_definition\n `(vector_sub:real^N->real^N->real^N) x y = lambda i. x$i - y$i`;;\n\nlet vector_neg = new_definition\n `(vector_neg:real^N->real^N) x = lambda i. --(x$i)`;;\n\noverload_interface (\"+\",`(vector_add):real^N->real^N->real^N`);;\noverload_interface (\"-\",`(vector_sub):real^N->real^N->real^N`);;\noverload_interface (\"--\",`(vector_neg):real^N->real^N`);;\n\nprioritize_real();;\n\nlet prioritize_vector = let ty = `:real^N` in\n fun () -> prioritize_overload ty;;\n\nparse_as_infix(\"%\",(21,\"right\"));;\n\nlet vector_mul = new_definition\n `((%):real->real^N->real^N) c x = lambda i. c * x$i`;;\n\nlet vec = new_definition\n `(vec:num->real^N) n = lambda i. &n`;;\n\nparse_as_infix(\"dot\",(20,\"right\"));;\n\nlet dot = new_definition\n `(x:real^N) dot (y:real^N) = sum(1..dimindex(:N)) (\\i. x$i * y$i)`;;\n\nlet DOT_1 = `(x:real^1) dot (y:real^1) = x$1 * y$1`;;\n\nlet DOT_2 = `(x:real^2) dot (y:real^2) = x$1 * y$1 + x$2 * y$2`;;\n\nlet DOT_3 = `(x:real^3) dot (y:real^3) = x$1 * y$1 + x$2 * y$2 + x$3 * y$3`;;\n\nlet DOT_4 = `(x:real^4) dot (y:real^4) = x$1 * y$1 + x$2 * y$2 + x$3 * y$3 + x$4 * y$4`;;\n\nlet VECTOR_ARITH_TAC =\n let RENAMED_LAMBDA_BETA th =\n if fst(dest_fun_ty(type_of(funpow 3 rand (concl th)))) = aty\n then INST_TYPE [aty,bty; bty,aty] LAMBDA_BETA else LAMBDA_BETA in\n POP_ASSUM_LIST(K ALL_TAC) THEN\n REPEAT(GEN_TAC ORELSE CONJ_TAC ORELSE DISCH_TAC ORELSE EQ_TAC) THEN\n REPEAT(POP_ASSUM MP_TAC) THEN REWRITE_TAC[IMP_IMP; GSYM CONJ_ASSOC] THEN\n REWRITE_TAC[dot; GSYM SUM_ADD_NUMSEG; GSYM SUM_SUB_NUMSEG;\n GSYM SUM_LMUL; GSYM SUM_RMUL; GSYM SUM_NEG] THEN\n (MATCH_MP_TAC SUM_EQ_NUMSEG ORELSE MATCH_MP_TAC SUM_EQ_0_NUMSEG ORELSE\n GEN_REWRITE_TAC ONCE_DEPTH_CONV [CART_EQ]) THEN\n REWRITE_TAC[AND_FORALL_THM] THEN TRY EQ_TAC THEN\n TRY(MATCH_MP_TAC MONO_FORALL) THEN GEN_TAC THEN\n REWRITE_TAC[TAUT `(a ==> b) /\\ (a ==> c) <=> a ==> b /\\ c`;\n TAUT `(a ==> b) \\/ (a ==> c) <=> a ==> b \\/ c`] THEN\n TRY(MATCH_MP_TAC(TAUT `(a ==> b ==> c) ==> (a ==> b) ==> (a ==> c)`)) THEN\n REWRITE_TAC[vector_add; vector_sub; vector_neg; vector_mul; vec] THEN\n DISCH_THEN(fun th -> REWRITE_TAC[MATCH_MP(RENAMED_LAMBDA_BETA th) th]) THEN\n REAL_ARITH_TAC;;\n\nlet VECTOR_ARITH tm = prove(tm,VECTOR_ARITH_TAC);;\n\nlet VEC_COMPONENT = `!k i. (vec k :real^N)$i = &k`;;\n\nlet VECTOR_ADD_COMPONENT = `!x:real^N y i. (x + y)$i = x$i + y$i`;;\n\nlet VECTOR_SUB_COMPONENT = `!x:real^N y i. (x - y)$i = x$i - y$i`;;\n\nlet VECTOR_NEG_COMPONENT = `!x:real^N i. (--x)$i = --(x$i)`;;\n\nlet VECTOR_MUL_COMPONENT = `!c x:real^N i. (c % x)$i = c * x$i`;;\n\nlet COND_COMPONENT = `(if b then x else y)$i = if b then x$i else y$i`;;\n\nlet VECTOR_ADD_SYM = VECTOR_ARITH `!x y:real^N. x + y = y + x`;;\n\nlet VECTOR_ADD_LID = VECTOR_ARITH `!x. vec 0 + x = x`;;\n\nlet VECTOR_ADD_RID = VECTOR_ARITH `!x. x + vec 0 = x`;;\n\nlet VECTOR_SUB_REFL = VECTOR_ARITH `!x. x - x = vec 0`;;\n\nlet VECTOR_ADD_LINV = VECTOR_ARITH `!x. --x + x = vec 0`;;\n\nlet VECTOR_ADD_RINV = VECTOR_ARITH `!x. x + --x = vec 0`;;\n\nlet VECTOR_SUB_RADD = VECTOR_ARITH `!x y. x - (x + y) = --y:real^N`;;\n\nlet VECTOR_NEG_SUB = VECTOR_ARITH `!x:real^N y. --(x - y) = y - x`;;\n\nlet VECTOR_SUB_EQ = VECTOR_ARITH `!x y. (x - y = vec 0) <=> (x = y)`;;\n\nlet VECTOR_MUL_ASSOC = VECTOR_ARITH `!a b x. a % (b % x) = (a * b) % x`;;\n\nlet VECTOR_MUL_LID = VECTOR_ARITH `!x. &1 % x = x`;;\n\nlet VECTOR_MUL_LZERO = VECTOR_ARITH `!x. &0 % x = vec 0`;;\n\nlet VECTOR_SUB_ADD = VECTOR_ARITH `(x - y) + y = x:real^N`;;\n\nlet VECTOR_SUB_ADD2 = VECTOR_ARITH `y + (x - y) = x:real^N`;;\n\nlet VECTOR_ADD_LDISTRIB = VECTOR_ARITH `c % (x + y) = c % x + c % y`;;\n\nlet VECTOR_SUB_LDISTRIB = VECTOR_ARITH `c % (x - y) = c % x - c % y`;;\n\nlet VECTOR_ADD_RDISTRIB = VECTOR_ARITH `(a + b) % x = a % x + b % x`;;\n\nlet VECTOR_SUB_RDISTRIB = VECTOR_ARITH `(a - b) % x = a % x - b % x`;;\n\nlet VECTOR_ADD_SUB = VECTOR_ARITH `(x + y:real^N) - x = y`;;\n\nlet VECTOR_EQ_ADDR = VECTOR_ARITH `(x + y = x) <=> (y = vec 0)`;;\n\nlet VECTOR_SUB = VECTOR_ARITH `x - y = x + --(y:real^N)`;;\n\nlet VECTOR_SUB_RZERO = VECTOR_ARITH `x - vec 0 = x`;;\n\nlet VECTOR_MUL_RZERO = VECTOR_ARITH `c % vec 0 = vec 0`;;\n\nlet VECTOR_NEG_MINUS1 = VECTOR_ARITH `--x = (--(&1)) % x`;;\n\nlet VECTOR_ADD_ASSOC = VECTOR_ARITH `(x:real^N) + y + z = (x + y) + z`;;\n\nlet VECTOR_SUB_LZERO = VECTOR_ARITH `vec 0 - x = --x`;;\n\nlet VECTOR_NEG_NEG = VECTOR_ARITH `--(--(x:real^N)) = x`;;\n\nlet VECTOR_MUL_LNEG = VECTOR_ARITH `--c % x = --(c % x)`;;\n\nlet VECTOR_MUL_RNEG = VECTOR_ARITH `c % --x = --(c % x)`;;\n\nlet VECTOR_NEG_0 = VECTOR_ARITH `--(vec 0) = vec 0`;;\n\nlet VECTOR_NEG_EQ_0 = VECTOR_ARITH `--x = vec 0 <=> x = vec 0`;;\n\nlet VECTOR_EQ_NEG2 = VECTOR_ARITH `!x y:real^N. --x = --y <=> x = y`;;\n\nlet VECTOR_ADD_AC = VECTOR_ARITH\n `(m + n = n + m:real^N) /\\\n ((m + n) + p = m + n + p) /\\\n (m + n + p = n + m + p)`;;\n\nlet VEC_EQ = `!m n. (vec m = vec n) <=> (m = n)`;;\n\nlet SUMS_SYM = `!s t:real^N->bool.\n {x + y | x IN s /\\ y IN t} = {y + x | y IN t /\\ x IN s}`;;\n\nlet SUMS_ASSOC = `!s t u:real^N->bool.\n {w + z | w IN {x + y | x IN s /\\ y IN t} /\\ z IN u} =\n {x + v | x IN s /\\ v IN {y + z | y IN t /\\ z IN u}}`;;\n\nlet EUCLIDEAN_SPACE_INFINITE = `INFINITE(:real^N)`;;\n\nlet DOT_SYM = VECTOR_ARITH `!x y. x dot y = y dot x`;;\n\nlet DOT_LADD = VECTOR_ARITH `!x y z. (x + y) dot z = (x dot z) + (y dot z)`;;\n\nlet DOT_RADD = VECTOR_ARITH `!x y z. x dot (y + z) = (x dot y) + (x dot z)`;;\n\nlet DOT_LSUB = VECTOR_ARITH `!x y z. (x - y) dot z = (x dot z) - (y dot z)`;;\n\nlet DOT_RSUB = VECTOR_ARITH `!x y z. x dot (y - z) = (x dot y) - (x dot z)`;;\n\nlet DOT_LMUL = VECTOR_ARITH `!c x y. (c % x) dot y = c * (x dot y)`;;\n\nlet DOT_RMUL = VECTOR_ARITH `!c x y. x dot (c % y) = c * (x dot y)`;;\n\nlet DOT_LNEG = VECTOR_ARITH `!x y. (--x) dot y = --(x dot y)`;;\n\nlet DOT_RNEG = VECTOR_ARITH `!x y. x dot (--y) = --(x dot y)`;;\n\nlet DOT_LZERO = VECTOR_ARITH `!x. (vec 0) dot x = &0`;;\n\nlet DOT_RZERO = VECTOR_ARITH `!x. x dot (vec 0) = &0`;;\n\nlet DOT_POS_LE = `!x. &0 <= x dot x`;;\n\nlet DOT_EQ_0 = `!x:real^N. ((x dot x = &0) <=> (x = vec 0))`;;\n\nlet DOT_POS_LT = `!x. (&0 < x dot x) <=> ~(x = vec 0)`;;\n\nlet FORALL_DOT_EQ_0 = `(!y. (!x. x dot y = &0) <=> y = vec 0) /\\\n (!x. (!y. x dot y = &0) <=> x = vec 0)`;;\n\nlet REFLECT_UNIV = `IMAGE (--) (:real^N) = (:real^N)`;;\n\nlet TRANSLATION_UNIV = `!a. IMAGE (\\x. a + x) (:real^N) = (:real^N)`;;\n\nlet TRANSLATION_SUBSET_GALOIS_RIGHT = `!s t a:real^N.\n s SUBSET IMAGE (\\x. a + x) t <=> IMAGE (\\x. --a + x) s SUBSET t`;;\n\nlet TRANSLATION_SUBSET_GALOIS_LEFT = `!s t a:real^N.\n IMAGE (\\x. a + x) s SUBSET t <=> s SUBSET IMAGE (\\x. --a + x) t`;;\n\nlet TRANSLATION_GALOIS = `!s t a:real^N. s = IMAGE (\\x. a + x) t <=> t = IMAGE (\\x. --a + x) s`;;\n\nlet IN_TRANSLATION_GALOIS = `!s a b:real^N. b IN IMAGE (\\x. a + x) s <=> (b - a) IN s`;;\n\nlet IN_TRANSLATION_GALOIS_ALT = `!s a b:real^N. (a + b) IN s <=> b IN IMAGE (\\x. --a + x) s`;;\n\nlet FORALL_DIMINDEX_1 = `(!i. 1 <= i /\\ i <= dimindex(:1) ==> P i) <=> P 1`;;\n\nlet VECTOR_ONE = `!x:real^1. x = lambda i. x$1`;;\n\nlet FORALL_REAL_ONE = `(!x:real^1. P x) <=> (!x. P(lambda i. x))`;;\n\nmake_overloadable \"norm\" `:A->real`;;\noverload_interface(\"norm\",`vector_norm:real^N->real`);;\n\nlet vector_norm = new_definition\n `norm x = sqrt(x dot x)`;;\n\noverride_interface(\"dist\",`distance:real^N#real^N->real`);;\n\nlet dist = new_definition\n `dist(x,y) = norm(x - y)`;;\n\nlet NORM_REAL = `!x:real^1. norm(x) = abs(x$1)`;;\n\nlet DIST_REAL = `!x:real^1 y. dist(x,y) = abs(x$1 - y$1)`;;\n\nlet NORM_0 = `norm(vec 0) = &0`;;\n\nlet NORM_POS_LE = `!x. &0 <= norm x`;;\n\nlet NORM_NEG = `!x. norm(--x) = norm x`;;\n\nlet NORM_SUB = `!x y. norm(x - y) = norm(y - x)`;;\n\nlet NORM_MUL = `!a x. norm(a % x) = abs(a) * norm x`;;\n\nlet NORM_EQ_0_DOT = `!x. (norm x = &0) <=> (x dot x = &0)`;;\n\nlet NORM_EQ_0 = `!x. (norm x = &0) <=> (x = vec 0)`;;\n\nlet NORM_POS_LT = `!x. &0 < norm x <=> ~(x = vec 0)`;;\n\nlet NORM_POW_2 = `!x. norm(x) pow 2 = x dot x`;;\n\nlet NORM_EQ_0_IMP = `!x. (norm x = &0) ==> (x = vec 0)`;;\n\nlet NORM_LE_0 = `!x. norm x <= &0 <=> (x = vec 0)`;;\n\nlet VECTOR_MUL_EQ_0 = `!a x. (a % x = vec 0) <=> (a = &0) \\/ (x = vec 0)`;;\n\nlet VECTOR_MUL_LCANCEL = `!a x y. (a % x = a % y) <=> (a = &0) \\/ (x = y)`;;\n\nlet VECTOR_MUL_RCANCEL = `!a b x. (a % x = b % x) <=> (a = b) \\/ (x = vec 0)`;;\n\nlet VECTOR_MUL_LCANCEL_IMP = `!a x y. ~(a = &0) /\\ (a % x = a % y) ==> (x = y)`;;\n\nlet VECTOR_MUL_RCANCEL_IMP = `!a b x. ~(x = vec 0) /\\ (a % x = b % x) ==> (a = b)`;;\n\nlet NORM_CAUCHY_SCHWARZ = `!(x:real^N) y. x dot y <= norm(x) * norm(y)`;;\n\nlet NORM_CAUCHY_SCHWARZ_ABS = `!x:real^N y. abs(x dot y) <= norm(x) * norm(y)`;;\n\nlet REAL_ABS_NORM = `!x. abs(norm x) = norm x`;;\n\nlet NORM_CAUCHY_SCHWARZ_DIV = `!x:real^N y. abs((x dot y) / (norm x * norm y)) <= &1`;;\n\nlet NORM_TRIANGLE = `!x y. norm(x + y) <= norm(x) + norm(y)`;;\n\nlet NORM_TRIANGLE_SUB = `!x y:real^N. norm(x) <= norm(y) + norm(x - y)`;;\n\nlet NORM_TRIANGLE_LE = `!x y. norm(x) + norm(y) <= e ==> norm(x + y) <= e`;;\n\nlet NORM_TRIANGLE_LT = `!x y. norm(x) + norm(y) < e ==> norm(x + y) < e`;;\n\nlet COMPONENT_LE_NORM = `!x:real^N i. abs(x$i) <= norm x`;;\n\nlet NORM_BOUND_COMPONENT_LE = `!x:real^N e. norm(x) <= e\n ==> !i. 1 <= i /\\ i <= dimindex(:N) ==> abs(x$i) <= e`;;\n\nlet NORM_BOUND_COMPONENT_LT = `!x:real^N e. norm(x) < e\n ==> !i. 1 <= i /\\ i <= dimindex(:N) ==> abs(x$i) < e`;;\n\nlet NORM_LE_L1 = `!x:real^N. norm x <= sum(1..dimindex(:N)) (\\i. abs(x$i))`;;\n\nlet REAL_ABS_SUB_NORM = `abs(norm(x) - norm(y)) <= norm(x - y)`;;\n\nlet NORM_LE = `!x y. norm(x) <= norm(y) <=> x dot x <= y dot y`;;\n\nlet NORM_LT = `!x y. norm(x) < norm(y) <=> x dot x < y dot y`;;\n\nlet NORM_EQ = `!x y. (norm x = norm y) <=> (x dot x = y dot y)`;;\n\nlet NORM_EQ_1 = `!x. norm(x) = &1 <=> x dot x = &1`;;\n\nlet NORM_LE_COMPONENTWISE = `!x:real^N y:real^N.\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> abs(x$i) <= abs(y$i))\n ==> norm(x) <= norm(y)`;;\n\nlet NORM_EQ_COMPONENTWISE = `!x:real^N y:real^N.\n (!i. 1 <= i /\\ i <= dimindex (:N) ==> abs(x$i) = abs(y$i))\n ==> norm x = norm y`;;\n\nlet L1_LE_NORM = `!x:real^N.\n sum(1..dimindex(:N)) (\\i. abs(x$i)) <= sqrt(&(dimindex(:N))) * norm x`;;\n\nlet DIST_INCREASES_ONLINE = `!a b d. ~(d = vec 0)\n ==> dist(a,b + d) > dist(a,b) \\/ dist(a,b - d) > dist(a,b)`;;\n\nlet NORM_INCREASES_ONLINE = `!a:real^N d. ~(d = vec 0)\n ==> norm(a + d) > norm(a) \\/ norm(a - d) > norm(a)`;;\n\nlet DOT_SQUARE_NORM = `!x. x dot x = norm(x) pow 2`;;\n\nlet NORM_EQ_SQUARE = `!x:real^N. norm(x) = a <=> &0 <= a /\\ x dot x = a pow 2`;;\n\nlet NORM_LE_SQUARE = `!x:real^N. norm(x) <= a <=> &0 <= a /\\ x dot x <= a pow 2`;;\n\nlet NORM_GE_SQUARE = `!x:real^N. norm(x) >= a <=> a <= &0 \\/ x dot x >= a pow 2`;;\n\nlet NORM_LT_SQUARE = `!x:real^N. norm(x) < a <=> &0 < a /\\ x dot x < a pow 2`;;\n\nlet NORM_GT_SQUARE = `!x:real^N. norm(x) > a <=> a < &0 \\/ x dot x > a pow 2`;;\n\nlet NORM_LT_SQUARE_ALT = `!x:real^N. norm(x) < a <=> &0 <= a /\\ x dot x < a pow 2`;;\n\nlet NORM_ARITH =\n let find_normedterms =\n let augment_norm b tm acc =\n match tm with\n Comb(Const(\"vector_norm\",_),v) -> insert (b,v) acc\n | _ -> acc in\n let rec find_normedterms tm acc =\n match tm with\n Comb(Comb(Const(\"real_add\",_),l),r) ->\n find_normedterms l (find_normedterms r acc)\n | Comb(Comb(Const(\"real_mul\",_),c),n) ->\n if not (is_ratconst c) then acc else\n augment_norm (rat_of_term c >=/ num 0) n acc\n | _ -> augment_norm true tm acc in\n find_normedterms in\n let lincomb_neg t = mapf minus_num t in\n let lincomb_cmul c t = if c =/ num 0 then undefined else mapf (( */ ) c) t in\n let lincomb_add l r = combine (+/) (fun x -> x =/ num 0) l r in\n let lincomb_sub l r = lincomb_add l (lincomb_neg r) in\n let lincomb_eq l r = lincomb_sub l r = undefined in\n let rec vector_lincomb tm =\n match tm with\n Comb(Comb(Const(\"vector_add\",_),l),r) ->\n lincomb_add (vector_lincomb l) (vector_lincomb r)\n | Comb(Comb(Const(\"vector_sub\",_),l),r) ->\n lincomb_sub (vector_lincomb l) (vector_lincomb r)\n | Comb(Comb(Const(\"%\",_),l),r) ->\n lincomb_cmul (rat_of_term l) (vector_lincomb r)\n | Comb(Const(\"vector_neg\",_),t) ->\n lincomb_neg (vector_lincomb t)\n | Comb(Const(\"vec\",_),n) when is_numeral n && dest_numeral n =/ num 0 ->\n undefined\n | _ -> (tm |=> num 1) in\n let vector_lincombs tms =\n itlist (fun t fns ->\n if can (assoc t) fns then fns else\n let f = vector_lincomb t in\n try let _,f' = find (fun (_,f') -> lincomb_eq f f') fns in\n (t,f')::fns\n with Failure _ -> (t,f)::fns) tms [] in\n let rec replacenegnorms fn tm =\n match tm with\n Comb(Comb(Const(\"real_add\",_),l),r) ->\n BINOP_CONV (replacenegnorms fn) tm\n | Comb(Comb(Const(\"real_mul\",_),c),n) when rat_of_term c \n RAND_CONV fn tm\n | _ -> REFL tm in\n let flip v eq =\n if defined eq v then (v |-> minus_num(apply eq v)) eq else eq in\n let rec allsubsets s =\n match s with\n [] -> [[]]\n | (a::t) -> let res = allsubsets t in\n map (fun b -> a::b) res @ res in\n let evaluate env lin =\n foldr (fun x c s -> s +/ c */ apply env x) lin (num 0) in\n let rec solve (vs,eqs) =\n match (vs,eqs) with\n [],[] -> (0 |=> num 1)\n | _,eq::oeqs ->\n let v = hd(intersect vs (dom eq)) in\n let c = apply eq v in\n let vdef = lincomb_cmul (num(-1) // c) eq in\n let eliminate eqn =\n if not(defined eqn v) then eqn else\n lincomb_add (lincomb_cmul (apply eqn v) vdef) eqn in\n let soln = solve (subtract vs [v],map eliminate oeqs) in\n (v |-> evaluate soln (undefine v vdef)) soln in\n let rec combinations k l =\n if k = 0 then [[]] else\n match l with\n [] -> []\n | h::t -> map (fun c -> h::c) (combinations (k - 1) t) @\n combinations k t in\n let vertices vs eqs =\n let vertex cmb =\n let soln = solve(vs,cmb) in\n map (fun v -> tryapplyd soln v (num 0)) vs in\n let rawvs = mapfilter vertex (combinations (length vs) eqs) in\n let unset = filter (forall (fun c -> c >=/ num 0)) rawvs in\n itlist (insert' (forall2 (=/))) unset [] in\n let subsumes l m = forall2 (fun x y -> abs_num x <=/ abs_num y) l m in\n let rec subsume todo dun =\n match todo with\n [] -> dun\n | v::ovs -> let dun' = if exists (fun w -> subsumes w v) dun then dun\n else v::(filter (fun w -> not(subsumes v w)) dun) in\n subsume ovs dun' in\n let NORM_CMUL_RULE =\n let MATCH_pth = (MATCH_MP o prove)\n (`!b x. b >= norm(x) ==> !c. abs(c) * b >= norm(c % x)`,\n SIMP_TAC[NORM_MUL; real_ge; REAL_LE_LMUL; REAL_ABS_POS]) in\n fun c th -> ISPEC(term_of_rat c) (MATCH_pth th) in\n let NORM_ADD_RULE =\n let MATCH_pth = (MATCH_MP o prove)\n (`!b1 b2 x1 x2. b1 >= norm(x1) /\\ b2 >= norm(x2)\n ==> b1 + b2 >= norm(x1 + x2)`,\n REWRITE_TAC[real_ge] THEN REPEAT STRIP_TAC THEN\n MATCH_MP_TAC NORM_TRIANGLE_LE THEN ASM_SIMP_TAC[REAL_LE_ADD2]) in\n fun th1 th2 -> MATCH_pth (CONJ th1 th2) in\n let INEQUALITY_CANON_RULE =\n CONV_RULE(LAND_CONV REAL_POLY_CONV) o\n CONV_RULE(LAND_CONV REAL_RAT_REDUCE_CONV) o\n GEN_REWRITE_RULE I [REAL_ARITH `s >= t <=> s - t >= &0`] in\n let NORM_CANON_CONV =\n let APPLY_pth1 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `x:real^N = &1 % x`]\n and APPLY_pth2 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `x - y:real^N = x + --y`]\n and APPLY_pth3 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `--x:real^N = -- &1 % x`]\n and APPLY_pth4 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `&0 % x:real^N = vec 0`;\n VECTOR_ARITH `c % vec 0:real^N = vec 0`]\n and APPLY_pth5 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `c % (d % x) = (c * d) % x`]\n and APPLY_pth6 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `c % (x + y) = c % x + c % y`]\n and APPLY_pth7 = GEN_REWRITE_CONV I\n [VECTOR_ARITH `vec 0 + x = x`;\n VECTOR_ARITH `x + vec 0 = x`]\n and APPLY_pth8 =\n GEN_REWRITE_CONV I [VECTOR_ARITH `c % x + d % x = (c + d) % x`] THENC\n LAND_CONV REAL_RAT_ADD_CONV THENC\n GEN_REWRITE_CONV TRY_CONV [VECTOR_ARITH `&0 % x = vec 0`]\n and APPLY_pth9 =\n GEN_REWRITE_CONV I\n [VECTOR_ARITH `(c % x + z) + d % x = (c + d) % x + z`;\n VECTOR_ARITH `c % x + (d % x + z) = (c + d) % x + z`;\n VECTOR_ARITH `(c % x + w) + (d % x + z) = (c + d) % x + (w + z)`] THENC\n LAND_CONV(LAND_CONV REAL_RAT_ADD_CONV)\n and APPLY_ptha =\n GEN_REWRITE_CONV I [VECTOR_ARITH `&0 % x + y = y`]\n and APPLY_pthb =\n GEN_REWRITE_CONV I\n [VECTOR_ARITH `c % x + d % y = c % x + d % y`;\n VECTOR_ARITH `(c % x + z) + d % y = c % x + (z + d % y)`;\n VECTOR_ARITH `c % x + (d % y + z) = c % x + (d % y + z)`;\n VECTOR_ARITH `(c % x + w) + (d % y + z) = c % x + (w + (d % y + z))`]\n and APPLY_pthc =\n GEN_REWRITE_CONV I\n [VECTOR_ARITH `c % x + d % y = d % y + c % x`;\n VECTOR_ARITH `(c % x + z) + d % y = d % y + (c % x + z)`;\n VECTOR_ARITH `c % x + (d % y + z) = d % y + (c % x + z)`;\n VECTOR_ARITH `(c % x + w) + (d % y + z) = d % y + ((c % x + w) + z)`]\n and APPLY_pthd =\n GEN_REWRITE_CONV TRY_CONV\n [VECTOR_ARITH `x + vec 0 = x`] in\n let headvector tm =\n match tm with\n Comb(Comb(Const(\"vector_add\",_),Comb(Comb(Const(\"%\",_),l),v)),r) -> v\n | Comb(Comb(Const(\"%\",_),l),v) -> v\n | _ -> failwith \"headvector: non-canonical term\" in\n let rec VECTOR_CMUL_CONV tm =\n ((APPLY_pth5 THENC LAND_CONV REAL_RAT_MUL_CONV) ORELSEC\n (APPLY_pth6 THENC BINOP_CONV VECTOR_CMUL_CONV)) tm\n and VECTOR_ADD_CONV tm =\n try APPLY_pth7 tm with Failure _ ->\n try APPLY_pth8 tm with Failure _ ->\n match tm with\n Comb(Comb(Const(\"vector_add\",_),lt),rt) ->\n let l = headvector lt and r = headvector rt in\n if l < r then (APPLY_pthb THENC\n RAND_CONV VECTOR_ADD_CONV THENC\n APPLY_pthd) tm\n else if r < l then (APPLY_pthc THENC\n RAND_CONV VECTOR_ADD_CONV THENC\n APPLY_pthd) tm else\n (APPLY_pth9 THENC\n ((APPLY_ptha THENC VECTOR_ADD_CONV) ORELSEC\n RAND_CONV VECTOR_ADD_CONV THENC\n APPLY_pthd)) tm\n | _ -> REFL tm in\n let rec VECTOR_CANON_CONV tm =\n match tm with\n Comb(Comb(Const(\"vector_add\",_),l),r) ->\n let lth = VECTOR_CANON_CONV l and rth = VECTOR_CANON_CONV r in\n let th = MK_COMB(AP_TERM (rator(rator tm)) lth,rth) in\n CONV_RULE (RAND_CONV VECTOR_ADD_CONV) th\n | Comb(Comb(Const(\"%\",_),l),r) ->\n let rth = AP_TERM (rator tm) (VECTOR_CANON_CONV r) in\n CONV_RULE (RAND_CONV(APPLY_pth4 ORELSEC VECTOR_CMUL_CONV)) rth\n | Comb(Comb(Const(\"vector_sub\",_),l),r) ->\n (APPLY_pth2 THENC VECTOR_CANON_CONV) tm\n | Comb(Const(\"vector_neg\",_),t) ->\n (APPLY_pth3 THENC VECTOR_CANON_CONV) tm\n | Comb(Const(\"vec\",_),n) when is_numeral n && dest_numeral n =/ num 0 ->\n REFL tm\n | _ -> APPLY_pth1 tm in\n fun tm ->\n match tm with\n Comb(Const(\"vector_norm\",_),e) -> RAND_CONV VECTOR_CANON_CONV tm\n | _ -> failwith \"NORM_CANON_CONV\" in\n let REAL_VECTOR_COMBO_PROVER =\n let pth_zero = `norm(vec 0:real^N) = &0`;;\n\nlet NORM_ARITH_TAC = CONV_TAC NORM_ARITH;;\n\nlet ASM_NORM_ARITH_TAC =\n REPEAT(FIRST_X_ASSUM(MP_TAC o check (not o is_forall o concl))) THEN\n NORM_ARITH_TAC;;\n\nlet HOMOMORPHISM_REAL_TO_REAL = `!f:real->real.\n (!x y. f(x + y) = f x + f y) /\\ (!x y. f(x * y) = f x * f y) <=>\n (f = \\x. &0) \\/ (f = \\x. x)`;;\n\nlet DOT_NORM = `!x y. x dot y = (norm(x + y) pow 2 - norm(x) pow 2 - norm(y) pow 2) / &2`;;\n\nlet DOT_NORM_SUB = `!x y. x dot y = ((norm(x) pow 2 + norm(y) pow 2) - norm(x - y) pow 2) / &2`;;\n\nlet VECTOR_EQ = `!x y. (x = y) <=> (x dot x = x dot y) /\\ (y dot y = x dot x)`;;\n\nlet DIST_REFL = `!x. dist(x,x) = &0`;;\n\nlet DIST_SYM = `!x y. dist(x,y) = dist(y,x)`;;\n\nlet DIST_POS_LE = `!x y. &0 <= dist(x,y)`;;\n\nlet REAL_ABS_DIST = `!x y:real^N. abs(dist(x,y)) = dist(x,y)`;;\n\nlet DIST_TRIANGLE = `!x:real^N y z. dist(x,z) <= dist(x,y) + dist(y,z)`;;\n\nlet DIST_TRIANGLE_ALT = `!x y z. dist(y,z) <= dist(x,y) + dist(x,z)`;;\n\nlet DIST_EQ_0 = `!x y. (dist(x,y) = &0) <=> (x = y)`;;\n\nlet DIST_POS_LT = `!x y. ~(x = y) ==> &0 < dist(x,y)`;;\n\nlet DIST_NZ = `!x y. ~(x = y) <=> &0 < dist(x,y)`;;\n\nlet DIST_TRIANGLE_LE = `!x y z e. dist(x,z) + dist(y,z) <= e ==> dist(x,y) <= e`;;\n\nlet DIST_TRIANGLE_LT = `!x y z e. dist(x,z) + dist(y,z) < e ==> dist(x,y) < e`;;\n\nlet DIST_TRIANGLE_HALF_L = `!x1 x2 y. dist(x1,y) < e / &2 /\\ dist(x2,y) < e / &2 ==> dist(x1,x2) < e`;;\n\nlet DIST_TRIANGLE_HALF_R = `!x1 x2 y. dist(y,x1) < e / &2 /\\ dist(y,x2) < e / &2 ==> dist(x1,x2) < e`;;\n\nlet DIST_TRIANGLE_ADD = `!x x' y y'. dist(x + y,x' + y') <= dist(x,x') + dist(y,y')`;;\n\nlet DIST_MUL = `!x y c. dist(c % x,c % y) = abs(c) * dist(x,y)`;;\n\nlet DIST_TRIANGLE_ADD_HALF = `!x x' y y':real^N.\n dist(x,x') < e / &2 /\\ dist(y,y') < e / &2 ==> dist(x + y,x' + y') < e`;;\n\nlet DIST_LE_0 = `!x y. dist(x,y) <= &0 <=> x = y`;;\n\nlet DIST_EQ = `!w x y z. dist(w,x) = dist(y,z) <=> dist(w,x) pow 2 = dist(y,z) pow 2`;;\n\nlet DIST_0 = `!x. dist(x,vec 0) = norm(x) /\\ dist(vec 0,x) = norm(x)`;;\n\nlet DIST_RESCALE = `!a x y:real^N. norm(x) = norm(y) ==> dist(a % x,y) = dist(x,a % y)`;;\n\nlet DIST_DESCALE = `!a b x y:real^N.\n &0 <= a /\\ &0 <= b /\\ norm(x) = norm(y)\n ==> dist(a % x,b % y) >= min a b * dist(x,y)`;;\n\nlet NEUTRAL_VECTOR_ADD = `neutral(+) = vec 0:real^N`;;\n\nlet MONOIDAL_VECTOR_ADD = `monoidal((+):real^N->real^N->real^N)`;;\n\nlet vsum = new_definition\n `(vsum:(A->bool)->(A->real^N)->real^N) s f = lambda i. sum s (\\x. f(x)$i)`;;\n\nlet VSUM_CLAUSES = `(!f. vsum {} f = vec 0) /\\\n (!x f s. FINITE s\n ==> (vsum (x INSERT s) f =\n if x IN s then vsum s f else f(x) + vsum s f))`;;\n\nlet VSUM = `!f s. FINITE s ==> vsum s f = iterate (+) s f`;;\n\nlet VSUM_EQ_0 = `!f s. (!x:A. x IN s ==> (f(x) = vec 0)) ==> (vsum s f = vec 0)`;;\n\nlet VSUM_0 = `vsum s (\\x. vec 0) = vec 0`;;\n\nlet VSUM_LMUL = `!f c s. vsum s (\\x. c % f(x)) = c % vsum s f`;;\n\nlet VSUM_RMUL = `!c s v. vsum s (\\x. c x % v) = (sum s c) % v`;;\n\nlet VSUM_ADD = `!f g s. FINITE s ==> (vsum s (\\x. f x + g x) = vsum s f + vsum s g)`;;\n\nlet VSUM_SUB = `!f g s. FINITE s ==> (vsum s (\\x. f x - g x) = vsum s f - vsum s g)`;;\n\nlet VSUM_CONST = `!c s. FINITE s ==> (vsum s (\\n. c) = &(CARD s) % c)`;;\n\nlet VSUM_COMPONENT = `!s f:A->real^N i. vsum s f$i = sum s (\\x. f x$i)`;;\n\nlet VSUM_IMAGE = `!f g s. FINITE s /\\ (!x y. x IN s /\\ y IN s /\\ (f x = f y) ==> (x = y))\n ==> (vsum (IMAGE f s) g = vsum s (g o f))`;;\n\nlet VSUM_UNION = `!f s t. FINITE s /\\ FINITE t /\\ DISJOINT s t\n ==> (vsum (s UNION t) f = vsum s f + vsum t f)`;;\n\nlet VSUM_DIFF = `!f s t. FINITE s /\\ t SUBSET s\n ==> (vsum (s DIFF t) f = vsum s f - vsum t f)`;;\n\nlet VSUM_DELETE = `!f s a. FINITE s /\\ a IN s\n ==> vsum (s DELETE a) f = vsum s f - f a`;;\n\nlet VSUM_INCL_EXCL = `!s t (f:A->real^N).\n FINITE s /\\ FINITE t\n ==> vsum s f + vsum t f = vsum (s UNION t) f + vsum (s INTER t) f`;;\n\nlet VSUM_NEG = `!f s. vsum s (\\x. --f x) = --vsum s f`;;\n\nlet VSUM_EQ = `!f g s. (!x. x IN s ==> (f x = g x)) ==> (vsum s f = vsum s g)`;;\n\nlet VSUM_SUPERSET = `!f:A->real^N u v.\n u SUBSET v /\\ (!x. x IN v /\\ ~(x IN u) ==> (f(x) = vec 0))\n ==> (vsum v f = vsum u f)`;;\n\nlet VSUM_SUPPORT = `!f:A->real^N s. vsum {x | x IN s /\\ ~(f x = vec 0)} f = vsum s f`;;\n\nlet VSUM_UNIV = `!f:A->real^N s.\n support (+) f (:A) SUBSET s ==> vsum s f = vsum (:A) f`;;\n\nlet VSUM_EQ_SUPERSET = `!f s t:A->bool.\n FINITE t /\\ t SUBSET s /\\\n (!x. x IN t ==> (f x = g x)) /\\\n (!x. x IN s /\\ ~(x IN t) ==> f(x) = vec 0)\n ==> vsum s f = vsum t g`;;\n\nlet VSUM_UNION_RZERO = `!f:A->real^N u v.\n (!x. x IN v /\\ ~(x IN u) ==> (f(x) = vec 0))\n ==> (vsum (u UNION v) f = vsum u f)`;;\n\nlet VSUM_UNION_LZERO = `!f:A->real^N u v.\n (!x. x IN u /\\ ~(x IN v) ==> (f(x) = vec 0))\n ==> (vsum (u UNION v) f = vsum v f)`;;\n\nlet VSUM_RESTRICT = `!f s. vsum s (\\x. if x IN s then f(x) else vec 0) = vsum s f`;;\n\nlet VSUM_RESTRICT_SET = `!P s f. vsum {x | x IN s /\\ P x} f =\n vsum s (\\x. if P x then f x else vec 0)`;;\n\nlet VSUM_CASES = `!s P f g. FINITE s\n ==> vsum s (\\x:A. if P x then (f x):real^N else g x) =\n vsum {x | x IN s /\\ P x} f + vsum {x | x IN s /\\ ~P x} g`;;\n\nlet VSUM_SING = `!f x. vsum {x} f = f(x)`;;\n\nlet VSUM_NORM = `!f s. FINITE s ==> norm(vsum s f) <= sum s (\\x. norm(f x))`;;\n\nlet VSUM_NORM_LE = `!s f:A->real^N g.\n FINITE s /\\ (!x. x IN s ==> norm(f x) <= g(x))\n ==> norm(vsum s f) <= sum s g`;;\n\nlet VSUM_NORM_TRIANGLE = `!s f b. FINITE s /\\ sum s (\\a. norm(f a)) <= b ==> norm(vsum s f) <= b`;;\n\nlet VSUM_NORM_BOUND = `!s f b. FINITE s /\\ (!x:A. x IN s ==> norm(f(x)) <= b)\n ==> norm(vsum s f) <= &(CARD s) * b`;;\n\nlet VSUM_CLAUSES_NUMSEG = `(!m. vsum(m..0) f = if m = 0 then f(0) else vec 0) /\\\n (!m n. vsum(m..SUC n) f = if m <= SUC n then vsum(m..n) f + f(SUC n)\n else vsum(m..n) f)`;;\n\nlet VSUM_CLAUSES_RIGHT = `!f m n. 0 < n /\\ m <= n ==> vsum(m..n) f = vsum(m..n-1) f + (f n):real^N`;;\n\nlet VSUM_CMUL_NUMSEG = `!f c m n. vsum (m..n) (\\x. c % f x) = c % vsum (m..n) f`;;\n\nlet VSUM_EQ_NUMSEG = `!f g m n.\n (!x. m <= x /\\ x <= n ==> (f x = g x))\n ==> (vsum(m .. n) f = vsum(m .. n) g)`;;\n\nlet VSUM_IMAGE_GEN = `!f:A->B g s.\n FINITE s\n ==> (vsum s g =\n vsum (IMAGE f s) (\\y. vsum {x | x IN s /\\ (f(x) = y)} g))`;;\n\nlet VSUM_GROUP = `!f:A->B g s t.\n FINITE s /\\ IMAGE f s SUBSET t\n ==> vsum t (\\y. vsum {x | x IN s /\\ f(x) = y} g) = vsum s g`;;\n\nlet VSUM_GROUP_RELATION = `!R:A->B->bool g s t.\n FINITE s /\\\n (!x. x IN s ==> ?!y. y IN t /\\ R x y)\n ==> vsum t (\\y. vsum {x | x IN s /\\ R x y} g) = vsum s g`;;\n\nlet VSUM_VMUL = `!f v s. (sum s f) % v = vsum s (\\x. f(x) % v)`;;\n\nlet VSUM_DELTA = `!s a. vsum s (\\x. if x = a then b else vec 0) =\n if a IN s then b else vec 0`;;\n\nlet VSUM_ADD_NUMSEG = `!f g m n. vsum(m..n) (\\i. f i + g i) = vsum(m..n) f + vsum(m..n) g`;;\n\nlet VSUM_SUB_NUMSEG = `!f g m n. vsum(m..n) (\\i. f i - g i) = vsum(m..n) f - vsum(m..n) g`;;\n\nlet VSUM_ADD_SPLIT = `!f m n p.\n m <= n + 1 ==> vsum(m..n + p) f = vsum(m..n) f + vsum(n + 1..n + p) f`;;\n\nlet VSUM_VSUM_PRODUCT = `!s:A->bool t:A->B->bool x.\n FINITE s /\\ (!i. i IN s ==> FINITE(t i))\n ==> vsum s (\\i. vsum (t i) (x i)) =\n vsum {i,j | i IN s /\\ j IN t i} (\\(i,j). x i j)`;;\n\nlet VSUM_IMAGE_NONZERO = `!d:B->real^N i:A->B s.\n FINITE s /\\\n (!x y. x IN s /\\ y IN s /\\ ~(x = y) /\\ i x = i y ==> d(i x) = vec 0)\n ==> vsum (IMAGE i s) d = vsum s (d o i)`;;\n\nlet VSUM_UNION_NONZERO = `!f s t. FINITE s /\\ FINITE t /\\ (!x. x IN s INTER t ==> f(x) = vec 0)\n ==> vsum (s UNION t) f = vsum s f + vsum t f`;;\n\nlet VSUM_UNIONS_NONZERO = `!f s. FINITE s /\\ (!t:A->bool. t IN s ==> FINITE t) /\\\n (!t1 t2 x. t1 IN s /\\ t2 IN s /\\ ~(t1 = t2) /\\ x IN t1 /\\ x IN t2\n ==> f x = vec 0)\n ==> vsum (UNIONS s) f = vsum s (\\t. vsum t f)`;;\n\nlet VSUM_CLAUSES_LEFT = `!f m n. m <= n ==> vsum(m..n) f = f m + vsum(m + 1..n) f`;;\n\nlet VSUM_DIFFS = `!m n. vsum(m..n) (\\k. f(k) - f(k + 1)) =\n if m <= n then f(m) - f(n + 1) else vec 0`;;\n\nlet VSUM_DIFFS_ALT = `!m n. vsum(m..n) (\\k. f(k + 1) - f(k)) =\n if m <= n then f(n + 1) - f(m) else vec 0`;;\n\nlet VSUM_DELETE_CASES = `!x f s.\n FINITE(s:A->bool)\n ==> vsum(s DELETE x) f = if x IN s then vsum s f - f x else vsum s f`;;\n\nlet VSUM_EQ_GENERAL = `!s:A->bool t:B->bool (f:A->real^N) g h.\n (!y. y IN t ==> ?!x. x IN s /\\ h x = y) /\\\n (!x. x IN s ==> h x IN t /\\ g(h x) = f x)\n ==> vsum s f = vsum t g`;;\n\nlet VSUM_EQ_GENERAL_INVERSES = `!s t (f:A->real^N) (g:B->real^N) h k.\n (!y. y IN t ==> k y IN s /\\ h (k y) = y) /\\\n (!x. x IN s ==> h x IN t /\\ k (h x) = x /\\ g (h x) = f x)\n ==> vsum s f = vsum t g`;;\n\nlet VSUM_NORM_ALLSUBSETS_BOUND = `!f:A->real^N p e.\n FINITE p /\\\n (!q. q SUBSET p ==> norm(vsum q f) <= e)\n ==> sum p (\\x. norm(f x)) <= &2 * &(dimindex(:N)) * e`;;\n\nlet DOT_LSUM = `!s f y. FINITE s ==> (vsum s f) dot y = sum s (\\x. f(x) dot y)`;;\n\nlet DOT_RSUM = `!s f x. FINITE s ==> x dot (vsum s f) = sum s (\\y. x dot f(y))`;;\n\nlet VSUM_OFFSET = `!p f m n. vsum(m + p..n + p) f = vsum(m..n) (\\i. f (i + p))`;;\n\nlet VSUM_OFFSET_0 = `!f m n. m <= n ==> vsum(m..n) f = vsum(0..n - m) (\\i. f (i + m))`;;\n\nlet VSUM_TRIV_NUMSEG = `!f m n. n < m ==> vsum(m..n) f = vec 0`;;\n\nlet VSUM_CONST_NUMSEG = `!c m n. vsum(m..n) (\\n. c) = &((n + 1) - m) % c`;;\n\nlet VSUM_SUC = `!f m n. vsum (SUC n..SUC m) f = vsum (n..m) (f o SUC)`;;\n\nlet VSUM_BIJECTION = `!f:A->real^N p s:A->bool.\n (!x. x IN s ==> p(x) IN s) /\\\n (!y. y IN s ==> ?!x. x IN s /\\ p(x) = y)\n ==> vsum s f = vsum s (f o p)`;;\n\nlet VSUM_PARTIAL_SUC = `!f g:num->real^N m n.\n vsum (m..n) (\\k. f(k) % (g(k + 1) - g(k))) =\n if m <= n then f(n + 1) % g(n + 1) - f(m) % g(m) -\n vsum (m..n) (\\k. (f(k + 1) - f(k)) % g(k + 1))\n else vec 0`;;\n\nlet VSUM_PARTIAL_PRE = `!f g:num->real^N m n.\n vsum (m..n) (\\k. f(k) % (g(k) - g(k - 1))) =\n if m <= n then f(n + 1) % g(n) - f(m) % g(m - 1) -\n vsum (m..n) (\\k. (f(k + 1) - f(k)) % g(k))\n else vec 0`;;\n\nlet VSUM_COMBINE_L = `!f m n p.\n 0 < n /\\ m <= n /\\ n <= p + 1\n ==> vsum(m..n - 1) f + vsum(n..p) f = vsum(m..p) f`;;\n\nlet VSUM_COMBINE_R = `!f m n p.\n m <= n + 1 /\\ n <= p\n ==> vsum(m..n) f + vsum(n + 1..p) f = vsum(m..p) f`;;\n\nlet VSUM_INJECTION = `!f p s.\n FINITE s /\\\n (!x. x IN s ==> p x IN s) /\\\n (!x y. x IN s /\\ y IN s /\\ p x = p y ==> x = y)\n ==> vsum s (f o p) = vsum s f`;;\n\nlet VSUM_SWAP = `!f s t.\n FINITE s /\\ FINITE t\n ==> vsum s (\\i. vsum t (f i)) = vsum t (\\j. vsum s (\\i. f i j))`;;\n\nlet VSUM_SWAP_NUMSEG = `!a b c d f.\n vsum (a..b) (\\i. vsum (c..d) (f i)) =\n vsum (c..d) (\\j. vsum (a..b) (\\i. f i j))`;;\n\nlet VSUM_ADD_GEN = `!f g s.\n FINITE {x | x IN s /\\ ~(f x = vec 0)} /\\\n FINITE {x | x IN s /\\ ~(g x = vec 0)}\n ==> vsum s (\\x. f x + g x) = vsum s f + vsum s g`;;\n\nlet VSUM_CASES_1 = `!s a. FINITE s /\\ a IN s\n ==> vsum s (\\x. if x = a then y else f(x)) = vsum s f + (y - f a)`;;\n\nlet VSUM_SING_NUMSEG = `vsum(n..n) f = f n`;;\n\nlet VSUM_1 = `vsum(1..1) f = f(1)`;;\n\nlet VSUM_2 = `!t. vsum(1..2) t = t(1) + t(2)`;;\n\nlet VSUM_3 = `!t. vsum(1..3) t = t(1) + t(2) + t(3)`;;\n\nlet VSUM_4 = `!t. vsum(1..4) t = t(1) + t(2) + t(3) + t(4)`;;\n\nlet VSUM_PAIR = `!f:num->real^N m n.\n vsum(2*m..2*n+1) f = vsum(m..n) (\\i. f(2*i) + f(2*i+1))`;;\n\nlet VSUM_PAIR_0 = `!f:num->real^N n. vsum(0..2*n+1) f = vsum(0..n) (\\i. f(2*i) + f(2*i+1))`;;\n\nlet VSUM_REFLECT = `!x m n. vsum(m..n) x =\n if n < m then vec 0 else vsum(0..n-m) (\\i. x(n - i))`;;\n\nlet th = `(!f g s. (!x. x IN s ==> f(x) = g(x))\n ==> vsum s (\\i. f(i)) = vsum s g) /\\\n (!f g a b. (!i. a <= i /\\ i <= b ==> f(i) = g(i))\n ==> vsum(a..b) (\\i. f(i)) = vsum(a..b) g) /\\\n (!f g p. (!x. p x ==> f x = g x)\n ==> vsum {y | p y} (\\i. f(i)) = vsum {y | p y} g)`;;\n\nlet EXPAND_VSUM_CONV =\n let [pth_0; pth_1; pth_2] = (CONJUNCTS o prove)\n (`(n < m ==> vsum(m..n) (f:num->real^N) = vec 0) /\\\n vsum(m..m) (f:num->real^N) = f m /\\\n (m <= n ==> vsum (m..n) (f:num->real^N) = f m + vsum (m + 1..n) f)`,\n REWRITE_TAC[VSUM_CLAUSES_LEFT; VSUM_SING_NUMSEG; VSUM_TRIV_NUMSEG])\n and ns_tm = `..` and f_tm = `f:num->real^N`\n and m_tm = `m:num` and n_tm = `n:num`\n and n_ty = `:N` in\n let rec conv tm =\n let smn,ftm = dest_comb tm in\n let s,mn = dest_comb smn in\n if not(is_const s && fst(dest_const s) = \"vsum\")\n then failwith \"EXPAND_VSUM_CONV\" else\n let mtm,ntm = dest_binop ns_tm mn in\n let m = dest_numeral mtm and n = dest_numeral ntm in\n let nty = hd(tl(snd(dest_type(snd(dest_fun_ty(type_of ftm)))))) in\n let ilist = [nty,n_ty] in\n let ifn = inst ilist and tfn = INST_TYPE ilist in\n if n < m then\n let th1 = INST [ftm,ifn f_tm; mtm,m_tm; ntm,n_tm] (tfn pth_0) in\n MP th1 (EQT_ELIM(NUM_LT_CONV(lhand(concl th1))))\n else if n = m then CONV_RULE (RAND_CONV(TRY_CONV BETA_CONV))\n (INST [ftm,ifn f_tm; mtm,m_tm] (tfn pth_1))\n else\n let th1 = INST [ftm,ifn f_tm; mtm,m_tm; ntm,n_tm] (tfn pth_2) in\n let th2 = MP th1 (EQT_ELIM(NUM_LE_CONV(lhand(concl th1)))) in\n CONV_RULE (RAND_CONV(COMB2_CONV (RAND_CONV(TRY_CONV BETA_CONV))\n (LAND_CONV(LAND_CONV NUM_ADD_CONV) THENC conv))) th2 in\n conv;;\n\nlet basis = new_definition\n `basis k = lambda i. if i = k then &1 else &0`;;\n\nlet NORM_BASIS = `!k. 1 <= k /\\ k <= dimindex(:N)\n ==> (norm(basis k :real^N) = &1)`;;\n\nlet NORM_BASIS_1 = `norm(basis 1) = &1`;;\n\nlet VECTOR_CHOOSE_SIZE = `!c. &0 <= c ==> ?x:real^N. norm(x) = c`;;\n\nlet VECTOR_CHOOSE_DIST = `!x e. &0 <= e ==> ?y:real^N. dist(x,y) = e`;;\n\nlet BASIS_INJ = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\\n (basis i :real^N = basis j)\n ==> (i = j)`;;\n\nlet BASIS_INJ_EQ = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\ 1 <= j /\\ j <= dimindex(:N)\n ==> (basis i:real^N = basis j <=> i = j)`;;\n\nlet BASIS_NE = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\\n ~(i = j)\n ==> ~(basis i :real^N = basis j)`;;\n\nlet BASIS_COMPONENT = `!k i. 1 <= i /\\ i <= dimindex(:N)\n ==> ((basis k :real^N)$i = if i = k then &1 else &0)`;;\n\nlet BASIS_EXPANSION = `!x:real^N. vsum(1..dimindex(:N)) (\\i. x$i % basis i) = x`;;\n\nlet BASIS_EXPANSION_UNIQUE = `!f x:real^N. (vsum(1..dimindex(:N)) (\\i. f(i) % basis i) = x) <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> f(i) = x$i)`;;\n\nlet DOT_BASIS = `!x:real^N i.\n 1 <= i /\\ i <= dimindex(:N)\n ==> ((basis i) dot x = x$i) /\\ (x dot (basis i) = x$i)`;;\n\nlet DOT_BASIS_BASIS = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> (basis i:real^N) dot (basis j) = if i = j then &1 else &0`;;\n\nlet DOT_BASIS_BASIS_UNEQUAL = `!i j. ~(i = j) ==> (basis i) dot (basis j) = &0`;;\n\nlet BASIS_EQ_0 = `!i. (basis i :real^N = vec 0) <=> ~(i IN 1..dimindex(:N))`;;\n\nlet BASIS_NONZERO = `!k. 1 <= k /\\ k <= dimindex(:N)\n ==> ~(basis k :real^N = vec 0)`;;\n\nlet VECTOR_EQ_LDOT = `!y z. (!x. x dot y = x dot z) <=> y = z`;;\n\nlet VECTOR_EQ_RDOT = `!x y. (!z. x dot z = y dot z) <=> x = y`;;\n\nlet orthogonal = new_definition\n `orthogonal x y <=> (x dot y = &0)`;;\n\nlet ORTHOGONAL_0 = `!x. orthogonal (vec 0) x /\\ orthogonal x (vec 0)`;;\n\nlet ORTHOGONAL_REFL = `!x. orthogonal x x <=> x = vec 0`;;\n\nlet ORTHOGONAL_SYM = `!x y. orthogonal x y <=> orthogonal y x`;;\n\nlet ORTHOGONAL_LNEG = `!x y. orthogonal (--x) y <=> orthogonal x y`;;\n\nlet ORTHOGONAL_RNEG = `!x y. orthogonal x (--y) <=> orthogonal x y`;;\n\nlet ORTHOGONAL_MUL = `(!a x y:real^N. orthogonal (a % x) y <=> a = &0 \\/ orthogonal x y) /\\\n (!a x y:real^N. orthogonal x (a % y) <=> a = &0 \\/ orthogonal x y)`;;\n\nlet ORTHOGONAL_BASIS = `!x:real^N i. 1 <= i /\\ i <= dimindex(:N)\n ==> (orthogonal (basis i) x <=> (x$i = &0))`;;\n\nlet ORTHOGONAL_BASIS_BASIS = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> (orthogonal (basis i :real^N) (basis j) <=> ~(i = j))`;;\n\nlet ORTHOGONAL_CLAUSES = `(!a. orthogonal a (vec 0)) /\\\n (!a x c. orthogonal a x ==> orthogonal a (c % x)) /\\\n (!a x. orthogonal a x ==> orthogonal a (--x)) /\\\n (!a x y. orthogonal a x /\\ orthogonal a y ==> orthogonal a (x + y)) /\\\n (!a x y. orthogonal a x /\\ orthogonal a y ==> orthogonal a (x - y)) /\\\n (!a. orthogonal (vec 0) a) /\\\n (!a x c. orthogonal x a ==> orthogonal (c % x) a) /\\\n (!a x. orthogonal x a ==> orthogonal (--x) a) /\\\n (!a x y. orthogonal x a /\\ orthogonal y a ==> orthogonal (x + y) a) /\\\n (!a x y. orthogonal x a /\\ orthogonal y a ==> orthogonal (x - y) a)`;;\n\nlet ORTHOGONAL_RVSUM = `!f:A->real^N s x.\n FINITE s /\\\n (!y. y IN s ==> orthogonal x (f y))\n ==> orthogonal x (vsum s f)`;;\n\nlet ORTHOGONAL_LVSUM = `!f:A->real^N s y.\n FINITE s /\\\n (!x. x IN s ==> orthogonal (f x) y)\n ==> orthogonal (vsum s f) y`;;\n\nlet NORM_ADD_PYTHAGOREAN = `!a b:real^N.\n orthogonal a b\n ==> norm(a + b) pow 2 = norm(a) pow 2 + norm(b) pow 2`;;\n\nlet NORM_VSUM_PYTHAGOREAN = `!k u:A->real^N.\n FINITE k /\\ pairwise (\\i j. orthogonal (u i) (u j)) k\n ==> norm(vsum k u) pow 2 = sum k (\\i. norm(u i) pow 2)`;;\n\nlet VECTOR_1 = `(vector[x]:A^1)$1 = x`;;\n\nlet VECTOR_2 = `(vector[x;y]:A^2)$1 = x /\\\n (vector[x;y]:A^2)$2 = y`;;\n\nlet VECTOR_3 = `(vector[x;y;z]:A^3)$1 = x /\\\n (vector[x;y;z]:A^3)$2 = y /\\\n (vector[x;y;z]:A^3)$3 = z`;;\n\nlet VECTOR_4 = `(vector[w;x;y;z]:A^4)$1 = w /\\\n (vector[w;x;y;z]:A^4)$2 = x /\\\n (vector[w;x;y;z]:A^4)$3 = y /\\\n (vector[w;x;y;z]:A^4)$4 = z`;;\n\nlet FORALL_VECTOR_1 = `(!v:A^1. P v) <=> !x. P(vector[x])`;;\n\nlet FORALL_VECTOR_2 = `(!v:A^2. P v) <=> !x y. P(vector[x;y])`;;\n\nlet FORALL_VECTOR_3 = `(!v:A^3. P v) <=> !x y z. P(vector[x;y;z])`;;\n\nlet FORALL_VECTOR_4 = `(!v:A^4. P v) <=> !w x y z. P(vector[w;x;y;z])`;;\n\nlet EXISTS_VECTOR_1 = `(?v:A^1. P v) <=> ?x. P(vector[x])`;;\n\nlet EXISTS_VECTOR_2 = `(?v:A^2. P v) <=> ?x y. P(vector[x;y])`;;\n\nlet EXISTS_VECTOR_3 = `(?v:A^3. P v) <=> ?x y z. P(vector[x;y;z])`;;\n\nlet EXISTS_VECTOR_4 = `(?v:A^4. P v) <=> ?w x y z. P(vector[w;x;y;z])`;;\n\nlet VECTOR_EXPAND_1 = `!x:real^1. x = vector[x$1]`;;\n\nlet VECTOR_EXPAND_2 = `!x:real^2. x = vector[x$1;x$2]`;;\n\nlet VECTOR_EXPAND_3 = `!x:real^3. x = vector[x$1;x$2;x$3]`;;\n\nlet VECTOR_EXPAND_4 = `!x:real^4. x = vector[x$1;x$2;x$3;x$4]`;;\n\nlet linear = new_definition\n `linear (f:real^M->real^N) <=>\n (!x y. f(x + y) = f(x) + f(y)) /\\\n (!c x. f(c % x) = c % f(x))`;;\n\nlet LINEAR_COMPOSE_CMUL = `!f c. linear f ==> linear (\\x. c % f(x))`;;\n\nlet LINEAR_COMPOSE_NEG = `!f. linear f ==> linear (\\x. --(f(x)))`;;\n\nlet LINEAR_COMPOSE_NEG_EQ = `!f:real^M->real^N. linear(\\x. --(f x)) <=> linear f`;;\n\nlet LINEAR_COMPOSE_ADD = `!f g. linear f /\\ linear g ==> linear (\\x. f(x) + g(x))`;;\n\nlet LINEAR_COMPOSE_SUB = `!f g. linear f /\\ linear g ==> linear (\\x. f(x) - g(x))`;;\n\nlet LINEAR_COMPOSE = `!f g. linear f /\\ linear g ==> linear (g o f)`;;\n\nlet LINEAR_ID = `linear (\\x. x)`;;\n\nlet LINEAR_I = `linear I`;;\n\nlet LINEAR_ZERO = `linear (\\x. vec 0)`;;\n\nlet LINEAR_NEGATION = `linear(--)`;;\n\nlet LINEAR_COMPOSE_VSUM = `!f s. FINITE s /\\ (!a. a IN s ==> linear(f a))\n ==> linear(\\x. vsum s (\\a. f a x))`;;\n\nlet LINEAR_VMUL_COMPONENT = `!f:real^M->real^N v k.\n linear f /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> linear (\\x. f(x)$k % v)`;;\n\nlet LINEAR_0 = `!f. linear f ==> (f(vec 0) = vec 0)`;;\n\nlet LINEAR_CMUL = `!f c x. linear f ==> (f(c % x) = c % f(x))`;;\n\nlet LINEAR_NEG = `!f x. linear f ==> (f(--x) = --(f x))`;;\n\nlet LINEAR_ADD = `!f x y. linear f ==> (f(x + y) = f(x) + f(y))`;;\n\nlet LINEAR_SUB = `!f x y. linear f ==> (f(x - y) = f(x) - f(y))`;;\n\nlet LINEAR_VSUM = `!f g s. linear f /\\ FINITE s ==> (f(vsum s g) = vsum s (f o g))`;;\n\nlet LINEAR_VSUM_MUL = `!f s c v.\n linear f /\\ FINITE s\n ==> f(vsum s (\\i. c i % v i)) = vsum s (\\i. c(i) % f(v i))`;;\n\nlet LINEAR_INJECTIVE_0 = `!f. linear f\n ==> ((!x y. (f(x) = f(y)) ==> (x = y)) <=>\n (!x. (f(x) = vec 0) ==> (x = vec 0)))`;;\n\nlet LINEAR_BOUNDED = `!f:real^M->real^N. linear f ==> ?B. !x. norm(f x) <= B * norm(x)`;;\n\nlet LINEAR_BOUNDED_POS = `!f:real^M->real^N. linear f ==> ?B. &0 < B /\\ !x. norm(f x) <= B * norm(x)`;;\n\nlet SYMMETRIC_LINEAR_IMAGE = `!f s. (!x. x IN s ==> --x IN s) /\\ linear f\n ==> !x. x IN (IMAGE f s) ==> --x IN (IMAGE f s)`;;\n\nlet bilinear = new_definition\n `bilinear f <=> (!x. linear(\\y. f x y)) /\\ (!y. linear(\\x. f x y))`;;\n\nlet BILINEAR_SWAP = `!op:real^M->real^N->real^P.\n bilinear(\\x y. op y x) <=> bilinear op`;;\n\nlet BILINEAR_LADD = `!h x y z. bilinear h ==> h (x + y) z = (h x z) + (h y z)`;;\n\nlet BILINEAR_RADD = `!h x y z. bilinear h ==> h x (y + z) = (h x y) + (h x z)`;;\n\nlet BILINEAR_LMUL = `!h c x y. bilinear h ==> h (c % x) y = c % (h x y)`;;\n\nlet BILINEAR_RMUL = `!h c x y. bilinear h ==> h x (c % y) = c % (h x y)`;;\n\nlet BILINEAR_LNEG = `!h x y. bilinear h ==> h (--x) y = --(h x y)`;;\n\nlet BILINEAR_RNEG = `!h x y. bilinear h ==> h x (--y) = --(h x y)`;;\n\nlet BILINEAR_LZERO = `!h x. bilinear h ==> h (vec 0) x = vec 0`;;\n\nlet BILINEAR_RZERO = `!h x. bilinear h ==> h x (vec 0) = vec 0`;;\n\nlet BILINEAR_LSUB = `!h x y z. bilinear h ==> h (x - y) z = (h x z) - (h y z)`;;\n\nlet BILINEAR_RSUB = `!h x y z. bilinear h ==> h x (y - z) = (h x y) - (h x z)`;;\n\nlet BILINEAR_LSUM = `!bop:real^M->real^N->real^P f s:A->bool y.\n bilinear bop /\\ FINITE s\n ==> bop(vsum s f) y = vsum s (\\i. bop (f i) y)`;;\n\nlet BILINEAR_RSUM = `!bop:real^M->real^N->real^P f s:A->bool x.\n bilinear bop /\\ FINITE s\n ==> bop x (vsum s f) = vsum s (\\i. bop x (f i))`;;\n\nlet BILINEAR_VSUM = `!h:real^M->real^N->real^P.\n bilinear h /\\ FINITE s /\\ FINITE t\n ==> h (vsum s f) (vsum t g) = vsum (s CROSS t) (\\(i,j). h (f i) (g j))`;;\n\nlet BILINEAR_BOUNDED = `!h:real^M->real^N->real^P.\n bilinear h ==> ?B. !x y. norm(h x y) <= B * norm(x) * norm(y)`;;\n\nlet BILINEAR_BOUNDED_POS = `!h. bilinear h\n ==> ?B. &0 < B /\\ !x y. norm(h x y) <= B * norm(x) * norm(y)`;;\n\nlet BILINEAR_VSUM_PARTIAL_SUC = `!f g h:real^M->real^N->real^P m n.\n bilinear h\n ==> vsum (m..n) (\\k. h (f k) (g(k + 1) - g(k))) =\n if m <= n then h (f(n + 1)) (g(n + 1)) - h (f m) (g m) -\n vsum (m..n) (\\k. h (f(k + 1) - f(k)) (g(k + 1)))\n else vec 0`;;\n\nlet BILINEAR_VSUM_PARTIAL_PRE = `!f g h:real^M->real^N->real^P m n.\n bilinear h\n ==> vsum (m..n) (\\k. h (f k) (g(k) - g(k - 1))) =\n if m <= n then h (f(n + 1)) (g(n)) - h (f m) (g(m - 1)) -\n vsum (m..n) (\\k. h (f(k + 1) - f(k)) (g(k)))\n else vec 0`;;\n\nlet BILINEAR_VSUM_CONVOLUTION_1 = `!bop:real^M->real^N->real^P a b n.\n bilinear bop\n ==> vsum(0..n) (\\m. vsum (0..m) (\\i. bop (a i) (b(m - i)))) =\n vsum(0..n) (\\m. bop (a m) (vsum(0..n-m) b))`;;\n\nlet BILINEAR_VSUM_CONVOLUTION_2 = `!bop:real^M->real^N->real^P a b n.\n bilinear bop\n ==> vsum(0..n) (\\m. vsum(0..m) (\\k. vsum(0..k) (\\i. bop (a i) (b(k-i))))) =\n vsum(0..n) (\\m. bop (vsum(0..m) a) (vsum(0..n-m) b))`;;\n\nlet adjoint = new_definition\n `adjoint(f:real^M->real^N) = @f'. !x y. f(x) dot y = x dot f'(y)`;;\n\nlet ADJOINT_WORKS = `!f:real^M->real^N. linear f ==> !x y. f(x) dot y = x dot (adjoint f)(y)`;;\n\nlet ADJOINT_LINEAR = `!f:real^M->real^N. linear f ==> linear(adjoint f)`;;\n\nlet ADJOINT_CLAUSES = `!f:real^M->real^N.\n linear f ==> (!x y. x dot (adjoint f)(y) = f(x) dot y) /\\\n (!x y. (adjoint f)(y) dot x = y dot f(x))`;;\n\nlet ADJOINT_ADJOINT = `!f:real^M->real^N. linear f ==> adjoint(adjoint f) = f`;;\n\nlet ADJOINT_UNIQUE = `!f f'. linear f /\\ (!x y. f'(x) dot y = x dot f(y))\n ==> f' = adjoint f`;;\n\nlet ADJOINT_COMPOSE = `!f g:real^N->real^N.\n linear f /\\ linear g ==> adjoint(f o g) = adjoint g o adjoint f`;;\n\nlet SELF_ADJOINT_COMPOSE = `!f g:real^N->real^N.\n linear f /\\ linear g /\\ adjoint f = f /\\ adjoint g = g\n ==> (adjoint(f o g) = f o g <=> f o g = g o f)`;;\n\nlet SELF_ADJOINT_ORTHOGONAL_EIGENVECTORS = `!f:real^N->real^N v w a b.\n linear f /\\ adjoint f = f /\\ f v = a % v /\\ f w = b % w /\\ ~(a = b)\n ==> orthogonal v w`;;\n\nlet ORTHOGONAL_PROJECTION_ALT = `!f:real^N->real^N.\n linear f\n ==> ((!x y. orthogonal (f x - x) (f x - f y)) <=>\n (!x y. orthogonal (f x - x) (f y)))`;;\n\nlet ORTHOGONAL_PROJECTION_EQ_SELF_ADJOINT_IDEMPOTENT = `!f:real^N->real^N.\n linear f\n ==> ((!x y. orthogonal (f x - x) (f x - f y)) <=>\n adjoint f = f /\\ f o f = f)`;;\n\nlet LIPSCHITZ_ON_POS = `!f:real^M->real^N s.\n (?B. !x y. x IN s /\\ y IN s\n ==> norm(f x - f y) <= B * norm(x - y)) <=>\n (?B. &0 < B /\\\n !x y. x IN s /\\ y IN s\n ==> norm(f x - f y) <= B * norm(x - y))`;;\n\nlet LIPSCHITZ_POS = `!f:real^M->real^N.\n (?B. !x y. norm(f x - f y) <= B * norm(x - y)) <=>\n (?B. &0 < B /\\ !x y. norm(f x - f y) <= B * norm(x - y))`;;\n\nlet LIPSCHITZ_ON_COMPOSE = `!f:real^M->real^N g:real^N->real^P s t.\n (?B. !x y. x IN s /\\ y IN s ==> norm(f x - f y) <= B * norm(x - y)) /\\\n (?B. !x y. x IN t /\\ y IN t ==> norm(g x - g y) <= B * norm(x - y)) /\\\n IMAGE f s SUBSET t\n ==> ?B. !x y. x IN s /\\ y IN s\n ==> norm(g(f x) - g(f y)) <= B * norm(x - y)`;;\n\nlet LINEAR_IMP_LIPSCHITZ = `!f:real^M->real^N.\n linear f ==> ?B. !x y. norm(f x - f y) <= B * norm(x - y)`;;\n\nlet LIPSCHITZ_ON_COMPONENTWISE = `!f:real^M->real^N s.\n (?B. !x y. x IN s /\\ y IN s ==> norm(f x - f y) <= B * norm(x - y)) <=>\n !i. 1 <= i /\\ i <= dimindex(:N)\n ==> ?B. !x y. x IN s /\\ y IN s\n ==> abs(f x$i - f y$i) <= B * norm(x - y)`;;\n\noverload_interface (\"--\",`(matrix_neg):real^N^M->real^N^M`);;\noverload_interface (\"+\",`(matrix_add):real^N^M->real^N^M->real^N^M`);;\noverload_interface (\"-\",`(matrix_sub):real^N^M->real^N^M->real^N^M`);;\n\nmake_overloadable \"**\" `:A->B->C`;;\n\noverload_interface (\"**\",`(vector_matrix_mul):real^M->real^N^M->real^N`);;\noverload_interface (\"**\",`(matrix_mul):real^N^M->real^P^N->real^P^M`);;\noverload_interface (\"**\",`(matrix_vector_mul):real^N^M->real^N->real^M`);;\n\nparse_as_infix(\"%%\",(21,\"right\"));;\n\nprioritize_real();;\n\nlet matrix_cmul = new_definition\n `((%%):real->real^N^M->real^N^M) c A = lambda i j. c * A$i$j`;;\n\nlet matrix_neg = new_definition\n `!A:real^N^M. --A = lambda i j. --(A$i$j)`;;\n\nlet matrix_add = new_definition\n `!A:real^N^M B:real^N^M. A + B = lambda i j. A$i$j + B$i$j`;;\n\nlet matrix_sub = new_definition\n `!A:real^N^M B:real^N^M. A - B = lambda i j. A$i$j - B$i$j`;;\n\nlet matrix_mul = new_definition\n `!A:real^N^M B:real^P^N.\n A ** B =\n lambda i j. sum(1..dimindex(:N)) (\\k. A$i$k * B$k$j)`;;\n\nlet matrix_vector_mul = new_definition\n `!A:real^N^M x:real^N.\n A ** x = lambda i. sum(1..dimindex(:N)) (\\j. A$i$j * x$j)`;;\n\nlet vector_matrix_mul = new_definition\n `!A:real^N^M x:real^M.\n x ** A = lambda j. sum(1..dimindex(:M)) (\\i. A$i$j * x$i)`;;\n\nlet mat = new_definition\n `(mat:num->real^N^M) k = lambda i j. if i = j then &k else &0`;;\n\nlet transp = new_definition\n `(transp:real^N^M->real^M^N) A = lambda i j. A$j$i`;;\n\nlet row = new_definition\n `(row:num->real^N^M->real^N) i A = lambda j. A$i$j`;;\n\nlet column = new_definition\n `(column:num->real^N^M->real^M) j A = lambda i. A$i$j`;;\n\nlet rows = new_definition\n `rows(A:real^N^M) = { row i A | 1 <= i /\\ i <= dimindex(:M)}`;;\n\nlet columns = new_definition\n `columns(A:real^N^M) = { column i A | 1 <= i /\\ i <= dimindex(:N)}`;;\n\nlet MATRIX_CMUL_COMPONENT = `!c A:real^N^M i. (c %% A)$i$j = c * A$i$j`;;\n\nlet MATRIX_ADD_COMPONENT = `!A B:real^N^M i j. (A + B)$i$j = A$i$j + B$i$j`;;\n\nlet MATRIX_SUB_COMPONENT = `!A B:real^N^M i j. (A - B)$i$j = A$i$j - B$i$j`;;\n\nlet MATRIX_NEG_COMPONENT = `!A:real^N^M i j. (--A)$i$j = --(A$i$j)`;;\n\nlet TRANSP_COMPONENT = `!A:real^N^M i j. (transp A)$i$j = A$j$i`;;\n\nlet MAT_COMPONENT = `!n i j.\n 1 <= i /\\ i <= dimindex(:M) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> (mat n:real^N^M)$i$j = if i = j then &n else &0`;;\n\nlet MAT_0_COMPONENT = `!i j. (mat 0:real^N^M)$i$j = &0`;;\n\nlet MATRIX_ADD_ROW = `!X Y:real^M^N i. (X + Y)$i = X$i + Y$i`;;\n\nlet MATRIX_SUB_ROW = `!X Y:real^M^N i. (X - Y)$i = X$i - Y$i`;;\n\nlet MATRIX_NEG_ROW = `!X:real^M^N i. (--X)$i = --(X$i)`;;\n\nlet MATRIX_CMUL_ROW = `!c X:real^M^N i. (c %% X)$i = c % X$i`;;\n\nlet MAT_0_ROW = `mat 0:real^M^N$i = vec 0`;;\n\nlet symmetric_matrix = new_definition\n `symmetric_matrix (A:real^N^N) <=> transp A = A`;;\n\nlet normal_matrix = new_definition\n `normal_matrix (A:real^N^N) <=> transp A ** A = A ** transp A`;;\n\nlet SYMMETRIC_IMP_NORMAL_MATRIX = `!A:real^N^N. symmetric_matrix A ==> normal_matrix A`;;\n\nlet MATRIX_ARITH_TAC =\n let CART2_EQ_FULL = `!x y:A^M^N. x = y <=> (!i j. x$i$j = y$i$j)`;;\n\nlet MAT_CMUL = `!a. mat a = &a %% mat 1`;;\n\nlet ROW_0 = `!i. row i (mat 0:real^N^N) = vec 0`;;\n\nlet COLUMN_0 = `!i. column i (mat 0:real^N^N) = vec 0`;;\n\nlet MATRIX_CMUL_ASSOC = `!a b X:real^M^N. a %% (b %% X) = (a * b) %% X`;;\n\nlet MATRIX_CMUL_LID = `!X:real^M^N. &1 %% X = X`;;\n\nlet MATRIX_ADD_SYM = `!A:real^N^M B. A + B = B + A`;;\n\nlet MATRIX_ADD_ASSOC = `!A:real^N^M B C. A + (B + C) = (A + B) + C`;;\n\nlet MATRIX_ADD_LID = `!A. mat 0 + A = A`;;\n\nlet MATRIX_ADD_RID = `!A. A + mat 0 = A`;;\n\nlet MATRIX_ADD_LNEG = `!A. --A + A = mat 0`;;\n\nlet MATRIX_ADD_RNEG = `!A. A + --A = mat 0`;;\n\nlet MATRIX_SUB = `!A:real^N^M B. A - B = A + --B`;;\n\nlet MATRIX_SUB_REFL = `!A. A - A = mat 0`;;\n\nlet MATRIX_SUB_EQ = `!A B:real^N^M. A - B = mat 0 <=> A = B`;;\n\nlet MATRIX_SUB_ADD = `!A B:real^N^M. (A - B) + B = A`;;\n\nlet MATRIX_SUB_ADD2 = `!A B:real^N^M. A + (B - A) = B`;;\n\nlet MATRIX_ADD_LDISTRIB = `!A:real^N^M B:real^P^N C. A ** (B + C) = A ** B + A ** C`;;\n\nlet MATRIX_MUL_LID = `!A:real^N^M. mat 1 ** A = A`;;\n\nlet MATRIX_MUL_RID = `!A:real^N^M. A ** mat 1 = A`;;\n\nlet MATRIX_MUL_ASSOC = `!A:real^N^M B:real^P^N C:real^Q^P. A ** B ** C = (A ** B) ** C`;;\n\nlet MATRIX_MUL_LZERO = `!A. (mat 0:real^N^M) ** (A:real^P^N) = mat 0`;;\n\nlet MATRIX_MUL_RZERO = `!A. (A:real^N^M) ** (mat 0:real^P^N) = mat 0`;;\n\nlet MATRIX_ADD_RDISTRIB = `!A:real^N^M B C:real^P^N. (A + B) ** C = A ** C + B ** C`;;\n\nlet MATRIX_SUB_LDISTRIB = `!A:real^N^M B C:real^P^N. A ** (B - C) = A ** B - A ** C`;;\n\nlet MATRIX_SUB_RDISTRIB = `!A:real^N^M B C:real^P^N. (A - B) ** C = A ** C - B ** C`;;\n\nlet MATRIX_MUL_LMUL = `!A:real^N^M B:real^P^N c. (c %% A) ** B = c %% (A ** B)`;;\n\nlet MATRIX_MUL_RMUL = `!A:real^N^M B:real^P^N c. A ** (c %% B) = c %% (A ** B)`;;\n\nlet MATRIX_CMUL_ADD_LDISTRIB = `!A:real^N^M B c. c %% (A + B) = c %% A + c %% B`;;\n\nlet MATRIX_CMUL_SUB_LDISTRIB = `!A:real^N^M B c. c %% (A - B) = c %% A - c %% B`;;\n\nlet MATRIX_CMUL_ADD_RDISTRIB = `!A:real^N^M b c. (b + c) %% A = b %% A + c %% A`;;\n\nlet MATRIX_CMUL_SUB_RDISTRIB = `!A:real^N^M b c. (b - c) %% A = b %% A - c %% A`;;\n\nlet MATRIX_CMUL_RZERO = `!c. c %% mat 0 = mat 0`;;\n\nlet MATRIX_CMUL_LZERO = `!A. &0 %% A = mat 0`;;\n\nlet MATRIX_NEG_MINUS1 = `!A:real^N^M. --A = --(&1) %% A`;;\n\nlet MATRIX_ADD_AC = `(A:real^N^M) + B = B + A /\\\n (A + B) + C = A + (B + C) /\\\n A + (B + C) = B + (A + C)`;;\n\nlet MATRIX_NEG_ADD = `!A B:real^N^M. --(A + B) = --A + --B`;;\n\nlet MATRIX_NEG_SUB = `!A B:real^N^M. --(A - B) = B - A`;;\n\nlet MATRIX_NEG_0 = `--(mat 0) = mat 0`;;\n\nlet MATRIX_SUB_RZERO = `!A:real^N^M. A - mat 0 = A`;;\n\nlet MATRIX_SUB_LZERO = `!A:real^N^M. mat 0 - A = --A`;;\n\nlet MATRIX_NEG_EQ_0 = `!A:real^N^M. --A = mat 0 <=> A = mat 0`;;\n\nlet MATRIX_VECTOR_MUL_ASSOC = `!A:real^N^M B:real^P^N x:real^P. A ** B ** x = (A ** B) ** x`;;\n\nlet MATRIX_VECTOR_MUL_LID = `!x:real^N. mat 1 ** x = x`;;\n\nlet MATRIX_VECTOR_MUL_LZERO = `!x:real^N. mat 0 ** x = vec 0`;;\n\nlet MATRIX_VECTOR_MUL_RZERO = `!A:real^M^N. A ** vec 0 = vec 0`;;\n\nlet MATRIX_VECTOR_MUL_ADD_LDISTRIB = `!A:real^M^N x:real^M y. A ** (x + y) = A ** x + A ** y`;;\n\nlet MATRIX_VECTOR_MUL_SUB_LDISTRIB = `!A:real^M^N x:real^M y. A ** (x - y) = A ** x - A ** y`;;\n\nlet MATRIX_VECTOR_MUL_ADD_RDISTRIB = `!A:real^M^N B x:real^M. (A + B) ** x = (A ** x) + (B ** x)`;;\n\nlet MATRIX_VECTOR_MUL_SUB_RDISTRIB = `!A:real^M^N B x:real^M. (A - B) ** x = (A ** x) - (B ** x)`;;\n\nlet MATRIX_VECTOR_MUL_RMUL = `!A:real^M^N x:real^M c. A ** (c % x) = c % (A ** x)`;;\n\nlet MATRIX_MUL_LNEG = `!A:real^N^M B:real^P^N. (--A) ** B = --(A ** B)`;;\n\nlet MATRIX_MUL_RNEG = `!A:real^N^M B:real^P^N. A ** --B = --(A ** B)`;;\n\nlet MATRIX_NEG_NEG = `!A:real^N^M. --(--A) = A`;;\n\nlet MATRIX_TRANSP_MUL = `!A B. transp(A ** B) = transp(B) ** transp(A)`;;\n\nlet TRANSP_EQ_0 = `!A:real^N^M. transp A = mat 0 <=> A = mat 0`;;\n\nlet SYMMETRIC_MATRIX_MUL = `!A B:real^N^N.\n symmetric_matrix A /\\ symmetric_matrix B\n ==> (symmetric_matrix(A ** B) <=> A ** B = B ** A)`;;\n\nlet MATRIX_EQ = `!A:real^N^M B. (A = B) = !x:real^N. A ** x = B ** x`;;\n\nlet MATRIX_EQ_0 = `!A:real^N^N. A = mat 0 <=> !x. A ** x = vec 0`;;\n\nlet MATRIX_VECTOR_MUL_COMPONENT = `!A:real^N^M x k.\n 1 <= k /\\ k <= dimindex(:M) ==> ((A ** x)$k = (A$k) dot x)`;;\n\nlet DOT_LMUL_MATRIX = `!A:real^N^M x:real^M y:real^N. (x ** A) dot y = x dot (A ** y)`;;\n\nlet TRANSP_MATRIX_CMUL = `!A:real^M^N c. transp(c %% A) = c %% transp A`;;\n\nlet SYMMETRIC_MATRIX_CMUL = `!c A:real^N^N.\n symmetric_matrix A ==> symmetric_matrix(c %% A)`;;\n\nlet TRANSP_MATRIX_ADD = `!A B:real^N^M. transp(A + B) = transp A + transp B`;;\n\nlet SYMMETRIC_MATRIX_ADD = `!A B:real^N^N.\n symmetric_matrix A /\\ symmetric_matrix B\n ==> symmetric_matrix(A + B)`;;\n\nlet TRANSP_MATRIX_SUB = `!A B:real^N^M. transp(A - B) = transp A - transp B`;;\n\nlet SYMMETRIC_MATRIX_SUB = `!A B:real^N^N.\n symmetric_matrix A /\\ symmetric_matrix B\n ==> symmetric_matrix(A - B)`;;\n\nlet TRANSP_MATRIX_NEG = `!A:real^N^M. transp(--A) = --(transp A)`;;\n\nlet SYMMETRIC_MATRIX_NEG = `!A:real^N^N. symmetric_matrix(--A) <=> symmetric_matrix A`;;\n\nlet TRANSP_MAT = `!n. transp(mat n) = mat n`;;\n\nlet TRANSP_TRANSP = `!A:real^N^M. transp(transp A) = A`;;\n\nlet SYMMETRIC_MATRIX_MAT = `!n. symmetric_matrix(mat n)`;;\n\nlet SYMMETRIC_MATRIX_COVARIANCE = `!A:real^N^M. symmetric_matrix(transp A ** A)`;;\n\nlet SYMMETRIC_MATRIX_SIMILAR = `!A B:real^N^N.\n symmetric_matrix B ==> symmetric_matrix(transp A ** B ** A)`;;\n\nlet TRANSP_EQ = `!A B:real^M^N. transp A = transp B <=> A = B`;;\n\nlet ROW_TRANSP = `!A:real^N^M i.\n 1 <= i /\\ i <= dimindex(:N) ==> row i (transp A) = column i A`;;\n\nlet COLUMN_TRANSP = `!A:real^N^M i.\n 1 <= i /\\ i <= dimindex(:M) ==> column i (transp A) = row i A`;;\n\nlet ROWS_TRANSP = `!A:real^N^M. rows(transp A) = columns A`;;\n\nlet COLUMNS_TRANSP = `!A:real^N^M. columns(transp A) = rows A`;;\n\nlet VECTOR_MATRIX_MUL_TRANSP = `!A:real^M^N x:real^N. x ** A = transp A ** x`;;\n\nlet MATRIX_VECTOR_MUL_TRANSP = `!A:real^M^N x:real^M. A ** x = x ** transp A`;;\n\nlet ROWS_NONEMPTY = `!A:real^N^M. ~(rows A = {})`;;\n\nlet COLUMNS_NONEMPTY = `!A:real^N^M. ~(columns A = {})`;;\n\nlet FINITE_ROWS = `!A:real^N^M. FINITE(rows A)`;;\n\nlet FINITE_COLUMNS = `!A:real^N^M. FINITE(columns A)`;;\n\nlet CARD_ROWS_LE = `!A:real^M^N. CARD(rows A) <= dimindex(:N)`;;\n\nlet CARD_COLUMNS_LE = `!A:real^M^N. CARD(columns A) <= dimindex(:M)`;;\n\nlet MATRIX_EQUAL_ROWS = `!A B:real^N^M.\n A = B <=> !i. 1 <= i /\\ i <= dimindex(:M) ==> row i A = row i B`;;\n\nlet MATRIX_EQUAL_COLUMNS = `!A B:real^N^M.\n A = B <=> !i. 1 <= i /\\ i <= dimindex(:N) ==> column i A = column i B`;;\n\nlet MATRIX_CMUL_EQ_0 = `!A:real^M^N c. c %% A = mat 0 <=> c = &0 \\/ A = mat 0`;;\n\nlet MAT_EQ = `!m n. mat m = mat n <=> m = n`;;\n\nlet MATRIX_VECTOR_LMUL = `!A:real^M^N c x:real^M. (c %% A) ** x = c % (A ** x)`;;\n\nlet MATRIX_VECTOR_MUL_LNEG = `!A:real^M^N x:real^M. --A ** x = --(A ** x)`;;\n\nlet MATRIX_VECTOR_MUL_RNEG = `!A:real^M^N x:real^M. A ** --x = --(A ** x)`;;\n\nlet COLUMN_MATRIX_MUL = `!A:real^N^M B:real^P^N.\n 1 <= i /\\ i <= dimindex(:P) ==> column i (A ** B) = A ** column i B`;;\n\nlet ROW_MATRIX_MUL = `!A:real^N^M B:real^P^N.\n 1 <= i /\\ i <= dimindex(:M) ==> row i (A ** B) = transp B ** row i A`;;\n\nlet MATRIX_MUL_DOT = `!A:real^N^M x. A ** x = lambda i. A$i dot x`;;\n\nlet MATRIX_MUL_VSUM = `!A:real^N^M x. A ** x = vsum(1..dimindex(:N)) (\\i. x$i % column i A)`;;\n\nlet VECTOR_COMPONENTWISE = `!x:real^N.\n x = lambda j. sum(1..dimindex(:N))\n (\\i. x$i * (basis i :real^N)$j)`;;\n\nlet LINEAR_COMPONENTWISE_EXPANSION = `!f:real^M->real^N.\n linear(f)\n ==> !x j. 1 <= j /\\ j <= dimindex(:N)\n ==> (f x $j =\n sum(1..dimindex(:M)) (\\i. x$i * f(basis i)$j))`;;\n\nlet invertible = new_definition\n `invertible(A:real^N^M) <=>\n ?A':real^M^N. (A ** A' = mat 1) /\\ (A' ** A = mat 1)`;;\n\nlet INVERTIBLE_I = `invertible(mat 1:real^N^N)`;;\n\nlet INVERTIBLE_NEG = `!A:real^N^M. invertible(--A) <=> invertible A`;;\n\nlet INVERTIBLE_CMUL = `!A:real^N^M c. invertible(c %% A) <=> ~(c = &0) /\\ invertible(A)`;;\n\nlet INVERTIBLE_MAT = `!a. invertible(mat a:real^N^N) <=> ~(a = 0)`;;\n\nlet MATRIX_ENTIRE = `(!A:real^N^M B:real^P^N. invertible A ==> (A ** B = mat 0 <=> B = mat 0)) /\\\n (!A:real^N^M B:real^P^N. invertible B ==> (A ** B = mat 0 <=> A = mat 0))`;;\n\nlet matrix = new_definition\n `(matrix:(real^M->real^N)->real^M^N) f = lambda i j. f(basis j)$i`;;\n\nlet MATRIX_COMPONENT = `!f:real^M->real^N i j.\n 1 <= j /\\ j <= dimindex(:M)\n ==> (matrix f)$i$j = f (basis j)$i`;;\n\nlet MATRIX_VECTOR_MUL_LINEAR = `!A:real^N^M. linear(\\x. A ** x)`;;\n\nlet MATRIX_WORKS = `!f:real^M->real^N. linear f ==> !x. matrix f ** x = f(x)`;;\n\nlet MATRIX_VECTOR_MUL = `!f:real^M->real^N. linear f ==> f = \\x. matrix f ** x`;;\n\nlet MATRIX_OF_MATRIX_VECTOR_MUL = `!A:real^N^M. matrix(\\x. A ** x) = A`;;\n\nlet MATRIX_COMPOSE = `!f g. linear f /\\ linear g ==> (matrix(g o f) = matrix g ** matrix f)`;;\n\nlet MATRIX_0 = `matrix(\\x. vec 0):real^M^N = mat 0`;;\n\nlet MATRIX_VECTOR_COLUMN = `!A:real^N^M x.\n A ** x = vsum(1..dimindex(:N)) (\\i. x$i % (transp A)$i)`;;\n\nlet MATRIX_MUL_COMPONENT = `!i. 1 <= i /\\ i <= dimindex(:P)\n ==> ((A:real^N^P) ** (B:real^M^N))$i = transp B ** A$i`;;\n\nlet ADJOINT_MATRIX = `!A:real^N^M. adjoint(\\x. A ** x) = (\\x. transp A ** x)`;;\n\nlet MATRIX_ADJOINT = `!f. linear f ==> matrix(adjoint f) = transp(matrix f)`;;\n\nlet MATRIX_ID = `matrix(\\x. x) = mat 1`;;\n\nlet MATRIX_I = `matrix I = mat 1`;;\n\nlet LINEAR_EQ_MATRIX = `!f g. linear f /\\ linear g /\\ matrix f = matrix g ==> f = g`;;\n\nlet MATRIX_CMUL = `!f:real^M->real^N c.\n linear f ==> matrix(\\x. c % f x) = c %% matrix f`;;\n\nlet MATRIX_NEG = `!f:real^M->real^N.\n linear f ==> matrix(\\x. --(f x)) = --(matrix f)`;;\n\nlet MATRIX_ADD = `!f g:real^M->real^N.\n linear f /\\ linear g ==> matrix(\\x. f x + g x) = matrix f + matrix g`;;\n\nlet MATRIX_SELF_ADJOINT = `!f. linear f ==> (adjoint f = f <=> symmetric_matrix(matrix f))`;;\n\nlet LINEAR_MATRIX_EXISTS = `!f:real^M->real^N. linear f <=> ?A:real^M^N. f = \\x. A ** x`;;\n\nlet LINEAR_1_GEN = `!f:real^N->real^N.\n dimindex(:N) = 1 ==> (linear f <=> ?c. f = \\x. c % x)`;;\n\nlet LINEAR_1 = `!f:real^1->real^1. linear f <=> ?c. f = \\x. c % x`;;\n\nlet SYMMETRIC_MATRIX = `!A:real^N^N. symmetric_matrix A <=> adjoint(\\x. A ** x) = \\x. A ** x`;;\n\nlet DOT_MATRIX_TRANSP_LMUL = `!A x y:real^N. (transp A ** x) dot y = x dot (A ** y)`;;\n\nlet DOT_MATRIX_TRANSP_RMUL = `!A x y:real^N. x dot (transp A ** y) = (A ** x) dot y`;;\n\nlet SYMMETRIC_MATRIX_ORTHOGONAL_EIGENVECTORS = `!A:real^N^N v w a b.\n symmetric_matrix A /\\ A ** v = a % v /\\ A ** w = b % w /\\ ~(a = b)\n ==> orthogonal v w`;;\n\nlet MATRIX_INJECTIVE_0 = `!m:real^M^N.\n (!x y:real^M. m ** x = m ** y ==> x = y) <=>\n (!x:real^M. m ** x = vec 0 ==> x = vec 0)`;;\n\nlet onorm = new_definition\n `onorm (f:real^M->real^N) = sup { norm(f x) | norm(x) = &1 }`;;\n\nlet NORM_BOUND_GENERALIZE = `!f:real^M->real^N b.\n linear f\n ==> ((!x. norm(x) = &1 ==> norm(f x) <= b) <=>\n (!x. norm(f x) <= b * norm(x)))`;;\n\nlet ONORM_DOT = `!f:real^M->real^N. onorm f = sup {f x dot y | norm x = &1 /\\ norm y = &1}`;;\n\nlet ONORM = `!f:real^M->real^N.\n linear f\n ==> (!x. norm(f x) <= onorm f * norm(x)) /\\\n (!b. (!x. norm(f x) <= b * norm(x)) ==> onorm f <= b)`;;\n\nlet ONORM_LE_EQ = `!f:real^M->real^N b.\n linear f ==> (onorm f <= b <=> !x. norm(f x) <= b * norm x)`;;\n\nlet ONORM_POS_LE = `!f. linear f ==> &0 <= onorm f`;;\n\nlet ONORM_EQ_0 = `!f:real^M->real^N. linear f ==> ((onorm f = &0) <=> (!x. f x = vec 0))`;;\n\nlet ONORM_CONST = `!y:real^N. onorm(\\x:real^M. y) = norm(y)`;;\n\nlet ONORM_POS_LT = `!f. linear f ==> (&0 < onorm f <=> ~(!x. f x = vec 0))`;;\n\nlet ONORM_COMPOSE = `!f g. linear f /\\ linear g ==> onorm(f o g) <= onorm f * onorm g`;;\n\nlet ONORM_CMUL = `!f:real^M->real^N c. linear f ==> onorm(\\x. c % f x) = abs c * onorm f`;;\n\nlet ONORM_NEG = `!f:real^M->real^N. onorm(\\x. --f x) = onorm f`;;\n\nlet ONORM_TRIANGLE = `!f:real^M->real^N g.\n linear f /\\ linear g ==> onorm(\\x. f x + g x) <= onorm f + onorm g`;;\n\nlet ONORM_TRIANGLE_LE = `!f g. linear f /\\ linear g /\\ onorm(f) + onorm(g) <= e\n ==> onorm(\\x. f x + g x) <= e`;;\n\nlet ONORM_TRIANGLE_LT = `!f g. linear f /\\ linear g /\\ onorm(f) + onorm(g) < e\n ==> onorm(\\x. f x + g x) < e`;;\n\nlet ONORM_ID = `onorm(\\x:real^N. x) = &1`;;\n\nlet ONORM_I = `onorm(I:real^N->real^N) = &1`;;\n\nlet ONORM_INVERSE_FUNCTION_BOUND = `!f g:real^M->real^N.\n linear f /\\ linear g /\\ f o g = I ==> &1 <= onorm f * onorm g`;;\n\nlet ONORM_ADJOINT = `!f:real^N->real^N. linear f ==> onorm(adjoint f) = onorm f`;;\n\nlet ONORM_COMPOSE_ADJOINT_LEFT = `!f:real^N->real^N. linear f ==> onorm(adjoint f o f) = onorm f pow 2`;;\n\nlet ONORM_COMPOSE_ADJOINT_RIGHT = `!f:real^N->real^N. linear f ==> onorm(f o adjoint f) = onorm f pow 2`;;\n\nlet ONORM_TRANSP = `!A:real^N^N. onorm(\\x. transp A ** x) = onorm(\\x. A ** x)`;;\n\nlet ONORM_COVARIANCE = `!A:real^N^N.\n onorm(\\x. (transp A ** A) ** x) = onorm(\\x. A ** x) pow 2`;;\n\nlet ONORM_COVARIANCE_ALT = `!A:real^N^N.\n onorm(\\x. (A ** transp A) ** x) = onorm(\\x. A ** x) pow 2`;;\n\nlet ONORM_LE_EQ_2,ONORM_LE_EQ_2_ABS = (CONJ_PAIR o prove)\n (`(!f:real^M->real^N b.\n linear f\n ==> (onorm f <= b <=> !x y. x dot (f y) <= b * norm x * norm y)) /\\\n (!f:real^M->real^N b.\n linear f\n ==> (onorm f <= b <=> !x y. abs(x dot (f y)) <= b * norm x * norm y))`,\n REWRITE_TAC[AND_FORALL_THM] THEN REPEAT GEN_TAC THEN\n ASM_CASES_TAC `linear(f:real^M->real^N)` THEN ASM_REWRITE_TAC[] THEN\n MATCH_MP_TAC(TAUT\n `(r ==> q) /\\ (p ==> r) /\\ (q ==> p) ==> (p <=> q) /\\ (p <=> r)`) THEN\n CONJ_TAC THENL\n [REPEAT(MATCH_MP_TAC MONO_FORALL THEN GEN_TAC) THEN REAL_ARITH_TAC;\n ASM_SIMP_TAC[ONORM_LE_EQ]] THEN\n CONJ_TAC THEN DISCH_TAC THENL\n [MAP_EVERY X_GEN_TAC [`x:real^N`; `y:real^M`] THEN\n TRANS_TAC REAL_LE_TRANS `norm(x:real^N) * norm((f:real^M->real^N) y)` THEN\n REWRITE_TAC[NORM_CAUCHY_SCHWARZ_ABS] THEN\n GEN_REWRITE_TAC RAND_CONV [REAL_ARITH `b * x * y:real = x * b * y`] THEN\n ASM_SIMP_TAC[REAL_LE_LMUL; NORM_POS_LE];\n X_GEN_TAC `x:real^M` THEN\n ASM_CASES_TAC `(f:real^M->real^N) x = vec 0` THENL\n [ASM_CASES_TAC `x:real^M = vec 0` THEN\n ASM_REWRITE_TAC[NORM_0; REAL_MUL_RZERO; REAL_LE_REFL] THEN\n FIRST_X_ASSUM(MP_TAC o SPECL [`basis 1:real^N`; `x:real^M`]) THEN\n ASM_SIMP_TAC[DOT_RZERO; NORM_BASIS; LE_REFL;\n DIMINDEX_GE_1; REAL_MUL_LID];\n FIRST_ASSUM(MP_TAC o SPECL [`(f:real^M->real^N) x`; `x:real^M`]) THEN\n REWRITE_TAC[GSYM NORM_POW_2; REAL_ARITH\n `y pow 2 <= b * y * x <=> y * y <= y * b * x`] THEN\n ASM_SIMP_TAC[REAL_LE_LMUL_EQ; NORM_POS_LT]]]);;\n\nlet lift = new_definition\n `(lift:real->real^1) x = lambda i. x`;;\n\nlet drop = new_definition\n `(drop:real^1->real) x = x$1`;;\n\nlet LIFT_COMPONENT = `!x. (lift x)$1 = x`;;\n\nlet LIFT_DROP = `(!x. lift(drop x) = x) /\\ (!x. drop(lift x) = x)`;;\n\nlet IMAGE_LIFT_DROP = `(!s. IMAGE (lift o drop) s = s) /\\ (!s. IMAGE (drop o lift) s = s)`;;\n\nlet IN_IMAGE_LIFT_DROP = `(!x s. x IN IMAGE lift s <=> drop x IN s) /\\\n (!x s. x IN IMAGE drop s <=> lift x IN s)`;;\n\nlet FORALL_LIFT = `(!x. P x) = (!x. P(lift x))`;;\n\nlet EXISTS_LIFT = `(?x. P x) = (?x. P(lift x))`;;\n\nlet FORALL_DROP = `(!x. P x) = (!x. P(drop x))`;;\n\nlet EXISTS_DROP = `(?x. P x) = (?x. P(drop x))`;;\n\nlet FORALL_LIFT_FUN = `!P:(A->real^1)->bool. (!f. P f) <=> (!f. P(lift o f))`;;\n\nlet FORALL_DROP_FUN = `!P:(A->real)->bool. (!f. P f) <=> (!f. P(drop o f))`;;\n\nlet FORALL_FUN_LIFT = `!P:(real->A)->bool. (!f. P f) <=> (!f. P(f o lift))`;;\n\nlet FORALL_FUN_DROP = `!P:(real^1->A)->bool. (!f. P f) <=> (!f. P(f o drop))`;;\n\nlet EXISTS_LIFT_FUN = `!P:(A->real^1)->bool. (?f. P f) <=> (?f. P(lift o f))`;;\n\nlet EXISTS_DROP_FUN = `!P:(A->real)->bool. (?f. P f) <=> (?f. P(drop o f))`;;\n\nlet EXISTS_FUN_LIFT = `!P:(real->A)->bool. (?f. P f) <=> (?f. P(f o lift))`;;\n\nlet EXISTS_FUN_DROP = `!P:(real^1->A)->bool. (?f. P f) <=> (?f. P(f o drop))`;;\n\nlet LIFT_EQ = `!x y. (lift x = lift y) <=> (x = y)`;;\n\nlet DROP_EQ = `!x y. (drop x = drop y) <=> (x = y)`;;\n\nlet LIFT_IN_IMAGE_LIFT = `!x s. (lift x) IN (IMAGE lift s) <=> x IN s`;;\n\nlet FORALL_LIFT_IMAGE = `!P. (!s. P s) <=> (!s. P(IMAGE lift s))`;;\n\nlet EXISTS_LIFT_IMAGE = `!P. (?s. P s) <=> (?s. P(IMAGE lift s))`;;\n\nlet SUBSET_LIFT_IMAGE = `!s t. IMAGE lift s SUBSET IMAGE lift t <=> s SUBSET t`;;\n\nlet FORALL_DROP_IMAGE = `!P. (!s. P s) <=> (!s. P(IMAGE drop s))`;;\n\nlet EXISTS_DROP_IMAGE = `!P. (?s. P s) <=> (?s. P(IMAGE drop s))`;;\n\nlet SUBSET_DROP_IMAGE = `!s t. IMAGE drop s SUBSET IMAGE drop t <=> s SUBSET t`;;\n\nlet DROP_IN_IMAGE_DROP = `!x s. (drop x) IN (IMAGE drop s) <=> x IN s`;;\n\nlet LIFT_NUM = `!n. lift(&n) = vec n`;;\n\nlet LIFT_ADD = `!x y. lift(x + y) = lift x + lift y`;;\n\nlet LIFT_SUB = `!x y. lift(x - y) = lift x - lift y`;;\n\nlet LIFT_CMUL = `!x c. lift(c * x) = c % lift(x)`;;\n\nlet LIFT_NEG = `!x. lift(--x) = --(lift x)`;;\n\nlet LIFT_EQ_CMUL = `!x. lift x = x % vec 1`;;\n\nlet SUM_VSUM = `!f s. sum s f = drop(vsum s(lift o f))`;;\n\nlet VSUM_REAL = `!f s. vsum s f = lift(sum s (drop o f))`;;\n\nlet LIFT_SUM = `!k x. lift(sum k x) = vsum k (lift o x)`;;\n\nlet DROP_VSUM = `!k x. drop(vsum k x) = sum k (drop o x)`;;\n\nlet DROP_LAMBDA = `!x. drop(lambda i. x i) = x 1`;;\n\nlet DROP_VEC = `!n. drop(vec n) = &n`;;\n\nlet DROP_ADD = `!x y. drop(x + y) = drop x + drop y`;;\n\nlet DROP_SUB = `!x y. drop(x - y) = drop x - drop y`;;\n\nlet DROP_CMUL = `!x c. drop(c % x) = c * drop(x)`;;\n\nlet DROP_NEG = `!x. drop(--x) = --(drop x)`;;\n\nlet NORM_1 = `!x. norm x = abs(drop x)`;;\n\nlet DIST_1 = `!x y. dist(x,y) = abs(drop x - drop y)`;;\n\nlet NORM_1_POS = `!x. &0 <= drop x ==> norm x = drop x`;;\n\nlet NORM_LIFT = `!x. norm(lift x) = abs(x)`;;\n\nlet DIST_LIFT = `!x y. dist(lift x,lift y) = abs(x - y)`;;\n\nlet ABS_DROP = `!x. abs(drop x) = norm x`;;\n\nlet LINEAR_VMUL_DROP = `!f v. linear f ==> linear (\\x. drop(f x) % v)`;;\n\nlet LINEAR_FROM_REALS = `!f:real^1->real^N. linear f ==> f = \\x. drop x % column 1 (matrix f)`;;\n\nlet LINEAR_TO_REALS = `!f:real^N->real^1. linear f ==> f = \\x. lift(row 1 (matrix f) dot x)`;;\n\nlet LINEAR_FROM_1 = `!f:real^1->real^N. linear f <=> ?c. f = \\x. drop x % c`;;\n\nlet DROP_EQ_0 = `!x. drop x = &0 <=> x = vec 0`;;\n\nlet DROP_WLOG_LE = `(!x y. P x y <=> P y x) /\\ (!x y. drop x <= drop y ==> P x y)\n ==> (!x y. P x y)`;;\n\nlet IMAGE_LIFT_UNIV = `IMAGE lift (:real) = (:real^1)`;;\n\nlet IMAGE_DROP_UNIV = `IMAGE drop (:real^1) = (:real)`;;\n\nlet LINEAR_LIFT_DOT = `!a. linear(\\x. lift(a dot x))`;;\n\nlet LINEAR_TO_1 = `!f:real^N->real^1. linear f <=> ?a. f = \\x. lift(a dot x)`;;\n\nlet LINEAR_LIFT_COMPONENT = `!k. linear(\\x:real^N. lift(x$k))`;;\n\nlet BILINEAR_DROP_MUL = `bilinear (\\x y:real^N. drop x % y)`;;\n\nlet BILINEAR_MUL_DROP = `bilinear(\\y:real^N x. drop x % y)`;;\n\nlet BILINEAR_LIFT_MUL = `bilinear (\\x y. lift(drop x * drop y))`;;\n\nlet LINEAR_COMPONENTWISE = `!f:real^M->real^N.\n linear f <=>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> linear(\\x. lift(f(x)$i))`;;\n\nlet DROP_BASIS = `!i. drop(basis i) = if i = 1 then &1 else &0`;;\n\nlet indicator = new_definition\n `indicator s :real^M->real^1 = \\x. if x IN s then vec 1 else vec 0`;;\n\nlet DROP_INDICATOR = `!s x. drop(indicator s x) = if x IN s then &1 else &0`;;\n\nlet DROP_INDICATOR_POS_LE = `!s x. &0 <= drop(indicator s x)`;;\n\nlet DROP_INDICATOR_LE_1 = `!s x. drop(indicator s x) <= &1`;;\n\nlet DROP_INDICATOR_ABS_LE_1 = `!s x. abs(drop(indicator s x)) <= &1`;;\n\nlet INDICATOR_COMPLEMENT = `!s. indicator((:real^N) DIFF s) = \\x. vec 1 - indicator s x`;;\n\nlet VECTORIZE_ADD = `!m1 m2:real^N^M. vectorize(m1 + m2) = vectorize m1 + vectorize m2`;;\n\nlet VECTORIZE_CMUL = `!c m:real^N^M. vectorize(c %% m) = c % vectorize m`;;\n\nlet VECTORIZE_SUB = `!m1 m2:real^N^M. vectorize(m1 - m2) = vectorize m1 - vectorize m2`;;\n\nlet VECTORIZE_0 = `vectorize(mat 0:real^N^M) = vec 0`;;\n\nlet MATRIFY_0 = `matrify(vec 0) = mat 0`;;\n\nlet VECTORIZE_EQ_0 = `!m:real^N^M. vectorize m = vec 0 <=> m = mat 0`;;\n\nlet MATRIFY_ADD = `!x y:real^(M,N)finite_prod. matrify(x + y) = matrify x + matrify y`;;\n\nlet MATRIFY_CMUL = `!c x:real^(M,N)finite_prod. matrify(c % x) = c %% matrify x`;;\n\nlet MATRIFY_SUB = `!x y:real^(M,N)finite_prod. matrify(x - y) = matrify x - matrify y`;;\n\nlet MATRIFY_EQ_0 = `!m:real^(M,N)finite_prod. matrify m = mat 0 <=> m = vec 0`;;\n\nlet BILINEAR_MATRIX_VECTOR_MUL = `bilinear (\\(m:real^(M,N)finite_prod) x:real^N. matrify m ** x)`;;\n\nlet BILINEAR_MATRIX_MUL = `bilinear (\\(m1:real^(M,N)finite_prod) (m2:real^(N,P)finite_prod).\n vectorize(matrify m1 ** matrify m2))`;;\n\nlet LINEAR_FSTCART = `linear fstcart`;;\n\nlet LINEAR_SNDCART = `linear sndcart`;;\n\nlet FSTCART_VEC = `!n. fstcart(vec n) = vec n`;;\n\nlet FSTCART_ADD = `!x:real^(M,N)finite_sum y. fstcart(x + y) = fstcart(x) + fstcart(y)`;;\n\nlet FSTCART_CMUL = `!x:real^(M,N)finite_sum c. fstcart(c % x) = c % fstcart(x)`;;\n\nlet FSTCART_NEG = `!x:real^(M,N)finite_sum. --(fstcart x) = fstcart(--x)`;;\n\nlet FSTCART_SUB = `!x:real^(M,N)finite_sum y. fstcart(x - y) = fstcart(x) - fstcart(y)`;;\n\nlet FSTCART_VSUM = `!k x. FINITE k ==> (fstcart(vsum k x) = vsum k (\\i. fstcart(x i)))`;;\n\nlet SNDCART_VEC = `!n. sndcart(vec n) = vec n`;;\n\nlet SNDCART_ADD = `!x:real^(M,N)finite_sum y. sndcart(x + y) = sndcart(x) + sndcart(y)`;;\n\nlet SNDCART_CMUL = `!x:real^(M,N)finite_sum c. sndcart(c % x) = c % sndcart(x)`;;\n\nlet SNDCART_NEG = `!x:real^(M,N)finite_sum. --(sndcart x) = sndcart(--x)`;;\n\nlet SNDCART_SUB = `!x:real^(M,N)finite_sum y. sndcart(x - y) = sndcart(x) - sndcart(y)`;;\n\nlet SNDCART_VSUM = `!k x. FINITE k ==> (sndcart(vsum k x) = vsum k (\\i. sndcart(x i)))`;;\n\nlet PASTECART_VEC = `!n. pastecart (vec n) (vec n) = vec n`;;\n\nlet PASTECART_ADD = `!x1 y1 x2:real^M y2:real^N.\n pastecart x1 y1 + pastecart x2 y2 = pastecart (x1 + x2) (y1 + y2)`;;\n\nlet PASTECART_CMUL = `!x1 y1 c. pastecart (c % x1) (c % y1) = c % pastecart x1 y1`;;\n\nlet PASTECART_NEG = `!x:real^M y:real^N. pastecart (--x) (--y) = --(pastecart x y)`;;\n\nlet PASTECART_SUB = `!x1 y1 x2:real^M y2:real^N.\n pastecart x1 y1 - pastecart x2 y2 = pastecart (x1 - x2) (y1 - y2)`;;\n\nlet PASTECART_VSUM = `!k x y. FINITE k ==> (pastecart (vsum k x) (vsum k y) =\n vsum k (\\i. pastecart (x i) (y i)))`;;\n\nlet PASTECART_EQ_VEC = `!x y n. pastecart x y = vec n <=> x = vec n /\\ y = vec n`;;\n\nlet FSTCART_SNDCART_MAT_ZERO = `fstcart(mat 0:real^M^(A,B)finite_sum) = mat 0 /\\\n sndcart(mat 0:real^M^(A,B)finite_sum) = mat 0`;;\n\nlet FSTCART_SNDCART_MATRIX_ADD = `!x:real^K^(M,N)finite_sum y.\n fstcart(x + y) = fstcart(x) + fstcart(y) /\\\n sndcart(x + y) = sndcart(x) + sndcart(y)`;;\n\nlet NORM_FSTCART = `!x. norm(fstcart x) <= norm x`;;\n\nlet DIST_FSTCART = `!x y. dist(fstcart x,fstcart y) <= dist(x,y)`;;\n\nlet NORM_SNDCART = `!x. norm(sndcart x) <= norm x`;;\n\nlet DIST_SNDCART = `!x y. dist(sndcart x,sndcart y) <= dist(x,y)`;;\n\nlet DOT_PASTECART = `!x1 x2 y1 y2. (pastecart x1 x2) dot (pastecart y1 y2) =\n x1 dot y1 + x2 dot y2`;;\n\nlet SQNORM_PASTECART = `!x y. norm(pastecart x y) pow 2 = norm(x) pow 2 + norm(y) pow 2`;;\n\nlet NORM_PASTECART = `!x y. norm(pastecart x y) = sqrt(norm(x) pow 2 + norm(y) pow 2)`;;\n\nlet NORM_PASTECART_LE = `!x y. norm(pastecart x y) <= norm(x) + norm(y)`;;\n\nlet DIST_PASTECART_LE = `!x1 y1 x2 y2.\n dist(pastecart x1 y1,pastecart x2 y2)\n <= dist(x1,x2) + dist(y1,y2)`;;\n\nlet NORM_LE_PASTECART = `!x:real^M y:real^N.\n norm(x) <= norm(pastecart x y) /\\\n norm(y) <= norm(pastecart x y)`;;\n\nlet DIST_LE_PASTECART = `!x1 y1 x2 y2.\n dist(x1,x2) <= dist(pastecart x1 y1,pastecart x2 y2) /\\\n dist(y1,y2) <= dist(pastecart x1 y1,pastecart x2 y2)`;;\n\nlet NORM_PASTECART_0 = `(!x. norm(pastecart x (vec 0)) = norm x) /\\\n (!y. norm(pastecart (vec 0) y) = norm y)`;;\n\nlet DIST_PASTECART_CANCEL = `(!x x' y. dist(pastecart x y,pastecart x' y) = dist(x,x')) /\\\n (!x y y'. dist(pastecart x y,pastecart x y') = dist(y,y'))`;;\n\nlet LINEAR_PASTECART = `!f:real^M->real^N g:real^M->real^P.\n linear f /\\ linear g ==> linear (\\x. pastecart (f x) (g x))`;;\n\nlet LINEAR_PASTECART_EQ = `!f:real^M->real^N g:real^M->real^P.\n linear (\\x. pastecart (f x) (g x)) <=> linear f /\\ linear g`;;\n\nlet dropout = new_definition\n `(dropout k:real^M->real^N) x =\n lambda i. if i < k /\\ i <= dimindex(:M) then x$i\n else if i + 1 <= dimindex(:M) then x$(i + 1)\n else &0`;;\n\nlet pushin = new_definition\n `pushin k t x = lambda i. if i < k then x$i\n else if i = k then t\n else x$(i - 1)`;;\n\nlet DROPOUT_PUSHIN = `!k t x.\n dimindex(:M) + 1 = dimindex(:N)\n ==> (dropout k:real^N->real^M) (pushin k t x) = x`;;\n\nlet PUSHIN_DROPOUT = `!k x.\n dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> pushin k (x$k) ((dropout k:real^N->real^M) x) = x`;;\n\nlet DROPOUT_GALOIS = `!k x:real^N y:real^M.\n dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> (y = dropout k x <=> (?t. x = pushin k t y))`;;\n\nlet IN_IMAGE_DROPOUT = `!x s.\n dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> (x IN IMAGE (dropout k:real^N->real^M) s <=>\n ?t. (pushin k t x) IN s)`;;\n\nlet DROPOUT_EQ = `!x y k. dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N) /\\\n x$k = y$k /\\ (dropout k:real^N->real^M) x = dropout k y\n ==> x = y`;;\n\nlet DROPOUT_0 = `dropout k (vec 0:real^N) = vec 0`;;\n\nlet DOT_DROPOUT = `!k x y:real^N.\n dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> (dropout k x:real^M) dot (dropout k y) = x dot y - x$k * y$k`;;\n\nlet DOT_PUSHIN = `!k a b x y:real^M.\n dimindex(:M) + 1 = dimindex(:N) /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> (pushin k a x:real^N) dot (pushin k b y) = x dot y + a * b`;;\n\nlet DROPOUT_ADD = `!k x y:real^N. dropout k (x + y) = dropout k x + dropout k y`;;\n\nlet DROPOUT_SUB = `!k x y:real^N. dropout k (x - y) = dropout k x - dropout k y`;;\n\nlet DROPOUT_MUL = `!k c x:real^N. dropout k (c % x) = c % dropout k x`;;\n\nlet LINEAR_DROPOUT = `!k. linear(dropout k :real^N->real^M)`;;\n\nlet LINEAR_PUSHIN = `!k. linear(pushin k (&0))`;;\n\nlet subspace = new_definition\n `subspace s <=>\n vec(0) IN s /\\\n (!x y. x IN s /\\ y IN s ==> (x + y) IN s) /\\\n (!c x. x IN s ==> (c % x) IN s)`;;\n\nlet span = new_definition\n `span s = subspace hull s`;;\n\nlet dependent = new_definition\n `dependent s <=> ?a. a IN s /\\ a IN span(s DELETE a)`;;\n\nlet independent = new_definition\n `independent s <=> ~(dependent s)`;;\n\nlet SUBSPACE_UNIV = `subspace(UNIV:real^N->bool)`;;\n\nlet SUBSPACE_IMP_NONEMPTY = `!s. subspace s ==> ~(s = {})`;;\n\nlet SUBSPACE_0 = `subspace s ==> vec(0) IN s`;;\n\nlet SUBSPACE_ADD = `!x y s. subspace s /\\ x IN s /\\ y IN s ==> (x + y) IN s`;;\n\nlet SUBSPACE_MUL = `!x c s. subspace s /\\ x IN s ==> (c % x) IN s`;;\n\nlet SUBSPACE_MUL_EQ = `!s c x:real^N. subspace s ==> ((c % x) IN s <=> c = &0 \\/ x IN s)`;;\n\nlet SUBSPACE_NEG = `!x s. subspace s /\\ x IN s ==> (--x) IN s`;;\n\nlet SUBSPACE_NEG_EQ = `!s x:real^N. subspace s ==> (--x IN s <=> x IN s)`;;\n\nlet SUBSPACE_SUB = `!x y s. subspace s /\\ x IN s /\\ y IN s ==> (x - y) IN s`;;\n\nlet SUBSPACE_VSUM = `!s f t. subspace s /\\ FINITE t /\\ (!x. x IN t ==> f(x) IN s)\n ==> (vsum t f) IN s`;;\n\nlet SUBSPACE_LINEAR_IMAGE = `!f s. linear f /\\ subspace s ==> subspace(IMAGE f s)`;;\n\nlet SUBSPACE_LINEAR_PREIMAGE = `!f s. linear f /\\ subspace s ==> subspace {x | f(x) IN s}`;;\n\nlet SUBSPACE_TRIVIAL = `subspace {vec 0}`;;\n\nlet SUBSPACE_INTER = `!s t. subspace s /\\ subspace t ==> subspace (s INTER t)`;;\n\nlet SUBSPACE_INTERS = `!f. (!s. s IN f ==> subspace s) ==> subspace(INTERS f)`;;\n\nlet LINEAR_INJECTIVE_0_SUBSPACE = `!f:real^M->real^N s.\n linear f /\\ subspace s\n ==> ((!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y) <=>\n (!x. x IN s /\\ f x = vec 0 ==> x = vec 0))`;;\n\nlet SUBSPACE_UNION_CHAIN = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ subspace(s UNION t)\n ==> s SUBSET t \\/ t SUBSET s`;;\n\nlet SUBSPACE_PCROSS = `!s:real^M->bool t:real^N->bool.\n subspace s /\\ subspace t ==> subspace(s PCROSS t)`;;\n\nlet SUBSPACE_PCROSS_EQ = `!s:real^M->bool t:real^N->bool.\n subspace(s PCROSS t) <=> subspace s /\\ subspace t`;;\n\nlet SPAN_SPAN = `!s. span(span s) = span s`;;\n\nlet SPAN_MONO = `!s t. s SUBSET t ==> span s SUBSET span t`;;\n\nlet SUBSPACE_SPAN = `!s. subspace(span s)`;;\n\nlet NONEMPTY_SPAN = `!s:real^N->bool. ~(span s = {})`;;\n\nlet SPAN_CLAUSES = `(!a s. a IN s ==> a IN span s) /\\\n (vec(0) IN span s) /\\\n (!x y s. x IN span s /\\ y IN span s ==> (x + y) IN span s) /\\\n (!x c s. x IN span s ==> (c % x) IN span s)`;;\n\nlet SPAN_INDUCT = `!s h. (!x. x IN s ==> x IN h) /\\ subspace h ==> !x. x IN span(s) ==> h(x)`;;\n\nlet SPAN_EMPTY = `span {} = {vec 0}`;;\n\nlet INDEPENDENT_EMPTY = `independent {}`;;\n\nlet INDEPENDENT_NONZERO = `!s. independent s ==> ~(vec 0 IN s)`;;\n\nlet INDEPENDENT_MONO = `!s t. independent t /\\ s SUBSET t ==> independent s`;;\n\nlet DEPENDENT_MONO = `!s t:real^N->bool. dependent s /\\ s SUBSET t ==> dependent t`;;\n\nlet SPAN_SUBSPACE = `!b s. b SUBSET s /\\ s SUBSET (span b) /\\ subspace s ==> (span b = s)`;;\n\nlet SPAN_INDUCT_ALT = `!s h. h(vec 0) /\\\n (!c x y. x IN s /\\ h(y) ==> h(c % x + y))\n ==> !x:real^N. x IN span(s) ==> h(x)`;;\n\nlet SPAN_SUPERSET = `!x. x IN s ==> x IN span s`;;\n\nlet SPAN_INC = `!s. s SUBSET span s`;;\n\nlet SPAN_UNION_SUBSET = `!s t. span s UNION span t SUBSET span(s UNION t)`;;\n\nlet SPAN_UNIV = `span(:real^N) = (:real^N)`;;\n\nlet SPAN_0 = `vec(0) IN span s`;;\n\nlet SPAN_ADD = `!x y s. x IN span s /\\ y IN span s ==> (x + y) IN span s`;;\n\nlet SPAN_MUL = `!x c s. x IN span s ==> (c % x) IN span s`;;\n\nlet SPAN_MUL_EQ = `!x:real^N c s. ~(c = &0) ==> ((c % x) IN span s <=> x IN span s)`;;\n\nlet SPAN_NEG = `!x s. x IN span s ==> (--x) IN span s`;;\n\nlet SPAN_NEG_EQ = `!x s. --x IN span s <=> x IN span s`;;\n\nlet SPAN_SUB = `!x y s. x IN span s /\\ y IN span s ==> (x - y) IN span s`;;\n\nlet SPAN_VSUM = `!s f t. FINITE t /\\ (!x. x IN t ==> f(x) IN span(s))\n ==> (vsum t f) IN span(s)`;;\n\nlet SPAN_ADD_EQ = `!s x y. x IN span s ==> ((x + y) IN span s <=> y IN span s)`;;\n\nlet SPAN_EQ_SELF = `!s. span s = s <=> subspace s`;;\n\nlet SPAN_OF_SUBSPACE = `!s:real^N->bool. subspace s ==> span s = s`;;\n\nlet SPAN_SUBSET_SUBSPACE = `!s t:real^N->bool. s SUBSET t /\\ subspace t ==> span s SUBSET t`;;\n\nlet SUBSPACE_TRANSLATION_SELF = `!s a. subspace s /\\ a IN s ==> IMAGE (\\x. a + x) s = s`;;\n\nlet SUBSPACE_TRANSLATION_SELF_EQ = `!s a:real^N. subspace s ==> (IMAGE (\\x. a + x) s = s <=> a IN s)`;;\n\nlet SUBSPACE_SUMS = `!s t. subspace s /\\ subspace t\n ==> subspace {x + y | x IN s /\\ y IN t}`;;\n\nlet SPAN_UNION = `!s t. span(s UNION t) = {x + y:real^N | x IN span s /\\ y IN span t}`;;\n\nlet SPAN_LINEAR_IMAGE = `!f:real^M->real^N s. linear f ==> (span(IMAGE f s) = IMAGE f (span s))`;;\n\nlet DEPENDENT_LINEAR_IMAGE_EQ = `!f:real^M->real^N s.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (dependent(IMAGE f s) <=> dependent s)`;;\n\nlet DEPENDENT_LINEAR_IMAGE = `!f:real^M->real^N s.\n linear f /\\ (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y) /\\\n dependent(s)\n ==> dependent(IMAGE f s)`;;\n\nlet INDEPENDENT_LINEAR_IMAGE_EQ = `!f:real^M->real^N s.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (independent(IMAGE f s) <=> independent s)`;;\n\nlet SPAN_BREAKDOWN = `!b s a:real^N.\n b IN s /\\ a IN span s ==> ?k. (a - k % b) IN span(s DELETE b)`;;\n\nlet SPAN_BREAKDOWN_EQ = `!a:real^N s. (x IN span(a INSERT s) <=> (?k. (x - k % a) IN span s))`;;\n\nlet SPAN_INSERT_0 = `!s. span(vec 0 INSERT s) = span s`;;\n\nlet SPAN_SING = `!a. span {a} = {u % a | u IN (:real)}`;;\n\nlet SPAN_2 = `!a b. span {a,b} = {u % a + v % b | u IN (:real) /\\ v IN (:real)}`;;\n\nlet SPAN_3 = `!a b c. span {a,b,c} =\n {u % a + v % b + w % c | u IN (:real) /\\ v IN (:real) /\\ w IN (:real)}`;;\n\nlet IN_SPAN_INSERT = `!a b:real^N s.\n a IN span(b INSERT s) /\\ ~(a IN span s) ==> b IN span(a INSERT s)`;;\n\nlet IN_SPAN_DELETE = `!a b s.\n a IN span s /\\ ~(a IN span (s DELETE b))\n ==> b IN span (a INSERT (s DELETE b))`;;\n\nlet EQ_SPAN_INSERT_EQ = `!s x y:real^N. (x - y) IN span s ==> span(x INSERT s) = span(y INSERT s)`;;\n\nlet SPAN_EXPLICIT = `!(p:real^N -> bool).\n span p =\n {y | ?s u. FINITE s /\\ s SUBSET p /\\\n vsum s (\\v. u v % v) = y}`;;\n\nlet DEPENDENT_EXPLICIT = `!p. dependent (p:real^N -> bool) <=>\n ?s u. FINITE s /\\ s SUBSET p /\\\n (?v. v IN s /\\ ~(u v = &0)) /\\\n vsum s (\\v. u v % v) = vec 0`;;\n\nlet DEPENDENT_FINITE = `!s:real^N->bool.\n FINITE s\n ==> (dependent s <=> ?u. (?v. v IN s /\\ ~(u v = &0)) /\\\n vsum s (\\v. u(v) % v) = vec 0)`;;\n\nlet SPAN_FINITE = `!s:real^N->bool.\n FINITE s ==> span s = {y | ?u. vsum s (\\v. u v % v) = y}`;;\n\nlet SPAN_STDBASIS = `span {basis i :real^N | 1 <= i /\\ i <= dimindex(:N)} = UNIV`;;\n\nlet HAS_SIZE_STDBASIS = `{basis i :real^N | 1 <= i /\\ i <= dimindex(:N)} HAS_SIZE\n dimindex(:N)`;;\n\nlet FINITE_STDBASIS = `FINITE {basis i :real^N | 1 <= i /\\ i <= dimindex(:N)}`;;\n\nlet CARD_STDBASIS = `CARD {basis i :real^N | 1 <= i /\\ i <= dimindex(:N)} =\n dimindex(:N)`;;\n\nlet IN_SPAN_IMAGE_BASIS = `!x:real^N s.\n x IN span(IMAGE basis s) <=>\n !i. 1 <= i /\\ i <= dimindex(:N) /\\ ~(i IN s) ==> x$i = &0`;;\n\nlet INDEPENDENT_STDBASIS = `independent {basis i :real^N | 1 <= i /\\ i <= dimindex(:N)}`;;\n\nlet INDEPENDENT_BASIS_IMAGE = `!k. independent(IMAGE basis k:real^N->bool) <=> k SUBSET 1..dimindex(:N) `;;\n\nlet dim = new_definition\n `dim (v:real^N->bool) =\n @n. ?b. b SUBSET v /\\ independent b /\\ v SUBSET (span b) /\\ b HAS_SIZE n`;;\n\nlet euclidean_matroid = new_definition\n `euclidean_matroid = matroid((:real^N),span)`;;\n\nlet EUCLIDEAN_MATROID = `matroid_set euclidean_matroid = (:real^N) /\\\n matroid_span euclidean_matroid = (span:(real^N->bool)->(real^N->bool))`;;\n\nlet EUCLIDEAN_MATROID_INDEPENDENT = `matroid_independent (euclidean_matroid:(real^N)matroid) = independent`;;\n\nlet EUCLIDEAN_MATROID_SPANNING = `!s. matroid_spanning euclidean_matroid s <=> span s = (:real^N)`;;\n\nlet EUCLIDEAN_MATROID_SUBSPACE = `matroid_subspace (euclidean_matroid:(real^N)matroid) = subspace`;;\n\nlet EUCLIDEAN_MATROID_FINITE_DIMENSIONAL = `matroid_finite_dimensional (euclidean_matroid:(real^N)matroid)`;;\n\nlet EUCLIDEAN_MATROID_DIMENSION = `matroid_dimension (euclidean_matroid:(real^N)matroid) = dimindex(:N)`;;\n\nlet EUCLIDEAN_MATROID_FINITE_DIM = `!s:real^N->bool. matroid_finite_dim euclidean_matroid s`;;\n\nlet EUCLIDEAN_SUBMATROID = `(!s:real^N->bool. matroid_set (submatroid euclidean_matroid s) = span s) /\\\n (!s:real^N->bool. matroid_span (submatroid euclidean_matroid s) = span)`;;\n\nlet EUCLIDEAN_MATROID_DIM = `matroid_dim (euclidean_matroid:(real^N)matroid) = dim`;;\n\nlet SPAN_EQ = `!s t:real^N->bool. span s = span t <=> s SUBSET span t /\\ t SUBSET span s`;;\n\nlet SPAN_EQ_INSERT = `!s x:real^N. span(x INSERT s) = span s <=> x IN span s`;;\n\nlet INDEPENDENT_INSERT = `!a:real^N s. independent(a INSERT s) <=>\n if a IN s then independent s\n else independent s /\\ ~(a IN span s)`;;\n\nlet SPAN_TRANS = `!x y:real^N s. x IN span(s) /\\ y IN span(x INSERT s) ==> y IN span(s)`;;\n\nlet SPANNING_SUBSET_INDEPENDENT = `!s t:real^N->bool.\n t SUBSET s /\\ independent s /\\ s SUBSET span(t) ==> s = t`;;\n\nlet EXCHANGE_LEMMA = `!s t:real^N->bool.\n FINITE t /\\ independent s /\\ s SUBSET span t\n ==> ?t'. t' HAS_SIZE (CARD t) /\\\n s SUBSET t' /\\ t' SUBSET (s UNION t) /\\ s SUBSET (span t')`;;\n\nlet INDEPENDENT_SPAN_BOUND = `!s t. FINITE t /\\ independent s /\\ s SUBSET span(t)\n ==> FINITE s /\\ CARD(s) <= CARD(t)`;;\n\nlet INDEPENDENT_BOUND = `!s:real^N->bool.\n independent s ==> FINITE s /\\ CARD(s) <= dimindex(:N)`;;\n\nlet DEPENDENT_BIGGERSET = `!s:real^N->bool. (FINITE s ==> CARD(s) > dimindex(:N)) ==> dependent s`;;\n\nlet INDEPENDENT_IMP_FINITE = `!s:real^N->bool. independent s ==> FINITE s`;;\n\nlet MAXIMAL_INDEPENDENT_SUBSET_EXTEND = `!s v:real^N->bool.\n s SUBSET v /\\ independent s\n ==> ?b. s SUBSET b /\\ b SUBSET v /\\ independent b /\\\n v SUBSET (span b)`;;\n\nlet MAXIMAL_INDEPENDENT_SUBSET = `!v:real^N->bool. ?b. b SUBSET v /\\ independent b /\\ v SUBSET (span b)`;;\n\nlet BASIS_EXISTS = `!v. ?b. b SUBSET v /\\ independent b /\\ v SUBSET (span b) /\\\n b HAS_SIZE (dim v)`;;\n\nlet BASIS_EXISTS_FINITE = `!v. ?b. FINITE b /\\\n b SUBSET v /\\\n independent b /\\\n v SUBSET (span b) /\\\n b HAS_SIZE (dim v)`;;\n\nlet BASIS_SUBSPACE_EXISTS = `!s:real^N->bool.\n subspace s\n ==> ?b. FINITE b /\\\n b SUBSET s /\\\n independent b /\\\n span b = s /\\\n b HAS_SIZE dim s`;;\n\nlet INDEPENDENT_CARD_LE_DIM = `!v b:real^N->bool.\n b SUBSET v /\\ independent b ==> FINITE b /\\ CARD(b) <= dim v`;;\n\nlet SPAN_CARD_GE_DIM = `!v b:real^N->bool.\n v SUBSET (span b) /\\ FINITE b ==> dim(v) <= CARD(b)`;;\n\nlet BASIS_CARD_EQ_DIM = `!v b. b SUBSET v /\\ v SUBSET (span b) /\\ independent b\n ==> FINITE b /\\ (CARD b = dim v)`;;\n\nlet BASIS_HAS_SIZE_DIM = `!v b. independent b /\\ span b = v ==> b HAS_SIZE (dim v)`;;\n\nlet DIM_SPAN = `!s:real^N->bool. dim(span s) = dim s`;;\n\nlet DIM_UNIQUE = `!v b. b SUBSET v /\\ v SUBSET (span b) /\\ independent b /\\ b HAS_SIZE n\n ==> dim v = n`;;\n\nlet DIM_LE_CARD = `!s. FINITE s ==> dim s <= CARD s`;;\n\nlet DIM_UNIV = `dim(:real^N) = dimindex(:N)`;;\n\nlet DIM_SUBSET = `!s t:real^N->bool. s SUBSET t ==> dim(s) <= dim(t)`;;\n\nlet DIM_SUBSET_UNIV = `!s:real^N->bool. dim(s) <= dimindex(:N)`;;\n\nlet BASIS_HAS_SIZE_UNIV = `!b. independent b /\\ span b = (:real^N) ==> b HAS_SIZE (dimindex(:N))`;;\n\nlet CARD_GE_DIM_INDEPENDENT = `!v b:real^N->bool.\n b SUBSET v /\\ independent b /\\ dim v <= CARD(b)\n ==> v SUBSET span b`;;\n\nlet CARD_LE_DIM_SPANNING = `!v b:real^N->bool.\n v SUBSET span b /\\ FINITE b /\\ CARD(b) <= dim v ==> independent b`;;\n\nlet CARD_EQ_DIM = `!v b. b SUBSET v /\\ b HAS_SIZE (dim v)\n ==> (independent b <=> v SUBSET (span b))`;;\n\nlet INDEPENDENT_BOUND_GENERAL = `!s:real^N->bool. independent s ==> FINITE s /\\ CARD(s) <= dim(s)`;;\n\nlet DEPENDENT_BIGGERSET_GENERAL = `!s:real^N->bool. (FINITE s ==> CARD(s) > dim(s)) ==> dependent s`;;\n\nlet DIM_INSERT_0 = `!s:real^N->bool. dim(vec 0 INSERT s) = dim s`;;\n\nlet DIM_EQ_CARD = `!s:real^N->bool. independent s ==> dim s = CARD s`;;\n\nlet DEPENDENT_EQ_DIM_LT_CARD = `!s:real^N->bool. dependent s <=> FINITE s ==> dim s < CARD s`;;\n\nlet INDEPENDENT_EQ_DIM_EQ_CARD = `!s:real^N->bool. independent s <=> FINITE s /\\ dim s = CARD s`;;\n\nlet SUBSET_LE_DIM = `!s t:real^N->bool. s SUBSET (span t) ==> dim s <= dim t`;;\n\nlet SPAN_EQ_DIM = `!s t. span s = span t ==> dim s = dim t`;;\n\nlet DIM_EMPTY = `dim({}:real^N->bool) = 0`;;\n\nlet DIM_INSERT = `!x:real^N s. dim(x INSERT s) = if x IN span s then dim s else dim s + 1`;;\n\nlet CHOOSE_SUBSPACE_OF_SUBSPACE = `!s:real^N->bool n.\n n <= dim s ==> ?t. subspace t /\\ t SUBSET span s /\\ dim t = n`;;\n\nlet SUBSPACE_EXISTS = `!n. n <= dimindex(:N) ==> ?s:real^N->bool. subspace s /\\ dim s = n`;;\n\nlet DIM_EQ_SPAN = `!s t:real^N->bool. s SUBSET t /\\ dim t <= dim s ==> span s = span t`;;\n\nlet DIM_EQ_FULL = `!s:real^N->bool. dim s = dimindex(:N) <=> span s = (:real^N)`;;\n\nlet DIM_PSUBSET = `!s t:real^N->bool. span s PSUBSET span t ==> dim s < dim t`;;\n\nlet LOWDIM_EXPAND_DIMENSION = `!s:real^N->bool n.\n dim s <= n /\\ n <= dimindex(:N)\n ==> ?t. dim(t) = n /\\ span s SUBSET span t`;;\n\nlet LOWDIM_EXPAND_BASIS = `!s:real^N->bool n.\n dim s <= n /\\ n <= dimindex(:N)\n ==> ?b. b HAS_SIZE n /\\ independent b /\\ span s SUBSET span b`;;\n\nlet INDEPENDENT_EXPLICIT = `!b:real^N->bool.\n independent b <=>\n FINITE b /\\\n !c. vsum b (\\v. c(v) % v) = vec 0 ==> !v. v IN b ==> c(v) = &0`;;\n\nlet INDEPENDENT_SING = `!x. independent {x} <=> ~(x = vec 0)`;;\n\nlet DEPENDENT_SING = `!x. dependent {x} <=> x = vec 0`;;\n\nlet DEPENDENT_2 = `!a b:real^N.\n dependent {a,b} <=>\n if a = b then a = vec 0\n else ?x y. x % a + y % b = vec 0 /\\ ~(x = &0 /\\ y = &0)`;;\n\nlet DEPENDENT_3 = `!a b c:real^N.\n ~(a = b) /\\ ~(a = c) /\\ ~(b = c)\n ==> (dependent {a,b,c} <=>\n ?x y z. x % a + y % b + z % c = vec 0 /\\\n ~(x = &0 /\\ y = &0 /\\ z = &0))`;;\n\nlet INDEPENDENT_2 = `!a b:real^N x y.\n independent{a,b} /\\ ~(a = b)\n ==> (x % a + y % b = vec 0 <=> x = &0 /\\ y = &0)`;;\n\nlet INDEPENDENT_3 = `!a b c:real^N x y z.\n independent{a,b,c} /\\ ~(a = b) /\\ ~(a = c) /\\ ~(b = c)\n ==> (x % a + y % b + z % c = vec 0 <=> x = &0 /\\ y = &0 /\\ z = &0)`;;\n\nlet LINEAR_SUBSPACE_GRAPH = `!f:real^M->real^N.\n linear f <=> subspace {pastecart x (f x) | x IN (:real^M)}`;;\n\nlet SPANS_IMAGE = `!f b v. linear f /\\ v SUBSET (span b)\n ==> (IMAGE f v) SUBSET span(IMAGE f b)`;;\n\nlet DIM_LINEAR_IMAGE_LE = `!f:real^M->real^N s. linear f ==> dim(IMAGE f s) <= dim s`;;\n\nlet DIM_SING = `!x. dim{x} = if x = vec 0 then 0 else 1`;;\n\nlet DIM_EQ_0 = `!s:real^N->bool. dim s = 0 <=> s SUBSET {vec 0}`;;\n\nlet SPANNING_SURJECTIVE_IMAGE = `!f:real^M->real^N s.\n UNIV SUBSET (span s) /\\ linear f /\\ (!y. ?x. f(x) = y)\n ==> UNIV SUBSET span(IMAGE f s)`;;\n\nlet INDEPENDENT_INJECTIVE_IMAGE_GEN = `!f:real^M->real^N s.\n independent s /\\ linear f /\\\n (!x y. x IN span s /\\ y IN span s /\\ f(x) = f(y) ==> x = y)\n ==> independent (IMAGE f s)`;;\n\nlet INDEPENDENT_INJECTIVE_IMAGE = `!f:real^M->real^N s.\n independent s /\\ linear f /\\ (!x y. (f(x) = f(y)) ==> (x = y))\n ==> independent (IMAGE f s)`;;\n\nlet VECTOR_SUB_PROJECT_ORTHOGONAL = `!b:real^N x. b dot (x - ((b dot x) / (b dot b)) % b) = &0`;;\n\nlet BASIS_ORTHOGONAL = `!b:real^N->bool.\n FINITE b\n ==> ?c. FINITE c /\\ CARD c <= CARD b /\\\n span c = span b /\\ pairwise orthogonal c`;;\n\nlet ORTHOGONAL_BASIS_EXISTS = `!v:real^N->bool.\n ?b. independent b /\\\n b SUBSET span v /\\\n v SUBSET span b /\\\n b HAS_SIZE dim v /\\\n pairwise orthogonal b`;;\n\nlet SPAN_SPECIAL_SCALE = `!s a x:real^N.\n span((a % x) INSERT s) = if a = &0 then span s else span(x INSERT s)`;;\n\nlet LINEAR_INDEP_IMAGE_LEMMA = `!f b. linear(f:real^M->real^N) /\\\n FINITE b /\\\n independent (IMAGE f b) /\\\n (!x y. x IN b /\\ y IN b /\\ (f x = f y) ==> (x = y))\n ==> !x. x IN span b ==> (f(x) = vec 0) ==> (x = vec 0)`;;\n\nlet LINEAR_INDEPENDENT_EXTEND_LEMMA = `!f b. FINITE b\n ==> independent b\n ==> ?g:real^M->real^N.\n (!x y. x IN span b /\\ y IN span b\n ==> (g(x + y) = g(x) + g(y))) /\\\n (!x c. x IN span b ==> (g(c % x) = c % g(x))) /\\\n (!x. x IN b ==> (g x = f x))`;;\n\nlet LINEAR_INDEPENDENT_EXTEND = `!f b. independent b\n ==> ?g:real^M->real^N. linear g /\\ (!x. x IN b ==> (g x = f x))`;;\n\nlet SUBSPACE_KERNEL = `!f. linear f ==> subspace {x | f(x) = vec 0}`;;\n\nlet LINEAR_EQ_0_SPAN = `!f:real^M->real^N b.\n linear f /\\ (!x. x IN b ==> f(x) = vec 0)\n ==> !x. x IN span(b) ==> f(x) = vec 0`;;\n\nlet LINEAR_EQ_0 = `!f b s. linear f /\\ s SUBSET (span b) /\\ (!x. x IN b ==> f(x) = vec 0)\n ==> !x. x IN s ==> f(x) = vec 0`;;\n\nlet LINEAR_EQ = `!f g b s. linear f /\\ linear g /\\ s SUBSET (span b) /\\\n (!x. x IN b ==> f(x) = g(x))\n ==> !x. x IN s ==> f(x) = g(x)`;;\n\nlet LINEAR_EQ_STDBASIS = `!f:real^M->real^N g.\n linear f /\\ linear g /\\\n (!i. 1 <= i /\\ i <= dimindex(:M)\n ==> f(basis i) = g(basis i))\n ==> f = g`;;\n\nlet SUBSPACE_LINEAR_FIXED_POINTS = `!f:real^N->real^N. linear f ==> subspace {x | f(x) = x}`;;\n\nlet BILINEAR_EQ = `!f:real^M->real^N->real^P g b c s.\n bilinear f /\\ bilinear g /\\\n s SUBSET (span b) /\\ t SUBSET (span c) /\\\n (!x y. x IN b /\\ y IN c ==> f x y = g x y)\n ==> !x y. x IN s /\\ y IN t ==> f x y = g x y`;;\n\nlet BILINEAR_EQ_STDBASIS = `!f:real^M->real^N->real^P g.\n bilinear f /\\ bilinear g /\\\n (!i j. 1 <= i /\\ i <= dimindex(:M) /\\ 1 <= j /\\ j <= dimindex(:N)\n ==> f (basis i) (basis j) = g (basis i) (basis j))\n ==> f = g`;;\n\nlet LEFT_INVERTIBLE_TRANSP = `!A:real^N^M.\n (?B:real^N^M. B ** transp A = mat 1) <=> (?B:real^M^N. A ** B = mat 1)`;;\n\nlet RIGHT_INVERTIBLE_TRANSP = `!A:real^N^M.\n (?B:real^N^M. transp A ** B = mat 1) <=> (?B:real^M^N. B ** A = mat 1)`;;\n\nlet INVERTIBLE_TRANSP = `!A:real^N^M. invertible(transp A) <=> invertible A`;;\n\nlet LINEAR_INJECTIVE_LEFT_INVERSE = `!f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> ?g. linear g /\\ g o f = I`;;\n\nlet LINEAR_INJECTIVE_LEFT_INVERSE_EQ = `!f:real^M->real^N.\n linear f\n ==> ((!x y. f x = f y ==> x = y) <=> ?g. linear g /\\ g o f = I)`;;\n\nlet LINEAR_SURJECTIVE_RIGHT_INVERSE = `!f:real^M->real^N.\n linear f /\\ (!y. ?x. f x = y) ==> ?g. linear g /\\ f o g = I`;;\n\nlet LINEAR_SURJECTIVE_RIGHT_INVERSE_EQ = `!f:real^M->real^N.\n linear f\n ==> ((!y. ?x. f x = y) <=> ?g. linear g /\\ f o g = I)`;;\n\nlet MATRIX_LEFT_INVERTIBLE_INJECTIVE = `!A:real^N^M.\n (?B:real^M^N. B ** A = mat 1) <=>\n !x y:real^N. A ** x = A ** y ==> x = y`;;\n\nlet MATRIX_LEFT_INVERTIBLE_KER = `!A:real^N^M.\n (?B:real^M^N. B ** A = mat 1) <=> !x. A ** x = vec 0 ==> x = vec 0`;;\n\nlet MATRIX_RIGHT_INVERTIBLE_SURJECTIVE = `!A:real^N^M.\n (?B:real^M^N. A ** B = mat 1) <=> !y:real^M. ?x. A ** x = y`;;\n\nlet MATRIX_LEFT_INVERTIBLE_INDEPENDENT_COLUMNS = `!A:real^N^M. (?B:real^M^N. B ** A = mat 1) <=>\n !c. vsum(1..dimindex(:N)) (\\i. c(i) % column i A) = vec 0 ==>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> c(i) = &0`;;\n\nlet MATRIX_RIGHT_INVERTIBLE_INDEPENDENT_ROWS = `!A:real^N^M. (?B:real^M^N. A ** B = mat 1) <=>\n !c. vsum(1..dimindex(:M)) (\\i. c(i) % row i A) = vec 0 ==>\n !i. 1 <= i /\\ i <= dimindex(:M) ==> c(i) = &0`;;\n\nlet MATRIX_RIGHT_INVERTIBLE_SPAN_COLUMNS = `!A:real^N^M. (?B:real^M^N. A ** B = mat 1) <=> span(columns A) = (:real^M)`;;\n\nlet MATRIX_LEFT_INVERTIBLE_SPAN_ROWS = `!A:real^N^M. (?B:real^M^N. B ** A = mat 1) <=> span(rows A) = (:real^N)`;;\n\nlet LINEAR_INJECTIVE_IMP_SURJECTIVE = `!f:real^N->real^N.\n linear f /\\ (!x y. (f(x) = f(y)) ==> (x = y))\n ==> !y. ?x. f(x) = y`;;\n\nlet LINEAR_SURJECTIVE_IMP_INJECTIVE = `!f:real^N->real^N.\n linear f /\\ (!y. ?x. f(x) = y)\n ==> !x y. (f(x) = f(y)) ==> (x = y)`;;\n\nlet LINEAR_SURJECTIVE_IFF_INJECTIVE = `!f:real^N->real^N.\n linear f ==> ((!y. ?x. f x = y) <=> (!x y. f x = f y ==> x = y))`;;\n\nlet LEFT_RIGHT_INVERSE_EQ = `!f:A->A g h. f o g = I /\\ g o h = I ==> f = h`;;\n\nlet ISOMORPHISM_EXPAND = `!f g. f o g = I /\\ g o f = I <=> (!x. f(g x) = x) /\\ (!x. g(f x) = x)`;;\n\nlet LINEAR_INJECTIVE_ISOMORPHISM = `!f:real^N->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> ?f'. linear f' /\\ (!x. f'(f x) = x) /\\ (!x. f(f' x) = x)`;;\n\nlet LINEAR_SURJECTIVE_ISOMORPHISM = `!f:real^N->real^N.\n linear f /\\ (!y. ?x. f x = y)\n ==> ?f'. linear f' /\\ (!x. f'(f x) = x) /\\ (!x. f(f' x) = x)`;;\n\nlet LINEAR_INVERSE_LEFT = `!f:real^N->real^N f'.\n linear f /\\ linear f' ==> ((f o f' = I) <=> (f' o f = I))`;;\n\nlet LEFT_INVERSE_LINEAR = `!f g:real^N->real^N. linear f /\\ (g o f = I) ==> linear g`;;\n\nlet RIGHT_INVERSE_LINEAR = `!f g:real^N->real^N. linear f /\\ (f o g = I) ==> linear g`;;\n\nlet LEFT_RIGHT_INVERSE_LINEAR = `!f g:real^M->real^N.\n linear f /\\ g o f = I /\\ f o g = I ==> linear g`;;\n\nlet LINEAR_BIJECTIVE_LEFT_RIGHT_INVERSE = `!f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y)\n ==> ?g. linear g /\\ (!x. g(f x) = x) /\\ (!y. f(g y) = y)`;;\n\nlet LINEAR_BIJECTIVE_LEFT_RIGHT_INVERSE_EQ = `!f:real^M->real^N.\n linear f\n ==> ((!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y) <=>\n ?g. linear g /\\ f o g = I /\\ g o f = I)`;;\n\nlet LINEAR_INJECTIVE_LEFT_RIGHT_INVERSE_EQ = `!f:real^N->real^N.\n linear f\n ==> ((!x y. f x = f y ==> x = y) <=>\n (?g. linear g /\\ f o g = I /\\ g o f = I))`;;\n\nlet LINEAR_SURJECTIVE_LEFT_RIGHT_INVERSE_EQ = `!f:real^N->real^N.\n linear f\n ==> ((!y. ?x. f x = y) <=>\n (?g. linear g /\\ f o g = I /\\ g o f = I))`;;\n\nlet MATRIX_LEFT_RIGHT_INVERSE = `!A:real^N^N A':real^N^N. (A ** A' = mat 1) <=> (A' ** A = mat 1)`;;\n\nlet MATRIX_LEFT_INVERTIBLE = `!f:real^M->real^N.\n linear f ==> ((?B:real^N^M. B ** matrix f = mat 1) <=>\n (?g. linear g /\\ g o f = I))`;;\n\nlet MATRIX_RIGHT_INVERTIBLE = `!f:real^M->real^N.\n linear f ==> ((?B:real^N^M. matrix f ** B = mat 1) <=>\n (?g. linear g /\\ f o g = I))`;;\n\nlet INVERTIBLE_LEFT_INVERSE = `!A:real^N^N. invertible(A) <=> ?B:real^N^N. B ** A = mat 1`;;\n\nlet INVERTIBLE_RIGHT_INVERSE = `!A:real^N^N. invertible(A) <=> ?B:real^N^N. A ** B = mat 1`;;\n\nlet MATRIX_INVERTIBLE = `!f:real^M->real^N.\n linear f\n ==> (invertible(matrix f) <=>\n ?g. linear g /\\ f o g = I /\\ g o f = I)`;;\n\nlet INVERTIBLE_EQ_INJECTIVE_AND_SURJECTIVE = `!m:real^M^N.\n invertible m <=>\n (!x y:real^M. m ** x = m ** y ==> x = y) /\\\n IMAGE (\\x. m ** x) (:real^M) = (:real^N)`;;\n\nlet LINEAR_INVERTIBLE_BOUNDED_BELOW_POS = `!f:real^M->real^N g.\n linear f /\\ linear g /\\ (g o f = I)\n ==> ?B. &0 < B /\\ !x. B * norm(x) <= norm(f x)`;;\n\nlet LINEAR_INVERTIBLE_BOUNDED_BELOW = `!f:real^M->real^N g.\n linear f /\\ linear g /\\ (g o f = I)\n ==> ?B. !x. B * norm(x) <= norm(f x)`;;\n\nlet LINEAR_INJECTIVE_BOUNDED_BELOW_POS = `!f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> ?B. &0 < B /\\ !x. norm(x) * B <= norm(f x)`;;\n\nlet DIM_INJECTIVE_LINEAR_IMAGE = `!f:real^M->real^N s.\n linear f /\\ (!x y. f x = f y ==> x = y) ==> dim(IMAGE f s) = dim s`;;\n\nlet LINEAR_INJECTIVE_DIMINDEX_LE = `!f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> dimindex(:M) <= dimindex(:N)`;;\n\nlet LINEAR_SURJECTIVE_DIMINDEX_LE = `!f:real^M->real^N.\n linear f /\\ (!y. ?x. f x = y)\n ==> dimindex(:N) <= dimindex(:M)`;;\n\nlet LINEAR_BIJECTIVE_DIMINDEX_EQ = `!f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y)\n ==> dimindex(:M) = dimindex(:N)`;;\n\nlet INVERTIBLE_IMP_SQUARE_MATRIX = `!A:real^N^M. invertible A ==> dimindex(:M) = dimindex(:N)`;;\n\nlet rowvector = new_definition\n `(rowvector:real^N->real^N^1) v = lambda i j. v$j`;;\n\nlet columnvector = new_definition\n `(columnvector:real^N->real^1^N) v = lambda i j. v$i`;;\n\nlet TRANSP_COLUMNVECTOR = `!v. transp(columnvector v) = rowvector v`;;\n\nlet TRANSP_ROWVECTOR = `!v. transp(rowvector v) = columnvector v`;;\n\nlet DOT_ROWVECTOR_COLUMNVECTOR = `!A:real^N^M v:real^N. columnvector(A ** v) = A ** columnvector v`;;\n\nlet DOT_MATRIX_PRODUCT = `!x y:real^N. x dot y = (rowvector x ** columnvector y)$1$1`;;\n\nlet DOT_MATRIX_VECTOR_MUL = `!A:real^N^N B:real^N^N x:real^N y:real^N.\n (A ** x) dot (B ** y) =\n ((rowvector x) ** (transp(A) ** B) ** (columnvector y))$1$1`;;\n\nlet MATRIX_VECTOR_MUL_IN_COLUMNSPACE = `!A:real^M^N x:real^M. (A ** x) IN span(columns A)`;;\n\nlet SUBSPACE_ORTHOGONAL_TO_VECTOR = `!x. subspace {y | orthogonal x y}`;;\n\nlet SUBSPACE_ORTHOGONAL_TO_VECTORS = `!s. subspace {y | (!x. x IN s ==> orthogonal x y)}`;;\n\nlet ORTHOGONAL_TO_SPAN = `!s x. (!y. y IN s ==> orthogonal x y)\n ==> !y. y IN span(s) ==> orthogonal x y`;;\n\nlet ORTHOGONAL_TO_SPAN_EQ = `!s x. (!y. y IN span(s) ==> orthogonal x y) <=>\n (!y. y IN s ==> orthogonal x y)`;;\n\nlet ORTHOGONAL_TO_SPANS_EQ = `!s t. (!x y. x IN span(s) /\\ y IN span(t) ==> orthogonal x y) <=>\n (!x y. x IN s /\\ y IN t ==> orthogonal x y)`;;\n\nlet ORTHOGONAL_NULLSPACE_ROWSPACE = `!A:real^M^N x y:real^M.\n A ** x = vec 0 /\\ y IN span(rows A) ==> orthogonal x y`;;\n\nlet NULLSPACE_INTER_ROWSPACE = `!A:real^M^N x:real^M. A ** x = vec 0 /\\ x IN span(rows A) <=> x = vec 0`;;\n\nlet MATRIX_VECTOR_MUL_INJECTIVE_ON_ROWSPACE = `!A:real^M^N x y:real^M.\n x IN span(rows A) /\\ y IN span(rows A) /\\ A ** x = A ** y ==> x = y`;;\n\nlet DIM_ROWS_LE_DIM_COLUMNS = `!A:real^M^N. dim(rows A) <= dim(columns A)`;;\n\nlet rank = new_definition\n `rank(A:real^M^N) = dim(columns A)`;;\n\nlet RANK_ROW = `!A:real^M^N. rank(A) = dim(rows A)`;;\n\nlet RANK_TRANSP = `!A:real^M^N. rank(transp A) = rank A`;;\n\nlet MATRIX_VECTOR_MUL_BASIS = `!A:real^M^N k. 1 <= k /\\ k <= dimindex(:M)\n ==> A ** (basis k) = column k A`;;\n\nlet COLUMNS_IMAGE_BASIS = `!A:real^M^N.\n columns A = IMAGE (\\x. A ** x) {basis i | 1 <= i /\\ i <= dimindex(:M)}`;;\n\nlet RANK_DIM_IM = `!A:real^M^N. rank A = dim(IMAGE (\\x. A ** x) (:real^M))`;;\n\nlet RANK_BOUND = `!A:real^M^N. rank(A) <= MIN (dimindex(:M)) (dimindex(:N))`;;\n\nlet FULL_RANK_INJECTIVE = `!A:real^M^N.\n rank A = dimindex(:M) <=>\n (!x y:real^M. A ** x = A ** y ==> x = y)`;;\n\nlet FULL_RANK_SURJECTIVE = `!A:real^M^N.\n rank A = dimindex(:N) <=> (!y:real^N. ?x:real^M. A ** x = y)`;;\n\nlet RANK_I = `rank(mat 1:real^N^N) = dimindex(:N)`;;\n\nlet MATRIX_FULL_LINEAR_EQUATIONS = `!A:real^M^N b:real^N.\n rank A = dimindex(:N) ==> ?x. A ** x = b`;;\n\nlet MATRIX_NONFULL_LINEAR_EQUATIONS_EQ = `!A:real^M^N.\n (?x. ~(x = vec 0) /\\ A ** x = vec 0) <=> ~(rank A = dimindex(:M))`;;\n\nlet MATRIX_NONFULL_LINEAR_EQUATIONS = `!A:real^M^N.\n ~(rank A = dimindex(:M)) ==> ?x. ~(x = vec 0) /\\ A ** x = vec 0`;;\n\nlet MATRIX_TRIVIAL_LINEAR_EQUATIONS = `!A:real^M^N.\n dimindex(:N) < dimindex(:M)\n ==> ?x. ~(x = vec 0) /\\ A ** x = vec 0`;;\n\nlet RANK_EQ_0 = `!A:real^M^N. rank A = 0 <=> A = mat 0`;;\n\nlet RANK_0 = `rank(mat 0) = 0`;;\n\nlet RANK_MUL_LE_RIGHT = `!A:real^N^M B:real^P^N. rank(A ** B) <= rank(B)`;;\n\nlet RANK_MUL_LE_LEFT = `!A:real^N^M B:real^P^N. rank(A ** B) <= rank(A)`;;\n\nlet SPAN_COLUMNSPACE = `!A:real^M^N. span(columns A) = {y | ?x. A ** x = y}`;;\n\nlet MATRIX_AUGMENTED_LINEAR_EQUATIONS = `!A:real^N^M y:real^N.\n (?x. transp A ** x = y) <=>\n rank(pastecart A (rowvector y)) = rank A`;;\n\nlet NORM_COLUMN_LE_ONORM = `!A:real^N^M i. norm(column i A) <= onorm(\\x. A ** x)`;;\n\nlet MATRIX_COMPONENT_LE_ONORM = `!A:real^N^M i j. abs(A$i$j) <= onorm(\\x. A ** x)`;;\n\nlet COMPONENT_LE_ONORM = `!f:real^M->real^N i j. linear f ==> abs(matrix f$i$j) <= onorm f`;;\n\nlet ONORM_LE_MATRIX_COMPONENT_SUM = `!A:real^N^M.\n onorm(\\x. A ** x) <=\n sum (1..dimindex(:M))\n (\\i. sum(1..dimindex(:N)) (\\j. abs(A$i$j)))`;;\n\nlet ONORM_LE_MATRIX_COMPONENT = `!A:real^N^M B.\n (!i j. 1 <= i /\\ i <= dimindex(:M) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> abs(A$i$j) <= B)\n ==> onorm(\\x. A ** x) <= &(dimindex(:M)) * &(dimindex(:N)) * B`;;\n\nlet MATRIX_RATIONAL_APPROXIMATION = `!A:real^N^M e.\n &0 < e\n ==> ?B. (!i j. 1 <= i /\\ i <= dimindex(:M) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> rational(B$i$j)) /\\\n onorm(\\x. (A - B) ** x) < e`;;\n\nlet HYPERPLANE_EQ_EMPTY = `!a:real^N b. {x | a dot x = b} = {} <=> a = vec 0 /\\ ~(b = &0)`;;\n\nlet HYPERPLANE_EQ_UNIV = `!a b. {x | a dot x = b} = (:real^N) <=> a = vec 0 /\\ b = &0`;;\n\nlet HALFSPACE_EQ_EMPTY_LT = `!a:real^N b. {x | a dot x < b} = {} <=> a = vec 0 /\\ b <= &0`;;\n\nlet HALFSPACE_EQ_EMPTY_GT = `!a:real^N b. {x | a dot x > b} = {} <=> a = vec 0 /\\ b >= &0`;;\n\nlet HALFSPACE_EQ_EMPTY_LE = `!a:real^N b. {x | a dot x <= b} = {} <=> a = vec 0 /\\ b < &0`;;\n\nlet HALFSPACE_EQ_EMPTY_GE = `!a:real^N b. {x | a dot x >= b} = {} <=> a = vec 0 /\\ b > &0`;;\n\nlet ADJOINT_INJECTIVE = `!f:real^M->real^N.\n linear f\n ==> ((!x y. adjoint f x = adjoint f y ==> x = y) <=>\n (!y. ?x. f x = y))`;;\n\nlet ADJOINT_SURJECTIVE = `!f:real^M->real^N.\n linear f\n ==> ((!y. ?x. adjoint f x = y) <=> (!x y. f x = f y ==> x = y))`;;\n\nlet ADJOINT_INJECTIVE_INJECTIVE = `!f:real^N->real^N.\n linear f\n ==> ((!x y. adjoint f x = adjoint f y ==> x = y) <=>\n (!x y. f x = f y ==> x = y))`;;\n\nlet ADJOINT_INJECTIVE_INJECTIVE_0 = `!f:real^N->real^N.\n linear f\n ==> ((!x. adjoint f x = vec 0 ==> x = vec 0) <=>\n (!x. f x = vec 0 ==> x = vec 0))`;;\n\nlet TRANSP_INJECTIVE = `!m:real^M^N.\n (!x y:real^N. transp m ** x = transp m ** y ==> x = y) <=>\n IMAGE (\\x. m ** x) (:real^M) = (:real^N)`;;\n\nlet TRANSP_SURJECTIVE = `!m:real^M^N.\n IMAGE (\\x. transp m ** x) (:real^N) = (:real^M) <=>\n (!x y:real^M. m ** x = m ** y ==> x = y)`;;\n\nlet LINEAR_SINGULAR_INTO_HYPERPLANE = `!f:real^N->real^N.\n linear f\n ==> (~(!x y. f(x) = f(y) ==> x = y) <=>\n ?a. ~(a = vec 0) /\\ !x. a dot f(x) = &0)`;;\n\nlet LINEAR_SINGULAR_IMAGE_HYPERPLANE = `!f:real^N->real^N.\n linear f /\\ ~(!x y. f(x) = f(y) ==> x = y)\n ==> ?a. ~(a = vec 0) /\\ !s. IMAGE f s SUBSET {x | a dot x = &0}`;;\n\nlet SPAN_DELETE_0 = `!s:real^N->bool. span(s DELETE vec 0) = span s`;;\n\nlet DIM_BASIS_IMAGE = `!k. dim(IMAGE basis k:real^N->bool) = CARD((1..dimindex(:N)) INTER k)`;;\n\nlet SPAN_IMAGE_SCALE = `!c s. (!x. x IN s ==> ~(c x = &0))\n ==> span (IMAGE (\\x:real^N. c(x) % x) s) = span s`;;\n\nlet DIM_IMAGE_SCALE = `!c s:real^N->bool.\n (!x. x IN s ==> ~(c x = &0)) ==> dim(IMAGE (\\x. c x % x) s) = dim s`;;\n\nlet PAIRWISE_ORTHOGONAL_INDEPENDENT = `!s:real^N->bool.\n pairwise orthogonal s /\\ ~(vec 0 IN s) ==> independent s`;;\n\nlet PAIRWISE_ORTHOGONAL_IMP_FINITE = `!s:real^N->bool. pairwise orthogonal s ==> FINITE s`;;\n\nlet GRAM_SCHMIDT_STEP = `!s a x.\n pairwise orthogonal s /\\ x IN span s\n ==> orthogonal x (a - vsum s (\\b:real^N. (b dot a) / (b dot b) % b))`;;\n\nlet ORTHOGONAL_EXTENSION = `!s t:real^N->bool.\n pairwise orthogonal s\n ==> ?u. pairwise orthogonal (s UNION u) /\\\n span (s UNION u) = span (s UNION t)`;;\n\nlet ORTHOGONAL_EXTENSION_STRONG = `!s t:real^N->bool.\n pairwise orthogonal s\n ==> ?u. DISJOINT u (vec 0 INSERT s) /\\\n pairwise orthogonal (s UNION u) /\\\n span (s UNION u) = span (s UNION t)`;;\n\nlet ORTHONORMAL_EXTENSION = `!s t:real^N->bool.\n pairwise orthogonal s /\\ (!x. x IN s ==> norm x = &1)\n ==> ?u. DISJOINT u s /\\\n pairwise orthogonal (s UNION u) /\\\n (!x. x IN u ==> norm x = &1) /\\\n span(s UNION u) = span(s UNION t)`;;\n\nlet VECTOR_IN_ORTHOGONAL_SPANNINGSET = `!a. ?s. a IN s /\\ pairwise orthogonal s /\\ span s = (:real^N)`;;\n\nlet VECTOR_IN_ORTHOGONAL_BASIS = `!a. ~(a = vec 0)\n ==> ?s. a IN s /\\ ~(vec 0 IN s) /\\\n pairwise orthogonal s /\\\n independent s /\\\n s HAS_SIZE (dimindex(:N)) /\\\n span s = (:real^N)`;;\n\nlet VECTOR_IN_ORTHONORMAL_BASIS = `!a. norm a = &1\n ==> ?s. a IN s /\\\n pairwise orthogonal s /\\\n (!x. x IN s ==> norm x = &1) /\\\n independent s /\\\n s HAS_SIZE (dimindex(:N)) /\\\n span s = (:real^N)`;;\n\nlet BESSEL_INEQUALITY = `!s x:real^N.\n pairwise orthogonal s /\\ (!x. x IN s ==> norm x = &1)\n ==> sum s (\\e. (e dot x) pow 2) <= norm(x) pow 2`;;\n\nlet ORTHOGONAL_SPANNINGSET_SUBSPACE = `!s:real^N->bool.\n subspace s\n ==> ?b. b SUBSET s /\\ pairwise orthogonal b /\\ span b = s`;;\n\nlet ORTHOGONAL_BASIS_SUBSPACE = `!s:real^N->bool.\n subspace s\n ==> ?b. ~(vec 0 IN b) /\\\n b SUBSET s /\\\n pairwise orthogonal b /\\\n independent b /\\\n b HAS_SIZE (dim s) /\\\n span b = s`;;\n\nlet ORTHONORMAL_BASIS_SUBSPACE = `!s:real^N->bool.\n subspace s\n ==> ?b. b SUBSET s /\\\n pairwise orthogonal b /\\\n (!x. x IN b ==> norm x = &1) /\\\n independent b /\\\n b HAS_SIZE (dim s) /\\\n span b = s`;;\n\nlet ORTHOGONAL_TO_SUBSPACE_EXISTS_GEN = `!s t:real^N->bool.\n span s PSUBSET span t\n ==> ?x. ~(x = vec 0) /\\ x IN span t /\\\n (!y. y IN span s ==> orthogonal x y)`;;\n\nlet ORTHOGONAL_TO_SUBSPACE_EXISTS = `!s:real^N->bool. dim s < dimindex(:N)\n ==> ?x. ~(x = vec 0) /\\ !y. y IN s ==> orthogonal x y`;;\n\nlet ORTHOGONAL_TO_VECTOR_EXISTS = `!x:real^N. 2 <= dimindex(:N) ==> ?y. ~(y = vec 0) /\\ orthogonal x y`;;\n\nlet SPAN_NOT_UNIV_ORTHOGONAL = `!s. ~(span s = (:real^N))\n ==> ?a. ~(a = vec 0) /\\ !x. x IN span s ==> a dot x = &0`;;\n\nlet SPAN_NOT_UNIV_SUBSET_HYPERPLANE = `!s. ~(span s = (:real^N))\n ==> ?a. ~(a = vec 0) /\\ span s SUBSET {x | a dot x = &0}`;;\n\nlet LOWDIM_SUBSET_HYPERPLANE = `!s. dim s < dimindex(:N)\n ==> ?a:real^N. ~(a = vec 0) /\\ span s SUBSET {x | a dot x = &0}`;;\n\nlet VECTOR_EQ_DOT_SPAN = `!b x y:real^N.\n (!v. v IN b ==> v dot x = v dot y) /\\ x IN span b /\\ y IN span b\n ==> x = y`;;\n\nlet ORTHONORMAL_BASIS_EXPAND = `!b x:real^N.\n pairwise orthogonal b /\\ (!v. v IN b ==> norm v = &1) /\\ x IN span b\n ==> vsum b (\\v. (v dot x) % v) = x`;;\n\nlet ORTHONORMAL_BASIS_EXPAND_DOT = `!b x y:real^N.\n pairwise orthogonal b /\\\n (!v. v IN b ==> norm v = &1) /\\\n (x IN span b \\/ y IN span b)\n ==> sum b (\\v. (v dot x) * (v dot y)) = x dot y`;;\n\nlet ORTHONORMAL_BASIS_EXPAND_NORM = `!b x:real^N.\n pairwise orthogonal b /\\\n (!v. v IN b ==> norm v = &1) /\\\n x IN span b\n ==> sum b (\\v. (v dot x) pow 2) = norm x pow 2`;;\n\nlet ORTHOGONAL_IMP_INDEPENDENT_SUBSPACES = `!s t:real^N->bool.\n (!a b. a IN s /\\ b IN t ==> orthogonal a b)\n ==> s INTER t SUBSET {vec 0}`;;\n\nlet INDEPENDENT_SUBSPACES_ALT = `!s t:real^N->bool.\n subspace s /\\ subspace t\n ==> (s INTER t SUBSET {vec 0} <=> s INTER t = {vec 0})`;;\n\nlet INDEPENDENT_SUBSPACES_0 = `!s t:real^N->bool.\n subspace s /\\ subspace t\n ==> (s INTER t SUBSET {vec 0} <=>\n !x y. x IN s /\\ y IN t /\\ x + y = vec 0\n ==> x = vec 0 /\\ y = vec 0)`;;\n\nlet INDEPENDENT_SUBSPACES = `!s t:real^N->bool.\n subspace s /\\ subspace t\n ==> (s INTER t SUBSET {vec 0} <=>\n !x y x' y'. x IN s /\\ x' IN s /\\ y IN t /\\ y' IN t /\\\n x + y = x' + y'\n ==> x = x' /\\ y = y')`;;\n\nlet ORTHOGONAL_SUBSPACE_DECOMP_UNIQUE = `!s t x y x' y':real^N.\n (!a b. a IN s /\\ b IN t ==> orthogonal a b) /\\\n x IN span s /\\ x' IN span s /\\ y IN span t /\\ y' IN span t /\\\n x + y = x' + y'\n ==> x = x' /\\ y = y'`;;\n\nlet ORTHOGONAL_SUBSPACE_DECOMP_EXISTS = `!s x:real^N. ?y z. y IN span s /\\ (!w. w IN span s ==> orthogonal z w) /\\\n x = y + z`;;\n\nlet ORTHOGONAL_SUBSPACE_DECOMP = `!s x. ?!(y,z). y IN span s /\\\n z IN {z:real^N | !x. x IN span s ==> orthogonal z x} /\\\n x = y + z`;;\n\nlet ISOMETRY_SUBSET_SUBSPACE = `!s:real^M->bool t:real^N->bool.\n subspace s /\\ subspace t /\\ dim s <= dim t\n ==> ?f. linear f /\\ IMAGE f s SUBSET t /\\\n (!x. x IN s ==> norm(f x) = norm(x))`;;\n\nlet ISOMETRIES_SUBSPACES = `!s:real^M->bool t:real^N->bool.\n subspace s /\\ subspace t /\\ dim s = dim t\n ==> ?f g. linear f /\\ linear g /\\\n IMAGE f s = t /\\ IMAGE g t = s /\\\n (!x. x IN s ==> norm(f x) = norm x) /\\\n (!y. y IN t ==> norm(g y) = norm y) /\\\n (!x. x IN s ==> g(f x) = x) /\\\n (!y. y IN t ==> f(g y) = y)`;;\n\nlet ISOMETRY_SUBSPACES = `!s:real^M->bool t:real^N->bool.\n subspace s /\\ subspace t /\\ dim s = dim t\n ==> ?f:real^M->real^N. linear f /\\ IMAGE f s = t /\\\n (!x. x IN s ==> norm(f x) = norm(x))`;;\n\nlet ISOMETRY_UNIV_SUBSPACE = `!s. subspace s /\\ dimindex(:M) = dim s\n ==> ?f:real^M->real^N.\n linear f /\\ IMAGE f (:real^M) = s /\\\n (!x. norm(f x) = norm(x))`;;\n\nlet ISOMETRY_UNIV_SUPERSET_SUBSPACE = `!s. subspace s /\\ dim s <= dimindex(:M) /\\ dimindex(:M) <= dimindex(:N)\n ==> ?f:real^M->real^N.\n linear f /\\ s SUBSET (IMAGE f (:real^M)) /\\\n (!x. norm(f x) = norm(x))`;;\n\nlet ISOMETRY_UNIV_UNIV = `dimindex(:M) <= dimindex(:N)\n ==> ?f:real^M->real^N. linear f /\\ (!x. norm(f x) = norm(x))`;;\n\nlet SUBSPACE_ISOMORPHISM = `!s t. subspace s /\\ subspace t /\\ dim(s) = dim(t)\n ==> ?f:real^M->real^N.\n linear f /\\ (IMAGE f s = t) /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> (x = y))`;;\n\nlet ISOMORPHISMS_UNIV_UNIV = `dimindex(:M) = dimindex(:N)\n ==> ?f:real^M->real^N g.\n linear f /\\ linear g /\\\n (!x. norm(f x) = norm x) /\\ (!y. norm(g y) = norm y) /\\\n (!x. g(f x) = x) /\\ (!y. f(g y) = y)`;;\n\nlet SUBSPACE_HYPERPLANE = `!a. subspace {x:real^N | a dot x = &0}`;;\n\nlet SUBSPACE_SPECIAL_HYPERPLANE = `!k. subspace {x:real^N | x$k = &0}`;;\n\nlet SPECIAL_HYPERPLANE_SPAN = `!k. 1 <= k /\\ k <= dimindex(:N)\n ==> {x:real^N | x$k = &0} =\n span(IMAGE basis ((1..dimindex(:N)) DELETE k))`;;\n\nlet DIM_SPECIAL_HYPERPLANE = `!k. 1 <= k /\\ k <= dimindex(:N)\n ==> dim {x:real^N | x$k = &0} = dimindex(:N) - 1`;;\n\nlet LOWDIM_EQ_INTER_HYPERPLANE = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ t SUBSET s /\\ dim t + 1 = dim s\n ==> ?a. ~(a = vec 0) /\\ {x | a dot x = &0} INTER s = t`;;\n\nlet LOWDIM_EQ_HYPERPLANE = `!s. dim s = dimindex(:N) - 1\n ==> ?a:real^N. ~(a = vec 0) /\\ span s = {x | a dot x = &0}`;;\n\nlet DIM_IMAGE_KERNEL_GEN = `!f:real^M->real^N s.\n linear f /\\ subspace s\n ==> dim(IMAGE f s) + dim {x | x IN s /\\ f x = vec 0} = dim(s)`;;\n\nlet DIM_IMAGE_KERNEL = `!f:real^M->real^N.\n linear f\n ==> dim(IMAGE f (:real^M)) + dim {x | f x = vec 0} = dimindex(:M)`;;\n\nlet DIM_SUMS_INTER = `!s t:real^N->bool.\n subspace s /\\ subspace t\n ==> dim {x + y | x IN s /\\ y IN t} + dim(s INTER t) = dim(s) + dim(t)`;;\n\nlet DIM_UNION_INTER = `!s t:real^N->bool.\n subspace s /\\ subspace t\n ==> dim(s UNION t) + dim(s INTER t) = dim s + dim t`;;\n\nlet DIM_KERNEL_COMPOSE = `!f:real^M->real^N g:real^N->real^P.\n linear f /\\ linear g\n ==> dim {x | (g o f) x = vec 0} <=\n dim {x | f(x) = vec 0} +\n dim {y | g(y) = vec 0}`;;\n\nlet DIM_ORTHOGONAL_SUM = `!s t:real^N->bool.\n (!x y. x IN s /\\ y IN t ==> x dot y = &0)\n ==> dim(s UNION t) = dim(s) + dim(t)`;;\n\nlet DIM_SUBSPACE_ORTHOGONAL_TO_VECTORS = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ s SUBSET t\n ==> dim {y | y IN t /\\ !x. x IN s ==> orthogonal x y} + dim s = dim t`;;\n\nlet DIM_SPECIAL_SUBSPACE = `!k. dim {x:real^N |\n !i. 1 <= i /\\ i <= dimindex(:N) /\\ i IN k ==> x$i = &0} =\n CARD((1..dimindex(:N)) DIFF k)`;;\n\nlet INDEPENDENT_UNION = `!s t:real^N->bool.\n independent s /\\ independent t /\\\n (span s) INTER (span t) SUBSET {vec 0}\n ==> independent(s UNION t)`;;\n\nlet LINEAR_INJECTIVE_ON_IFF_DIM = `!f:real^M->real^N s.\n linear f /\\ subspace s\n ==> ((!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y) <=>\n dim(IMAGE f s) = dim s)`;;\n\nlet DIM_INJECTIVE_ON_LINEAR_IMAGE = `!f:real^M->real^N s.\n linear f /\\ subspace s /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)\n ==> dim(IMAGE f s) = dim s`;;\n\nlet DIM_EQ_SUBSPACES = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ s SUBSET t /\\ dim t <= dim s\n ==> s = t`;;\n\nlet DIM_EQ_SUBSPACE = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ s SUBSET t\n ==> (dim s = dim t <=> s = t)`;;\n\nlet LINEAR_SURJECTIVE_ON_IFF_DIM = `!f:real^M->real^N s t.\n linear f /\\ subspace s /\\ subspace t /\\ IMAGE f s SUBSET t\n ==> (IMAGE f s = t <=> dim(IMAGE f s) = dim t)`;;\n\nlet LINEAR_INJECTIVE_IMP_SURJECTIVE_ON = `!f:real^M->real^N s t.\n linear f /\\ subspace s /\\ subspace t /\\\n IMAGE f s SUBSET t /\\ dim t <= dim s /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)\n ==> IMAGE f s = t`;;\n\nlet LINEAR_SURJECTIVE_IFF_INJECTIVE_ON = `!f:real^M->real^N s t.\n linear f /\\ subspace s /\\ subspace t /\\\n IMAGE f s SUBSET t /\\ dim s = dim t\n ==> (IMAGE f s = t <=>\n !x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)`;;\n\nlet LINEAR_INJECTIVE_IFF_DIM = `!f:real^M->real^N.\n linear f\n ==> ((!x y. f x = f y ==> x = y) <=>\n dim(IMAGE f (:real^M)) = dimindex(:M))`;;\n\nlet LINEAR_SURJECTIVE_IFF_DIM = `!f:real^M->real^N.\n linear f\n ==> ((!y. ?x. f x = y) <=>\n dim(IMAGE f (:real^M)) = dimindex(:N))`;;\n\nlet LINEAR_SURJECTIVE_IFF_INJECTIVE_GEN = `!f:real^M->real^N.\n dimindex(:M) = dimindex(:N) /\\ linear f\n ==> ((!y. ?x. f x = y) <=> (!x y. f x = f y ==> x = y))`;;\n\nlet MATRIX_INVERTIBLE_LEFT_GEN = `!f:real^M->real^N.\n linear f /\\ dimindex(:N) <= dimindex(:M)\n ==> (invertible(matrix f) <=> ?g. linear g /\\ g o f = I)`;;\n\nlet MATRIX_INVERTIBLE_LEFT = `!f:real^N->real^N.\n linear f\n ==> (invertible(matrix f) <=> ?g. linear g /\\ g o f = I)`;;\n\nlet MATRIX_INVERTIBLE_RIGHT_GEN = `!f:real^M->real^N.\n linear f /\\ dimindex(:M) <= dimindex(:N)\n ==> (invertible(matrix f) <=> ?g. linear g /\\ f o g = I)`;;\n\nlet MATRIX_INVERTIBLE_RIGHT = `!f:real^N->real^N.\n linear f\n ==> (invertible(matrix f) <=> ?g. linear g /\\ f o g = I)`;;\n\nlet PASTECART_AS_ORTHOGONAL_SUM = `!x:real^M y:real^N.\n pastecart x y = pastecart x (vec 0) + pastecart (vec 0) y`;;\n\nlet PCROSS_AS_ORTHOGONAL_SUM = `!s:real^M->bool t:real^N->bool.\n s PCROSS t =\n {u + v | u IN IMAGE (\\x. pastecart x (vec 0)) s /\\\n v IN IMAGE (\\y. pastecart (vec 0) y) t}`;;\n\nlet DIM_PCROSS = `!s:real^M->bool t:real^N->bool.\n subspace s /\\ subspace t ==> dim(s PCROSS t) = dim s + dim t`;;\n\nlet SPAN_PCROSS_SUBSET = `!s:real^M->bool t:real^N->bool.\n span(s PCROSS t) SUBSET (span s) PCROSS (span t)`;;\n\nlet SPAN_PCROSS = `!s:real^M->bool t:real^N->bool.\n ~(s = {}) /\\ ~(t = {}) /\\ (vec 0 IN s \\/ vec 0 IN t)\n ==> span(s PCROSS t) = (span s) PCROSS (span t)`;;\n\nlet DIM_PCROSS_STRONG = `!s:real^M->bool t:real^N->bool.\n ~(s = {}) /\\ ~(t = {}) /\\ (vec 0 IN s \\/ vec 0 IN t)\n ==> dim(s PCROSS t) = dim s + dim t`;;\n\nlet SPAN_SUMS = `!s t:real^N->bool.\n ~(s = {}) /\\ ~(t = {}) /\\ vec 0 IN (s UNION t)\n ==> span {x + y | x IN s /\\ y IN t} =\n {x + y | x IN span s /\\ y IN span t}`;;\n\nlet RANK_NULLSPACE = `!A:real^M^N. rank A + dim {x | A ** x = vec 0} = dimindex(:M)`;;\n\nlet RANK_SYLVESTER = `!A:real^N^M B:real^P^N.\n rank(A) + rank(B) <= rank(A ** B) + dimindex(:N)`;;\n\nlet RANK_GRAM = `!A:real^M^N. rank(transp A ** A) = rank A`;;\n\nlet RANK_TRIANGLE = `!A B:real^M^N. rank(A + B) <= rank(A) + rank(B)`;;\n\nlet COVARIANCE_MATRIX_EQ_0 = `!A:real^N^M. transp A ** A = mat 0 <=> A = mat 0`;;\n\nlet MATRIX_MUL_COVARIANCE_LCANCEL = `!A:real^N^P B C:real^M^N.\n (transp A ** A) ** B = (transp A ** A) ** C <=> A ** B = A ** C`;;\n\nlet MATRIX_MUL_COVARIANCE_RCANCEL = `!A:real^P^N B C:real^N^M.\n B ** (A ** transp A) = C ** (A ** transp A) <=> B ** A = C ** A`;;\n\nlet MATRIX_VECTOR_MUL_COVARIANCE_EQ_0 = `!A:real^M^N x. (transp A ** A) ** x = vec 0 <=> A ** x = vec 0`;;\n\nlet matrix_inv = new_definition\n `matrix_inv (A:real^M^N) =\n matrix(\\y. @x. (!w. A ** w = vec 0 ==> orthogonal x w) /\\\n (!z. orthogonal (y - A ** x) (A ** z)))`;;\n\nlet MOORE_PENROSE_PSEUDOINVERSE,MOORE_PENROSE_PSEUDOINVERSE_UNIQUE =\n let lemma_existence = `!f:real^M->real^N y.\n linear f\n ==> ?x. (!w. f w = vec 0 ==> orthogonal x w) /\\\n (!z. orthogonal (y - f x) (f z))`;;\n\nlet SYMMETRIC_MATRIX_INV_RMUL = `!A:real^M^N. symmetric_matrix(A ** matrix_inv A)`;;\n\nlet MATRIX_INV_INV = `!A:real^M^N. matrix_inv (matrix_inv A) = A`;;\n\nlet MATRIX_INV_EQ = `!A B:real^M^N. matrix_inv A = matrix_inv B <=> A = B`;;\n\nlet MATRIX_INV_MUL_OUTER = `!A:real^M^N. matrix_inv A ** A ** matrix_inv A = matrix_inv A`;;\n\nlet SYMMETRIC_MATRIX_INV_LMUL = `!A:real^M^N. symmetric_matrix(matrix_inv A ** A)`;;\n\nlet MATRIX_INV_UNIQUE_STRONG = `!A:real^M^N X.\n A ** X ** A = A /\\ X ** A ** X = X /\\\n symmetric_matrix(A ** X) /\\ symmetric_matrix(X ** A)\n ==> matrix_inv A = X`;;\n\nlet MATRIX_INV_TRANSP = `!A:real^M^N. matrix_inv (transp A) = transp(matrix_inv A)`;;\n\nlet TRANSP_MATRIX_INV = `!A:real^M^N. transp(matrix_inv A) = matrix_inv(transp A)`;;\n\nlet SYMMETRIC_MATRIX_INV = `!A:real^N^N. symmetric_matrix(matrix_inv A) <=> symmetric_matrix A`;;\n\nlet MATRIX_INV_0 = `matrix_inv(mat 0:real^M^N) = mat 0`;;\n\nlet MATRIX_INV_EQ_0 = `!A:real^M^N. matrix_inv A = mat 0 <=> A = mat 0`;;\n\nlet MATRIX_INV_CMUL = `!c A:real^M^N. matrix_inv (c %% A) = inv(c) %% matrix_inv A`;;\n\nlet MATRIX_INV = `!A:real^N^M.\n invertible A ==> A ** matrix_inv A = mat 1 /\\ matrix_inv A ** A = mat 1`;;\n\nlet MATRIX_INV_LEFT = `!A:real^N^N. matrix_inv A ** A = mat 1 <=> invertible A`;;\n\nlet MATRIX_INV_RIGHT = `!A:real^N^N. A ** matrix_inv A = mat 1 <=> invertible A`;;\n\nlet MATRIX_MUL_LCANCEL = `!A:real^M^N B:real^P^M C.\n invertible A ==> (A ** B = A ** C <=> B = C)`;;\n\nlet MATRIX_MUL_RCANCEL = `!A B:real^M^N C:real^P^M.\n invertible C ==> (A ** C = B ** C <=> A = B)`;;\n\nlet RANK_INVERTIBLE_RMUL = `!A:real^M^N B:real^P^M. invertible B ==> rank(A ** B) = rank A`;;\n\nlet RANK_INVERTIBLE_LMUL = `!A:real^M^N B:real^P^M. invertible A ==> rank(A ** B) = rank B`;;\n\nlet RANK_CMUL = `!A:real^N^M c. rank(c %% A) = if c = &0 then 0 else rank A`;;\n\nlet RANK_NEG = `!A:real^N^M. rank(--A) = rank A`;;\n\nlet MATRIX_INV_UNIQUE = `!A:real^N^M B. A ** B = mat 1 /\\ B ** A = mat 1 ==> matrix_inv A = B`;;\n\nlet MATRIX_INV_I = `matrix_inv(mat 1:real^N^N) = mat 1`;;\n\nlet INVERTIBLE_MATRIX_INV = `!A:real^M^N. invertible(matrix_inv A) <=> invertible A`;;\n\nlet MATRIX_INV_UNIQUE_LEFT = `!A:real^N^N B. A ** B = mat 1 ==> matrix_inv B = A`;;\n\nlet MATRIX_INV_UNIQUE_RIGHT = `!A:real^N^N B. A ** B = mat 1 ==> matrix_inv A = B`;;\n\nlet MATRIX_INV_COVARIANCE = `!A:real^M^N.\n matrix_inv(transp A ** A) = matrix_inv(A) ** transp(matrix_inv A)`;;\n\nlet COVARIANCE_MATRIX_INV = `!A:real^M^N.\n transp(matrix_inv A) ** matrix_inv A = matrix_inv(A ** transp A)`;;\n\nlet NORMAL_MATRIX_INV = `!A:real^N^N. normal_matrix(matrix_inv A) <=> normal_matrix A`;;\n\nlet MATRIX_INV_COVARIANCE_RMUL = `!A:real^M^N. matrix_inv(transp A ** A) ** transp A = matrix_inv A`;;\n\nlet MATRIX_INV_COVARIANCE_LMUL = `!A:real^M^N. transp(A) ** matrix_inv(A ** transp A) = matrix_inv A`;;\n\nlet RANK_SIMILAR = `!A:real^N^N U:real^M^N.\n invertible U ==> rank(matrix_inv U ** A ** U) = rank A`;;\n\nlet RANK_MATRIX_INV = `!A:real^M^N. rank(matrix_inv A) = rank A`;;\n\nlet RANK_MATRIX_INV_RMUL = `!A:real^M^N. rank(A ** matrix_inv A) = rank A`;;\n\nlet RANK_MATRIX_INV_LMUL = `!A:real^M^N. rank(matrix_inv A ** A) = rank A`;;\n\nlet MATRIX_INV_MULTIPLE_TRANP_RIGHT = `!A:real^M^N.\n matrix_inv A = matrix_inv A ** transp(matrix_inv A) ** transp A`;;\n\nlet MATRIX_TRANSP_MULTIPLE_INV_RIGHT = `!A:real^M^N. transp A = transp A ** A ** matrix_inv A`;;\n\nlet MATRIX_INV_MULTIPLE_TRANP_LEFT = `!A:real^M^N.\n matrix_inv A = transp A ** transp(matrix_inv A) ** matrix_inv A`;;\n\nlet MATRIX_TRANSP_MULTIPLE_INV_LEFT = `!A:real^M^N. transp A = matrix_inv A ** A ** transp A`;;\n\nlet MATRIX_VECTOR_MUL_INV_EQ_0 = `!A:real^M^N. matrix_inv A ** x = vec 0 <=> transp A ** x = vec 0`;;\n\nlet KERNEL_MATRIX_INV = `!A:real^M^N.\n {x | matrix_inv A ** x = vec 0} = {x | transp A ** x = vec 0}`;;\n\nlet IMAGE_MATRIX_INV = `!A:real^M^N.\n IMAGE (\\x:real^N. matrix_inv A ** x) UNIV =\n IMAGE (\\x. transp A ** x) UNIV`;;\n\nlet COMMUTING_MATRIX_INV_COVARIANCE = `!A:real^M^N.\n matrix_inv(transp A ** A) ** (transp A ** A) =\n (transp A ** A) ** matrix_inv(transp A ** A)`;;\n\nlet COMMUTING_MATRIX_INV_NORMAL = `!A:real^N^N.\n normal_matrix A ==> matrix_inv A ** A = A ** matrix_inv A`;;\n\nlet MATRIX_MUL_INV_EQ_0 = `!A:real^P^N B:real^N^M.\n matrix_inv A ** matrix_inv B = mat 0 <=> B ** A = mat 0`;;\n\nlet MATRIX_INV_IDEMPOTENT = `!A:real^N^N. symmetric_matrix A /\\ A ** A = A ==> matrix_inv A = A`;;\n\nlet IDEMPOTENT_MATRIX_MUL_LINV = `!A:real^N^M.\n (matrix_inv A ** A) ** (matrix_inv A ** A) = matrix_inv A ** A`;;\n\nlet IDEMPOTENT_MATRIX_MUL_RINV = `!A:real^N^M.\n (A ** matrix_inv A) ** (A ** matrix_inv A) = A ** matrix_inv A`;;\n\nlet MATRIX_INV_MUL_LINV = `!A:real^N^M. matrix_inv(matrix_inv A ** A) = matrix_inv A ** A`;;\n\nlet MATRIX_INV_MUL_RINV = `!A:real^N^M. matrix_inv(A ** matrix_inv A) = A ** matrix_inv A`;;\n\nlet infnorm = define\n `infnorm (x:real^N) = sup { abs(x$i) | 1 <= i /\\ i <= dimindex(:N) }`;;\n\nlet NUMSEG_DIMINDEX_NONEMPTY = `?i. i IN 1..dimindex(:N)`;;\n\nlet INFNORM_SET_IMAGE = `{abs(x$i) | 1 <= i /\\ i <= dimindex(:N)} =\n IMAGE (\\i. abs(x$i)) (1..dimindex(:N))`;;\n\nlet INFNORM_SET_LEMMA = `FINITE {abs((x:real^N)$i) | 1 <= i /\\ i <= dimindex(:N)} /\\\n ~({abs(x$i) | 1 <= i /\\ i <= dimindex(:N)} = {})`;;\n\nlet INFNORM_POS_LE = `!x. &0 <= infnorm x`;;\n\nlet INFNORM_TRIANGLE = `!x y. infnorm(x + y) <= infnorm x + infnorm y`;;\n\nlet INFNORM_EQ_0 = `!x. infnorm x = &0 <=> x = vec 0`;;\n\nlet INFNORM_0 = `infnorm(vec 0) = &0`;;\n\nlet INFNORM_NEG = `!x. infnorm(--x) = infnorm x`;;\n\nlet INFNORM_SUB = `!x y. infnorm(x - y) = infnorm(y - x)`;;\n\nlet REAL_ABS_SUB_INFNORM = `abs(infnorm x - infnorm y) <= infnorm(x - y)`;;\n\nlet REAL_ABS_INFNORM = `!x. abs(infnorm x) = infnorm x`;;\n\nlet COMPONENT_LE_INFNORM = `!x:real^N i. 1 <= i /\\ i <= dimindex (:N) ==> abs(x$i) <= infnorm x`;;\n\nlet INFNORM_MUL_LEMMA = `!a x. infnorm(a % x) <= abs a * infnorm x`;;\n\nlet INFNORM_MUL = `!a x:real^N. infnorm(a % x) = abs a * infnorm x`;;\n\nlet INFNORM_POS_LT = `!x. &0 < infnorm x <=> ~(x = vec 0)`;;\n\nlet INFNORM_LE_NORM = `!x. infnorm(x) <= norm(x)`;;\n\nlet NORM_LE_INFNORM = `!x:real^N. norm(x) <= sqrt(&(dimindex(:N))) * infnorm(x)`;;\n\nlet NORM_CAUCHY_SCHWARZ_EQ = `!x:real^N y. x dot y = norm(x) * norm(y) <=> norm(x) % y = norm(y) % x`;;\n\nlet NORM_CAUCHY_SCHWARZ_ABS_EQ = `!x:real^N y. abs(x dot y) = norm(x) * norm(y) <=>\n norm(x) % y = norm(y) % x \\/ norm(x) % y = --norm(y) % x`;;\n\nlet NORM_TRIANGLE_EQ = `!x y:real^N. norm(x + y) = norm(x) + norm(y) <=> norm(x) % y = norm(y) % x`;;\n\nlet DIST_TRIANGLE_EQ = `!x y z. dist(x,z) = dist(x,y) + dist(y,z) <=>\n norm (x - y) % (y - z) = norm (y - z) % (x - y)`;;\n\nlet NORM_CROSS_MULTIPLY = `!a b x y:real^N.\n a % x = b % y /\\ &0 < a /\\ &0 < b\n ==> norm y % x = norm x % y`;;\n\nlet collinear = new_definition\n `collinear s <=> ?u. !x y. x IN s /\\ y IN s ==> ?c. x - y = c % u`;;\n\nlet COLLINEAR_ALT2 = `!s:real^N->bool. collinear s <=> ?u v. !x. x IN s ==> ?c. x - u = c % v`;;\n\nlet COLLINEAR_ALT = `!s:real^N->bool. collinear s <=> ?u v. !x. x IN s ==> ?c. x = u + c % v`;;\n\nlet COLLINEAR_SUBSET = `!s t. collinear t /\\ s SUBSET t ==> collinear s`;;\n\nlet COLLINEAR_EMPTY = `collinear {}`;;\n\nlet COLLINEAR_SING = `!x. collinear {x}`;;\n\nlet COLLINEAR_2 = `!x y:real^N. collinear {x,y}`;;\n\nlet COLLINEAR_SMALL = `!s. FINITE s /\\ CARD s <= 2 ==> collinear s`;;\n\nlet COLLINEAR_3 = `!x y z. collinear {x,y,z} <=> collinear {vec 0,x - y,z - y}`;;\n\nlet COLLINEAR_LEMMA = `!x y:real^N. collinear {vec 0,x,y} <=>\n x = vec 0 \\/ y = vec 0 \\/ ?c. y = c % x`;;\n\nlet COLLINEAR_LEMMA_ALT = `!x y. collinear {vec 0,x,y} <=> x = vec 0 \\/ ?c. y = c % x`;;\n\nlet COLLINEAR_SPAN = `!a b:real^N. collinear{vec 0,a,b} <=> a = vec 0 \\/ b IN span {a}`;;\n\nlet NORM_CAUCHY_SCHWARZ_EQUAL = `!x y:real^N. abs(x dot y) = norm(x) * norm(y) <=> collinear {vec 0,x,y}`;;\n\nlet DOT_CAUCHY_SCHWARZ_EQUAL = `!x y:real^N.\n (x dot y) pow 2 = (x dot x) * (y dot y) <=>\n collinear {vec 0,x,y}`;;\n\nlet COLLINEAR_3_EXPAND = `!a b c:real^N. collinear{a,b,c} <=> a = c \\/ ?u. b = u % a + (&1 - u) % c`;;\n\nlet COLLINEAR_TRIPLES = `!s a b:real^N.\n ~(a = b)\n ==> (collinear(a INSERT b INSERT s) <=>\n !x. x IN s ==> collinear{a,b,x})`;;\n\nlet COLLINEAR_4_3 = `!a b c d:real^N.\n ~(a = b)\n ==> (collinear {a,b,c,d} <=> collinear{a,b,c} /\\ collinear{a,b,d})`;;\n\nlet COLLINEAR_3_TRANS = `!a b c d:real^N.\n collinear{a,b,c} /\\ collinear{b,c,d} /\\ ~(b = c) ==> collinear{a,b,d}`;;\n\nlet ORTHOGONAL_TO_ORTHOGONAL_2D = `!x y z:real^2.\n ~(x = vec 0) /\\ orthogonal x y /\\ orthogonal x z\n ==> collinear {vec 0,y,z}`;;\n\nlet COLLINEAR_3_2D = `!x y z:real^2. collinear{x,y,z} <=>\n (z$1 - x$1) * (y$2 - x$2) = (y$1 - x$1) * (z$2 - x$2)`;;\n\nlet COLLINEAR_3_DOT_MULTIPLES = `!a b c:real^N.\n collinear {a,b,c} <=>\n ((b - a) dot (b - a)) % (c - a) = ((c - a) dot (b - a)) % (b - a)`;;\n\nlet ORTHOGONAL_AND_COLLINEAR = `!x y:real^N.\n orthogonal x y /\\ collinear{vec 0,x,y} <=> x = vec 0 \\/ y = vec 0`;;\n\nlet between = new_definition\n `between x (a,b) <=> dist(a,b) = dist(a,x) + dist(x,b)`;;\n\nlet BETWEEN_REFL = `!a b. between a (a,b) /\\ between b (a,b) /\\ between a (a,a)`;;\n\nlet BETWEEN_REFL_EQ = `!a x. between x (a,a) <=> x = a`;;\n\nlet BETWEEN_SYM = `!a b x. between x (a,b) <=> between x (b,a)`;;\n\nlet BETWEEN_ANTISYM = `!a b c. between a (b,c) /\\ between b (a,c) ==> a = b`;;\n\nlet BETWEEN_TRANS = `!a b c d. between a (b,c) /\\ between d (a,c) ==> between d (b,c)`;;\n\nlet BETWEEN_TRANS_2 = `!a b c d. between a (b,c) /\\ between d (a,b) ==> between a (c,d)`;;\n\nlet BETWEEN_TRANSLATION = `!a x y. between (a + x) (a + y,a + z) <=> between x (y,z)`;;\n\nlet BETWEEN_NORM = `!a b x:real^N.\n between x (a,b) <=> norm(x - a) % (b - x) = norm(b - x) % (x - a)`;;\n\nlet BETWEEN_DOT = `!a b x:real^N.\n between x (a,b) <=> (x - a) dot (b - x) = norm(x - a) * norm(b - x)`;;\n\nlet BETWEEN_EXISTS_EXTENSION = `!a b x:real^N.\n between b (a,x) /\\ ~(b = a) ==> ?d. &0 <= d /\\ x = b + d % (b - a)`;;\n\nlet BETWEEN_IMP_COLLINEAR = `!a b x:real^N. between x (a,b) ==> collinear {a,x,b}`;;\n\nlet BETWEEN_CMUL_LIFT = `!a b c v:real^N.\n between (c % v) (a % v,b % v) <=>\n v = vec 0 \\/ between (lift c) (lift a,lift b)`;;\n\nlet BETWEEN_1 = `!a b x. between x (a,b) <=>\n drop a <= drop x /\\ drop x <= drop b \\/\n drop b <= drop x /\\ drop x <= drop a`;;\n\nlet COLLINEAR_BETWEEN_CASES = `!a b c:real^N.\n collinear {a,b,c} <=>\n between a (b,c) \\/ between b (c,a) \\/ between c (a,b)`;;\n\nlet COLLINEAR_BETWEEN_CASES_2 = `!a b c d:real^N.\n between c (a,b) /\\ between d (a,b)\n ==> between d (a,c) \\/ between d (c,b)`;;\n\nlet BETWEEN_RESTRICTED_CASES = `!a b c x:real^N.\n between x (a,b) /\\ between x (a,c) /\\ ~(x = a)\n ==> between b (a,c) \\/ between c (a,b)`;;\n\nlet COLLINEAR_DIST_BETWEEN = `!a b x. collinear {x,a,b} /\\\n dist(x,a) <= dist(a,b) /\\ dist(x,b) <= dist(a,b)\n ==> between x (a,b)`;;\n\nlet BETWEEN_COLLINEAR_DIST_EQ = `!a b x:real^N.\n between x (a,b) <=>\n collinear {a, x, b} /\\\n dist(x,a) <= dist(a,b) /\\ dist(x,b) <= dist(a,b)`;;\n\nlet COLLINEAR_1 = `!s:real^1->bool. collinear s`;;\n\nlet midpoint = new_definition\n `midpoint(a,b) = inv(&2) % (a + b)`;;\n\nlet MIDPOINT_REFL = `!x. midpoint(x,x) = x`;;\n\nlet MIDPOINT_SYM = `!a b. midpoint(a,b) = midpoint(b,a)`;;\n\nlet DIST_MIDPOINT = `!a b. dist(a,midpoint(a,b)) = dist(a,b) / &2 /\\\n dist(b,midpoint(a,b)) = dist(a,b) / &2 /\\\n dist(midpoint(a,b),a) = dist(a,b) / &2 /\\\n dist(midpoint(a,b),b) = dist(a,b) / &2`;;\n\nlet MIDPOINT_EQ_ENDPOINT = `!a b. (midpoint(a,b) = a <=> a = b) /\\\n (midpoint(a,b) = b <=> a = b) /\\\n (a = midpoint(a,b) <=> a = b) /\\\n (b = midpoint(a,b) <=> a = b)`;;\n\nlet BETWEEN_MIDPOINT = `!a b. between (midpoint(a,b)) (a,b) /\\ between (midpoint(a,b)) (b,a)`;;\n\nlet MIDPOINT_LINEAR_IMAGE = `!f a b. linear f ==> midpoint(f a,f b) = f(midpoint(a,b))`;;\n\nlet COLLINEAR_MIDPOINT = `!a b. collinear{a,midpoint(a,b),b}`;;\n\nlet MIDPOINT_COLLINEAR = `!a b c:real^N.\n ~(a = c)\n ==> (b = midpoint(a,c) <=> collinear{a,b,c} /\\ dist(a,b) = dist(b,c))`;;\n\nlet MIDPOINT_BETWEEN = `!a b c:real^N.\n b = midpoint (a,c) <=> between b (a,c) /\\ dist (a,b) = dist (b,c)`;;\n\nlet DROP_MIDPOINT = `!x y. drop(midpoint(x,y)) = (drop x + drop y) / &2`;;\n\nlet open_interval = new_definition\n `open_interval(a:real^N,b:real^N) =\n {x:real^N | !i. 1 <= i /\\ i <= dimindex(:N)\n ==> a$i < x$i /\\ x$i < b$i}`;;\n\nlet closed_interval = new_definition\n `closed_interval(l:(real^N#real^N)list) =\n {x:real^N | !i. 1 <= i /\\ i <= dimindex(:N)\n ==> FST(HD l)$i <= x$i /\\ x$i <= SND(HD l)$i}`;;\n\nmake_overloadable \"interval\" `:A`;;\n\noverload_interface(\"interval\",`open_interval`);;\noverload_interface(\"interval\",`closed_interval`);;\n\nlet interval = `(interval (a,b) = {x:real^N | !i. 1 <= i /\\ i <= dimindex(:N)\n ==> a$i < x$i /\\ x$i < b$i}) /\\\n (interval [a,b] = {x:real^N | !i. 1 <= i /\\ i <= dimindex(:N)\n ==> a$i <= x$i /\\ x$i <= b$i})`;;\n\nlet IN_INTERVAL = `(!x:real^N.\n x IN interval (a,b) <=>\n !i. 1 <= i /\\ i <= dimindex(:N)\n ==> a$i < x$i /\\ x$i < b$i) /\\\n (!x:real^N.\n x IN interval [a,b] <=>\n !i. 1 <= i /\\ i <= dimindex(:N)\n ==> a$i <= x$i /\\ x$i <= b$i)`;;\n\nlet IN_INTERVAL_REFLECT = `(!a b x. (--x) IN interval[--b,--a] <=> x IN interval[a,b]) /\\\n (!a b x. (--x) IN interval(--b,--a) <=> x IN interval(a,b))`;;\n\nlet REFLECT_INTERVAL = `(!a b:real^N. IMAGE (--) (interval[a,b]) = interval[--b,--a]) /\\\n (!a b:real^N. IMAGE (--) (interval(a,b)) = interval(--b,--a))`;;\n\nlet INTERVAL_EQ_EMPTY = `((interval [a:real^N,b] = {}) <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\ b$i < a$i) /\\\n ((interval (a:real^N,b) = {}) <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\ b$i <= a$i)`;;\n\nlet INTERVAL_NE_EMPTY = `(~(interval [a:real^N,b] = {}) <=>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= b$i) /\\\n (~(interval (a:real^N,b) = {}) <=>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> a$i < b$i)`;;\n\nlet SUBSET_INTERVAL_IMP = `((!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i)\n ==> interval[c,d] SUBSET interval[a:real^N,b]) /\\\n ((!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i < c$i /\\ d$i < b$i)\n ==> interval[c,d] SUBSET interval(a:real^N,b)) /\\\n ((!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i)\n ==> interval(c,d) SUBSET interval[a:real^N,b]) /\\\n ((!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i)\n ==> interval(c,d) SUBSET interval(a:real^N,b))`;;\n\nlet INTERVAL_SING = `interval[a,a] = {a} /\\ interval(a,a) = {}`;;\n\nlet SUBSET_INTERVAL = `(interval[c,d] SUBSET interval[a:real^N,b] <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> c$i <= d$i)\n ==> (!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i)) /\\\n (interval[c,d] SUBSET interval(a:real^N,b) <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> c$i <= d$i)\n ==> (!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i < c$i /\\ d$i < b$i)) /\\\n (interval(c,d) SUBSET interval[a:real^N,b] <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> c$i < d$i)\n ==> (!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i)) /\\\n (interval(c,d) SUBSET interval(a:real^N,b) <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> c$i < d$i)\n ==> (!i. 1 <= i /\\ i <= dimindex(:N) ==> a$i <= c$i /\\ d$i <= b$i))`;;\n\nlet DISJOINT_INTERVAL = `!a b c d:real^N.\n (interval[a,b] INTER interval[c,d] = {} <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\\n (b$i < a$i \\/ d$i < c$i \\/ b$i < c$i \\/ d$i < a$i)) /\\\n (interval[a,b] INTER interval(c,d) = {} <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\\n (b$i < a$i \\/ d$i <= c$i \\/ b$i <= c$i \\/ d$i <= a$i)) /\\\n (interval(a,b) INTER interval[c,d] = {} <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\\n (b$i <= a$i \\/ d$i < c$i \\/ b$i <= c$i \\/ d$i <= a$i)) /\\\n (interval(a,b) INTER interval(c,d) = {} <=>\n ?i. 1 <= i /\\ i <= dimindex(:N) /\\\n (b$i <= a$i \\/ d$i <= c$i \\/ b$i <= c$i \\/ d$i <= a$i))`;;\n\nlet ENDS_IN_INTERVAL = `(!a b. a IN interval[a,b] <=> ~(interval[a,b] = {})) /\\\n (!a b. b IN interval[a,b] <=> ~(interval[a,b] = {})) /\\\n (!a b. ~(a IN interval(a,b))) /\\\n (!a b. ~(b IN interval(a,b)))`;;\n\nlet ENDS_IN_UNIT_INTERVAL = `vec 0 IN interval[vec 0,vec 1] /\\\n vec 1 IN interval[vec 0,vec 1] /\\\n ~(vec 0 IN interval(vec 0,vec 1)) /\\\n ~(vec 1 IN interval(vec 0,vec 1))`;;\n\nlet INTER_INTERVAL = `interval[a,b] INTER interval[c,d] =\n interval[(lambda i. max (a$i) (c$i)),(lambda i. min (b$i) (d$i))]`;;\n\nlet INTERVAL_OPEN_SUBSET_CLOSED = `!a b. interval(a,b) SUBSET interval[a,b]`;;\n\nlet WLOG_LINEAR_INJECTIVE_IMAGE_2 = `!P Q. (!f s. P s /\\ linear f ==> Q(IMAGE f s)) /\\\n (!g t. Q t /\\ linear g ==> P(IMAGE g t))\n ==> !f:real^M->real^N.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> !s. Q(IMAGE f s) <=> P s`;;\n\nlet WLOG_LINEAR_INJECTIVE_IMAGE_2_ALT = `!P Q f s. (!h u. P u /\\ linear h ==> Q(IMAGE h u)) /\\\n (!g t. Q t /\\ linear g ==> P(IMAGE g t)) /\\\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (Q(IMAGE f s) <=> P s)`;;\n\nlet WLOG_LINEAR_INJECTIVE_IMAGE = `!P. (!f s. P s /\\ linear f ==> P(IMAGE f s))\n ==> !f:real^N->real^N. linear f /\\ (!x y. f x = f y ==> x = y)\n ==> !s. P(IMAGE f s) <=> P s`;;\n\nlet WLOG_LINEAR_INJECTIVE_IMAGE_ALT = `!P f s. (!g t. P t /\\ linear g ==> P(IMAGE g t)) /\\\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (P(IMAGE f s) <=> P s)`;;\n\nlet LINEAR_INVARIANT_RULE th =\n let [f;s] = fst(strip_forall(concl th)) in\n let (rm,rn) = dest_fun_ty (type_of f) in\n let m = last(snd(dest_type rm)) and n = last(snd(dest_type rn)) in\n let th' = INST_TYPE [m,n; n,m] th in\n let th0 = CONJ th th' in\n let th1 = try MATCH_MP WLOG_LINEAR_INJECTIVE_IMAGE_2 th0\n with Failure _ ->\n MATCH_MP WLOG_LINEAR_INJECTIVE_IMAGE_2\n (GEN_REWRITE_RULE (BINOP_CONV o ONCE_DEPTH_CONV) [CONJ_SYM] th0) in\n GEN_REWRITE_RULE BINDER_CONV [RIGHT_IMP_FORALL_THM] th1;;\n\nlet SUBSPACE_LINEAR_IMAGE_EQ = `!f s. linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (subspace (IMAGE f s) <=> subspace s)`;;\n\nlet invariant_under_linear = ref([]:thm list);;\n\nlet invariant_under_translation = ref([]:thm list);;\n\nlet scaling_theorems = ref([]:thm list);;\n\nlet COUNTABLE_UNION_OF_BIJECTIVE_IMAGE = `!(f:A->B) P P'.\n (!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y) /\\\n (!s. P' (IMAGE f s) <=> P s)\n ==> (!s. (COUNTABLE UNION_OF P') (IMAGE f s) <=>\n (COUNTABLE UNION_OF P) s)`;;\n\nlet COUNTABLE_INTERSECTION_OF_BIJECTIVE_IMAGE = `!(f:A->B) P P'.\n (!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y) /\\\n (!s. P' (IMAGE f s) <=> P s)\n ==> (!s. (COUNTABLE INTERSECTION_OF P') (IMAGE f s) <=>\n (COUNTABLE INTERSECTION_OF P) s)`;;\n\nlet AFFINITY_SCALING_TRANSLATION = `!m c:real^N. (\\x. m % x + c) = (\\x. c + x) o (\\x. m % x)`;;\n\nlet LINEAR_SCALING = `!c. linear(\\x:real^N. c % x)`;;\n\nlet INJECTIVE_SCALING = `!c. (!x y:real^N. c % x = c % y ==> x = y) <=> ~(c = &0)`;;\n\nlet SURJECTIVE_SCALING = `!c. (!y:real^N. ?x. c % x = y) <=> ~(c = &0)`;;\n\nlet SCALING_INVARIANT =\n let pths = (CONJUNCTS o UNDISCH o prove)\n (`&0 < c\n ==> linear(\\x:real^N. c % x) /\\\n (!x y:real^N. c % x = c % y ==> x = y) /\\\n (!y:real^N. ?x. c % x = y)`,\n SIMP_TAC[REAL_LT_IMP_NZ; LINEAR_SCALING;\n INJECTIVE_SCALING; SURJECTIVE_SCALING])\n and sc_tm = `\\x:real^N. c % x`\n and sa_tm = `&0:real < c`\n and c_tm = `c:real` in\n fun th ->\n let ith = BETA_RULE(ISPEC sc_tm th) in\n let avs,bod = strip_forall(concl ith) in\n let cjs = conjuncts(lhand bod) in\n let cths = map (fun t -> find(fun th -> aconv (concl th) t) pths) cjs in\n let oth = MP (SPECL avs ith) (end_itlist CONJ cths) in\n GEN c_tm (DISCH sa_tm (GENL avs oth));;\n\nlet add_scaling_theorems thl =\n (scaling_theorems := (!scaling_theorems) @ thl);;\n\nlet add_linear_invariants thl =\n ignore(mapfilter (fun th -> add_scaling_theorems[SCALING_INVARIANT th]) thl);\n (invariant_under_linear := (!invariant_under_linear) @ thl);;\n\nlet add_translation_invariants thl =\n (invariant_under_translation := (!invariant_under_translation) @ thl);;\n\nlet th_sets = `!f. (!x y. f x = f y ==> x = y)\n ==> (if p then f x else f y) = f(if p then x else y) /\\\n (if p then IMAGE f s else IMAGE f t) =\n IMAGE f (if p then s else t) /\\\n (f x) INSERT (IMAGE f s) = IMAGE f (x INSERT s) /\\\n (IMAGE f s) DELETE (f x) = IMAGE f (s DELETE x) /\\\n (IMAGE f s) INTER (IMAGE f t) = IMAGE f (s INTER t) /\\\n (IMAGE f s) UNION (IMAGE f t) = IMAGE f (s UNION t) /\\\n UNIONS(IMAGE (IMAGE f) u) = IMAGE f (UNIONS u) /\\\n (IMAGE f s) DIFF (IMAGE f t) = IMAGE f (s DIFF t) /\\\n (IMAGE f s (f x) <=> s x) /\\\n ((f x) IN (IMAGE f s) <=> x IN s) /\\\n ((f o xs) (n:num) = f(xs n)) /\\\n ((f o pt) (tt:real^1) = f(pt tt)) /\\\n (IMAGE (f o g) k = IMAGE f (IMAGE g k)) /\\\n (DISJOINT (IMAGE f s) (IMAGE f t) <=> DISJOINT s t) /\\\n ((IMAGE f s) SUBSET (IMAGE f t) <=> s SUBSET t) /\\\n ((IMAGE f s) PSUBSET (IMAGE f t) <=> s PSUBSET t) /\\\n (IMAGE f s = IMAGE f t <=> s = t) /\\\n ((IMAGE f s) HAS_SIZE n <=> s HAS_SIZE n) /\\\n (FINITE(IMAGE f s) <=> FINITE s) /\\\n (INFINITE(IMAGE f s) <=> INFINITE s) /\\\n (COUNTABLE(IMAGE f s) <=> COUNTABLE s)`;;\n\nlet th_set = `!f:A->B s. (!x y. f x = f y ==> x = y) /\\ (!y. ?x. f x = y)\n ==> INTERS (IMAGE (IMAGE f) s) = IMAGE f (INTERS s)`;;\n\nlet PRESERVES_NORM_PRESERVES_DOT = `!f:real^M->real^N x y.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> (f x) dot (f y) = x dot y`;;\n\nlet PRESEVES_NORM_PRESERVES_DIST = `!f:real^M->real^N.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> !x y. dist(f x,f y) = dist(x,y)`;;\n\nlet PRESERVES_NORM_INJECTIVE = `!f:real^M->real^N.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> !x y. f x = f y ==> x = y`;;\n\nlet ORTHOGONAL_LINEAR_IMAGE_EQ = `!f:real^M->real^N x y.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> (orthogonal (f x) (f y) <=> orthogonal x y)`;;\n\nlet NORMAL_MATRIX_IFF_SAME_NORM_TRANSP,NORMAL_MATRIX_IFF_SAME_DOT_TRANSP =\n (CONJ_PAIR o prove)\n (`(!A:real^N^N.\n normal_matrix A <=>\n !x. norm(transp A ** x) = norm(A ** x)) /\\\n (!A:real^N^N.\n normal_matrix A <=>\n !x y. (transp A ** x) dot (transp A ** y) = (A ** x) dot (A ** y))`,\n REWRITE_TAC[normal_matrix; AND_FORALL_THM] THEN GEN_TAC THEN MATCH_MP_TAC\n (TAUT `(q <=> r) /\\ (p <=> r) ==> (p <=> q) /\\ (p <=> r)`) THEN\n CONJ_TAC THENL\n [EQ_TAC THENL [ALL_TAC; SIMP_TAC[NORM_EQ]] THEN\n REPEAT STRIP_TAC THEN MATCH_MP_TAC SAME_NORM_SAME_DOT THEN\n ASM_REWRITE_TAC[MATRIX_VECTOR_MUL_LINEAR] THEN\n GEN_REWRITE_TAC RAND_CONV [GSYM ETA_AX] THEN\n REWRITE_TAC[MATRIX_VECTOR_MUL_LINEAR];\n REWRITE_TAC[DOT_MATRIX_TRANSP_RMUL] THEN\n GEN_REWRITE_TAC (RAND_CONV o funpow 2 BINDER_CONV o RAND_CONV)\n [GSYM DOT_MATRIX_TRANSP_LMUL] THEN\n ONCE_REWRITE_TAC[GSYM REAL_SUB_0] THEN REWRITE_TAC[GSYM DOT_LSUB] THEN\n REWRITE_TAC[FORALL_DOT_EQ_0; MATRIX_VECTOR_MUL_ASSOC] THEN\n REWRITE_TAC[GSYM MATRIX_EQ_0; GSYM MATRIX_VECTOR_MUL_SUB_RDISTRIB] THEN\n REWRITE_TAC[MATRIX_SUB_EQ] THEN MESON_TAC[]]);;\n\nlet NORMAL_MATRIX_KERNEL_TRANSP_EXPLICIT = `!A x:real^N.\n normal_matrix A\n ==> (transp A ** x = vec 0 <=> A ** x = vec 0)`;;\n\nlet NORMAL_MATRIX_KERNEL_TRANSP = `!A:real^N^N.\n normal_matrix A\n ==> {x | transp A ** x = vec 0} = {x | A ** x = vec 0}`;;\n\nadd_linear_invariants\n [GSYM LINEAR_ADD;\n GSYM LINEAR_CMUL;\n GSYM LINEAR_SUB;\n GSYM LINEAR_NEG;\n MIDPOINT_LINEAR_IMAGE;\n MESON[] `!f:real^M->real^N x.\n (!x. norm(f x) = norm x) ==> norm(f x) = norm x`;\n PRESERVES_NORM_PRESERVES_DOT;\n MESON[dist; LINEAR_SUB]\n `!f:real^M->real^N x y.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> dist(f x,f y) = dist(x,y)`;\n MESON[] `!f:real^M->real^N x y.\n (!x y. f x = f y ==> x = y) ==> (f x = f y <=> x = y)`;\n SUBSPACE_LINEAR_IMAGE_EQ;\n ORTHOGONAL_LINEAR_IMAGE_EQ;\n SPAN_LINEAR_IMAGE;\n DEPENDENT_LINEAR_IMAGE_EQ;\n INDEPENDENT_LINEAR_IMAGE_EQ;\n DIM_INJECTIVE_LINEAR_IMAGE];;\n\nadd_translation_invariants\n [VECTOR_ARITH `!a x y. a + x:real^N = a + y <=> x = y`;\n NORM_ARITH `!a x y. dist(a + x,a + y) = dist(x,y)`;\n VECTOR_ARITH `!a x y. &1 / &2 % ((a + x) + (a + y)) = a + &1 / &2 % (x + y)`;\n VECTOR_ARITH `!a x y. inv(&2) % ((a + x) + (a + y)) = a + inv(&2) % (x + y)`;\n VECTOR_ARITH `!a x y. (a + x) - (a + y):real^N = x - y`;\n (EQT_ELIM o (REWRITE_CONV[midpoint] THENC(EQT_INTRO o NORM_ARITH)))\n `!a x y. midpoint(a + x,a + y) = a + midpoint(x,y)`;\n (EQT_ELIM o (REWRITE_CONV[between] THENC(EQT_INTRO o NORM_ARITH)))\n `!a x y z. between (a + x) (a + y,a + z) <=> between x (y,z)`];;\n\nlet th = `!a s b c:real^N. (a + b) + c IN IMAGE (\\x. a + x) s <=> (b + c) IN s`;;\n\nadd_translation_invariants [MEM_TRANSLATION];;\n\nlet MEM_LINEAR_IMAGE = `!f:real^M->real^N x l.\n linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (MEM (f x) (MAP f l) <=> MEM x l)`;;\n\nadd_linear_invariants [MEM_LINEAR_IMAGE];;\n\nlet LENGTH_TRANSLATION = `!a:real^N l. LENGTH(MAP (\\x. a + x) l) = LENGTH l`;;\n\nlet QUANTIFY_SURJECTION_HIGHER_THM = `!f:A->B.\n (!y. ?x. f x = y)\n ==> ((!P. (!x. P x) <=> (!x. P (f x))) /\\\n (!P. (?x. P x) <=> (?x. P (f x))) /\\\n (!Q. (!s. Q s) <=> (!s. Q(IMAGE f s))) /\\\n (!Q. (?s. Q s) <=> (?s. Q(IMAGE f s))) /\\\n (!Q. (!s. Q s) <=> (!s. Q(IMAGE (IMAGE f) s))) /\\\n (!Q. (?s. Q s) <=> (?s. Q(IMAGE (IMAGE f) s))) /\\\n (!P. (!g:real^1->B. P g) <=> (!g. P(f o g))) /\\\n (!P. (?g:real^1->B. P g) <=> (?g. P(f o g))) /\\\n (!P. (!g:num->B. P g) <=> (!g. P(f o g))) /\\\n (!P. (?g:num->B. P g) <=> (?g. P(f o g))) /\\\n (!Q. (!l. Q l) <=> (!l. Q(MAP f l))) /\\\n (!Q. (?l. Q l) <=> (?l. Q(MAP f l)))) /\\\n ((!P. {x | P x} = IMAGE f {x | P(f x)}) /\\\n (!Q. {s | Q s} = IMAGE (IMAGE f) {s | Q(IMAGE f s)}) /\\\n (!R. {l | R l} = IMAGE (MAP f) {l | R(MAP f l)}))`;;\n\nlet PARTIAL_EXPAND_QUANTS_CONV avoid th =\n let ath,sth = CONJ_PAIR th in\n let conv1 = GEN_REWRITE_CONV I [ath]\n and conv2 = GEN_REWRITE_CONV I [sth] in\n let conv1' tm =\n let th = conv1 tm in\n if mem (fst(dest_var(fst(dest_abs(rand tm))))) avoid\n then failwith \"Not going to expand this variable\" else th in\n let rec conv tm =\n ((conv1' THENC BINDER_CONV conv) ORELSEC\n (conv2 THENC\n RAND_CONV(RAND_CONV(ABS_CONV(BINDER_CONV(LAND_CONV conv))))) ORELSEC\n SUB_CONV conv) tm in\n conv;;\n\nlet EXPAND_QUANTS_CONV = PARTIAL_EXPAND_QUANTS_CONV [];;" }, { "theorem_id": 68, "title": "091_the_triangle_inequality", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Basic Properties of Triangles\\\ntheory Triangle\nimports\n Angles\nbegin\n\ntext \\\n We prove a number of basic geometric properties of triangles. All theorems hold\n in any real inner product space.\n\\\nsubsection \\Thales' theorem\\\n\ntheorem thales:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"dist B (midpoint A C) = dist A C / 2\"\n shows \"orthogonal (A - B) (C - B)\"\n by sorry\n\nsubsection \\Sine and cosine laws\\\n\ntext \\\n The proof of the Law of Cosines follows trivially from the definition of the angle,\n the definition of the norm in vector spaces with an inner product and the bilinearity\n of the inner product.\n\\\n\nlemma cosine_law_vector:\n \"norm (u - v) ^ 2 = norm u ^ 2 + norm v ^ 2 - 2 * norm u * norm v * cos (vangle u v)\"\n by sorry\n\nlemma cosine_law_triangle:\n \"dist b c ^ 2 = dist a b ^ 2 + dist a c ^ 2 - 2 * dist a b * dist a c * cos (angle b a c)\"\n by sorry\n\ntext \\\n According to our definition, angles are always between $0$ and $\\pi$ and therefore,\n the sign of an angle is always non-negative. We can therefore look at\n $\\sin(\\alpha)^2$, which we can express in terms of $\\cos(\\alpha)$ using the\n identity $\\sin(\\alpha)^2 + \\cos(\\alpha)^2 = 1$. The remaining proof is then a\n trivial consequence of the definitions.\n\\\nlemma sine_law_triangle:\n \"sin (angle a b c) * dist b c = sin (angle b a c) * dist a c\" (is \"?A = ?B\")\n by sorry\n\ntext \\\n The following forms of the Law of Sines/Cosines are more convenient for eliminating\n sines/cosines from a goal completely.\n\\\n\nlemma cosine_law_triangle':\n \"2 * dist a b * dist a c * cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2)\"\n by sorry\n\nlemma cosine_law_triangle'':\n \"cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2) / (2 * dist a b * dist a c)\"\n by sorry\n\nlemma sine_law_triangle':\n \"b \\ c \\ sin (angle a b c) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nlemma sine_law_triangle'':\n \"b \\ c \\ sin (angle c b a) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nsubsection \\Sum of angles\\\n\ncontext\nbegin\n\nprivate lemma gather_squares: \"a * (a * b) = a^2 * (b :: real)\"\n by (simp_all add: power2_eq_square)\n\nprivate lemma eval_power: \"x ^ numeral n = x * x ^ pred_numeral n\"\n by (subst numeral_eq_Suc, subst power_Suc) simp\n\ntext \\\n The proof that the sum of the angles in a triangle is $\\pi$ is somewhat more\n involved. Following the HOL Light proof by John Harrison, we first prove\n that $\\cos(\\alpha + \\beta + \\gamma) = -1$ and $\\alpha + \\beta + \\gamma \\in [0;3\\pi)$,\n which then implies the theorem.\n\n The main work is proving $\\cos(\\alpha + \\beta + \\gamma)$. This is done using the\n addition theorems for the sine and cosine, then using the Laws of Sines to eliminate\n all $\\sin$ terms save $\\sin(\\gamma)^2$, which only appears squared in the remaining goal.\n We then use $\\sin(\\gamma)^2 = 1 - \\cos(\\gamma)^2$ to eliminate this term and apply\n the law of cosines to eliminate this term as well.\n\n The remaining goal is a non-linear equation containing only the length of the sides\n of the triangle. It can be shown by simple algebraic rewriting.\n\\\nlemma angle_sum_triangle:\n assumes \"a \\ b \\ b \\ c \\ a \\ c\"\n shows \"angle c a b + angle a b c + angle b c a = pi\"\n by sorry\n\nend\n\nsubsection \\Congruence Theorems\\\n\ntext \\\n If two triangles agree on two angles at a non-degenerate side, the third angle\n must also be equal.\n\\\nlemma similar_triangle_aa:\n assumes \"b1 \\ c1\" \"b2 \\ c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n shows \"angle b1 a1 c1 = angle b2 a2 c2\"\n by sorry\n\ntext \\\n A triangle is defined by its three angles and the lengths of three sides up to congruence.\n Two triangles are congruent if they have their angles are the same and their sides have\n the same length.\n\\\n\nlocale congruent_triangle =\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes sides': \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n and angles': \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\"\n \"angle a1 c1 b1 = angle a2 c2 b2\"\nbegin\n\nlemma sides:\n \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n \"dist b1 a1 = dist a2 b2\" \"dist c1 a1 = dist a2 c2\" \"dist c1 b1 = dist b2 c2\"\n \"dist a1 b1 = dist b2 a2\" \"dist a1 c1 = dist c2 a2\" \"dist b1 c1 = dist c2 b2\"\n \"dist b1 a1 = dist b2 a2\" \"dist c1 a1 = dist c2 a2\" \"dist c1 b1 = dist c2 b2\"\n by sorry\n\nlemma angles:\n \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\" \"angle a1 c1 b1 = angle a2 c2 b2\"\n \"angle c1 a1 b1 = angle b2 a2 c2\" \"angle c1 b1 a1 = angle a2 b2 c2\" \"angle b1 c1 a1 = angle a2 c2 b2\"\n \"angle b1 a1 c1 = angle c2 a2 b2\" \"angle a1 b1 c1 = angle c2 b2 a2\" \"angle a1 c1 b1 = angle b2 c2 a2\"\n \"angle c1 a1 b1 = angle c2 a2 b2\" \"angle c1 b1 a1 = angle c2 b2 a2\" \"angle b1 c1 a1 = angle b2 c2 a2\"\n by sorry\n\nend\n\nlemmas congruent_triangleD = congruent_triangle.sides congruent_triangle.angles\n\ntext \\\n Given two triangles that agree on a subset of its side lengths and angles that are\n sufficient to define a triangle uniquely up to congruence, one can conclude that they\n must also agree on all remaining quantities, i.e. that they are congruent.\n\n The following four congruence theorems state what constitutes such a uniquely-defining\n subset of quantities. Each theorem states in its name which quantities are required and\n in which order (clockwise or counter-clockwise): an ``s'' stands for a side,\n an ``a'' stands for an angle.\n\n The lemma ``congruent-triangleI-sas, for example, requires that two adjacent sides and the\n angle inbetween are the same in both triangles.\n\\\n\nlemma congruent_triangleI_sss:\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"dist a1 c1 = dist a2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sss = congruent_triangleD[OF congruent_triangleI_sss]\n\nlemma congruent_triangleI_sas:\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sas = congruent_triangleD[OF congruent_triangleI_sas]\n\nlemma congruent_triangleI_aas:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"\\collinear {a1,b1,c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_aas = congruent_triangleD[OF congruent_triangleI_aas]\n\nlemma congruent_triangleI_asa:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"angle b1 a1 c1 = angle b2 a2 c2\"\n assumes \"\\collinear {a1, b1, c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_asa = congruent_triangleD[OF congruent_triangleI_asa]\n\nsubsection \\Isosceles Triangle Theorem\\\n\ntext \\\n We now prove the Isosceles Triangle Theorem: in a triangle where two sides have\n the same length, the two angles that are adjacent to only one of the two sides\n must be equal.\n\\\nlemma isosceles_triangle:\n assumes \"dist a c = dist b c\"\n shows \"angle b a c = angle a b c\"\n by sorry\n\ntext \\\n For the non-degenerate case (i.e. the three points are not collinear), We also\n prove the converse.\n\\\nlemma isosceles_triangle_converse:\n assumes \"angle a b c = angle b a c\" \"\\collinear {a,b,c}\"\n shows \"dist a c = dist b c\"\n by sorry\n\nsubsection\\Contributions by Lukas Bulwahn\\\n \nlemma Pythagoras:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"orthogonal (A - C) (B - C)\"\n shows \"(dist B C) ^ 2 + (dist C A) ^ 2 = (dist A B) ^ 2\"\n by sorry\n\nlemma isosceles_triangle_orthogonal_on_midpoint:\n fixes A B C :: \"'a :: euclidean_space\"\n assumes \"dist C A = dist C B\"\n shows \"orthogonal (C - midpoint A B) (A - midpoint A B)\"\n by sorry\n\nend" }, { "theorem_id": 68, "title": "091_the_triangle_inequality", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Johannes Hölzl, Yaël Dillies\n-/\nmodule\n\npublic import Mathlib.Analysis.Normed.Group.Defs\npublic import Mathlib.Data.NNReal.Basic\npublic import Mathlib.Topology.Algebra.Support\npublic import Mathlib.Topology.MetricSpace.Basic\n\n/-!\n# (Semi)normed groups: basic theory\n\nWe prove basic properties of (semi)normed groups.\n\n## Tags\n\nnormed group\n-/\n\n@[expose] public section\n\n\nvariable {𝓕 α ι κ E F G : Type*}\n\nopen Filter Function Metric Bornology\nopen ENNReal Filter NNReal Uniformity Pointwise Topology\n\nsection SeminormedGroup\n\nvariable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E}\n {a a₁ a₂ b c d : E} {r r₁ r₂ : ℝ}\n\n@[to_additive]\ntheorem dist_eq_norm_inv_mul (a b : E) : dist a b = ‖a⁻¹ * b‖ :=\n SeminormedGroup.dist_eq _ _\n\n@[to_additive]\ntheorem dist_eq_norm_inv_mul' (a b : E) : dist a b = ‖b⁻¹ * a‖ := by sorry\nlemma DiscreteTopology.of_forall_le_norm' (hpos : 0 < r) (hr : ∀ x : E, x ≠ 1 → r ≤ ‖x‖) :\n DiscreteTopology E :=\n .of_forall_le_dist hpos fun x y hne ↦ by\n simp only [dist_eq_norm_inv_mul]\n exact hr _ (by simpa [inv_mul_eq_one] using hne)\n\n@[to_additive (attr := simp)]\ntheorem dist_one_right (a : E) : dist a 1 = ‖a‖ := by rw [dist_eq_norm_inv_mul', inv_one, one_mul]\n\n@[to_additive]\ntheorem inseparable_one_iff_norm {a : E} : Inseparable a 1 ↔ ‖a‖ = 0 := by sorry\nlemma dist_one_left (a : E) : dist 1 a = ‖a‖ := by rw [dist_comm, dist_one_right]\n\n@[to_additive (attr := simp)]\nlemma dist_one : dist (1 : E) = norm := funext dist_one_left\n\n@[to_additive]\ntheorem norm_div_rev (a b : E) : ‖a / b‖ = ‖b / a‖ := by sorry\ntheorem norm_inv' (a : E) : ‖a⁻¹‖ = ‖a‖ := by simpa using norm_div_rev 1 a\n\n@[to_additive (attr := simp) norm_abs_zsmul]\ntheorem norm_zpow_abs (a : E) (n : ℤ) : ‖a ^ |n|‖ = ‖a ^ n‖ := by sorry\ntheorem norm_pow_natAbs (a : E) (n : ℤ) : ‖a ^ n.natAbs‖ = ‖a ^ n‖ := by sorry\ntheorem norm_zpow_isUnit (a : E) {n : ℤ} (hn : IsUnit n) : ‖a ^ n‖ = ‖a‖ := by sorry\ntheorem norm_units_zsmul {E : Type*} [SeminormedAddGroup E] (n : ℤˣ) (a : E) : ‖n • a‖ = ‖a‖ :=\n norm_isUnit_zsmul a n.isUnit\n\nopen scoped symmDiff in\n@[to_additive]\ntheorem dist_mulIndicator (s t : Set α) (f : α → E) (x : α) :\n dist (s.mulIndicator f x) (t.mulIndicator f x) = ‖(s ∆ t).mulIndicator f x‖ := by sorry\ntheorem norm_mul_le' (a b : E) : ‖a * b‖ ≤ ‖a‖ + ‖b‖ := by sorry\ntheorem norm_mul_le_of_le' (h₁ : ‖a₁‖ ≤ r₁) (h₂ : ‖a₂‖ ≤ r₂) : ‖a₁ * a₂‖ ≤ r₁ + r₂ :=\n (norm_mul_le' a₁ a₂).trans <| add_le_add h₁ h₂\n\n/-- **Triangle inequality** for the norm. -/\n@[to_additive norm_add₃_le /-- **Triangle inequality** for the norm. -/]\nlemma norm_mul₃_le' : ‖a * b * c‖ ≤ ‖a‖ + ‖b‖ + ‖c‖ := norm_mul_le_of_le' (norm_mul_le' _ _) le_rfl\n\n/-- **Triangle inequality** for the norm. -/\n@[to_additive norm_add₄_le /-- **Triangle inequality** for the norm. -/]\nlemma norm_mul₄_le' : ‖a * b * c * d‖ ≤ ‖a‖ + ‖b‖ + ‖c‖ + ‖d‖ :=\n norm_mul_le_of_le' norm_mul₃_le' le_rfl\n\n@[to_additive]\nlemma norm_div_le_norm_div_add_norm_div (a b c : E) : ‖a / c‖ ≤ ‖a / b‖ + ‖b / c‖ := by sorry\nlemma norm_le_norm_div_add (a b : E) : ‖a‖ ≤ ‖a / b‖ + ‖b‖ := by sorry\ntheorem norm_nonneg' (a : E) : 0 ≤ ‖a‖ := by sorry\ntheorem abs_norm' (z : E) : |‖z‖| = ‖z‖ := abs_of_nonneg <| norm_nonneg' _\n\n@[to_additive (attr := simp) norm_zero]\ntheorem norm_one' : ‖(1 : E)‖ = 0 := by rw [← dist_one_right, dist_self]\n\n@[to_additive]\ntheorem ne_one_of_norm_ne_zero : ‖a‖ ≠ 0 → a ≠ 1 :=\n mt <| by\n rintro rfl\n exact norm_one'\n\n@[to_additive (attr := nontriviality) norm_of_subsingleton]\ntheorem norm_of_subsingleton' [Subsingleton E] (a : E) : ‖a‖ = 0 := by sorry\ntheorem zero_lt_one_add_norm_sq' (x : E) : 0 < 1 + ‖x‖ ^ 2 := by sorry\ntheorem norm_div_le (a b : E) : ‖a / b‖ ≤ ‖a‖ + ‖b‖ := by sorry\ntheorem norm_div_le_of_le {r₁ r₂ : ℝ} (H₁ : ‖a₁‖ ≤ r₁) (H₂ : ‖a₂‖ ≤ r₂) : ‖a₁ / a₂‖ ≤ r₁ + r₂ :=\n (norm_div_le a₁ a₂).trans <| add_le_add H₁ H₂\n\n@[to_additive dist_le_norm_add_norm]\ntheorem dist_le_norm_add_norm' (a b : E) : dist a b ≤ ‖a‖ + ‖b‖ := by sorry\ntheorem abs_norm_sub_norm_le_norm_inv_mul (a b : E) : |‖a‖ - ‖b‖| ≤ ‖a⁻¹ * b‖ := by sorry\ntheorem norm_sub_norm_le_norm_inv_mul (a b : E) : ‖a‖ - ‖b‖ ≤ ‖a⁻¹ * b‖ :=\n (le_abs_self _).trans (abs_norm_sub_norm_le_norm_inv_mul a b)\n\n@[to_additive (attr := bound)]\ntheorem norm_sub_le_norm_mul (a b : E) : ‖a‖ - ‖b‖ ≤ ‖a * b‖ := by sorry\ntheorem dist_norm_norm_le_norm_inv_mul (a b : E) : dist ‖a‖ ‖b‖ ≤ ‖a⁻¹ * b‖ :=\n abs_norm_sub_norm_le_norm_inv_mul a b\n\n@[to_additive]\ntheorem norm_le_norm_add_norm_div' (u v : E) : ‖u‖ ≤ ‖v‖ + ‖u / v‖ := by sorry\ntheorem norm_le_norm_add_norm_inv_mul (u v : E) : ‖u‖ ≤ ‖v‖ + ‖u⁻¹ * v‖ := by sorry\ntheorem norm_le_norm_add_norm_div (u v : E) : ‖v‖ ≤ ‖u‖ + ‖u / v‖ := by sorry\ntheorem norm_le_mul_norm_add (u v : E) : ‖u‖ ≤ ‖u * v‖ + ‖v‖ :=\n calc\n ‖u‖ = ‖u * v / v‖ := by rw [mul_div_cancel_right]\n _ ≤ ‖u * v‖ + ‖v‖ := norm_div_le _ _\n\n/-- An analogue of `norm_le_mul_norm_add` for the multiplication from the left. -/\n@[to_additive /-- An analogue of `norm_le_add_norm_add` for the addition from the left. -/]\ntheorem norm_le_mul_norm_add' (u v : E) : ‖v‖ ≤ ‖u * v‖ + ‖u‖ :=\n calc\n ‖v‖ = ‖u⁻¹ * (u * v)‖ := by rw [← mul_assoc, inv_mul_cancel, one_mul]\n _ ≤ ‖u⁻¹‖ + ‖u * v‖ := norm_mul_le' u⁻¹ (u * v)\n _ = ‖u * v‖ + ‖u‖ := by rw [norm_inv', add_comm]\n\n@[to_additive]\nlemma norm_mul_eq_norm_right {x : E} (y : E) (h : ‖x‖ = 0) : ‖x * y‖ = ‖y‖ := by sorry\nlemma norm_mul_eq_norm_left (x : E) {y : E} (h : ‖y‖ = 0) : ‖x * y‖ = ‖x‖ := by sorry\nlemma norm_div_eq_norm_right {x : E} (y : E) (h : ‖x‖ = 0) : ‖x / y‖ = ‖y‖ := by sorry\nlemma norm_div_eq_norm_left (x : E) {y : E} (h : ‖y‖ = 0) : ‖x / y‖ = ‖x‖ := by sorry\ntheorem ball_eq_norm_inv_mul_lt (y : E) (ε : ℝ) : ball y ε = { x | ‖x⁻¹ * y‖ < ε } :=\n Set.ext fun a => by simp [dist_eq_norm_inv_mul]\n\n@[to_additive]\ntheorem ball_one_eq (r : ℝ) : ball (1 : E) r = { x | ‖x‖ < r } :=\n Set.ext fun a => by simp\n\n@[to_additive]\ntheorem mem_ball_iff_norm_inv_mul_lt : b ∈ ball a r ↔ ‖b⁻¹ * a‖ < r := by sorry\ntheorem mem_ball_iff_norm_inv_mul_lt' : b ∈ ball a r ↔ ‖a⁻¹ * b‖ < r := by sorry\ntheorem mem_ball_one_iff : a ∈ ball (1 : E) r ↔ ‖a‖ < r := by rw [mem_ball, dist_one_right]\n\n@[to_additive]\ntheorem mem_closedBall_iff_norm_inv_mul_le : b ∈ closedBall a r ↔ ‖b⁻¹ * a‖ ≤ r := by sorry\ntheorem mem_closedBall_one_iff : a ∈ closedBall (1 : E) r ↔ ‖a‖ ≤ r := by sorry\ntheorem mem_closedBall_iff_norm_inv_mul_le' : b ∈ closedBall a r ↔ ‖a⁻¹ * b‖ ≤ r := by sorry\ntheorem norm_le_of_mem_closedBall' (h : b ∈ closedBall a r) : ‖b‖ ≤ ‖a‖ + r :=\n (norm_le_norm_add_norm_inv_mul b a).trans (by simp [mem_closedBall_iff_norm_inv_mul_le.1 h])\n\n@[to_additive norm_le_norm_add_const_of_dist_le]\ntheorem norm_le_norm_add_const_of_dist_le' : dist a b ≤ r → ‖a‖ ≤ ‖b‖ + r :=\n norm_le_of_mem_closedBall'\n\n@[to_additive norm_lt_of_mem_ball]\ntheorem norm_lt_of_mem_ball' (h : b ∈ ball a r) : ‖b‖ < ‖a‖ + r :=\n (norm_le_norm_add_norm_inv_mul b a).trans_lt (by simp [mem_ball_iff_norm_inv_mul_lt.1 h])\n\n@[to_additive]\ntheorem norm_div_sub_norm_div_le_norm_div (u v w : E) : ‖u / w‖ - ‖v / w‖ ≤ ‖u / v‖ := by sorry\nlemma norm_mul_sub_norm_div_le_two_mul {E : Type*} [SeminormedGroup E] (u v : E) :\n ‖u * v‖ - ‖u / v‖ ≤ 2 * ‖v‖ := by sorry\nlemma norm_mul_sub_norm_div_le_two_mul_min {E : Type*} [SeminormedCommGroup E] (u v : E) :\n ‖u * v‖ - ‖u / v‖ ≤ 2 * min ‖u‖ ‖v‖ := by sorry\ntheorem mem_sphere_iff_norm_inv_mul_eq : b ∈ sphere a r ↔ ‖b⁻¹ * a‖ = r := by sorry\ntheorem mem_sphere_one_iff_norm : a ∈ sphere (1 : E) r ↔ ‖a‖ = r := by simp\n\n@[to_additive (attr := simp) norm_eq_of_mem_sphere]\ntheorem norm_eq_of_mem_sphere' (x : sphere (1 : E) r) : ‖(x : E)‖ = r :=\n mem_sphere_one_iff_norm.mp x.2\n\n@[to_additive]\ntheorem ne_one_of_mem_sphere (hr : r ≠ 0) (x : sphere (1 : E) r) : (x : E) ≠ 1 :=\n ne_one_of_norm_ne_zero <| by rwa [norm_eq_of_mem_sphere' x]\n\n@[to_additive ne_zero_of_mem_unit_sphere]\ntheorem ne_one_of_mem_unit_sphere (x : sphere (1 : E) 1) : (x : E) ≠ 1 :=\n ne_one_of_mem_sphere one_ne_zero _\n\nvariable (E)\n\n/-- The norm of a seminormed group as a group seminorm. -/\n@[to_additive /-- The norm of a seminormed group as an additive group seminorm. -/]\ndef normGroupSeminorm : GroupSeminorm E :=\n ⟨norm, norm_one', norm_mul_le', norm_inv'⟩\n\n@[to_additive (attr := simp)]\ntheorem coe_normGroupSeminorm : ⇑(normGroupSeminorm E) = norm :=\n rfl\n\nvariable {E}\n\n@[to_additive]\ntheorem NormedGroup.tendsto_nhds_one {f : α → E} {l : Filter α} :\n Tendsto f l (𝓝 1) ↔ ∀ ε > 0, ∀ᶠ x in l, ‖f x‖ < ε :=\n Metric.tendsto_nhds.trans <| by simp only [dist_one_right]\n\n@[deprecated (since := \"2026-02-17\")]\nalias NormedCommGroup.tendsto_nhds_one := NormedGroup.tendsto_nhds_one\n\n@[deprecated (since := \"2026-02-17\")]\nalias NormedAddCommGroup.tendsto_nhds_zero := NormedAddGroup.tendsto_nhds_zero\n\n@[to_additive]\ntheorem NormedGroup.tendsto_nhds_nhds {f : E → F} {x : E} {y : F} :\n Tendsto f (𝓝 x) (𝓝 y) ↔ ∀ ε > 0, ∃ δ > 0, ∀ x', ‖x'⁻¹ * x‖ < δ → ‖(f x')⁻¹ * y‖ < ε := by sorry\ntheorem NormedGroup.nhds_basis_norm_lt (x : E) :\n (𝓝 x).HasBasis (fun ε : ℝ => 0 < ε) fun ε => { y | ‖y⁻¹ * x‖ < ε } := by sorry\ntheorem NormedGroup.nhds_one_basis_norm_lt :\n (𝓝 (1 : E)).HasBasis (fun ε : ℝ => 0 < ε) fun ε => { y | ‖y‖ < ε } := by sorry\ntheorem NormedGroup.uniformity_basis_dist :\n (𝓤 E).HasBasis (fun ε : ℝ => 0 < ε) fun ε => { p : E × E | ‖p.fst⁻¹ * p.snd‖ < ε } := by sorry\nopen Finset\n\nvariable [FunLike 𝓕 E F]\n\nsection NNNorm\n\n-- See note [lower instance priority]\n@[to_additive]\ninstance (priority := 100) SeminormedGroup.toNNNorm : NNNorm E :=\n ⟨fun a => .mk ‖a‖ (norm_nonneg' a)⟩\n\n@[to_additive (attr := simp, norm_cast) coe_nnnorm]\ntheorem coe_nnnorm' (a : E) : (‖a‖₊ : ℝ) = ‖a‖ := rfl\n\n@[to_additive (attr := simp) coe_comp_nnnorm]\ntheorem coe_comp_nnnorm' : (toReal : ℝ≥0 → ℝ) ∘ (nnnorm : E → ℝ≥0) = norm :=\n rfl\n\n@[to_additive (attr := simp) norm_toNNReal]\ntheorem norm_toNNReal' : ‖a‖.toNNReal = ‖a‖₊ :=\n @Real.toNNReal_coe ‖a‖₊\n\n@[to_additive (attr := simp) toReal_enorm]\nlemma toReal_enorm' (x : E) : ‖x‖ₑ.toReal = ‖x‖ := by simp [enorm]\n\n@[to_additive (attr := simp) ofReal_norm]\nlemma ofReal_norm' (x : E) : .ofReal ‖x‖ = ‖x‖ₑ := by sorry\ntheorem enorm'_eq_iff_norm_eq {x : E} {y : F} : ‖x‖ₑ = ‖y‖ₑ ↔ ‖x‖ = ‖y‖ := by sorry\ntheorem enorm'_le_iff_norm_le {x : E} {y : F} : ‖x‖ₑ ≤ ‖y‖ₑ ↔ ‖x‖ ≤ ‖y‖ := by sorry\ntheorem nndist_eq_nnnorm_inv_mul (a b : E) : nndist a b = ‖a⁻¹ * b‖₊ :=\n NNReal.eq <| dist_eq_norm_inv_mul _ _\n\n@[to_additive (attr := simp) nnnorm_neg]\ntheorem nnnorm_inv' (a : E) : ‖a⁻¹‖₊ = ‖a‖₊ :=\n NNReal.eq <| norm_inv' a\n\n@[to_additive (attr := simp)]\ntheorem nndist_one_right (a : E) : nndist a 1 = ‖a‖₊ := by sorry\nlemma edist_one_right (a : E) : edist a 1 = ‖a‖ₑ := by simp [edist_nndist, nndist_one_right, enorm]\n\n@[to_additive (attr := simp) nnnorm_zero]\ntheorem nnnorm_one' : ‖(1 : E)‖₊ = 0 := NNReal.eq norm_one'\n\n@[to_additive]\ntheorem ne_one_of_nnnorm_ne_zero {a : E} : ‖a‖₊ ≠ 0 → a ≠ 1 :=\n mt <| by\n rintro rfl\n exact nnnorm_one'\n\n@[to_additive nnnorm_add_le]\ntheorem nnnorm_mul_le' (a b : E) : ‖a * b‖₊ ≤ ‖a‖₊ + ‖b‖₊ :=\n NNReal.coe_le_coe.1 <| norm_mul_le' a b\n\n@[to_additive norm_nsmul_le]\nlemma norm_pow_le_mul_norm : ∀ {n : ℕ}, ‖a ^ n‖ ≤ n * ‖a‖ := by sorry\nlemma nnnorm_pow_le_mul_norm {n : ℕ} : ‖a ^ n‖₊ ≤ n * ‖a‖₊ := by sorry\ntheorem nnnorm_zpow_abs (a : E) (n : ℤ) : ‖a ^ |n|‖₊ = ‖a ^ n‖₊ :=\n NNReal.eq <| norm_zpow_abs a n\n\n@[to_additive (attr := simp) nnnorm_natAbs_smul]\ntheorem nnnorm_pow_natAbs (a : E) (n : ℤ) : ‖a ^ n.natAbs‖₊ = ‖a ^ n‖₊ :=\n NNReal.eq <| norm_pow_natAbs a n\n\n@[to_additive nnnorm_isUnit_zsmul]\ntheorem nnnorm_zpow_isUnit (a : E) {n : ℤ} (hn : IsUnit n) : ‖a ^ n‖₊ = ‖a‖₊ :=\n NNReal.eq <| norm_zpow_isUnit a hn\n\n@[simp]\ntheorem nnnorm_units_zsmul {E : Type*} [SeminormedAddGroup E] (n : ℤˣ) (a : E) : ‖n • a‖₊ = ‖a‖₊ :=\n NNReal.eq <| norm_isUnit_zsmul a n.isUnit\n\n@[to_additive (attr := simp)]\ntheorem nndist_one_left (a : E) : nndist 1 a = ‖a‖₊ := by simp [nndist_eq_nnnorm_inv_mul]\n\n@[to_additive (attr := simp)]\ntheorem edist_one_left (a : E) : edist 1 a = ‖a‖₊ := by sorry\nopen scoped symmDiff in\n@[to_additive]\ntheorem nndist_mulIndicator (s t : Set α) (f : α → E) (x : α) :\n nndist (s.mulIndicator f x) (t.mulIndicator f x) = ‖(s ∆ t).mulIndicator f x‖₊ :=\n NNReal.eq <| dist_mulIndicator s t f x\n\n@[to_additive]\ntheorem nnnorm_div_le (a b : E) : ‖a / b‖₊ ≤ ‖a‖₊ + ‖b‖₊ :=\n NNReal.coe_le_coe.1 <| norm_div_le _ _\n\n@[to_additive]\nlemma enorm_div_le : ‖a / b‖ₑ ≤ ‖a‖ₑ + ‖b‖ₑ := by sorry\ntheorem nndist_nnnorm_nnnorm_le_nnnorm_inv_mul (a b : E) : nndist ‖a‖₊ ‖b‖₊ ≤ ‖a⁻¹ * b‖₊ :=\n NNReal.coe_le_coe.1 <| dist_norm_norm_le_norm_inv_mul a b\n\n@[to_additive]\ntheorem nnnorm_le_nnnorm_add_nnnorm_div (a b : E) : ‖b‖₊ ≤ ‖a‖₊ + ‖a / b‖₊ :=\n norm_le_norm_add_norm_div _ _\n\n@[to_additive]\ntheorem nnnorm_le_nnnorm_add_nnnorm_div' (a b : E) : ‖a‖₊ ≤ ‖b‖₊ + ‖a / b‖₊ :=\n norm_le_norm_add_norm_div' _ _\n\nalias nnnorm_le_insert' := nnnorm_le_nnnorm_add_nnnorm_sub'\n\nalias nnnorm_le_insert := nnnorm_le_nnnorm_add_nnnorm_sub\n\n@[to_additive]\ntheorem nnnorm_le_mul_nnnorm_add (a b : E) : ‖a‖₊ ≤ ‖a * b‖₊ + ‖b‖₊ :=\n norm_le_mul_norm_add _ _\n\n/-- An analogue of `nnnorm_le_mul_nnnorm_add` for the multiplication from the left. -/\n@[to_additive /-- An analogue of `nnnorm_le_add_nnnorm_add` for the addition from the left. -/]\ntheorem nnnorm_le_mul_nnnorm_add' (a b : E) : ‖b‖₊ ≤ ‖a * b‖₊ + ‖a‖₊ :=\n norm_le_mul_norm_add' _ _\n\n@[to_additive]\nlemma nnnorm_mul_eq_nnnorm_right {x : E} (y : E) (h : ‖x‖₊ = 0) : ‖x * y‖₊ = ‖y‖₊ :=\n NNReal.eq <| norm_mul_eq_norm_right _ <| congr_arg NNReal.toReal h\n\n@[to_additive]\nlemma nnnorm_mul_eq_nnnorm_left (x : E) {y : E} (h : ‖y‖₊ = 0) : ‖x * y‖₊ = ‖x‖₊ :=\n NNReal.eq <| norm_mul_eq_norm_left _ <| congr_arg NNReal.toReal h\n\n@[to_additive]\nlemma nnnorm_div_eq_nnnorm_right {x : E} (y : E) (h : ‖x‖₊ = 0) : ‖x / y‖₊ = ‖y‖₊ :=\n NNReal.eq <| norm_div_eq_norm_right _ <| congr_arg NNReal.toReal h\n\n@[to_additive]\nlemma nnnorm_div_eq_nnnorm_left (x : E) {y : E} (h : ‖y‖₊ = 0) : ‖x / y‖₊ = ‖x‖₊ :=\n NNReal.eq <| norm_div_eq_norm_left _ <| congr_arg NNReal.toReal h\n\n/-- The nonnegative norm seen as an `ENNReal` and then as a `Real` is equal to the norm. -/\n@[to_additive toReal_coe_nnnorm /-- The nonnegative norm seen as an `ENNReal` and\nthen as a `Real` is equal to the norm. -/]\ntheorem toReal_coe_nnnorm' (a : E) : (‖a‖₊ : ℝ≥0∞).toReal = ‖a‖ := rfl\n\nopen scoped symmDiff in\n@[to_additive]\ntheorem edist_mulIndicator (s t : Set α) (f : α → E) (x : α) :\n edist (s.mulIndicator f x) (t.mulIndicator f x) = ‖(s ∆ t).mulIndicator f x‖₊ := by sorry\ntheorem nontrivialTopology_iff_exists_nnnorm_ne_zero' :\n NontrivialTopology E ↔ ∃ x : E, ‖x‖₊ ≠ 0 := by sorry\ntheorem indiscreteTopology_iff_forall_nnnorm_eq_zero' :\n IndiscreteTopology E ↔ ∀ x : E, ‖x‖₊ = 0 := by sorry\nvariable (E) in\n@[to_additive exists_nnnorm_ne_zero]\ntheorem exists_nnnorm_ne_zero' [NontrivialTopology E] : ∃ x : E, ‖x‖₊ ≠ 0 :=\n nontrivialTopology_iff_exists_nnnorm_ne_zero'.1 ‹_›\n\n@[to_additive (attr := nontriviality) nnnorm_eq_zero]\ntheorem IndiscreteTopology.nnnorm_eq_zero' [IndiscreteTopology E] : ∀ x : E, ‖x‖₊ = 0 :=\n indiscreteTopology_iff_forall_nnnorm_eq_zero'.1 ‹_›\n\nalias ⟨_, NontrivialTopology.of_exists_nnnorm_ne_zero'⟩ :=\n nontrivialTopology_iff_exists_nnnorm_ne_zero'\nalias ⟨_, NontrivialTopology.of_exists_nnnorm_ne_zero⟩ :=\n nontrivialTopology_iff_exists_nnnorm_ne_zero\nattribute [to_additive existing NontrivialTopology.of_exists_nnnorm_ne_zero]\n NontrivialTopology.of_exists_nnnorm_ne_zero'\n\nalias ⟨_, IndiscreteTopology.of_forall_nnnorm_eq_zero'⟩ :=\n indiscreteTopology_iff_forall_nnnorm_eq_zero'\nalias ⟨_, IndiscreteTopology.of_forall_nnnorm_eq_zero⟩ :=\n indiscreteTopology_iff_forall_nnnorm_eq_zero\nattribute [to_additive existing IndiscreteTopology.of_forall_nnnorm_eq_zero]\n IndiscreteTopology.of_forall_nnnorm_eq_zero'\n\n@[to_additive nontrivialTopology_iff_exists_norm_ne_zero]\ntheorem nontrivialTopology_iff_exists_norm_ne_zero' :\n NontrivialTopology E ↔ ∃ x : E, ‖x‖ ≠ 0 := by sorry\ntheorem indiscreteTopology_iff_forall_norm_eq_zero' :\n IndiscreteTopology E ↔ ∀ x : E, ‖x‖ = 0 := by sorry\nvariable (E) in\n@[to_additive exists_norm_ne_zero]\ntheorem exists_norm_ne_zero' [NontrivialTopology E] : ∃ x : E, ‖x‖ ≠ 0 :=\n nontrivialTopology_iff_exists_norm_ne_zero'.1 ‹_›\n\n@[to_additive (attr := nontriviality) IndiscreteTopology.norm_eq_zero]\ntheorem IndiscreteTopology.norm_eq_zero' [IndiscreteTopology E] : ∀ x : E, ‖x‖ = 0 :=\n indiscreteTopology_iff_forall_norm_eq_zero'.1 ‹_›\n\nalias ⟨_, NontrivialTopology.of_exists_norm_ne_zero'⟩ :=\n nontrivialTopology_iff_exists_norm_ne_zero'\nalias ⟨_, NontrivialTopology.of_exists_norm_ne_zero⟩ :=\n nontrivialTopology_iff_exists_norm_ne_zero\nattribute [to_additive existing NontrivialTopology.of_exists_norm_ne_zero]\n NontrivialTopology.of_exists_norm_ne_zero'\n\nalias ⟨_, IndiscreteTopology.of_forall_norm_eq_zero'⟩ :=\n indiscreteTopology_iff_forall_norm_eq_zero'\nalias ⟨_, IndiscreteTopology.of_forall_norm_eq_zero⟩ :=\n indiscreteTopology_iff_forall_norm_eq_zero\nattribute [to_additive existing IndiscreteTopology.of_forall_norm_eq_zero]\n IndiscreteTopology.of_forall_norm_eq_zero'\n\nend NNNorm\n\nsection ENorm\n\n@[to_additive (attr := simp) enorm_zero]\nlemma enorm_one' {E : Type*} [TopologicalSpace E] [ESeminormedMonoid E] : ‖(1 : E)‖ₑ = 0 := by sorry\nlemma exists_enorm_lt' (E : Type*) [TopologicalSpace E] [ESeminormedMonoid E]\n [hbot : NeBot (𝓝[≠] (1 : E))] {c : ℝ≥0∞} (hc : c ≠ 0) : ∃ x ≠ (1 : E), ‖x‖ₑ < c :=\n frequently_iff_neBot.mpr hbot |>.and_eventually\n (ContinuousENorm.continuous_enorm.tendsto' 1 0 (by simp) |>.eventually_lt_const hc.bot_lt) := by sorry\nlemma enorm_inv' (a : E) : ‖a⁻¹‖ₑ = ‖a‖ₑ := by simp [enorm]\n\n@[to_additive ofReal_norm_eq_enorm]\nlemma ofReal_norm_eq_enorm' (a : E) : .ofReal ‖a‖ = ‖a‖ₑ := ENNReal.ofReal_eq_coe_nnreal _\n\n@[to_additive]\ntheorem edist_eq_enorm_inv_mul (a b : E) : edist a b = ‖a⁻¹ * b‖ₑ := by sorry\nlemma enorm_div_rev {E : Type*} [SeminormedGroup E] (a b : E) : ‖a / b‖ₑ = ‖b / a‖ₑ := by sorry\ntheorem mem_eball_one_iff {r : ℝ≥0∞} : a ∈ eball 1 r ↔ ‖a‖ₑ < r := by sorry\nend ENorm\n\nsection ESeminormedMonoid\n\nvariable {E : Type*} [TopologicalSpace E] [ESeminormedMonoid E]\n\n@[to_additive enorm_add_le]\nlemma enorm_mul_le' (a b : E) : ‖a * b‖ₑ ≤ ‖a‖ₑ + ‖b‖ₑ := ESeminormedMonoid.enorm_mul_le a b\n\n@[to_additive enorm_add_le_of_le]\ntheorem enorm_mul_le_of_le' {r₁ r₂ : ℝ≥0∞} {a₁ a₂ : E}\n (h₁ : ‖a₁‖ₑ ≤ r₁) (h₂ : ‖a₂‖ₑ ≤ r₂) : ‖a₁ * a₂‖ₑ ≤ r₁ + r₂ :=\n (enorm_mul_le' a₁ a₂).trans <| add_le_add h₁ h₂\n\n@[to_additive enorm_add₃_le]\nlemma enorm_mul₃_le' {a b c : E} : ‖a * b * c‖ₑ ≤ ‖a‖ₑ + ‖b‖ₑ + ‖c‖ₑ :=\n enorm_mul_le_of_le' (enorm_mul_le' _ _) le_rfl\n\n@[to_additive enorm_add₄_le]\nlemma enorm_mul₄_le' {a b c d : E} : ‖a * b * c * d‖ₑ ≤ ‖a‖ₑ + ‖b‖ₑ + ‖c‖ₑ + ‖d‖ₑ :=\n enorm_mul_le_of_le' enorm_mul₃_le' le_rfl\n\nend ESeminormedMonoid\n\nsection ENormedMonoid\n\nvariable {E : Type*} [TopologicalSpace E] [ENormedMonoid E]\n\n@[to_additive (attr := simp) enorm_eq_zero]\nlemma enorm_eq_zero' {a : E} : ‖a‖ₑ = 0 ↔ a = 1 := by sorry\nlemma enorm_ne_zero' {a : E} : ‖a‖ₑ ≠ 0 ↔ a ≠ 1 :=\n enorm_eq_zero'.ne\n\n@[to_additive (attr := simp) enorm_pos]\nlemma enorm_pos' {a : E} : 0 < ‖a‖ₑ ↔ a ≠ 1 :=\n pos_iff_ne_zero.trans enorm_ne_zero'\n\nend ENormedMonoid\n\nopen Set in\n@[to_additive]\nlemma SeminormedGroup.disjoint_nhds (x : E) (f : Filter E) :\n Disjoint (𝓝 x) f ↔ ∃ δ > 0, ∀ᶠ y in f, δ ≤ ‖y⁻¹ * x‖ := by sorry\nlemma SeminormedGroup.disjoint_nhds_one (f : Filter E) :\n Disjoint (𝓝 1) f ↔ ∃ δ > 0, ∀ᶠ y in f, δ ≤ ‖y‖ := by sorry\nend SeminormedGroup\n\nsection Induced\n\nvariable (E F)\nvariable [FunLike 𝓕 E F]\n\n-- See note [reducible non-instances]\n/-- A group homomorphism from a `Group` to a `SeminormedGroup` induces a `SeminormedGroup`\nstructure on the domain. -/\n@[to_additive /-- A group homomorphism from an `AddGroup` to a\n`SeminormedAddGroup` induces a `SeminormedAddGroup` structure on the domain. -/]\nabbrev SeminormedGroup.induced [Group E] [SeminormedGroup F] [MonoidHomClass 𝓕 E F] (f : 𝓕) :\n SeminormedGroup E :=\n { PseudoMetricSpace.induced f toPseudoMetricSpace with\n norm := fun x => ‖f x‖\n dist_eq := fun x y => by simp only [map_mul, map_inv, ← dist_eq_norm_inv_mul]; rfl }\n\n-- See note [reducible non-instances]\n/-- A group homomorphism from a `CommGroup` to a `SeminormedGroup` induces a\n`SeminormedCommGroup` structure on the domain. -/\n@[to_additive /-- A group homomorphism from an `AddCommGroup` to a\n`SeminormedAddGroup` induces a `SeminormedAddCommGroup` structure on the domain. -/]\nabbrev SeminormedCommGroup.induced\n [CommGroup E] [SeminormedGroup F] [MonoidHomClass 𝓕 E F] (f : 𝓕) :\n SeminormedCommGroup E :=\n { SeminormedGroup.induced E F f with\n mul_comm := mul_comm }\n\n-- See note [reducible non-instances].\n/-- An injective group homomorphism from a `Group` to a `NormedGroup` induces a `NormedGroup`\nstructure on the domain. -/\n@[to_additive /-- An injective group homomorphism from an `AddGroup` to a\n`NormedAddGroup` induces a `NormedAddGroup` structure on the domain. -/]\nabbrev NormedGroup.induced\n [Group E] [NormedGroup F] [MonoidHomClass 𝓕 E F] (f : 𝓕) (h : Injective f) :\n NormedGroup E :=\n { SeminormedGroup.induced E F f, MetricSpace.induced f h _ with }\n\n-- See note [reducible non-instances].\n/-- An injective group homomorphism from a `CommGroup` to a `NormedGroup` induces a\n`NormedCommGroup` structure on the domain. -/\n@[to_additive /-- An injective group homomorphism from a `CommGroup` to a\n`NormedCommGroup` induces a `NormedCommGroup` structure on the domain. -/]\nabbrev NormedCommGroup.induced [CommGroup E] [NormedGroup F] [MonoidHomClass 𝓕 E F] (f : 𝓕)\n (h : Injective f) : NormedCommGroup E :=\n { SeminormedGroup.induced E F f, MetricSpace.induced f h _ with\n mul_comm := mul_comm }\n\nend Induced\n\nsection SeminormedCommGroup\n\nvariable [SeminormedCommGroup E] [SeminormedCommGroup F] {a b : E} {r : ℝ}\nvariable {ε : Type*} [TopologicalSpace ε] [ESeminormedCommMonoid ε]\n\n@[to_additive]\ntheorem dist_eq_norm_div (a b : E) : dist a b = ‖a / b‖ := by sorry\ntheorem dist_eq_norm_div' (a b : E) : dist a b = ‖b / a‖ := by sorry\ntheorem norm_inv_mul (a b : E) : ‖a⁻¹ * b‖ = ‖a / b‖ := by sorry\ntheorem abs_norm_sub_norm_le' (a b : E) : |‖a‖ - ‖b‖| ≤ ‖a / b‖ :=\n (abs_norm_sub_norm_le_norm_inv_mul a b).trans_eq (norm_inv_mul a b)\n\n@[to_additive norm_sub_norm_le]\ntheorem norm_sub_norm_le' (a b : E) : ‖a‖ - ‖b‖ ≤ ‖a / b‖ :=\n (le_abs_self _).trans (abs_norm_sub_norm_le' a b)\n\n@[to_additive dist_norm_norm_le]\ntheorem dist_norm_norm_le' (a b : E) : dist ‖a‖ ‖b‖ ≤ ‖a / b‖ :=\n abs_norm_sub_norm_le' a b\n\n@[to_additive nndist_nnnorm_nnnorm_le]\ntheorem nndist_nnnorm_nnnorm_le' (a b : E) : nndist ‖a‖₊ ‖b‖₊ ≤ ‖a / b‖₊ :=\n NNReal.coe_le_coe.1 <| dist_norm_norm_le' a b\n\n@[to_additive]\ntheorem nndist_eq_nnnorm_div (a b : E) : nndist a b = ‖a / b‖₊ :=\n NNReal.eq <| dist_eq_norm_div _ _\n\nalias nndist_eq_nnnorm := nndist_eq_nnnorm_sub\n\n@[to_additive]\ntheorem edist_eq_enorm_div (a b : E) : edist a b = ‖a / b‖ₑ := by sorry\ntheorem dist_inv (x y : E) : dist x⁻¹ y = dist x y⁻¹ := by sorry\ntheorem norm_multiset_sum_le {E} [SeminormedAddCommGroup E] (m : Multiset E) :\n ‖m.sum‖ ≤ (m.map fun x => ‖x‖).sum :=\n m.le_sum_of_subadditive norm norm_zero.le norm_add_le\n\nvariable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddCommMonoid ε] in\ntheorem enorm_multisetSum_le (m : Multiset ε) :\n ‖m.sum‖ₑ ≤ (m.map fun x => ‖x‖ₑ).sum :=\n m.le_sum_of_subadditive enorm enorm_zero.le enorm_add_le\n\n@[to_additive existing]\ntheorem norm_multiset_prod_le (m : Multiset E) : ‖m.prod‖ ≤ (m.map fun x => ‖x‖).sum :=\n m.apply_prod_le_sum_map _ norm_one'.le norm_mul_le'\n\nvariable {ε : Type*} [TopologicalSpace ε] [ESeminormedCommMonoid ε] in\n@[to_additive existing]\ntheorem enorm_multisetProd_le (m : Multiset ε) :\n ‖m.prod‖ₑ ≤ (m.map fun x => ‖x‖ₑ).sum :=\n m.apply_prod_le_sum_map _ enorm_one'.le enorm_mul_le'\n\nvariable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddCommMonoid ε] in\n@[bound]\ntheorem enorm_sum_le (s : Finset ι) (f : ι → ε) :\n ‖∑ i ∈ s, f i‖ₑ ≤ ∑ i ∈ s, ‖f i‖ₑ :=\n s.le_sum_of_subadditive enorm enorm_zero.le enorm_add_le f\n\n@[bound]\ntheorem norm_sum_le {E} [SeminormedAddCommGroup E] (s : Finset ι) (f : ι → E) :\n ‖∑ i ∈ s, f i‖ ≤ ∑ i ∈ s, ‖f i‖ :=\n s.le_sum_of_subadditive norm norm_zero.le norm_add_le f\n\n@[to_additive existing]\ntheorem enorm_prod_le (s : Finset ι) (f : ι → ε) : ‖∏ i ∈ s, f i‖ₑ ≤ ∑ i ∈ s, ‖f i‖ₑ :=\n s.apply_prod_le_sum_apply _ enorm_one'.le enorm_mul_le'\n\n@[to_additive existing]\ntheorem norm_prod_le (s : Finset ι) (f : ι → E) : ‖∏ i ∈ s, f i‖ ≤ ∑ i ∈ s, ‖f i‖ :=\n s.apply_prod_le_sum_apply _ norm_one'.le norm_mul_le'\n\n@[to_additive]\ntheorem enorm_prod_le_of_le (s : Finset ι) {f : ι → ε} {n : ι → ℝ≥0∞} (h : ∀ b ∈ s, ‖f b‖ₑ ≤ n b) :\n ‖∏ b ∈ s, f b‖ₑ ≤ ∑ b ∈ s, n b :=\n (enorm_prod_le s f).trans <| Finset.sum_le_sum h\n\n@[to_additive]\ntheorem norm_prod_le_of_le (s : Finset ι) {f : ι → E} {n : ι → ℝ} (h : ∀ b ∈ s, ‖f b‖ ≤ n b) :\n ‖∏ b ∈ s, f b‖ ≤ ∑ b ∈ s, n b :=\n (norm_prod_le s f).trans <| Finset.sum_le_sum h\n\n@[to_additive]\ntheorem dist_prod_prod_le_of_le (s : Finset ι) {f a : ι → E} {d : ι → ℝ}\n (h : ∀ b ∈ s, dist (f b) (a b) ≤ d b) :\n dist (∏ b ∈ s, f b) (∏ b ∈ s, a b) ≤ ∑ b ∈ s, d b := by sorry\ntheorem dist_prod_prod_le (s : Finset ι) (f a : ι → E) :\n dist (∏ b ∈ s, f b) (∏ b ∈ s, a b) ≤ ∑ b ∈ s, dist (f b) (a b) :=\n dist_prod_prod_le_of_le s fun _ _ => le_rfl\n\n@[to_additive ball_eq]\ntheorem ball_eq' (y : E) (ε : ℝ) : ball y ε = { x | ‖x / y‖ < ε } := by sorry\ntheorem mem_ball_iff_norm'' : b ∈ ball a r ↔ ‖b / a‖ < r := by sorry\ntheorem mem_ball_iff_norm''' : b ∈ ball a r ↔ ‖a / b‖ < r := by sorry\ntheorem mem_closedBall_iff_norm'' : b ∈ closedBall a r ↔ ‖b / a‖ ≤ r := by sorry\ntheorem mem_closedBall_iff_norm''' : b ∈ closedBall a r ↔ ‖a / b‖ ≤ r := by sorry\ntheorem mem_sphere_iff_norm' : b ∈ sphere a r ↔ ‖b / a‖ = r := by simp [dist_eq_norm_div]\n\n@[to_additive]\ntheorem mul_mem_ball_iff_norm : a * b ∈ ball a r ↔ ‖b‖ < r := by sorry\ntheorem mul_mem_closedBall_iff_norm : a * b ∈ closedBall a r ↔ ‖b‖ ≤ r := by sorry\ntheorem preimage_mul_ball (a b : E) (r : ℝ) : (b * ·) ⁻¹' ball a r = ball (a / b) r := by sorry\ntheorem preimage_mul_closedBall (a b : E) (r : ℝ) :\n (b * ·) ⁻¹' closedBall a r = closedBall (a / b) r := by sorry\ntheorem preimage_mul_sphere (a b : E) (r : ℝ) : (b * ·) ⁻¹' sphere a r = sphere (a / b) r := by sorry\ntheorem pow_mem_closedBall {n : ℕ} (h : a ∈ closedBall b r) :\n a ^ n ∈ closedBall (b ^ n) (n • r) := by sorry\ntheorem pow_mem_ball {n : ℕ} (hn : 0 < n) (h : a ∈ ball b r) : a ^ n ∈ ball (b ^ n) (n • r) := by sorry\ntheorem mul_mem_closedBall_mul_iff {c : E} : a * c ∈ closedBall (b * c) r ↔ a ∈ closedBall b r := by sorry\ntheorem mul_mem_ball_mul_iff {c : E} : a * c ∈ ball (b * c) r ↔ a ∈ ball b r := by sorry\ntheorem smul_closedBall'' : a • closedBall b r = closedBall (a • b) r := by sorry\ntheorem smul_ball'' : a • ball b r = ball (a • b) r := by sorry\ntheorem nnnorm_multiset_prod_le (m : Multiset E) : ‖m.prod‖₊ ≤ (m.map fun x => ‖x‖₊).sum :=\n NNReal.coe_le_coe.1 <| by\n push_cast\n rw [Multiset.map_map]\n exact norm_multiset_prod_le _\n\n@[to_additive]\ntheorem nnnorm_prod_le (s : Finset ι) (f : ι → E) : ‖∏ a ∈ s, f a‖₊ ≤ ∑ a ∈ s, ‖f a‖₊ :=\n NNReal.coe_le_coe.1 <| by\n push_cast\n exact norm_prod_le _ _\n\n@[to_additive]\ntheorem nnnorm_prod_le_of_le (s : Finset ι) {f : ι → E} {n : ι → ℝ≥0} (h : ∀ b ∈ s, ‖f b‖₊ ≤ n b) :\n ‖∏ b ∈ s, f b‖₊ ≤ ∑ b ∈ s, n b :=\n (norm_prod_le_of_le s h).trans_eq (NNReal.coe_sum ..).symm\n\n@[to_additive]\ntheorem NormedCommGroup.tendsto_nhds_nhds {f : E → F} {x : E} {y : F} :\n Tendsto f (𝓝 x) (𝓝 y) ↔ ∀ ε > 0, ∃ δ > 0, ∀ x', ‖x' / x‖ < δ → ‖f x' / y‖ < ε := by sorry\ntheorem NormedCommGroup.nhds_basis_norm_lt (x : E) :\n (𝓝 x).HasBasis (fun ε : ℝ => 0 < ε) fun ε => { y | ‖y / x‖ < ε } := by sorry\ntheorem NormedCommGroup.uniformity_basis_dist :\n (𝓤 E).HasBasis (fun ε : ℝ => 0 < ε) fun ε => { p : E × E | ‖p.fst / p.snd‖ < ε } := by sorry\nend SeminormedCommGroup\n\nsection NormedGroup\n\nvariable [NormedGroup E] {a b : E}\n\n@[to_additive (attr := simp) norm_le_zero_iff]\nlemma norm_le_zero_iff' : ‖a‖ ≤ 0 ↔ a = 1 := by rw [← dist_one_right, dist_le_zero]\n\n@[to_additive (attr := simp) norm_pos_iff]\nlemma norm_pos_iff' : 0 < ‖a‖ ↔ a ≠ 1 := by rw [← not_le, norm_le_zero_iff']\n\n@[to_additive (attr := simp) norm_eq_zero]\nlemma norm_eq_zero' : ‖a‖ = 0 ↔ a = 1 := (norm_nonneg' a).ge_iff_eq'.symm.trans norm_le_zero_iff'\n\n@[to_additive norm_ne_zero_iff]\nlemma norm_ne_zero_iff' : ‖a‖ ≠ 0 ↔ a ≠ 1 := norm_eq_zero'.not\n\n@[to_additive]\ntheorem norm_div_eq_zero_iff : ‖a / b‖ = 0 ↔ a = b := by rw [norm_eq_zero', div_eq_one]\n\n@[to_additive]\ntheorem norm_div_pos_iff : 0 < ‖a / b‖ ↔ a ≠ b := by sorry\ntheorem eq_of_norm_div_le_zero (h : ‖a / b‖ ≤ 0) : a = b := by sorry\ntheorem eq_one_or_norm_pos (a : E) : a = 1 ∨ 0 < ‖a‖ := by sorry\ntheorem eq_one_or_nnnorm_pos (a : E) : a = 1 ∨ 0 < ‖a‖₊ :=\n eq_one_or_norm_pos a\n\n@[to_additive (attr := simp) nnnorm_eq_zero]\ntheorem nnnorm_eq_zero' : ‖a‖₊ = 0 ↔ a = 1 := by sorry\ntheorem nnnorm_ne_zero_iff' : ‖a‖₊ ≠ 0 ↔ a ≠ 1 :=\n nnnorm_eq_zero'.not\n\n@[to_additive (attr := simp) nnnorm_pos]\nlemma nnnorm_pos' : 0 < ‖a‖₊ ↔ a ≠ 1 := pos_iff_ne_zero.trans nnnorm_ne_zero_iff'\n\nvariable (E)\n\n/-- The norm of a normed group as a group norm. -/\n@[to_additive /-- The norm of a normed group as an additive group norm. -/]\ndef normGroupNorm : GroupNorm E :=\n { normGroupSeminorm _ with eq_one_of_map_eq_zero' := fun _ => norm_eq_zero'.1 }\n\n@[simp]\ntheorem coe_normGroupNorm : ⇑(normGroupNorm E) = norm :=\n rfl\n\nend NormedGroup\n\nsection NormedAddGroup\n\nvariable [NormedAddGroup E] [TopologicalSpace α] {f : α → E}\n\n/-! Some relations with `HasCompactSupport` -/\n\ntheorem hasCompactSupport_norm_iff : (HasCompactSupport fun x => ‖f x‖) ↔ HasCompactSupport f :=\n hasCompactSupport_comp_left norm_eq_zero\n\nalias ⟨_, HasCompactSupport.norm⟩ := hasCompactSupport_norm_iff\n\nend NormedAddGroup\n\n/-! ### `positivity` extensions -/\n\nnamespace Mathlib.Meta.Positivity\n\nopen Lean Meta Qq Function\n\n/-- Extension for the `positivity` tactic: multiplicative norms are always nonnegative, and positive\non non-one inputs. -/\n@[positivity ‖_‖]\nmeta def evalMulNorm : PositivityExt where eval {u α} _ _ e := do\n match u, α, e with\n | 0, ~q(ℝ), ~q(@Norm.norm $E $_n $a) =>\n let _seminormedGroup_E ← synthInstanceQ q(SeminormedGroup $E)\n assertInstancesCommute\n -- Check whether we are in a normed group and whether the context contains a `a ≠ 1` assumption\n let o : Option (Q(NormedGroup $E) × Q($a ≠ 1)) := ← do\n let .some normedGroup_E ← trySynthInstanceQ q(NormedGroup $E) | return none\n let some pa ← findLocalDeclWithTypeQ? q($a ≠ 1) | return none\n return some (normedGroup_E, pa)\n match o with\n -- If so, return a proof of `0 < ‖a‖`\n | some (_normedGroup_E, pa) =>\n assertInstancesCommute\n return .positive q(norm_pos_iff'.2 $pa)\n -- Else, return a proof of `0 ≤ ‖a‖`\n | none => return .nonnegative q(norm_nonneg' $a)\n | _, _, _ => throwError \"not `‖·‖`\"\n\n/-- Extension for the `positivity` tactic: additive norms are always nonnegative, and positive\non non-zero inputs. -/\n@[positivity ‖_‖]\nmeta def evalAddNorm : PositivityExt where eval {u α} _ _ e := do\n match u, α, e with\n | 0, ~q(ℝ), ~q(@Norm.norm $E $_n $a) =>\n let _seminormedAddGroup_E ← synthInstanceQ q(SeminormedAddGroup $E)\n assertInstancesCommute\n -- Check whether we are in a normed group and whether the context contains a `a ≠ 0` assumption\n let o : Option (Q(NormedAddGroup $E) × Q($a ≠ 0)) := ← do\n let .some normedAddGroup_E ← trySynthInstanceQ q(NormedAddGroup $E) | return none\n let some pa ← findLocalDeclWithTypeQ? q($a ≠ 0) | return none\n return some (normedAddGroup_E, pa)\n match o with\n -- If so, return a proof of `0 < ‖a‖`\n | some (_normedAddGroup_E, pa) =>\n assertInstancesCommute\n return .positive q(norm_pos_iff.2 $pa)\n -- Else, return a proof of `0 ≤ ‖a‖`\n | none => return .nonnegative q(norm_nonneg $a)\n | _, _, _ => throwError \"not `‖·‖`\"\n\nend Mathlib.Meta.Positivity\n" }, { "theorem_id": 68, "title": "091_the_triangle_inequality", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From Stdlib Require Import Rbase.\nFrom Stdlib Require Import Rfunctions.\nFrom Stdlib Require Import SeqSeries.\nFrom Stdlib Require Import Rtrigo1.\nFrom Stdlib Require Import R_sqrt.\n#[local] Open Scope R_scope.\n\nDefinition dist_euc (x0 y0 x1 y1:R) : R :=\n sqrt (Rsqr (x0 - x1) + Rsqr (y0 - y1)).\n\nLemma distance_refl : forall x0 y0:R, dist_euc x0 y0 x0 y0 = 0.\nProof.\nAdmitted.\n\nLemma distance_symm :\n forall x0 y0 x1 y1:R, dist_euc x0 y0 x1 y1 = dist_euc x1 y1 x0 y0.\nProof.\nAdmitted.\n\nLemma law_cosines :\n forall x0 y0 x1 y1 x2 y2 ac:R,\n let a := dist_euc x1 y1 x0 y0 in\n let b := dist_euc x2 y2 x0 y0 in\n let c := dist_euc x2 y2 x1 y1 in\n a * c * cos ac = (x0 - x1) * (x2 - x1) + (y0 - y1) * (y2 - y1) ->\n Rsqr b = Rsqr c + Rsqr a - 2 * (a * c * cos ac).\nProof.\nAdmitted.\n\nLemma triangle :\n forall x0 y0 x1 y1 x2 y2:R,\n dist_euc x0 y0 x1 y1 <= dist_euc x0 y0 x2 y2 + dist_euc x2 y2 x1 y1.\nProof.\nAdmitted.\n\nDefinition xt (x tx:R) : R := x + tx.\nDefinition yt (y ty:R) : R := y + ty.\n\nLemma translation_0 : forall x y:R, xt x 0 = x /\\ yt y 0 = y.\nProof.\nAdmitted.\n\nLemma isometric_translation :\n forall x1 x2 y1 y2 tx ty:R,\n Rsqr (x1 - x2) + Rsqr (y1 - y2) =\n Rsqr (xt x1 tx - xt x2 tx) + Rsqr (yt y1 ty - yt y2 ty).\nProof.\nAdmitted.\n\nDefinition xr (x y theta:R) : R := x * cos theta + y * sin theta.\nDefinition yr (x y theta:R) : R := - x * sin theta + y * cos theta.\n\nLemma rotation_0 : forall x y:R, xr x y 0 = x /\\ yr x y 0 = y.\nProof.\nAdmitted.\n\nLemma rotation_PI2 :\n forall x y:R, xr x y (PI / 2) = y /\\ yr x y (PI / 2) = - x.\nProof.\nAdmitted.\n\nLemma isometric_rotation_0 :\n forall x1 y1 x2 y2 theta:R,\n Rsqr (x1 - x2) + Rsqr (y1 - y2) =\n Rsqr (xr x1 y1 theta - xr x2 y2 theta) +\n Rsqr (yr x1 y1 theta - yr x2 y2 theta).\nProof.\nAdmitted.\n\nLemma isometric_rotation :\n forall x1 y1 x2 y2 theta:R,\n dist_euc x1 y1 x2 y2 =\n dist_euc (xr x1 y1 theta) (yr x1 y1 theta) (xr x2 y2 theta)\n (yr x2 y2 theta).\nProof.\nAdmitted.\n\nLemma isometric_rot_trans :\n forall x1 y1 x2 y2 tx ty theta:R,\n Rsqr (x1 - x2) + Rsqr (y1 - y2) =\n Rsqr (xr (xt x1 tx) (yt y1 ty) theta - xr (xt x2 tx) (yt y2 ty) theta) +\n Rsqr (yr (xt x1 tx) (yt y1 ty) theta - yr (xt x2 tx) (yt y2 ty) theta).\nProof.\nAdmitted.\n\nLemma isometric_trans_rot :\n forall x1 y1 x2 y2 tx ty theta:R,\n Rsqr (x1 - x2) + Rsqr (y1 - y2) =\n Rsqr (xt (xr x1 y1 theta) tx - xt (xr x2 y2 theta) tx) +\n Rsqr (yt (yr x1 y1 theta) ty - yt (yr x2 y2 theta) ty).\nProof.\nAdmitted." }, { "theorem_id": 69, "title": "093_the_birthday_problem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "prioritize_num();;\n\nparse_as_infix(\"-->\",(13,\"right\"));;\n\nlet funspace = new_definition\n `(s --> t) = {f:A->B | (!x. x IN s ==> f(x) IN t) /\\\n (!x. ~(x IN s) ==> f(x) = @y. T)}`;;\n\nlet FUNSPACE_EMPTY = `({} --> t) = {(\\x. @y. T)}`;;\n\nlet HAS_SIZE_FUNSPACE = `!s:A->bool t:B->bool m n.\n s HAS_SIZE m /\\ t HAS_SIZE n ==> (s --> t) HAS_SIZE (n EXP m)`;;\n\nlet FACT_DIVIDES = `!m n. m <= n ==> ?d. FACT(n) = d * FACT(m)`;;\n\nlet FACT_DIV_MULT = `!m n. m <= n ==> FACT n = (FACT(n) DIV FACT(m)) * FACT(m)`;;\n\nlet HAS_SIZE_FUNSPACE_INJECTIVE = `!s:A->bool t:B->bool m n.\n s HAS_SIZE m /\\ t HAS_SIZE n\n ==> {f | f IN (s --> t) /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y)}\n HAS_SIZE (if n < m then 0 else (FACT n) DIV (FACT(n - m)))`;;\n\nlet HAS_SIZE_DIFF = `!s t:A->bool m n.\n s SUBSET t /\\ s HAS_SIZE m /\\ t HAS_SIZE n\n ==> (t DIFF s) HAS_SIZE (n - m)`;;\n\nlet BIRTHDAY_THM = `!s:A->bool t:B->bool m n.\n s HAS_SIZE m /\\ t HAS_SIZE n\n ==> {f | f IN (s --> t) /\\\n ?x y. x IN s /\\ y IN s /\\ ~(x = y) /\\ f(x) = f(y)}\n HAS_SIZE (if m <= n then (n EXP m) - (FACT n) DIV (FACT(n - m))\n else n EXP m)`;;\n\nlet FACT_DIV_SIMP = `!m n. m < n\n ==> (FACT n) DIV (FACT m) = n * FACT(n - 1) DIV FACT(m)`;;\n\nlet BIRTHDAY_THM_EXPLICIT = `!s t. s HAS_SIZE 23 /\\ t HAS_SIZE 365\n ==> 2 * CARD {f | f IN (s --> t) /\\\n ?x y. x IN s /\\ y IN s /\\ ~(x = y) /\\ f(x) = f(y)}\n >= CARD (s --> t)`;;" }, { "theorem_id": 69, "title": "093_the_birthday_problem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory Probability\nimports\n Central_Limit_Theorem\n Discrete_Topology\n PMF_Impl\n Projective_Limit\n Random_Permutations\n SPMF\n Product_PMF\n Hoeffding\n Stream_Space\n Tree_Space\n Conditional_Expectation\n Essential_Supremum\n Stopping_Time\nbegin\n\nend" }, { "theorem_id": 69, "title": "093_the_birthday_problem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2021 Eric Rodriguez. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Rodriguez\n-/\nimport Mathlib.Data.Fintype.CardEmbedding\nimport Mathlib.Probability.UniformOn\nimport Mathlib.Probability.Notation\n\n/-!\n# Birthday Problem\n\nThis file proves Theorem 93 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/).\n\nAs opposed to the standard probabilistic statement, we instead state the birthday problem\nin terms of injective functions. The general result about `Fintype.card (α ↪ β)` which this proof\nuses is `Fintype.card_embedding_eq`.\n-/\n\n\nnamespace Theorems100\n\nlocal notation \"|\" x \"|\" => Finset.card x\n\nlocal notation \"‖\" x \"‖\" => Fintype.card x\n\n/-- **Birthday Problem**: set cardinality interpretation. -/\ntheorem birthday :\n 2 * ‖Fin 23 ↪ Fin 365‖ < ‖Fin 23 → Fin 365‖ ∧ 2 * ‖Fin 22 ↪ Fin 365‖ > ‖Fin 22 → Fin 365‖ := by sorry\nsection MeasureTheory\n\nopen MeasureTheory ProbabilityTheory\n\nopen scoped ProbabilityTheory ENNReal\n\nvariable {n m : ℕ}\n\n/- In order for Lean to understand that we can take probabilities in `Fin 23 → Fin 365`, we must\ntell Lean that there is a `MeasurableSpace` structure on the space. Note that this instance\nis only for `Fin m` - Lean automatically figures out that the function space `Fin n → Fin m`\nis _also_ measurable, by using `MeasurableSpace.pi`, and furthermore that all sets are measurable,\nfrom `MeasurableSingletonClass.pi`. -/\ninstance : MeasurableSpace (Fin m) :=\n ⊤\n\ninstance : MeasurableSingletonClass (Fin m) :=\n ⟨fun _ => trivial⟩\n\n/- We then endow the space with a canonical measure, which is called ℙ.\nWe define this to be the conditional counting measure. -/\nnoncomputable instance measureSpace : MeasureSpace (Fin n → Fin m) :=\n ⟨uniformOn Set.univ⟩\n\ntheorem FinFin.measure_apply {s : Set <| Fin n → Fin m} :\n ℙ s = |s.toFinite.toFinset| / ‖Fin n → Fin m‖ := by sorry\ntheorem birthday_measure :\n ℙ ({f | (Function.Injective f)} : Set ((Fin 23) → (Fin 365))) < 1 / 2 := by sorry\nend MeasureTheory\n\nend Theorems100\n" }, { "theorem_id": 69, "title": "093_the_birthday_problem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Arith.\nRequire Import ZArith.\nRequire Import List.\nRequire Import Lia.\nImport ListNotations.\n\nFixpoint appears x l :=\n match l with\n | [] => false\n | y :: l => if Nat.eqb x y then true else appears x l\n end.\n\nFixpoint collision l :=\n match l with\n | [] => false\n | x :: l => if appears x l then true else collision l\n end.\n\nFixpoint enumerate n :=\n match n with\n | 0 => []\n | S n => n :: enumerate n\n end.\n\nLemma length_enumerate n : length (enumerate n) = n.\nProof.\nAdmitted.\n\nLemma filter_app {A} f (l1 l2 : list A) :\n filter f (l1 ++ l2) = filter f l1 ++ filter f l2.\nProof.\nAdmitted.\n\nFixpoint cartesian_product {A B} (xs : list A) (ys : list B) : list (A * B) :=\n match xs with\n | [] => []\n | x :: xs => map (pair x) ys ++ cartesian_product xs ys\n end.\n\nFixpoint picks {A} n (l : list A) : list (list A) :=\n match n with\n | O => [[]]\n | S n => map (fun x => fst x :: snd x) (cartesian_product l (picks n l))\n end.\n\nLemma length_cartesian_product {A B} (xs : list A) (ys : list B) :\n length (cartesian_product xs ys) = length xs * length ys.\nProof.\nAdmitted.\n\nLemma Zlength_picks {A} n (l : list A) :\n Zlength (picks n l) = Z.\nProof.\nAdmitted.\n\nFixpoint partial_fact k n :=\n (match k with\n | O => 1\n | S k => n * partial_fact k (n - 1)\n end)%Z.\n\nDefinition no {A} (f : A -> bool) x := negb (f x).\n\nLemma cartesian_product_filters {A B} (f : A -> bool) (g : B -> bool) xs ys :\n cartesian_product (filter f xs) (filter g ys) =\n filter (fun p => andb (f (fst p)) (g (snd p))) (cartesian_product xs ys).\nProof.\nAdmitted.\n\nLemma picks_remove k a l :\n picks k (filter (no (Nat.\nProof.\nAdmitted.\n\nLemma appears_filter x l f :\n appears x l = false -> appears x (filter f l) = false.\nProof.\nAdmitted.\n\nLemma collision_filter l f :\n collision l = false -> collision (filter f l) = false.\nProof.\nAdmitted.\n\nLemma collision_count l :\n collision l = false -> Forall (fun x1 : nat => count_occ Nat.\nProof.\nAdmitted.\n\nLemma length_no_collision_picks k l :\n collision l = false ->\n Zlength (filter (no collision) (picks k l)) =\n partial_fact k (Zlength l).\nProof.\nAdmitted.\n\nLemma length_filter {A} (f : A -> bool) l :\n length (filter f l) + length (filter (no f) l) = length l.\nProof.\nAdmitted.\n\nLemma Zlength_filter {A} (f : A -> bool) l :\n (Zlength (filter f l) = Zlength l - Zlength (filter (no f) l))%Z.\nProof.\nAdmitted.\n\nLemma enumerate_no_collisions n : collision (enumerate n) = false.\nProof.\nAdmitted.\n\nTheorem birthday_paradox :\n let l := picks 23 (enumerate 365) in\n 2 * length (filter collision l) > length l.\nProof.\nAdmitted.\n\nTheorem birthday_paradox_min :\n let l := picks 22 (enumerate 365) in\n 2 * length (filter collision l) < length l.\nProof.\nAdmitted." }, { "theorem_id": 70, "title": "094_the_law_of_cosines", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/transcendentals.ml\";;\n\nprioritize_vector();;\n\nlet vangle = new_definition\n `vangle x y = if x = vec 0 \\/ y = vec 0 then pi / &2\n else acs((x dot y) / (norm x * norm y))`;;\n\nlet angle = new_definition\n `angle(a,b,c) = vangle (a - b) (c - b)`;;\n\nlet VANGLE = `!x y:real^N. x dot y = norm(x) * norm(y) * cos(vangle x y)`;;\n\nlet VANGLE_RANGE = `!x y:real^N. &0 <= vangle x y /\\ vangle x y <= pi`;;\n\nlet ORTHOGONAL_VANGLE = `!x y:real^N. orthogonal x y <=> vangle x y = pi / &2`;;\n\nlet VANGLE_EQ_PI = `!x y:real^N. vangle x y = pi ==> norm(x) % y + norm(y) % x = vec 0`;;\n\nlet ANGLE_EQ_PI = `!A B C:real^N. angle(A,B,C) = pi ==> dist(A,C) = dist(A,B) + dist(B,C)`;;\n\nlet SIN_ANGLE_POS = `!A B C. &0 <= sin(angle(A,B,C))`;;\n\nlet ANGLE = `!A B C. (A - C) dot (B - C) = dist(A,C) * dist(B,C) * cos(angle(A,C,B))`;;\n\nlet ANGLE_REFL = `!A B. angle(A,A,B) = pi / &2 /\\\n angle(B,A,A) = pi / &2`;;\n\nlet ANGLE_REFL_MID = `!A B. ~(A = B) ==> angle(A,B,A) = &0`;;\n\nlet ANGLE_SYM = `!A B C. angle(A,B,C) = angle(C,B,A)`;;\n\nlet ANGLE_RANGE = `!A B C. &0 <= angle(A,B,C) /\\ angle(A,B,C) <= pi`;;\n\nlet LAW_OF_COSINES = `!A B C:real^N.\n dist(B,C) pow 2 = dist(A,B) pow 2 + dist(A,C) pow 2 -\n &2 * dist(A,B) * dist(A,C) * cos(angle(B,A,C))`;;\n\nlet LAW_OF_SINES = `!A B C:real^N.\n sin(angle(A,B,C)) * dist(B,C) = sin(angle(B,A,C)) * dist(A,C)`;;\n\nlet TRIANGLE_ANGLE_SUM_LEMMA = `!A B C:real^N. ~(A = B) /\\ ~(A = C) /\\ ~(B = C)\n ==> cos(angle(B,A,C) + angle(A,B,C) + angle(B,C,A)) = -- &1`;;\n\nlet COS_MINUS1_LEMMA = `!x. cos(x) = -- &1 /\\ &0 <= x /\\ x < &3 * pi ==> x = pi`;;\n\nlet TRIANGLE_ANGLE_SUM = `!A B C:real^N. ~(A = B) /\\ ~(A = C) /\\ ~(B = C)\n ==> angle(B,A,C) + angle(A,B,C) + angle(B,C,A) = pi`;;" }, { "theorem_id": 70, "title": "094_the_law_of_cosines", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Basic Properties of Triangles\\\ntheory Triangle\nimports\n Angles\nbegin\n\ntext \\\n We prove a number of basic geometric properties of triangles. All theorems hold\n in any real inner product space.\n\\\nsubsection \\Thales' theorem\\\n\ntheorem thales:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"dist B (midpoint A C) = dist A C / 2\"\n shows \"orthogonal (A - B) (C - B)\"\n by sorry\n\nsubsection \\Sine and cosine laws\\\n\ntext \\\n The proof of the Law of Cosines follows trivially from the definition of the angle,\n the definition of the norm in vector spaces with an inner product and the bilinearity\n of the inner product.\n\\\n\nlemma cosine_law_vector:\n \"norm (u - v) ^ 2 = norm u ^ 2 + norm v ^ 2 - 2 * norm u * norm v * cos (vangle u v)\"\n by sorry\n\nlemma cosine_law_triangle:\n \"dist b c ^ 2 = dist a b ^ 2 + dist a c ^ 2 - 2 * dist a b * dist a c * cos (angle b a c)\"\n by sorry\n\ntext \\\n According to our definition, angles are always between $0$ and $\\pi$ and therefore,\n the sign of an angle is always non-negative. We can therefore look at\n $\\sin(\\alpha)^2$, which we can express in terms of $\\cos(\\alpha)$ using the\n identity $\\sin(\\alpha)^2 + \\cos(\\alpha)^2 = 1$. The remaining proof is then a\n trivial consequence of the definitions.\n\\\nlemma sine_law_triangle:\n \"sin (angle a b c) * dist b c = sin (angle b a c) * dist a c\" (is \"?A = ?B\")\n by sorry\n\ntext \\\n The following forms of the Law of Sines/Cosines are more convenient for eliminating\n sines/cosines from a goal completely.\n\\\n\nlemma cosine_law_triangle':\n \"2 * dist a b * dist a c * cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2)\"\n by sorry\n\nlemma cosine_law_triangle'':\n \"cos (angle b a c) = (dist a b ^ 2 + dist a c ^ 2 - dist b c ^ 2) / (2 * dist a b * dist a c)\"\n by sorry\n\nlemma sine_law_triangle':\n \"b \\ c \\ sin (angle a b c) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nlemma sine_law_triangle'':\n \"b \\ c \\ sin (angle c b a) = sin (angle b a c) * dist a c / dist b c\"\n by sorry\n\nsubsection \\Sum of angles\\\n\ncontext\nbegin\n\nprivate lemma gather_squares: \"a * (a * b) = a^2 * (b :: real)\"\n by (simp_all add: power2_eq_square)\n\nprivate lemma eval_power: \"x ^ numeral n = x * x ^ pred_numeral n\"\n by (subst numeral_eq_Suc, subst power_Suc) simp\n\ntext \\\n The proof that the sum of the angles in a triangle is $\\pi$ is somewhat more\n involved. Following the HOL Light proof by John Harrison, we first prove\n that $\\cos(\\alpha + \\beta + \\gamma) = -1$ and $\\alpha + \\beta + \\gamma \\in [0;3\\pi)$,\n which then implies the theorem.\n\n The main work is proving $\\cos(\\alpha + \\beta + \\gamma)$. This is done using the\n addition theorems for the sine and cosine, then using the Laws of Sines to eliminate\n all $\\sin$ terms save $\\sin(\\gamma)^2$, which only appears squared in the remaining goal.\n We then use $\\sin(\\gamma)^2 = 1 - \\cos(\\gamma)^2$ to eliminate this term and apply\n the law of cosines to eliminate this term as well.\n\n The remaining goal is a non-linear equation containing only the length of the sides\n of the triangle. It can be shown by simple algebraic rewriting.\n\\\nlemma angle_sum_triangle:\n assumes \"a \\ b \\ b \\ c \\ a \\ c\"\n shows \"angle c a b + angle a b c + angle b c a = pi\"\n by sorry\n\nend\n\nsubsection \\Congruence Theorems\\\n\ntext \\\n If two triangles agree on two angles at a non-degenerate side, the third angle\n must also be equal.\n\\\nlemma similar_triangle_aa:\n assumes \"b1 \\ c1\" \"b2 \\ c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n shows \"angle b1 a1 c1 = angle b2 a2 c2\"\n by sorry\n\ntext \\\n A triangle is defined by its three angles and the lengths of three sides up to congruence.\n Two triangles are congruent if they have their angles are the same and their sides have\n the same length.\n\\\n\nlocale congruent_triangle =\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes sides': \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n and angles': \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\"\n \"angle a1 c1 b1 = angle a2 c2 b2\"\nbegin\n\nlemma sides:\n \"dist a1 b1 = dist a2 b2\" \"dist a1 c1 = dist a2 c2\" \"dist b1 c1 = dist b2 c2\"\n \"dist b1 a1 = dist a2 b2\" \"dist c1 a1 = dist a2 c2\" \"dist c1 b1 = dist b2 c2\"\n \"dist a1 b1 = dist b2 a2\" \"dist a1 c1 = dist c2 a2\" \"dist b1 c1 = dist c2 b2\"\n \"dist b1 a1 = dist b2 a2\" \"dist c1 a1 = dist c2 a2\" \"dist c1 b1 = dist c2 b2\"\n by sorry\n\nlemma angles:\n \"angle b1 a1 c1 = angle b2 a2 c2\" \"angle a1 b1 c1 = angle a2 b2 c2\" \"angle a1 c1 b1 = angle a2 c2 b2\"\n \"angle c1 a1 b1 = angle b2 a2 c2\" \"angle c1 b1 a1 = angle a2 b2 c2\" \"angle b1 c1 a1 = angle a2 c2 b2\"\n \"angle b1 a1 c1 = angle c2 a2 b2\" \"angle a1 b1 c1 = angle c2 b2 a2\" \"angle a1 c1 b1 = angle b2 c2 a2\"\n \"angle c1 a1 b1 = angle c2 a2 b2\" \"angle c1 b1 a1 = angle c2 b2 a2\" \"angle b1 c1 a1 = angle b2 c2 a2\"\n by sorry\n\nend\n\nlemmas congruent_triangleD = congruent_triangle.sides congruent_triangle.angles\n\ntext \\\n Given two triangles that agree on a subset of its side lengths and angles that are\n sufficient to define a triangle uniquely up to congruence, one can conclude that they\n must also agree on all remaining quantities, i.e. that they are congruent.\n\n The following four congruence theorems state what constitutes such a uniquely-defining\n subset of quantities. Each theorem states in its name which quantities are required and\n in which order (clockwise or counter-clockwise): an ``s'' stands for a side,\n an ``a'' stands for an angle.\n\n The lemma ``congruent-triangleI-sas, for example, requires that two adjacent sides and the\n angle inbetween are the same in both triangles.\n\\\n\nlemma congruent_triangleI_sss:\n fixes a1 b1 c1 :: \"'a :: real_inner\" and a2 b2 c2 :: \"'b :: real_inner\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"dist a1 c1 = dist a2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sss = congruent_triangleD[OF congruent_triangleI_sss]\n\nlemma congruent_triangleI_sas:\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"dist b1 c1 = dist b2 c2\"\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_sas = congruent_triangleD[OF congruent_triangleI_sas]\n\nlemma congruent_triangleI_aas:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"angle b1 c1 a1 = angle b2 c2 a2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"\\collinear {a1,b1,c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_aas = congruent_triangleD[OF congruent_triangleI_aas]\n\nlemma congruent_triangleI_asa:\n assumes \"angle a1 b1 c1 = angle a2 b2 c2\"\n assumes \"dist a1 b1 = dist a2 b2\"\n assumes \"angle b1 a1 c1 = angle b2 a2 c2\"\n assumes \"\\collinear {a1, b1, c1}\"\n shows \"congruent_triangle a1 b1 c1 a2 b2 c2\"\n by sorry\n\nlemmas congruent_triangle_asa = congruent_triangleD[OF congruent_triangleI_asa]\n\nsubsection \\Isosceles Triangle Theorem\\\n\ntext \\\n We now prove the Isosceles Triangle Theorem: in a triangle where two sides have\n the same length, the two angles that are adjacent to only one of the two sides\n must be equal.\n\\\nlemma isosceles_triangle:\n assumes \"dist a c = dist b c\"\n shows \"angle b a c = angle a b c\"\n by sorry\n\ntext \\\n For the non-degenerate case (i.e. the three points are not collinear), We also\n prove the converse.\n\\\nlemma isosceles_triangle_converse:\n assumes \"angle a b c = angle b a c\" \"\\collinear {a,b,c}\"\n shows \"dist a c = dist b c\"\n by sorry\n\nsubsection\\Contributions by Lukas Bulwahn\\\n \nlemma Pythagoras:\n fixes A B C :: \"'a :: real_inner\"\n assumes \"orthogonal (A - C) (B - C)\"\n shows \"(dist B C) ^ 2 + (dist C A) ^ 2 = (dist A B) ^ 2\"\n by sorry\n\nlemma isosceles_triangle_orthogonal_on_midpoint:\n fixes A B C :: \"'a :: euclidean_space\"\n assumes \"dist C A = dist C B\"\n shows \"orthogonal (C - midpoint A B) (A - midpoint A B)\"\n by sorry\n\nend" }, { "theorem_id": 70, "title": "094_the_law_of_cosines", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Manuel Candales\n-/\nmodule\n\npublic import Mathlib.Analysis.Normed.Affine.AddTorsor\npublic import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine\npublic import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine\npublic import Mathlib.Tactic.IntervalCases\n\n/-!\n# Triangles\n\nThis file proves basic geometrical results about distances and angles\nin (possibly degenerate) triangles in real inner product spaces and\nEuclidean affine spaces. More specialized results, and results\ndeveloped for simplices in general rather than just for triangles, are\nin separate files. Definitions and results that make sense in more\ngeneral affine spaces rather than just in the Euclidean case go under\n`LinearAlgebra.AffineSpace`.\n\n## Implementation notes\n\nResults in this file are generally given in a form with only those\nnon-degeneracy conditions needed for the particular result, rather\nthan requiring affine independence of the points of a triangle\nunnecessarily.\n\n## References\n\n* https://en.wikipedia.org/wiki/Law_of_cosines\n* https://en.wikipedia.org/wiki/Pons_asinorum\n* https://en.wikipedia.org/wiki/Sum_of_angles_of_a_triangle\n* https://en.wikipedia.org/wiki/Law_of_sines\n\n-/\n\npublic section\n\nnoncomputable section\n\nopen scoped CharZero Real RealInnerProductSpace\n\nnamespace InnerProductGeometry\n\n/-!\n### Geometrical results on triangles in real inner product spaces\n\nThis section develops some results on (possibly degenerate) triangles\nin real inner product spaces, where those definitions and results can\nmost conveniently be developed in terms of vectors and then used to\ndeduce corresponding results for Euclidean affine spaces.\n-/\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]\n\n/-- **Law of cosines** (cosine rule), vector angle form. -/\ntheorem norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle (x y : V) :\n ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ - 2 * ‖x‖ * ‖y‖ * Real.cos (angle x y) := by sorry\ntheorem sin_angle_mul_norm_eq_sin_angle_mul_norm (x y : V) :\n Real.sin (angle x y) * ‖x‖ = Real.sin (angle y (x - y)) * ‖x - y‖ := by sorry\ntheorem sin_angle_div_norm_eq_sin_angle_div_norm (x y : V) (hx : x ≠ 0) (hxy : x - y ≠ 0) :\n Real.sin (angle x y) / ‖x - y‖ = Real.sin (angle y (x - y)) / ‖x‖ := by sorry\ntheorem angle_sub_eq_angle_sub_rev_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) :\n angle x (x - y) = angle y (y - x) := by sorry\ntheorem norm_eq_of_angle_sub_eq_angle_sub_rev_of_angle_ne_pi {x y : V}\n (h : angle x (x - y) = angle y (y - x)) (hpi : angle x y ≠ π) : ‖x‖ = ‖y‖ := by sorry\ntheorem angle_eq_angle_add_add_angle_add (x : V) {y : V} (hy : y ≠ 0) :\n angle x y = angle x (x + y) + angle y (x + y) := by sorry\ntheorem angle_add_angle_sub_add_angle_sub_eq_pi (x : V) {y : V} (hy : y ≠ 0) :\n angle x y + angle x (x - y) + angle y (y - x) = π := by sorry\nend InnerProductGeometry\n\nnamespace Orientation\n\nopen Module InnerProductGeometry\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [Fact (finrank ℝ V = 2)]\nvariable (o : Orientation ℝ V (Fin 2))\n\n/-- **Converse of pons asinorum**, oriented vector angle form (given equality of angles mod `π`). -/\ntheorem norm_eq_of_two_zsmul_oangle_sub_eq {x y : V}\n (h : (2 : ℤ) • o.oangle x (x - y) = (2 : ℤ) • o.oangle (y - x) y) (h0 : o.oangle x y ≠ 0)\n (hpi : o.oangle x y ≠ π) : ‖x‖ = ‖y‖ := by sorry\nend Orientation\n\nnamespace EuclideanGeometry\n\n/-!\n### Geometrical results on triangles in Euclidean affine spaces\n\nThis section develops some geometrical definitions and results on\n(possibly degenerate) triangles in Euclidean affine spaces.\n-/\n\nopen InnerProductGeometry\nopen scoped EuclideanGeometry\n\nvariable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]\n [NormedAddTorsor V P]\n\n/-- **Law of cosines** (cosine rule), angle-at-point form. -/\ntheorem dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle (p₁ p₂ p₃ : P) :\n dist p₁ p₃ * dist p₁ p₃ = dist p₁ p₂ * dist p₁ p₂ + dist p₃ p₂ * dist p₃ p₂ -\n 2 * dist p₁ p₂ * dist p₃ p₂ * Real.cos (∠ p₁ p₂ p₃) := by sorry\ntheorem sin_angle_mul_dist_eq_sin_angle_mul_dist (p₁ p₂ p₃ : P) :\n Real.sin (∠ p₁ p₂ p₃) * dist p₂ p₃ = Real.sin (∠ p₃ p₁ p₂) * dist p₃ p₁ := by sorry\ntheorem sin_angle_div_dist_eq_sin_angle_div_dist {p₁ p₂ p₃ : P} (h23 : p₂ ≠ p₃) (h31 : p₃ ≠ p₁) :\n Real.sin (∠ p₁ p₂ p₃) / dist p₃ p₁ = Real.sin (∠ p₃ p₁ p₂) / dist p₂ p₃ := by sorry\ntheorem dist_eq_dist_mul_sin_angle_div_sin_angle {p₁ p₂ p₃ : P}\n (h : ¬Collinear ℝ ({p₁, p₂, p₃} : Set P)) :\n dist p₁ p₂ = dist p₃ p₁ * Real.sin (∠ p₂ p₃ p₁) / Real.sin (∠ p₁ p₂ p₃) := by sorry\ntheorem angle_eq_angle_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dist p₁ p₃) :\n ∠ p₁ p₂ p₃ = ∠ p₁ p₃ p₂ := by sorry\ntheorem dist_eq_of_angle_eq_angle_of_angle_ne_pi {p₁ p₂ p₃ : P} (h : ∠ p₁ p₂ p₃ = ∠ p₁ p₃ p₂)\n (hpi : ∠ p₂ p₁ p₃ ≠ π) : dist p₁ p₂ = dist p₁ p₃ := by sorry\ntheorem dist_eq_of_two_zsmul_oangle_eq [Module.Oriented ℝ V (Fin 2)]\n [Fact (Module.finrank ℝ V = 2)] {p₁ p₂ p₃ : P} (h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₂ p₃ p₁)\n (h0 : ∡ p₃ p₁ p₂ ≠ 0) (hpi : ∡ p₃ p₁ p₂ ≠ π) : dist p₁ p₂ = dist p₁ p₃ := by sorry\ntheorem angle_add_angle_add_angle_eq_pi {p₁ p₂ : P} (p₃ : P) (h : p₂ ≠ p₁) :\n ∠ p₁ p₂ p₃ + ∠ p₂ p₃ p₁ + ∠ p₃ p₁ p₂ = π := by sorry\ntheorem exterior_angle_eq_angle_add_angle {p₁ p₂ p₃ : P} (p : P) (h : Sbtw ℝ p p₁ p₂) :\n ∠ p₃ p₁ p = ∠ p₁ p₃ p₂ + ∠ p₃ p₂ p₁ := by sorry\ntheorem oangle_add_oangle_add_oangle_eq_pi [Module.Oriented ℝ V (Fin 2)]\n [Fact (Module.finrank ℝ V = 2)] {p₁ p₂ p₃ : P} (h21 : p₂ ≠ p₁) (h32 : p₃ ≠ p₂)\n (h13 : p₁ ≠ p₃) : ∡ p₁ p₂ p₃ + ∡ p₂ p₃ p₁ + ∡ p₃ p₁ p₂ = π := by sorry\nlemma angle_add_of_ne_of_ne {a b c p : P} (hb : a ≠ b) (hc : a ≠ c) (hp : Wbtw ℝ b p c) :\n ∠ b a p + ∠ p a c = ∠ b a c := by sorry\ntheorem dist_sq_mul_dist_add_dist_sq_mul_dist (a b c p : P) (h : ∠ b p c = π) :\n dist a b ^ 2 * dist c p + dist a c ^ 2 * dist b p =\n dist b c * (dist a p ^ 2 + dist b p * dist c p) := by sorry\ntheorem dist_sq_add_dist_sq_eq_two_mul_dist_midpoint_sq_add_half_dist_sq (a b c : P) :\n dist a b ^ 2 + dist a c ^ 2 = 2 * (dist a (midpoint ℝ b c) ^ 2 + (dist b c / 2) ^ 2) := by sorry\ntheorem dist_mul_of_eq_angle_of_dist_mul (a b c a' b' c' : P) (r : ℝ) (h : ∠ a' b' c' = ∠ a b c)\n (hab : dist a' b' = r * dist a b) (hcb : dist c' b' = r * dist c b) :\n dist a' c' = r * dist a c := by sorry\ntheorem dist_lt_of_angle_lt {a b c : P} (h : ¬Collinear ℝ ({a, b, c} : Set P)) :\n ∠ a c b < ∠ a b c → dist a b < dist a c := by sorry\ntheorem angle_lt_iff_dist_lt {a b c : P} (h : ¬Collinear ℝ ({a, b, c} : Set P)) :\n ∠ a c b < ∠ a b c ↔ dist a b < dist a c := by sorry\ntheorem angle_le_iff_dist_le {a b c : P} (h : ¬Collinear ℝ ({a, b, c} : Set P)) :\n ∠ a c b ≤ ∠ a b c ↔ dist a b ≤ dist a c := by sorry\nlemma pi_div_three_le_angle_of_le_of_le {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₂ p₃ p₁ ≤ ∠ p₁ p₂ p₃)\n (h₃₁₂ : ∠ p₃ p₁ p₂ ≤ ∠ p₁ p₂ p₃) : π / 3 ≤ ∠ p₁ p₂ p₃ := by sorry\nlemma pi_div_three_lt_angle_of_le_of_le_of_ne {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₂ p₃ p₁ ≤ ∠ p₁ p₂ p₃)\n (h₃₁₂ : ∠ p₃ p₁ p₂ ≤ ∠ p₁ p₂ p₃)\n (hne : ∠ p₁ p₂ p₃ ≠ ∠ p₂ p₃ p₁ ∨ ∠ p₁ p₂ p₃ ≠ ∠ p₃ p₁ p₂ ∨ ∠ p₂ p₃ p₁ ≠ ∠ p₃ p₁ p₂) :\n π / 3 < ∠ p₁ p₂ p₃ := by sorry\nlemma angle_le_pi_div_three_of_le_of_le {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₁ p₂ p₃ ≤ ∠ p₂ p₃ p₁)\n (h₃₁₂ : ∠ p₁ p₂ p₃ ≤ ∠ p₃ p₁ p₂) (hnd : p₁ ≠ p₂ ∨ p₁ ≠ p₃ ∨ p₂ ≠ p₃) :\n ∠ p₁ p₂ p₃ ≤ π / 3 := by sorry\nlemma angle_lt_pi_div_three_of_le_of_le_of_ne {p₁ p₂ p₃ : P} (h₂₃₁ : ∠ p₁ p₂ p₃ ≤ ∠ p₂ p₃ p₁)\n (h₃₁₂ : ∠ p₁ p₂ p₃ ≤ ∠ p₃ p₁ p₂)\n (hne : ∠ p₁ p₂ p₃ ≠ ∠ p₂ p₃ p₁ ∨ ∠ p₁ p₂ p₃ ≠ ∠ p₃ p₁ p₂ ∨ ∠ p₂ p₃ p₁ ≠ ∠ p₃ p₁ p₂) :\n ∠ p₁ p₂ p₃ < π / 3 := by sorry\nend EuclideanGeometry\n" }, { "theorem_id": 70, "title": "094_the_law_of_cosines", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From HighSchoolGeometry Require Export euclidien_classiques.\nFrom HighSchoolGeometry Require Export trigo.\nSet Implicit Arguments.\nUnset Strict Implicit.\n \nLemma produit_scalaire_Cosinus :\n forall A B C : PO,\n A <> B ->\n A <> C ->\n scalaire (vec A B) (vec A C) =\n distance A B * (distance A C * Cos (cons_AV (vec A B) (vec A C))).\nProof.\nAdmitted.\n \nLemma produit_scalaire_cosinus :\n forall (A B C : PO) (a : R),\n A <> B ->\n A <> C ->\n image_angle a = cons_AV (vec A B) (vec A C) ->\n scalaire (vec A B) (vec A C) = distance A B * (distance A C * cos a).\nProof.\nAdmitted.\n#[export] Hint Resolve carre_scalaire_distance: geo.\n \nLemma triangle_rectangle_Cos :\n forall (A B C : PO) (a : R),\n A <> B ->\n A <> C ->\n orthogonal (vec B A) (vec B C) ->\n distance A B = distance A C * Cos (cons_AV (vec A B) (vec A C)).\nProof.\nAdmitted.\n \nLemma triangle_rectangle_cos :\n forall (A B C : PO) (a : R),\n A <> B ->\n A <> C ->\n orthogonal (vec B A) (vec B C) ->\n image_angle a = cons_AV (vec A B) (vec A C) ->\n distance A B = distance A C * cos a.\nProof.\nAdmitted.\n \nLemma triangle_rectangle_absolu_cos :\n forall (A B C : PO) (a : R),\n A <> B ->\n A <> C ->\n orthogonal (vec B A) (vec B C) ->\n image_angle a = cons_AV (vec A B) (vec A C) ->\n distance A B = distance A C * Rabs (cos a).\nProof.\nAdmitted.\n \nLemma orthogonal_distincts :\n forall A B C : PO,\n A <> B -> A <> C -> orthogonal (vec A B) (vec A C) -> B <> C.\nProof.\nAdmitted.\n \nLemma triangle_rectangle_direct_sinus :\n forall (A B C : PO) (a : R),\n A <> B ->\n A <> C ->\n B <> C ->\n image_angle pisurdeux = cons_AV (vec B C) (vec B A) ->\n image_angle a = cons_AV (vec A B) (vec A C) ->\n distance C B = distance C A * sin a.\nProof.\nAdmitted.\n \nLemma triangle_rectangle_indirect_sinus :\n forall (A B C : PO) (a : R),\n A <> B ->\n A <> C ->\n B <> C ->\n image_angle (- pisurdeux) = cons_AV (vec B C) (vec B A) ->\n image_angle a = cons_AV (vec A B) (vec A C) ->\n distance C B = distance C A * - sin a.\nProof.\nAdmitted.\n \nLemma triangle_rectangle_absolu_sinus :\n forall (A B C : PO) (a : R),\n A <> B ->\n A <> C ->\n B <> C ->\n orthogonal (vec B A) (vec B C) ->\n image_angle a = cons_AV (vec A B) (vec A C) ->\n distance C B = distance C A * Rabs (sin a).\nProof.\nAdmitted.\n \nLemma triangle_rectangle_direct_Sin :\n forall A B C : PO,\n A <> B ->\n A <> C ->\n B <> C ->\n image_angle pisurdeux = cons_AV (vec B C) (vec B A) ->\n distance C B = distance C A * Sin (cons_AV (vec A B) (vec A C)).\nProof.\nAdmitted.\n \nLemma triangle_rectangle_indirect_Sin :\n forall A B C : PO,\n A <> B ->\n A <> C ->\n B <> C ->\n image_angle (- pisurdeux) = cons_AV (vec B C) (vec B A) ->\n distance C B = distance C A * - Sin (cons_AV (vec A B) (vec A C)).\nProof.\nAdmitted.\n \nLemma triangle_rectangle_absolu_Sin :\n forall A B C : PO,\n A <> B ->\n A <> C ->\n B <> C ->\n orthogonal (vec B A) (vec B C) ->\n distance C B = distance C A * Rabs (Sin (cons_AV (vec A B) (vec A C))).\nProof.\nAdmitted.\n \nLemma projete_negatif_cos :\n forall (A B C H : PO) (a k : R),\n A <> B ->\n A <> C ->\n H = projete_orthogonal A B C ->\n vec A H = mult_PP k (vec A B) ->\n k < 0 -> image_angle a = cons_AV (vec A B) (vec A C) -> cos a < 0.\nProof.\nAdmitted.\n \nLemma projete_absolu_cos :\n forall (A B C H : PO) (a : R),\n A <> B ->\n A <> C ->\n H = projete_orthogonal A B C ->\n image_angle a = cons_AV (vec A B) (vec A C) ->\n distance A H = distance A C * Rabs (cos a).\nProof.\nAdmitted.\n \nLemma projete_absolu_sin :\n forall (A B C H : PO) (a : R),\n triangle A B C ->\n H = projete_orthogonal A B C ->\n image_angle a = cons_AV (vec A B) (vec A C) ->\n distance C H = distance C A * Rabs (sin a).\nProof.\nAdmitted.\n \nLemma projete_absolu_Sin :\n forall A B C H : PO,\n triangle A B C ->\n H = projete_orthogonal A B C ->\n distance C H = distance C A * Rabs (Sin (cons_AV (vec A B) (vec A C))).\nProof.\nAdmitted.\n \nLemma projete_absolu_Cos :\n forall A B C H : PO,\n A <> B ->\n A <> C ->\n H = projete_orthogonal A B C ->\n distance A H = distance A C * Rabs (Cos (cons_AV (vec A B) (vec A C))).\nProof.\nAdmitted.\n \nTheorem Al_Kashi_Cos :\n forall A B C : PO,\n A <> B ->\n A <> C ->\n Rsqr (distance B C) =\n Rsqr (distance A B) + Rsqr (distance A C) +\n - (2 * (distance A B * (distance A C * Cos (cons_AV (vec A B) (vec A C))))).\nProof.\nAdmitted.\n \nTheorem Al_Kashi :\n forall (A B C : PO) (a : R),\n A <> B ->\n A <> C ->\n image_angle a = cons_AV (vec A B) (vec A C) ->\n Rsqr (distance B C) =\n Rsqr (distance A B) + Rsqr (distance A C) +\n - (2 * (distance A B * (distance A C * cos a))).\nProof.\nAdmitted.\n \nLemma triangles_isometriques :\n forall (A B C A' B' C' : PO) (x x' y y' : R),\n A <> B :>PO ->\n A <> C :>PO ->\n B <> C :>PO ->\n distance A' B' = distance A B ->\n distance A' C' = distance A C ->\n cons_AV (vec A B) (vec A C) = cons_AV (vec A' B') (vec A' C') :>AV ->\n image_angle x = cons_AV (vec B C) (vec B A) :>AV ->\n image_angle x' = cons_AV (vec B' C') (vec B' A') :>AV ->\n image_angle y = cons_AV (vec C A) (vec C B) :>AV ->\n image_angle y' = cons_AV (vec C' A') (vec C' B') :>AV ->\n distance B' C' = distance B C /\\ cos x = cos x' /\\ cos y = cos y'.\nProof.\nAdmitted.\n \nAxiom\n angles_egaux_triangle :\n forall (A B C A' B' C' : PO) (x x' y y' : R),\n A <> B :>PO ->\n A <> C :>PO ->\n B <> C :>PO ->\n cons_AV (vec A B) (vec A C) = cons_AV (vec A' B') (vec A' C') :>AV ->\n image_angle x = cons_AV (vec B C) (vec B A) :>AV ->\n image_angle x' = cons_AV (vec B' C') (vec B' A') :>AV ->\n image_angle y = cons_AV (vec C A) (vec C B) :>AV ->\n image_angle y' = cons_AV (vec C' A') (vec C' B') :>AV ->\n cos x = cos x' ->\n cos y = cos y' ->\n cons_AV (vec B C) (vec B A) = cons_AV (vec B' C') (vec B' A') :>AV /\\\n cons_AV (vec C A) (vec C B) = cons_AV (vec C' A') (vec C' B') :>AV.\n \nLemma cas_egalite_triangle :\n forall A B C A' B' C' : PO,\n A <> B :>PO ->\n A <> C :>PO ->\n B <> C :>PO ->\n distance A' B' = distance A B ->\n distance A' C' = distance A C ->\n cons_AV (vec A B) (vec A C) = cons_AV (vec A' B') (vec A' C') :>AV ->\n distance B' C' = distance B C /\\\n cons_AV (vec B C) (vec B A) = cons_AV (vec B' C') (vec B' A') :>AV /\\\n cons_AV (vec C A) (vec C B) = cons_AV (vec C' A') (vec C' B') :>AV.\nProof.\nAdmitted.\n \nLemma triangles_isometriques_indirects :\n forall (A B C A' B' C' : PO) (x x' y y' : R),\n A <> B :>PO ->\n A <> C :>PO ->\n B <> C :>PO ->\n distance A' B' = distance A B ->\n distance A' C' = distance A C ->\n cons_AV (vec A B) (vec A C) = cons_AV (vec A' C') (vec A' B') :>AV ->\n image_angle x = cons_AV (vec B C) (vec B A) :>AV ->\n image_angle x' = cons_AV (vec B' C') (vec B' A') :>AV ->\n image_angle y = cons_AV (vec C A) (vec C B) :>AV ->\n image_angle y' = cons_AV (vec C' A') (vec C' B') :>AV ->\n distance B' C' = distance B C /\\ cos x = cos x' /\\ cos y = cos y'.\nProof.\nAdmitted.\n \nAxiom\n angles_egaux_triangle_indirect :\n forall (A B C A' B' C' : PO) (x x' y y' : R),\n A <> B :>PO ->\n A <> C :>PO ->\n B <> C :>PO ->\n cons_AV (vec A B) (vec A C) = cons_AV (vec A' C') (vec A' B') :>AV ->\n image_angle x = cons_AV (vec B C) (vec B A) :>AV ->\n image_angle x' = cons_AV (vec B' C') (vec B' A') :>AV ->\n image_angle y = cons_AV (vec C A) (vec C B) :>AV ->\n image_angle y' = cons_AV (vec C' A') (vec C' B') :>AV ->\n cos x = cos x' :>R ->\n cos y = cos y' :>R ->\n cons_AV (vec B C) (vec B A) = cons_AV (vec B' A') (vec B' C') :>AV /\\\n cons_AV (vec C A) (vec C B) = cons_AV (vec C' A') (vec C' B') :>AV.\n \nLemma cas_egalite_triangle_indirect :\n forall A B C A' B' C' : PO,\n A <> B :>PO ->\n A <> C :>PO ->\n B <> C :>PO ->\n distance A' B' = distance A B :>R ->\n distance A' C' = distance A C :>R ->\n cons_AV (vec A B) (vec A C) = cons_AV (vec A' C') (vec A' B') :>AV ->\n distance B' C' = distance B C :>R /\\\n cons_AV (vec B C) (vec B A) = cons_AV (vec B' A') (vec B' C') :>AV /\\\n cons_AV (vec C A) (vec C B) = cons_AV (vec C' A') (vec C' B') :>AV.\nProof.\nAdmitted." }, { "theorem_id": 71, "title": "095_ptolemy_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/transcendentals.ml\";;\n\nlet DOT_VECTOR = `(vector [x1;y1] :real^2) dot (vector [x2;y2]) = x1 * x2 + y1 * y2`;;\n\nlet DIST_SEGMENT_LEMMA = `!a1 a2. &0 <= a1 /\\ a1 <= a2 /\\ a2 <= &2 * pi /\\ &0 <= radius\n ==> dist(centre + radius % vector [cos(a1);sin(a1)] :real^2,\n centre + radius % vector [cos(a2);sin(a2)]) =\n &2 * radius * sin((a2 - a1) / &2)`;;\n\nlet PTOLEMY = `!A B C D:real^2 a b c d centre radius.\n A = centre + radius % vector [cos(a);sin(a)] /\\\n B = centre + radius % vector [cos(b);sin(b)] /\\\n C = centre + radius % vector [cos(c);sin(c)] /\\\n D = centre + radius % vector [cos(d);sin(d)] /\\\n &0 <= radius /\\\n &0 <= a /\\ a <= b /\\ b <= c /\\ c <= d /\\ d <= &2 * pi\n ==> dist(A,C) * dist(B,D) =\n dist(A,B) * dist(C,D) + dist(A,D) * dist(B,C)`;;" }, { "theorem_id": 71, "title": "095_ptolemy_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Ptolemy's Theorem\\\n\ntheory Ptolemys_Theorem\nimports\n \"HOL-Analysis.Multivariate_Analysis\"\nbegin\n\nsubsection \\Preliminaries\\\n\nsubsubsection \\Additions to Rat theory\\\n\nhide_const (open) normalize\n\nsubsubsection \\Additions to Transcendental theory\\\n\ntext \\\nLemmas about @{const arcsin} and @{const arccos} commonly involve to show that their argument is\nin the domain of those partial functions, i.e., the argument @{term y} is between @{term \"-1::real\"}\nand @{term \"1::real\"}.\nAs the argumentation for @{term \"(-1::real) \\ y\"} and @{term \"y \\ (1::real)\"} is often very similar,\nwe prefer to prove @{term \"\\y\\ \\ (1::real)\"} to the two goals above.\n\nThe lemma for rewriting the term @{term \"cos (arccos y)\"} is already provided in the Isabelle\ndistribution with name @{thm [source] cos_arccos_abs}. Here, we further provide the analogue on\n@{term \"arcsin\"} for rewriting @{term \"sin (arcsin y)\"}.\n\\\n\nlemma sin_arcsin_abs: \"\\y\\ \\ 1 \\ sin (arcsin y) = y\"\n by sorry\n\ntext \\\nThe further lemmas are the required variants from existing lemmas @{thm [source] arccos_lbound}\nand @{thm [source] arccos_ubound}.\n\\\n\nlemma arccos_lbound_abs [simp]:\n \"\\y\\ \\ 1 \\ 0 \\ arccos y\"\n by sorry\n\nlemma arccos_ubound_abs [simp]:\n \"\\y\\ \\ 1 \\ arccos y \\ pi\"\n by sorry\n\ntext \\\nAs we choose angles to be between @{term \"0::real\"} between @{term \"2 * pi\"},\nwe need some lemmas to reason about the sign of @{term \"sin x\"}\nfor angles @{term \"x\"}.\n\\\n\nlemma sin_ge_zero_iff:\n assumes \"0 \\ x\" \"x < 2 * pi\"\n shows \"0 \\ sin x \\ x \\ pi\"\n by sorry\n\nlemma sin_less_zero_iff:\n assumes \"0 \\ x\" \"x < 2 * pi\"\n shows \"sin x < 0 \\ pi < x\"\n by sorry\n\nsubsubsection \\Addition to Finite-Cartesian-Product theory\\\n\ntext \\\nHere follow generally useful additions and specialised equations\nfor two-dimensional real-valued vectors.\n\\\n\nlemma axis_nth_eq_0 [simp]:\n assumes \"i \\ j\"\n shows \"axis i x $ j = 0\"\n by sorry\n\nlemma norm_axis:\n fixes x :: real\n shows \"norm (axis i x) = abs x\"\n by sorry\n\nlemma norm_eq_on_real_2_vec:\n fixes x :: \"real ^ 2\"\n shows \"norm x = sqrt ((x $ 1) ^ 2 + (x $ 2) ^ 2)\"\n by sorry\n\nlemma dist_eq_on_real_2_vec:\n fixes a b :: \"real ^ 2\"\n shows \"dist a b = sqrt ((a $ 1 - b $ 1) ^ 2 + (a $ 2 - b $ 2) ^ 2)\"\n by sorry\n\nsubsection \\Polar Form of Two-Dimensional Real-Valued Vectors\\\n\nsubsubsection \\Definitions to Transfer to Polar Form and Back\\\n\ndefinition of_radiant :: \"real \\ real ^ 2\"\nwhere\n \"of_radiant \\ = axis 1 (cos \\) + axis 2 (sin \\)\"\n\ndefinition normalize :: \"real ^ 2 \\ real ^ 2\"\nwhere\n \"normalize p = (if p = 0 then axis 1 1 else (1 / norm p) *\\<^sub>R p)\"\n\ndefinition radiant_of :: \"real ^ 2 \\ real\"\nwhere\n \"radiant_of p = (THE \\. 0 \\ \\ \\ \\ < 2 * pi \\ of_radiant \\ = normalize p)\"\n\ntext \\\nThe vector @{term \"of_radiant \\\"} is the vector with length @{term \"1::real\"} and angle @{term \"\\\"}\nto the first axis.\nWe normalize vectors to length @{term \"1::real\"} keeping their orientation with the normalize function.\nConversely, @{term \"radiant_of p\"} is the angle of vector @{term p} to the first axis, where we\nchoose @{term \"radiant_of\"} to return angles between @{term \"0::real\"} and @{term \"2 * pi\"},\nfollowing the usual high-school convention.\nWith these definitions, we can express the main result\n@{term \"norm p *\\<^sub>R of_radiant (radiant_of p) = p\"}.\nNote that the main result holds for any definition of @{term \"radiant_of 0\"}.\nSo, we choose to define @{term \"normalize 0\"} and @{term \"radiant_of 0\"}, such that\n@{term \"radiant_of 0 = 0\"}.\n\\\n\nsubsubsection \\Lemmas on @{const of_radiant}\\\n\nlemma nth_of_radiant_1 [simp]:\n \"of_radiant \\ $ 1 = cos \\\"\n by sorry\n\nlemma nth_of_radiant_2 [simp]:\n \"of_radiant \\ $ 2 = sin \\\"\n by sorry\n\nlemma norm_of_radiant:\n \"norm (of_radiant \\) = 1\"\n by sorry\n\nlemma of_radiant_plus_2pi:\n \"of_radiant (\\ + 2 * pi) = of_radiant \\\"\n by sorry\n\nlemma of_radiant_minus_2pi:\n \"of_radiant (\\ - 2 * pi) = of_radiant \\\"\n by sorry\n\nsubsubsection \\Lemmas on @{const normalize}\\\n\nlemma normalize_eq:\n \"norm p *\\<^sub>R normalize p = p\"\n by sorry\n\nlemma norm_normalize:\n \"norm (normalize p) = 1\"\n by sorry\n\nlemma nth_normalize [simp]:\n \"\\normalize p $ i\\ \\ 1\"\n by sorry\n\nlemma normalize_square:\n \"(normalize p $ 1)\\<^sup>2 + (normalize p $ 2)\\<^sup>2 = 1\"\n by sorry\n\nlemma nth_normalize_ge_zero_iff:\n \"0 \\ normalize p $ i \\ 0 \\ p $ i\"\n by sorry\n\nlemma nth_normalize_less_zero_iff:\n \"normalize p $ i < 0 \\ p $ i < 0\"\n by sorry\n\nlemma normalize_boundary_iff:\n \"\\normalize p $ 1\\ = 1 \\ p $ 2 = 0\"\n by sorry\n\nlemma between_normalize_if_distant_from_0:\n assumes \"norm p \\ 1\"\n shows \"between (0, p) (normalize p)\"\n by sorry\n\nlemma between_normalize_if_near_0:\n assumes \"norm p \\ 1\"\n shows \"between (0, normalize p) p\"\n by sorry\n\nsubsubsection \\Lemmas on @{const radiant_of}\\\n\nlemma radiant_of:\n \"0 \\ radiant_of p \\ radiant_of p < 2 * pi \\ of_radiant (radiant_of p) = normalize p\"\n by sorry\n\nlemma radiant_of_bounds [simp]:\n \"0 \\ radiant_of p\" \"radiant_of p < 2 * pi\"\n by sorry\n\nlemma radiant_of_weak_ubound [simp]:\n \"radiant_of p \\ 2 * pi\"\n by sorry\n\nsubsubsection \\Main Equations for Transforming to Polar Form\\\n\nlemma polar_form_eq:\n \"norm p *\\<^sub>R of_radiant (radiant_of p) = p\"\n by sorry\n\nlemma relative_polar_form_eq:\n \"Q + dist P Q *\\<^sub>R of_radiant (radiant_of (P - Q)) = P\"\n by sorry\n\nsubsection \\Ptolemy's Theorem\\\n\nlemma dist_circle_segment:\n assumes \"0 \\ radius\" \"0 \\ \\\" \"\\ \\ \\\" \"\\ \\ 2 * pi\"\n shows \"dist (center + radius *\\<^sub>R of_radiant \\) (center + radius *\\<^sub>R of_radiant \\) = 2 * radius * sin ((\\ - \\) / 2)\"\n (is \"?lhs = ?rhs\")\n by sorry\n\ntheorem ptolemy_trigonometric:\n fixes \\\\<^sub>1 \\\\<^sub>2 \\\\<^sub>3 :: real\n shows \"sin (\\\\<^sub>1 + \\\\<^sub>2) * sin (\\\\<^sub>2 + \\\\<^sub>3) = sin \\\\<^sub>1 * sin \\\\<^sub>3 + sin \\\\<^sub>2 * sin (\\\\<^sub>1 + \\\\<^sub>2 + \\\\<^sub>3)\"\n by sorry\n\ntheorem ptolemy:\n fixes A B C D center :: \"real ^ 2\"\n assumes \"dist center A = radius\" and \"dist center B = radius\"\n assumes \"dist center C = radius\" and \"dist center D = radius\"\n assumes ordering_of_points:\n \"radiant_of (A - center) \\ radiant_of (B - center)\"\n \"radiant_of (B - center) \\ radiant_of (C - center)\"\n \"radiant_of (C - center) \\ radiant_of (D - center)\"\n shows \"dist A C * dist B D = dist A B * dist C D + dist A D * dist B C\"\n by sorry\n\nend" }, { "theorem_id": 71, "title": "095_ptolemy_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2021 Manuel Candales. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Manuel Candales, Benjamin Davidson\n-/\nmodule\n\npublic import Mathlib.Geometry.Euclidean.Sphere.Power\npublic import Mathlib.Geometry.Euclidean.Triangle\n\n/-!\n# Ptolemy's theorem\n\nThis file proves Ptolemy's theorem on the lengths of the diagonals and sides of a cyclic\nquadrilateral.\n\n## Main theorems\n\n* `mul_dist_add_mul_dist_eq_mul_dist_of_cospherical`: Ptolemy’s Theorem (Freek No. 95).\n\nTODO: The current statement of Ptolemy’s theorem works around the lack of a \"cyclic polygon\" concept\nin mathlib, which is what the theorem statement would naturally use (or two such concepts, since\nboth a strict version, where all vertices must be distinct, and a weak version, where consecutive\nvertices may be equal, would be useful; Ptolemy's theorem should then use the weak one).\n\nAn API needs to be built around that concept, which would include:\n- strict cyclic implies weak cyclic,\n- weak cyclic and consecutive points distinct implies strict cyclic,\n- weak/strict cyclic implies weak/strict cyclic for any subsequence,\n- any three points on a sphere are weakly or strictly cyclic according to whether they are distinct,\n- any number of points on a sphere intersected with a two-dimensional affine subspace are cyclic in\n some order,\n- a list of points is cyclic if and only if its reversal is,\n- a list of points is cyclic if and only if any cyclic permutation is, while other permutations\n are not when the points are distinct,\n- a point P where the diagonals of a cyclic polygon cross exists (and is unique) with weak/strict\n betweenness depending on weak/strict cyclicity,\n- four points on a sphere with such a point P are cyclic in the appropriate order,\n\nand so on.\n-/\n\npublic section\n\n\nopen Real\n\nopen scoped EuclideanGeometry RealInnerProductSpace Real\n\nnamespace EuclideanGeometry\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]\nvariable {P : Type*} [MetricSpace P] [NormedAddTorsor V P]\n\n/-- **Ptolemy’s Theorem**. -/\ntheorem mul_dist_add_mul_dist_eq_mul_dist_of_cospherical {a b c d p : P}\n (h : Cospherical ({a, b, c, d} : Set P)) (hapc : ∠ a p c = π) (hbpd : ∠ b p d = π) :\n dist a b * dist c d + dist b c * dist d a = dist a c * dist b d := by sorry\nend EuclideanGeometry\n" }, { "theorem_id": 71, "title": "095_ptolemy_s_theorem", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From HighSchoolGeometry Require Export triangles_semblables.\nFrom HighSchoolGeometry Require Export orientation.\n\nLemma EntreDeuxVec_sym :\nforall (A B C M N :PO),\n vecEntreDeuxVec A B C M -> A<>N->\n cons_AV ( vec A B) (vec A M) = cons_AV (vec A N) (vec A C) ->\n vecEntreDeuxVec A B C N.\nProof.\nAdmitted.\n\nLemma EntreDeuxPoint :\nforall ( A B M :PO),\n positifColineaire A B M -> positifColineaire B A M -> distance A B = distance A M + distance M B.\nProof.\nAdmitted.\n\nFrom HighSchoolGeometry Require Export Droite_espace.\n\nLemma Exists_Intersection1 : \nforall (A B C D :PO),\n vecEntreDeuxVec A B C D ->\n exists E :PO, alignes A D E /\\ alignes B C E.\nProof.\nAdmitted.\n\nLemma angles_representants_unitaires_r :\n\n forall A B C D E F : PO,\n A <> B ->\n C <> D ->\n cons_AV (vec A B) (vec C D) =\n cons_AV (vec A B)\n (representant_unitaire (vec C D)).\nProof.\nAdmitted.\n\nLemma angles_representants_unitaires2 :\n\n forall A B C D E F : PO,\n A <> B ->\n C <> D ->\n cons_AV (vec A B) (vec C D) =\n cons_AV (representant_unitaire (vec A B)) (vec C D).\nProof.\nAdmitted.\n\nLemma Exists_Intersection :\nforall (A B C D :PO),\n vecEntreDeuxVec A B C D ->\n exists E :PO, cons_AV ( vec A B) (vec A E) = cons_AV (vec A D) (vec A C)\n /\\ positifColineaire B C E /\\ positifColineaire C B E.\nProof.\nAdmitted.\n\nLtac deroule_sont_cocycliques :=\n match goal with H : sont_cocycliques ?A ?B ?C ?D|- _ =>\n generalize H ; let name := fresh in intros name ;\n unfold sont_cocycliques in name;\n destruct name ;decompose [and] name; clear name;\n repeat match goal with H' : circonscrit ?O ?A ?B ?C |- _ =>\n unfold circonscrit in H';\n decompose [and] H' ; clear H' end ;\n repeat match goal with H' : isocele ?O ?A ?B |- _ =>\n unfold isocele in H'\n end\nend.\n\nLemma sont_cocycliques_avec_ordre_cycle:\nforall (A B C D :PO),\n sont_cocycliques A B C D ->sont_cocycliques B C D A.\nProof.\nAdmitted.\n\nLemma sont_cocycliques_avec_ordre_permute:\nforall (A B C D :PO),\n sont_cocycliques A B C D ->sont_cocycliques A B D C.\nProof.\nAdmitted.\n\nTheorem Ptolemee:\nforall (A B C D : PO),\n orient A B C -> orient A B D -> orient C D A -> orient C D B ->\n sont_cocycliques A B C D ->\n (distance A B * distance C D ) + (distance B C *distance D A) =\n distance A C * distance B D.\nProof.\nAdmitted." }, { "theorem_id": 72, "title": "096_principle_of_inclusion___exclusion", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "let SUBSET_INSERT_EXISTS = `!s x:A t. s SUBSET (x INSERT t) <=>\n s SUBSET t \\/ ?u. u SUBSET t /\\ s = x INSERT u`;;\n\nlet FINITE_SUBSETS_RESTRICT = `!s:A->bool p. FINITE s ==> FINITE {t | t SUBSET s /\\ p t}`;;\n\nlet INCLUSION_EXCLUSION_REAL_RESTRICTED_INDEXED = `!P (f:(A->bool)->real) (A:I->bool) (x:I->(A->bool)).\n (!s t. P s /\\ P t /\\ DISJOINT s t\n ==> f(s UNION t) = f(s) + f(t)) /\\\n P {} /\\\n (!s t. P s /\\ P t ==> P(s INTER t) /\\ P(s UNION t) /\\ P(s DIFF t)) /\\\n FINITE A /\\ (!a. a IN A ==> P(x a))\n ==> f(UNIONS(IMAGE x A)) =\n sum {B | B SUBSET A /\\ ~(B = {})}\n (\\B. (-- &1) pow (CARD B + 1) * f(INTERS(IMAGE x B)))`;;\n\nlet INCLUSION_EXCLUSION_REAL_RESTRICTED = `!P (f:(A->bool)->real) (A:(A->bool)->bool).\n (!s t. P s /\\ P t /\\ DISJOINT s t\n ==> f(s UNION t) = f(s) + f(t)) /\\\n P {} /\\\n (!s t. P s /\\ P t ==> P(s INTER t) /\\ P(s UNION t) /\\ P(s DIFF t)) /\\\n FINITE A /\\ (!a. a IN A ==> P(a))\n ==> f(UNIONS A) =\n sum {B | B SUBSET A /\\ ~(B = {})}\n (\\B. (-- &1) pow (CARD B + 1) * f(INTERS B))`;;\n\nlet INCLUSION_EXCLUSION_REAL_INDEXED = `!(f:(A->bool)->real) (A:I->bool) (x:I->(A->bool)).\n (!s t. DISJOINT s t ==> f(s UNION t) = f(s) + f(t)) /\\ FINITE A\n ==> f(UNIONS(IMAGE x A)) =\n sum {B | B SUBSET A /\\ ~(B = {})}\n (\\B. (-- &1) pow (CARD B + 1) * f(INTERS(IMAGE x B)))`;;\n\nlet INCLUSION_EXCLUSION_REAL = `!(f:(A->bool)->real) (A:(A->bool)->bool).\n (!s t. DISJOINT s t ==> f(s UNION t) = f(s) + f(t)) /\\ FINITE A\n ==> f(UNIONS A) =\n sum {B | B SUBSET A /\\ ~(B = {})}\n (\\B. (-- &1) pow (CARD B + 1) * f(INTERS B))`;;\n\nlet INCLUSION_EXCLUSION = `!s:(A->bool)->bool.\n FINITE s /\\ (!k. k IN s ==> FINITE k)\n ==> &(CARD(UNIONS s)) =\n sum {t | t SUBSET s /\\ ~(t = {})}\n (\\t. (-- &1) pow (CARD t + 1) * &(CARD(INTERS t)))`;;\n\nlet INCLUSION_EXCLUSION_USUAL = `!s:(A->bool)->bool.\n FINITE s /\\ (!k. k IN s ==> FINITE k)\n ==> &(CARD(UNIONS s)) =\n sum (1..CARD s) (\\n. (-- &1) pow (n + 1) *\n sum {t | t SUBSET s /\\ t HAS_SIZE n}\n (\\t. &(CARD(INTERS t))))`;;\n\nlet FINITE_SUBSETS_RESTRICT = `!s:A->bool p. FINITE s ==> FINITE {t | t SUBSET s /\\ p t}`;;\n\nlet CARD_ADJUST_LEMMA = `!f:A->B s x y.\n FINITE s /\\\n (!x y. x IN s /\\ y IN s /\\ f x = f y ==> x = y) /\\\n x = y + CARD (IMAGE f s)\n ==> x = y + CARD s`;;\n\nlet CARD_SUBSETS_STEP = `!x:A s. FINITE s /\\ ~(x IN s) /\\ u SUBSET s\n ==> CARD {t | t SUBSET (x INSERT s) /\\ u SUBSET t /\\ ODD(CARD t)} =\n CARD {t | t SUBSET s /\\ u SUBSET t /\\ ODD(CARD t)} +\n CARD {t | t SUBSET s /\\ u SUBSET t /\\ EVEN(CARD t)} /\\\n CARD {t | t SUBSET (x INSERT s) /\\ u SUBSET t /\\ EVEN(CARD t)} =\n CARD {t | t SUBSET s /\\ u SUBSET t /\\ EVEN(CARD t)} +\n CARD {t | t SUBSET s /\\ u SUBSET t /\\ ODD(CARD t)}`;;\n\nlet CARD_SUBSUPERSETS_EVEN_ODD = `!s u:A->bool.\n FINITE u /\\ s PSUBSET u\n ==> CARD {t | s SUBSET t /\\ t SUBSET u /\\ EVEN(CARD t)} =\n CARD {t | s SUBSET t /\\ t SUBSET u /\\ ODD(CARD t)}`;;\n\nlet SUM_ALTERNATING_CANCELS = `!s:A->bool f.\n FINITE s /\\\n CARD {x | x IN s /\\ EVEN(f x)} = CARD {x | x IN s /\\ ODD(f x)}\n ==> sum s (\\x. (-- &1) pow (f x)) = &0`;;\n\nlet INCLUSION_EXCLUSION_SYMMETRIC = `!f g:(A->bool)->real.\n (!s. FINITE s\n ==> g(s) = sum {t | t SUBSET s} (\\t. (-- &1) pow (CARD t) * f(t)))\n ==> !s. FINITE s\n ==> f(s) = sum {t | t SUBSET s} (\\t. (-- &1) pow (CARD t) * g(t))`;;\n\nlet INCLUSION_EXCLUSION_MOBIUS = `!f g:(A->bool)->real.\n (!s. FINITE s ==> g(s) = sum {t | t SUBSET s} f)\n ==> !s. FINITE s\n ==> f(s) = sum {t | t SUBSET s}\n (\\t. (-- &1) pow (CARD s - CARD t) * g(t))`;;" }, { "theorem_id": 72, "title": "096_principle_of_inclusion___exclusion", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "\nsection \\Basic combinatorics in Isabelle/HOL (and the Archive of Formal Proofs)\\\n\ntheory Combinatorics\nimports\n Transposition\n Stirling\n Permutations\n List_Permutation\n Multiset_Permutations\n Cycles\n Perm\n Orbits\nbegin\n\nend\n" }, { "theorem_id": 72, "title": "096_principle_of_inclusion___exclusion", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2024 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nmodule\n\npublic import Mathlib.Algebra.BigOperators.Pi\npublic import Mathlib.Algebra.BigOperators.Ring.Finset\npublic import Mathlib.Algebra.Module.BigOperators\n\n/-!\n# Inclusion-exclusion principle\n\nThis file proves several variants of the inclusion-exclusion principle.\n\nThe inclusion-exclusion principle says that the sum/integral of a function over a finite union of\nsets can be calculated as the alternating sum over `n > 0` of the sum/integral of the function over\nthe intersection of `n` of the sets.\n\nBy taking complements, it also says that the sum/integral of a function over a finite intersection\nof complements of sets can be calculated as the alternating sum over `n ≥ 0` of the sum/integral of\nthe function over the intersection of `n` of the sets.\n\nBy taking the function to be constant `1`, we instead get a result about the cardinality/measure of\nthe sets.\n\n## Main declarations\n\nPer the above explanation, this file contains the following variants of inclusion-exclusion:\n* `Finset.inclusion_exclusion_sum_biUnion`: Sum of a function over a finite union of sets\n* `Finset.inclusion_exclusion_card_biUnion`: Cardinality of a finite union of sets\n* `Finset.inclusion_exclusion_sum_inf_compl`: Sum of a function over a finite intersection of\n complements of sets\n* `Finset.inclusion_exclusion_card_inf_compl`: Cardinality of a finite intersection of\n complements of sets\n\nSee also `MeasureTheory.integral_biUnion_eq_sum_powerset` for the version with integrals, and\n`MeasureTheory.measureReal_biUnion_eq_sum_powerset` for the version with measures.\n\n## TODO\n\n* Prove that truncating the series alternatively gives an upper/lower bound to the true value.\n-/\n\npublic section\n\nassert_not_exists Field\n\nnamespace Finset\nvariable {ι α G : Type*} [AddCommGroup G] {s : Finset ι}\n\nlemma prod_indicator_biUnion_sub_indicator (hs : s.Nonempty) (S : ι → Set α) (a : α) :\n ∏ i ∈ s, (Set.indicator (⋃ i ∈ s, S i) 1 a - Set.indicator (S i) 1 a) = (0 : ℤ) := by sorry\nlemma indicator_biUnion_eq_sum_powerset (s : Finset ι) (S : ι → Set α) (f : α → G) (a : α) :\n Set.indicator (⋃ i ∈ s, S i) f a = ∑ t ∈ s.powerset with t.Nonempty,\n (-1) ^ (#t + 1) • Set.indicator (⋂ i ∈ t, S i) f a := by sorry\nvariable [DecidableEq α]\n\nlemma prod_indicator_biUnion_finset_sub_indicator (hs : s.Nonempty) (S : ι → Finset α) (a : α) :\n ∏ i ∈ s, (Set.indicator (s.biUnion S) 1 a - Set.indicator (S i) 1 a) = (0 : ℤ) := by sorry\ntheorem inclusion_exclusion_sum_biUnion (s : Finset ι) (S : ι → Finset α) (f : α → G) :\n ∑ a ∈ s.biUnion S, f a = ∑ t : s.powerset.filter (·.Nonempty),\n (-1) ^ (#t.1 + 1) • ∑ a ∈ t.1.inf' (mem_filter.1 t.2).2 S, f a := by sorry\ntheorem inclusion_exclusion_card_biUnion (s : Finset ι) (S : ι → Finset α) :\n #(s.biUnion S) = ∑ t : s.powerset.filter (·.Nonempty),\n (-1 : ℤ) ^ (#t.1 + 1) * #(t.1.inf' (mem_filter.1 t.2).2 S) := by sorry\nvariable [Fintype α]\n\n/-- **Inclusion-exclusion principle** for the sum of a function over an intersection of complements.\n\nThe sum of a function `f` over the intersection of the complements of the `S i` over `i ∈ s` is the\nalternating sum of the sums of `f` over the intersections of the `S i`. -/\ntheorem inclusion_exclusion_sum_inf_compl (s : Finset ι) (S : ι → Finset α) (f : α → G) :\n ∑ a ∈ s.inf fun i ↦ (S i)ᶜ, f a = ∑ t ∈ s.powerset, (-1) ^ #t • ∑ a ∈ t.inf S, f a := by sorry\ntheorem inclusion_exclusion_card_inf_compl (s : Finset ι) (S : ι → Finset α) :\n #(s.inf fun i ↦ (S i)ᶜ) = ∑ t ∈ s.powerset, (-1 : ℤ) ^ #t * #(t.inf S) := by sorry\nend Finset\n" }, { "theorem_id": 72, "title": "096_principle_of_inclusion___exclusion", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "Require Import Lists.List.\nRequire Import ZArith.\nRequire Import Setoid.\nRequire Import Coq.Classes.Morphisms.\nRequire Import Lia.\n\nOpen Scope Z_scope.\nImport ListNotations.\n\nSection InclusionExclusion.\n\nVariable X : Set.\nVariable enum_X : list X.\n\nDefinition set := X -> bool.\n\nDefinition cardinal (A : set) := Z.of_nat (length (filter A enum_X)).\n\nDefinition empty_set : set := fun _ => false.\n\nDefinition binary_union (A B : set) x := orb (A x) (B x).\n\nDefinition binary_intersection (A B : set) x := andb (A x) (B x).\n\nInfix \" ∪ \" := binary_union (at level 50).\n\nInfix \" ∩ \" := binary_intersection (at level 50).\n\nNotation \" # \" := cardinal.\n\nLemma cardinal_union_lemma A B : # (A ∪ B) = # A + # B - # (A ∩ B).\nProof.\nAdmitted.\n\nInstance intersection_morphism :\n Proper (set_eq ==> set_eq ==> set_eq) binary_intersection | 10.\nProof.\nAdmitted.\n\nInstance cardinal_morphism :\n Proper (set_eq ==> @eq Z) cardinal | 10.\nProof.\nAdmitted.\n\nLemma cardinal_set_eq (A B : set) : A == B -> # A = # B.\nProof.\nAdmitted.\n\nLtac iftac :=\n let x := fresh \"x\" in\n intro x; compute;\n repeat\n match goal with\n |- context [ if ?b x then _ else _] => destruct b\n end; try reflexivity.\n\nLtac Rewrite H :=\n let E := fresh \"E\" in\n assert (E : H) by iftac; rewrite E; clear E.\n\nLemma cardinal_ternary_union A B C :\n # (A ∪ B ∪ C) = # A + # B + # C - # (A ∩ B) - #(B ∩ C) - # (C ∩ A) + #(A ∩ B ∩ C).\nProof.\nAdmitted.\n\nFixpoint sublists {A} (xs : list A) : list (list A) :=\n match xs with\n | nil => [[]]\n | x :: xs =>\n let xss := sublists xs in\n xss ++ (map (fun l => x :: l)) xss\n end.\n\nDefinition nonempty {A} (xs : list A) :=\n match xs with\n [] => false\n | _ :: _ => true\n end.\n\nFixpoint sum l :=\n match l with\n | nil => 0\n | x :: l => x + sum l\n end.\n\nFixpoint alternating_sign n :=\n match n with\n | O => 1\n | S n => - alternating_sign n\n end.\n\nLemma cardinal_empty : cardinal empty_set = 0.\nProof.\nAdmitted.\n\nLemma sum_app l1 l2 : sum (l1 ++ l2) = sum l1 + sum l2.\nProof.\nAdmitted.\n\nLemma filter_app {A} f (l1 l2 : list A) :\n filter f (l1 ++ l2) = filter f l1 ++ filter f l2.\nProof.\nAdmitted.\n\nLemma filter_map_always {A B} f (g : A -> B) l :\n (forall x, f (g x) = true) ->\n filter f (map g l) = map g l.\nProof.\nAdmitted.\n\nLemma sublists_proper {A} (l : list A) :\n sublists l = [] :: filter nonempty (sublists l).\nProof.\nAdmitted.\n\nLemma sublists_map {A B} (f : A -> B) l :\n sublists (map f l) = map (map f) (sublists l).\nProof.\nAdmitted.\n\nTheorem inclusion_exclusion (l : list set) :\n cardinal (list_union l) =\n sum\n (map (fun l' => cardinal (list_intersection l') *\n alternating_sign (1 + length l'))\n (filter nonempty (sublists l))).\nProof.\nAdmitted.\n\nEnd InclusionExclusion.\n\nArguments list_union [X].\nArguments list_intersection [X].\nArguments cardinal [X] [enum_X]." }, { "theorem_id": 73, "title": "097_cramer_s_rule", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Multivariate/vectors.ml\";;\nneeds \"Library/permutations.ml\";;\nneeds \"Library/floor.ml\";;\nneeds \"Library/products.ml\";;\n\nprioritize_real();;\n\nlet trace = new_definition\n `(trace:real^N^N->real) A = sum(1..dimindex(:N)) (\\i. A$i$i)`;;\n\nlet TRACE_0 = `trace(mat 0) = &0`;;\n\nlet TRACE_I = `trace(mat 1 :real^N^N) = &(dimindex(:N))`;;\n\nlet TRACE_ADD = `!A B:real^N^N. trace(A + B) = trace(A) + trace(B)`;;\n\nlet TRACE_SUB = `!A B:real^N^N. trace(A - B) = trace(A) - trace(B)`;;\n\nlet TRACE_CMUL = `!c A:real^N^N. trace(c %% A) = c * trace A`;;\n\nlet TRACE_NEG = `!A:real^N^N. trace(--A) = --(trace A)`;;\n\nlet TRACE_MUL_SYM = `!A B:real^N^M. trace(A ** B) = trace(B ** A)`;;\n\nlet TRACE_TRANSP = `!A:real^N^N. trace(transp A) = trace A`;;\n\nlet TRACE_SIMILAR = `!A:real^N^N U:real^N^N.\n invertible U ==> trace(matrix_inv U ** A ** U) = trace A`;;\n\nlet TRACE_MUL_CYCLIC = `!A:real^P^M B C:real^M^N. trace(A ** B ** C) = trace(B ** C ** A)`;;\n\nlet det = new_definition\n `det(A:real^N^N) =\n sum { p | p permutes 1..dimindex(:N) }\n (\\p. sign(p) * product (1..dimindex(:N)) (\\i. A$i$(p i)))`;;\n\nlet IN_DIMINDEX_SWAP = `!m n j. 1 <= m /\\ m <= dimindex(:N) /\\\n 1 <= n /\\ n <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> 1 <= swap(m,n) j /\\ swap(m,n) j <= dimindex(:N)`;;\n\nlet LAMBDA_BETA_PERM = `!p i. p permutes 1..dimindex(:N) /\\ 1 <= i /\\ i <= dimindex(:N)\n ==> ((lambda) g :A^N) $ p(i) = g(p i)`;;\n\nlet PRODUCT_PERMUTE = `!f p s. p permutes s ==> product s f = product s (f o p)`;;\n\nlet PRODUCT_PERMUTE_NUMSEG = `!f p m n. p permutes m..n ==> product(m..n) f = product(m..n) (f o p)`;;\n\nlet REAL_MUL_SUM = `!s t f g.\n FINITE s /\\ FINITE t\n ==> sum s f * sum t g = sum s (\\i. sum t (\\j. f(i) * g(j)))`;;\n\nlet REAL_MUL_SUM_NUMSEG = `!m n p q. sum(m..n) f * sum(p..q) g =\n sum(m..n) (\\i. sum(p..q) (\\j. f(i) * g(j)))`;;\n\nlet DET_CMUL = `!A:real^N^N c. det(c %% A) = c pow dimindex(:N) * det A`;;\n\nlet DET_NEG = `!A:real^N^N. det(--A) = --(&1) pow dimindex(:N) * det A`;;\n\nlet DET_TRANSP = `!A:real^N^N. det(transp A) = det A`;;\n\nlet DET_LOWERTRIANGULAR = `!A:real^N^N.\n (!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\ i < j ==> A$i$j = &0)\n ==> det(A) = product(1..dimindex(:N)) (\\i. A$i$i)`;;\n\nlet DET_UPPERTRIANGULAR = `!A:real^N^N.\n (!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\ j < i ==> A$i$j = &0)\n ==> det(A) = product(1..dimindex(:N)) (\\i. A$i$i)`;;\n\nlet DET_I = `det(mat 1 :real^N^N) = &1`;;\n\nlet DET_0 = `det(mat 0 :real^N^N) = &0`;;\n\nlet DET_PERMUTE_ROWS = `!A:real^N^N p.\n p permutes 1..dimindex(:N)\n ==> det(lambda i. A$p(i)) = sign(p) * det(A)`;;\n\nlet DET_PERMUTE_COLUMNS = `!A:real^N^N p.\n p permutes 1..dimindex(:N)\n ==> det((lambda i j. A$i$p(j)):real^N^N) = sign(p) * det(A)`;;\n\nlet DET_IDENTICAL_ROWS = `!A:real^N^N i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\ ~(i = j) /\\\n row i A = row j A\n ==> det A = &0`;;\n\nlet DET_IDENTICAL_COLUMNS = `!A:real^N^N i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\ ~(i = j) /\\\n column i A = column j A\n ==> det A = &0`;;\n\nlet DET_ZERO_ROW = `!A:real^N^N i.\n 1 <= i /\\ i <= dimindex(:N) /\\ row i A = vec 0 ==> det A = &0`;;\n\nlet DET_ZERO_COLUMN = `!A:real^N^N i.\n 1 <= i /\\ i <= dimindex(:N) /\\ column i A = vec 0 ==> det A = &0`;;\n\nlet DET_ROW_ADD = `!a b c k.\n 1 <= k /\\ k <= dimindex(:N)\n ==> det((lambda i. if i = k then a + b else c i):real^N^N) =\n det((lambda i. if i = k then a else c i):real^N^N) +\n det((lambda i. if i = k then b else c i):real^N^N)`;;\n\nlet DET_ROW_MUL = `!a b c k.\n 1 <= k /\\ k <= dimindex(:N)\n ==> det((lambda i. if i = k then c % a else b i):real^N^N) =\n c * det((lambda i. if i = k then a else b i):real^N^N)`;;\n\nlet DET_ROW_OPERATION = `!A:real^N^N i.\n 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\ ~(i = j)\n ==> det(lambda k. if k = i then row i A + c % row j A else row k A) =\n det A`;;\n\nlet DET_ROW_SPAN = `!A:real^N^N i x.\n 1 <= i /\\ i <= dimindex(:N) /\\\n x IN span {row j A | 1 <= j /\\ j <= dimindex(:N) /\\ ~(j = i)}\n ==> det(lambda k. if k = i then row i A + x else row k A) =\n det A`;;\n\nlet DET_DEPENDENT_ROWS = `!A:real^N^N. dependent(rows A) ==> det A = &0`;;\n\nlet DET_DEPENDENT_COLUMNS = `!A:real^N^N. dependent(columns A) ==> det A = &0`;;\n\nlet DET_LINEAR_ROW_VSUM = `!a c s k.\n FINITE s /\\ 1 <= k /\\ k <= dimindex(:N)\n ==> det((lambda i. if i = k then vsum s a else c i):real^N^N) =\n sum s\n (\\j. det((lambda i. if i = k then a(j) else c i):real^N^N))`;;\n\nlet BOUNDED_FUNCTIONS_BIJECTIONS_1 = `!p. p IN {(y,g) | y IN s /\\\n g IN {f | (!i. 1 <= i /\\ i <= k ==> f i IN s) /\\\n (!i. ~(1 <= i /\\ i <= k) ==> f i = i)}}\n ==> (\\(y,g) i. if i = SUC k then y else g(i)) p IN\n {f | (!i. 1 <= i /\\ i <= SUC k ==> f i IN s) /\\\n (!i. ~(1 <= i /\\ i <= SUC k) ==> f i = i)} /\\\n (\\h. h(SUC k),(\\i. if i = SUC k then i else h(i)))\n ((\\(y,g) i. if i = SUC k then y else g(i)) p) = p`;;\n\nlet BOUNDED_FUNCTIONS_BIJECTIONS_2 = `!h. h IN {f | (!i. 1 <= i /\\ i <= SUC k ==> f i IN s) /\\\n (!i. ~(1 <= i /\\ i <= SUC k) ==> f i = i)}\n ==> (\\h. h(SUC k),(\\i. if i = SUC k then i else h(i))) h IN\n {(y,g) | y IN s /\\\n g IN {f | (!i. 1 <= i /\\ i <= k ==> f i IN s) /\\\n (!i. ~(1 <= i /\\ i <= k) ==> f i = i)}} /\\\n (\\(y,g) i. if i = SUC k then y else g(i))\n ((\\h. h(SUC k),(\\i. if i = SUC k then i else h(i))) h) = h`;;\n\nlet FINITE_BOUNDED_FUNCTIONS = `!s k. FINITE s\n ==> FINITE {f | (!i. 1 <= i /\\ i <= k ==> f(i) IN s) /\\\n (!i. ~(1 <= i /\\ i <= k) ==> f(i) = i)}`;;\n\nlet DET_LINEAR_ROWS_VSUM_LEMMA = `!s k a c.\n FINITE s /\\ k <= dimindex(:N)\n ==> det((lambda i. if i <= k then vsum s (a i) else c i):real^N^N) =\n sum {f | (!i. 1 <= i /\\ i <= k ==> f(i) IN s) /\\\n !i. ~(1 <= i /\\ i <= k) ==> f(i) = i}\n (\\f. det((lambda i. if i <= k then a i (f i) else c i)\n :real^N^N))`;;\n\nlet DET_LINEAR_ROWS_VSUM = `!s a.\n FINITE s\n ==> det((lambda i. vsum s (a i)):real^N^N) =\n sum {f | (!i. 1 <= i /\\ i <= dimindex(:N) ==> f(i) IN s) /\\\n !i. ~(1 <= i /\\ i <= dimindex(:N)) ==> f(i) = i}\n (\\f. det((lambda i. a i (f i)):real^N^N))`;;\n\nlet MATRIX_MUL_VSUM_ALT = `!A:real^N^N B:real^N^N. A ** B =\n lambda i. vsum (1..dimindex(:N)) (\\k. A$i$k % B$k)`;;\n\nlet DET_ROWS_MUL = `!a c. det((lambda i. c(i) % a(i)):real^N^N) =\n product(1..dimindex(:N)) (\\i. c(i)) *\n det((lambda i. a(i)):real^N^N)`;;\n\nlet DET_MUL = `!A B:real^N^N. det(A ** B) = det(A) * det(B)`;;\n\nlet DET_LINEAR_ROWS = `!f:real^N->real^N A:real^N^N.\n linear f ==> det(lambda i. f(A$i)) = det(matrix f) * det A`;;\n\nlet INVERTIBLE_DET_NZ = `!A:real^N^N. invertible(A) <=> ~(det A = &0)`;;\n\nlet DET_EQ_0 = `!A:real^N^N. det(A) = &0 <=> ~invertible(A)`;;\n\nlet DET_MATRIX_INV = `!A:real^N^N. det(matrix_inv A) = inv(det A)`;;\n\nlet MATRIX_MUL_LINV = `!A:real^N^N. ~(det A = &0) ==> matrix_inv A ** A = mat 1`;;\n\nlet MATRIX_MUL_RINV = `!A:real^N^N. ~(det A = &0) ==> A ** matrix_inv A = mat 1`;;\n\nlet DET_MATRIX_EQ_0 = `!f:real^N->real^N.\n linear f\n ==> (det(matrix f) = &0 <=>\n ~(?g. linear g /\\ f o g = I /\\ g o f = I))`;;\n\nlet DET_MATRIX_EQ_0_LEFT = `!f:real^N->real^N.\n linear f\n ==> (det(matrix f) = &0 <=>\n ~(?g. linear g /\\ g o f = I))`;;\n\nlet DET_MATRIX_EQ_0_RIGHT = `!f:real^N->real^N.\n linear f\n ==> (det(matrix f) = &0 <=>\n ~(?g. linear g /\\ f o g = I))`;;\n\nlet DET_EQ_0_RANK = `!A:real^N^N. det A = &0 <=> rank A < dimindex(:N)`;;\n\nlet RANK_EQ_FULL_DET = `!A:real^N^N. rank A = dimindex(:N) <=> ~(det A = &0)`;;\n\nlet INVERTIBLE_COVARIANCE_RANK = `!A:real^N^M. invertible(transp A ** A) <=> rank A = dimindex(:N)`;;\n\nlet HOMOGENEOUS_LINEAR_EQUATIONS_DET = `!A:real^N^N. (?x. ~(x = vec 0) /\\ A ** x = vec 0) <=> det A = &0`;;\n\nlet INVERTIBLE_MATRIX_MUL = `!A:real^N^N B:real^N^N.\n invertible(A ** B) <=> invertible A /\\ invertible B`;;\n\nlet MATRIX_INV_MUL = `!A:real^N^N B:real^N^N.\n invertible A /\\ invertible B\n ==> matrix_inv(A ** B) = matrix_inv B ** matrix_inv A`;;\n\nlet DET_SIMILAR = `!S:real^N^N A. invertible S ==> det(matrix_inv S ** A ** S) = det A`;;\n\nlet INVERTIBLE_NEARBY_ONORM = `!A B:real^N^N.\n invertible A /\\\n onorm(\\x. (B - A) ** x) < inv(onorm(\\x. matrix_inv A ** x))\n ==> invertible B`;;\n\nlet INVERTIBLE_NEARBY = `!A:real^N^N.\n invertible A\n ==> ?e. &0 < e /\\ !B. onorm(\\x. (B - A) ** x) < e ==> invertible B`;;\n\nlet CRAMER_LEMMA_TRANSP = `!A:real^N^N x:real^N.\n 1 <= k /\\ k <= dimindex(:N)\n ==> det((lambda i. if i = k\n then vsum(1..dimindex(:N)) (\\i. x$i % row i A)\n else row i A):real^N^N) =\n x$k * det A`;;\n\nlet CRAMER_LEMMA = `!A:real^N^N x:real^N.\n 1 <= k /\\ k <= dimindex(:N)\n ==> det((lambda i j. if j = k then (A**x)$i else A$i$j):real^N^N) =\n x$k * det(A)`;;\n\nlet CRAMER = `!A:real^N^N x b.\n ~(det(A) = &0)\n ==> (A ** x = b <=>\n x = lambda k.\n det((lambda i j. if j = k then b$i else A$i$j):real^N^N) /\n det(A))`;;\n\nlet CRAMER_MATRIX_LEFT = `!A:real^N^N X:real^N^N B:real^N^N.\n ~(det A = &0)\n ==> (X ** A = B <=>\n X = lambda k l.\n det((lambda i j. if j = l then B$k$i else A$j$i):real^N^N) /\n det A)`;;\n\nlet CRAMER_MATRIX_RIGHT = `!A:real^N^N X:real^N^N B:real^N^N.\n ~(det A = &0)\n ==> (A ** X = B <=>\n X = lambda k l.\n det((lambda i j. if j = k then B$i$l else A$i$j):real^N^N) /\n det A)`;;\n\nlet CRAMER_MATRIX_RIGHT_INVERSE = `!A:real^N^N A':real^N^N.\n A ** A' = mat 1 <=>\n ~(det A = &0) /\\\n A' = lambda k l.\n det((lambda i j. if j = k then if i = l then &1 else &0\n else A$i$j):real^N^N) /\n det A`;;\n\nlet CRAMER_MATRIX_LEFT_INVERSE = `!A:real^N^N A':real^N^N.\n A' ** A = mat 1 <=>\n ~(det A = &0) /\\\n A' = lambda k l.\n det((lambda i j. if j = l then if i = k then &1 else &0\n else A$j$i):real^N^N) /\n det A`;;\n\nlet cofactor = new_definition\n `(cofactor:real^N^N->real^N^N) A =\n lambda i j. det((lambda k l. if k = i /\\ l = j then &1\n else if k = i \\/ l = j then &0\n else A$k$l):real^N^N)`;;\n\nlet COFACTOR_TRANSP = `!A:real^N^N. cofactor(transp A) = transp(cofactor A)`;;\n\nlet COFACTOR_COLUMN = `!A:real^N^N.\n cofactor A =\n lambda i j. det((lambda k l. if l = j then if k = i then &1 else &0\n else A$k$l):real^N^N)`;;\n\nlet COFACTOR_ROW = `!A:real^N^N.\n cofactor A =\n lambda i j. det((lambda k l. if k = i then if l = j then &1 else &0\n else A$k$l):real^N^N)`;;\n\nlet MATRIX_RIGHT_INVERSE_COFACTOR = `!A:real^N^N A':real^N^N.\n A ** A' = mat 1 <=>\n ~(det A = &0) /\\ A' = inv(det A) %% transp(cofactor A)`;;\n\nlet MATRIX_LEFT_INVERSE_COFACTOR = `!A:real^N^N A':real^N^N.\n A' ** A = mat 1 <=>\n ~(det A = &0) /\\ A' = inv(det A) %% transp(cofactor A)`;;\n\nlet MATRIX_INV_COFACTOR = `!A. ~(det A = &0) ==> matrix_inv A = inv(det A) %% transp(cofactor A)`;;\n\nlet COFACTOR_MATRIX_INV = `!A:real^N^N. ~(det A = &0) ==> cofactor A = det(A) %% transp(matrix_inv A)`;;\n\nlet COFACTOR_I = `cofactor(mat 1:real^N^N) = mat 1`;;\n\nlet DET_COFACTOR_EXPANSION = `!A:real^N^N i.\n 1 <= i /\\ i <= dimindex(:N)\n ==> det A = sum (1..dimindex(:N))\n (\\j. A$i$j * (cofactor A)$i$j)`;;\n\nlet MATRIX_MUL_RIGHT_COFACTOR = `!A:real^N^N. A ** transp(cofactor A) = det(A) %% mat 1`;;\n\nlet MATRIX_MUL_LEFT_COFACTOR = `!A:real^N^N. transp(cofactor A) ** A = det(A) %% mat 1`;;\n\nlet COFACTOR_CMUL = `!A:real^N^N c. cofactor(c %% A) = c pow (dimindex(:N) - 1) %% cofactor A`;;\n\nlet COFACTOR_0 = `cofactor(mat 0:real^N^N) = if dimindex(:N) = 1 then mat 1 else mat 0`;;\n\nlet PRODUCT_1 = `product(1..1) f = f(1)`;;\n\nlet PRODUCT_2 = `!t. product(1..2) t = t(1) * t(2)`;;\n\nlet PRODUCT_3 = `!t. product(1..3) t = t(1) * t(2) * t(3)`;;\n\nlet PRODUCT_4 = `!t. product(1..4) t = t(1) * t(2) * t(3) * t(4)`;;\n\nlet DET_1_GEN = `!A:real^N^N. dimindex(:N) = 1 ==> det A = A$1$1`;;\n\nlet DET_1 = `!A:real^1^1. det A = A$1$1`;;\n\nlet DET_2 = `!A:real^2^2. det A = A$1$1 * A$2$2 - A$1$2 * A$2$1`;;\n\nlet DET_3 = `!A:real^3^3.\n det(A) = A$1$1 * A$2$2 * A$3$3 +\n A$1$2 * A$2$3 * A$3$1 +\n A$1$3 * A$2$1 * A$3$2 -\n A$1$1 * A$2$3 * A$3$2 -\n A$1$2 * A$2$1 * A$3$3 -\n A$1$3 * A$2$2 * A$3$1`;;\n\nlet DET_4 = `!A:real^4^4.\n det(A) = A$1$1 * A$2$2 * A$3$3 * A$4$4 +\n A$1$1 * A$2$3 * A$3$4 * A$4$2 +\n A$1$1 * A$2$4 * A$3$2 * A$4$3 +\n A$1$2 * A$2$1 * A$3$4 * A$4$3 +\n A$1$2 * A$2$3 * A$3$1 * A$4$4 +\n A$1$2 * A$2$4 * A$3$3 * A$4$1 +\n A$1$3 * A$2$1 * A$3$2 * A$4$4 +\n A$1$3 * A$2$2 * A$3$4 * A$4$1 +\n A$1$3 * A$2$4 * A$3$1 * A$4$2 +\n A$1$4 * A$2$1 * A$3$3 * A$4$2 +\n A$1$4 * A$2$2 * A$3$1 * A$4$3 +\n A$1$4 * A$2$3 * A$3$2 * A$4$1 -\n A$1$1 * A$2$2 * A$3$4 * A$4$3 -\n A$1$1 * A$2$3 * A$3$2 * A$4$4 -\n A$1$1 * A$2$4 * A$3$3 * A$4$2 -\n A$1$2 * A$2$1 * A$3$3 * A$4$4 -\n A$1$2 * A$2$3 * A$3$4 * A$4$1 -\n A$1$2 * A$2$4 * A$3$1 * A$4$3 -\n A$1$3 * A$2$1 * A$3$4 * A$4$2 -\n A$1$3 * A$2$2 * A$3$1 * A$4$4 -\n A$1$3 * A$2$4 * A$3$2 * A$4$1 -\n A$1$4 * A$2$1 * A$3$2 * A$4$3 -\n A$1$4 * A$2$2 * A$3$3 * A$4$1 -\n A$1$4 * A$2$3 * A$3$1 * A$4$2`;;\n\nlet COFACTOR_1_GEN = `!A:real^N^N. dimindex(:N) = 1 ==> cofactor A = mat 1`;;\n\nlet COFACTOR_1 = `!A:real^1^1. cofactor A = mat 1`;;\n\nlet DISJOINT_HYPERPLANES_IMP_COLLINEAR = `!a b:real^N c d.\n DISJOINT {x | a dot x = c} {x | b dot x = d}\n ==> collinear {vec 0, a, b}`;;\n\nlet DISJOINT_HALFSPACES_IMP_COLLINEAR = `(!a b:real^N c d.\n DISJOINT {x | a dot x < c} {x | b dot x < d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x < c} {x | b dot x <= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x < c} {x | b dot x = d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x < c} {x | b dot x >= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x < c} {x | b dot x > d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x <= c} {x | b dot x < d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x <= c} {x | b dot x <= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x <= c} {x | b dot x = d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x <= c} {x | b dot x >= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x <= c} {x | b dot x > d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x = c} {x | b dot x < d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x = c} {x | b dot x <= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x = c} {x | b dot x = d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x = c} {x | b dot x >= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x = c} {x | b dot x > d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x >= c} {x | b dot x < d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x >= c} {x | b dot x <= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x >= c} {x | b dot x = d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x >= c} {x | b dot x >= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x >= c} {x | b dot x > d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x > c} {x | b dot x < d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x > c} {x | b dot x <= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x > c} {x | b dot x = d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x > c} {x | b dot x >= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n DISJOINT {x | a dot x > c} {x | b dot x > d}\n ==> collinear {vec 0, a, b})`;;\n\nlet SUBSET_HALFSPACES_IMP_COLLINEAR = `(!a b:real^N c d.\n {x | a dot x < c} SUBSET {x | b dot x < d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x < c} SUBSET {x | b dot x <= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x < c} SUBSET {x | b dot x = d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x < c} SUBSET {x | b dot x >= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x < c} SUBSET {x | b dot x > d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x <= c} SUBSET {x | b dot x < d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x <= c} SUBSET {x | b dot x <= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x <= c} SUBSET {x | b dot x = d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x <= c} SUBSET {x | b dot x >= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x <= c} SUBSET {x | b dot x > d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x = c} SUBSET {x | b dot x < d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x = c} SUBSET {x | b dot x <= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x = c} SUBSET {x | b dot x = d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x = c} SUBSET {x | b dot x >= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x = c} SUBSET {x | b dot x > d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x >= c} SUBSET {x | b dot x < d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x >= c} SUBSET {x | b dot x <= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x >= c} SUBSET {x | b dot x = d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x >= c} SUBSET {x | b dot x >= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x >= c} SUBSET {x | b dot x > d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x > c} SUBSET {x | b dot x < d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x > c} SUBSET {x | b dot x <= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x > c} SUBSET {x | b dot x = d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x > c} SUBSET {x | b dot x >= d}\n ==> collinear {vec 0, a, b}) /\\\n (!a b:real^N c d.\n {x | a dot x > c} SUBSET {x | b dot x > d}\n ==> collinear {vec 0, a, b})`;;\n\nlet SUBSET_HYPERPLANES = `!a b a' b'.\n {x | a dot x = b} SUBSET {x | a' dot x = b'} <=>\n {x | a dot x = b} = {} \\/ {x | a' dot x = b'} = (:real^N) \\/\n {x | a dot x = b} = {x | a' dot x = b'}`;;\n\nlet EIGENVALUES_CHARACTERISTIC_ALT = `!A:real^N^N c.\n (?v. ~(v = vec 0) /\\ A ** v = c % v) <=> det(A - c %% mat 1) = &0`;;\n\nlet EIGENVALUES_CHARACTERISTIC = `!A:real^N^N c.\n (?v. ~(v = vec 0) /\\ A ** v = c % v) <=> det(c %% mat 1 - A) = &0`;;\n\nlet INVERTIBLE_EIGENVALUES = `!A:real^N^N.\n invertible(A) <=> !c v. A ** v = c % v /\\ ~(v = vec 0) ==> ~(c = &0)`;;\n\nlet CHARACTERISTIC_POLYNOMIAL = `!A:real^N^N.\n ?a. a(dimindex(:N)) = &1 /\\\n !x. det(x %% mat 1 - A) =\n sum (0..dimindex(:N)) (\\i. a i * x pow i)`;;\n\nlet FINITE_EIGENVALUES = `!A:real^N^N. FINITE {c | ?v. ~(v = vec 0) /\\ A ** v = c % v}`;;\n\nlet GRASSMANN_PLUCKER_2 = `!x1 x2 y1 y2:real^2.\n det(vector[x1;x2]) * det(vector[y1;y2]) =\n det(vector[y1;x2]) * det(vector[x1;y2]) +\n det(vector[y2;x2]) * det(vector[y1;x1])`;;\n\nlet GRASSMANN_PLUCKER_3 = `!x1 x2 x3 y1 y2 y3:real^3.\n det(vector[x1;x2;x3]) * det(vector[y1;y2;y3]) =\n det(vector[y1;x2;x3]) * det(vector[x1;y2;y3]) +\n det(vector[y2;x2;x3]) * det(vector[y1;x1;y3]) +\n det(vector[y3;x2;x3]) * det(vector[y1;y2;x1])`;;\n\nlet GRASSMANN_PLUCKER_4 = `!x1 x2 x3 x4:real^4 y1 y2 y3 y4:real^4.\n det(vector[x1;x2;x3;x4]) * det(vector[y1;y2;y3;y4]) =\n det(vector[y1;x2;x3;x4]) * det(vector[x1;y2;y3;y4]) +\n det(vector[y2;x2;x3;x4]) * det(vector[y1;x1;y3;y4]) +\n det(vector[y3;x2;x3;x4]) * det(vector[y1;y2;x1;y4]) +\n det(vector[y4;x2;x3;x4]) * det(vector[y1;y2;y3;x1])`;;\n\nlet INTEGER_PRODUCT = `!f s. (!x. x IN s ==> integer(f x)) ==> integer(product s f)`;;\n\nlet INTEGER_SIGN = `!p. integer(sign p)`;;\n\nlet INTEGER_DET = `!M:real^N^N.\n (!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> integer(M$i$j))\n ==> integer(det M)`;;\n\nlet diagonal_matrix = new_definition\n `diagonal_matrix(A:real^N^M) <=>\n !i j. 1 <= i /\\ i <= dimindex(:M) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\\n ~(i = j)\n ==> A$i$j = &0`;;\n\nlet DIAGONAL_MATRIX = `!A:real^N^N.\n diagonal_matrix A <=> A = (lambda i j. if i = j then A$i$j else &0)`;;\n\nlet DIAGONAL_MATRIX_MAT = `!m. diagonal_matrix(mat m:real^N^N)`;;\n\nlet TRANSP_DIAGONAL_MATRIX = `!A:real^N^N. diagonal_matrix A ==> transp A = A`;;\n\nlet DIAGONAL_IMP_SYMMETRIC_MATRIX = `!A:real^N^N. diagonal_matrix A ==> symmetric_matrix A`;;\n\nlet DIAGONAL_MATRIX_ADD = `!A B:real^N^M.\n diagonal_matrix A /\\ diagonal_matrix B\n ==> diagonal_matrix(A + B)`;;\n\nlet DIAGONAL_MATRIX_CMUL = `!A:real^N^M c.\n diagonal_matrix A ==> diagonal_matrix(c %% A)`;;\n\nlet MATRIX_MUL_DIAGONAL = `!A:real^N^N B:real^N^N.\n diagonal_matrix A /\\ diagonal_matrix B\n ==> A ** B = lambda i j. A$i$j * B$i$j`;;\n\nlet DIAGONAL_MATRIX_MUL_COMPONENT = `!A:real^N^N B:real^N^N i j.\n diagonal_matrix A /\\ diagonal_matrix B /\\\n 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> (A ** B)$i$j = A$i$j * B$i$j`;;\n\nlet DIAGONAL_MATRIX_MUL = `!A:real^N^N B:real^N^N.\n diagonal_matrix A /\\ diagonal_matrix B\n ==> diagonal_matrix(A ** B)`;;\n\nlet DIAGONAL_MATRIX_MUL_EQ = `!A:real^M^N B:real^N^M.\n diagonal_matrix (A ** B) <=>\n pairwise (\\i j. orthogonal (row i A) (column j B)) (1..dimindex(:N))`;;\n\nlet DIAGONAL_MATRIX_INV_EXPLICIT = `!A:real^N^N. diagonal_matrix A ==> matrix_inv A = lambda i j. inv(A$i$j)`;;\n\nlet DIAGONAL_MATRIX_INV_COMPONENT = `!A:real^N^N i j.\n diagonal_matrix A /\\\n 1 <= i /\\ i <= dimindex(:N) /\\ 1 <= j /\\ j <= dimindex(:N)\n ==> (matrix_inv A)$i$j = inv(A$i$j)`;;\n\nlet DIAGONAL_MATRIX_INV = `!A:real^N^N. diagonal_matrix(matrix_inv A) <=> diagonal_matrix A`;;\n\nlet DET_DIAGONAL = `!A:real^N^N.\n diagonal_matrix A\n ==> det(A) = product(1..dimindex(:N)) (\\i. A$i$i)`;;\n\nlet INVERTIBLE_DIAGONAL_MATRIX = `!D:real^N^N.\n diagonal_matrix D\n ==> (invertible D <=>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> ~(D$i$i = &0))`;;\n\nlet COMMUTING_WITH_DIAGONAL_MATRIX = `!A D:real^N^N.\n diagonal_matrix D\n ==> (A ** D = D ** A <=>\n !i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> A$i$j = &0 \\/ D$i$i = D$j$j)`;;\n\nlet RANK_DIAGONAL_MATRIX = `!A:real^N^N.\n diagonal_matrix A\n ==> rank A = CARD {i | i IN 1..dimindex(:N) /\\ ~(A$i$i = &0)}`;;\n\nlet ONORM_DIAGONAL_MATRIX = `!A:real^N^N.\n diagonal_matrix A\n ==> onorm(\\x. A ** x) = sup {abs(A$i$i) | 1 <= i /\\ i <= dimindex(:N)}`;;\n\nlet positive_semidefinite = new_definition\n `positive_semidefinite(A:real^N^N) <=>\n symmetric_matrix A /\\ !x. &0 <= x dot (A ** x)`;;\n\nlet POSITIVE_SEMIDEFINITE_IMP_SYMMETRIC_MATRIX = `!A:real^N^N. positive_semidefinite A ==> symmetric_matrix A`;;\n\nlet POSITIVE_SEMIDEFINITE_IMP_SYMMETRIC = `!A:real^N^N. positive_semidefinite A ==> transp A = A`;;\n\nlet POSITIVE_SEMIDEFINITE_ADD = `!A B:real^N^N.\n positive_semidefinite A /\\ positive_semidefinite B\n ==> positive_semidefinite(A + B)`;;\n\nlet POSITIVE_SEMIDEFINITE_CMUL = `!c A:real^N^N.\n positive_semidefinite A /\\ &0 <= c\n ==> positive_semidefinite(c %% A)`;;\n\nlet POSITIVE_SEMIDEFINITE_TRANSP = `!A:real^N^N. positive_semidefinite(transp A) <=> positive_semidefinite A`;;\n\nlet POSITIVE_SEMIDEFINITE_COVARIANCE = `!A:real^N^M. positive_semidefinite(transp A ** A)`;;\n\nlet POSITIVE_SEMIDEFINITE_SIMILAR = `!A B:real^N^M.\n positive_semidefinite A\n ==> positive_semidefinite(transp B ** A ** B)`;;\n\nlet POSITIVE_SEMIDEFINITE_SIMILAR_EQ = `!A B:real^N^N.\n invertible B\n ==> (positive_semidefinite (transp B ** A ** B) <=>\n positive_semidefinite A)`;;\n\nlet POSITIVE_SEMIDEFINITE_DIAGONAL_MATRIX = `!D:real^N^N.\n diagonal_matrix D /\\\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> &0 <= D$i$i)\n ==> positive_semidefinite D`;;\n\nlet POSITIVE_SEMIDEFINITE_DIAGONAL_MATRIX_EQ = `!D:real^N^N.\n diagonal_matrix D\n ==> (positive_semidefinite D <=>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> &0 <= D$i$i)`;;\n\nlet DIAGONAL_POSITIVE_SEMIDEFINITE = `!A:real^N^N i.\n positive_semidefinite A /\\ 1 <= i /\\ i <= dimindex(:N)\n ==> &0 <= A$i$i`;;\n\nlet TRACE_POSITIVE_SEMIDEFINITE = `!A:real^N^N. positive_semidefinite A ==> &0 <= trace A`;;\n\nlet TRACE_LE_MUL_SQUARES = `!A B:real^N^N.\n symmetric_matrix A /\\ symmetric_matrix B\n ==> trace((A ** B) ** (A ** B)) <= trace((A ** A) ** (B ** B))`;;\n\nlet POSITIVE_SEMIDEFINITE_ZERO_FORM = `!A:real^N^N. positive_semidefinite A /\\ x dot (A ** x) = &0\n ==> A ** x = vec 0`;;\n\nlet POSITIVE_SEMIDEFINITE_ZERO_FORM_EQ = `!A:real^N^N. positive_semidefinite A\n ==> (x dot (A ** x) = &0 <=> A ** x = vec 0)`;;\n\nlet POSITIVE_SEMIDEFINITE_1_GEN = `!A:real^N^N.\n dimindex(:N) = 1 ==> (positive_semidefinite A <=> &0 <= A$1$1)`;;\n\nlet POSITIVE_SEMIDEFINITE_1 = `!A:real^1^1. positive_semidefinite A <=> &0 <= A$1$1`;;\n\nlet POSITIVE_SEMIDEFINITE_SUBMATRIX_2 = `!A:real^N^N i j.\n positive_semidefinite A /\\\n 1 <= i /\\ i <= dimindex(:N) /\\ 1 <= j /\\ j <= dimindex(:N)\n ==> positive_semidefinite\n (vector[vector[A$i$i;A$i$j];\n vector[A$j$i;A$j$j]]:real^2^2)`;;\n\nlet DOT_VECTORIZE = `!A B:real^N^M. vectorize A dot vectorize B = trace(transp A ** B)`;;\n\nlet NORM_VECTORIZE_TRANSP = `!A:real^N^M. norm(vectorize(transp A)) = norm(vectorize A)`;;\n\nlet COMPATIBLE_NORM_VECTORIZE = `!A:real^N^M x. norm(A ** x) <= norm(vectorize A) * norm x`;;\n\nlet ONORM_LE_NORM_VECTORIZE = `!A:real^M^N. onorm(\\x. A ** x) <= norm(vectorize A)`;;\n\nlet NORM_VECTORIZE_POW_2 = `!A:real^N^M.\n norm(vectorize A) pow 2 = sum(1..dimindex(:M)) (\\i. norm(A$i) pow 2)`;;\n\nlet NORM_VECTORIZE_MUL_LE = `!A:real^N^P B:real^M^N.\n norm(vectorize(A ** B)) <= norm(vectorize A) * norm(vectorize B)`;;\n\nlet NORM_VECTORIZE_HADAMARD_LE = `!A:real^N^M B:real^N^M.\n norm(vectorize((lambda i j. A$i$j * B$i$j):real^N^M))\n <= norm(vectorize A) * norm(vectorize B)`;;\n\nlet TRACE_COVARIANCE_POS_LE = `!A:real^M^N. &0 <= trace(transp A ** A)`;;\n\nlet TRACE_COVARIANCE_EQ_0 = `!A:real^M^N. trace(transp A ** A) = &0 <=> A = mat 0`;;\n\nlet TRACE_COVARIANCE_POS_LT = `!A:real^M^N. &0 < trace(transp A ** A) <=> ~(A = mat 0)`;;\n\nlet TRACE_COVARIANCE_CAUCHY_SCHWARZ = `!A B:real^M^N.\n trace(transp A ** B)\n <= sqrt(trace(transp A ** A)) * sqrt(trace(transp B ** B))`;;\n\nlet TRACE_COVARIANCE_CAUCHY_SCHWARZ_ABS = `!A B:real^M^N.\n abs(trace(transp A ** B))\n <= sqrt(trace(transp A ** A)) * sqrt(trace(transp B ** B))`;;\n\nlet TRACE_COVARIANCE_CAUCHY_SCHWARZ_SQUARE = `!A B:real^M^N.\n trace(transp A ** B) pow 2\n <= trace(transp A ** A) * trace(transp B ** B)`;;\n\nlet positive_definite = new_definition\n `positive_definite(A:real^N^N) <=>\n symmetric_matrix A /\\ !x. ~(x = vec 0) ==> &0 < x dot (A ** x)`;;\n\nlet POSITIVE_DEFINITE_IMP_SYMMETRIC_MATRIX = `!A:real^N^N. positive_definite A ==> symmetric_matrix A`;;\n\nlet POSITIVE_DEFINITE_IMP_SYMMETRIC = `!A:real^N^N. positive_definite A ==> transp A = A`;;\n\nlet POSITIVE_DEFINITE_POSITIVE_SEMIDEFINITE = `!A:real^N^N.\n positive_definite A <=> positive_semidefinite A /\\ invertible A`;;\n\nlet POSITIVE_DEFINITE_SIMILAR_EQ = `!A B:real^N^N.\n positive_definite(transp B ** A ** B) <=>\n invertible B /\\ positive_definite A`;;\n\nlet POSITIVE_DEFINITE_1_GEN = `!A:real^N^N.\n dimindex(:N) = 1 ==> (positive_definite A <=> &0 < A$1$1)`;;\n\nlet POSITIVE_DEFINITE_1 = `!A:real^1^1. positive_definite A <=> &0 < A$1$1`;;\n\nlet POSITIVE_DEFINITE_IMP_INVERTIBLE = `!A:real^N^N. positive_definite A ==> invertible A`;;\n\nlet POSITIVE_DEFINITE_IMP_POSITIVE_SEMIDEFINITE = `!A:real^N^N. positive_definite A ==> positive_semidefinite A`;;\n\nlet POSITIVE_SEMIDEFINITE_POSITIVE_DEFINITE_ADD = `!A B:real^N^N.\n positive_semidefinite A /\\ positive_definite B\n ==> positive_definite(A + B)`;;\n\nlet POSITIVE_DEFINITE_POSITIVE_SEMIDEFINITE_ADD = `!A B:real^N^N.\n positive_definite A /\\ positive_semidefinite B\n ==> positive_definite(A + B)`;;\n\nlet POSITIVE_DEFINITE_ADD = `!A B:real^N^N.\n positive_definite A /\\ positive_definite B\n ==> positive_definite(A + B)`;;\n\nlet POSITIVE_DEFINITE_CMUL = `!c A:real^N^N.\n positive_definite A /\\ &0 < c\n ==> positive_definite(c %% A)`;;\n\nlet NEARBY_POSITIVE_DEFINITE_MATRIX_GEN = `!A:real^N^N B x.\n positive_semidefinite A /\\ positive_definite B /\\ &0 < x\n ==> positive_definite(A + x %% B)`;;\n\nlet POSITIVE_DEFINITE_TRANSP = `!A:real^N^N. positive_definite(transp A) <=> positive_definite A`;;\n\nlet POSITIVE_DEFINITE_COVARIANCE = `!A:real^N^N. positive_definite(transp A ** A) <=> invertible A`;;\n\nlet POSITIVE_DEFINITE_SIMILAR = `!A B:real^N^N.\n positive_definite A /\\ invertible B\n ==> positive_definite(transp B ** A ** B)`;;\n\nlet POSITIVE_DEFINITE_DIAGONAL_MATRIX = `!D:real^N^N.\n diagonal_matrix D /\\\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> &0 < D$i$i)\n ==> positive_definite D`;;\n\nlet POSITIVE_DEFINITE_DIAGONAL_MATRIX_EQ = `!D:real^N^N.\n diagonal_matrix D\n ==> (positive_definite D <=>\n !i. 1 <= i /\\ i <= dimindex(:N) ==> &0 < D$i$i)`;;\n\nlet DIAGONAL_POSITIVE_DEFINITE = `!A:real^N^N i.\n positive_definite A /\\ 1 <= i /\\ i <= dimindex(:N)\n ==> &0 < A$i$i`;;\n\nlet TRACE_POSITIVE_DEFINITE = `!A:real^N^N. positive_definite A ==> &0 < trace A`;;\n\nlet POSITIVE_DEFINITE_MAT = `!m. positive_definite(mat m:real^N^N) <=> 0 < m`;;\n\nlet POSITIVE_DEFINITE_ID = `positive_definite(mat 1:real^N^N)`;;\n\nlet POSITIVE_SEMIDEFINITE_MAT = `!m. positive_semidefinite(mat m:real^N^N)`;;\n\nlet NEARBY_POSITIVE_DEFINITE_MATRIX = `!A:real^N^N x.\n positive_semidefinite A /\\ &0 < x ==> positive_definite(A + x %% mat 1)`;;\n\nlet POSITIVE_SEMIDEFINITE_ANTISYM = `!A:real^N^N. positive_semidefinite A /\\ positive_semidefinite(--A) <=>\n A = mat 0`;;\n\nlet LOEWNER_ORDER_ANTISYM = `!(A:real^N^N) B.\n positive_semidefinite(A - B) /\\ positive_semidefinite(B - A) <=>\n A = B`;;\n\nlet HADAMARD_INEQUALITY_ROW = `!A:real^N^N. abs(det A) <= product(1..dimindex(:N)) (\\i. norm(row i A))`;;\n\nlet HADAMARD_INEQUALITY_COLUMN = `!A:real^N^N. abs(det A) <= product(1..dimindex(:N)) (\\i. norm(column i A))`;;\n\nlet orthogonal_transformation = new_definition\n `orthogonal_transformation(f:real^N->real^N) <=>\n linear f /\\ !v w. f(v) dot f(w) = v dot w`;;\n\nlet ORTHOGONAL_TRANSFORMATION = `!f. orthogonal_transformation f <=> linear f /\\ !v. norm(f v) = norm(v)`;;\n\nlet ORTHOGONAL_ORTHOGONAL_TRANSFORMATION = `!f x y:real^N.\n orthogonal_transformation f\n ==> (orthogonal (f x) (f y) <=> orthogonal x y)`;;\n\nlet ORTHOGONAL_TRANSFORMATION_COMPOSE = `!f g. orthogonal_transformation f /\\ orthogonal_transformation g\n ==> orthogonal_transformation(f o g)`;;\n\nlet ORTHOGONAL_TRANSFORMATION_NEG = `!f:real^N->real^N.\n orthogonal_transformation(\\x. --(f x)) <=> orthogonal_transformation f`;;\n\nlet ORTHOGONAL_TRANSFORMATION_LINEAR = `!f:real^N->real^N. orthogonal_transformation f ==> linear f`;;\n\nlet ORTHOGONAL_TRANSFORMATION_INJECTIVE = `!f:real^N->real^N.\n orthogonal_transformation f ==> !x y. f x = f y ==> x = y`;;\n\nlet ORTHOGONAL_TRANSFORMATION_SURJECTIVE = `!f:real^N->real^N.\n orthogonal_transformation f ==> !y. ?x. f x = y`;;\n\nlet orthogonal_matrix = new_definition\n `orthogonal_matrix(Q:real^N^N) <=>\n transp(Q) ** Q = mat 1 /\\ Q ** transp(Q) = mat 1`;;\n\nlet ORTHOGONAL_MATRIX = `orthogonal_matrix(Q:real^N^N) <=> transp(Q) ** Q = mat 1`;;\n\nlet ORTHOGONAL_MATRIX_ALT = `!A:real^N^N. orthogonal_matrix A <=> A ** transp A = mat 1`;;\n\nlet ORTHOGONAL_MATRIX_TRANSP = `!A:real^N^N. orthogonal_matrix(transp A) <=> orthogonal_matrix A`;;\n\nlet ORTHOGONAL_MATRIX_TRANSP_LMUL = `!P:real^N^N. orthogonal_matrix P ==> transp P ** P = mat 1`;;\n\nlet ORTHOGONAL_MATRIX_TRANSP_RMUL = `!P:real^N^N. orthogonal_matrix P ==> P ** transp P = mat 1`;;\n\nlet NORM_VECTORIZE_ORTHOGONAL_MATRIX_RMUL = `!A:real^N^N P:real^N^N.\n orthogonal_matrix P ==> norm(vectorize(A ** P)) = norm(vectorize A)`;;\n\nlet NORM_VECTORIZE_ORTHOGONAL_MATRIX_LMUL = `!A:real^N^N P:real^N^N.\n orthogonal_matrix P ==> norm(vectorize(P ** A)) = norm(vectorize A)`;;\n\nlet ORTHOGONAL_MATRIX_ID = `orthogonal_matrix(mat 1)`;;\n\nlet ORTHOGONAL_MATRIX_MUL = `!A B. orthogonal_matrix A /\\ orthogonal_matrix B\n ==> orthogonal_matrix(A ** B)`;;\n\nlet ORTHOGONAL_TRANSFORMATION_MATRIX = `!f:real^N->real^N.\n orthogonal_transformation f <=> linear f /\\ orthogonal_matrix(matrix f)`;;\n\nlet ORTHOGONAL_MATRIX_TRANSFORMATION = `!A:real^N^N. orthogonal_matrix A <=> orthogonal_transformation(\\x. A ** x)`;;\n\nlet ORTHOGONAL_MATRIX_MATRIX = `!f:real^N->real^N.\n orthogonal_transformation f ==> orthogonal_matrix(matrix f)`;;\n\nlet ORTHOGONAL_MATRIX_NORM_EQ = `!A. orthogonal_matrix A <=> !x. norm(A ** x) = norm x`;;\n\nlet ORTHOGONAL_MATRIX_NORM = `!A x:real^N. orthogonal_matrix A ==> norm(A ** x) = norm x`;;\n\nlet DET_ORTHOGONAL_MATRIX = `!Q. orthogonal_matrix Q ==> det(Q) = &1 \\/ det(Q) = -- &1`;;\n\nlet ORTHOGONAL_MATRIX_IMP_INVERTIBLE = `!A:real^N^N. orthogonal_matrix A ==> invertible A`;;\n\nlet MATRIX_MUL_LTRANSP_DOT_COLUMN = `!A:real^N^M. transp A ** A = (lambda i j. (column i A) dot (column j A))`;;\n\nlet MATRIX_MUL_RTRANSP_DOT_ROW = `!A:real^N^M. A ** transp A = (lambda i j. (row i A) dot (row j A))`;;\n\nlet ORTHOGONAL_MATRIX_ORTHONORMAL_COLUMNS = `!A:real^N^N.\n orthogonal_matrix A <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> norm(column i A) = &1) /\\\n (!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\ ~(i = j)\n ==> orthogonal (column i A) (column j A))`;;\n\nlet ORTHOGONAL_MATRIX_ORTHONORMAL_ROWS = `!A:real^N^N.\n orthogonal_matrix A <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> norm(row i A) = &1) /\\\n (!i j. 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N) /\\ ~(i = j)\n ==> orthogonal (row i A) (row j A))`;;\n\nlet ORTHOGONAL_MATRIX_ORTHONORMAL_ROWS_INDEXED = `!A:real^N^N.\n orthogonal_matrix A <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> norm(row i A) = &1) /\\\n pairwise (\\i j. orthogonal (row i A) (row j A)) (1..dimindex(:N))`;;\n\nlet ORTHOGONAL_MATRIX_ORTHONORMAL_ROWS_PAIRWISE = `!A:real^N^N.\n orthogonal_matrix A <=>\n CARD(rows A) = dimindex(:N) /\\\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> norm(row i A) = &1) /\\\n pairwise orthogonal (rows A)`;;\n\nlet ORTHOGONAL_MATRIX_ORTHONORMAL_ROWS_SPAN = `!A:real^N^N.\n orthogonal_matrix A <=>\n span(rows A) = (:real^N) /\\\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> norm(row i A) = &1) /\\\n pairwise orthogonal (rows A)`;;\n\nlet ORTHOGONAL_MATRIX_ORTHONORMAL_COLUMNS_INDEXED = `!A:real^N^N.\n orthogonal_matrix A <=>\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> norm(column i A) = &1) /\\\n pairwise (\\i j. orthogonal (column i A) (column j A)) (1..dimindex(:N))`;;\n\nlet ORTHOGONAL_MATRIX_ORTHONORMAL_COLUMNS_PAIRWISE = `!A:real^N^N.\n orthogonal_matrix A <=>\n CARD(columns A) = dimindex(:N) /\\\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> norm(column i A) = &1) /\\\n pairwise orthogonal (columns A)`;;\n\nlet ORTHOGONAL_MATRIX_ORTHONORMAL_COLUMNS_SPAN = `!A:real^N^N.\n orthogonal_matrix A <=>\n span(columns A) = (:real^N) /\\\n (!i. 1 <= i /\\ i <= dimindex(:N) ==> norm(column i A) = &1) /\\\n pairwise orthogonal (columns A)`;;\n\nlet ORTHOGONAL_MATRIX_2 = `!A:real^2^2. orthogonal_matrix A <=>\n A$1$1 pow 2 + A$2$1 pow 2 = &1 /\\\n A$1$2 pow 2 + A$2$2 pow 2 = &1 /\\\n A$1$1 * A$1$2 + A$2$1 * A$2$2 = &0`;;\n\nlet ORTHOGONAL_MATRIX_2_ALT = `!A:real^2^2. orthogonal_matrix A <=>\n A$1$1 pow 2 + A$2$1 pow 2 = &1 /\\\n (A$1$1 = A$2$2 /\\ A$1$2 = --(A$2$1) \\/\n A$1$1 = --(A$2$2) /\\ A$1$2 = A$2$1)`;;\n\nlet ORTHOGONAL_MATRIX_INV = `!A:real^N^N. orthogonal_matrix A ==> matrix_inv A = transp A`;;\n\nlet ORTHOGONAL_MATRIX_INV_EQ = `!A:real^N^N. orthogonal_matrix(matrix_inv A) <=> orthogonal_matrix A`;;\n\nlet ORTHOGONAL_TRANSFORMATION_ORTHOGONAL_EIGENVECTORS = `!f:real^N->real^N v w a b.\n orthogonal_transformation f /\\ f v = a % v /\\ f w = b % w /\\ ~(a = b)\n ==> orthogonal v w`;;\n\nlet ORTHOGONAL_MATRIX_ORTHOGONAL_EIGENVECTORS = `!A:real^N^N v w a b.\n orthogonal_matrix A /\\ A ** v = a % v /\\ A ** w = b % w /\\ ~(a = b)\n ==> orthogonal v w`;;\n\nlet ORTHOGONAL_TRANSFORMATION_ID = `orthogonal_transformation(\\x. x)`;;\n\nlet ORTHOGONAL_TRANSFORMATION_I = `orthogonal_transformation I`;;\n\nlet ORTHOGONAL_TRANSFORMATION_NEGATION = `orthogonal_transformation(--)`;;\n\nlet ORTHOGONAL_TRANSFORMATION_1_GEN = `!f:real^N->real^N.\n dimindex(:N) = 1\n ==> (orthogonal_transformation f <=> f = I \\/ f = (--))`;;\n\nlet ORTHOGONAL_MATRIX_1 = `!m:real^N^N.\n dimindex(:N) = 1\n ==> (orthogonal_matrix m <=> m = mat 1 \\/ m = --mat 1)`;;\n\nlet MATRIX_INV_ORTHOGONAL_LMUL = `!U A:real^M^N.\n orthogonal_matrix U\n ==> matrix_inv(U ** A) = matrix_inv A ** matrix_inv U`;;\n\nlet MATRIX_INV_ORTHOGONAL_RMUL = `!U A:real^M^N.\n orthogonal_matrix U\n ==> matrix_inv(A ** U) = matrix_inv U ** matrix_inv A`;;\n\nlet ORTHOGONAL_TRANSFORMATION_EQ_ADJOINT_LEFT = `!f:real^N->real^N.\n orthogonal_transformation f <=> linear f /\\ adjoint f o f = I`;;\n\nlet ORTHOGONAL_TRANSFORMATION_EQ_ADJOINT_RIGHT = `!f:real^N->real^N.\n orthogonal_transformation f <=> linear f /\\ f o adjoint f = I`;;\n\nlet ORTHOGONAL_TRANSFORMATION_EQ_ADJOINT = `!f:real^N->real^N.\n orthogonal_transformation f <=>\n linear f /\\ adjoint f o f = I /\\ f o adjoint f = I`;;\n\nlet ORTHOGONAL_TRANSFORMATION_ADJOINT = `!f:real^N->real^N.\n orthogonal_transformation f ==> orthogonal_transformation(adjoint f)`;;\n\nlet ORTHOGONAL_TRANSFORMATION_ADJOINT_EQ =\n (`!f:real^N->real^N.\n linear f\n ==> (orthogonal_transformation(adjoint f) <=>\n orthogonal_transformation f)`,\n MESON_TAC[ORTHOGONAL_TRANSFORMATION_ADJOINT; ADJOINT_LINEAR;\n ADJOINT_ADJOINT]);;\n\nlet ONORM_ORTHOGONAL_TRANSFORMATION = `!f:real^N->real^N. orthogonal_transformation f ==> onorm f = &1`;;\n\nlet ONORM_ORTHOGONAL_MATRIX = `!A:real^N^N. orthogonal_matrix A ==> onorm(\\x. A ** x) = &1`;;\n\nlet SCALING_LINEAR = `!f:real^M->real^N c.\n (f(vec 0) = vec 0) /\\ (!x y. dist(f x,f y) = c * dist(x,y))\n ==> linear(f)`;;\n\nlet ISOMETRY_LINEAR = `!f:real^M->real^N.\n (f(vec 0) = vec 0) /\\ (!x y. dist(f x,f y) = dist(x,y))\n ==> linear(f)`;;\n\nlet ISOMETRY_IMP_AFFINITY = `!f:real^M->real^N.\n (!x y. dist(f x,f y) = dist(x,y))\n ==> ?h. linear h /\\ !x. f(x) = f(vec 0) + h(x)`;;\n\nlet ORTHOGONALITY_PRESERVING_IMP_SCALING = `!f:real^M->real^N.\n linear f /\\ (!x y. orthogonal x y ==> orthogonal (f x) (f y))\n ==> ?c. &0 <= c /\\ !x. norm(f x) = c * norm(x)`;;\n\nlet ORTHOGONALITY_PRESERVING_EQ_SIMILARITY_ALT,\n ORTHOGONALITY_PRESERVING_EQ_SIMILARITY =\n (CONJ_PAIR o prove)\n (`(!f:real^N->real^N.\n linear f /\\ (!x y. orthogonal x y ==> orthogonal (f x) (f y)) <=>\n ?c g. &0 <= c /\\ orthogonal_transformation g /\\ f = \\z. c % g z) /\\\n (!f:real^N->real^N.\n linear f /\\ (!x y. orthogonal x y ==> orthogonal (f x) (f y)) <=>\n ?c g. orthogonal_transformation g /\\ f = \\z. c % g z)`,\n REWRITE_TAC[AND_FORALL_THM] THEN GEN_TAC THEN\n MATCH_MP_TAC(TAUT\n `(q ==> r) /\\ (r ==> p) /\\ (p ==> q)\n ==> (p <=> q) /\\ (p <=> r)`) THEN\n REPEAT CONJ_TAC THENL\n [ASM_MESON_TAC[];\n STRIP_TAC THEN\n ASM_SIMP_TAC[ORTHOGONAL_TRANSFORMATION_LINEAR; LINEAR_COMPOSE_CMUL] THEN\n ASM_SIMP_TAC[ORTHOGONAL_MUL; ORTHOGONAL_ORTHOGONAL_TRANSFORMATION];\n DISCH_TAC THEN\n FIRST_ASSUM(MP_TAC o MATCH_MP ORTHOGONALITY_PRESERVING_IMP_SCALING) THEN\n MATCH_MP_TAC MONO_EXISTS THEN X_GEN_TAC `c:real` THEN\n ASM_CASES_TAC `c = &0` THENL\n [ASM_SIMP_TAC[REAL_MUL_LZERO; FUN_EQ_THM; NORM_EQ_0] THEN\n DISCH_TAC THEN EXISTS_TAC `\\x:real^N. x` THEN\n REWRITE_TAC[VECTOR_MUL_LZERO; ORTHOGONAL_TRANSFORMATION_ID];\n STRIP_TAC THEN EXISTS_TAC `\\x. inv(c) % (f:real^N->real^N) x` THEN\n ASM_REWRITE_TAC[ORTHOGONAL_TRANSFORMATION; FUN_EQ_THM] THEN\n ASM_SIMP_TAC[LINEAR_COMPOSE_CMUL; NORM_MUL; VECTOR_MUL_ASSOC] THEN\n ASM_SIMP_TAC[REAL_MUL_RINV; VECTOR_MUL_LID; REAL_ABS_INV] THEN\n ASM_REWRITE_TAC[real_abs; REAL_MUL_ASSOC] THEN\n ASM_SIMP_TAC[REAL_MUL_LINV; REAL_MUL_LID]]]);;\n\nlet ORTHOGONAL_TRANSFORMATION_ISOMETRY = `!f:real^N->real^N.\n orthogonal_transformation f <=>\n (f(vec 0) = vec 0) /\\ (!x y. dist(f x,f y) = dist(x,y))`;;\n\nlet ISOMETRY_SPHERE_EXTEND = `!f:real^N->real^N.\n (!x. norm(x) = &1 ==> norm(f x) = &1) /\\\n (!x y. norm(x) = &1 /\\ norm(y) = &1 ==> dist(f x,f y) = dist(x,y))\n ==> ?g. orthogonal_transformation g /\\\n (!x. norm(x) = &1 ==> g(x) = f(x))`;;\n\nlet ORTHOGONAL_TRANSFORMATION_INVERSE_o = `!f:real^N->real^N.\n orthogonal_transformation f\n ==> ?g. orthogonal_transformation g /\\ g o f = I /\\ f o g = I`;;\n\nlet ORTHOGONAL_TRANSFORMATION_INVERSE = `!f:real^N->real^N.\n orthogonal_transformation f\n ==> ?g. orthogonal_transformation g /\\\n (!x. g(f x) = x) /\\ (!y. f(g y) = y)`;;\n\nlet ONORM_COMPOSE_ORTHOGONAL_TRANSFORMATION_LEFT = `!f g. orthogonal_transformation f ==> onorm(f o g) = onorm g`;;\n\nlet ONORM_COMPOSE_ORTHOGONAL_TRANSFORMATION_RIGHT = `!f g. orthogonal_transformation g ==> onorm(f o g) = onorm f`;;\n\nlet SQNORM_LE_MAX_EIGENVECTOR_SPAN = `!(f:real^N->real^N) b c x l.\n linear f /\\\n pairwise orthogonal b /\\\n (!x. x IN b ==> f x = c x % x /\\ c x pow 2 <= l) /\\\n x IN span b\n ==> norm(f x) pow 2 <= l * norm x pow 2`;;\n\nlet NORM_LE_MAX_EIGENVECTOR_SPAN = `!(f:real^N->real^N) b c x l.\n linear f /\\\n pairwise orthogonal b /\\\n (!x. x IN b ==> f x = c x % x /\\ abs(c x) <= l) /\\\n x IN span b\n ==> norm(f x) <= l * norm x`;;\n\nlet ONORM_EQ_MAX_EIGENVECTOR = `!(f:real^N->real^N) b c.\n linear f /\\\n pairwise orthogonal b /\\\n span b = (:real^N) /\\\n ~(vec 0 IN b) /\\\n (!x. x IN b ==> f x = c x % x)\n ==> onorm f = sup {abs(c x) | x IN b}`;;\n\nlet ONORM_ORTHOGONAL_MATRIX_MUL_LEFT = `!(A:real^N^N) (P:real^N^N).\n orthogonal_matrix P ==> onorm (\\x. (P ** A) ** x) = onorm(\\x. A ** x)`;;\n\nlet ONORM_ORTHOGONAL_MATRIX_MUL_RIGHT = `!(A:real^N^N) (P:real^N^N).\n orthogonal_matrix P ==> onorm (\\x. (A ** P) ** x) = onorm(\\x. A ** x)`;;\n\nlet ONORM_DIAGONALIZED_MATRIX = `!(A:real^N^N) D P.\n orthogonal_matrix P /\\\n diagonal_matrix D /\\\n transp P ** D ** P = A\n ==> onorm(\\x. A ** x) = sup {abs(D$i$i) | 1 <= i /\\ i <= dimindex (:N)}`;;\n\nlet ONORM_DIAGONALIZED_COVARIANCE_MATRIX = `!(A:real^N^N) D P.\n orthogonal_matrix P /\\\n diagonal_matrix D /\\\n transp P ** D ** P = transp A ** A\n ==> onorm(\\x. A ** x) =\n sqrt(sup {abs(D$i$i) | 1 <= i /\\ i <= dimindex (:N)})`;;\n\nlet ORTHOGONAL_MATRIX_EXISTS_BASIS = `!a:real^N.\n norm(a) = &1\n ==> ?A. orthogonal_matrix A /\\ A**(basis 1) = a`;;\n\nlet ORTHOGONAL_TRANSFORMATION_EXISTS_1 = `!a b:real^N.\n norm(a) = &1 /\\ norm(b) = &1\n ==> ?f. orthogonal_transformation f /\\ f a = b`;;\n\nlet ORTHOGONAL_TRANSFORMATION_EXISTS = `!a b:real^N.\n norm(a) = norm(b) ==> ?f. orthogonal_transformation f /\\ f a = b`;;\n\nlet ORTHOGONAL_TRANSFORMATION_INTO_SUBSPACE = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ dim s <= dim t\n ==> ?f. orthogonal_transformation f /\\ IMAGE f s SUBSET t`;;\n\nlet ORTHOGONAL_TRANSFORMATION_ONTO_SUBSPACE = `!s t:real^N->bool.\n subspace s /\\ subspace t /\\ dim s = dim t\n ==> ?f. orthogonal_transformation f /\\ IMAGE f s = t`;;\n\nlet rotation_matrix = new_definition\n `rotation_matrix Q <=> orthogonal_matrix Q /\\ det(Q) = &1`;;\n\nlet rotoinversion_matrix = new_definition\n `rotoinversion_matrix Q <=> orthogonal_matrix Q /\\ det(Q) = -- &1`;;\n\nlet ORTHOGONAL_ROTATION_OR_ROTOINVERSION = `!Q. orthogonal_matrix Q <=> rotation_matrix Q \\/ rotoinversion_matrix Q`;;\n\nlet ROTATION_MATRIX_1 = `!m:real^N^N.\n dimindex(:N) = 1 ==> (rotation_matrix m <=> m = mat 1)`;;\n\nlet ROTOINVERSION_MATRIX_1 = `!m:real^N^N.\n dimindex(:N) = 1 ==> (rotoinversion_matrix m <=> m = --mat 1)`;;\n\nlet ROTATION_MATRIX_2 = `!A:real^2^2. rotation_matrix A <=>\n A$1$1 pow 2 + A$2$1 pow 2 = &1 /\\\n A$1$1 = A$2$2 /\\ A$1$2 = --(A$2$1)`;;\n\nlet ROTATION_MATRIX_EXISTS_BASIS = `!a:real^N.\n 2 <= dimindex(:N) /\\ norm(a) = &1\n ==> ?A. rotation_matrix A /\\ A**(basis 1) = a`;;\n\nlet ROTATION_EXISTS_1 = `!a b:real^N.\n 2 <= dimindex(:N) /\\ norm(a) = &1 /\\ norm(b) = &1\n ==> ?f. orthogonal_transformation f /\\ det(matrix f) = &1 /\\ f a = b`;;\n\nlet ROTATION_EXISTS = `!a b:real^N.\n 2 <= dimindex(:N) /\\ norm(a) = norm(b)\n ==> ?f. orthogonal_transformation f /\\ det(matrix f) = &1 /\\ f a = b`;;\n\nlet ROTATION_RIGHTWARD_LINE = `!a:real^N k.\n 1 <= k /\\ k <= dimindex(:N)\n ==> ?b f. orthogonal_transformation f /\\\n (2 <= dimindex(:N) ==> det(matrix f) = &1) /\\\n f(b % basis k) = a /\\\n &0 <= b`;;\n\nlet EULER_ROTATION_THEOREM = `!A:real^3^3. rotation_matrix A ==> ?v:real^3. ~(v = vec 0) /\\ A ** v = v`;;\n\nlet EULER_ROTOINVERSION_THEOREM = `!A:real^3^3.\n rotoinversion_matrix A ==> ?v:real^3. ~(v = vec 0) /\\ A ** v = --v`;;\n\nlet ROTATION_LOWDIM_HORIZONTAL = `!s:real^N->bool.\n dim s < dimindex(:N)\n ==> ?f. orthogonal_transformation f /\\ det(matrix f) = &1 /\\\n (IMAGE f s) SUBSET {z | z$(dimindex(:N)) = &0}`;;\n\nlet ORTHOGONAL_TRANSFORMATION_LOWDIM_HORIZONTAL = `!s:real^N->bool.\n dim s < dimindex(:N)\n ==> ?f. orthogonal_transformation f /\\\n (IMAGE f s) SUBSET {z | z$(dimindex(:N)) = &0}`;;\n\nlet ORTHOGONAL_TRANSFORMATION_BETWEEN_ORTHOGONAL_SETS = `!v:num->real^N w k.\n pairwise (\\i j. orthogonal (v i) (v j)) k /\\\n pairwise (\\i j. orthogonal (w i) (w j)) k /\\\n (!i. i IN k ==> norm(v i) = norm(w i))\n ==> ?f. orthogonal_transformation f /\\\n (!i. i IN k ==> f(v i) = w i)`;;\n\nlet reflect_along = new_definition\n `reflect_along v (x:real^N) = x - (&2 * (x dot v) / (v dot v)) % v`;;\n\nlet REFLECT_ALONG_ADD = `!v x y:real^N.\n reflect_along v (x + y) = reflect_along v x + reflect_along v y`;;\n\nlet REFLECT_ALONG_MUL = `!v a x:real^N. reflect_along v (a % x) = a % reflect_along v x`;;\n\nlet LINEAR_REFLECT_ALONG = `!v:real^N. linear(reflect_along v)`;;\n\nlet REFLECT_ALONG_0 = `!v:real^N. reflect_along v (vec 0) = vec 0`;;\n\nlet REFLECT_ALONG_NEG = `!v x:real^N. reflect_along v (--x) = --(reflect_along v x)`;;\n\nlet REFLECT_ALONG_REFL = `!v:real^N. reflect_along v v = --v`;;\n\nlet REFLECT_ALONG_INVOLUTION = `!v x:real^N. reflect_along v (reflect_along v x) = x`;;\n\nlet REFLECT_ALONG_GALOIS = `!v p q:real^N. reflect_along v p = q <=> p = reflect_along v q`;;\n\nlet REFLECT_ALONG_EQ_0 = `!v x:real^N. reflect_along v x = vec 0 <=> x = vec 0`;;\n\nlet ORTHOGONAL_TRANSFORMATION_REFLECT_ALONG = `!v:real^N. orthogonal_transformation(reflect_along v)`;;\n\nlet REFLECT_ALONG_EQ_SELF = `!v x:real^N. reflect_along v x = x <=> orthogonal v x`;;\n\nlet REFLECT_ALONG_ZERO = `reflect_along (vec 0:real^N) = I`;;\n\nlet REFLECT_ALONG_LINEAR_IMAGE = `!f:real^M->real^N v x.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> reflect_along (f v) (f x) = f(reflect_along v x)`;;\n\nadd_linear_invariants [REFLECT_ALONG_LINEAR_IMAGE];;\n\nlet REFLECT_ALONG_SCALE = `!c v x:real^N. ~(c = &0) ==> reflect_along (c % v) x = reflect_along v x`;;\n\nlet REFLECT_ALONG_NEGATION = `!v:real^N. reflect_along (--v) = reflect_along v`;;\n\nlet REFLECT_ALONG_1D = `!v x:real^N.\n dimindex(:N) = 1 ==> reflect_along v x = if v = vec 0 then x else --x`;;\n\nlet REFLECT_ALONG_BASIS = `!x:real^N k.\n 1 <= k /\\ k <= dimindex(:N)\n ==> reflect_along (basis k) x = x - (&2 * x$k) % basis k`;;\n\nlet MATRIX_REFLECT_ALONG_BASIS = `!k. 1 <= k /\\ k <= dimindex(:N)\n ==> matrix(reflect_along (basis k)):real^N^N =\n lambda i j. if i = k /\\ j = k then --(&1)\n else if i = j then &1\n else &0`;;\n\nlet ROTOINVERSION_MATRIX_REFLECT_ALONG = `!v:real^N. ~(v = vec 0) ==> rotoinversion_matrix(matrix(reflect_along v))`;;\n\nlet DET_MATRIX_REFLECT_ALONG = `!v:real^N. det(matrix(reflect_along v)) =\n if v = vec 0 then &1 else --(&1)`;;\n\nlet REFLECT_ALONG_BASIS_COMPONENT = `!x:real^N i j.\n 1 <= i /\\ i <= dimindex(:N) /\\\n 1 <= j /\\ j <= dimindex(:N)\n ==> reflect_along (basis i) x$j = if j = i then --(x$j) else x$j`;;\n\nlet REFLECT_BASIS_ALONG_BASIS = `!i j. 1 <= i /\\ i <= dimindex(:N) /\\ 1 <= j /\\ j <= dimindex(:N)\n ==> reflect_along (basis i:real^N) (basis j) =\n if i = j then --(basis j) else basis j`;;\n\nlet NORM_REFLECT_ALONG = `!v x:real^N. norm(reflect_along v x) = norm x`;;\n\nlet REFLECT_ALONG_EQ = `!v x y:real^N. reflect_along v x = reflect_along v y <=> x = y`;;\n\nlet REFLECT_ALONG_SURJECTIVE = `!v y:real^N. ?x. reflect_along v x = y`;;\n\nlet REFLECT_ALONG_SWITCH = `!a b:real^N.\n norm a = norm b /\\ ~(a = b)\n ==> reflect_along (b - a) a = b /\\ reflect_along (b - a) b = a`;;\n\nlet ROTOINVERSION_EXISTS_GEN = `!s a b:real^N.\n subspace s /\\ a IN s /\\ b IN s /\\ ~(a = b) /\\ norm a = norm b\n ==> ?f. orthogonal_transformation f /\\ IMAGE f s = s /\\\n (!x. orthogonal a x /\\ orthogonal b x ==> f x = x) /\\\n det (matrix f) = -- &1 /\\\n f a = b /\\ f b = a`;;\n\nlet ORTHOGONAL_TRANSFORMATION_EXISTS_GEN = `!s a b:real^N.\n subspace s /\\ a IN s /\\ b IN s /\\ norm a = norm b\n ==> ?f. orthogonal_transformation f /\\ IMAGE f s = s /\\\n (!x. orthogonal a x /\\ orthogonal b x ==> f x = x) /\\\n f a = b /\\ f b = a`;;\n\nlet ORTHOGONAL_TRANSFORMATION_GENERATED_BY_REFLECTIONS = `!f:real^N->real^N n.\n orthogonal_transformation f /\\\n dimindex(:N) <= dim {x | f x = x} + n\n ==> ?l. LENGTH l <= n /\\ ALL (\\v. ~(v = vec 0)) l /\\\n f = ITLIST (\\v h. reflect_along v o h) l I`;;\n\nlet ORTHOGONAL_TRANSFORMATION_REFLECT_INDUCT = `!P:(real^N->real^N)->bool.\n P I /\\\n (!f a. orthogonal_transformation f /\\ ~(a = vec 0) /\\ P f\n ==> P(reflect_along a o f))\n ==> !f. orthogonal_transformation f ==> P f`;;\n\nlet SCALING_THEOREMS v =\n let th1 = UNDISCH(snd(EQ_IMP_RULE(ISPEC v NORM_POS_LT))) in\n let t = rand(concl th1) in\n end_itlist CONJ (map (C MP th1 o SPEC t) (!scaling_theorems));;\n\nlet TRANSLATION_INVARIANTS x =\n end_itlist CONJ (mapfilter (ISPEC x) (!invariant_under_translation));;\n\nlet USABLE_CONCLUSION f ths th =\n let ith = PURE_REWRITE_RULE[RIGHT_FORALL_IMP_THM] (ISPEC f th) in\n let bod = concl ith in\n let cjs = conjuncts(fst(dest_imp bod)) in\n let ths = map (fun t -> find(fun th -> aconv (concl th) t) ths) cjs in\n GEN_ALL(MP ith (end_itlist CONJ ths));;\n\nlet LINEAR_INVARIANTS =\n let sths = (CONJUNCTS o prove)\n (`(!f:real^M->real^N.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> (!x y. f x = f y ==> x = y)) /\\\n (!f:real^N->real^N.\n linear f /\\ (!x. norm(f x) = norm x) ==> (!y. ?x. f x = y)) /\\\n (!f:real^N->real^N. linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (!y. ?x. f x = y)) /\\\n (!f:real^N->real^N. linear f /\\ (!y. ?x. f x = y)\n ==> (!x y. f x = f y ==> x = y))`,\n CONJ_TAC THENL\n [ONCE_REWRITE_TAC[GSYM VECTOR_SUB_EQ] THEN\n SIMP_TAC[GSYM LINEAR_SUB; GSYM NORM_EQ_0];\n MESON_TAC[ORTHOGONAL_TRANSFORMATION_SURJECTIVE;\n ORTHOGONAL_TRANSFORMATION_INJECTIVE; ORTHOGONAL_TRANSFORMATION;\n LINEAR_SURJECTIVE_IFF_INJECTIVE]]) in\n fun f ths ->\n let ths' = ths @ mapfilter (USABLE_CONCLUSION f ths) sths in\n end_itlist CONJ\n (mapfilter (USABLE_CONCLUSION f ths') (!invariant_under_linear));;\n\nlet GEOM_ORIGIN_CONV,GEOM_TRANSLATE_CONV =\n let pth = `!a:real^N. a = a + vec 0 /\\\n {} = IMAGE (\\x. a + x) {} /\\\n {} = IMAGE (IMAGE (\\x. a + x)) {} /\\\n (:real^N) = IMAGE (\\x. a + x) (:real^N) /\\\n (:real^N->bool) = IMAGE (IMAGE (\\x. a + x)) (:real^N->bool) /\\\n [] = MAP (\\x. a + x) []`;;\n\nlet EXISTS_GENVAR_RULE =\n let rec rule vs th =\n match vs with\n [] -> th\n | v::ovs -> let x,bod = dest_exists(concl th) in\n let th1 = rule ovs (ASSUME bod) in\n let th2 = SIMPLE_CHOOSE x (SIMPLE_EXISTS x th1) in\n PROVE_HYP th (CONV_RULE (GEN_ALPHA_CONV v) th2) in\n fun th -> rule (map (genvar o type_of) (fst(strip_exists(concl th)))) th;;\n\nlet GEOM_BASIS_MULTIPLE_RULE =\n let pth = `!f. orthogonal_transformation (f:real^N->real^N)\n ==> (vec 0 = f(vec 0) /\\\n {} = IMAGE f {} /\\\n {} = IMAGE (IMAGE f) {} /\\\n (:real^N) = IMAGE f (:real^N) /\\\n (:real^N->bool) = IMAGE (IMAGE f) (:real^N->bool) /\\\n [] = MAP f []) /\\\n ((!P. (!x. P x) <=> (!x. P (f x))) /\\\n (!P. (?x. P x) <=> (?x. P (f x))) /\\\n (!Q. (!s. Q s) <=> (!s. Q (IMAGE f s))) /\\\n (!Q. (?s. Q s) <=> (?s. Q (IMAGE f s))) /\\\n (!Q. (!s. Q s) <=> (!s. Q (IMAGE (IMAGE f) s))) /\\\n (!Q. (?s. Q s) <=> (?s. Q (IMAGE (IMAGE f) s))) /\\\n (!P. (!g:real^1->real^N. P g) <=> (!g. P (f o g))) /\\\n (!P. (?g:real^1->real^N. P g) <=> (?g. P (f o g))) /\\\n (!P. (!g:num->real^N. P g) <=> (!g. P (f o g))) /\\\n (!P. (?g:num->real^N. P g) <=> (?g. P (f o g))) /\\\n (!Q. (!l. Q l) <=> (!l. Q(MAP f l))) /\\\n (!Q. (?l. Q l) <=> (?l. Q(MAP f l)))) /\\\n ((!P. {x | P x} = IMAGE f {x | P(f x)}) /\\\n (!Q. {s | Q s} = IMAGE (IMAGE f) {s | Q(IMAGE f s)}) /\\\n (!R. {l | R l} = IMAGE (MAP f) {l | R(MAP f l)}))`;;\n\nlet GEN_GEOM_NORMALIZE_TAC x avoid (asl,w as gl) =\n let avs,bod = strip_forall w\n and avs' = subtract (frees w) (freesl(map (concl o snd) asl)) in\n (MAP_EVERY X_GEN_TAC avs THEN\n MAP_EVERY (fun t -> SPEC_TAC(t,t)) (rev(subtract (avs@avs') [x])) THEN\n SPEC_TAC(x,x) THEN\n W(MATCH_MP_TAC o GEOM_NORMALIZE_RULE avoid o snd)) gl;;\n\nlet GEOM_NORMALIZE_TAC x = GEN_GEOM_NORMALIZE_TAC x [];;\n\nlet COLLINEAR_TRANSLATION_EQ = `!a s. collinear (IMAGE (\\x. a + x) s) <=> collinear s`;;\n\nadd_translation_invariants [COLLINEAR_TRANSLATION_EQ];;\n\nlet COLLINEAR_TRANSLATION = `!s a. collinear s ==> collinear (IMAGE (\\x. a + x) s)`;;\n\nlet COLLINEAR_LINEAR_IMAGE = `!f s. collinear s /\\ linear f ==> collinear(IMAGE f s)`;;\n\nlet COLLINEAR_LINEAR_IMAGE_EQ = `!f s. linear f /\\ (!x y. f x = f y ==> x = y)\n ==> (collinear (IMAGE f s) <=> collinear s)`;;\n\nadd_linear_invariants [COLLINEAR_LINEAR_IMAGE_EQ];;\n\nlet GEOM_DROP_DIMENSION_RULE =\n let oth = prove\n (`!f:real^M->real^N.\n linear f /\\ (!x. norm(f x) = norm x)\n ==> linear f /\\\n (!x y. f x = f y ==> x = y) /\\\n (!x. norm(f x) = norm x)`,\n MESON_TAC[PRESERVES_NORM_INJECTIVE])\n and cth = prove\n (`linear(f:real^M->real^N)\n ==> vec 0 = f(vec 0) /\\\n {} = IMAGE f {} /\\\n {} = IMAGE (IMAGE f) {} /\\\n [] = MAP f []`,\n REWRITE_TAC[IMAGE_CLAUSES; MAP; GSYM LINEAR_0]) in\n fun dth th ->\n let ath = GEN_ALL th\n and eth = MATCH_MP ISOMETRY_UNIV_UNIV dth\n and avoid = variables(concl th) in\n let f,bod = dest_exists(concl eth) in\n let fimage = list_mk_icomb \"IMAGE\" [f]\n and fmap = list_mk_icomb \"MAP\" [f]\n and fcompose = list_mk_icomb \"o\" [f] in\n let fimage2 = list_mk_icomb \"IMAGE\" [fimage] in\n let lin,iso = CONJ_PAIR(ASSUME bod) in\n let olduniv = rand(rand(concl dth))\n and newuniv = rand(lhand(concl dth)) in\n let oldty = fst(dest_fun_ty(type_of olduniv))\n and newty = fst(dest_fun_ty(type_of newuniv)) in\n let newvar v =\n let n,t = dest_var v in\n variant avoid (mk_var(n,tysubst[newty,oldty] t)) in\n let newterm v =\n try let v' = newvar v in\n tryfind (fun f -> mk_comb(f,v')) [f;fimage;fmap;fcompose;fimage2]\n with Failure _ -> v in\n let specrule th =\n let v = fst(dest_forall(concl th)) in SPEC (newterm v) th in\n let sth = SUBS(CONJUNCTS(MATCH_MP cth lin)) ath in\n let fth = SUBS[SYM(MATCH_MP LINEAR_0 lin)] (repeat specrule sth) in\n let thps = CONJUNCTS(MATCH_MP oth (ASSUME bod)) in\n let th5 = LINEAR_INVARIANTS f thps in\n let th6 = GEN_REWRITE_RULE REDEPTH_CONV [th5] fth in\n let th7 = PROVE_HYP eth (SIMPLE_CHOOSE f th6) in\n GENL (map newvar (fst(strip_forall(concl ath)))) th7;;\n\nlet GEOM_EQUAL_DIMENSION_RULE =\n let bth = prove\n (`dimindex(:M) = dimindex(:N)\n ==> ?f:real^M->real^N.\n (linear f /\\ (!y. ?x. f x = y)) /\\\n (!x. norm(f x) = norm x)`,\n REWRITE_TAC[SET_RULE `(!y. ?x. f x = y) <=> IMAGE f UNIV = UNIV`] THEN\n DISCH_TAC THEN REWRITE_TAC[GSYM CONJ_ASSOC] THEN\n MATCH_MP_TAC ISOMETRY_UNIV_SUBSPACE THEN\n REWRITE_TAC[SUBSPACE_UNIV; DIM_UNIV] THEN FIRST_ASSUM ACCEPT_TAC)\n and pth = prove\n (`!f:real^M->real^N.\n linear f /\\ (!y. ?x. f x = y)\n ==> (vec 0 = f(vec 0) /\\\n {} = IMAGE f {} /\\\n {} = IMAGE (IMAGE f) {} /\\\n (:real^N) = IMAGE f (:real^M) /\\\n (:real^N->bool) = IMAGE (IMAGE f) (:real^M->bool) /\\\n [] = MAP f []) /\\\n ((!P. (!x. P x) <=> (!x. P (f x))) /\\\n (!P. (?x. P x) <=> (?x. P (f x))) /\\\n (!Q. (!s. Q s) <=> (!s. Q (IMAGE f s))) /\\\n (!Q. (?s. Q s) <=> (?s. Q (IMAGE f s))) /\\\n (!Q. (!s. Q s) <=> (!s. Q (IMAGE (IMAGE f) s))) /\\\n (!Q. (?s. Q s) <=> (?s. Q (IMAGE (IMAGE f) s))) /\\\n (!P. (!g:real^1->real^N. P g) <=> (!g. P (f o g))) /\\\n (!P. (?g:real^1->real^N. P g) <=> (?g. P (f o g))) /\\\n (!P. (!g:num->real^N. P g) <=> (!g. P (f o g))) /\\\n (!P. (?g:num->real^N. P g) <=> (?g. P (f o g))) /\\\n (!Q. (!l. Q l) <=> (!l. Q(MAP f l))) /\\\n (!Q. (?l. Q l) <=> (?l. Q(MAP f l)))) /\\\n ((!P. {x | P x} = IMAGE f {x | P(f x)}) /\\\n (!Q. {s | Q s} = IMAGE (IMAGE f) {s | Q(IMAGE f s)}) /\\\n (!R. {l | R l} = IMAGE (MAP f) {l | R(MAP f l)}))`,\n GEN_TAC THEN\n SIMP_TAC[SET_RULE `UNIV = IMAGE f UNIV <=> (!y. ?x. f x = y)`;\n SURJECTIVE_IMAGE] THEN\n MATCH_MP_TAC MONO_AND THEN\n REWRITE_TAC[QUANTIFY_SURJECTION_HIGHER_THM] THEN\n REWRITE_TAC[IMAGE_CLAUSES; MAP] THEN MESON_TAC[LINEAR_0]) in\n fun dth th ->\n let eth = EXISTS_GENVAR_RULE (MATCH_MP bth dth) in\n let f,bod = dest_exists(concl eth) in\n let lsth,neth = CONJ_PAIR(ASSUME bod) in\n let cth,qth = CONJ_PAIR(MATCH_MP pth lsth) in\n let th1 = CONV_RULE\n (EXPAND_QUANTS_CONV qth THENC SUBS_CONV(CONJUNCTS cth)) th in\n let ith = LINEAR_INVARIANTS f (neth::CONJUNCTS lsth) in\n let th2 = GEN_REWRITE_RULE (RAND_CONV o REDEPTH_CONV) [BETA_THM;ith] th1 in\n let th3 = GEN f (DISCH bod th2) in\n MP (CONV_RULE (REWR_CONV LEFT_FORALL_IMP_THM) th3) eth;;" }, { "theorem_id": 73, "title": "097_cramer_s_rule", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "section \\Elementary Linear Algebra on Euclidean Spaces\\\n\ntheory Linear_Algebra\nimports\n Euclidean_Space\n \"HOL-Library.Infinite_Set\"\nbegin\n\nlemma linear_simps:\n assumes \"bounded_linear f\"\n shows\n \"f (a + b) = f a + f b\"\n \"f (a - b) = f a - f b\"\n \"f 0 = 0\"\n \"f (- a) = - f a\"\n \"f (s *\\<^sub>R v) = s *\\<^sub>R (f v)\"\n by sorry\n\nlemma finite_Atleast_Atmost_nat[simp]: \"finite {f x |x. x \\ (UNIV::'a::finite set)}\"\n by sorry\n\nlemma substdbasis_expansion_unique:\n includes inner_syntax\n assumes d: \"d \\ Basis\"\n shows \"(\\i\\d. f i *\\<^sub>R i) = (x::'a::euclidean_space) \\\n (\\i\\Basis. (i \\ d \\ f i = x \\ i) \\ (i \\ d \\ x \\ i = 0))\"\n by sorry\n\nlemma independent_substdbasis: \"d \\ Basis \\ independent d\"\n by sorry\n\nlemma subset_translation_eq [simp]:\n fixes a :: \"'a::real_vector\" shows \"(+) a ` s \\ (+) a ` t \\ s \\ t\"\n by sorry\n\nlemma translate_inj_on:\n fixes A :: \"'a::ab_group_add set\"\n shows \"inj_on (\\x. a + x) A\"\n by sorry\n\nlemma translation_assoc:\n fixes a b :: \"'a::ab_group_add\"\n shows \"(\\x. b + x) ` ((\\x. a + x) ` S) = (\\x. (a + b) + x) ` S\"\n by sorry\n\nlemma translation_invert:\n fixes a :: \"'a::ab_group_add\"\n assumes \"(\\x. a + x) ` A = (\\x. a + x) ` B\"\n shows \"A = B\"\n by sorry\n\nlemma translation_galois:\n fixes a :: \"'a::ab_group_add\"\n shows \"T = ((\\x. a + x) ` S) \\ S = ((\\x. (- a) + x) ` T)\"\n by sorry\n\nlemma translation_inverse_subset:\n assumes \"((\\x. - a + x) ` V) \\ (S :: 'n::ab_group_add set)\"\n shows \"V \\ ((\\x. a + x) ` S)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\More interesting properties of the norm\\\n\nunbundle inner_syntax\n\ntext\\Equality of vectors in terms of \\<^term>\\(\\)\\ products.\\\n\nlemma linear_componentwise:\n fixes f:: \"'a::euclidean_space \\ 'b::real_inner\"\n assumes lf: \"linear f\"\n shows \"(f x) \\ j = (\\i\\Basis. (x\\i) * (f i\\j))\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma vector_eq: \"x = y \\ x \\ x = x \\ y \\ y \\ y = x \\ x\"\n by sorry\n\nlemma norm_triangle_half_r:\n \"norm (y - x1) < e/2 \\ norm (y - x2) < e/2 \\ norm (x1 - x2) < e\"\n by sorry\n\nlemma norm_triangle_half_l:\n assumes \"norm (x - y) < e/2\" and \"norm (x' - y) < e/2\"\n shows \"norm (x - x') < e\"\n by sorry\n\nlemma abs_triangle_half_r:\n fixes y :: \"'a::linordered_field\"\n shows \"abs (y - x1) < e/2 \\ abs (y - x2) < e/2 \\ abs (x1 - x2) < e\"\n by sorry\n\nlemma abs_triangle_half_l:\n fixes y :: \"'a::linordered_field\"\n assumes \"abs (x - y) < e/2\" and \"abs (x' - y) < e/2\"\n shows \"abs (x - x') < e\"\n by sorry\n\nlemma sum_clauses:\n shows \"sum f {} = 0\"\n and \"finite S \\ sum f (insert x S) = (if x \\ S then sum f S else f x + sum f S)\"\n by sorry\n\nlemma vector_eq_ldot: \"(\\x. x \\ y = x \\ z) \\ y = z\" and vector_eq_rdot: \"(\\z. x \\ z = y \\ z) \\ x = y\"\n by sorry\n\nsubsection \\Substandard Basis\\\n\nlemma ex_card:\n assumes \"n \\ card A\"\n shows \"\\S\\A. card S = n\"\n by sorry\n\nlemma subspace_substandard: \"subspace {x::'a::euclidean_space. (\\i\\Basis. P i \\ x\\i = 0)}\"\n by sorry\n\nlemma dim_substandard:\n assumes d: \"d \\ Basis\"\n shows \"dim {x::'a::euclidean_space. \\i\\Basis. i \\ d \\ x\\i = 0} = card d\" (is \"dim ?A = _\")\n by sorry\n\nsubsection \\Orthogonality\\\n\ndefinition\\<^marker>\\tag important\\ (in real_inner) \"orthogonal x y \\ x \\ y = 0\"\n\ncontext real_inner\nbegin\n\nlemma orthogonal_self: \"orthogonal x x \\ x = 0\"\n by sorry\n\nlemma orthogonal_clauses:\n \"orthogonal a 0\"\n \"orthogonal a x \\ orthogonal a (c *\\<^sub>R x)\"\n \"orthogonal a x \\ orthogonal a (- x)\"\n \"orthogonal a x \\ orthogonal a y \\ orthogonal a (x + y)\"\n \"orthogonal a x \\ orthogonal a y \\ orthogonal a (x - y)\"\n \"orthogonal 0 a\"\n \"orthogonal x a \\ orthogonal (c *\\<^sub>R x) a\"\n \"orthogonal x a \\ orthogonal (- x) a\"\n \"orthogonal x a \\ orthogonal y a \\ orthogonal (x + y) a\"\n \"orthogonal x a \\ orthogonal y a \\ orthogonal (x - y) a\"\n by sorry\n\nend\n\nlemma orthogonal_commute: \"orthogonal x y \\ orthogonal y x\"\n by sorry\n\nlemma orthogonal_scaleR [simp]: \"c \\ 0 \\ orthogonal (c *\\<^sub>R x) = orthogonal x\"\n by sorry\n\nlemma pairwise_ortho_scaleR:\n \"pairwise (\\i j. orthogonal (f i) (g j)) B\n \\ pairwise (\\i j. orthogonal (a i *\\<^sub>R f i) (a j *\\<^sub>R g j)) B\"\n by sorry\n\nlemma orthogonal_rvsum:\n \"\\finite s; \\y. y \\ s \\ orthogonal x (f y)\\ \\ orthogonal x (sum f s)\"\n by sorry\n\nlemma orthogonal_lvsum:\n \"\\finite s; \\x. x \\ s \\ orthogonal (f x) y\\ \\ orthogonal (sum f s) y\"\n by sorry\n\nlemma norm_add_Pythagorean:\n assumes \"orthogonal a b\"\n shows \"(norm (a + b))\\<^sup>2 = (norm a)\\<^sup>2 + (norm b)\\<^sup>2\"\n by sorry\n\nlemma norm_sum_Pythagorean:\n assumes \"finite I\" \"pairwise (\\i j. orthogonal (f i) (f j)) I\"\n shows \"(norm (sum f I))\\<^sup>2 = (\\i\\I. (norm (f i))\\<^sup>2)\"\n by sorry\n\nsubsection \\Orthogonality of a transformation\\\n\ndefinition\\<^marker>\\tag important\\ \"orthogonal_transformation f \\ linear f \\ (\\v w. f v \\ f w = v \\ w)\"\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation:\n \"orthogonal_transformation f \\ linear f \\ (\\v. norm (f v) = norm v)\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation_id [simp]: \"orthogonal_transformation (\\x. x)\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_orthogonal_transformation:\n \"orthogonal_transformation f \\ orthogonal (f x) (f y) \\ orthogonal x y\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation_compose:\n \"\\orthogonal_transformation f; orthogonal_transformation g\\ \\ orthogonal_transformation(f \\ g)\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation_neg:\n \"orthogonal_transformation(\\x. -(f x)) \\ orthogonal_transformation f\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation_scaleR: \"orthogonal_transformation f \\ f (c *\\<^sub>R v) = c *\\<^sub>R f v\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation_linear:\n \"orthogonal_transformation f \\ linear f\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation_inj:\n \"orthogonal_transformation f \\ inj f\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation_surj:\n \"orthogonal_transformation f \\ surj f\"\n for f :: \"'a::euclidean_space \\ 'a::euclidean_space\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation_bij:\n \"orthogonal_transformation f \\ bij f\"\n for f :: \"'a::euclidean_space \\ 'a::euclidean_space\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation_inv:\n \"orthogonal_transformation f \\ orthogonal_transformation (inv f)\"\n for f :: \"'a::euclidean_space \\ 'a::euclidean_space\"\n by sorry\n\nlemma\\<^marker>\\tag unimportant\\ orthogonal_transformation_norm:\n \"orthogonal_transformation f \\ norm (f x) = norm x\"\n by sorry\n\nsubsection \\Bilinear functions\\\n\ndefinition\\<^marker>\\tag important\\\nbilinear :: \"('a::real_vector \\ 'b::real_vector \\ 'c::real_vector) \\ bool\" where\n\"bilinear f \\ (\\x. linear (\\y. f x y)) \\ (\\y. linear (\\x. f x y))\"\n\nlemma bilinear_ladd: \"bilinear h \\ h (x + y) z = h x z + h y z\"\n by sorry\n\nlemma bilinear_radd: \"bilinear h \\ h x (y + z) = h x y + h x z\"\n by sorry\n\nlemma bilinear_times:\n fixes c::\"'a::real_algebra\" shows \"bilinear (\\x y::'a. x*y)\"\n by sorry\n\nlemma bilinear_lmul: \"bilinear h \\ h (c *\\<^sub>R x) y = c *\\<^sub>R h x y\"\n by sorry\n\nlemma bilinear_rmul: \"bilinear h \\ h x (c *\\<^sub>R y) = c *\\<^sub>R h x y\"\n by sorry\n\nlemma bilinear_lneg: \"bilinear h \\ h (- x) y = - h x y\"\n by sorry\n\nlemma bilinear_rneg: \"bilinear h \\ h x (- y) = - h x y\"\n by sorry\n\nlemma (in ab_group_add) eq_add_iff: \"x = x + y \\ y = 0\"\n by sorry\n\nlemma bilinear_lzero:\n assumes \"bilinear h\"\n shows \"h 0 x = 0\"\n by sorry\n\nlemma bilinear_rzero:\n assumes \"bilinear h\"\n shows \"h x 0 = 0\"\n by sorry\n\nlemma bilinear_lsub: \"bilinear h \\ h (x - y) z = h x z - h y z\"\n by sorry\n\nlemma bilinear_rsub: \"bilinear h \\ h z (x - y) = h z x - h z y\"\n by sorry\n\nlemma bilinear_sum:\n assumes \"bilinear h\"\n shows \"h (sum f S) (sum g T) = sum (\\(i,j). h (f i) (g j)) (S \\ T) \"\n by sorry\n\nsubsection \\Adjoints\\\n\ndefinition\\<^marker>\\tag important\\ adjoint :: \"(('a::real_inner) \\ ('b::real_inner)) \\ 'b \\ 'a\" where\n\"adjoint f = (SOME f'. \\x y. f x \\ y = x \\ f' y)\"\n\nlemma adjoint_unique:\n assumes \"\\x y. inner (f x) y = inner x (g y)\"\n shows \"adjoint f = g\"\n by sorry\n\ntext \\TODO: The following lemmas about adjoints should hold for any\n Hilbert space (i.e. complete inner product space).\n (see \\<^url>\\https://en.wikipedia.org/wiki/Hermitian_adjoint\\)\n\\\n\nlemma adjoint_works:\n fixes f :: \"'n::euclidean_space \\ 'm::euclidean_space\"\n assumes lf: \"linear f\"\n shows \"x \\ adjoint f y = f x \\ y\"\n by sorry\n\nlemma adjoint_clauses:\n fixes f :: \"'n::euclidean_space \\ 'm::euclidean_space\"\n assumes lf: \"linear f\"\n shows \"x \\ adjoint f y = f x \\ y\"\n and \"adjoint f y \\ x = y \\ f x\"\n by sorry\n\nlemma adjoint_linear:\n fixes f :: \"'n::euclidean_space \\ 'm::euclidean_space\"\n assumes lf: \"linear f\"\n shows \"linear (adjoint f)\"\n by sorry\n\nlemma adjoint_adjoint:\n fixes f :: \"'n::euclidean_space \\ 'm::euclidean_space\"\n assumes lf: \"linear f\"\n shows \"adjoint (adjoint f) = f\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Euclidean Spaces as Typeclass\\\n\nlemma independent_Basis: \"independent Basis\"\n by sorry\n\nlemma span_Basis [simp]: \"span Basis = UNIV\"\n by sorry\n\nlemma in_span_Basis: \"x \\ span Basis\"\n by sorry\n\nlemma representation_euclidean_space:\n \"representation Basis x = (\\b. if b \\ Basis then inner x b else 0)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\Linearity and Bilinearity continued\\\n\nlemma linear_bounded:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n assumes lf: \"linear f\"\n shows \"\\B. \\x. norm (f x) \\ B * norm x\"\n by sorry\n\nlemma linear_conv_bounded_linear:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n shows \"linear f \\ bounded_linear f\"\n by sorry\n\nlemmas linear_linear = linear_conv_bounded_linear[symmetric]\n\nlemma inj_linear_imp_inv_bounded_linear:\n fixes f::\"'a::euclidean_space \\ 'a\"\n shows \"\\bounded_linear f; inj f\\ \\ bounded_linear (inv f)\"\n by sorry\n\nlemma linear_bounded_pos:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n assumes lf: \"linear f\"\n obtains B where \"B > 0\" \"\\x. norm (f x) \\ B * norm x\"\n by sorry\n\nlemma linear_invertible_bounded_below_pos:\n fixes f :: \"'a::real_normed_vector \\ 'b::euclidean_space\"\n assumes \"linear f\" \"linear g\" and gf: \"g \\ f = id\"\n obtains B where \"B > 0\" \"\\x. B * norm x \\ norm(f x)\"\n by sorry\n\nlemma linear_inj_bounded_below_pos:\n fixes f :: \"'a::real_normed_vector \\ 'b::euclidean_space\"\n assumes \"linear f\" \"inj f\"\n obtains B where \"B > 0\" \"\\x. B * norm x \\ norm(f x)\"\n by sorry\n\nlemma bounded_linearI':\n fixes f ::\"'a::euclidean_space \\ 'b::real_normed_vector\"\n assumes \"\\x y. f (x + y) = f x + f y\"\n and \"\\c x. f (c *\\<^sub>R x) = c *\\<^sub>R f x\"\n shows \"bounded_linear f\"\n by sorry\n\nlemma bilinear_bounded:\n fixes h :: \"'m::euclidean_space \\ 'n::euclidean_space \\ 'k::real_normed_vector\"\n assumes bh: \"bilinear h\"\n shows \"\\B. \\x y. norm (h x y) \\ B * norm x * norm y\"\n by sorry\n\nlemma bilinear_conv_bounded_bilinear:\n fixes h :: \"'a::euclidean_space \\ 'b::euclidean_space \\ 'c::real_normed_vector\"\n shows \"bilinear h \\ bounded_bilinear h\"\n by sorry\n\nlemma bilinear_bounded_pos:\n fixes h :: \"'a::euclidean_space \\ 'b::euclidean_space \\ 'c::real_normed_vector\"\n assumes bh: \"bilinear h\"\n shows \"\\B > 0. \\x y. norm (h x y) \\ B * norm x * norm y\"\n by sorry\n\nlemma bounded_linear_imp_has_derivative: \n \"bounded_linear f \\ (f has_derivative f) net\"\n by sorry\n\nlemma linear_imp_has_derivative:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n shows \"linear f \\ (f has_derivative f) net\"\n by sorry\n\nlemma bounded_linear_imp_differentiable: \"bounded_linear f \\ f differentiable net\"\n by sorry\n\nlemma linear_imp_differentiable:\n fixes f :: \"'a::euclidean_space \\ 'b::real_normed_vector\"\n shows \"linear f \\ f differentiable net\"\n by sorry\n\nlemma of_real_differentiable [simp,derivative_intros]: \"of_real differentiable F\"\n by sorry\n\nlemma bounded_linear_representation:\n fixes B :: \"'a :: euclidean_space set\"\n assumes \"independent B\" \"span B = UNIV\"\n shows \"bounded_linear (\\v. representation B v b)\"\n by sorry\n\nsubsection\\<^marker>\\tag unimportant\\ \\We continue\\\n\nlemma independent_bound:\n fixes S :: \"'a::euclidean_space set\"\n shows \"independent S \\ finite S \\ card S \\ DIM('a)\"\n by sorry\n\nlemmas independent_imp_finite = finiteI_independent\n\ncorollary\\<^marker>\\tag unimportant\\ independent_card_le:\n fixes S :: \"'a::euclidean_space set\"\n assumes \"independent S\"\n shows \"card S \\ DIM('a)\"\n by sorry\n\nlemma dependent_biggerset:\n fixes S :: \"'a::euclidean_space set\"\n shows \"(finite S \\ card S > DIM('a)) \\ dependent S\"\n by sorry\n\ntext \\Picking an orthogonal replacement for a spanning set.\\\n\nlemma vector_sub_project_orthogonal:\n fixes b x :: \"'a::euclidean_space\"\n shows \"b \\ (x - ((b \\ x) / (b \\ b)) *\\<^sub>R b) = 0\"\n by sorry\n\nlemma pairwise_orthogonal_insert:\n assumes \"pairwise orthogonal S\"\n and \"\\y. y \\ S \\ orthogonal x y\"\n shows \"pairwise orthogonal (insert x S)\"\n by sorry\n\nlemma basis_orthogonal:\n fixes B :: \"'a::real_inner set\"\n assumes fB: \"finite B\"\n shows \"\\C. finite C \\ card C \\ card B \\ span C = span B \\ pairwise orthogonal C\"\n (is \" \\C. ?P B C\")\n by sorry\n\nlemma orthogonal_basis_exists:\n fixes V :: \"('a::euclidean_space) set\"\n shows \"\\B. independent B \\ B \\ span V \\ V \\ span B \\ (card B = dim V) \\ pairwise orthogonal B\"\n by sorry\n\ntext \\Low-dimensional subset is in a hyperplane (weak orthogonal complement).\\\n\nlemma span_not_UNIV_orthogonal:\n fixes S :: \"'a::euclidean_space set\"\n assumes sU: \"span S \\ UNIV\"\n shows \"\\a::'a. a \\ 0 \\ (\\x \\ span S. a \\ x = 0)\"\n by sorry\n\nlemma span_not_univ_subset_hyperplane:\n fixes S :: \"'a::euclidean_space set\"\n assumes SU: \"span S \\ UNIV\"\n shows \"\\ a. a \\0 \\ span S \\ {x. a \\ x = 0}\"\n by sorry\n\nlemma lowdim_subset_hyperplane:\n fixes S :: \"'a::euclidean_space set\"\n assumes d: \"dim S < DIM('a)\"\n shows \"\\a::'a. a \\ 0 \\ span S \\ {x. a \\ x = 0}\"\n by sorry\n\nlemma linear_eq_stdbasis:\n fixes f :: \"'a::euclidean_space \\ _\"\n assumes lf: \"linear f\"\n and lg: \"linear g\"\n and fg: \"\\b. b \\ Basis \\ f b = g b\"\n shows \"f = g\"\n by sorry\n\ntext \\Similar results for bilinear functions.\\\n\nlemma bilinear_eq:\n assumes bf: \"bilinear f\"\n and bg: \"bilinear g\"\n and SB: \"S \\ span B\"\n and TC: \"T \\ span C\"\n and \"x\\S\" \"y\\T\"\n and fg: \"\\x y. \\x \\ B; y\\ C\\ \\ f x y = g x y\"\n shows \"f x y = g x y\"\n by sorry\n\nlemma bilinear_eq_stdbasis:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space \\ _\"\n assumes bf: \"bilinear f\"\n and bg: \"bilinear g\"\n and fg: \"\\i j. i \\ Basis \\ j \\ Basis \\ f i j = g i j\"\n shows \"f = g\"\n by sorry\n\nsubsection \\Infinity norm\\\n\ndefinition\\<^marker>\\tag important\\ \"infnorm (x::'a::euclidean_space) = Sup {\\x \\ b\\ |b. b \\ Basis}\"\n\nlemma infnorm_set_image:\n fixes x :: \"'a::euclidean_space\"\n shows \"{\\x \\ i\\ |i. i \\ Basis} = (\\i. \\x \\ i\\) ` Basis\"\n by sorry\n\nlemma infnorm_Max:\n fixes x :: \"'a::euclidean_space\"\n shows \"infnorm x = Max ((\\i. \\x \\ i\\) ` Basis)\"\n by sorry\n\nlemma infnorm_set_lemma:\n fixes x :: \"'a::euclidean_space\"\n shows \"finite {\\x \\ i\\ |i. i \\ Basis}\"\n and \"{\\x \\ i\\ |i. i \\ Basis} \\ {}\"\n by sorry\n\nlemma infnorm_pos_le:\n fixes x :: \"'a::euclidean_space\"\n shows \"0 \\ infnorm x\"\n by sorry\n\nlemma infnorm_triangle:\n fixes x :: \"'a::euclidean_space\"\n shows \"infnorm (x + y) \\ infnorm x + infnorm y\"\n by sorry\n\nlemma infnorm_eq_0:\n fixes x :: \"'a::euclidean_space\"\n shows \"infnorm x = 0 \\ x = 0\"\n by sorry\n\nlemma infnorm_0: \"infnorm 0 = 0\"\n by sorry\n\nlemma infnorm_neg: \"infnorm (- x) = infnorm x\"\n by sorry\n\nlemma infnorm_sub: \"infnorm (x - y) = infnorm (y - x)\"\n by sorry\n\nlemma absdiff_infnorm: \"\\infnorm x - infnorm y\\ \\ infnorm (x - y)\"\n by sorry\n\nlemma real_abs_infnorm: \"\\infnorm x\\ = infnorm x\"\n by sorry\n\nlemma Basis_le_infnorm:\n fixes x :: \"'a::euclidean_space\"\n shows \"b \\ Basis \\ \\x \\ b\\ \\ infnorm x\"\n by sorry\n\nlemma infnorm_mul: \"infnorm (a *\\<^sub>R x) = \\a\\ * infnorm x\"\n by sorry\n\nlemma infnorm_mul_lemma: \"infnorm (a *\\<^sub>R x) \\ \\a\\ * infnorm x\"\n by sorry\n\nlemma infnorm_pos_lt: \"infnorm x > 0 \\ x \\ 0\"\n by sorry\n\ntext \\Prove that it differs only up to a bound from Euclidean norm.\\\n\nlemma infnorm_le_norm: \"infnorm x \\ norm x\"\n by sorry\n\nlemma norm_le_infnorm:\n fixes x :: \"'a::euclidean_space\"\n shows \"norm x \\ sqrt DIM('a) * infnorm x\"\n by sorry\n\nlemma tendsto_infnorm [tendsto_intros]:\n assumes \"(f \\ a) F\"\n shows \"((\\x. infnorm (f x)) \\ infnorm a) F\"\n by sorry\n\ntext \\Equality in Cauchy-Schwarz and triangle inequalities.\\\n\nlemma norm_cauchy_schwarz_eq: \"x \\ y = norm x * norm y \\ norm x *\\<^sub>R y = norm y *\\<^sub>R x\"\n (is \"?lhs \\ ?rhs\")\n by sorry\n\nlemma norm_cauchy_schwarz_abs_eq:\n \"\\x \\ y\\ = norm x * norm y \\\n norm x *\\<^sub>R y = norm y *\\<^sub>R x \\ norm x *\\<^sub>R y = - norm y *\\<^sub>R x\"\n by sorry\n\nlemma norm_triangle_eq:\n fixes x y :: \"'a::real_inner\"\n shows \"norm (x + y) = norm x + norm y \\ norm x *\\<^sub>R y = norm y *\\<^sub>R x\"\n by sorry\n\nlemma dist_triangle_eq:\n fixes x y z :: \"'a::real_inner\"\n shows \"dist x z = dist x y + dist y z \\\n norm (x - y) *\\<^sub>R (y - z) = norm (y - z) *\\<^sub>R (x - y)\"\n by sorry\n\nsubsection \\Collinearity\\\n\ndefinition\\<^marker>\\tag important\\ collinear :: \"'a::real_vector set \\ bool\"\n where \"collinear S \\ (\\u. \\x \\ S. \\ y \\ S. \\c. x - y = c *\\<^sub>R u)\"\n\nlemma collinear_alt:\n \"collinear S \\ (\\u v. \\x \\ S. \\c. x = u + c *\\<^sub>R v)\" (is \"?lhs = ?rhs\")\n by sorry\n\nlemma collinear:\n fixes S :: \"'a::{perfect_space,real_vector} set\"\n shows \"collinear S \\ (\\u. u \\ 0 \\ (\\x \\ S. \\ y \\ S. \\c. x - y = c *\\<^sub>R u))\"\n by sorry\n\nlemma collinear_subset: \"\\collinear T; S \\ T\\ \\ collinear S\"\n by sorry\n\nlemma collinear_empty [iff]: \"collinear {}\"\n by sorry\n\nlemma collinear_sing [iff]: \"collinear {x}\"\n by sorry\n\nlemma collinear_2 [iff]: \"collinear {x, y}\"\n by sorry\n\nlemma collinear_lemma: \"collinear {0, x, y} \\ x = 0 \\ y = 0 \\ (\\c. y = c *\\<^sub>R x)\"\n (is \"?lhs \\ ?rhs\")\n by sorry\n\nlemma collinear_iff_Reals: \"collinear {0::complex,w,z} \\ z/w \\ \\\"\n by sorry\n\nlemma collinear_scaleR_iff: \"collinear {0, \\ *\\<^sub>R w, \\ *\\<^sub>R z} \\ collinear {0,w,z} \\ \\=0 \\ \\=0\"\n (is \"?lhs = ?rhs\")\n by sorry\n\nlemma norm_cauchy_schwarz_equal: \"\\x \\ y\\ = norm x * norm y \\ collinear {0, x, y}\"\n by sorry\n\nlemma norm_triangle_eq_imp_collinear:\n fixes x y :: \"'a::real_inner\"\n assumes \"norm (x + y) = norm x + norm y\"\n shows \"collinear{0,x,y}\"\n by sorry\n\nsubsection\\Properties of special hyperplanes\\\n\nlemma subspace_hyperplane: \"subspace {x. a \\ x = 0}\"\n by sorry\n\nlemma subspace_hyperplane2: \"subspace {x. x \\ a = 0}\"\n by sorry\n\nlemma special_hyperplane_span:\n fixes S :: \"'n::euclidean_space set\"\n assumes \"k \\ Basis\"\n shows \"{x. k \\ x = 0} = span (Basis - {k})\"\n by sorry\n\nlemma dim_special_hyperplane:\n fixes k :: \"'n::euclidean_space\"\n shows \"k \\ Basis \\ dim {x. k \\ x = 0} = DIM('n) - 1\"\n by sorry\n\nproposition dim_hyperplane:\n fixes a :: \"'a::euclidean_space\"\n assumes \"a \\ 0\"\n shows \"dim {x. a \\ x = 0} = DIM('a) - 1\"\n by sorry\n\nlemma lowdim_eq_hyperplane:\n fixes S :: \"'a::euclidean_space set\"\n assumes \"dim S = DIM('a) - 1\"\n obtains a where \"a \\ 0\" and \"span S = {x. a \\ x = 0}\"\n by sorry\n\nlemma dim_eq_hyperplane:\n fixes S :: \"'n::euclidean_space set\"\n shows \"dim S = DIM('n) - 1 \\ (\\a. a \\ 0 \\ span S = {x. a \\ x = 0})\"\n by sorry\n\nsubsection\\ Orthogonal bases and Gram-Schmidt process\\\n\nlemma pairwise_orthogonal_independent:\n assumes \"pairwise orthogonal S\" and \"0 \\ S\"\n shows \"independent S\"\n by sorry\n\nlemma pairwise_orthogonal_imp_finite:\n fixes S :: \"'a::euclidean_space set\"\n assumes \"pairwise orthogonal S\"\n shows \"finite S\"\n by sorry\n\nlemma subspace_orthogonal_to_vector: \"subspace {y. orthogonal x y}\"\n by sorry\n\nlemma subspace_orthogonal_to_vectors: \"subspace {y. \\x \\ S. orthogonal x y}\"\n by sorry\n\nlemma orthogonal_to_span:\n assumes a: \"a \\ span S\" and x: \"\\y. y \\ S \\ orthogonal x y\"\n shows \"orthogonal x a\"\n by sorry\n\nproposition Gram_Schmidt_step:\n fixes S :: \"'a::euclidean_space set\"\n assumes S: \"pairwise orthogonal S\" and x: \"x \\ span S\"\n shows \"orthogonal x (a - (\\b\\S. (b \\ a / (b \\ b)) *\\<^sub>R b))\"\n by sorry\n\nlemma orthogonal_extension_aux:\n fixes S :: \"'a::euclidean_space set\"\n assumes \"finite T\" \"finite S\" \"pairwise orthogonal S\"\n shows \"\\U. pairwise orthogonal (S \\ U) \\ span (S \\ U) = span (S \\ T)\"\n by sorry\n\nproposition orthogonal_extension:\n fixes S :: \"'a::euclidean_space set\"\n assumes S: \"pairwise orthogonal S\"\n obtains U where \"pairwise orthogonal (S \\ U)\" \"span (S \\ U) = span (S \\ T)\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ orthogonal_extension_strong:\n fixes S :: \"'a::euclidean_space set\"\n assumes S: \"pairwise orthogonal S\"\n obtains U where \"U \\ (insert 0 S) = {}\" \"pairwise orthogonal (S \\ U)\"\n \"span (S \\ U) = span (S \\ T)\"\n by sorry\n\nsubsection\\Decomposing a vector into parts in orthogonal subspaces\\\n\ntext\\existence of orthonormal basis for a subspace.\\\n\nlemma orthogonal_spanningset_subspace:\n fixes S :: \"'a :: euclidean_space set\"\n assumes \"subspace S\"\n obtains B where \"B \\ S\" \"pairwise orthogonal B\" \"span B = S\"\n by sorry\n\nlemma orthogonal_basis_subspace:\n fixes S :: \"'a :: euclidean_space set\"\n assumes \"subspace S\"\n obtains B where \"0 \\ B\" \"B \\ S\" \"pairwise orthogonal B\" \"independent B\"\n \"card B = dim S\" \"span B = S\"\n by sorry\n\nproposition orthonormal_basis_subspace:\n fixes S :: \"'a :: euclidean_space set\"\n assumes \"subspace S\"\n obtains B where \"B \\ S\" \"pairwise orthogonal B\"\n and \"\\x. x \\ B \\ norm x = 1\"\n and \"independent B\" \"card B = dim S\" \"span B = S\"\n by sorry\n\nproposition\\<^marker>\\tag unimportant\\ orthogonal_to_subspace_exists_gen:\n fixes S :: \"'a :: euclidean_space set\"\n assumes \"span S \\ span T\"\n obtains x where \"x \\ 0\" \"x \\ span T\" \"\\y. y \\ span S \\ orthogonal x y\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ orthogonal_to_subspace_exists:\n fixes S :: \"'a :: euclidean_space set\"\n assumes \"dim S < DIM('a)\"\n obtains x where \"x \\ 0\" \"\\y. y \\ span S \\ orthogonal x y\"\n by sorry\n\ncorollary\\<^marker>\\tag unimportant\\ orthogonal_to_vector_exists:\n fixes x :: \"'a :: euclidean_space\"\n assumes \"2 \\ DIM('a)\"\n obtains y where \"y \\ 0\" \"orthogonal x y\"\n by sorry\n\nproposition\\<^marker>\\tag unimportant\\ orthogonal_subspace_decomp_exists:\n fixes S :: \"'a :: euclidean_space set\"\n obtains y z\n where \"y \\ span S\"\n and \"\\w. w \\ span S \\ orthogonal z w\"\n and \"x = y + z\"\n by sorry\n\nlemma orthogonal_subspace_decomp_unique:\n fixes S :: \"'a :: euclidean_space set\"\n assumes \"x + y = x' + y'\"\n and ST: \"x \\ span S\" \"x' \\ span S\" \"y \\ span T\" \"y' \\ span T\"\n and orth: \"\\a b. \\a \\ S; b \\ T\\ \\ orthogonal a b\"\n shows \"x = x' \\ y = y'\"\n by sorry\n\nlemma vector_in_orthogonal_spanningset:\n fixes a :: \"'a::euclidean_space\"\n obtains S where \"a \\ S\" \"pairwise orthogonal S\" \"span S = UNIV\"\n by sorry\n\nlemma vector_in_orthogonal_basis:\n fixes a :: \"'a::euclidean_space\"\n assumes \"a \\ 0\"\n obtains S where \"a \\ S\" \"0 \\ S\" \"pairwise orthogonal S\" \"independent S\" \"finite S\"\n \"span S = UNIV\" \"card S = DIM('a)\"\n by sorry\n\nlemma vector_in_orthonormal_basis:\n fixes a :: \"'a::euclidean_space\"\n assumes \"norm a = 1\"\n obtains S where \"a \\ S\" \"pairwise orthogonal S\" \"\\x. x \\ S \\ norm x = 1\"\n \"independent S\" \"card S = DIM('a)\" \"span S = UNIV\"\n by sorry\n\nproposition dim_orthogonal_sum:\n fixes A :: \"'a::euclidean_space set\"\n assumes \"\\x y. \\x \\ A; y \\ B\\ \\ x \\ y = 0\"\n shows \"dim(A \\ B) = dim A + dim B\"\n by sorry\n\nlemma dim_subspace_orthogonal_to_vectors:\n fixes A :: \"'a::euclidean_space set\"\n assumes \"subspace A\" \"subspace B\" \"A \\ B\"\n shows \"dim {y \\ B. \\x \\ A. orthogonal x y} + dim A = dim B\"\n by sorry\n\nsubsection\\Linear functions are (uniformly) continuous on any set\\\n\nsubsection\\<^marker>\\tag unimportant\\ \\Topological properties of linear functions\\\n\nlemma linear_lim_0:\n assumes \"bounded_linear f\"\n shows \"(f \\ 0) (at (0))\"\n by sorry\n\nlemma linear_continuous_at:\n \"bounded_linear f \\continuous (at a) f\"\n by sorry\n\nlemma linear_continuous_within:\n \"bounded_linear f \\ continuous (at x within s) f\"\n by sorry\n\nlemma linear_continuous_on:\n \"bounded_linear f \\ continuous_on s f\"\n by sorry\n\nlemma Lim_linear:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\" and h :: \"'b \\ 'c::real_normed_vector\"\n assumes \"(f \\ l) F\" \"linear h\"\n shows \"((\\x. h(f x)) \\ h l) F\"\n by sorry\n\nlemma linear_continuous_compose:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\" and g :: \"'b \\ 'c::real_normed_vector\"\n assumes \"continuous F f\" \"linear g\"\n shows \"continuous F (\\x. g(f x))\"\n by sorry\n\nlemma linear_continuous_on_compose:\n fixes f :: \"'a::euclidean_space \\ 'b::euclidean_space\" and g :: \"'b \\ 'c::real_normed_vector\"\n assumes \"continuous_on S f\" \"linear g\"\n shows \"continuous_on S (\\x. g(f x))\"\n by sorry\n\ntext\\Also bilinear functions, in composition form\\\n\nlemma bilinear_continuous_compose:\n fixes h :: \"'a::euclidean_space \\ 'b::euclidean_space \\ 'c::real_normed_vector\"\n assumes \"continuous F f\" \"continuous F g\" \"bilinear h\"\n shows \"continuous F (\\x. h (f x) (g x))\"\n by sorry\n\nlemma bilinear_continuous_on_compose:\n fixes h :: \"'a::euclidean_space \\ 'b::euclidean_space \\ 'c::real_normed_vector\"\n and f :: \"'d::t2_space \\ 'a\"\n assumes \"continuous_on S f\" \"continuous_on S g\" \"bilinear h\"\n shows \"continuous_on S (\\x. h (f x) (g x))\"\n by sorry\n\nend" }, { "theorem_id": 73, "title": "097_cramer_s_rule", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2019 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen\n-/\nmodule\n\npublic import Mathlib.Algebra.Regular.Basic\npublic import Mathlib.LinearAlgebra.Matrix.Symmetric\npublic import Mathlib.LinearAlgebra.Matrix.MvPolynomial\npublic import Mathlib.LinearAlgebra.Matrix.Polynomial\npublic import Mathlib.GroupTheory.GroupAction.Ring\n\n/-!\n# Cramer's rule and adjugate matrices\n\nThe adjugate matrix is the transpose of the cofactor matrix.\nIt is calculated with Cramer's rule, which we introduce first.\nThe vectors returned by Cramer's rule are given by the linear map `cramer`,\nwhich sends a matrix `A` and vector `b` to the vector consisting of the\ndeterminant of replacing the `i`th column of `A` with `b` at index `i`\n(written as `(A.updateCol i b).det`).\nUsing Cramer's rule, we can compute for each matrix `A` the matrix `adjugate A`.\nThe entries of the adjugate are the minors of `A`.\nInstead of defining a minor by deleting row `i` and column `j` of `A`, we\nreplace the `i`th row of `A` with the `j`th basis vector; the resulting matrix\nhas the same determinant but more importantly equals Cramer's rule applied\nto `A` and the `j`th basis vector, simplifying the subsequent proofs.\nWe prove the adjugate behaves like `det A • A⁻¹`.\n\n## Main definitions\n\n* `Matrix.cramer A b`: the vector output by Cramer's rule on `A` and `b`.\n* `Matrix.adjugate A`: the adjugate (or classical adjoint) of the matrix `A`.\n\n## References\n\n * https://en.wikipedia.org/wiki/Cramer's_rule#Finding_inverse_matrix\n\n## Tags\n\ncramer, cramer's rule, adjugate\n-/\n\n@[expose] public section\n\n\nnamespace Matrix\n\nuniverse u v w\n\nvariable {m : Type u} {n : Type v} {α : Type w}\nvariable [DecidableEq n] [Fintype n] [DecidableEq m] [Fintype m] [CommRing α]\n\nopen Matrix Polynomial Equiv Equiv.Perm Finset\n\nsection Cramer\n\n/-!\n ### `cramer` section\n\n Introduce the linear map `cramer` with values defined by `cramerMap`.\n After defining `cramerMap` and showing it is linear,\n we will restrict our proofs to using `cramer`.\n-/\n\n\nvariable (A : Matrix n n α) (b : n → α)\n\n/-- `cramerMap A b i` is the determinant of the matrix `A` with column `i` replaced with `b`,\n and thus `cramerMap A b` is the vector output by Cramer's rule on `A` and `b`.\n\n If `A * x = b` has a unique solution in `x`, `cramerMap A` sends the vector `b` to `A.det • x`.\n Otherwise, the outcome of `cramerMap` is well-defined but not necessarily useful.\n-/\ndef cramerMap (i : n) : α :=\n (A.updateCol i b).det\n\ntheorem cramerMap_is_linear (i : n) : IsLinearMap α fun b => cramerMap A b i :=\n { map_add := det_updateCol_add _ _\n map_smul := det_updateCol_smul _ _ }\n\ntheorem cramer_is_linear : IsLinearMap α (cramerMap A) := by sorry\ndef cramer (A : Matrix n n α) : (n → α) →ₗ[α] (n → α) :=\n IsLinearMap.mk' (cramerMap A) (cramer_is_linear A)\n\ntheorem cramer_apply (i : n) : cramer A b i = (A.updateCol i b).det :=\n rfl\n\ntheorem cramer_transpose_apply (i : n) : cramer Aᵀ b i = (A.updateRow i b).det := by sorry\ntheorem cramer_transpose_row_self (i : n) : Aᵀ.cramer (A i) = Pi.single i A.det := by sorry\ntheorem cramer_row_self (i : n) (h : ∀ j, b j = A j i) : A.cramer b = Pi.single i A.det := by sorry\ntheorem cramer_one : cramer (1 : Matrix n n α) = 1 := by sorry\ntheorem cramer_smul (r : α) (A : Matrix n n α) :\n cramer (r • A) = r ^ (Fintype.card n - 1) • cramer A :=\n LinearMap.ext fun _ => funext fun _ => det_updateCol_smul_left _ _ _ _\n\n@[simp]\ntheorem cramer_subsingleton_apply [Subsingleton n] (A : Matrix n n α) (b : n → α) (i : n) :\n cramer A b i = b i := by rw [cramer_apply, det_eq_elem_of_subsingleton _ i, updateCol_self]\n\ntheorem cramer_zero [Nontrivial n] : cramer (0 : Matrix n n α) = 0 := by sorry\ntheorem sum_cramer {β} (s : Finset β) (f : β → n → α) :\n (∑ x ∈ s, cramer A (f x)) = cramer A (∑ x ∈ s, f x) :=\n (map_sum (cramer A) ..).symm\n\n/-- Use linearity of `cramer` and vector evaluation to take `cramer A _ i` out of a summation. -/\ntheorem sum_cramer_apply {β} (s : Finset β) (f : n → β → α) (i : n) :\n (∑ x ∈ s, cramer A (fun j => f j x) i) = cramer A (fun j : n => ∑ x ∈ s, f j x) i :=\n calc\n (∑ x ∈ s, cramer A (fun j => f j x) i) = (∑ x ∈ s, cramer A fun j => f j x) i :=\n (Finset.sum_apply i s _).symm\n _ = cramer A (fun j : n => ∑ x ∈ s, f j x) i := by sorry\ntheorem cramer_submatrix_equiv (A : Matrix m m α) (e : n ≃ m) (b : n → α) :\n cramer (A.submatrix e e) b = cramer A (b ∘ e.symm) ∘ e := by sorry\ntheorem cramer_reindex (e : m ≃ n) (A : Matrix m m α) (b : n → α) :\n cramer (reindex e e A) b = cramer A (b ∘ e) ∘ e.symm :=\n cramer_submatrix_equiv _ _ _\n\nend Cramer\n\nsection Adjugate\n\n/-!\n### `adjugate` section\n\nDefine the `adjugate` matrix and a few equations.\nThese will hold for any matrix over a commutative ring.\n-/\n\n\n/-- The adjugate matrix is the transpose of the cofactor matrix.\n\n Typically, the cofactor matrix is defined by taking minors,\n i.e. the determinant of the matrix with a row and column removed.\n However, the proof of `mul_adjugate` becomes a lot easier if we use the\n matrix replacing a column with a basis vector, since it allows us to use\n facts about the `cramer` map.\n-/\ndef adjugate (A : Matrix n n α) : Matrix n n α :=\n of fun i => cramer Aᵀ (Pi.single i 1)\n\ntheorem adjugate_def (A : Matrix n n α) : adjugate A = of fun i => cramer Aᵀ (Pi.single i 1) :=\n rfl\n\ntheorem adjugate_apply (A : Matrix n n α) (i j : n) :\n adjugate A i j = (A.updateRow j (Pi.single i 1)).det := by sorry\ntheorem adjugate_transpose (A : Matrix n n α) : (adjugate A)ᵀ = adjugate Aᵀ := by sorry\ntheorem IsSymm.adjugate {A : Matrix n n α} (hA : A.IsSymm) : A.adjugate.IsSymm := by sorry\ntheorem adjugate_submatrix_equiv_self (e : n ≃ m) (A : Matrix m m α) :\n adjugate (A.submatrix e e) = (adjugate A).submatrix e e := by sorry\ntheorem adjugate_reindex (e : m ≃ n) (A : Matrix m m α) :\n adjugate (reindex e e A) = reindex e e (adjugate A) :=\n adjugate_submatrix_equiv_self _ _\n\n/-- Since the map `b ↦ cramer A b` is linear in `b`, it must be multiplication by some matrix. This\nmatrix is `A.adjugate`. -/\ntheorem cramer_eq_adjugate_mulVec (A : Matrix n n α) (b : n → α) :\n cramer A b = A.adjugate *ᵥ b := by sorry\ntheorem mul_adjugate_apply (A : Matrix n n α) (i j k) :\n A i k * adjugate A k j = cramer Aᵀ (Pi.single k (A i k)) j := by sorry\ntheorem mul_adjugate (A : Matrix n n α) : A * adjugate A = A.det • (1 : Matrix n n α) := by sorry\ntheorem adjugate_mul (A : Matrix n n α) : adjugate A * A = A.det • (1 : Matrix n n α) :=\n calc\n adjugate A * A = (Aᵀ * adjugate Aᵀ)ᵀ := by sorry\ntheorem adjugate_smul (r : α) (A : Matrix n n α) :\n adjugate (r • A) = r ^ (Fintype.card n - 1) • adjugate A := by sorry\ntheorem mulVec_cramer (A : Matrix n n α) (b : n → α) : A *ᵥ cramer A b = A.det • b := by sorry\ntheorem adjugate_subsingleton [Subsingleton n] (A : Matrix n n α) : adjugate A = 1 := by sorry\ntheorem adjugate_eq_one_of_card_eq_one {A : Matrix n n α} (h : Fintype.card n = 1) :\n adjugate A = 1 :=\n haveI : Subsingleton n := Fintype.card_le_one_iff_subsingleton.mp h.le\n adjugate_subsingleton _\n\n@[simp]\ntheorem adjugate_zero [Nontrivial n] : adjugate (0 : Matrix n n α) = 0 := by sorry\ntheorem adjugate_one : adjugate (1 : Matrix n n α) = 1 := by sorry\ntheorem adjugate_diagonal (v : n → α) :\n adjugate (diagonal v) = diagonal fun i => ∏ j ∈ Finset.univ.erase i, v j := by sorry\ntheorem _root_.RingHom.map_adjugate {R S : Type*} [CommRing R] [CommRing S] (f : R →+* S)\n (M : Matrix n n R) : f.mapMatrix M.adjugate = Matrix.adjugate (f.mapMatrix M) := by sorry\ntheorem _root_.AlgHom.map_adjugate {R A B : Type*} [CommSemiring R] [CommRing A] [CommRing B]\n [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) (M : Matrix n n A) :\n f.mapMatrix M.adjugate = Matrix.adjugate (f.mapMatrix M) :=\n f.toRingHom.map_adjugate _\n\ntheorem det_adjugate (A : Matrix n n α) : (adjugate A).det = A.det ^ (Fintype.card n - 1) := by sorry\ntheorem adjugate_fin_zero (A : Matrix (Fin 0) (Fin 0) α) : adjugate A = 0 :=\n Subsingleton.elim _ _\n\n@[simp]\ntheorem adjugate_fin_one (A : Matrix (Fin 1) (Fin 1) α) : adjugate A = 1 :=\n adjugate_subsingleton A\n\ntheorem adjugate_fin_succ_eq_det_submatrix {n : ℕ} (A : Matrix (Fin n.succ) (Fin n.succ) α) (i j) :\n adjugate A i j = (-1) ^ (j + i : ℕ) * det (A.submatrix j.succAbove i.succAbove) := by sorry\ntheorem adjugate_fin_two (A : Matrix (Fin 2) (Fin 2) α) :\n adjugate A = !![A 1 1, -A 0 1; -A 1 0, A 0 0] := by sorry\ntheorem adjugate_fin_two_of (a b c d : α) : adjugate !![a, b; c, d] = !![d, -b; -c, a] :=\n adjugate_fin_two _\n\ntheorem adjugate_fin_three (A : Matrix (Fin 3) (Fin 3) α) :\n adjugate A =\n !![A 1 1 * A 2 2 - A 1 2 * A 2 1,\n -(A 0 1 * A 2 2) + A 0 2 * A 2 1,\n A 0 1 * A 1 2 - A 0 2 * A 1 1;\n -(A 1 0 * A 2 2) + A 1 2 * A 2 0,\n A 0 0 * A 2 2 - A 0 2 * A 2 0,\n -(A 0 0 * A 1 2) + A 0 2 * A 1 0;\n A 1 0 * A 2 1 - A 1 1 * A 2 0,\n -(A 0 0 * A 2 1) + A 0 1 * A 2 0,\n A 0 0 * A 1 1 - A 0 1 * A 1 0] := by sorry\ntheorem adjugate_fin_three_of (a b c d e f g h i : α) :\n adjugate !![a, b, c; d, e, f; g, h, i] =\n !![ e * i - f * h, -(b * i) + c * h, b * f - c * e;\n -(d * i) + f * g, a * i - c * g, -(a * f) + c * d;\n d * h - e * g, -(a * h) + b * g, a * e - b * d] :=\n adjugate_fin_three _\n\ntheorem det_eq_sum_mul_adjugate_row (A : Matrix n n α) (i : n) :\n det A = ∑ j : n, A i j * adjugate A j i := by sorry\ntheorem det_eq_sum_mul_adjugate_col (A : Matrix n n α) (j : n) :\n det A = ∑ i : n, A i j * adjugate A j i := by sorry\ntheorem adjugate_conjTranspose [StarRing α] (A : Matrix n n α) : A.adjugateᴴ = adjugate Aᴴ := by sorry\ntheorem isRegular_of_isLeftRegular_det {A : Matrix n n α} (hA : IsLeftRegular A.det) :\n IsRegular A := by sorry\ntheorem adjugate_mul_distrib_aux (A B : Matrix n n α) (hA : IsLeftRegular A.det)\n (hB : IsLeftRegular B.det) : adjugate (A * B) = adjugate B * adjugate A := by sorry\ntheorem adjugate_mul_distrib (A B : Matrix n n α) : adjugate (A * B) = adjugate B * adjugate A := by sorry\ntheorem adjugate_pow (A : Matrix n n α) (k : ℕ) : adjugate (A ^ k) = adjugate A ^ k := by sorry\ntheorem det_smul_adjugate_adjugate (A : Matrix n n α) :\n det A • adjugate (adjugate A) = det A ^ (Fintype.card n - 1) • A := by sorry\ntheorem adjugate_adjugate (A : Matrix n n α) (h : Fintype.card n ≠ 1) :\n adjugate (adjugate A) = det A ^ (Fintype.card n - 2) • A := by sorry\ntheorem adjugate_adjugate' (A : Matrix n n α) [Nontrivial n] :\n adjugate (adjugate A) = det A ^ (Fintype.card n - 2) • A :=\n adjugate_adjugate _ <| Fintype.one_lt_card.ne'\n\nend Adjugate\n\nend Matrix\n" }, { "theorem_id": 73, "title": "097_cramer_s_rule", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From HB Require Import structures.\nFrom mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice.\nFrom mathcomp Require Import fintype finfun bigop finset nmodule fingroup perm.\nFrom mathcomp Require Import order algebra divalg countalg finalg zmodp.\n\nSet Implicit Arguments.\nUnset Strict Implicit.\nUnset Printing Implicit Defensive.\n\nLocal Open Scope group_scope.\nImport GRing.Theory.\nLocal Open Scope ring_scope.\n\nReserved Notation \"''M_' n\" (at level 0, n at level 2, format \"''M_' n\").\nReserved Notation \"''rV_' n\" (at level 0, n at level 2, format \"''rV_' n\").\nReserved Notation \"''cV_' n\" (at level 0, n at level 2, format \"''cV_' n\").\nReserved Notation \"''M_' ( n )\". \nReserved Notation \"''M_' ( m , n )\" (format \"''M_' ( m , n )\").\nReserved Notation \"''M[' R ]_ n\" (at level 0, n at level 2). \nReserved Notation \"''rV[' R ]_ n\" (at level 0, n at level 2). \nReserved Notation \"''cV[' R ]_ n\" (at level 0, n at level 2). \nReserved Notation \"''M[' R ]_ ( n )\". \nReserved Notation \"''M[' R ]_ ( m , n )\". \n\nReserved Notation \"\\matrix_ i E\"\n (at level 34, E at level 39, i at level 2, format \"\\matrix_ i E\").\nReserved Notation \"\\matrix_ ( i < n ) E\"\n (at level 34, E at level 39, i, n at level 50). \nReserved Notation \"\\matrix_ ( i , j ) E\"\n (E at level 39, j at level 50, format \"\\matrix_ ( i , j ) E\").\nReserved Notation \"\\matrix[ k ]_ ( i , j ) E\"\n (at level 34, E at level 39, i, j at level 50,\n format \"\\matrix[ k ]_ ( i , j ) E\").\nReserved Notation \"\\matrix_ ( i < m , j < n ) E\"\n (E at level 39, j, n at level 50). \nReserved Notation \"\\matrix_ ( i , j < n ) E\"\n (E at level 39, n at level 50). \nReserved Notation \"\\row_ j E\"\n (at level 34, E at level 39, j at level 2, format \"\\row_ j E\").\nReserved Notation \"\\row_ ( j < n ) E\"\n (at level 34, E at level 39, j, n at level 50). \nReserved Notation \"\\col_ j E\"\n (at level 34, E at level 39, j at level 2, format \"\\col_ j E\").\nReserved Notation \"\\col_ ( j < n ) E\"\n (at level 34, E at level 39, j, n at level 50). \nReserved Notation \"\\mxblock_ ( i , j ) E\"\n (at level 34, E at level 39, i, j at level 50,\n format \"\\mxblock_ ( i , j ) E\").\nReserved Notation \"\\mxblock_ ( i < m , j < n ) E\"\n (E at level 39, m, j, n at level 50). \nReserved Notation \"\\mxblock_ ( i , j < n ) E\"\n (E at level 39, n at level 50). \nReserved Notation \"\\mxrow_ j E\"\n (at level 34, E at level 39, j at level 2, format \"\\mxrow_ j E\").\nReserved Notation \"\\mxrow_ ( j < n ) E\"\n (at level 34, E at level 39, j, n at level 50). \nReserved Notation \"\\mxcol_ j E\"\n (at level 34, E at level 39, j at level 2, format \"\\mxcol_ j E\").\nReserved Notation \"\\mxcol_ ( j < n ) E\"\n (at level 34, E at level 39, j, n at level 50). \nReserved Notation \"\\mxdiag_ j E\"\n (at level 34, E at level 39, j at level 2, format \"\\mxdiag_ j E\").\nReserved Notation \"\\mxdiag_ ( j < n ) E\"\n (at level 34, E at level 39, j, n at level 50). \n\nReserved Notation \"x %:M\" (format \"x %:M\").\nReserved Notation \"A *m B\" (at level 40, left associativity, format \"A *m B\").\nReserved Notation \"A ^T\" (format \"A ^T\").\nReserved Notation \"\\tr A\" (at level 10, A at level 8, format \"\\tr A\").\nReserved Notation \"\\det A\" (at level 10, A at level 8, format \"\\det A\").\nReserved Notation \"\\adj A\" (at level 10, A at level 8, format \"\\adj A\").\n\nReserved Notation \"{ ''GL_' n [ R ] }\"\n (n at level 2, format \"{ ''GL_' n [ R ] }\").\nReserved Notation \"{ ''GL_' n ( p ) }\"\n (p at level 10, format \"{ ''GL_' n ( p ) }\").\n\nLocal Notation simp := (Monoid.Theory.simpm, oppr0).\n\nSection MatrixDef.\n\nVariable R : Type.\nVariables m n : nat.\n\nVariant matrix : predArgType := Matrix of {ffun 'I_m * 'I_n -> R}.\n\nDefinition mx_val A := let: Matrix g := A in g.\n\nHB.instance Definition _ := [isNew for mx_val].\n\nDefinition fun_of_matrix A (i : 'I_m) (j : 'I_n) := mx_val A (i, j).\n\nCoercion fun_of_matrix : matrix >-> Funclass.\n\nEnd MatrixDef.\n\nFact matrix_key : unit.\nProof.\nAdmitted.\n\nHB.lock\nDefinition matrix_of_fun R (m n : nat) (k : unit) (F : 'I_m -> 'I_n -> R) :=\n @Matrix R m n [ffun ij => F ij.1 ij.2].\nCanonical matrix_unlockable := Unlockable matrix_of_fun.unlock.\n\nSection MatrixDef2.\n\nVariable R : Type.\nVariables m n : nat.\nImplicit Type F : 'I_m -> 'I_n -> R.\n\nLemma mxE k F : matrix_of_fun k F =2 F.\nProof.\nAdmitted.\n\nLemma matrixP (A B : matrix R m n) : A =2 B <-> A = B.\nProof.\nAdmitted.\n\nLemma eq_mx k F1 F2 : (F1 =2 F2) -> matrix_of_fun k F1 = matrix_of_fun k F2.\nProof.\nAdmitted.\n\nEnd MatrixDef2.\n\nArguments eq_mx {R m n k} [F1] F2 eq_F12.\n\nBind Scope ring_scope with matrix.\n\nNotation \"''M[' R ]_ ( m , n )\" := (matrix R m n) (only parsing): type_scope.\nNotation \"''rV[' R ]_ n\" := 'M[R]_(1, n) (only parsing) : type_scope.\nNotation \"''cV[' R ]_ n\" := 'M[R]_(n, 1) (only parsing) : type_scope.\nNotation \"''M[' R ]_ n\" := 'M[R]_(n, n) (only parsing) : type_scope.\nNotation \"''M[' R ]_ ( n )\" := 'M[R]_n (only parsing) : type_scope.\nNotation \"''M_' ( m , n )\" := 'M[_]_(m, n) : type_scope.\nNotation \"''rV_' n\" := 'M_(1, n) : type_scope.\nNotation \"''cV_' n\" := 'M_(n, 1) : type_scope.\nNotation \"''M_' n\" := 'M_(n, n) : type_scope.\nNotation \"''M_' ( n )\" := 'M_n (only parsing) : type_scope.\n\nNotation \"\\matrix[ k ]_ ( i , j ) E\" := (matrix_of_fun k (fun i j => E)) :\n ring_scope.\n\nNotation \"\\matrix_ ( i < m , j < n ) E\" :=\n (@matrix_of_fun _ m n matrix_key (fun i j => E)) (only parsing) : ring_scope.\n\nNotation \"\\matrix_ ( i , j < n ) E\" :=\n (\\matrix_(i < n, j < n) E) (only parsing) : ring_scope.\n\nNotation \"\\matrix_ ( i , j ) E\" := (\\matrix_(i < _, j < _) E) : ring_scope.\n\nNotation \"\\matrix_ ( i < m ) E\" :=\n (\\matrix_(i < m, j < _) @fun_of_matrix _ 1 _ E 0 j)\n (only parsing) : ring_scope.\nNotation \"\\matrix_ i E\" := (\\matrix_(i < _) E) : ring_scope.\n\nNotation \"\\col_ ( i < n ) E\" := (@matrix_of_fun _ n 1 matrix_key (fun i _ => E))\n (only parsing) : ring_scope.\nNotation \"\\col_ i E\" := (\\col_(i < _) E) : ring_scope.\n\nNotation \"\\row_ ( j < n ) E\" := (@matrix_of_fun _ 1 n matrix_key (fun _ j => E))\n (only parsing) : ring_scope.\nNotation \"\\row_ j E\" := (\\row_(j < _) E) : ring_scope.\n\nHB.instance Definition _ (R : eqType) m n := [Equality of 'M[R]_(m, n) by <:].\nHB.instance Definition _ (R : choiceType) m n := [Choice of 'M[R]_(m, n) by <:].\nHB.instance Definition _ (R : countType) m n := [Countable of 'M[R]_(m, n) by <:].\nHB.instance Definition _ (R : finType) m n := [Finite of 'M[R]_(m, n) by <:].\n\nLemma card_mx (F : finType) m n : (#|{: 'M[F]_(m, n)}| = #|F| ^ (m * n))%N.\nProof.\nAdmitted.\n\nSection MatrixStructural.\n\nVariable R : Type.\n\nFact const_mx_key : unit.\nProof.\nAdmitted.\nDefinition const_mx m n a : 'M[R]_(m, n) := \\matrix[const_mx_key]_(i, j) a.\nArguments const_mx {m n}.\n\nSection FixedDim.\n\nVariables m n : nat.\nImplicit Type A : 'M[R]_(m, n).\n\nDefinition castmx m' n' (eq_mn : (m = m') * (n = n')) A : 'M_(m', n') :=\n let: erefl in _ = m' := eq_mn.1 return 'M_(m', n') in\n let: erefl in _ = n' := eq_mn.2 return 'M_(m, n') in A.\n\nDefinition conform_mx m' n' B A :=\n match m =P m', n =P n' with\n | ReflectT eq_m, ReflectT eq_n => castmx (eq_m, eq_n) A\n | _, _ => B\n end.\n\nFact trmx_key : unit.\nProof.\nAdmitted.\nDefinition trmx A := \\matrix[trmx_key]_(i, j) A j i.\n\nFact row_perm_key : unit.\nProof.\nAdmitted.\nDefinition row_perm (s : 'S_m) A := \\matrix[row_perm_key]_(i, j) A (s i) j.\nFact col_perm_key : unit.\nProof.\nAdmitted.\nDefinition col_perm (s : 'S_n) A := \\matrix[col_perm_key]_(i, j) A i (s j).\n\nDefinition xrow i1 i2 := row_perm (tperm i1 i2).\nDefinition xcol j1 j2 := col_perm (tperm j1 j2).\n\nDefinition row i0 A := \\row_j A i0 j.\nDefinition col j0 A := \\col_i A i j0.\n\nDefinition row' i0 A := \\matrix_(i, j) A (lift i0 i) j.\nDefinition col' j0 A := \\matrix_(i, j) A i (lift j0 j).\n\nDefinition mxsub m' n' f g A := \\matrix_(i < m', j < n') A (f i) (g j).\nLocal Notation colsub g := (mxsub id g).\nLocal Notation rowsub f := (mxsub f id).\n\nLemma castmx_const m' n' (eq_mn : (m = m') * (n = n')) a :\n castmx eq_mn (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma trmx_const a : trmx (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma row_perm_const s a : row_perm s (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma col_perm_const s a : col_perm s (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma xrow_const i1 i2 a : xrow i1 i2 (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma xcol_const j1 j2 a : xcol j1 j2 (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma rowP (u v : 'rV[R]_n) : u 0 =1 v 0 <-> u = v.\nProof.\nAdmitted.\n\nLemma rowK u_ i0 : row i0 (\\matrix_i u_ i) = u_ i0.\nProof.\nAdmitted.\n\nLemma row_matrixP A B : (forall i, row i A = row i B) <-> A = B.\nProof.\nAdmitted.\n\nLemma colP (u v : 'cV[R]_m) : u^~ 0 =1 v^~ 0 <-> u = v.\nProof.\nAdmitted.\n\nLemma row_const i0 a : row i0 (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma col_const j0 a : col j0 (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma row'_const i0 a : row' i0 (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma col'_const j0 a : col' j0 (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma col_perm1 A : col_perm 1 A = A.\nProof.\nAdmitted.\n\nLemma row_perm1 A : row_perm 1 A = A.\nProof.\nAdmitted.\n\nLemma col_permM s t A : col_perm (s * t) A = col_perm s (col_perm t A).\nProof.\nAdmitted.\n\nLemma row_permM s t A : row_perm (s * t) A = row_perm s (row_perm t A).\nProof.\nAdmitted.\n\nLemma col_row_permC s t A :\n col_perm s (row_perm t A) = row_perm t (col_perm s A).\nProof.\nAdmitted.\n\nLemma rowEsub i : row i = rowsub (fun=> i).\nProof.\nAdmitted.\nLemma colEsub j : col j = colsub (fun=> j).\nProof.\nAdmitted.\n\nLemma row'Esub i : row' i = rowsub (lift i).\nProof.\nAdmitted.\nLemma col'Esub j : col' j = colsub (lift j).\nProof.\nAdmitted.\n\nLemma row_permEsub s : row_perm s = rowsub s.\nProof.\nAdmitted.\n\nLemma col_permEsub s : col_perm s = colsub s.\nProof.\nAdmitted.\n\nLemma xrowEsub i1 i2 : xrow i1 i2 = rowsub (tperm i1 i2).\nProof.\nAdmitted.\n\nLemma xcolEsub j1 j2 : xcol j1 j2 = colsub (tperm j1 j2).\nProof.\nAdmitted.\n\nLemma mxsub_id : mxsub id id =1 id.\nProof.\nAdmitted.\n\nLemma eq_mxsub m' n' f f' g g' : f =1 f' -> g =1 g' ->\n @mxsub m' n' f g =1 mxsub f' g'.\nProof.\nAdmitted.\n\nLemma eq_rowsub m' (f f' : 'I_m' -> 'I_m) : f =1 f' -> rowsub f =1 rowsub f'.\nProof.\nAdmitted.\n\nLemma eq_colsub n' (g g' : 'I_n' -> 'I_n) : g =1 g' -> colsub g =1 colsub g'.\nProof.\nAdmitted.\n\nLemma mxsub_eq_id f g : f =1 id -> g =1 id -> mxsub f g =1 id.\nProof.\nAdmitted.\n\nLemma mxsub_eq_colsub n' f g : f =1 id -> @mxsub _ n' f g =1 colsub g.\nProof.\nAdmitted.\n\nLemma mxsub_eq_rowsub m' f g : g =1 id -> @mxsub m' _ f g =1 rowsub f.\nProof.\nAdmitted.\n\nLemma mxsub_ffunl m' n' f g : @mxsub m' n' (finfun f) g =1 mxsub f g.\nProof.\nAdmitted.\n\nLemma mxsub_ffunr m' n' f g : @mxsub m' n' f (finfun g) =1 mxsub f g.\nProof.\nAdmitted.\n\nLemma mxsub_ffun m' n' f g : @mxsub m' n' (finfun f) (finfun g) =1 mxsub f g.\nProof.\nAdmitted.\n\nLemma mxsub_const m' n' f g a : @mxsub m' n' f g (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nEnd FixedDim.\n\nLocal Notation colsub g := (mxsub id g).\nLocal Notation rowsub f := (mxsub f id).\nLocal Notation \"A ^T\" := (trmx A) : ring_scope.\n\nLemma castmx_id m n erefl_mn (A : 'M_(m, n)) : castmx erefl_mn A = A.\nProof.\nAdmitted.\n\nLemma castmx_comp m1 n1 m2 n2 m3 n3 (eq_m1 : m1 = m2) (eq_n1 : n1 = n2)\n (eq_m2 : m2 = m3) (eq_n2 : n2 = n3) A :\n castmx (eq_m2, eq_n2) (castmx (eq_m1, eq_n1) A)\n = castmx (etrans eq_m1 eq_m2, etrans eq_n1 eq_n2) A.\nProof.\nAdmitted.\n\nLemma castmxK m1 n1 m2 n2 (eq_m : m1 = m2) (eq_n : n1 = n2) :\n cancel (castmx (eq_m, eq_n)) (castmx (esym eq_m, esym eq_n)).\nProof.\nAdmitted.\n\nLemma castmxKV m1 n1 m2 n2 (eq_m : m1 = m2) (eq_n : n1 = n2) :\n cancel (castmx (esym eq_m, esym eq_n)) (castmx (eq_m, eq_n)).\nProof.\nAdmitted.\n\nLemma castmx_sym m1 n1 m2 n2 (eq_m : m1 = m2) (eq_n : n1 = n2) A1 A2 :\n A1 = castmx (eq_m, eq_n) A2 -> A2 = castmx (esym eq_m, esym eq_n) A1.\nProof.\nAdmitted.\n\nLemma eq_castmx m1 n1 m2 n2 (eq_mn eq_mn' : (m1 = m2) * (n1 = n2)) :\n castmx eq_mn =1 castmx eq_mn'.\nProof.\nAdmitted.\n\nLemma castmxE m1 n1 m2 n2 (eq_mn : (m1 = m2) * (n1 = n2)) A i j :\n castmx eq_mn A i j =\n A (cast_ord (esym eq_mn.\nProof.\nAdmitted.\n\nLemma conform_mx_id m n (B A : 'M_(m, n)) : conform_mx B A = A.\nProof.\nAdmitted.\n\nLemma nonconform_mx m m' n n' (B : 'M_(m', n')) (A : 'M_(m, n)) :\n (m != m') || (n != n') -> conform_mx B A = B.\nProof.\nAdmitted.\n\nLemma conform_castmx m1 n1 m2 n2 m3 n3\n (e_mn : (m2 = m3) * (n2 = n3)) (B : 'M_(m1, n1)) A :\n conform_mx B (castmx e_mn A) = conform_mx B A.\nProof.\nAdmitted.\n\nLemma trmxK m n : cancel (@trmx m n) (@trmx n m).\nProof.\nAdmitted.\n\nLemma trmx_inj m n : injective (@trmx m n).\nProof.\nAdmitted.\n\nLemma trmx_cast m1 n1 m2 n2 (eq_mn : (m1 = m2) * (n1 = n2)) A :\n (castmx eq_mn A)^T = castmx (eq_mn.\nProof.\nAdmitted.\n\nLemma trmx_conform m' n' m n (B : 'M_(m', n')) (A : 'M_(m, n)) :\n (conform_mx B A)^T = conform_mx B^T A^T.\nProof.\nAdmitted.\n\nLemma tr_row_perm m n s (A : 'M_(m, n)) : (row_perm s A)^T = col_perm s A^T.\nProof.\nAdmitted.\n\nLemma tr_col_perm m n s (A : 'M_(m, n)) : (col_perm s A)^T = row_perm s A^T.\nProof.\nAdmitted.\n\nLemma tr_xrow m n i1 i2 (A : 'M_(m, n)) : (xrow i1 i2 A)^T = xcol i1 i2 A^T.\nProof.\nAdmitted.\n\nLemma tr_xcol m n j1 j2 (A : 'M_(m, n)) : (xcol j1 j2 A)^T = xrow j1 j2 A^T.\nProof.\nAdmitted.\n\nLemma row_id n i (V : 'rV_n) : row i V = V.\nProof.\nAdmitted.\n\nLemma col_id n j (V : 'cV_n) : col j V = V.\nProof.\nAdmitted.\n\nLemma row_eq m1 m2 n i1 i2 (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) :\n row i1 A1 = row i2 A2 -> A1 i1 =1 A2 i2.\nProof.\nAdmitted.\n\nLemma col_eq m n1 n2 j1 j2 (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) :\n col j1 A1 = col j2 A2 -> A1^~ j1 =1 A2^~ j2.\nProof.\nAdmitted.\n\nLemma row'_eq m n i0 (A B : 'M_(m, n)) :\n row' i0 A = row' i0 B -> {in predC1 i0, A =2 B}.\nProof.\nAdmitted.\n\nLemma col'_eq m n j0 (A B : 'M_(m, n)) :\n col' j0 A = col' j0 B -> forall i, {in predC1 j0, A i =1 B i}.\nProof.\nAdmitted.\n\nLemma tr_row m n i0 (A : 'M_(m, n)) : (row i0 A)^T = col i0 A^T.\nProof.\nAdmitted.\n\nLemma tr_row' m n i0 (A : 'M_(m, n)) : (row' i0 A)^T = col' i0 A^T.\nProof.\nAdmitted.\n\nLemma tr_col m n j0 (A : 'M_(m, n)) : (col j0 A)^T = row j0 A^T.\nProof.\nAdmitted.\n\nLemma tr_col' m n j0 (A : 'M_(m, n)) : (col' j0 A)^T = row' j0 A^T.\nProof.\nAdmitted.\n\nLemma mxsub_comp m1 m2 m3 n1 n2 n3\n (f : 'I_m2 -> 'I_m1) (f' : 'I_m3 -> 'I_m2)\n (g : 'I_n2 -> 'I_n1) (g' : 'I_n3 -> 'I_n2) (A : 'M_(m1, n1)) :\n mxsub (f \\o f') (g \\o g') A = mxsub f' g' (mxsub f g A).\nProof.\nAdmitted.\n\nLemma rowsub_comp m1 m2 m3 n\n (f : 'I_m2 -> 'I_m1) (f' : 'I_m3 -> 'I_m2) (A : 'M_(m1, n)) :\n rowsub (f \\o f') A = rowsub f' (rowsub f A).\nProof.\nAdmitted.\n\nLemma colsub_comp m n n2 n3\n (g : 'I_n2 -> 'I_n) (g' : 'I_n3 -> 'I_n2) (A : 'M_(m, n)) :\n colsub (g \\o g') A = colsub g' (colsub g A).\nProof.\nAdmitted.\n\nLemma mxsubrc m1 m2 n n2 f g (A : 'M_(m1, n)) :\n mxsub f g A = rowsub f (colsub g A) :> 'M_(m2, n2).\nProof.\nAdmitted.\n\nLemma mxsubcr m1 m2 n n2 f g (A : 'M_(m1, n)) :\n mxsub f g A = colsub g (rowsub f A) :> 'M_(m2, n2).\nProof.\nAdmitted.\n\nLemma rowsub_cast m1 m2 n (eq_m : m1 = m2) (A : 'M_(m2, n)) :\n rowsub (cast_ord eq_m) A = castmx (esym eq_m, erefl) A.\nProof.\nAdmitted.\n\nLemma colsub_cast m n1 n2 (eq_n : n1 = n2) (A : 'M_(m, n2)) :\n colsub (cast_ord eq_n) A = castmx (erefl, esym eq_n) A.\nProof.\nAdmitted.\n\nLemma mxsub_cast m1 m2 n1 n2 (eq_m : m1 = m2) (eq_n : n1 = n2) A :\n mxsub (cast_ord eq_m) (cast_ord eq_n) A = castmx (esym eq_m, esym eq_n) A.\nProof.\nAdmitted.\n\nLemma castmxEsub m1 m2 n1 n2 (eq_mn : (m1 = m2) * (n1 = n2)) A :\n castmx eq_mn A = mxsub (cast_ord (esym eq_mn.\nProof.\nAdmitted.\n\nLemma trmx_mxsub m1 m2 n1 n2 f g (A : 'M_(m1, n1)) :\n (mxsub f g A)^T = mxsub g f A^T :> 'M_(n2, m2).\nProof.\nAdmitted.\n\nLemma row_mxsub m1 m2 n1 n2\n (f : 'I_m2 -> 'I_m1) (g : 'I_n2 -> 'I_n1) (A : 'M_(m1, n1)) i :\n row i (mxsub f g A) = row (f i) (colsub g A).\nProof.\nAdmitted.\n\nLemma col_mxsub m1 m2 n1 n2\n (f : 'I_m2 -> 'I_m1) (g : 'I_n2 -> 'I_n1) (A : 'M_(m1, n1)) i :\n col i (mxsub f g A) = col (g i) (rowsub f A).\nProof.\nAdmitted.\n\nLemma row_rowsub m1 m2 n (f : 'I_m2 -> 'I_m1) (A : 'M_(m1, n)) i :\n row i (rowsub f A) = row (f i) A.\nProof.\nAdmitted.\n\nLemma col_colsub m n1 n2 (g : 'I_n2 -> 'I_n1) (A : 'M_(m, n1)) i :\n col i (colsub g A) = col (g i) A.\nProof.\nAdmitted.\n\nLtac split_mxE := apply/matrixP=> i j; do ![rewrite mxE | case: split => ?].\n\nSection CutPaste.\n\nVariables m m1 m2 n n1 n2 : nat.\n\nFact row_mx_key : unit.\nProof.\nAdmitted.\nDefinition row_mx (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) : 'M[R]_(m, n1 + n2) :=\n \\matrix[row_mx_key]_(i, j)\n match split j with inl j1 => A1 i j1 | inr j2 => A2 i j2 end.\n\nFact col_mx_key : unit.\nProof.\nAdmitted.\nDefinition col_mx (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) : 'M[R]_(m1 + m2, n) :=\n \\matrix[col_mx_key]_(i, j)\n match split i with inl i1 => A1 i1 j | inr i2 => A2 i2 j end.\n\nFact lsubmx_key : unit.\nProof.\nAdmitted.\nDefinition lsubmx (A : 'M[R]_(m, n1 + n2)) :=\n \\matrix[lsubmx_key]_(i, j) A i (lshift n2 j).\n\nFact rsubmx_key : unit.\nProof.\nAdmitted.\nDefinition rsubmx (A : 'M[R]_(m, n1 + n2)) :=\n \\matrix[rsubmx_key]_(i, j) A i (rshift n1 j).\n\nFact usubmx_key : unit.\nProof.\nAdmitted.\nDefinition usubmx (A : 'M[R]_(m1 + m2, n)) :=\n \\matrix[usubmx_key]_(i, j) A (lshift m2 i) j.\n\nFact dsubmx_key : unit.\nProof.\nAdmitted.\nDefinition dsubmx (A : 'M[R]_(m1 + m2, n)) :=\n \\matrix[dsubmx_key]_(i, j) A (rshift m1 i) j.\n\nLemma row_mxEl A1 A2 i j : row_mx A1 A2 i (lshift n2 j) = A1 i j.\nProof.\nAdmitted.\n\nLemma row_mxKl A1 A2 : lsubmx (row_mx A1 A2) = A1.\nProof.\nAdmitted.\n\nLemma row_mxEr A1 A2 i j : row_mx A1 A2 i (rshift n1 j) = A2 i j.\nProof.\nAdmitted.\n\nLemma row_mxKr A1 A2 : rsubmx (row_mx A1 A2) = A2.\nProof.\nAdmitted.\n\nLemma hsubmxK A : row_mx (lsubmx A) (rsubmx A) = A.\nProof.\nAdmitted.\n\nLemma col_mxEu A1 A2 i j : col_mx A1 A2 (lshift m2 i) j = A1 i j.\nProof.\nAdmitted.\n\nLemma col_mxKu A1 A2 : usubmx (col_mx A1 A2) = A1.\nProof.\nAdmitted.\n\nLemma col_mxEd A1 A2 i j : col_mx A1 A2 (rshift m1 i) j = A2 i j.\nProof.\nAdmitted.\n\nLemma col_mxKd A1 A2 : dsubmx (col_mx A1 A2) = A2.\nProof.\nAdmitted.\n\nLemma lsubmxEsub : lsubmx = colsub (lshift _).\nProof.\nAdmitted.\n\nLemma rsubmxEsub : rsubmx = colsub (@rshift _ _).\nProof.\nAdmitted.\n\nLemma usubmxEsub : usubmx = rowsub (lshift _).\nProof.\nAdmitted.\n\nLemma dsubmxEsub : dsubmx = rowsub (@rshift _ _).\nProof.\nAdmitted.\n\nLemma eq_row_mx A1 A2 B1 B2 : row_mx A1 A2 = row_mx B1 B2 -> A1 = B1 /\\ A2 = B2.\nProof.\nAdmitted.\n\nLemma eq_col_mx A1 A2 B1 B2 : col_mx A1 A2 = col_mx B1 B2 -> A1 = B1 /\\ A2 = B2.\nProof.\nAdmitted.\n\nLemma lsubmx_const (r : R) : lsubmx (const_mx r : 'M_(m, n1 + n2)) = const_mx r.\nProof.\nAdmitted.\n\nLemma rsubmx_const (r : R) : rsubmx (const_mx r : 'M_(m, n1 + n2)) = const_mx r.\nProof.\nAdmitted.\n\nLemma row_mx_const a : row_mx (const_mx a) (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma col_mx_const a : col_mx (const_mx a) (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nLemma row_usubmx A i : row i (usubmx A) = row (lshift m2 i) A.\nProof.\nAdmitted.\n\nLemma row_dsubmx A i : row i (dsubmx A) = row (rshift m1 i) A.\nProof.\nAdmitted.\n\nLemma col_lsubmx A i : col i (lsubmx A) = col (lshift n2 i) A.\nProof.\nAdmitted.\n\nLemma col_rsubmx A i : col i (rsubmx A) = col (rshift n1 i) A.\nProof.\nAdmitted.\n\nEnd CutPaste.\n\nLemma row_thin_mx m n (A : 'M_(m,0)) (B : 'M_(m,n)) : row_mx A B = B.\nProof.\nAdmitted.\n\nLemma col_flat_mx m n (A : 'M_(0,n)) (B : 'M_(m,n)) : col_mx A B = B.\nProof.\nAdmitted.\n\nLemma trmx_lsub m n1 n2 (A : 'M_(m, n1 + n2)) : (lsubmx A)^T = usubmx A^T.\nProof.\nAdmitted.\n\nLemma trmx_rsub m n1 n2 (A : 'M_(m, n1 + n2)) : (rsubmx A)^T = dsubmx A^T.\nProof.\nAdmitted.\n\nLemma tr_row_mx m n1 n2 (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) :\n (row_mx A1 A2)^T = col_mx A1^T A2^T.\nProof.\nAdmitted.\n\nLemma tr_col_mx m1 m2 n (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) :\n (col_mx A1 A2)^T = row_mx A1^T A2^T.\nProof.\nAdmitted.\n\nLemma trmx_usub m1 m2 n (A : 'M_(m1 + m2, n)) : (usubmx A)^T = lsubmx A^T.\nProof.\nAdmitted.\n\nLemma trmx_dsub m1 m2 n (A : 'M_(m1 + m2, n)) : (dsubmx A)^T = rsubmx A^T.\nProof.\nAdmitted.\n\nLemma vsubmxK m1 m2 n (A : 'M_(m1 + m2, n)) : col_mx (usubmx A) (dsubmx A) = A.\nProof.\nAdmitted.\n\nLemma cast_row_mx m m' n1 n2 (eq_m : m = m') A1 A2 :\n castmx (eq_m, erefl _) (row_mx A1 A2)\n = row_mx (castmx (eq_m, erefl n1) A1) (castmx (eq_m, erefl n2) A2).\nProof.\nAdmitted.\n\nLemma cast_col_mx m1 m2 n n' (eq_n : n = n') A1 A2 :\n castmx (erefl _, eq_n) (col_mx A1 A2)\n = col_mx (castmx (erefl m1, eq_n) A1) (castmx (erefl m2, eq_n) A2).\nProof.\nAdmitted.\n\nLemma row_mxA m n1 n2 n3 (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) (A3 : 'M_(m, n3)) :\n let cast := (erefl m, esym (addnA n1 n2 n3)) in\n row_mx A1 (row_mx A2 A3) = castmx cast (row_mx (row_mx A1 A2) A3).\nProof.\nAdmitted.\nDefinition row_mxAx := row_mxA. \n\nLemma col_mxA m1 m2 m3 n (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) (A3 : 'M_(m3, n)) :\n let cast := (esym (addnA m1 m2 m3), erefl n) in\n col_mx A1 (col_mx A2 A3) = castmx cast (col_mx (col_mx A1 A2) A3).\nProof.\nAdmitted.\nDefinition col_mxAx := col_mxA. \n\nLemma row_row_mx m n1 n2 i0 (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) :\n row i0 (row_mx A1 A2) = row_mx (row i0 A1) (row i0 A2).\nProof.\nAdmitted.\n\nLemma col_col_mx m1 m2 n j0 (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) :\n col j0 (col_mx A1 A2) = col_mx (col j0 A1) (col j0 A2).\nProof.\nAdmitted.\n\nLemma row'_row_mx m n1 n2 i0 (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) :\n row' i0 (row_mx A1 A2) = row_mx (row' i0 A1) (row' i0 A2).\nProof.\nAdmitted.\n\nLemma col'_col_mx m1 m2 n j0 (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) :\n col' j0 (col_mx A1 A2) = col_mx (col' j0 A1) (col' j0 A2).\nProof.\nAdmitted.\n\nLemma colKl m n1 n2 j1 (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) :\n col (lshift n2 j1) (row_mx A1 A2) = col j1 A1.\nProof.\nAdmitted.\n\nLemma colKr m n1 n2 j2 (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) :\n col (rshift n1 j2) (row_mx A1 A2) = col j2 A2.\nProof.\nAdmitted.\n\nLemma rowKu m1 m2 n i1 (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) :\n row (lshift m2 i1) (col_mx A1 A2) = row i1 A1.\nProof.\nAdmitted.\n\nLemma rowKd m1 m2 n i2 (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) :\n row (rshift m1 i2) (col_mx A1 A2) = row i2 A2.\nProof.\nAdmitted.\n\nLemma col'Kl m n1 n2 j1 (A1 : 'M_(m, n1.\nProof.\nAdmitted.\n\nLemma row'Ku m1 m2 n i1 (A1 : 'M_(m1.\nProof.\nAdmitted.\n\nLemma mx'_cast m n : 'I_n -> (m + n.\nProof.\nAdmitted.\n\nLemma col'Kr m n1 n2 j2 (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) :\n col' (rshift n1 j2) (@row_mx m n1 n2 A1 A2)\n = castmx (erefl m, mx'_cast n1 j2) (row_mx A1 (col' j2 A2)).\nProof.\nAdmitted.\n\nLemma row'Kd m1 m2 n i2 (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) :\n row' (rshift m1 i2) (col_mx A1 A2)\n = castmx (mx'_cast m1 i2, erefl n) (col_mx A1 (row' i2 A2)).\nProof.\nAdmitted.\n\nSection Block.\n\nVariables m1 m2 n1 n2 : nat.\n\nDefinition block_mx Aul Aur Adl Adr : 'M_(m1 + m2, n1 + n2) :=\n col_mx (row_mx Aul Aur) (row_mx Adl Adr).\n\nLemma eq_block_mx Aul Aur Adl Adr Bul Bur Bdl Bdr :\n block_mx Aul Aur Adl Adr = block_mx Bul Bur Bdl Bdr ->\n [/\\ Aul = Bul, Aur = Bur, Adl = Bdl & Adr = Bdr].\nProof.\nAdmitted.\n\nLemma block_mx_const a :\n block_mx (const_mx a) (const_mx a) (const_mx a) (const_mx a) = const_mx a.\nProof.\nAdmitted.\n\nSection CutBlock.\n\nVariable A : matrix R (m1 + m2) (n1 + n2).\n\nDefinition ulsubmx := lsubmx (usubmx A).\nDefinition ursubmx := rsubmx (usubmx A).\nDefinition dlsubmx := lsubmx (dsubmx A).\nDefinition drsubmx := rsubmx (dsubmx A).\n\nLemma submxK : block_mx ulsubmx ursubmx dlsubmx drsubmx = A.\nProof.\nAdmitted.\n\nLemma ulsubmxEsub : ulsubmx = mxsub (lshift _) (lshift _) A.\nProof.\nAdmitted.\n\nLemma dlsubmxEsub : dlsubmx = mxsub (@rshift _ _) (lshift _) A.\nProof.\nAdmitted.\n\nLemma ursubmxEsub : ursubmx = mxsub (lshift _) (@rshift _ _) A.\nProof.\nAdmitted.\n\nLemma drsubmxEsub : drsubmx = mxsub (@rshift _ _) (@rshift _ _) A.\nProof.\nAdmitted.\n\nEnd CutBlock.\n\nSection CatBlock.\n\nVariables (Aul : 'M[R]_(m1, n1)) (Aur : 'M[R]_(m1, n2)).\nVariables (Adl : 'M[R]_(m2, n1)) (Adr : 'M[R]_(m2, n2)).\n\nLet A := block_mx Aul Aur Adl Adr.\n\nLemma block_mxEul i j : A (lshift m2 i) (lshift n2 j) = Aul i j.\nProof.\nAdmitted.\nLemma block_mxKul : ulsubmx A = Aul.\nProof.\nAdmitted.\n\nLemma block_mxEur i j : A (lshift m2 i) (rshift n1 j) = Aur i j.\nProof.\nAdmitted.\nLemma block_mxKur : ursubmx A = Aur.\nProof.\nAdmitted.\n\nLemma block_mxEdl i j : A (rshift m1 i) (lshift n2 j) = Adl i j.\nProof.\nAdmitted.\nLemma block_mxKdl : dlsubmx A = Adl.\nProof.\nAdmitted.\n\nLemma block_mxEdr i j : A (rshift m1 i) (rshift n1 j) = Adr i j.\nProof.\nAdmitted.\nLemma block_mxKdr : drsubmx A = Adr.\nProof.\nAdmitted.\n\nLemma block_mxEv : A = col_mx (row_mx Aul Aur) (row_mx Adl Adr).\nProof.\nAdmitted.\n\nEnd CatBlock.\n\nEnd Block.\n\nSection TrCutBlock.\n\nVariables m1 m2 n1 n2 : nat.\nVariable A : 'M[R]_(m1 + m2, n1 + n2).\n\nLemma trmx_ulsub : (ulsubmx A)^T = ulsubmx A^T.\nProof.\nAdmitted.\n\nLemma trmx_ursub : (ursubmx A)^T = dlsubmx A^T.\nProof.\nAdmitted.\n\nLemma trmx_dlsub : (dlsubmx A)^T = ursubmx A^T.\nProof.\nAdmitted.\n\nLemma trmx_drsub : (drsubmx A)^T = drsubmx A^T.\nProof.\nAdmitted.\n\nEnd TrCutBlock.\n\nSection TrBlock.\nVariables m1 m2 n1 n2 : nat.\nVariables (Aul : 'M[R]_(m1, n1)) (Aur : 'M[R]_(m1, n2)).\nVariables (Adl : 'M[R]_(m2, n1)) (Adr : 'M[R]_(m2, n2)).\n\nLemma tr_block_mx :\n (block_mx Aul Aur Adl Adr)^T = block_mx Aul^T Adl^T Aur^T Adr^T.\nProof.\nAdmitted.\n\nLemma block_mxEh :\n block_mx Aul Aur Adl Adr = row_mx (col_mx Aul Adl) (col_mx Aur Adr).\nProof.\nAdmitted.\nEnd TrBlock.\n\nLemma block_mxA m1 m2 m3 n1 n2 n3\n (A11 : 'M_(m1, n1)) (A12 : 'M_(m1, n2)) (A13 : 'M_(m1, n3))\n (A21 : 'M_(m2, n1)) (A22 : 'M_(m2, n2)) (A23 : 'M_(m2, n3))\n (A31 : 'M_(m3, n1)) (A32 : 'M_(m3, n2)) (A33 : 'M_(m3, n3)) :\n let cast := (esym (addnA m1 m2 m3), esym (addnA n1 n2 n3)) in\n let row1 := row_mx A12 A13 in let col1 := col_mx A21 A31 in\n let row3 := row_mx A31 A32 in let col3 := col_mx A13 A23 in\n block_mx A11 row1 col1 (block_mx A22 A23 A32 A33)\n = castmx cast (block_mx (block_mx A11 A12 A21 A22) col3 row3 A33).\nProof.\nAdmitted.\nDefinition block_mxAx := block_mxA. \n\nSection Induction.\n\nLemma row_ind m (P : forall n, 'M[R]_(m, n) -> Type) :\n (forall A, P 0 A) ->\n (forall n c A, P n A -> P (1 + n)%N (row_mx c A)) ->\n forall n A, P n A.\nProof.\nAdmitted.\n\nLemma col_ind n (P : forall m, 'M[R]_(m, n) -> Type) :\n (forall A, P 0 A) ->\n (forall m r A, P m A -> P (1 + m)%N (col_mx r A)) ->\n forall m A, P m A.\nProof.\nAdmitted.\n\nLemma mx_ind (P : forall m n, 'M[R]_(m, n) -> Type) :\n (forall m A, P m 0 A) ->\n (forall n A, P 0 n A) ->\n (forall m n x r c A, P m n A -> P (1 + m)%N (1 + n)%N (block_mx x r c A)) ->\n forall m n A, P m n A.\nProof.\nAdmitted.\nDefinition matrix_rect := mx_ind.\nDefinition matrix_rec := mx_ind.\nDefinition matrix_ind := mx_ind.\n\nLemma sqmx_ind (P : forall n, 'M[R]_n -> Type) :\n (forall A, P 0 A) ->\n (forall n x r c A, P n A -> P (1 + n)%N (block_mx x r c A)) ->\n forall n A, P n A.\nProof.\nAdmitted.\n\nLemma ringmx_ind (P : forall n, 'M[R]_n.\nProof.\nAdmitted.\n\nLemma mxsub_ind\n (weight : forall m n, 'M[R]_(m, n) -> nat)\n (sub : forall m n m' n', ('I_m' -> 'I_m) -> ('I_n' -> 'I_n) -> Prop)\n (P : forall m n, 'M[R]_(m, n) -> Type) :\n (forall m n (A : 'M[R]_(m, n)),\n (forall m' n' f g, weight m' n' (mxsub f g A) < weight m n A ->\n sub m n m' n' f g ->\n P m' n' (mxsub f g A)) -> P m n A) ->\n forall m n A, P m n A.\nProof.\nAdmitted.\n\nEnd Induction.\n\nSection VecMatrix.\n\nVariables m n : nat.\n\nLemma mxvec_cast : #|{:'I_m * 'I_n}| = (m * n)%N.\nProof.\nAdmitted.\n\nDefinition mxvec_index (i : 'I_m) (j : 'I_n) :=\n cast_ord mxvec_cast (enum_rank (i, j)).\n\nVariant is_mxvec_index : 'I_(m * n) -> Type :=\n isMxvecIndex i j : is_mxvec_index (mxvec_index i j).\n\nLemma mxvec_indexP k : is_mxvec_index k.\nProof.\nAdmitted.\n\nCoercion pair_of_mxvec_index k (i_k : is_mxvec_index k) :=\n let: isMxvecIndex i j := i_k in (i, j).\n\nDefinition mxvec (A : 'M[R]_(m, n)) :=\n castmx (erefl _, mxvec_cast) (\\row_k A (enum_val k).1 (enum_val k).2).\n\nFact vec_mx_key : unit.\nProof.\nAdmitted.\nDefinition vec_mx (u : 'rV[R]_(m * n)) :=\n \\matrix[vec_mx_key]_(i, j) u 0 (mxvec_index i j).\n\nLemma mxvecE A i j : mxvec A 0 (mxvec_index i j) = A i j.\nProof.\nAdmitted.\n\nLemma mxvecK : cancel mxvec vec_mx.\nProof.\nAdmitted.\n\nLemma vec_mxK : cancel vec_mx mxvec.\nProof.\nAdmitted.\n\nLemma curry_mxvec_bij : {on 'I_(m * n), bijective (uncurry mxvec_index)}.\nProof.\nAdmitted.\n\nEnd VecMatrix.\n\nEnd MatrixStructural.\n\nArguments const_mx {R m n}.\nArguments row_mxA {R m n1 n2 n3 A1 A2 A3}.\nArguments col_mxA {R m1 m2 m3 n A1 A2 A3}.\nArguments block_mxA {R m1 m2 m3 n1 n2 n3 A11 A12 A13 A21 A22 A23 A31 A32 A33}.\nPrenex Implicits castmx trmx trmxK lsubmx rsubmx usubmx dsubmx row_mx col_mx.\nPrenex Implicits block_mx ulsubmx ursubmx dlsubmx drsubmx.\nPrenex Implicits mxvec vec_mx mxvec_indexP mxvecK vec_mxK.\nArguments trmx_inj {R m n} [A1 A2] eqA12t : rename.\n\nNotation \"A ^T\" := (trmx A) : ring_scope.\nNotation colsub g := (mxsub id g).\nNotation rowsub f := (mxsub f id).\n\nArguments eq_mxsub [R m n m' n' f] f' [g] g' _.\nArguments eq_rowsub [R m n m' f] f' _.\nArguments eq_colsub [R m n n' g] g' _.\n\nSection MapMatrix.\n\nVariables (aT rT : Type) (f : aT -> rT).\n\nFact map_mx_key : unit.\nProof.\nAdmitted.\nDefinition map_mx m n (A : 'M_(m, n)) := \\matrix[map_mx_key]_(i, j) f (A i j).\n\nNotation \"A ^f\" := (map_mx A) : ring_scope.\n\nSection OneMatrix.\n\nVariables (m n : nat) (A : 'M[aT]_(m, n)).\n\nLemma map_trmx : A^f^T = A^T^f.\nProof.\nAdmitted.\n\nLemma map_const_mx a : (const_mx a)^f = const_mx (f a) :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma map_row i : (row i A)^f = row i A^f.\nProof.\nAdmitted.\n\nLemma map_col j : (col j A)^f = col j A^f.\nProof.\nAdmitted.\n\nLemma map_row' i0 : (row' i0 A)^f = row' i0 A^f.\nProof.\nAdmitted.\n\nLemma map_col' j0 : (col' j0 A)^f = col' j0 A^f.\nProof.\nAdmitted.\n\nLemma map_mxsub m' n' g h : (@mxsub _ _ _ m' n' g h A)^f = mxsub g h A^f.\nProof.\nAdmitted.\n\nLemma map_row_perm s : (row_perm s A)^f = row_perm s A^f.\nProof.\nAdmitted.\n\nLemma map_col_perm s : (col_perm s A)^f = col_perm s A^f.\nProof.\nAdmitted.\n\nLemma map_xrow i1 i2 : (xrow i1 i2 A)^f = xrow i1 i2 A^f.\nProof.\nAdmitted.\n\nLemma map_xcol j1 j2 : (xcol j1 j2 A)^f = xcol j1 j2 A^f.\nProof.\nAdmitted.\n\nLemma map_castmx m' n' c : (castmx c A)^f = castmx c A^f :> 'M_(m', n').\nProof.\nAdmitted.\n\nLemma map_conform_mx m' n' (B : 'M_(m', n')) :\n (conform_mx B A)^f = conform_mx B^f A^f.\nProof.\nAdmitted.\n\nLemma map_mxvec : (mxvec A)^f = mxvec A^f.\nProof.\nAdmitted.\n\nLemma map_vec_mx (v : 'rV_(m * n)) : (vec_mx v)^f = vec_mx v^f.\nProof.\nAdmitted.\n\nEnd OneMatrix.\n\nSection Block.\n\nVariables m1 m2 n1 n2 : nat.\nVariables (Aul : 'M[aT]_(m1, n1)) (Aur : 'M[aT]_(m1, n2)).\nVariables (Adl : 'M[aT]_(m2, n1)) (Adr : 'M[aT]_(m2, n2)).\nVariables (Bh : 'M[aT]_(m1, n1 + n2)) (Bv : 'M[aT]_(m1 + m2, n1)).\nVariable B : 'M[aT]_(m1 + m2, n1 + n2).\n\nLemma map_row_mx : (row_mx Aul Aur)^f = row_mx Aul^f Aur^f.\nProof.\nAdmitted.\n\nLemma map_col_mx : (col_mx Aul Adl)^f = col_mx Aul^f Adl^f.\nProof.\nAdmitted.\n\nLemma map_block_mx :\n (block_mx Aul Aur Adl Adr)^f = block_mx Aul^f Aur^f Adl^f Adr^f.\nProof.\nAdmitted.\n\nLemma map_lsubmx : (lsubmx Bh)^f = lsubmx Bh^f.\nProof.\nAdmitted.\n\nLemma map_rsubmx : (rsubmx Bh)^f = rsubmx Bh^f.\nProof.\nAdmitted.\n\nLemma map_usubmx : (usubmx Bv)^f = usubmx Bv^f.\nProof.\nAdmitted.\n\nLemma map_dsubmx : (dsubmx Bv)^f = dsubmx Bv^f.\nProof.\nAdmitted.\n\nLemma map_ulsubmx : (ulsubmx B)^f = ulsubmx B^f.\nProof.\nAdmitted.\n\nLemma map_ursubmx : (ursubmx B)^f = ursubmx B^f.\nProof.\nAdmitted.\n\nLemma map_dlsubmx : (dlsubmx B)^f = dlsubmx B^f.\nProof.\nAdmitted.\n\nLemma map_drsubmx : (drsubmx B)^f = drsubmx B^f.\nProof.\nAdmitted.\n\nEnd Block.\n\nEnd MapMatrix.\n\nArguments map_mx {aT rT} f {m n} A.\n\nSection MultipleMapMatrix.\nContext {R S T : Type} {m n : nat}.\nLocal Notation \"M ^ phi\" := (map_mx phi M).\n\nLemma map_mx_comp (f : R -> S) (g : S -> T)\n (M : 'M_(m, n)) : M ^ (g \\o f) = (M ^ f) ^ g.\nProof.\nAdmitted.\n\nLemma eq_in_map_mx (g f : R -> S) (M : 'M_(m, n)) :\n (forall i j, f (M i j) = g (M i j)) -> M ^ f = M ^ g.\nProof.\nAdmitted.\n\nLemma eq_map_mx (g f : R -> S) : f =1 g ->\n forall (M : 'M_(m, n)), M ^ f = M ^ g.\nProof.\nAdmitted.\n\nLemma map_mx_id_in (f : R -> R) (M : 'M_(m, n)) :\n (forall i j, f (M i j) = M i j) -> M ^ f = M.\nProof.\nAdmitted.\n\nLemma map_mx_id (f : R -> R) : f =1 id -> forall M : 'M_(m, n), M ^ f = M.\nProof.\nAdmitted.\n\nEnd MultipleMapMatrix.\nArguments eq_map_mx {R S m n} g [f].\nArguments eq_in_map_mx {R S m n} g [f M].\nArguments map_mx_id_in {R m n} [f M].\nArguments map_mx_id {R m n} [f].\n\nSection Map2Matrix.\nContext {R S T : Type} (f : R -> S -> T).\n\nFact map2_mx_key : unit.\nProof.\nAdmitted.\nDefinition map2_mx m n (A : 'M_(m, n)) (B : 'M_(m, n)) :=\n \\matrix[map2_mx_key]_(i, j) f (A i j) (B i j).\n\nSection OneMatrix.\n\nVariables (m n : nat) (A : 'M[R]_(m, n)) (B : 'M[S]_(m, n)).\n\nLemma map2_trmx : (map2_mx A B)^T = map2_mx A^T B^T.\nProof.\nAdmitted.\n\nLemma map2_const_mx a b :\n map2_mx (const_mx a) (const_mx b) = const_mx (f a b) :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma map2_row i : map2_mx (row i A) (row i B) = row i (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_col j : map2_mx (col j A) (col j B) = col j (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_row' i0 : map2_mx (row' i0 A) (row' i0 B) = row' i0 (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_col' j0 : map2_mx (col' j0 A) (col' j0 B) = col' j0 (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_mxsub m' n' g h :\n map2_mx (@mxsub _ _ _ m' n' g h A) (@mxsub _ _ _ m' n' g h B) =\n mxsub g h (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_row_perm s :\n map2_mx (row_perm s A) (row_perm s B) = row_perm s (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_col_perm s :\n map2_mx (col_perm s A) (col_perm s B) = col_perm s (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_xrow i1 i2 :\n map2_mx (xrow i1 i2 A) (xrow i1 i2 B) = xrow i1 i2 (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_xcol j1 j2 :\n map2_mx (xcol j1 j2 A) (xcol j1 j2 B) = xcol j1 j2 (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_castmx m' n' c :\n map2_mx (castmx c A) (castmx c B) = castmx c (map2_mx A B) :> 'M_(m', n').\nProof.\nAdmitted.\n\nLemma map2_conform_mx m' n' (A' : 'M_(m', n')) (B' : 'M_(m', n')) :\n map2_mx (conform_mx A' A) (conform_mx B' B) =\n conform_mx (map2_mx A' B') (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_mxvec : map2_mx (mxvec A) (mxvec B) = mxvec (map2_mx A B).\nProof.\nAdmitted.\n\nLemma map2_vec_mx (v : 'rV_(m * n)) (w : 'rV_(m * n)) :\n map2_mx (vec_mx v) (vec_mx w) = vec_mx (map2_mx v w).\nProof.\nAdmitted.\n\nEnd OneMatrix.\n\nSection Block.\n\nVariables m1 m2 n1 n2 : nat.\nVariables (Aul : 'M[R]_(m1, n1)) (Aur : 'M[R]_(m1, n2)).\nVariables (Adl : 'M[R]_(m2, n1)) (Adr : 'M[R]_(m2, n2)).\nVariables (Bh : 'M[R]_(m1, n1 + n2)) (Bv : 'M[R]_(m1 + m2, n1)).\nVariable B : 'M[R]_(m1 + m2, n1 + n2).\nVariables (A'ul : 'M[S]_(m1, n1)) (A'ur : 'M[S]_(m1, n2)).\nVariables (A'dl : 'M[S]_(m2, n1)) (A'dr : 'M[S]_(m2, n2)).\nVariables (B'h : 'M[S]_(m1, n1 + n2)) (B'v : 'M[S]_(m1 + m2, n1)).\nVariable B' : 'M[S]_(m1 + m2, n1 + n2).\n\nLemma map2_row_mx :\n map2_mx (row_mx Aul Aur) (row_mx A'ul A'ur) =\n row_mx (map2_mx Aul A'ul) (map2_mx Aur A'ur).\nProof.\nAdmitted.\n\nLemma map2_col_mx :\n map2_mx (col_mx Aul Adl) (col_mx A'ul A'dl) =\n col_mx (map2_mx Aul A'ul) (map2_mx Adl A'dl).\nProof.\nAdmitted.\n\nLemma map2_block_mx :\n map2_mx (block_mx Aul Aur Adl Adr) (block_mx A'ul A'ur A'dl A'dr) =\n block_mx\n (map2_mx Aul A'ul) (map2_mx Aur A'ur) (map2_mx Adl A'dl) (map2_mx Adr A'dr).\nProof.\nAdmitted.\n\nLemma map2_lsubmx : map2_mx (lsubmx Bh) (lsubmx B'h) = lsubmx (map2_mx Bh B'h).\nProof.\nAdmitted.\n\nLemma map2_rsubmx : map2_mx (rsubmx Bh) (rsubmx B'h) = rsubmx (map2_mx Bh B'h).\nProof.\nAdmitted.\n\nLemma map2_usubmx : map2_mx (usubmx Bv) (usubmx B'v) = usubmx (map2_mx Bv B'v).\nProof.\nAdmitted.\n\nLemma map2_dsubmx : map2_mx (dsubmx Bv) (dsubmx B'v) = dsubmx (map2_mx Bv B'v).\nProof.\nAdmitted.\n\nLemma map2_ulsubmx : map2_mx (ulsubmx B) (ulsubmx B') = ulsubmx (map2_mx B B').\nProof.\nAdmitted.\n\nLemma map2_ursubmx : map2_mx (ursubmx B) (ursubmx B') = ursubmx (map2_mx B B').\nProof.\nAdmitted.\n\nLemma map2_dlsubmx : map2_mx (dlsubmx B) (dlsubmx B') = dlsubmx (map2_mx B B').\nProof.\nAdmitted.\n\nLemma map2_drsubmx : map2_mx (drsubmx B) (drsubmx B') = drsubmx (map2_mx B B').\nProof.\nAdmitted.\n\nEnd Block.\n\nEnd Map2Matrix.\n\nSection Map2Eq.\n\nContext {R S T : Type} {m n : nat}.\n\nLemma eq_in_map2_mx (f g : R -> S -> T) (M : 'M[R]_(m, n)) (M' : 'M[S]_(m, n)) :\n (forall i j, f (M i j) (M' i j) = g (M i j) (M' i j)) ->\n map2_mx f M M' = map2_mx g M M'.\nProof.\nAdmitted.\n\nLemma eq_map2_mx (f g : R -> S -> T) : f =2 g ->\n @map2_mx _ _ _ f m n =2 @map2_mx _ _ _ g m n.\nProof.\nAdmitted.\n\nLemma map2_mx_left_in (f : R -> R -> R) (M : 'M_(m, n)) (M' : 'M_(m, n)) :\n (forall i j, f (M i j) (M' i j) = M i j) -> map2_mx f M M' = M.\nProof.\nAdmitted.\n\nLemma map2_mx_left (f : R -> R -> R) : f =2 (fun x _ => x) ->\n forall (M : 'M_(m, n)) (M' : 'M_(m, n)), map2_mx f M M' = M.\nProof.\nAdmitted.\n\nLemma map2_mx_right_in (f : R -> R -> R) (M : 'M_(m, n)) (M' : 'M_(m, n)) :\n (forall i j, f (M i j) (M' i j) = M' i j) -> map2_mx f M M' = M'.\nProof.\nAdmitted.\n\nLemma map2_mx_right (f : R -> R -> R) : f =2 (fun _ x => x) ->\n forall (M : 'M_(m, n)) (M' : 'M_(m, n)), map2_mx f M M' = M'.\nProof.\nAdmitted.\n\nEnd Map2Eq.\n\nSection MatrixLaws.\n\nContext {T : Type} {m n : nat} {idm : T}.\n\nLemma map2_mxA {opm : Monoid.\nProof.\nAdmitted.\n\nLemma map2_1mx {opm : Monoid.\nProof.\nAdmitted.\n\nLemma map2_mx1 {opm : Monoid.\nProof.\nAdmitted.\n\nHB.instance Definition _ {opm : Monoid.law idm} :=\n Monoid.isLaw.Build 'M_(m, n) (const_mx idm) (@map2_mx _ _ _ opm _ _)\n map2_mxA map2_1mx map2_mx1.\n\nLemma map2_mxC {opm : Monoid.\nProof.\nAdmitted.\n\nHB.instance Definition _ {opm : Monoid.com_law idm} :=\n SemiGroup.isCommutativeLaw.Build 'M_(m, n) (@map2_mx _ _ _ opm _ _) map2_mxC.\n\nLemma map2_0mx {opm : Monoid.\nProof.\nAdmitted.\n\nLemma map2_mx0 {opm : Monoid.\nProof.\nAdmitted.\n\nHB.instance Definition _ {opm : Monoid.mul_law idm} :=\n Monoid.isMulLaw.Build 'M_(m, n) (const_mx idm) (@map2_mx _ _ _ opm _ _)\n map2_0mx map2_mx0.\n\nLemma map2_mxDl {mul : T -> T -> T} {add : Monoid.\nProof.\nAdmitted.\n\nLemma map2_mxDr {mul : T -> T -> T} {add : Monoid.\nProof.\nAdmitted.\n\nHB.instance Definition _ {mul : T -> T -> T} {add : Monoid.add_law idm mul} :=\n Monoid.isAddLaw.Build 'M_(m, n)\n (@map2_mx _ _ _ mul _ _) (@map2_mx _ _ _ add _ _)\n map2_mxDl map2_mxDr.\n\nEnd MatrixLaws.\n\nSection MatrixNmodule.\n\nVariable V : nmodType.\n\nSection FixedDim.\n\nVariables m n : nat.\nImplicit Types A B : 'M[V]_(m, n).\n\nFact addmx_key : unit.\nProof.\nAdmitted.\nDefinition addmx := @map2_mx V V V +%R m n.\n\nDefinition addmxA : associative addmx := map2_mxA.\nDefinition addmxC : commutative addmx := map2_mxC.\nDefinition add0mx : left_id (const_mx 0) addmx := map2_1mx.\n\nHB.instance Definition _ := GRing.isNmodule.Build 'M[V]_(m, n)\n addmxA addmxC add0mx.\n\nLemma mulmxnE A d i j : (A *+ d) i j = A i j *+ d.\nProof.\nAdmitted.\n\nLemma summxE I r (P : pred I) (E : I -> 'M_(m, n)) i j :\n (\\sum_(k <- r | P k) E k) i j = \\sum_(k <- r | P k) E k i j.\nProof.\nAdmitted.\n\nFact const_mx_is_nmod_morphism : nmod_morphism const_mx.\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=const_mx_is_nmod_morphism)]\nDefinition const_mx_is_semi_additive := const_mx_is_nmod_morphism.\nHB.instance Definition _ := GRing.isNmodMorphism.Build V 'M[V]_(m, n) const_mx\n const_mx_is_nmod_morphism.\n\nEnd FixedDim.\n\nSection SemiAdditive.\n\nVariables (m n p q : nat) (f : 'I_p -> 'I_q -> 'I_m) (g : 'I_p -> 'I_q -> 'I_n).\n\nDefinition swizzle_mx k (A : 'M[V]_(m, n)) :=\n \\matrix[k]_(i, j) A (f i j) (g i j).\n\nFact swizzle_mx_is_nmod_morphism k : nmod_morphism (swizzle_mx k).\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=swizzle_mx_is_nmod_morphism)]\nDefinition swizzle_mx_is_semi_additive := swizzle_mx_is_nmod_morphism.\nHB.instance Definition _ k := GRing.isNmodMorphism.Build 'M_(m, n) 'M_(p, q)\n (swizzle_mx k) (swizzle_mx_is_nmod_morphism k).\n\nEnd SemiAdditive.\n\nLocal Notation SwizzleAdd op := (GRing.Additive.copy op (swizzle_mx _ _ _)).\n\nHB.instance Definition _ m n := SwizzleAdd (@trmx V m n).\nHB.instance Definition _ m n i := SwizzleAdd (@row V m n i).\nHB.instance Definition _ m n j := SwizzleAdd (@col V m n j).\nHB.instance Definition _ m n i := SwizzleAdd (@row' V m n i).\nHB.instance Definition _ m n j := SwizzleAdd (@col' V m n j).\nHB.instance Definition _ m n m' n' f g := SwizzleAdd (@mxsub V m n m' n' f g).\nHB.instance Definition _ m n s := SwizzleAdd (@row_perm V m n s).\nHB.instance Definition _ m n s := SwizzleAdd (@col_perm V m n s).\nHB.instance Definition _ m n i1 i2 := SwizzleAdd (@xrow V m n i1 i2).\nHB.instance Definition _ m n j1 j2 := SwizzleAdd (@xcol V m n j1 j2).\nHB.instance Definition _ m n1 n2 := SwizzleAdd (@lsubmx V m n1 n2).\nHB.instance Definition _ m n1 n2 := SwizzleAdd (@rsubmx V m n1 n2).\nHB.instance Definition _ m1 m2 n := SwizzleAdd (@usubmx V m1 m2 n).\nHB.instance Definition _ m1 m2 n := SwizzleAdd (@dsubmx V m1 m2 n).\nHB.instance Definition _ m n := SwizzleAdd (@vec_mx V m n).\nHB.instance Definition _ m n := GRing.isNmodMorphism.Build 'M_(m, n) 'rV_(m * n)\n mxvec (can2_nmod_morphism (@vec_mxK V m n) mxvecK).\n\nLemma flatmx0 n : all_equal_to (0 : 'M_(0, n)).\nProof.\nAdmitted.\n\nLemma thinmx0 n : all_equal_to (0 : 'M_(n, 0)).\nProof.\nAdmitted.\n\nLemma trmx0 m n : (0 : 'M_(m, n))^T = 0.\nProof.\nAdmitted.\n\nLemma row0 m n i0 : row i0 (0 : 'M_(m, n)) = 0.\nProof.\nAdmitted.\n\nLemma col0 m n j0 : col j0 (0 : 'M_(m, n)) = 0.\nProof.\nAdmitted.\n\nLemma mxvec_eq0 m n (A : 'M_(m, n)) : (mxvec A == 0) = (A == 0).\nProof.\nAdmitted.\n\nLemma vec_mx_eq0 m n (v : 'rV_(m * n)) : (vec_mx v == 0) = (v == 0).\nProof.\nAdmitted.\n\nLemma row_mx0 m n1 n2 : row_mx 0 0 = 0 :> 'M_(m, n1 + n2).\nProof.\nAdmitted.\n\nLemma col_mx0 m1 m2 n : col_mx 0 0 = 0 :> 'M_(m1 + m2, n).\nProof.\nAdmitted.\n\nLemma block_mx0 m1 m2 n1 n2 : block_mx 0 0 0 0 = 0 :> 'M_(m1 + m2, n1 + n2).\nProof.\nAdmitted.\n\nLtac split_mxE := apply/matrixP=> i j; do ![rewrite mxE | case: split => ?].\n\nLemma add_row_mx m n1 n2 (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) B1 B2 :\n row_mx A1 A2 + row_mx B1 B2 = row_mx (A1 + B1) (A2 + B2).\nProof.\nAdmitted.\n\nLemma add_col_mx m1 m2 n (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) B1 B2 :\n col_mx A1 A2 + col_mx B1 B2 = col_mx (A1 + B1) (A2 + B2).\nProof.\nAdmitted.\n\nLemma add_block_mx m1 m2 n1 n2 (Aul : 'M_(m1, n1)) Aur Adl (Adr : 'M_(m2, n2))\n Bul Bur Bdl Bdr :\n let A := block_mx Aul Aur Adl Adr in let B := block_mx Bul Bur Bdl Bdr in\n A + B = block_mx (Aul + Bul) (Aur + Bur) (Adl + Bdl) (Adr + Bdr).\nProof.\nAdmitted.\n\nLemma row_mx_eq0 (m n1 n2 : nat) (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)):\n (row_mx A1 A2 == 0) = (A1 == 0) && (A2 == 0).\nProof.\nAdmitted.\n\nLemma col_mx_eq0 (m1 m2 n : nat) (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)):\n (col_mx A1 A2 == 0) = (A1 == 0) && (A2 == 0).\nProof.\nAdmitted.\n\nLemma block_mx_eq0 m1 m2 n1 n2 (Aul : 'M_(m1, n1)) Aur Adl (Adr : 'M_(m2, n2)) :\n (block_mx Aul Aur Adl Adr == 0) =\n [&& Aul == 0, Aur == 0, Adl == 0 & Adr == 0].\nProof.\nAdmitted.\n\nLemma trmx_eq0 m n (A : 'M_(m, n)) : (A^T == 0) = (A == 0).\nProof.\nAdmitted.\n\nLemma matrix_eq0 m n (A : 'M_(m, n)) :\n (A == 0) = [forall i, forall j, A i j == 0].\nProof.\nAdmitted.\n\nLemma matrix0Pn m n (A : 'M_(m, n)) : reflect (exists i j, A i j != 0) (A != 0).\nProof.\nAdmitted.\n\nLemma rV0Pn n (v : 'rV_n) : reflect (exists i, v 0 i != 0) (v != 0).\nProof.\nAdmitted.\n\nLemma cV0Pn n (v : 'cV_n) : reflect (exists i, v i 0 != 0) (v != 0).\nProof.\nAdmitted.\n\nDefinition nz_row m n (A : 'M_(m, n)) :=\n oapp (fun i => row i A) 0 [pick i | row i A != 0].\n\nLemma nz_row_eq0 m n (A : 'M_(m, n)) : (nz_row A == 0) = (A == 0).\nProof.\nAdmitted.\n\nDefinition is_diag_mx m n (A : 'M[V]_(m, n)) :=\n [forall i : 'I__, forall j : 'I__, (i != j :> nat) ==> (A i j == 0)].\n\nLemma is_diag_mxP m n (A : 'M[V]_(m, n)) :\n reflect (forall i j : 'I__, i != j :> nat -> A i j = 0) (is_diag_mx A).\nProof.\nAdmitted.\n\nLemma mx0_is_diag m n : is_diag_mx (0 : 'M[V]_(m, n)).\nProof.\nAdmitted.\n\nLemma mx11_is_diag (M : 'M_1) : is_diag_mx M.\nProof.\nAdmitted.\n\nDefinition is_trig_mx m n (A : 'M[V]_(m, n)) :=\n [forall i : 'I__, forall j : 'I__, (i < j)%N ==> (A i j == 0)].\n\nLemma is_trig_mxP m n (A : 'M[V]_(m, n)) :\n reflect (forall i j : 'I__, (i < j)%N -> A i j = 0) (is_trig_mx A).\nProof.\nAdmitted.\n\nLemma is_diag_mx_is_trig m n (A : 'M[V]_(m, n)) : is_diag_mx A -> is_trig_mx A.\nProof.\nAdmitted.\n\nLemma mx0_is_trig m n : is_trig_mx (0 : 'M[V]_(m, n)).\nProof.\nAdmitted.\n\nLemma mx11_is_trig (M : 'M_1) : is_trig_mx M.\nProof.\nAdmitted.\n\nLemma is_diag_mxEtrig m n (A : 'M[V]_(m, n)) :\n is_diag_mx A = is_trig_mx A && is_trig_mx A^T.\nProof.\nAdmitted.\n\nLemma is_diag_trmx m n (A : 'M[V]_(m, n)) : is_diag_mx A^T = is_diag_mx A.\nProof.\nAdmitted.\n\nLemma ursubmx_trig m1 m2 n1 n2 (A : 'M[V]_(m1 + m2, n1 + n2)) :\n m1 <= n1 -> is_trig_mx A -> ursubmx A = 0.\nProof.\nAdmitted.\n\nLemma dlsubmx_diag m1 m2 n1 n2 (A : 'M[V]_(m1 + m2, n1 + n2)) :\n n1 <= m1 -> is_diag_mx A -> dlsubmx A = 0.\nProof.\nAdmitted.\n\nLemma ulsubmx_trig m1 m2 n1 n2 (A : 'M[V]_(m1 + m2, n1 + n2)) :\n is_trig_mx A -> is_trig_mx (ulsubmx A).\nProof.\nAdmitted.\n\nLemma drsubmx_trig m1 m2 n1 n2 (A : 'M[V]_(m1 + m2, n1 + n2)) :\n m1 <= n1 -> is_trig_mx A -> is_trig_mx (drsubmx A).\nProof.\nAdmitted.\n\nLemma ulsubmx_diag m1 m2 n1 n2 (A : 'M[V]_(m1 + m2, n1 + n2)) :\n is_diag_mx A -> is_diag_mx (ulsubmx A).\nProof.\nAdmitted.\n\nLemma drsubmx_diag m1 m2 n1 n2 (A : 'M[V]_(m1 + m2, n1 + n2)) :\n m1 = n1 -> is_diag_mx A -> is_diag_mx (drsubmx A).\nProof.\nAdmitted.\n\nLemma is_trig_block_mx m1 m2 n1 n2 ul ur dl dr : m1 = n1 ->\n @is_trig_mx (m1 + m2) (n1 + n2) (block_mx ul ur dl dr) =\n [&& ur == 0, is_trig_mx ul & is_trig_mx dr].\nProof.\nAdmitted.\n\nLemma trigmx_ind (P : forall m n, 'M_(m, n) -> Type) :\n (forall m, P m 0 0) ->\n (forall n, P 0 n 0) ->\n (forall m n x c A, is_trig_mx A ->\n P m n A -> P (1 + m)%N (1 + n)%N (block_mx x 0 c A)) ->\n forall m n A, is_trig_mx A -> P m n A.\nProof.\nAdmitted.\n\nLemma trigsqmx_ind (P : forall n, 'M[V]_n -> Type) : (P 0 0) ->\n (forall n x c A, is_trig_mx A -> P n A -> P (1 + n)%N (block_mx x 0 c A)) ->\n forall n A, is_trig_mx A -> P n A.\nProof.\nAdmitted.\n\nLemma is_diag_block_mx m1 m2 n1 n2 ul ur dl dr : m1 = n1 ->\n @is_diag_mx (m1 + m2) (n1 + n2) (block_mx ul ur dl dr) =\n [&& ur == 0, dl == 0, is_diag_mx ul & is_diag_mx dr].\nProof.\nAdmitted.\n\nLemma diagmx_ind (P : forall m n, 'M_(m, n) -> Type) :\n (forall m, P m 0 0) ->\n (forall n, P 0 n 0) ->\n (forall m n x c A, is_diag_mx A ->\n P m n A -> P (1 + m)%N (1 + n)%N (block_mx x 0 c A)) ->\n forall m n A, is_diag_mx A -> P m n A.\nProof.\nAdmitted.\n\nLemma diagsqmx_ind (P : forall n, 'M[V]_n -> Type) :\n (P 0 0) ->\n (forall n x c A, is_diag_mx A -> P n A -> P (1 + n)%N (block_mx x 0 c A)) ->\n forall n A, is_diag_mx A -> P n A.\nProof.\nAdmitted.\n\nFact diag_mx_key : unit.\nProof.\nAdmitted.\nDefinition diag_mx n (d : 'rV[V]_n) :=\n \\matrix[diag_mx_key]_(i, j) (d 0 i *+ (i == j)).\n\nLemma tr_diag_mx n (d : 'rV_n) : (diag_mx d)^T = diag_mx d.\nProof.\nAdmitted.\n\nFact diag_mx_is_nmod_morphism n : nmod_morphism (@diag_mx n).\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=diag_mx_is_nmod_morphism)]\nDefinition diag_mx_is_semi_additive := diag_mx_is_nmod_morphism.\nHB.instance Definition _ n := GRing.isNmodMorphism.Build 'rV_n 'M_n (@diag_mx n)\n (@diag_mx_is_nmod_morphism n).\n\nLemma diag_mx_row m n (l : 'rV_n) (r : 'rV_m) :\n diag_mx (row_mx l r) = block_mx (diag_mx l) 0 0 (diag_mx r).\nProof.\nAdmitted.\n\nLemma diag_mxP n (A : 'M[V]_n) :\n reflect (exists d : 'rV_n, A = diag_mx d) (is_diag_mx A).\nProof.\nAdmitted.\n\nLemma diag_mx_is_diag n (r : 'rV[V]_n) : is_diag_mx (diag_mx r).\nProof.\nAdmitted.\n\nLemma diag_mx_is_trig n (r : 'rV[V]_n) : is_trig_mx (diag_mx r).\nProof.\nAdmitted.\n\nSection ScalarMx.\n\nVariable n : nat.\n\nFact scalar_mx_key : unit.\nProof.\nAdmitted.\nDefinition scalar_mx x : 'M[V]_n :=\n \\matrix[scalar_mx_key]_(i , j) (x *+ (i == j)).\nNotation \"x %:M\" := (scalar_mx x) : ring_scope.\n\nLemma diag_const_mx a : diag_mx (const_mx a) = a%:M :> 'M_n.\nProof.\nAdmitted.\n\nLemma tr_scalar_mx a : (a%:M)^T = a%:M.\nProof.\nAdmitted.\n\nFact scalar_mx_is_nmod_morphism : nmod_morphism scalar_mx.\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=scalar_mx_is_nmod_morphism)]\nDefinition scalar_mx_is_semi_additive := scalar_mx_is_nmod_morphism.\nHB.instance Definition _ := GRing.isNmodMorphism.Build V 'M_n scalar_mx\n scalar_mx_is_nmod_morphism.\n\nDefinition is_scalar_mx (A : 'M[V]_n) :=\n if insub 0 is Some i then A == (A i i)%:M else true.\n\nLemma is_scalar_mxP A : reflect (exists a, A = a%:M) (is_scalar_mx A).\nProof.\nAdmitted.\n\nLemma scalar_mx_is_scalar a : is_scalar_mx a%:M.\nProof.\nAdmitted.\n\nLemma mx0_is_scalar : is_scalar_mx 0.\nProof.\nAdmitted.\n\nLemma scalar_mx_is_diag a : is_diag_mx a%:M.\nProof.\nAdmitted.\n\nLemma is_scalar_mx_is_diag A : is_scalar_mx A -> is_diag_mx A.\nProof.\nAdmitted.\n\nLemma scalar_mx_is_trig a : is_trig_mx a%:M.\nProof.\nAdmitted.\n\nLemma is_scalar_mx_is_trig A : is_scalar_mx A -> is_trig_mx A.\nProof.\nAdmitted.\n\nEnd ScalarMx.\n\nNotation \"x %:M\" := (scalar_mx _ x) : ring_scope.\n\nLemma mx11_scalar (A : 'M_1) : A = (A 0 0)%:M.\nProof.\nAdmitted.\n\nLemma scalar_mx_block n1 n2 a : a%:M = block_mx a%:M 0 0 a%:M :> 'M_(n1 + n2).\nProof.\nAdmitted.\n\nSection Trace.\n\nVariable n : nat.\n\nDefinition mxtrace (A : 'M[V]_n) := \\sum_i A i i.\nLocal Notation \"'\\tr' A\" := (mxtrace A) : ring_scope.\n\nLemma mxtrace_tr A : \\tr A^T = \\tr A.\nProof.\nAdmitted.\n\nFact mxtrace_is_nmod_morphism : nmod_morphism mxtrace.\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=mxtrace_is_nmod_morphism)]\nDefinition mxtrace_is_semi_additive := mxtrace_is_nmod_morphism.\nHB.instance Definition _ := GRing.isNmodMorphism.Build 'M_n V mxtrace\n mxtrace_is_nmod_morphism.\n\nLemma mxtrace0 : \\tr 0 = 0.\nProof.\nAdmitted.\nLemma mxtraceD A B : \\tr (A + B) = \\tr A + \\tr B.\nProof.\nAdmitted.\n\nLemma mxtrace_diag D : \\tr (diag_mx D) = \\sum_j D 0 j.\nProof.\nAdmitted.\n\nLemma mxtrace_scalar a : \\tr a%:M = a *+ n.\nProof.\nAdmitted.\n\nEnd Trace.\nLocal Notation \"'\\tr' A\" := (mxtrace A) : ring_scope.\n\nLemma trace_mx11 (A : 'M_1) : \\tr A = A 0 0.\nProof.\nAdmitted.\n\nLemma mxtrace_block n1 n2 (Aul : 'M_n1) Aur Adl (Adr : 'M_n2) :\n \\tr (block_mx Aul Aur Adl Adr) = \\tr Aul + \\tr Adr.\nProof.\nAdmitted.\n\nEnd MatrixNmodule.\n\nArguments is_diag_mx {V m n}.\nArguments is_diag_mxP {V m n A}.\nArguments is_trig_mx {V m n}.\nArguments is_trig_mxP {V m n A}.\nArguments scalar_mx {V n}.\nArguments is_scalar_mxP {V n A}.\n\nNotation \"\\tr A\" := (mxtrace A) : ring_scope.\n\nSection MapNmodMatrix.\n\nVariables (aR rR : nmodType) (f : {additive aR -> rR}) (m n : nat).\nLocal Notation \"A ^f\" := (map_mx f A) : ring_scope.\nImplicit Type A : 'M[aR]_(m, n).\n\nLemma map_mx0 : 0^f = 0 :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma map_mxD A B : (A + B)^f = A^f + B^f.\nProof.\nAdmitted.\n\nDefinition map_mx_sum := big_morph _ map_mxD map_mx0.\n\nHB.instance Definition _ :=\n GRing.isNmodMorphism.Build 'M[aR]_(m, n) 'M[rR]_(m, n) (map_mx f)\n (map_mx0, map_mxD).\n\nEnd MapNmodMatrix.\n\nSection MatrixZmodule.\n\nVariable V : zmodType.\n\nSection FixedDim.\n\nVariables m n : nat.\nImplicit Types A B : 'M[V]_(m, n).\n\nFact oppmx_key : unit.\nProof.\nAdmitted.\nDefinition oppmx := @map_mx V V -%R m n.\n\nLemma addNmx : left_inverse (const_mx 0) oppmx (@addmx V m n).\nProof.\nAdmitted.\n\nHB.instance Definition _ := GRing.Nmodule_isZmodule.Build 'M[V]_(m, n) addNmx.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=raddfB)]\nFact const_mx_is_zmod_morphism : zmod_morphism const_mx.\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=raddfB),\n warning=\"-deprecated\"]\nDefinition const_mx_is_additive := const_mx_is_zmod_morphism.\n\nEnd FixedDim.\n\nSection Additive.\n\nVariables (m n p q : nat) (f : 'I_p -> 'I_q -> 'I_m) (g : 'I_p -> 'I_q -> 'I_n).\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=raddfB)]\nFact swizzle_mx_is_zmod_morphism k : zmod_morphism (swizzle_mx f g k).\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=raddfB),\n warning=\"-deprecated\"]\nDefinition swizzle_mx_is_additive := swizzle_mx_is_zmod_morphism.\n\nEnd Additive.\n\nLtac split_mxE := apply/matrixP=> i j; do ![rewrite mxE | case: split => ?].\n\nLemma opp_row_mx m n1 n2 (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) :\n - row_mx A1 A2 = row_mx (- A1) (- A2).\nProof.\nAdmitted.\n\nLemma opp_col_mx m1 m2 n (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) :\n - col_mx A1 A2 = col_mx (- A1) (- A2).\nProof.\nAdmitted.\n\nLemma opp_block_mx m1 m2 n1 n2 (Aul : 'M_(m1, n1)) Aur Adl (Adr : 'M_(m2, n2)) :\n - block_mx Aul Aur Adl Adr = block_mx (- Aul) (- Aur) (- Adl) (- Adr).\nProof.\nAdmitted.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=raddfB)]\nFact diag_mx_is_zmod_morphism n : zmod_morphism (@diag_mx V n).\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=raddfB),\n warning=\"-deprecated\"]\nDefinition diag_mx_is_additive := diag_mx_is_zmod_morphism.\n\nSection ScalarMx.\n\nVariable n : nat.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=raddfB)]\nFact scalar_mx_is_zmod_morphism : zmod_morphism (@scalar_mx V n).\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=raddfB),\n warning=\"-deprecated\"]\nDefinition scalar_mx_is_additive := scalar_mx_is_zmod_morphism.\n\nEnd ScalarMx.\n\nSection Trace.\n\nVariable n : nat.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=raddfB)]\nFact mxtrace_is_zmod_morphism : zmod_morphism (@mxtrace V n).\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=raddfB),\n warning=\"-deprecated\"]\nDefinition mxtrace_is_additive := mxtrace_is_zmod_morphism.\n\nEnd Trace.\n\nEnd MatrixZmodule.\n\nSection MapZmodMatrix.\n\nVariables (aR rR : zmodType) (f : {additive aR -> rR}) (m n : nat).\nLocal Notation \"A ^f\" := (map_mx f A) : ring_scope.\nImplicit Type A : 'M[aR]_(m, n).\n\nLemma map_mxN A : (- A)^f = - A^f.\nProof.\nAdmitted.\n\nLemma map_mxB A B : (A - B)^f = A^f - B^f.\nProof.\nAdmitted.\n\nEnd MapZmodMatrix.\n\nSection MatrixAlgebra.\n\nVariable R : pzSemiRingType.\n\nSection SemiRingModule.\n\nVariables m n : nat.\nImplicit Types A B : 'M[R]_(m, n).\n\nFact scalemx_key : unit.\nProof.\nAdmitted.\nDefinition scalemx x A := \\matrix[scalemx_key]_(i, j) (x * A i j).\n\nFact delta_mx_key : unit.\nProof.\nAdmitted.\nDefinition delta_mx i0 j0 : 'M[R]_(m, n) :=\n \\matrix[delta_mx_key]_(i, j) ((i == i0) && (j == j0))%:R.\n\nLocal Notation \"x *m: A\" := (scalemx x A) (at level 40) : ring_scope.\n\nFact scale0mx A : 0 *m: A = 0.\nProof.\nAdmitted.\n\nFact scale1mx A : 1 *m: A = A.\nProof.\nAdmitted.\n\nFact scalemxDl A x y : (x + y) *m: A = x *m: A + y *m: A.\nProof.\nAdmitted.\n\nFact scalemxDr x A B : x *m: (A + B) = x *m: A + x *m: B.\nProof.\nAdmitted.\n\nFact scalemxA x y A : x *m: (y *m: A) = (x * y) *m: A.\nProof.\nAdmitted.\n\nHB.instance Definition _ :=\n GRing.Nmodule_isLSemiModule.Build R 'M[R]_(m, n)\n scalemxA scale0mx scale1mx scalemxDr scalemxDl.\n\nLemma scalemx_const a b : a *: const_mx b = const_mx (a * b).\nProof.\nAdmitted.\n\nLemma matrix_sum_delta A : A = \\sum_(i < m) \\sum_(j < n) A i j *: delta_mx i j.\nProof.\nAdmitted.\n\nEnd SemiRingModule.\n\nLemma trmx_delta m n i j : (delta_mx i j)^T = delta_mx j i :> 'M[R]_(n, m).\nProof.\nAdmitted.\n\nLemma delta_mx_lshift m n1 n2 i j :\n delta_mx i (lshift n2 j) = row_mx (delta_mx i j) 0 :> 'M_(m, n1 + n2).\nProof.\nAdmitted.\n\nLemma delta_mx_rshift m n1 n2 i j :\n delta_mx i (rshift n1 j) = row_mx 0 (delta_mx i j) :> 'M_(m, n1 + n2).\nProof.\nAdmitted.\n\nLemma delta_mx_ushift m1 m2 n i j :\n delta_mx (lshift m2 i) j = col_mx (delta_mx i j) 0 :> 'M_(m1 + m2, n).\nProof.\nAdmitted.\n\nLemma delta_mx_dshift m1 m2 n i j :\n delta_mx (rshift m1 i) j = col_mx 0 (delta_mx i j) :> 'M_(m1 + m2, n).\nProof.\nAdmitted.\n\nLemma vec_mx_delta m n i j :\n vec_mx (delta_mx 0 (mxvec_index i j)) = delta_mx i j :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma mxvec_delta m n i j :\n mxvec (delta_mx i j) = delta_mx 0 (mxvec_index i j) :> 'rV_(m * n).\nProof.\nAdmitted.\n\nLtac split_mxE := apply/matrixP=> i j; do ![rewrite mxE | case: split => ?].\n\nNotation \"x %:M\" := (scalar_mx x) : ring_scope.\n\nLemma trmx1 n : (1%:M)^T = 1%:M :> 'M[R]_n.\nProof.\nAdmitted.\n\nLemma row1 n i : row i (1%:M : 'M_n) = delta_mx 0 i.\nProof.\nAdmitted.\n\nLemma col1 n i : col i (1%:M : 'M_n) = delta_mx i 0.\nProof.\nAdmitted.\n\nFact mulmx_key : unit.\nProof.\nAdmitted.\nDefinition mulmx {m n p} (A : 'M_(m, n)) (B : 'M_(n, p)) : 'M[R]_(m, p) :=\n \\matrix[mulmx_key]_(i, k) \\sum_j (A i j * B j k).\n\nLocal Notation \"A *m B\" := (mulmx A B) : ring_scope.\n\nLemma mulmxA m n p q (A : 'M_(m, n)) (B : 'M_(n, p)) (C : 'M_(p, q)) :\n A *m (B *m C) = A *m B *m C.\nProof.\nAdmitted.\n\nLemma mul0mx m n p (A : 'M_(n, p)) : 0 *m A = 0 :> 'M_(m, p).\nProof.\nAdmitted.\n\nLemma mulmx0 m n p (A : 'M_(m, n)) : A *m 0 = 0 :> 'M_(m, p).\nProof.\nAdmitted.\n\nLemma mulmxDl m n p (A1 A2 : 'M_(m, n)) (B : 'M_(n, p)) :\n (A1 + A2) *m B = A1 *m B + A2 *m B.\nProof.\nAdmitted.\n\nLemma mulmxDr m n p (A : 'M_(m, n)) (B1 B2 : 'M_(n, p)) :\n A *m (B1 + B2) = A *m B1 + A *m B2.\nProof.\nAdmitted.\n\nHB.instance Definition _ m n p A :=\n GRing.isNmodMorphism.Build 'M_(n, p) 'M_(m, p) (mulmx A)\n (mulmx0 _ A, mulmxDr A).\n\nLemma scalemxAl m n p a (A : 'M_(m, n)) (B : 'M_(n, p)) :\n a *: (A *m B) = (a *: A) *m B.\nProof.\nAdmitted.\n\nLemma mulmx_suml m n p (A : 'M_(n, p)) I r P (B_ : I -> 'M_(m, n)) :\n (\\sum_(i <- r | P i) B_ i) *m A = \\sum_(i <- r | P i) B_ i *m A.\nProof.\nAdmitted.\n\nLemma mulmx_sumr m n p (A : 'M_(m, n)) I r P (B_ : I -> 'M_(n, p)) :\n A *m (\\sum_(i <- r | P i) B_ i) = \\sum_(i <- r | P i) A *m B_ i.\nProof.\nAdmitted.\n\nLemma rowE m n i (A : 'M_(m, n)) : row i A = delta_mx 0 i *m A.\nProof.\nAdmitted.\n\nLemma colE m n i (A : 'M_(m, n)) : col i A = A *m delta_mx i 0.\nProof.\nAdmitted.\n\nLemma mul_rVP m n A B : ((@mulmx 1 m n)^~ A =1 mulmx^~ B) <-> (A = B).\nProof.\nAdmitted.\n\nLemma row_mul m n p (i : 'I_m) A (B : 'M_(n, p)) :\n row i (A *m B) = row i A *m B.\nProof.\nAdmitted.\n\nLemma mxsub_mul m n m' n' p f g (A : 'M_(m, p)) (B : 'M_(p, n)) :\n mxsub f g (A *m B) = rowsub f A *m colsub g B :> 'M_(m', n').\nProof.\nAdmitted.\n\nLemma mul_rowsub_mx m n m' p f (A : 'M_(m, p)) (B : 'M_(p, n)) :\n rowsub f A *m B = rowsub f (A *m B) :> 'M_(m', n).\nProof.\nAdmitted.\n\nLemma mulmx_colsub m n n' p g (A : 'M_(m, p)) (B : 'M_(p, n)) :\n A *m colsub g B = colsub g (A *m B) :> 'M_(m, n').\nProof.\nAdmitted.\n\nLemma mul_delta_mx_cond m n p (j1 j2 : 'I_n) (i1 : 'I_m) (k2 : 'I_p) :\n delta_mx i1 j1 *m delta_mx j2 k2 = delta_mx i1 k2 *+ (j1 == j2).\nProof.\nAdmitted.\n\nLemma mul_delta_mx m n p (j : 'I_n) (i : 'I_m) (k : 'I_p) :\n delta_mx i j *m delta_mx j k = delta_mx i k.\nProof.\nAdmitted.\n\nLemma mul_delta_mx_0 m n p (j1 j2 : 'I_n) (i1 : 'I_m) (k2 : 'I_p) :\n j1 != j2 -> delta_mx i1 j1 *m delta_mx j2 k2 = 0.\nProof.\nAdmitted.\n\nLemma mul_diag_mx m n d (A : 'M_(m, n)) :\n diag_mx d *m A = \\matrix_(i, j) (d 0 i * A i j).\nProof.\nAdmitted.\n\nLemma mul_mx_diag m n (A : 'M_(m, n)) d :\n A *m diag_mx d = \\matrix_(i, j) (A i j * d 0 j).\nProof.\nAdmitted.\n\nLemma mulmx_diag n (d e : 'rV_n) :\n diag_mx d *m diag_mx e = diag_mx (\\row_j (d 0 j * e 0 j)).\nProof.\nAdmitted.\n\nLemma scalar_mxM n a b : (a * b)%:M = a%:M *m b%:M :> 'M_n.\nProof.\nAdmitted.\n\nLemma mul1mx m n (A : 'M_(m, n)) : 1%:M *m A = A.\nProof.\nAdmitted.\n\nLemma mulmx1 m n (A : 'M_(m, n)) : A *m 1%:M = A.\nProof.\nAdmitted.\n\nLemma rowsubE m m' n f (A : 'M_(m, n)) :\n rowsub f A = rowsub f 1%:M *m A :> 'M_(m', n).\nProof.\nAdmitted.\n\nLemma mul_col_perm m n p s (A : 'M_(m, n)) (B : 'M_(n, p)) :\n col_perm s A *m B = A *m row_perm s^-1 B.\nProof.\nAdmitted.\n\nLemma mul_row_perm m n p s (A : 'M_(m, n)) (B : 'M_(n, p)) :\n A *m row_perm s B = col_perm s^-1 A *m B.\nProof.\nAdmitted.\n\nLemma mul_xcol m n p j1 j2 (A : 'M_(m, n)) (B : 'M_(n, p)) :\n xcol j1 j2 A *m B = A *m xrow j1 j2 B.\nProof.\nAdmitted.\n\nDefinition perm_mx n s : 'M_n := row_perm s (1%:M : 'M[R]_n).\n\nDefinition tperm_mx n i1 i2 : 'M_n := perm_mx (tperm i1 i2).\n\nLemma col_permE m n s (A : 'M_(m, n)) : col_perm s A = A *m perm_mx s^-1.\nProof.\nAdmitted.\n\nLemma row_permE m n s (A : 'M_(m, n)) : row_perm s A = perm_mx s *m A.\nProof.\nAdmitted.\n\nLemma xcolE m n j1 j2 (A : 'M_(m, n)) : xcol j1 j2 A = A *m tperm_mx j1 j2.\nProof.\nAdmitted.\n\nLemma xrowE m n i1 i2 (A : 'M_(m, n)) : xrow i1 i2 A = tperm_mx i1 i2 *m A.\nProof.\nAdmitted.\n\nLemma perm_mxEsub n s : @perm_mx n s = rowsub s 1%:M.\nProof.\nAdmitted.\n\nLemma tperm_mxEsub n i1 i2 : @tperm_mx n i1 i2 = rowsub (tperm i1 i2) 1%:M.\nProof.\nAdmitted.\n\nLemma tr_perm_mx n (s : 'S_n) : (perm_mx s)^T = perm_mx s^-1.\nProof.\nAdmitted.\n\nLemma tr_tperm_mx n i1 i2 : (tperm_mx i1 i2)^T = tperm_mx i1 i2 :> 'M_n.\nProof.\nAdmitted.\n\nLemma perm_mx1 n : perm_mx 1 = 1%:M :> 'M_n.\nProof.\nAdmitted.\n\nLemma perm_mxM n (s t : 'S_n) : perm_mx (s * t) = perm_mx s *m perm_mx t.\nProof.\nAdmitted.\n\nDefinition is_perm_mx n (A : 'M_n) := [exists s, A == perm_mx s].\n\nLemma is_perm_mxP n (A : 'M_n) :\n reflect (exists s, A = perm_mx s) (is_perm_mx A).\nProof.\nAdmitted.\n\nLemma perm_mx_is_perm n (s : 'S_n) : is_perm_mx (perm_mx s).\nProof.\nAdmitted.\n\nLemma is_perm_mx1 n : is_perm_mx (1%:M : 'M_n).\nProof.\nAdmitted.\n\nLemma is_perm_mxMl n (A B : 'M_n) :\n is_perm_mx A -> is_perm_mx (A *m B) = is_perm_mx B.\nProof.\nAdmitted.\n\nLemma is_perm_mx_tr n (A : 'M_n) : is_perm_mx A^T = is_perm_mx A.\nProof.\nAdmitted.\n\nLemma is_perm_mxMr n (A B : 'M_n) :\n is_perm_mx B -> is_perm_mx (A *m B) = is_perm_mx A.\nProof.\nAdmitted.\n\nFact pid_mx_key : unit.\nProof.\nAdmitted.\nDefinition pid_mx {m n} r : 'M[R]_(m, n) :=\n \\matrix[pid_mx_key]_(i, j) ((i == j :> nat) && (i < r))%:R.\n\nLemma pid_mx_0 m n : pid_mx 0 = 0 :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma pid_mx_1 r : pid_mx r = 1%:M :> 'M_r.\nProof.\nAdmitted.\n\nLemma pid_mx_row n r : pid_mx r = row_mx 1%:M 0 :> 'M_(r, r + n).\nProof.\nAdmitted.\n\nLemma pid_mx_col m r : pid_mx r = col_mx 1%:M 0 :> 'M_(r + m, r).\nProof.\nAdmitted.\n\nLemma pid_mx_block m n r : pid_mx r = block_mx 1%:M 0 0 0 :> 'M_(r + m, r + n).\nProof.\nAdmitted.\n\nLemma tr_pid_mx m n r : (pid_mx r)^T = pid_mx r :> 'M_(n, m).\nProof.\nAdmitted.\n\nLemma pid_mx_minv m n r : pid_mx (minn m r) = pid_mx r :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma pid_mx_minh m n r : pid_mx (minn n r) = pid_mx r :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma mul_pid_mx m n p q r :\n (pid_mx q : 'M_(m, n)) *m (pid_mx r : 'M_(n, p)) = pid_mx (minn n (minn q r)).\nProof.\nAdmitted.\n\nLemma pid_mx_id m n p r :\n r <= n -> (pid_mx r : 'M_(m, n)) *m (pid_mx r : 'M_(n, p)) = pid_mx r.\nProof.\nAdmitted.\n\nLemma pid_mxErow m n (le_mn : m <= n) :\n pid_mx m = rowsub (widen_ord le_mn) 1%:M.\nProof.\nAdmitted.\n\nLemma pid_mxEcol m n (le_mn : m <= n) :\n pid_mx n = colsub (widen_ord le_mn) 1%:M.\nProof.\nAdmitted.\n\nLemma mul_mx_row m n p1 p2 (A : 'M_(m, n)) (Bl : 'M_(n, p1)) (Br : 'M_(n, p2)) :\n A *m row_mx Bl Br = row_mx (A *m Bl) (A *m Br).\nProof.\nAdmitted.\n\nLemma mul_col_mx m1 m2 n p (Au : 'M_(m1, n)) (Ad : 'M_(m2, n)) (B : 'M_(n, p)) :\n col_mx Au Ad *m B = col_mx (Au *m B) (Ad *m B).\nProof.\nAdmitted.\n\nLemma mul_row_col m n1 n2 p (Al : 'M_(m, n1)) (Ar : 'M_(m, n2))\n (Bu : 'M_(n1, p)) (Bd : 'M_(n2, p)) :\n row_mx Al Ar *m col_mx Bu Bd = Al *m Bu + Ar *m Bd.\nProof.\nAdmitted.\n\nLemma mul_col_row m1 m2 n p1 p2 (Au : 'M_(m1, n)) (Ad : 'M_(m2, n))\n (Bl : 'M_(n, p1)) (Br : 'M_(n, p2)) :\n col_mx Au Ad *m row_mx Bl Br\n = block_mx (Au *m Bl) (Au *m Br) (Ad *m Bl) (Ad *m Br).\nProof.\nAdmitted.\n\nLemma mul_row_block m n1 n2 p1 p2 (Al : 'M_(m, n1)) (Ar : 'M_(m, n2))\n (Bul : 'M_(n1, p1)) (Bur : 'M_(n1, p2))\n (Bdl : 'M_(n2, p1)) (Bdr : 'M_(n2, p2)) :\n row_mx Al Ar *m block_mx Bul Bur Bdl Bdr\n = row_mx (Al *m Bul + Ar *m Bdl) (Al *m Bur + Ar *m Bdr).\nProof.\nAdmitted.\n\nLemma mul_block_col m1 m2 n1 n2 p (Aul : 'M_(m1, n1)) (Aur : 'M_(m1, n2))\n (Adl : 'M_(m2, n1)) (Adr : 'M_(m2, n2))\n (Bu : 'M_(n1, p)) (Bd : 'M_(n2, p)) :\n block_mx Aul Aur Adl Adr *m col_mx Bu Bd\n = col_mx (Aul *m Bu + Aur *m Bd) (Adl *m Bu + Adr *m Bd).\nProof.\nAdmitted.\n\nLemma mulmx_block m1 m2 n1 n2 p1 p2 (Aul : 'M_(m1, n1)) (Aur : 'M_(m1, n2))\n (Adl : 'M_(m2, n1)) (Adr : 'M_(m2, n2))\n (Bul : 'M_(n1, p1)) (Bur : 'M_(n1, p2))\n (Bdl : 'M_(n2, p1)) (Bdr : 'M_(n2, p2)) :\n block_mx Aul Aur Adl Adr *m block_mx Bul Bur Bdl Bdr\n = block_mx (Aul *m Bul + Aur *m Bdl) (Aul *m Bur + Aur *m Bdr)\n (Adl *m Bul + Adr *m Bdl) (Adl *m Bur + Adr *m Bdr).\nProof.\nAdmitted.\n\nLemma mulmx_lsub m n p k (A : 'M_(m, n)) (B : 'M_(n, p + k)) :\n A *m lsubmx B = lsubmx (A *m B).\nProof.\nAdmitted.\n\nLemma mulmx_rsub m n p k (A : 'M_(m, n)) (B : 'M_(n, p + k)) :\n A *m rsubmx B = rsubmx (A *m B).\nProof.\nAdmitted.\n\nLemma mul_usub_mx m k n p (A : 'M_(m + k, n)) (B : 'M_(n, p)) :\n usubmx A *m B = usubmx (A *m B).\nProof.\nAdmitted.\n\nLemma mul_dsub_mx m k n p (A : 'M_(m + k, n)) (B : 'M_(n, p)) :\n dsubmx A *m B = dsubmx (A *m B).\nProof.\nAdmitted.\n\nSection Trace.\nVariable n : nat.\n\nLemma mxtrace1 : \\tr (1%:M : 'M[R]_n) = n%:R.\nProof.\nAdmitted.\n\nLemma mxtraceZ a (A : 'M_n) : \\tr (a *: A) = a * \\tr A.\nProof.\nAdmitted.\n\nHB.instance Definition _ :=\n GRing.isScalable.Build R 'M_n R _ (@mxtrace _ n) mxtraceZ.\n\nEnd Trace.\n\nSection StructuralLinear.\n\nFact swizzle_mx_is_scalable m n p q f g k :\n scalable (@swizzle_mx R m n p q f g k).\nProof.\nAdmitted.\nHB.instance Definition _ m n p q f g k :=\n GRing.isScalable.Build R 'M[R]_(m, n) 'M[R]_(p, q) *:%R (swizzle_mx f g k)\n (swizzle_mx_is_scalable f g k).\n\nLocal Notation SwizzleLin op := (GRing.Linear.copy op (swizzle_mx _ _ _)).\n\nHB.instance Definition _ m n := SwizzleLin (@trmx R m n).\nHB.instance Definition _ m n i := SwizzleLin (@row R m n i).\nHB.instance Definition _ m n j := SwizzleLin (@col R m n j).\nHB.instance Definition _ m n i := SwizzleLin (@row' R m n i).\nHB.instance Definition _ m n j := SwizzleLin (@col' R m n j).\nHB.instance Definition _ m n m' n' f g := SwizzleLin (@mxsub R m n m' n' f g).\nHB.instance Definition _ m n s := SwizzleLin (@row_perm R m n s).\nHB.instance Definition _ m n s := SwizzleLin (@col_perm R m n s).\nHB.instance Definition _ m n i1 i2 := SwizzleLin (@xrow R m n i1 i2).\nHB.instance Definition _ m n j1 j2 := SwizzleLin (@xcol R m n j1 j2).\nHB.instance Definition _ m n1 n2 := SwizzleLin (@lsubmx R m n1 n2).\nHB.instance Definition _ m n1 n2 := SwizzleLin (@rsubmx R m n1 n2).\nHB.instance Definition _ m1 m2 n := SwizzleLin (@usubmx R m1 m2 n).\nHB.instance Definition _ m1 m2 n := SwizzleLin (@dsubmx R m1 m2 n).\n\nHB.instance Definition _ m n := SwizzleLin (@vec_mx R m n).\nDefinition mxvec_is_scalable m n := can2_scalable (@vec_mxK R m n) mxvecK.\nHB.instance Definition _ m n :=\n GRing.isScalable.Build R 'M_(m, n) 'rV_(m * n) *:%R mxvec\n (@mxvec_is_scalable m n).\n\nEnd StructuralLinear.\n\nLemma row_sum_delta n (u : 'rV_n) : u = \\sum_(j < n) u 0 j *: delta_mx 0 j.\nProof.\nAdmitted.\n\nLemma scale_row_mx m n1 n2 a (A1 : 'M_(m, n1)) (A2 : 'M_(m, n2)) :\n a *: row_mx A1 A2 = row_mx (a *: A1) (a *: A2).\nProof.\nAdmitted.\n\nLemma scale_col_mx m1 m2 n a (A1 : 'M_(m1, n)) (A2 : 'M_(m2, n)) :\n a *: col_mx A1 A2 = col_mx (a *: A1) (a *: A2).\nProof.\nAdmitted.\n\nLemma scale_block_mx m1 m2 n1 n2 a (Aul : 'M_(m1, n1)) (Aur : 'M_(m1, n2))\n (Adl : 'M_(m2, n1)) (Adr : 'M_(m2, n2)) :\n a *: block_mx Aul Aur Adl Adr\n = block_mx (a *: Aul) (a *: Aur) (a *: Adl) (a *: Adr).\nProof.\nAdmitted.\n\nFact diag_mx_is_scalable n : scalable (@diag_mx R n).\nProof.\nAdmitted.\nHB.instance Definition _ n :=\n GRing.isScalable.Build R 'rV_n 'M_n _ (@diag_mx _ n) (@diag_mx_is_scalable n).\n\nLemma diag_mx_sum_delta n (d : 'rV_n) :\n diag_mx d = \\sum_i d 0 i *: delta_mx i i.\nProof.\nAdmitted.\n\nLemma row_diag_mx n (d : 'rV_n) i : row i (diag_mx d) = d 0 i *: delta_mx 0 i.\nProof.\nAdmitted.\n\nLemma scale_scalar_mx n a1 a2 : a1 *: a2%:M = (a1 * a2)%:M :> 'M_n.\nProof.\nAdmitted.\n\nLemma scalemx1 n a : a *: 1%:M = a%:M :> 'M_n.\nProof.\nAdmitted.\n\nLemma scalar_mx_sum_delta n a : a%:M = \\sum_i a *: delta_mx i i :> 'M_n.\nProof.\nAdmitted.\n\nLemma mx1_sum_delta n : 1%:M = \\sum_i delta_mx i i :> 'M[R]_n.\nProof.\nAdmitted.\n\nLemma mulmx_sum_row m n (u : 'rV_m) (A : 'M_(m, n)) :\n u *m A = \\sum_i u 0 i *: row i A.\nProof.\nAdmitted.\n\nLemma mul_scalar_mx m n a (A : 'M_(m, n)) : a%:M *m A = a *: A.\nProof.\nAdmitted.\n\nSection MatrixSemiRing.\n\nVariable n : nat.\n\nHB.instance Definition _ := GRing.Nmodule_isPzSemiRing.Build 'M[R]_n\n (@mulmxA n n n n) (@mul1mx n n) (@mulmx1 n n)\n (@mulmxDl n n n) (@mulmxDr n n n) (@mul0mx n n n) (@mulmx0 n n n).\n\nHB.instance Definition _ :=\n GRing.LSemiModule_isLSemiAlgebra.Build R 'M[R]_n (@scalemxAl n n n).\n\nLemma mulmxE : mulmx = *%R.\nProof.\nAdmitted.\nLemma idmxE : 1%:M = 1 :> 'M_n.\nProof.\nAdmitted.\n\nFact scalar_mx_is_monoid_morphism : monoid_morphism (@scalar_mx R n).\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=scalar_mx_is_monoid_morphism)]\nDefinition scalar_mx_is_multiplicative := scalar_mx_is_monoid_morphism.\nHB.instance Definition _ := GRing.isMonoidMorphism.Build R 'M_n (@scalar_mx _ n)\n scalar_mx_is_monoid_morphism.\n\nEnd MatrixSemiRing.\n\nSection LinRowVector.\n\nVariables m n : nat.\n\nFact lin1_mx_key : unit.\nProof.\nAdmitted.\nDefinition lin1_mx (f : 'rV[R]_m -> 'rV[R]_n) :=\n \\matrix[lin1_mx_key]_(i, j) f (delta_mx 0 i) 0 j.\n\nVariable f : {linear 'rV[R]_m -> 'rV[R]_n}.\n\nLemma mul_rV_lin1 u : u *m lin1_mx f = f u.\nProof.\nAdmitted.\n\nEnd LinRowVector.\n\nSection LinMatrix.\n\nVariables m1 n1 m2 n2 : nat.\n\nDefinition lin_mx (f : 'M[R]_(m1, n1) -> 'M[R]_(m2, n2)) :=\n lin1_mx (mxvec \\o f \\o vec_mx).\n\nVariable f : {linear 'M[R]_(m1, n1) -> 'M[R]_(m2, n2)}.\n\nLemma mul_rV_lin u : u *m lin_mx f = mxvec (f (vec_mx u)).\nProof.\nAdmitted.\n\nLemma mul_vec_lin A : mxvec A *m lin_mx f = mxvec (f A).\nProof.\nAdmitted.\n\nLemma mx_rV_lin u : vec_mx (u *m lin_mx f) = f (vec_mx u).\nProof.\nAdmitted.\n\nLemma mx_vec_lin A : vec_mx (mxvec A *m lin_mx f) = f A.\nProof.\nAdmitted.\n\nEnd LinMatrix.\n\nSection Mulmxr.\n\nVariables m n p : nat.\nImplicit Type A : 'M[R]_(m, n).\nImplicit Type B : 'M[R]_(n, p).\n\nDefinition mulmxr B A := mulmx A B.\nArguments mulmxr B A /.\n\nFact mulmxr_is_semilinear B : semilinear (mulmxr B).\nProof.\nAdmitted.\nHB.instance Definition _ (B : 'M_(n, p)) :=\n GRing.isSemilinear.Build R 'M_(m, n) 'M_(m, p) _ (mulmxr B)\n (mulmxr_is_semilinear B).\n\nDefinition lin_mulmxr B := lin_mx (mulmxr B).\n\nFact lin_mulmxr_is_semilinear : semilinear lin_mulmxr.\nProof.\nAdmitted.\nHB.instance Definition _ :=\n GRing.isSemilinear.Build R 'M_(n, p) 'M_(m * n, m * p) _ lin_mulmxr\n lin_mulmxr_is_semilinear.\n\nEnd Mulmxr.\n\nSection LiftPerm.\n\nVariable n : nat.\n\nDefinition lift0_mx A : 'M_(1 + n) := block_mx 1 0 0 A.\n\nLemma lift0_mx_perm s : lift0_mx (perm_mx s) = perm_mx (lift0_perm s).\nProof.\nAdmitted.\n\nLemma lift0_mx_is_perm s : is_perm_mx (lift0_mx (perm_mx s)).\nProof.\nAdmitted.\n\nEnd LiftPerm.\n\nLemma exp_block_diag_mx m n (A: 'M_m.\nProof.\nAdmitted.\n\nEnd MatrixAlgebra.\n\nArguments delta_mx {R m n}.\nArguments perm_mx {R n}.\nArguments tperm_mx {R n}.\nArguments pid_mx {R m n}.\nArguments lin_mulmxr {R m n p}.\nPrenex Implicits diag_mx is_scalar_mx.\nPrenex Implicits mulmx mxtrace.\n\nArguments mul_delta_mx {R m n p}.\nArguments mulmxr {_ _ _ _} B A /.\n\n#[global] Hint Extern 0 (is_true (is_diag_mx (scalar_mx _))) =>\n apply: scalar_mx_is_diag : core.\n#[global] Hint Extern 0 (is_true (is_trig_mx (scalar_mx _))) =>\n apply: scalar_mx_is_trig : core.\n#[global] Hint Extern 0 (is_true (is_diag_mx (diag_mx _))) =>\n apply: diag_mx_is_diag : core.\n#[global] Hint Extern 0 (is_true (is_trig_mx (diag_mx _))) =>\n apply: diag_mx_is_trig : core.\n\nNotation \"a %:M\" := (scalar_mx a) : ring_scope.\nNotation \"A *m B\" := (mulmx A B) : ring_scope.\n\nLemma trmx_mul_rev (R : pzSemiRingType) m n p\n (A : 'M[R]_(m, n)) (B : 'M[R]_(n, p)) :\n (A *m B)^T = (B : 'M[R^c]_(n, p))^T *m (A : 'M[R^c]_(m, n))^T.\nProof.\nAdmitted.\n\nHB.instance Definition _ (R : pzRingType) m n :=\n GRing.LSemiModule.on 'M[R]_(m, n).\nHB.instance Definition _ (R : pzRingType) n := GRing.PzSemiRing.on 'M[R]_n.\n\nSection MatrixNzSemiRing.\n\nVariables (R : nzSemiRingType) (n' : nat).\nLocal Notation n := n'.+1.\n\nLemma matrix_nonzero1 : 1%:M != 0 :> 'M[R]_n.\nProof.\nAdmitted.\n\nHB.instance Definition _ :=\n GRing.PzSemiRing_isNonZero.Build 'M[R]_n matrix_nonzero1.\n\nEnd MatrixNzSemiRing.\n\nHB.instance Definition _ (R : nzRingType) n := GRing.NzSemiRing.on 'M[R]_n.+1.\n\nHB.instance Definition _ (M : countNmodType) m n :=\n [Countable of 'M[M]_(m, n) by <:].\nHB.instance Definition _ (M : countZmodType) m n :=\n [Countable of 'M[M]_(m, n) by <:].\nHB.instance Definition _ (R : countNzSemiRingType) n :=\n [Countable of 'M[R]_n.+1 by <:].\nHB.instance Definition _ (R : countNzRingType) n :=\n [Countable of 'M[R]_n.+1 by <:].\n\nHB.instance Definition _ (V : finNmodType) (m n : nat) :=\n [Finite of 'M[V]_(m, n) by <:].\nHB.instance Definition _ (V : finZmodType) (m n : nat) :=\n [Finite of 'M[V]_(m, n) by <:].\n#[compress_coercions]\nHB.instance Definition _ (V : finZmodType) (m n : nat) :=\n [finGroupMixin of 'M[V]_(m, n) for +%R].\n#[compress_coercions]\nHB.instance Definition _ (R : finNzSemiRingType) n :=\n [Finite of 'M[R]_n.+1 by <:].\n#[compress_coercions]\nHB.instance Definition _ (R : finNzRingType) (m n : nat) :=\n FinRing.Zmodule.on 'M[R]_(m, n).\n#[compress_coercions]\nHB.instance Definition _ (R : finNzRingType) n := [Finite of 'M[R]_n.+1 by <:].\n\nSection MapSemiRingMatrix.\n\nVariables (aR rR : pzSemiRingType) (f : {rmorphism aR -> rR}).\nLocal Notation \"A ^f\" := (map_mx f A) : ring_scope.\n\nSection FixedSize.\n\nVariables m n p : nat.\nImplicit Type A : 'M[aR]_(m, n).\n\nLemma map_mxZ a A : (a *: A)^f = f a *: A^f.\nProof.\nAdmitted.\n\nLemma map_mxM A B : (A *m B)^f = A^f *m B^f :> 'M_(m, p).\nProof.\nAdmitted.\n\nLemma map_delta_mx i j : (delta_mx i j)^f = delta_mx i j :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma map_diag_mx d : (diag_mx d)^f = diag_mx d^f :> 'M_n.\nProof.\nAdmitted.\n\nLemma map_scalar_mx a : a%:M^f = (f a)%:M :> 'M_n.\nProof.\nAdmitted.\n\nLemma map_mx1 : 1%:M^f = 1%:M :> 'M_n.\nProof.\nAdmitted.\n\nLemma map_perm_mx (s : 'S_n) : (perm_mx s)^f = perm_mx s.\nProof.\nAdmitted.\n\nLemma map_tperm_mx (i1 i2 : 'I_n) : (tperm_mx i1 i2)^f = tperm_mx i1 i2.\nProof.\nAdmitted.\n\nLemma map_pid_mx r : (pid_mx r)^f = pid_mx r :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma trace_map_mx (A : 'M_n) : \\tr A^f = f (\\tr A).\nProof.\nAdmitted.\n\nEnd FixedSize.\n\nLemma map_lin1_mx m n (g : 'rV_m -> 'rV_n) gf :\n (forall v, (g v)^f = gf v^f) -> (lin1_mx g)^f = lin1_mx gf.\nProof.\nAdmitted.\n\nLemma map_lin_mx m1 n1 m2 n2 (g : 'M_(m1, n1) -> 'M_(m2, n2)) gf :\n (forall A, (g A)^f = gf A^f) -> (lin_mx g)^f = lin_mx gf.\nProof.\nAdmitted.\n\nFact map_mx_is_monoid_morphism n : monoid_morphism (map_mx f : 'M_n -> 'M_n).\nProof.\nAdmitted.\n#[deprecated(since=\"mathcomp 2.5.0\", use=map_mx_is_monoid_morphism)]\nDefinition map_mx_is_multiplicative := map_mx_is_monoid_morphism.\nHB.instance Definition _ n :=\n GRing.isMonoidMorphism.Build 'M[aR]_n 'M[rR]_n (map_mx f)\n (map_mx_is_monoid_morphism n).\n\nEnd MapSemiRingMatrix.\n\nSection CommMx.\n\nContext {R : pzSemiRingType} {n : nat}.\nImplicit Types (f g p : 'M[R]_n) (fs : seq 'M[R]_n) (d : 'rV[R]_n) (I : Type).\n\nDefinition comm_mx f g : Prop := f *m g = g *m f.\nDefinition comm_mxb f g : bool := f *m g == g *m f.\n\nLemma comm_mx_sym f g : comm_mx f g -> comm_mx g f.\nProof.\nAdmitted.\n\nLemma comm_mx_refl f : comm_mx f f.\nProof.\nAdmitted.\n\nLemma comm_mx0 f : comm_mx f 0.\nProof.\nAdmitted.\nLemma comm0mx f : comm_mx 0 f.\nProof.\nAdmitted.\n\nLemma comm_mx1 f : comm_mx f 1%:M.\nProof.\nAdmitted.\n\nLemma comm1mx f : comm_mx 1%:M f.\nProof.\nAdmitted.\n\nHint Resolve comm_mx0 comm0mx comm_mx1 comm1mx : core.\n\nLemma comm_mxD f g g' : comm_mx f g -> comm_mx f g' -> comm_mx f (g + g').\nProof.\nAdmitted.\n\nLemma comm_mxM f g g' : comm_mx f g -> comm_mx f g' -> comm_mx f (g *m g').\nProof.\nAdmitted.\n\nLemma comm_mx_sum I (s : seq I) (P : pred I) (F : I -> 'M[R]_n) (f : 'M[R]_n) :\n (forall i : I, P i -> comm_mx f (F i)) -> comm_mx f (\\sum_(i <- s | P i) F i).\nProof.\nAdmitted.\n\nLemma comm_mxP f g : reflect (comm_mx f g) (comm_mxb f g).\nProof.\nAdmitted.\n\nNotation all_comm_mx fs := (all2rel comm_mxb fs).\n\nLemma all_comm_mxP fs :\n reflect {in fs &, forall f g, f *m g = g *m f} (all_comm_mx fs).\nProof.\nAdmitted.\n\nLemma all_comm_mx1 f : all_comm_mx [:: f].\nProof.\nAdmitted.\n\nLemma all_comm_mx2P f g : reflect (f *m g = g *m f) (all_comm_mx [:: f; g]).\nProof.\nAdmitted.\n\nLemma all_comm_mx_cons f fs :\n all_comm_mx (f :: fs) = all (comm_mxb f) fs && all_comm_mx fs.\nProof.\nAdmitted.\n\nLemma comm_mxE : comm_mx = @GRing.\nProof.\nAdmitted.\n\nEnd CommMx.\nNotation all_comm_mx := (allrel comm_mxb).\n\nSection ComMatrix.\n\nVariable R : comPzSemiRingType.\n\nSection AssocLeft.\n\nVariables m n p : nat.\nImplicit Type A : 'M[R]_(m, n).\nImplicit Type B : 'M[R]_(n, p).\n\nLemma trmx_mul A B : (A *m B)^T = B^T *m A^T.\nProof.\nAdmitted.\n\nLemma scalemxAr a A B : a *: (A *m B) = A *m (a *: B).\nProof.\nAdmitted.\n\nFact mulmx_is_scalable A : scalable (@mulmx _ m n p A).\nProof.\nAdmitted.\nHB.instance Definition _ A :=\n GRing.isScalable.Build R 'M[R]_(n, p) 'M[R]_(m, p) *:%R (mulmx A)\n (mulmx_is_scalable A).\n\nDefinition lin_mulmx A : 'M[R]_(n * p, m * p) := lin_mx (mulmx A).\n\nFact lin_mulmx_is_semilinear : semilinear lin_mulmx.\nProof.\nAdmitted.\nHB.instance Definition _ :=\n GRing.isSemilinear.Build R 'M[R]_(m, n) 'M[R]_(n * p, m * p) _ lin_mulmx\n lin_mulmx_is_semilinear.\n\nEnd AssocLeft.\n\nSection LinMulRow.\n\nVariables m n : nat.\n\nDefinition lin_mul_row u : 'M[R]_(m * n, n) := lin1_mx (mulmx u \\o vec_mx).\n\nFact lin_mul_row_is_semilinear : semilinear lin_mul_row.\nProof.\nAdmitted.\nHB.instance Definition _ := GRing.isSemilinear.Build R _ _ _ lin_mul_row\n lin_mul_row_is_semilinear.\n\nLemma mul_vec_lin_row A u : mxvec A *m lin_mul_row u = u *m A.\nProof.\nAdmitted.\n\nEnd LinMulRow.\n\nLemma diag_mxC n (d e : 'rV[R]_n) :\n diag_mx d *m diag_mx e = diag_mx e *m diag_mx d.\nProof.\nAdmitted.\n\nLemma diag_mx_comm n (d e : 'rV[R]_n) : comm_mx (diag_mx d) (diag_mx e).\nProof.\nAdmitted.\n\nLemma scalar_mxC m n a (A : 'M[R]_(m, n)) : A *m a%:M = a%:M *m A.\nProof.\nAdmitted.\n\nLemma comm_mx_scalar n a (A : 'M[R]_n) : comm_mx A a%:M.\nProof.\nAdmitted.\n\nLemma comm_scalar_mx n a (A : 'M[R]_n) : comm_mx a%:M A.\nProof.\nAdmitted.\n\nLemma mxtrace_mulC m n (A : 'M[R]_(m, n)) B : \\tr (A *m B) = \\tr (B *m A).\nProof.\nAdmitted.\n\nLemma mxvec_dotmul m n (A : 'M[R]_(m, n)) u v :\n mxvec (u^T *m v) *m (mxvec A)^T = u *m A *m v^T.\nProof.\nAdmitted.\n\nLemma mul_mx_scalar m n a (A : 'M[R]_(m, n)) : A *m a%:M = a *: A.\nProof.\nAdmitted.\n\nEnd ComMatrix.\n\nHB.instance Definition _ (R : comPzSemiRingType) (n : nat) :=\n GRing.LSemiAlgebra_isSemiAlgebra.Build R 'M[R]_n (fun k => scalemxAr k).\n\nHB.instance Definition _ (R : comPzRingType) (n : nat) :=\n GRing.PzSemiAlgebra.on 'M[R]_n.\n\nHB.instance Definition _ (R : comNzSemiRingType) (n' : nat) :=\n GRing.PzSemiAlgebra.on 'M[R]_n'.+1.\n\nHB.instance Definition _ (R : comNzRingType) (n' : nat) :=\n GRing.PzAlgebra.on 'M[R]_n'.+1.\n\nHB.instance Definition _ (R : finComNzRingType) (n' : nat) :=\n [Finite of 'M[R]_n'.+1 by <:].\n\nArguments lin_mulmx {R m n p} A.\nArguments lin_mul_row {R m n} u.\nArguments diag_mx_comm {R n}.\nArguments comm_mx_scalar {R n}.\nArguments comm_scalar_mx {R n}.\n\n#[global] Hint Resolve comm_mx_scalar comm_scalar_mx : core.\n\nSection MatrixAlgebra.\n\nVariable R : pzRingType.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=linearP)]\nFact diag_mx_is_linear n : linear (@diag_mx R n).\nProof.\nAdmitted.\n\nLemma mulmxN m n p (A : 'M[R]_(m, n)) (B : 'M_(n, p)) : A *m (- B) = - (A *m B).\nProof.\nAdmitted.\n\nLemma mulNmx m n p (A : 'M[R]_(m, n)) (B : 'M_(n, p)) : - A *m B = - (A *m B).\nProof.\nAdmitted.\n\nLemma mulmxBl m n p (A1 A2 : 'M[R]_(m, n)) (B : 'M_(n, p)) :\n (A1 - A2) *m B = A1 *m B - A2 *m B.\nProof.\nAdmitted.\n\nLemma mulmxBr m n p (A : 'M[R]_(m, n)) (B1 B2 : 'M_(n, p)) :\n A *m (B1 - B2) = A *m B1 - A *m B2.\nProof.\nAdmitted.\n\nDefinition copid_mx {n} r : 'M[R]_n := 1%:M - pid_mx r.\n\nLemma mul_copid_mx_pid m n r :\n r <= m -> copid_mx r *m pid_mx r = 0 :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma mul_pid_mx_copid m n r :\n r <= n -> pid_mx r *m copid_mx r = 0 :> 'M_(m, n).\nProof.\nAdmitted.\n\nLemma copid_mx_id n r : r <= n -> copid_mx r *m copid_mx r = copid_mx r :> 'M_n.\nProof.\nAdmitted.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=linearP)]\nFact mulmxr_is_linear m n p B : linear (@mulmxr R m n p B).\nProof.\nAdmitted.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=linearP)]\nFact lin_mulmxr_is_linear m n p : linear (@lin_mulmxr R m n p).\nProof.\nAdmitted.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=scalarP)]\nFact mxtrace_is_scalar n : scalar (@mxtrace R n).\nProof.\nAdmitted.\n\nDefinition determinant n (A : 'M_n) : R :=\n \\sum_(s : 'S_n) (-1) ^+ s * \\prod_i A i (s i).\n\nDefinition cofactor n A (i j : 'I_n) : R :=\n (-1) ^+ (i + j) * determinant (row' i (col' j A)).\n\nFact adjugate_key : unit.\nProof.\nAdmitted.\nDefinition adjugate n (A : 'M_n) := \\matrix[adjugate_key]_(i, j) cofactor A j i.\n\nEnd MatrixAlgebra.\n\nArguments copid_mx {R n}.\nPrenex Implicits determinant cofactor adjugate.\n\nNotation \"'\\det' A\" := (determinant A) : ring_scope.\nNotation \"'\\adj' A\" := (adjugate A) : ring_scope.\n\nSection MapRingMatrix.\n\nVariables (aR rR : pzRingType) (f : {rmorphism aR -> rR}).\nLocal Notation \"A ^f\" := (map_mx f A) : ring_scope.\n\nSection FixedSize.\n\nVariables m n p : nat.\nImplicit Type A : 'M[aR]_(m, n).\n\nLemma det_map_mx n' (A : 'M_n') : \\det A^f = f (\\det A).\nProof.\nAdmitted.\n\nLemma cofactor_map_mx (A : 'M_n) i j : cofactor A^f i j = f (cofactor A i j).\nProof.\nAdmitted.\n\nLemma map_mx_adj (A : 'M_n) : (\\adj A)^f = \\adj A^f.\nProof.\nAdmitted.\n\nEnd FixedSize.\n\nLemma map_copid_mx n r : (copid_mx r)^f = copid_mx r :> 'M_n.\nProof.\nAdmitted.\n\nEnd MapRingMatrix.\n\nSection CommMx.\n\nContext {R : pzRingType} {n : nat}.\nImplicit Types (f g p : 'M[R]_n) (fs : seq 'M[R]_n) (d : 'rV[R]_n) (I : Type).\n\nLemma comm_mxN f g : comm_mx f g -> comm_mx f (- g).\nProof.\nAdmitted.\n\nLemma comm_mxN1 f : comm_mx f (- 1%:M).\nProof.\nAdmitted.\n\nLemma comm_mxB f g g' : comm_mx f g -> comm_mx f g' -> comm_mx f (g - g').\nProof.\nAdmitted.\n\nEnd CommMx.\n\nSection ComMatrix.\nVariable R : comPzRingType.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=linearP)]\nFact lin_mulmx_is_linear m n p : linear (@lin_mulmx R m n p).\nProof.\nAdmitted.\n\n#[deprecated(since=\"mathcomp 2.5.0\", use=linearP)]\nFact lin_mul_row_is_linear m n : linear (@lin_mul_row R m n).\nProof.\nAdmitted.\n\nLemma determinant_multilinear n (A B C : 'M[R]_n) i0 b c :\n row i0 A = b *: row i0 B + c *: row i0 C ->\n row' i0 B = row' i0 A ->\n row' i0 C = row' i0 A ->\n \\det A = b * \\det B + c * \\det C.\nProof.\nAdmitted.\n\nLemma determinant_alternate n (A : 'M[R]_n) i1 i2 :\n i1 != i2 -> A i1 =1 A i2 -> \\det A = 0.\nProof.\nAdmitted.\n\nLemma det_tr n (A : 'M[R]_n) : \\det A^T = \\det A.\nProof.\nAdmitted.\n\nLemma det_perm n (s : 'S_n) : \\det (perm_mx s) = (-1) ^+ s :> R.\nProof.\nAdmitted.\n\nLemma det1 n : \\det (1%:M : 'M[R]_n) = 1.\nProof.\nAdmitted.\n\nLemma det_mx00 (A : 'M[R]_0) : \\det A = 1.\nProof.\nAdmitted.\n\nLemma detZ n a (A : 'M[R]_n) : \\det (a *: A) = a ^+ n * \\det A.\nProof.\nAdmitted.\n\nLemma det0 n' : \\det (0 : 'M[R]_n'.\nProof.\nAdmitted.\n\nLemma det_scalar n a : \\det (a%:M : 'M[R]_n) = a ^+ n.\nProof.\nAdmitted.\n\nLemma det_scalar1 a : \\det (a%:M : 'M[R]_1) = a.\nProof.\nAdmitted.\n\nLemma det_mx11 (M : 'M[R]_1) : \\det M = M 0 0.\nProof.\nAdmitted.\n\nLemma det_mulmx n (A B : 'M[R]_n) : \\det (A *m B) = \\det A * \\det B.\nProof.\nAdmitted.\n\nLemma detM n' (A B : 'M[R]_n'.\nProof.\nAdmitted.\n\nLemma expand_cofactor n (A : 'M[R]_n) i j :\n cofactor A i j =\n \\sum_(s : 'S_n | s i == j) (-1) ^+ s * \\prod_(k | i != k) A k (s k).\nProof.\nAdmitted.\n\nLemma expand_det_row n (A : 'M[R]_n) i0 :\n \\det A = \\sum_j A i0 j * cofactor A i0 j.\nProof.\nAdmitted.\n\nLemma cofactor_tr n (A : 'M[R]_n) i j : cofactor A^T i j = cofactor A j i.\nProof.\nAdmitted.\n\nLemma cofactorZ n a (A : 'M[R]_n) i j :\n cofactor (a *: A) i j = a ^+ n.\nProof.\nAdmitted.\n\nLemma expand_det_col n (A : 'M[R]_n) j0 :\n \\det A = \\sum_i (A i j0 * cofactor A i j0).\nProof.\nAdmitted.\n\nLemma trmx_adj n (A : 'M[R]_n) : (\\adj A)^T = \\adj A^T.\nProof.\nAdmitted.\n\nLemma adjZ n a (A : 'M[R]_n) : \\adj (a *: A) = a^+n.\nProof.\nAdmitted.\n\nLemma mul_mx_adj n (A : 'M[R]_n) : A *m \\adj A = (\\det A)%:M.\nProof.\nAdmitted.\n\nLemma mul_adj_mx n (A : 'M[R]_n) : \\adj A *m A = (\\det A)%:M.\nProof.\nAdmitted.\n\nLemma adj1 n : \\adj (1%:M) = 1%:M :> 'M[R]_n.\nProof.\nAdmitted.\n\nLemma mulmx1C n (A B : 'M[R]_n) : A *m B = 1%:M -> B *m A = 1%:M.\nProof.\nAdmitted.\n\nLemma det_ublock n1 n2 Aul (Aur : 'M[R]_(n1, n2)) Adr :\n \\det (block_mx Aul Aur 0 Adr) = \\det Aul * \\det Adr.\nProof.\nAdmitted.\n\nLemma det_lblock n1 n2 Aul (Adl : 'M[R]_(n2, n1)) Adr :\n \\det (block_mx Aul 0 Adl Adr) = \\det Aul * \\det Adr.\nProof.\nAdmitted.\n\nLemma det_trig n (A : 'M[R]_n) : is_trig_mx A -> \\det A = \\prod_(i < n) A i i.\nProof.\nAdmitted.\n\nLemma det_diag n (d : 'rV[R]_n) : \\det (diag_mx d) = \\prod_i d 0 i.\nProof.\nAdmitted.\n\nEnd ComMatrix.\n\nArguments lin_mul_row {R m n} u.\nArguments lin_mulmx {R m n p} A.\n\nLemma mulmx1_min (R : comNzRingType) m n (A : 'M[R]_(m, n)) B :\n A *m B = 1%:M -> m <= n.\nProof.\nAdmitted.\n\nSection MatrixInv.\n\nVariables R : comUnitRingType.\n\nSection Defs.\n\nVariable n : nat.\nImplicit Type A : 'M[R]_n.\n\nDefinition unitmx : pred 'M[R]_n := fun A => \\det A \\is a GRing.unit.\nDefinition invmx A := if A \\in unitmx then (\\det A)^-1 *: \\adj A else A.\n\nLemma unitmxE A : (A \\in unitmx) = (\\det A \\is a GRing.\nProof.\nAdmitted.\n\nLemma unitmx1 : 1%:M \\in unitmx.\nProof.\nAdmitted.\n\nLemma unitmx_perm s : perm_mx s \\in unitmx.\nProof.\nAdmitted.\n\nLemma unitmx_tr A : (A^T \\in unitmx) = (A \\in unitmx).\nProof.\nAdmitted.\n\nLemma unitmxZ a A : a \\is a GRing.\nProof.\nAdmitted.\n\nLemma invmx1 : invmx 1%:M = 1%:M.\nProof.\nAdmitted.\n\nLemma invmxZ a A : a *: A \\in unitmx -> invmx (a *: A) = a^-1 *: invmx A.\nProof.\nAdmitted.\n\nLemma invmx_scalar a : invmx a%:M = a^-1%:M.\nProof.\nAdmitted.\n\nLemma mulVmx : {in unitmx, left_inverse 1%:M invmx mulmx}.\nProof.\nAdmitted.\n\nLemma mulmxV : {in unitmx, right_inverse 1%:M invmx mulmx}.\nProof.\nAdmitted.\n\nLemma mulKmx m : {in unitmx, @left_loop _ 'M_(n, m) invmx mulmx}.\nProof.\nAdmitted.\n\nLemma mulKVmx m : {in unitmx, @rev_left_loop _ 'M_(n, m) invmx mulmx}.\nProof.\nAdmitted.\n\nLemma mulmxK m : {in unitmx, @right_loop 'M_(m, n) _ invmx mulmx}.\nProof.\nAdmitted.\n\nLemma mulmxKV m : {in unitmx, @rev_right_loop 'M_(m, n) _ invmx mulmx}.\nProof.\nAdmitted.\n\nLemma det_inv A : \\det (invmx A) = (\\det A)^-1.\nProof.\nAdmitted.\n\nLemma unitmx_inv A : (invmx A \\in unitmx) = (A \\in unitmx).\nProof.\nAdmitted.\n\nLemma unitmx_mul A B : (A *m B \\in unitmx) = (A \\in unitmx) && (B \\in unitmx).\nProof.\nAdmitted.\n\nLemma trmx_inv (A : 'M_n) : (invmx A)^T = invmx (A^T).\nProof.\nAdmitted.\n\nLemma invmxK : involutive invmx.\nProof.\nAdmitted.\n\nLemma mulmx1_unit A B : A *m B = 1%:M -> A \\in unitmx /\\ B \\in unitmx.\nProof.\nAdmitted.\n\nLemma intro_unitmx A B : B *m A = 1%:M /\\ A *m B = 1%:M -> unitmx A.\nProof.\nAdmitted.\n\nLemma invmx_out : {in [predC unitmx], invmx =1 id}.\nProof.\nAdmitted.\n\nEnd Defs.\n\nVariable n' : nat.\nLocal Notation n := n'.+1.\n\nHB.instance Definition _ := GRing.NzRing_hasMulInverse.Build 'M[R]_n\n (@mulVmx n) (@mulmxV n) (@intro_unitmx n) (@invmx_out n).\n\nLemma detV (A : 'M_n) : \\det A^-1 = (\\det A)^-1.\nProof.\nAdmitted.\n\nLemma unitr_trmx (A : 'M_n) : (A^T \\is a GRing.\nProof.\nAdmitted.\n\nLemma trmxV (A : 'M_n) : A^-1^T = (A^T)^-1.\nProof.\nAdmitted.\n\nLemma perm_mxV (s : 'S_n) : perm_mx s^-1 = (perm_mx s)^-1.\nProof.\nAdmitted.\n\nLemma is_perm_mxV (A : 'M_n) : is_perm_mx A^-1 = is_perm_mx A.\nProof.\nAdmitted.\n\nEnd MatrixInv.\n\nPrenex Implicits unitmx invmx invmxK.\n\nLemma block_diag_mx_unit (R : comUnitRingType) n1 n2\n (Aul : 'M[R]_n1) (Adr : 'M[R]_n2) :\n (block_mx Aul 0 0 Adr \\in unitmx) = (Aul \\in unitmx) && (Adr \\in unitmx).\nProof.\nAdmitted.\n\nLemma invmx_block_diag (R : comUnitRingType) n1 n2\n (Aul : 'M[R]_n1) (Adr : 'M[R]_n2) :\n block_mx Aul 0 0 Adr \\in unitmx ->\n invmx (block_mx Aul 0 0 Adr) = block_mx (invmx Aul) 0 0 (invmx Adr).\nProof.\nAdmitted.\n\nHB.instance Definition _ (R : countComUnitRingType) (n' : nat) :=\n [Countable of 'M[R]_n'.+1 by <:].\n\nHB.instance Definition _ (n : nat) (R : finComUnitRingType) :=\n [Finite of 'M[R]_n.+1 by <:].\n\nSection FinUnitMatrix.\n\nVariable n : nat.\n\nDefinition GLtype (R : finComUnitRingType) := {unit 'M[R]_n.-1.+1}.\n\nCoercion GLval R (u : GLtype R) : 'M[R]_n.-1.+1 :=\n let: FinRing.Unit A _ := u in A.\n\nEnd FinUnitMatrix.\n\nBind Scope group_scope with GLtype.\nArguments GLtype n%_N R%_type.\nArguments GLval {n%_N R} u%_g.\n\nNotation \"{ ''GL_' n [ R ] }\" := (GLtype n R) : type_scope.\n\nNotation \"{ ''GL_' n ( p ) }\" := {'GL_n['F_p]} : type_scope.\n\nHB.instance Definition _ (n : nat) (R : finComUnitRingType) :=\n [isSub of {'GL_n[R]} for GLval].\n\nSection GL_unit.\n\nVariables (n : nat) (R : finComUnitRingType).\n\nHB.instance Definition _ := [Finite of {'GL_n[R]} by <:].\nHB.instance Definition _ := FinGroup.on {'GL_n[R]}.\n\nDefinition GLgroup := [set: {'GL_n[R]}].\nCanonical GLgroup_group := Eval hnf in [group of GLgroup].\n\nImplicit Types u v : {'GL_n[R]}.\n\nLemma GL_1E : GLval 1 = 1.\nProof.\nAdmitted.\nLemma GL_VE u : GLval u^-1 = (GLval u)^-1.\nProof.\nAdmitted.\nLemma GL_VxE u : GLval u^-1 = invmx u.\nProof.\nAdmitted.\nLemma GL_ME u v : GLval (u * v) = GLval u * GLval v.\nProof.\nAdmitted.\nLemma GL_MxE u v : GLval (u * v) = u *m v.\nProof.\nAdmitted.\nLemma GL_unit u : GLval u \\is a GRing.\nProof.\nAdmitted.\nLemma GL_unitmx u : val u \\in unitmx.\nProof.\nAdmitted.\n\nLemma GL_det u : \\det u != 0.\nProof.\nAdmitted.\n\nEnd GL_unit.\n\nArguments GLgroup n%_N R%_type.\nArguments GLgroup_group n%_N R%_type.\n\nNotation \"''GL_' n [ R ]\" := (GLgroup n R)\n (n at level 2, format \"''GL_' n [ R ]\") : group_scope.\nNotation \"''GL_' n ( p )\" := 'GL_n['F_p]\n (p at level 10, format \"''GL_' n ( p )\") : group_scope.\nNotation \"''GL_' n [ R ]\" := (GLgroup_group n R) : Group_scope.\nNotation \"''GL_' n ( p )\" := (GLgroup_group n 'F_p) : Group_scope.\n\nSection MatrixDomain.\n\nVariable R : idomainType.\n\nLemma scalemx_eq0 m n a (A : 'M[R]_(m, n)) :\n (a *: A == 0) = (a == 0) || (A == 0).\nProof.\nAdmitted.\n\nLemma scalemx_inj m n a :\n a != 0 -> injective ( *:%R a : 'M[R]_(m, n) -> 'M[R]_(m, n)).\nProof.\nAdmitted.\n\nLemma det0P n (A : 'M[R]_n) :\n reflect (exists2 v : 'rV[R]_n, v != 0 & v *m A = 0) (\\det A == 0).\nProof.\nAdmitted.\n\nEnd MatrixDomain.\n\nArguments det0P {R n A}.\n\nSection MapFieldMatrix.\n\nVariables (aF : fieldType) (rF : comUnitRingType) (f : {rmorphism aF -> rF}).\nLocal Notation \"A ^f\" := (map_mx f A) : ring_scope.\n\nLemma map_mx_inj {m n} : injective (map_mx f : 'M_(m, n) -> 'M_(m, n)).\nProof.\nAdmitted.\n\nLemma map_mx_is_scalar n (A : 'M_n) : is_scalar_mx A^f = is_scalar_mx A.\nProof.\nAdmitted.\n\nLemma map_unitmx n (A : 'M_n) : (A^f \\in unitmx) = (A \\in unitmx).\nProof.\nAdmitted.\n\nLemma map_mx_unit n' (A : 'M_n'.\nProof.\nAdmitted.\n\nLemma map_invmx n (A : 'M_n) : (invmx A)^f = invmx A^f.\nProof.\nAdmitted.\n\nLemma map_mx_inv n' (A : 'M_n'.\nProof.\nAdmitted.\n\nLemma map_mx_eq0 m n (A : 'M_(m, n)) : (A^f == 0) = (A == 0).\nProof.\nAdmitted.\n\nEnd MapFieldMatrix.\n\nArguments map_mx_inj {aF rF f m n} [A1 A2] eqA12f : rename.\n\nSection CormenLUP.\n\nVariable F : fieldType.\n\nFixpoint cormen_lup {n} :=\n match n return let M := 'M[F]_n.+1 in M -> M * M * M with\n | 0 => fun A => (1, 1, A)\n | _.+1 => fun A =>\n let k := odflt 0 [pick k | A k 0 != 0] in\n let A1 : 'M_(1 + _) := xrow 0 k A in\n let P1 : 'M_(1 + _) := tperm_mx 0 k in\n let Schur := ((A k 0)^-1 *: dlsubmx A1) *m ursubmx A1 in\n let: (P2, L2, U2) := cormen_lup (drsubmx A1 - Schur) in\n let P := block_mx 1 0 0 P2 *m P1 in\n let L := block_mx 1 0 ((A k 0)^-1 *: (P2 *m dlsubmx A1)) L2 in\n let U := block_mx (ulsubmx A1) (ursubmx A1) 0 U2 in\n (P, L, U)\n end.\n\nLemma cormen_lup_perm n (A : 'M_n.\nProof.\nAdmitted.\n\nLemma cormen_lup_correct n (A : 'M_n.\nProof.\nAdmitted.\n\nLemma cormen_lup_detL n (A : 'M_n.\nProof.\nAdmitted.\n\nLemma cormen_lup_lower n A (i j : 'I_n.\nProof.\nAdmitted.\n\nLemma cormen_lup_upper n A (i j : 'I_n.\nProof.\nAdmitted.\n\nEnd CormenLUP.\n\nSection mxOver.\nSection mxOverType.\nContext {m n : nat} {T : Type}.\nImplicit Types (S : {pred T}).\n\nDefinition mxOver_pred (S : {pred T}) :=\n fun M : 'M[T]_(m, n) => [forall i, [forall j, M i j \\in S]].\nArguments mxOver_pred _ _ /.\nDefinition mxOver (S : {pred T}) := [qualify a M | mxOver_pred S M].\n\nLemma mxOverP {S : {pred T}} {M : 'M[T]__} :\n reflect (forall i j, M i j \\in S) (M \\is a mxOver S).\nProof.\nAdmitted.\n\nLemma mxOverS (S1 S2 : {pred T}) :\n {subset S1 <= S2} -> {subset mxOver S1 <= mxOver S2}.\nProof.\nAdmitted.\n\nLemma mxOver_const c S : c \\in S -> const_mx c \\is a mxOver S.\nProof.\nAdmitted.\n\nLemma mxOver_constE c S : (m > 0)%N -> (n > 0)%N ->\n (const_mx c \\is a mxOver S) = (c \\in S).\nProof.\nAdmitted.\n\nEnd mxOverType.\n\nLemma thinmxOver {n : nat} {T : Type} (M : 'M[T]_(n, 0)) S : M \\is a mxOver S.\nProof.\nAdmitted.\n\nLemma flatmxOver {n : nat} {T : Type} (M : 'M[T]_(0, n)) S : M \\is a mxOver S.\nProof.\nAdmitted.\n\nSection mxOverZmodule.\nContext {M : zmodType} {m n : nat}.\nImplicit Types (S : {pred M}).\n\nLemma mxOver0 S : 0 \\in S -> 0 \\is a @mxOver m n _ S.\nProof.\nAdmitted.\n\nSection mxOverAdd.\nVariable addS : addrClosed M.\nFact mxOver_add_subproof : addr_closed (@mxOver m n _ addS).\nProof.\nAdmitted.\nHB.instance Definition _ :=\n GRing.isAddClosed.Build 'M[M]_(m, n) (mxOver_pred addS)\n mxOver_add_subproof.\nEnd mxOverAdd.\n\nSection mxOverOpp.\nVariable oppS : opprClosed M.\nFact mxOver_opp_subproof : oppr_closed (@mxOver m n _ oppS).\nProof.\nAdmitted.\nHB.instance Definition _ :=\n GRing.isOppClosed.Build 'M[M]_(m, n) (mxOver_pred oppS)\n mxOver_opp_subproof.\nEnd mxOverOpp.\n\nHB.instance Definition _ (zmodS : zmodClosed M) :=\n GRing.OppClosed.on (mxOver_pred zmodS).\n\nEnd mxOverZmodule.\n\nSection mxOverRing.\nContext {R : pzSemiRingType} {m n : nat}.\n\nLemma mxOver_scalar S c : 0 \\in S -> c \\in S -> c%:M \\is a @mxOver n n R S.\nProof.\nAdmitted.\n\nLemma mxOver_scalarE S c : (n > 0)%N ->\n (c%:M \\is a @mxOver n n R S) = ((n > 1) ==> (0 \\in S)) && (c \\in S).\nProof.\nAdmitted.\n\nLemma mxOverZ (S : mulrClosed R) :\n {in S & mxOver S, forall a : R, forall v : 'M[R]_(m, n),\n a *: v \\is a mxOver S}.\nProof.\nAdmitted.\n\nLemma mxOver_diag (S : {pred R}) k (D : 'rV[R]_k) :\n 0 \\in S -> D \\is a mxOver S -> diag_mx D \\is a mxOver S.\nProof.\nAdmitted.\n\nLemma mxOver_diagE (S : {pred R}) k (D : 'rV[R]_k) : k > 0 ->\n (diag_mx D \\is a mxOver S) = ((k > 1) ==> (0 \\in S)) && (D \\is a mxOver S).\nProof.\nAdmitted.\n\nLemma mxOverM (S : semiringClosed R) p q r : {in mxOver S & mxOver S,\n forall u : 'M[R]_(p, q), forall v : 'M[R]_(q, r), u *m v \\is a mxOver S}.\nProof.\nAdmitted.\n\nEnd mxOverRing.\n\nSection mxRingOver.\nContext {R : pzSemiRingType} {n : nat} (S : semiringClosed R).\n\nFact mxOver_mul_subproof : mulr_closed (@mxOver n n _ S).\nProof.\nAdmitted.\nHB.instance Definition _ := GRing.isMulClosed.Build _ (mxOver_pred S)\n mxOver_mul_subproof.\n\nEnd mxRingOver.\n\nHB.instance Definition _ {R : pzRingType} {n : nat} (S : subringClosed R) :=\n GRing.MulClosed.on (@mxOver_pred n n _ S).\n\nEnd mxOver.\n\nSection BlockMatrix.\nImport tagnat.\nContext {T : Type} {p q : nat} {p_ : 'I_p -> nat} {q_ : 'I_q -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nNotation sq := (\\sum_i q_ i)%N.\nImplicit Type (s : 'I_sp) (t : 'I_sq).\n\nDefinition mxblock (B_ : forall i j, 'M[T]_(p_ i, q_ j)) :=\n \\matrix_(j, k) B_ (sig1 j) (sig1 k) (sig2 j) (sig2 k).\nLocal Notation \"\\mxblock_ ( i , j ) E\" := (mxblock (fun i j => E)) : ring_scope.\n\nDefinition mxrow m (B_ : forall j, 'M[T]_(m, q_ j)) :=\n \\matrix_(j, k) B_ (sig1 k) j (sig2 k).\nLocal Notation \"\\mxrow_ i E\" := (mxrow (fun i => E)) : ring_scope.\n\nDefinition mxcol n (B_ : forall i, 'M[T]_(p_ i, n)) :=\n \\matrix_(j, k) B_ (sig1 j) (sig2 j) k.\nLocal Notation \"\\mxcol_ i E\" := (mxcol (fun i => E)) : ring_scope.\n\nDefinition submxblock (A : 'M[T]_(sp, sq)) i j := mxsub (Rank i) (Rank j) A.\nDefinition submxrow m (A : 'M[T]_(m, sq)) j := colsub (Rank j) A.\nDefinition submxcol n (A : 'M[T]_(sp, n)) i := rowsub (Rank i) A.\n\nLemma mxblockEh B_ : \\mxblock_(i, j) B_ i j = \\mxrow_j \\mxcol_i B_ i j.\nProof.\nAdmitted.\n\nLemma mxblockEv B_ : \\mxblock_(i, j) B_ i j = \\mxcol_i \\mxrow_j B_ i j.\nProof.\nAdmitted.\n\nLemma submxblockEh A i j : submxblock A i j = submxcol (submxrow A j) i.\nProof.\nAdmitted.\n\nLemma submxblockEv A i j : submxblock A i j = submxrow (submxcol A i) j.\nProof.\nAdmitted.\n\nLemma mxblockK B_ i j : submxblock (\\mxblock_(i, j) B_ i j) i j = B_ i j.\nProof.\nAdmitted.\n\nLemma mxrowK m B_ j : @submxrow m (\\mxrow_j B_ j) j = B_ j.\nProof.\nAdmitted.\n\nLemma mxcolK n B_ i : @submxcol n (\\mxcol_i B_ i) i = B_ i.\nProof.\nAdmitted.\n\nLemma submxrow_matrix B_ j :\n submxrow (\\mxblock_(i, j) B_ i j) j = \\mxcol_i B_ i j.\nProof.\nAdmitted.\n\nLemma submxcol_matrix B_ i :\n submxcol (\\mxblock_(i, j) B_ i j) i = \\mxrow_j B_ i j.\nProof.\nAdmitted.\n\nLemma submxblockK A : \\mxblock_(i, j) (submxblock A i j) = A.\nProof.\nAdmitted.\n\nLemma submxrowK m (A : 'M[T]_(m, sq)) : \\mxrow_j (submxrow A j) = A.\nProof.\nAdmitted.\n\nLemma submxcolK n (A : 'M[T]_(sp, n)) : \\mxcol_i (submxcol A i) = A.\nProof.\nAdmitted.\n\nLemma mxblockP A B :\n (forall i j, submxblock A i j = submxblock B i j) <-> A = B.\nProof.\nAdmitted.\n\nLemma mxrowP m (A B : 'M_(m, sq)) :\n (forall j, submxrow A j = submxrow B j) <-> A = B.\nProof.\nAdmitted.\n\nLemma mxcolP n (A B : 'M_(sp, n)) :\n (forall i, submxcol A i = submxcol B i) <-> A = B.\nProof.\nAdmitted.\n\nLemma eq_mxblockP A_ B_ :\n (forall i j, A_ i j = B_ i j) <->\n (\\mxblock_(i, j) A_ i j = \\mxblock_(i, j) B_ i j).\nProof.\nAdmitted.\n\nLemma eq_mxblock A_ B_ :\n (forall i j, A_ i j = B_ i j) ->\n (\\mxblock_(i, j) A_ i j = \\mxblock_(i, j) B_ i j).\nProof.\nAdmitted.\n\nLemma eq_mxrowP m (A_ B_ : forall j, 'M[T]_(m, q_ j)) :\n (forall j, A_ j = B_ j) <-> (\\mxrow_j A_ j = \\mxrow_j B_ j).\nProof.\nAdmitted.\n\nLemma eq_mxrow m (A_ B_ : forall j, 'M[T]_(m, q_ j)) :\n (forall j, A_ j = B_ j) -> (\\mxrow_j A_ j = \\mxrow_j B_ j).\nProof.\nAdmitted.\n\nLemma eq_mxcolP n (A_ B_ : forall i, 'M[T]_(p_ i, n)) :\n (forall i, A_ i = B_ i) <-> (\\mxcol_i A_ i = \\mxcol_i B_ i).\nProof.\nAdmitted.\n\nLemma eq_mxcol n (A_ B_ : forall i, 'M[T]_(p_ i, n)) :\n (forall i, A_ i = B_ i) -> (\\mxcol_i A_ i = \\mxcol_i B_ i).\nProof.\nAdmitted.\n\nLemma row_mxrow m (B_ : forall j, 'M[T]_(m, q_ j)) i :\n row i (\\mxrow_j B_ j) = \\mxrow_j (row i (B_ j)).\nProof.\nAdmitted.\n\nLemma col_mxrow m (B_ : forall j, 'M[T]_(m, q_ j)) j :\n col j (\\mxrow_j B_ j) = col (sig2 j) (B_ (sig1 j)).\nProof.\nAdmitted.\n\nLemma row_mxcol n (B_ : forall i, 'M[T]_(p_ i, n)) i :\n row i (\\mxcol_i B_ i) = row (sig2 i) (B_ (sig1 i)).\nProof.\nAdmitted.\n\nLemma col_mxcol n (B_ : forall i, 'M[T]_(p_ i, n)) j :\n col j (\\mxcol_i B_ i) = \\mxcol_i (col j (B_ i)).\nProof.\nAdmitted.\n\nLemma row_mxblock B_ i :\n row i (\\mxblock_(i, j) B_ i j) = \\mxrow_j row (sig2 i) (B_ (sig1 i) j).\nProof.\nAdmitted.\n\nLemma col_mxblock B_ j :\n col j (\\mxblock_(i, j) B_ i j) = \\mxcol_i col (sig2 j) (B_ i (sig1 j)).\nProof.\nAdmitted.\n\nEnd BlockMatrix.\n\nNotation \"\\mxblock_ ( i < m , j < n ) E\" :=\n (mxblock (fun (i : 'I_m) (j : 'I_ n) => E)) (only parsing) : ring_scope.\nNotation \"\\mxblock_ ( i , j < n ) E\" :=\n (\\mxblock_(i < n, j < n) E) (only parsing) : ring_scope.\nNotation \"\\mxblock_ ( i , j ) E\" := (\\mxblock_(i < _, j < _) E) : ring_scope.\nNotation \"\\mxrow_ ( j < m ) E\" := (mxrow (fun (j : 'I_m) => E))\n (only parsing) : ring_scope.\nNotation \"\\mxrow_ j E\" := (\\mxrow_(j < _) E) : ring_scope.\nNotation \"\\mxcol_ ( i < m ) E\" := (mxcol (fun (i : 'I_m) => E))\n (only parsing) : ring_scope.\nNotation \"\\mxcol_ i E\" := (\\mxcol_(i < _) E) : ring_scope.\n\nLemma tr_mxblock {T : Type} {p q : nat} {p_ : 'I_p -> nat} {q_ : 'I_q -> nat}\n (B_ : forall i j, 'M[T]_(p_ i, q_ j)) :\n (\\mxblock_(i, j) B_ i j)^T = \\mxblock_(i, j) (B_ j i)^T.\nProof.\nAdmitted.\n\nSection SquareBlockMatrix.\n\nContext {T : Type} {p : nat} {p_ : 'I_p -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nImplicit Type (s : 'I_sp).\n\nLemma tr_mxrow n (B_ : forall j, 'M[T]_(n, p_ j)) :\n (\\mxrow_j B_ j)^T = \\mxcol_i (B_ i)^T.\nProof.\nAdmitted.\n\nLemma tr_mxcol n (B_ : forall i, 'M[T]_(p_ i, n)) :\n (\\mxcol_i B_ i)^T = \\mxrow_i (B_ i)^T.\nProof.\nAdmitted.\n\nLemma tr_submxblock (A : 'M[T]_sp) i j :\n (submxblock A i j)^T = (submxblock A^T j i).\nProof.\nAdmitted.\n\nLemma tr_submxrow n (A : 'M[T]_(n, sp)) j :\n (submxrow A j)^T = (submxcol A^T j).\nProof.\nAdmitted.\n\nLemma tr_submxcol n (A : 'M[T]_(sp, n)) i :\n (submxcol A i)^T = (submxrow A^T i).\nProof.\nAdmitted.\n\nEnd SquareBlockMatrix.\n\nSection BlockRowRecL.\nImport tagnat.\nContext {T : Type} {m : nat} {p_ : 'I_m.+1 -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\n\nLemma mxsize_recl : (p_ ord0 + \\sum_i p_ (lift ord0 i) = (\\sum_i p_ i))%N.\nProof.\nAdmitted.\n\nLemma mxrow_recl n (B_ : forall j, 'M[T]_(n, p_ j)) :\n \\mxrow_j B_ j = castmx (erefl, mxsize_recl)\n (row_mx (B_ 0) (\\mxrow_j B_ (lift ord0 j))).\nProof.\nAdmitted.\n\nEnd BlockRowRecL.\n\nLemma mxcol_recu {T : Type} {p : nat} {p_ : 'I_p.\nProof.\nAdmitted.\n\nSection BlockMatrixRec.\nLocal Notation e := (mxsize_recl, mxsize_recl).\nLocal Notation l0 := (lift ord0).\nContext {T : Type}.\n\nLemma mxblock_recu {p q : nat} {p_ : 'I_p.\nProof.\nAdmitted.\n\nLemma mxblock_recl {p q : nat} {p_ : 'I_p -> nat} {q_ : 'I_q.\nProof.\nAdmitted.\n\nLemma mxblock_recul {p q : nat} {p_ : 'I_p.\nProof.\nAdmitted.\n\nLemma mxrowEblock {q : nat} {q_ : 'I_q -> nat} m\n (R_ : forall j, 'M[T]_(m, q_ j)) :\n (\\mxrow_j R_ j) =\n castmx (big_ord1 _ (fun=> m), erefl) (\\mxblock_(i < 1, j < q) R_ j).\nProof.\nAdmitted.\n\nLemma mxcolEblock {p : nat} {p_ : 'I_p -> nat} n\n (C_ : forall i, 'M[T]_(p_ i, n)) :\n (\\mxcol_i C_ i) =\n castmx (erefl, big_ord1 _ (fun=> n)) (\\mxblock_(i < p, j < 1) C_ i).\nProof.\nAdmitted.\n\nLemma mxEmxrow m n (A : 'M[T]_(m, n)) :\n A = castmx (erefl, big_ord1 _ (fun=> n)) (\\mxrow__ A).\nProof.\nAdmitted.\n\nLemma mxEmxcol m n (A : 'M[T]_(m, n)) :\n A = castmx (big_ord1 _ (fun=> m), erefl) (\\mxcol__ A).\nProof.\nAdmitted.\n\nLemma mxEmxblock m n (A : 'M[T]_(m, n)) :\n A = castmx (big_ord1 _ (fun=> m), big_ord1 _ (fun=> n))\n (\\mxblock_(i < 1, j < 1) A).\nProof.\nAdmitted.\n\nEnd BlockMatrixRec.\n\nSection BlockRowNmod.\nContext {V : nmodType} {q : nat} {q_ : 'I_q -> nat}.\nNotation sq := (\\sum_i q_ i)%N.\nImplicit Type (s : 'I_sq).\n\nLemma mxrowD m (R_ R'_ : forall j, 'M[V]_(m, q_ j)) :\n \\mxrow_j (R_ j + R'_ j) = \\mxrow_j (R_ j) + \\mxrow_j (R'_ j).\nProof.\nAdmitted.\n\nLemma mxrow0 m : \\mxrow_j (0 : 'M[V]_(m, q_ j)) = 0.\nProof.\nAdmitted.\n\nLemma mxrow_const m a : \\mxrow_j (const_mx a : 'M[V]_(m, q_ j)) = const_mx a.\nProof.\nAdmitted.\n\nLemma mxrow_sum (J : finType) m\n (R_ : forall i j, 'M[V]_(m, q_ j)) (P : {pred J}) :\n \\mxrow_j (\\sum_(i | P i) R_ i j) = \\sum_(i | P i) \\mxrow_j (R_ i j).\nProof.\nAdmitted.\n\nLemma submxrowD m (B B' : 'M[V]_(m, sq)) j :\n submxrow (B + B') j = submxrow B j + submxrow B' j.\nProof.\nAdmitted.\n\nLemma submxrow0 m j : submxrow (0 : 'M[V]_(m, sq)) j = 0.\nProof.\nAdmitted.\n\nLemma submxrow_sum (J : finType) m\n (R_ : forall i, 'M[V]_(m, sq)) (P : {pred J}) j:\n submxrow (\\sum_(i | P i) R_ i) j = \\sum_(i | P i) submxrow (R_ i) j.\nProof.\nAdmitted.\n\nEnd BlockRowNmod.\n\nSection BlockRowZmod.\nContext {V : zmodType} {q : nat} {q_ : 'I_q -> nat}.\nNotation sq := (\\sum_i q_ i)%N.\nImplicit Type (s : 'I_sq).\n\nLemma mxrowN m (R_ : forall j, 'M[V]_(m, q_ j)) :\n \\mxrow_j (- R_ j) = - \\mxrow_j (R_ j).\nProof.\nAdmitted.\n\nLemma mxrowB m (R_ R'_ : forall j, 'M[V]_(m, q_ j)) :\n \\mxrow_j (R_ j - R'_ j) = \\mxrow_j (R_ j) - \\mxrow_j (R'_ j).\nProof.\nAdmitted.\n\nLemma submxrowN m (B : 'M[V]_(m, sq)) j :\n submxrow (- B) j = - submxrow B j.\nProof.\nAdmitted.\n\nLemma submxrowB m (B B' : 'M[V]_(m, sq)) j :\n submxrow (B - B') j = submxrow B j - submxrow B' j.\nProof.\nAdmitted.\n\nEnd BlockRowZmod.\n\nSection BlockRowSemiRing.\nContext {R : pzSemiRingType} {n : nat} {q_ : 'I_n -> nat}.\nNotation sq := (\\sum_i q_ i)%N.\nImplicit Type (s : 'I_sq).\n\nLemma mul_mxrow m n' (A : 'M[R]_(m, n')) (R_ : forall j, 'M[R]_(n', q_ j)) :\n A *m \\mxrow_j R_ j= \\mxrow_j (A *m R_ j).\nProof.\nAdmitted.\n\nLemma mul_submxrow m n' (A : 'M[R]_(m, n')) (B : 'M[R]_(n', sq)) j :\n A *m submxrow B j= submxrow (A *m B) j.\nProof.\nAdmitted.\n\nEnd BlockRowSemiRing.\n\nSection BlockColNmod.\nContext {V : nmodType} {n : nat} {p_ : 'I_n -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nImplicit Type (s : 'I_sp).\n\nLemma mxcolD m (C_ C'_ : forall i, 'M[V]_(p_ i, m)) :\n \\mxcol_i (C_ i + C'_ i) = \\mxcol_i (C_ i) + \\mxcol_i (C'_ i).\nProof.\nAdmitted.\n\nLemma mxcol0 m : \\mxcol_i (0 : 'M[V]_(p_ i, m)) = 0.\nProof.\nAdmitted.\n\nLemma mxcol_const m a : \\mxcol_j (const_mx a : 'M[V]_(p_ j, m)) = const_mx a.\nProof.\nAdmitted.\n\nLemma mxcol_sum\n (I : finType) m (C_ : forall j i, 'M[V]_(p_ i, m)) (P : {pred I}):\n \\mxcol_i (\\sum_(j | P j) C_ j i) = \\sum_(j | P j) \\mxcol_i (C_ j i).\nProof.\nAdmitted.\n\nLemma submxcolD m (B B' : 'M[V]_(sp, m)) i :\n submxcol (B + B') i = submxcol B i + submxcol B' i.\nProof.\nAdmitted.\n\nLemma submxcol0 m i : submxcol (0 : 'M[V]_(sp, m)) i = 0.\nProof.\nAdmitted.\n\nLemma submxcol_sum (I : finType) m\n (C_ : forall j, 'M[V]_(sp, m)) (P : {pred I}) i :\n submxcol (\\sum_(j | P j) C_ j) i = \\sum_(j | P j) submxcol (C_ j) i.\nProof.\nAdmitted.\n\nEnd BlockColNmod.\n\nSection BlockColZmod.\nContext {V : zmodType} {n : nat} {p_ : 'I_n -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nImplicit Type (s : 'I_sp).\n\nLemma mxcolN m (C_ : forall i, 'M[V]_(p_ i, m)) :\n \\mxcol_i (- C_ i) = - \\mxcol_i (C_ i).\nProof.\nAdmitted.\n\nLemma mxcolB m (C_ C'_ : forall i, 'M[V]_(p_ i, m)) :\n \\mxcol_i (C_ i - C'_ i) = \\mxcol_i (C_ i) - \\mxcol_i (C'_ i).\nProof.\nAdmitted.\n\nLemma submxcolN m (B : 'M[V]_(sp, m)) i :\n submxcol (- B) i = - submxcol B i.\nProof.\nAdmitted.\n\nLemma submxcolB m (B B' : 'M[V]_(sp, m)) i :\n submxcol (B - B') i = submxcol B i - submxcol B' i.\nProof.\nAdmitted.\n\nEnd BlockColZmod.\n\nSection BlockColSemiRing.\nContext {R : pzSemiRingType} {n : nat} {p_ : 'I_n -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nImplicit Type (s : 'I_sp).\n\nLemma mxcol_mul n' m (C_ : forall i, 'M[R]_(p_ i, n')) (A : 'M[R]_(n', m)) :\n \\mxcol_i C_ i *m A = \\mxcol_i (C_ i *m A).\nProof.\nAdmitted.\n\nLemma submxcol_mul n' m (B : 'M[R]_(sp, n')) (A : 'M[R]_(n', m)) i :\n submxcol B i *m A = submxcol (B *m A) i.\nProof.\nAdmitted.\n\nEnd BlockColSemiRing.\n\nSection BlockMatrixNmod.\nContext {V : nmodType} {m n : nat}.\nContext {p_ : 'I_m -> nat} {q_ : 'I_n -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nNotation sq := (\\sum_i q_ i)%N.\n\nLemma mxblockD (B_ B'_ : forall i j, 'M[V]_(p_ i, q_ j)) :\n \\mxblock_(i, j) (B_ i j + B'_ i j) =\n \\mxblock_(i, j) (B_ i j) + \\mxblock_(i, j) (B'_ i j).\nProof.\nAdmitted.\n\nLemma mxblock0 : \\mxblock_(i, j) (0 : 'M[V]_(p_ i, q_ j)) = 0.\nProof.\nAdmitted.\n\nLemma mxblock_const a :\n \\mxblock_(i, j) (const_mx a : 'M[V]_(p_ i, q_ j)) = const_mx a.\nProof.\nAdmitted.\n\nLemma mxblock_sum (I : finType)\n (B_ : forall k i j, 'M[V]_(p_ i, q_ j)) (P : {pred I}):\n \\mxblock_(i, j) (\\sum_(k | P k) B_ k i j) =\n \\sum_(k | P k) \\mxblock_(i, j) (B_ k i j).\nProof.\nAdmitted.\n\nLemma submxblockD (B B' : 'M[V]_(sp, sq)) i j :\n submxblock (B + B') i j = submxblock B i j + submxblock B' i j.\nProof.\nAdmitted.\n\nLemma submxblock0 i j : submxblock (0 : 'M[V]_(sp, sq)) i j = 0.\nProof.\nAdmitted.\n\nLemma submxblock_sum (I : finType)\n (B_ : forall k, 'M[V]_(sp, sq)) (P : {pred I}) i j :\n submxblock (\\sum_(k | P k) B_ k) i j = \\sum_(k | P k) submxblock (B_ k) i j.\nProof.\nAdmitted.\n\nEnd BlockMatrixNmod.\n\nSection BlockMatrixZmod.\nContext {V : zmodType} {m n : nat}.\nContext {p_ : 'I_m -> nat} {q_ : 'I_n -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nNotation sq := (\\sum_i q_ i)%N.\n\nLemma mxblockN (B_ : forall i j, 'M[V]_(p_ i, q_ j)) :\n \\mxblock_(i, j) (- B_ i j) = - \\mxblock_(i, j) (B_ i j).\nProof.\nAdmitted.\n\nLemma mxblockB (B_ B'_ : forall i j, 'M[V]_(p_ i, q_ j)) :\n \\mxblock_(i, j) (B_ i j - B'_ i j) =\n \\mxblock_(i, j) (B_ i j) - \\mxblock_(i, j) (B'_ i j).\nProof.\nAdmitted.\n\nLemma submxblockN (B : 'M[V]_(sp, sq)) i j :\n submxblock (- B) i j = - submxblock B i j.\nProof.\nAdmitted.\n\nLemma submxblockB (B B' : 'M[V]_(sp, sq)) i j :\n submxblock (B - B') i j = submxblock B i j - submxblock B' i j.\nProof.\nAdmitted.\n\nEnd BlockMatrixZmod.\n\nSection BlockMatrixSemiRing.\nContext {R : pzSemiRingType} {p q : nat} {p_ : 'I_p -> nat} {q_ : 'I_q -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nNotation sq := (\\sum_i q_ i)%N.\n\nLemma mul_mxrow_mxcol m n\n (R_ : forall j, 'M[R]_(m, p_ j)) (C_ : forall i, 'M[R]_(p_ i, n)) :\n \\mxrow_j R_ j *m \\mxcol_i C_ i = \\sum_i (R_ i *m C_ i).\nProof.\nAdmitted.\n\nLemma mul_mxcol_mxrow m\n (C_ : forall i, 'M[R]_(p_ i, m)) (R_ : forall j, 'M[R]_(m, q_ j)) :\n \\mxcol_i C_ i*m \\mxrow_j R_ j = \\mxblock_(i, j) (C_ i *m R_ j).\nProof.\nAdmitted.\n\nLemma mul_mxrow_mxblock m\n (R_ : forall i, 'M[R]_(m, p_ i)) (B_ : forall i j, 'M[R]_(p_ i, q_ j)) :\n \\mxrow_i R_ i *m \\mxblock_(i, j) B_ i j = \\mxrow_j (\\sum_i (R_ i *m B_ i j)).\nProof.\nAdmitted.\n\nLemma mul_mxblock_mxrow m\n (B_ : forall i j, 'M[R]_(q_ i, p_ j)) (C_ : forall i, 'M[R]_(p_ i, m)) :\n \\mxblock_(i, j) B_ i j *m \\mxcol_j C_ j = \\mxcol_i (\\sum_j (B_ i j *m C_ j)).\nProof.\nAdmitted.\n\nEnd BlockMatrixSemiRing.\n\nLemma mul_mxblock {R : pzSemiRingType} {p q r : nat}\n {p_ : 'I_p -> nat} {q_ : 'I_q -> nat} {r_ : 'I_r -> nat}\n (A_ : forall i j, 'M[R]_(p_ i, q_ j)) (B_ : forall j k, 'M_(q_ j, r_ k)) :\n \\mxblock_(i, j) A_ i j *m \\mxblock_(j, k) B_ j k =\n \\mxblock_(i, k) \\sum_j (A_ i j *m B_ j k).\nProof.\nAdmitted.\n\nSection SquareBlockMatrixNmod.\nImport Order.TTheory tagnat.\nContext {V : nmodType} {p : nat} {p_ : 'I_p -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nImplicit Type (s : 'I_sp).\n\nLemma is_trig_mxblockP (B_ : forall i j, 'M[V]_(p_ i, p_ j)) :\n reflect [/\\ forall (i j : 'I_p), (i < j)%N -> B_ i j = 0 &\n forall i, is_trig_mx (B_ i i)]\n (is_trig_mx (\\mxblock_(i, j) B_ i j)).\nProof.\nAdmitted.\n\nLemma is_trig_mxblock (B_ : forall i j, 'M[V]_(p_ i, p_ j)) :\n is_trig_mx (\\mxblock_(i, j) B_ i j) =\n ([forall i : 'I_p, forall j : 'I_p, (i < j)%N ==> (B_ i j == 0)] &&\n [forall i, is_trig_mx (B_ i i)]).\nProof.\nAdmitted.\n\nLemma is_diag_mxblockP (B_ : forall i j, 'M[V]_(p_ i, p_ j)) :\n reflect [/\\ forall (i j : 'I_p), i != j -> B_ i j = 0 &\n forall i, is_diag_mx (B_ i i)]\n (is_diag_mx (\\mxblock_(i, j) B_ i j)).\nProof.\nAdmitted.\n\nLemma is_diag_mxblock (B_ : forall i j, 'M[V]_(p_ i, p_ j)) :\n is_diag_mx (\\mxblock_(i, j) B_ i j) =\n ([forall i : 'I_p, forall j : 'I_p, (i != j) ==> (B_ i j == 0)] &&\n [forall i, is_diag_mx (B_ i i)]).\nProof.\nAdmitted.\n\nDefinition mxdiag (B_ : forall i, 'M[V]_(p_ i)) : 'M[V]_(\\sum_i p_ i) :=\n \\mxblock_(j, k) if j == k then conform_mx 0 (B_ j) else 0.\nLocal Notation \"\\mxdiag_ i E\" := (mxdiag (fun i => E)) : ring_scope.\n\nLemma submxblock_diag (B_ : forall i, 'M[V]_(p_ i)) i :\n submxblock (\\mxdiag_i B_ i) i i = B_ i.\nProof.\nAdmitted.\n\nLemma eq_mxdiagP (B_ B'_ : forall i, 'M[V]_(p_ i)) :\n (forall i, B_ i = B'_ i) <-> (\\mxdiag_i B_ i = \\mxdiag_i B'_ i).\nProof.\nAdmitted.\n\nLemma eq_mxdiag (B_ B'_ : forall i, 'M[V]_(p_ i)) :\n (forall i, B_ i = B'_ i) -> (\\mxdiag_i B_ i = \\mxdiag_i B'_ i).\nProof.\nAdmitted.\n\nLemma mxdiagD (B_ B'_ : forall i, 'M[V]_(p_ i)) :\n \\mxdiag_i (B_ i + B'_ i) = \\mxdiag_i (B_ i) + \\mxdiag_i (B'_ i).\nProof.\nAdmitted.\n\nLemma mxdiag_sum (I : finType) (B_ : forall k i, 'M[V]_(p_ i)) (P : {pred I}) :\n \\mxdiag_i (\\sum_(k | P k) B_ k i) = \\sum_(k | P k) \\mxdiag_i (B_ k i).\nProof.\nAdmitted.\n\nLemma tr_mxdiag (B_ : forall i, 'M[V]_(p_ i)) :\n (\\mxdiag_i B_ i)^T = \\mxdiag_i (B_ i)^T.\nProof.\nAdmitted.\n\nLemma row_mxdiag (B_ : forall i, 'M[V]_(p_ i)) k :\n let B'_ i := if sig1 k == i then conform_mx 0 (B_ i) else 0 in\n row k (\\mxdiag_ i B_ i) = row (sig2 k) (\\mxrow_i B'_ i).\nProof.\nAdmitted.\n\nLemma col_mxdiag (B_ : forall i, 'M[V]_(p_ i)) k :\n let B'_ i := if sig1 k == i then conform_mx 0 (B_ i) else 0 in\n col k (\\mxdiag_ i B_ i) = col (sig2 k) (\\mxcol_i B'_ i).\nProof.\nAdmitted.\n\nEnd SquareBlockMatrixNmod.\n\nNotation \"\\mxdiag_ ( i < n ) E\" := (mxdiag (fun i : 'I_n => E))\n (only parsing) : ring_scope.\nNotation \"\\mxdiag_ i E\" := (\\mxdiag_(i < _) E) : ring_scope.\n\nSection SquareBlockMatrixZmod.\nImport Order.TTheory tagnat.\nContext {V : zmodType} {p : nat} {p_ : 'I_p -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nImplicit Type (s : 'I_sp).\n\nLemma mxdiagN (B_ : forall i, 'M[V]_(p_ i)) :\n \\mxdiag_i (- B_ i) = - \\mxdiag_i (B_ i).\nProof.\nAdmitted.\n\nLemma mxdiagB (B_ B'_ : forall i, 'M[V]_(p_ i)) :\n \\mxdiag_i (B_ i - B'_ i) = \\mxdiag_i (B_ i) - \\mxdiag_i (B'_ i).\nProof.\nAdmitted.\n\nLemma mxdiag0 : \\mxdiag_i (0 : 'M[V]_(p_ i)) = 0.\nProof.\nAdmitted.\n\nEnd SquareBlockMatrixZmod.\n\nLemma mxdiag_recl {V : nmodType} {m : nat} {p_ : 'I_m.\nProof.\nAdmitted.\n\nSection SquareBlockMatrixSemiRing.\nImport tagnat.\nContext {R : pzSemiRingType} {p : nat} {p_ : 'I_p -> nat}.\nNotation sp := (\\sum_i p_ i)%N.\nImplicit Type (s : 'I_sp).\n\nLemma mxtrace_mxblock (B_ : forall i j, 'M[R]_(p_ i, p_ j)) :\n \\tr (\\mxblock_(i, j) B_ i j) = \\sum_i \\tr (B_ i i).\nProof.\nAdmitted.\n\nLemma mxdiagZ a : \\mxdiag_i (a%:M : 'M[R]_(p_ i)) = a%:M.\nProof.\nAdmitted.\n\nLemma diag_mxrow (B_ : forall j, 'rV[R]_(p_ j)) :\n diag_mx (\\mxrow_j B_ j) = \\mxdiag_j (diag_mx (B_ j)).\nProof.\nAdmitted.\n\nLemma mxtrace_mxdiag (B_ : forall i, 'M[R]_(p_ i)) :\n \\tr (\\mxdiag_i B_ i) = \\sum_i \\tr (B_ i).\nProof.\nAdmitted.\n\nLemma mul_mxdiag_mxcol m\n (D_ : forall i, 'M[R]_(p_ i)) (C_ : forall i, 'M[R]_(p_ i, m)):\n \\mxdiag_i D_ i *m \\mxcol_i C_ i = \\mxcol_i (D_ i *m C_ i).\nProof.\nAdmitted.\n\nEnd SquareBlockMatrixSemiRing.\n\nLemma mul_mxrow_mxdiag {R : pzSemiRingType} {p : nat} {p_ : 'I_p -> nat} m\n (R_ : forall i, 'M[R]_(m, p_ i)) (D_ : forall i, 'M[R]_(p_ i)) :\n \\mxrow_i R_ i *m \\mxdiag_i D_ i = \\mxrow_i (R_ i *m D_ i).\nProof.\nAdmitted.\n\nLemma mul_mxblock_mxdiag {R : pzSemiRingType} {p q : nat}\n {p_ : 'I_p -> nat} {q_ : 'I_q -> nat}\n (B_ : forall i j, 'M[R]_(p_ i, q_ j)) (D_ : forall j, 'M[R]_(q_ j)) :\n \\mxblock_(i, j) B_ i j *m \\mxdiag_j D_ j = \\mxblock_(i, j) (B_ i j *m D_ j).\nProof.\nAdmitted.\n\nLemma mul_mxdiag_mxblock {R : pzSemiRingType} {p q : nat}\n {p_ : 'I_p -> nat} {q_ : 'I_q -> nat}\n (D_ : forall j, 'M[R]_(p_ j)) (B_ : forall i j, 'M[R]_(p_ i, q_ j)):\n \\mxdiag_j D_ j *m \\mxblock_(i, j) B_ i j = \\mxblock_(i, j) (D_ i *m B_ i j).\nProof.\nAdmitted.\n\nDefinition Vandermonde (R : pzRingType) (m n : nat) (a : 'rV[R]_n) :=\n \\matrix_(i < m, j < n) a 0 j ^+ i.\n\nLemma det_Vandermonde (R : comPzRingType) (n : nat) (a : 'rV[R]_n) :\n \\det (Vandermonde n a) = \\prod_(i < n) \\prod_(j < n | i < j) (a 0 j - a 0 i).\nProof.\nAdmitted." }, { "theorem_id": 74, "title": "098_bertrand_s_postulate", "source": "hundred-theorems", "tier": "b", "prover": "hol-light", "content": "needs \"Library/prime.ml\";;\nneeds \"Library/pocklington.ml\";;\nneeds \"Library/analysis.ml\";;\nneeds \"Library/transc.ml\";;\nneeds \"Library/calc_real.ml\";;\nneeds \"Library/floor.ml\";;\n\nprioritize_real();;\n\nlet num_of_float =\n let p22 = ( ** ) 2.0 22.0\n and p44 = ( ** ) 2.0 44.0\n and p66 = ( ** ) 2.0 66.0\n and q22 = pow2 22 and q44 = pow2 44 and q66 = pow2 66 in\n fun x ->\n let y0,n = frexp x in\n let u0 = int_of_float(y0 *. p22) in\n let y1 = p22 *. y0 -. float_of_int u0 in\n let u1 = int_of_float(y1 *. p22) in\n let y2 = p22 *. y1 -. float_of_int u1 in\n let u2 = int_of_float(y2 *. p22) in\n let y3 = p22 *. y2 -. float_of_int u2 in\n if y3 <> 0.0 then failwith \"num_of_float: inexactness!\" else\n (num u0 // q22 +/ num u1 // q44 +/ num u2 // q66) */ pow2 n;;\n\nlet ISQRT = new_definition\n `ISQRT n = @m. m EXP 2 <= n /\\ n < (m + 1) EXP 2`;;\n\nlet ISQRT_WORKS = `!n. ISQRT(n) EXP 2 <= n /\\ n < (ISQRT(n) + 1) EXP 2`;;\n\nlet ISQRT_0 = `ISQRT 0 = 0`;;\n\nlet ISQRT_UNIQUE = `!m n. (ISQRT n = m) <=> m EXP 2 <= n /\\ n < (m + 1) EXP 2`;;\n\nlet ISQRT_SUC = `!n. ISQRT(SUC n) =\n if ?m. SUC n = m EXP 2 then SUC(ISQRT n) else ISQRT n`;;\n\nlet LN_2_COMPOSITION = `ln(&2) =\n &7 * ln(&1 + inv(&8)) - &2 * ln(&1 + inv(&24)) - &4 * ln(&1 + inv(&80))`;;\n\nlet LN_N_CONV =\n let pth = `x = (&1 + inv(&8)) pow n * (x / (&1 + inv(&8)) pow n)`;;\n\nlet LN_FACT = `!n. ln(&(FACT n)) = sum(1,n) (\\d. ln(&d))`;;\n\nlet LN_FACT_BOUNDS = `!n. ~(n = 0) ==> abs(ln(&(FACT n)) - (&n * ln(&n) - &n)) <= &1 + ln(&n)`;;\n\nlet primepow = new_definition\n `primepow q <=> ?p k. 1 <= k /\\ prime p /\\ (q = p EXP k)`;;\n\nlet aprimedivisor = new_definition\n `aprimedivisor q = @p. prime p /\\ p divides q`;;\n\nlet PRIMEPOW_GE_2 = `!q. primepow q ==> 2 <= q`;;\n\nlet PRIMEPOW_0 = `~(primepow 0)`;;\n\nlet APRIMEDIVISOR_PRIMEPOW = `!p k. prime p /\\ 1 <= k ==> (aprimedivisor(p EXP k) = p)`;;\n\nlet APRIMEDIVISOR = `!n. ~(n = 1) ==> prime(aprimedivisor n) /\\ (aprimedivisor n) divides n`;;\n\nlet BIG_POWER_LEMMA = `!m n. 2 <= m ==> ?k. n <= m EXP k`;;\n\nlet PRIME_PRIMEPOW = `!p. prime p ==> primepow p`;;\n\nlet rec bezout (m,n) =\n if m =/ num 0 then (num 0,num 1) else if n =/ num 0 then (num 1,num 0)\n else if m <=/ n then\n let q = quo_num n m and r = mod_num n m in\n let (x,y) = bezout(m,r) in\n (x -/ q */ y,y)\n else let (x,y) = bezout(n,m) in (y,x);;\n\nlet PRIMEPOW_CONV =\n let pth0 = `primepow 0 <=> F`;;\n\nlet APRIMEDIVISOR_CONV =\n let pth = `prime p ==> 1 <= k /\\ (q = p EXP k) ==> (aprimedivisor q = p)`;;\n\nlet LN_PRIMEFACT = `!n. ~(n = 0)\n ==> (ln(&n) =\n sum(1,n) (\\d. if primepow d /\\ d divides n\n then ln(&(aprimedivisor d)) else &0))`;;\n\nlet MANGOLDT = `!n. ln(&(FACT n)) = sum(1,n) (\\d. mangoldt(d) * floor(&n / &d))`;;\n\nlet psi = new_definition\n `psi(n) = sum(1,n) (\\d. mangoldt(d))`;;\n\nlet PSI_BOUNDS_LN_FACT = `!n. ln(&(FACT(n))) - &2 * ln(&(FACT(n DIV 2))) <= psi(n) /\\\n psi(n) - psi(n DIV 2) <= ln(&(FACT(n))) - &2 * ln(&(FACT(n DIV 2)))`;;\n\nlet LN_FACT_DIFF_BOUNDS = `!n. abs((ln(&(FACT(n))) - &2 * ln(&(FACT(n DIV 2)))) - &n * ln(&2))\n <= &4 * ln(if n = 0 then &1 else &n) + &3`;;\n\nlet PSI_BOUNDS_INDUCT = `!n. &n * ln(&2) - (&4 * ln (if n = 0 then &1 else &n) + &3) <= psi(n) /\\\n psi(n) - psi(n DIV 2)\n <= &n * ln(&2) + (&4 * ln (if n = 0 then &1 else &n) + &3)`;;\n\nlet MANGOLDT_CONV =\n GEN_REWRITE_CONV I [mangoldt] THENC\n RATOR_CONV(LAND_CONV PRIMEPOW_CONV) THENC\n GEN_REWRITE_CONV I [COND_CLAUSES] THENC\n TRY_CONV(funpow 2 RAND_CONV APRIMEDIVISOR_CONV);;\n\nlet MANGOLDT_CONV =\n let pth0 = `mangoldt 0 = ln(&1)`;;\n\nlet PSI_LIST =\n let PSI_0 = `psi(0) = ln(&1)`;;\n\nlet PSI_UBOUND_128_LOG = `!n. n <= 128 ==> psi(n) <= (&3 / &2 * ln(&2)) * &n`;;\n\nlet OVERPOWER_LEMMA = `!f g d a.\n f(a) <= g(a) /\\\n (!x. a <= x ==> ((\\x. g(x) - f(x)) diffl (d(x)))(x)) /\\\n (!x. a <= x ==> &0 <= d(x))\n ==> !x. a <= x ==> f(x) <= g(x)`;;\n\nlet DOUBLE_CASES_RULE th =\n let bod = snd(dest_forall(concl th)) in\n let ant,cons = dest_imp bod in\n let m = dest_numeral (rand ant)\n and c = rat_of_term (lhand(lhand(rand cons))) in\n let x = float_of_num(m +/ num 1) in\n let d = (4.0 *. log x +. 3.0) /. (x *. log 2.0) in\n let c' = c // num 2 +/ num 1 +/\n (floor_num(num_of_float(1024.0 *. d)) +/ num 2) // num 1024 in\n let c'' = max_num c c' in\n let tm = mk_forall\n (`n:num`,\n subst [mk_numeral(num 2 */ m),rand ant;\n term_of_rat c'',lhand(lhand(rand cons))] bod) in\n prove(tm,\n REPEAT STRIP_TAC THEN\n ASM_CASES_TAC (mk_comb(`(<=) (n:num)`,mk_numeral m)) THENL\n [FIRST_ASSUM(MP_TAC o MATCH_MP th) THEN\n MATCH_MP_TAC(REAL_ARITH `a <= b ==> x <= a ==> x <= b`) THEN\n MATCH_MP_TAC REAL_LE_RMUL THEN REWRITE_TAC[REAL_POS] THEN\n MATCH_MP_TAC REAL_LE_RMUL THEN CONV_TAC REAL_RAT_REDUCE_CONV THEN\n MATCH_MP_TAC LN_POS THEN CONV_TAC REAL_RAT_REDUCE_CONV;\n ALL_TAC] THEN\n MP_TAC(SPEC `n:num` PSI_BOUNDS_INDUCT) THEN\n SUBGOAL_THEN `~(n = 0)` (fun th -> REWRITE_TAC[th]) THENL\n [FIRST_ASSUM(UNDISCH_TAC o check is_neg o concl) THEN ARITH_TAC;\n ALL_TAC] THEN\n MATCH_MP_TAC(REAL_ARITH\n `pn2 <= ((a - &1) * l2) * n - logtm\n ==> u <= v /\\ pn - pn2 <= n * l2 + logtm ==> pn <= (a * l2) * n`) THEN\n MP_TAC(SPEC `n DIV 2` th) THEN\n ANTS_TAC THENL\n [ASM_SIMP_TAC[LE_LDIV_EQ; ARITH] THEN\n FIRST_ASSUM(UNDISCH_TAC o check ((not) o is_neg) o concl) THEN\n ARITH_TAC;\n ALL_TAC] THEN\n MATCH_MP_TAC(REAL_ARITH `a <= b ==> x <= a ==> x <= b`) THEN\n W(fun (asl,w) ->\n MATCH_MP_TAC REAL_LE_TRANS THEN\n EXISTS_TAC(mk_comb(rator(lhand w),`&n / &2`))) THEN\n CONJ_TAC THENL\n [MATCH_MP_TAC REAL_LE_LMUL THEN CONJ_TAC THENL\n [MATCH_MP_TAC REAL_LE_MUL THEN CONV_TAC REAL_RAT_REDUCE_CONV THEN\n MATCH_MP_TAC LN_POS THEN CONV_TAC REAL_RAT_REDUCE_CONV;\n ALL_TAC] THEN\n SIMP_TAC[REAL_LE_RDIV_EQ; REAL_OF_NUM_LT; ARITH] THEN\n REWRITE_TAC[REAL_OF_NUM_MUL; REAL_OF_NUM_LE] THEN\n MP_TAC(SPECL [`n:num`; `2`] DIVISION) THEN ARITH_TAC;\n ALL_TAC] THEN\n GEN_REWRITE_TAC (LAND_CONV o RAND_CONV) [real_div] THEN\n MATCH_MP_TAC(REAL_ARITH\n `logtm <= ((c - a * b) * l2) * n\n ==> (a * l2) * n * b <= (c * l2) * n - logtm`) THEN\n CONV_TAC REAL_RAT_REDUCE_CONV THEN\n SUBST1_TAC(REAL_ARITH `&n = &1 + (&n - &1)`) THEN\n FIRST_X_ASSUM(MP_TAC o MATCH_MP (ARITH_RULE\n `~(n <= b) ==> b + 1 <= n`)) THEN\n GEN_REWRITE_TAC LAND_CONV [GSYM REAL_OF_NUM_LE] THEN\n DISCH_THEN(MP_TAC o MATCH_MP (REAL_ARITH\n `a <= n ==> a - &1 <= n - &1`)) THEN\n ABBREV_TAC `x = &n - &1` THEN\n CONV_TAC(LAND_CONV NUM_REDUCE_CONV THENC REAL_RAT_REDUCE_CONV) THEN\n SPEC_TAC(`x:real`,`x:real`) THEN POP_ASSUM_LIST(K ALL_TAC) THEN\n MATCH_MP_TAC OVERPOWER_LEMMA THEN\n W(fun (asl,w) ->\n let th = DIFF_CONV\n (lhand(rator(rand(body(rand(lhand(rand(body(rand w))))))))) in\n MP_TAC th) THEN\n GEN_REWRITE_TAC (LAND_CONV o TOP_DEPTH_CONV)\n [REAL_MUL_LZERO; REAL_ADD_LID; REAL_ADD_RID;\n REAL_MUL_RID; REAL_MUL_LID] THEN\n W(fun (asl,w) ->\n let tm = mk_abs(`x:real`,rand(rator(rand(body(rand(lhand w)))))) in\n DISCH_TAC THEN EXISTS_TAC tm) THEN\n CONJ_TAC THENL\n [CONV_TAC REAL_RAT_REDUCE_CONV THEN REWRITE_TAC[real_sub] THEN\n CONV_TAC(ONCE_DEPTH_CONV LN_N2_CONV) THEN\n CONV_TAC REALCALC_REL_CONV;\n ALL_TAC] THEN\n REWRITE_TAC[] THEN CONJ_TAC THENL\n [GEN_TAC THEN\n DISCH_THEN(fun th -> FIRST_ASSUM MATCH_MP_TAC THEN MP_TAC th) THEN\n REAL_ARITH_TAC;\n ALL_TAC] THEN\n X_GEN_TAC `x:real` THEN DISCH_TAC THEN REWRITE_TAC[REAL_SUB_LE] THEN\n SIMP_TAC[GSYM REAL_LE_RDIV_EQ; REAL_LT_DIV; REAL_OF_NUM_LT; ARITH] THEN\n FIRST_ASSUM(MATCH_MP_TAC o MATCH_MP (REAL_ARITH\n `a <= x ==> inv(&1 + x) <= inv(&1 + a) /\\\n inv(&1 + a) <= b ==> inv(&1 + x) <= b`)) THEN\n CONJ_TAC THENL\n [MATCH_MP_TAC REAL_LE_INV2 THEN CONV_TAC REAL_RAT_REDUCE_CONV THEN\n POP_ASSUM MP_TAC THEN REAL_ARITH_TAC;\n ALL_TAC] THEN\n SIMP_TAC[REAL_LE_RDIV_EQ; REAL_LT_DIV; REAL_OF_NUM_LT; ARITH] THEN\n GEN_REWRITE_TAC RAND_CONV [REAL_MUL_SYM] THEN\n SIMP_TAC[GSYM REAL_LE_LDIV_EQ; REAL_LT_DIV; REAL_OF_NUM_LT; ARITH] THEN\n CONV_TAC REAL_RAT_REDUCE_CONV THEN\n CONV_TAC(ONCE_DEPTH_CONV LN_N2_CONV) THEN CONV_TAC REALCALC_REL_CONV);;\n\nlet PSI_UBOUND_1024_LOG = funpow 3 DOUBLE_CASES_RULE PSI_UBOUND_128_LOG;;\n\nlet PSI_BOUNDS_SUSTAINED_INDUCT = `&4 * ln(&1 + &2 pow j) + &3 <= (d * ln(&2)) * (&1 + &2 pow j) /\\\n &4 / (&1 + &2 pow j) <= d * ln(&2) /\\ &0 <= c /\\ c / &2 + d + &1 <= c\n ==> !k. j <= k /\\\n (!n. n <= 2 EXP k ==> psi(n) <= (c * ln(&2)) * &n)\n ==> !n. n <= 2 EXP (SUC k) ==> psi(n) <= (c * ln(&2)) * &n`;;\n\nlet PSI_BOUNDS_SUSTAINED = `(!n. n <= 2 EXP k ==> psi(n) <= (c * ln(&2)) * &n)\n ==> &4 * ln(&1 + &2 pow k) + &3\n <= ((c / &2 - &1) * ln(&2)) * (&1 + &2 pow k) /\\\n &4 / (&1 + &2 pow k) <= (c / &2 - &1) * ln(&2) /\\ &0 <= c\n ==> !n. psi(n) <= (c * ln(&2)) * &n`;;\n\nlet PSI_UBOUND_LOG = `!n. psi(n) <= (&4407 / &2048 * ln (&2)) * &n`;;\n\nlet PSI_UBOUND_3_2 = `!n. psi(n) <= &3 / &2 * &n`;;\n\nlet PSI_LBOUND_3_5 = `!n. 4 <= n ==> &3 / &5 * &n <= psi(n)`;;\n\nlet theta = new_definition\n `theta(n) = sum(1,n) (\\p. if prime p then ln(&p) else &0)`;;\n\nlet THETA_LIST =\n let THETA_0 = `theta(0) = ln(&1)`;;\n\nlet PSI_SPLIT = `psi(n) = theta(n) +\n sum(1,n) (\\d. if ?p k. 1 <= k /\\ prime p /\\ (d = p EXP (2 * k))\n then ln(&(aprimedivisor d)) else &0) +\n sum(1,n) (\\d. if ?p k. 1 <= k /\\ prime p /\\ (d = p EXP (2 * k + 1))\n then ln(&(aprimedivisor d)) else &0)`;;\n\nlet SUM_SURJECT = `!f i m n p q.\n (!r. m <= r /\\ r < m + n ==> &0 <= f(i r)) /\\\n (!s. p <= s /\\ s < p + q /\\ ~(f(s) = &0)\n ==> ?r. m <= r /\\ r < m + n /\\ (i r = s))\n ==> sum(p,q) f <= sum(m,n) (\\r. f(i r))`;;\n\nlet PSI_RESIDUES_COMPARE_2 = `sum(2,n) (\\d. if ?p k. 1 <= k /\\ prime p /\\ (d = p EXP (2 * k + 1))\n then ln(&(aprimedivisor d)) else &0)\n <= sum(2,n) (\\d. if ?p k. 1 <= k /\\ prime p /\\ (d = p EXP (2 * k))\n then ln(&(aprimedivisor d)) else &0)`;;\n\nlet PSI_RESIDUES_COMPARE = `!n. sum(1,n) (\\d. if ?p k. 1 <= k /\\ prime p /\\ (d = p EXP (2 * k + 1))\n then ln(&(aprimedivisor d)) else &0)\n <= sum(1,n) (\\d. if ?p k. 1 <= k /\\ prime p /\\ (d = p EXP (2 * k))\n then ln(&(aprimedivisor d)) else &0)`;;\n\nlet PSI_SQRT = `!n. psi(ISQRT(n)) =\n sum(1,n) (\\d. if ?p k. 1 <= k /\\ prime p /\\ (d = p EXP (2 * k))\n then ln(&(aprimedivisor d)) else &0)`;;\n\nlet PSI_THETA = `!n. theta(n) + psi(ISQRT n) <= psi(n) /\\\n psi(n) <= theta(n) + &2 * psi(ISQRT n)`;;\n\nlet THETA_LE_PSI = `!n. theta(n) <= psi(n)`;;\n\nlet PSI_UBOUND_30 = `!n. n <= 30 ==> psi(n) <= &65 / &64 * &n`;;\n\nlet THETA_UBOUND_3_2 = `!n. theta(n) <= &3 / &2 * &n`;;\n\nlet THETA_LBOUND_1_2 = `!n. 5 <= n ==> &1 / &2 * &n <= theta(n)`;;\n\nlet FLOOR_POS = `!x. &0 <= x ==> &0 <= floor x`;;\n\nlet FLOOR_NUM_EXISTS = `!x. &0 <= x ==> ?k. floor x = &k`;;\n\nlet FLOOR_DIV_INTERVAL = `!n d k. ~(d = 0)\n ==> ((floor(&n / &d) = &k) =\n if k = 0 then &n < &d\n else &n / &(k + 1) < &d /\\ &d <= &n / &k)`;;\n\nlet FLOOR_DIV_EXISTS = `!n d. ~(d = 0)\n ==> ?k. (floor(&n / &d) = &k) /\\\n d * k <= n /\\ n < d * (k + 1)`;;\n\nlet FLOOR_HALF_INTERVAL = `!n d. ~(d = 0)\n ==> (floor (&n / &d) - &2 * floor (&(n DIV 2) / &d) =\n if ?k. ODD k /\\ n DIV (k + 1) < d /\\ d <= n DIV k\n then &1 else &0)`;;\n\nlet SUM_EXPAND_LEMMA = `!n m k. (m + 2 * k = n)\n ==> (sum (1,n DIV (2 * k + 1))\n (\\d. if ?k. ODD k /\\ n DIV (k + 1) < d /\\ d <= n DIV k\n then mangoldt d else &0) =\n sum (1,n) (\\d. --(&1) pow (d + 1) * psi (n DIV d)) -\n sum (1,2 * k)\n (\\d. --(&1) pow (d + 1) * psi (n DIV d)))`;;\n\nlet FACT_EXPAND_PSI = `!n. ln(&(FACT(n))) - &2 * ln(&(FACT(n DIV 2))) =\n sum(1,n) (\\d. --(&1) pow (d + 1) * psi(n DIV d))`;;\n\nlet PSI_MONO = `!m n. m <= n ==> psi(m) <= psi(n)`;;\n\nlet PSI_POS = `!n. &0 <= psi(n)`;;\n\nlet PSI_EXPANSION_CUTOFF = `!n m p. m <= p\n ==> sum(1,2 * m) (\\d. --(&1) pow (d + 1) * psi(n DIV d))\n <= sum(1,2 * p) (\\d. --(&1) pow (d + 1) * psi(n DIV d)) /\\\n sum(1,2 * p + 1) (\\d. --(&1) pow (d + 1) * psi(n DIV d))\n <= sum(1,2 * m + 1) (\\d. --(&1) pow (d + 1) * psi(n DIV d))`;;\n\nlet FACT_PSI_BOUND_ODD = `!n k. ODD(k)\n ==> ln(&(FACT n)) - &2 * ln(&(FACT (n DIV 2)))\n <= sum(1,k) (\\d. --(&1) pow (d + 1) * psi(n DIV d))`;;\n\nlet FACT_PSI_BOUND_EVEN = `!n k. EVEN(k)\n ==> sum(1,k) (\\d. --(&1) pow (d + 1) * psi(n DIV d))\n <= ln(&(FACT n)) - &2 * ln(&(FACT (n DIV 2)))`;;\n\nlet FACT_PSI_BOUND_2_3 = `!n. psi(n) - psi(n DIV 2)\n <= ln(&(FACT n)) - &2 * ln(&(FACT (n DIV 2))) /\\\n ln(&(FACT n)) - &2 * ln(&(FACT (n DIV 2)))\n <= psi(n) - psi(n DIV 2) + psi(n DIV 3)`;;\n\nlet PSI_DOUBLE_LEMMA = `!n. n >= 1200 ==> &n / &6 <= psi(n) - psi(n DIV 2)`;;\n\nlet THETA_DOUBLE_LEMMA = `!n. n >= 1200 ==> theta(n DIV 2) < theta(n)`;;\n\nlet BIG_BERTRAND = `!n. n >= 2400 ==> ?p. prime(p) /\\ n <= p /\\ p <= 2 * n`;;\n\nlet LANDAU_TRICK = `!n. 0 < n /\\ n < 2400\n ==> n <= 2 /\\ 2 <= 2 * n \\/\n n <= 3 /\\ 3 <= 2 * n \\/\n n <= 5 /\\ 5 <= 2 * n \\/\n n <= 7 /\\ 7 <= 2 * n \\/\n n <= 13 /\\ 13 <= 2 * n \\/\n n <= 23 /\\ 23 <= 2 * n \\/\n n <= 43 /\\ 43 <= 2 * n \\/\n n <= 83 /\\ 83 <= 2 * n \\/\n n <= 163 /\\ 163 <= 2 * n \\/\n n <= 317 /\\ 317 <= 2 * n \\/\n n <= 631 /\\ 631 <= 2 * n \\/\n n <= 1259 /\\ 1259 <= 2 * n \\/\n n <= 2503 /\\ 2503 <= 2 * n`;;\n\nlet BERTRAND = `!n. ~(n = 0) ==> ?p. prime p /\\ n <= p /\\ p <= 2 * n`;;\n\nlet pii = new_definition\n `pii(n) = sum(1,n) (\\p. if prime(p) then &1 else &0)`;;\n\nlet PII_LIST =\n let PII_0 = `pii(0) = &0`;;\n\nlet PII = `!n. pii(n) = &(CARD {p | p <= n /\\ prime(p)})`;;\n\nlet PII_LBOUND = `!n. 3 <= n ==> &1 / &2 * (&n / ln(&n)) <= pii(n)`;;\n\nlet PII_UBOUND_CASES_50 = `!n. n < 50 ==> 3 <= n ==> ln(&n) * pii(n) <= &5 * &n`;;\n\nlet THETA_POS = `!n. &0 <= theta n`;;\n\nlet PII_MONO = `!m n. m <= n ==> pii(m) <= pii(n)`;;\n\nlet PII_POS = `!n. &0 <= pii(n)`;;\n\nlet PII_CHANGE = `!m n. ~(m = 0) ==> ln(&m) * (pii n - pii m) <= &3 / &2 * &n`;;\n\nlet PII_ISQRT_INDUCT = `!n. 50 <= n\n ==> ln(&n) * pii(n)\n <= &9 / &4 * (&3 / &2 * &n + ln(&(ISQRT(n))) * pii(ISQRT(n)))`;;\n\nlet PII_UBOUND_5 = `!n. 3 <= n ==> pii(n) <= &5 * (&n / ln(&n))`;;" }, { "theorem_id": 74, "title": "098_bertrand_s_postulate", "source": "hundred-theorems", "tier": "b", "prover": "isabelle", "content": "theory Bertrand\n imports \n Complex_Main\n \"HOL-Number_Theory.Number_Theory\"\n \"HOL-Library.Discrete_Functions\"\n \"HOL-Decision_Procs.Approximation_Bounds\"\n \"HOL-Library.Code_Target_Numeral\"\n Pratt_Certificate.Pratt_Certificate\nbegin\n\nsubsection \\Auxiliary facts\\\n \nlemma ln_2_le: \"ln 2 \\ 355 / (512 :: real)\"\n by sorry\n\nlemma ln_2_ge: \"ln 2 \\ (5677 / 8192 :: real)\"\n by sorry\n\nlemma ln_2_ge': \"ln (2 :: real) \\ 2/3\" and ln_2_le': \"ln (2 :: real) \\ 16/23\"\n by sorry\n\nlemma of_nat_ge_1_iff: \"(of_nat x :: 'a :: linordered_semidom) \\ 1 \\ x \\ 1\"\n by sorry\n \nlemma floor_conv_div_nat:\n \"of_int (floor (real m / real n)) = real (m div n)\"\n by sorry\n\nlemma frac_conv_mod_nat:\n \"frac (real m / real n) = real (m mod n) / real n\"\n by sorry\n\nlemma of_nat_prod_mset: \"prod_mset (image_mset of_nat A) = of_nat (prod_mset A)\"\n by sorry\n\nlemma prod_mset_pos: \"(\\x :: 'a :: linordered_semidom. x \\# A \\ x > 0) \\ prod_mset A > 0\"\n by sorry\n\nlemma ln_msetprod:\n assumes \"\\x. x \\#I \\ x > 0\"\n shows \"(\\p::nat\\#I. ln p) = ln (\\p\\#I. p)\"\n by sorry\n\nlemma ln_fact: \"ln (fact n) = (\\d=1..n. ln d)\"\n by sorry\n\nlemma overpower_lemma:\n fixes f g :: \"real \\ real\"\n assumes \"f a \\ g a\"\n assumes \"\\x. a \\ x \\ ((\\x. g x - f x) has_real_derivative (d x)) (at x)\"\n assumes \"\\x. a \\ x \\ d x \\ 0\"\n assumes \"a \\ x\"\n shows \"f x \\ g x\"\n by sorry\n\nsubsection \\Preliminary definitions\\\n\ndefinition primepow_even :: \"nat \\ bool\" where\n \"primepow_even q \\ (\\ p k. 1 \\ k \\ prime p \\ q = p^(2*k))\"\n\ndefinition primepow_odd :: \"nat \\ bool\" where\n \"primepow_odd q \\ (\\ p k. 1 \\ k \\ prime p \\ q = p^(2*k+1))\"\n\nabbreviation (input) isprimedivisor :: \"nat \\ nat \\ bool\" where\n \"isprimedivisor q p \\ prime p \\ p dvd q\"\n\ndefinition pre_mangoldt :: \"nat \\ nat\" where\n \"pre_mangoldt d = (if primepow d then aprimedivisor d else 1)\"\n\ndefinition mangoldt_even :: \"nat \\ real\" where\n \"mangoldt_even d = (if primepow_even d then ln (real (aprimedivisor d)) else 0)\"\n\ndefinition mangoldt_odd :: \"nat \\ real\" where\n \"mangoldt_odd d = (if primepow_odd d then ln (real (aprimedivisor d)) else 0)\"\n\ndefinition mangoldt_1 :: \"nat \\ real\" where\n \"mangoldt_1 d = (if prime d then ln d else 0)\"\n\ndefinition psi :: \"nat \\ real\" where\n \"psi n = (\\d=1..n. mangoldt d)\"\n\ndefinition psi_even :: \"nat \\ real\" where\n \"psi_even n = (\\d=1..n. mangoldt_even d)\"\n\ndefinition psi_odd :: \"nat \\ real\" where\n \"psi_odd n = (\\d=1..n. mangoldt_odd d)\"\n\nabbreviation (input) psi_even_2 :: \"nat \\ real\" where\n \"psi_even_2 n \\ (\\d=2..n. mangoldt_even d)\"\n\nabbreviation (input) psi_odd_2 :: \"nat \\ real\" where\n \"psi_odd_2 n \\ (\\d=2..n. mangoldt_odd d)\"\n\ndefinition theta :: \"nat \\ real\" where\n \"theta n = (\\p=1..n. if prime p then ln (real p) else 0)\"\n\nsubsection \\Properties of prime powers\\ \n\nlemma primepow_even_imp_primepow:\n assumes \"primepow_even n\"\n shows \"primepow n\"\n by sorry\n\nlemma primepow_odd_imp_primepow:\n assumes \"primepow_odd n\"\n shows \"primepow n\"\n by sorry\n\nlemma primepow_odd_altdef:\n \"primepow_odd n \\\n primepow n \\ odd (multiplicity (aprimedivisor n) n) \\ multiplicity (aprimedivisor n) n > 1\"\n by sorry\n\nlemma primepow_even_altdef:\n \"primepow_even n \\ primepow n \\ even (multiplicity (aprimedivisor n) n)\"\n by sorry\n\nlemma primepow_odd_mult:\n assumes \"d > Suc 0\"\n shows \"primepow_odd (aprimedivisor d * d) \\ primepow_even d\"\n by sorry\n\nlemma pre_mangoldt_primepow:\n assumes \"primepow n\" \"aprimedivisor n = p\"\n shows \"pre_mangoldt n = p\"\n by sorry\n\nlemma pre_mangoldt_notprimepow:\n assumes \"\\primepow n\"\n shows \"pre_mangoldt n = 1\"\n by sorry\n\nlemma primepow_cases:\n \"primepow d \\\n ( primepow_even d \\ \\ primepow_odd d \\ \\ prime d) \\\n (\\ primepow_even d \\ primepow_odd d \\ \\ prime d) \\\n (\\ primepow_even d \\ \\ primepow_odd d \\ prime d)\"\n by sorry\n\nsubsection \\Deriving a recurrence for the psi function\\\n \nlemma ln_fact_bounds:\n assumes \"n > 0\"\n shows \"abs(ln (fact n) - n * ln n + n) \\ 1 + ln n\"\n by sorry\n\nlemma ln_fact_diff_bounds:\n \"abs(ln (fact n) - 2 * ln (fact (n div 2)) - n * ln 2) \\ 4 * ln (if n = 0 then 1 else n) + 3\"\n by sorry\n \nlemma ln_primefact:\n assumes \"n \\ (0::nat)\"\n shows \"ln n = (\\d=1..n. if primepow d \\ d dvd n then ln (aprimedivisor d) else 0)\" \n (is \"?lhs = ?rhs\")\n by sorry\n\ncontext\nbegin\n\nprivate lemma divisors:\n fixes x d::nat\n assumes \"x \\ {1..n}\"\n assumes \"d dvd x\"\n shows \"\\k\\{1..n div d}. x = d * k\"\nproof -\n from assms have \"x \\ n\"\n by simp\n then have ub: \"x div d \\ n div d\"\n by (simp add: div_le_mono \\x \\ n\\)\n from assms have \"1 \\ x div d\" by (auto elim!: dvdE)\n with ub have \"x div d \\ {1..n div d}\"\n by simp\n with \\d dvd x\\ show ?thesis by (auto intro!: bexI[of _ \"x div d\"])\nqed\n\nlemma ln_fact_conv_mangoldt: \"ln (fact n) = (\\d=1..n. mangoldt d * floor (n / d))\"\n by sorry\n\nend\n\ncontext\nbegin\n\nprivate lemma div_2_mult_2_bds:\n fixes n d :: nat\n assumes \"d > 0\"\n shows \"0 \\ \\n / d\\ - 2 * \\(n div 2) / d\\\" \"\\n / d\\ - 2 * \\(n div 2) / d\\ \\ 1\"\nproof -\n have \"\\2::real\\ * \\(n div 2) / d\\ \\ \\2 * ((n div 2) / d)\\\" \n by (rule le_mult_floor) simp_all\n also from assms have \"\\ \\ \\n / d\\\" by (intro floor_mono) (simp_all add: field_simps)\n finally show \"0 \\ \\n / d\\ - 2 * \\(n div 2) / d\\\" by (simp add: algebra_simps)\nnext \n have \"real (n div d) \\ real (2 * ((n div 2) div d) + 1)\"\n by (subst div_mult2_eq [symmetric], simp only: mult.commute, subst div_mult2_eq) simp\n thus \"\\n / d\\ - 2 * \\(n div 2) / d\\ \\ 1\"\n unfolding of_nat_add of_nat_mult floor_conv_div_nat [symmetric] by simp_all\nqed\n\nprivate lemma n_div_d_eq_1: \"d \\ {n div 2 + 1..n} \\ \\real n / real d\\ = 1\"\n by (cases \"n = d\") (auto simp: field_simps intro: floor_eq)\n \nlemma psi_bounds_ln_fact:\n shows \"ln (fact n) - 2 * ln (fact (n div 2)) \\ psi n\"\n \"psi n - psi (n div 2) \\ ln (fact n) - 2 * ln (fact (n div 2))\"\n by sorry\n\nend\n\nlemma psi_bounds_induct:\n \"real n * ln 2 - (4 * ln (real (if n = 0 then 1 else n)) + 3) \\ psi n\"\n \"psi n - psi (n div 2) \\ real n * ln 2 + (4 * ln (real (if n = 0 then 1 else n)) + 3)\"\n by sorry\n \nsubsection \\Bounding the psi function\\\n\ntext \\\n In this section, we will first prove the relatively tight estimate\n @{prop \"psi n \\ 3 / 2 + ln 2 * n\"} for @{term \"n \\ 128\"} and then use the \n recurrence we have just derived to extend it to @{prop \"psi n \\ 551 / 256\"} for \n @{term \"n \\ 1024\"}, at which point applying the recurrence can be used to prove \n the same bound for arbitrarily big numbers.\n\n First of all, we will prove the bound for @{term \"n <= 128\"} using reflection and\n approximation.\n\\ \n\ncontext\nbegin\n\nprivate lemma Ball_insertD:\n assumes \"\\x\\insert y A. P x\"\n shows \"P y\" \"\\x\\A. P x\"\n using assms by auto\n\nprivate lemma meta_eq_TrueE: \"PROP A \\ Trueprop True \\ PROP A\"\n by simp\n\nprivate lemma pre_mangoldt_pos: \"pre_mangoldt n > 0\"\n unfolding pre_mangoldt_def by (auto simp: primepow_gt_Suc_0)\n\nprivate lemma psi_conv_pre_mangoldt: \"psi n = ln (real (prod pre_mangoldt {1..n}))\"\n by (auto simp: psi_def mangoldt_def pre_mangoldt_def ln_prod primepow_gt_Suc_0 intro!: sum.cong)\n\nprivate lemma eval_psi_aux1: \"psi 0 = ln (real (numeral Num.One))\"\n by (simp add: psi_def)\n\nprivate lemma eval_psi_aux2:\n assumes \"psi m = ln (real (numeral x))\" \"pre_mangoldt n = y\" \"m + 1 = n\" \"numeral x * y = z\"\n shows \"psi n = ln (real z)\"\nproof -\n from assms(2) [symmetric] have [simp]: \"y > 0\" by (simp add: pre_mangoldt_pos)\n have \"psi n = psi (Suc m)\" by (simp add: assms(3) [symmetric])\n also have \"\\ = ln (real y * (\\x = Suc 0..m. real (pre_mangoldt x)))\"\n using assms(2,3) [symmetric] by (simp add: psi_conv_pre_mangoldt prod.nat_ivl_Suc' mult_ac)\n also have \"\\ = ln (real y) + psi m\"\n by (subst ln_mult) (simp_all add: pre_mangoldt_pos prod_pos psi_conv_pre_mangoldt)\n also have \"psi m = ln (real (numeral x))\" by fact\n also have \"ln (real y) + \\ = ln (real (numeral x * y))\" by (simp add: ln_mult)\n finally show ?thesis by (simp add: assms(4) [symmetric])\nqed\n\nprivate lemma Ball_atLeast0AtMost_doubleton:\n assumes \"psi 0 \\ 3 / 2 * ln 2 * real 0\"\n assumes \"psi 1 \\ 3 / 2 * ln 2 * real 1\"\n shows \"(\\x\\{0..1}. psi x \\ 3 / 2 * ln 2 * real x)\"\n using assms unfolding One_nat_def atLeast0_atMost_Suc ball_simps by auto\n\nprivate lemma Ball_atLeast0AtMost_insert:\n assumes \"(\\x\\{0..m}. psi x \\ 3 / 2 * ln 2 * real x)\"\n assumes \"psi (numeral n) \\ 3 / 2 * ln 2 * real (numeral n)\" \"m = pred_numeral n\"\n shows \"(\\x\\{0..numeral n}. psi x \\ 3 / 2 * ln 2 * real x)\"\n using assms\n by (subst numeral_eq_Suc[of n], subst atLeast0_atMost_Suc,\n subst ball_simps, simp only: numeral_eq_Suc [symmetric])\n\nprivate lemma eval_psi_ineq_aux:\n assumes \"psi n = x\" \"x \\ 3 / 2 * ln 2 * n\"\n shows \"psi n \\ 3 / 2 * ln 2 * n\"\n using assms by simp_all\n \nprivate lemma eval_psi_ineq_aux2:\n assumes \"numeral m ^ 2 \\ (2::nat) ^ (3 * n)\"\n shows \"ln (real (numeral m)) \\ 3 / 2 * ln 2 * real n\"\nproof -\n have \"ln (real (numeral m)) \\ 3 / 2 * ln 2 * real n \\ \n 2 * log 2 (real (numeral m)) \\ 3 * real n\"\n by (simp add: field_simps log_def)\n also have \"2 * log 2 (real (numeral m)) = log 2 (real (numeral m ^ 2))\"\n by (subst of_nat_power, subst log_nat_power) simp_all\n also have \"\\ \\ 3 * real n \\ real ((numeral m) ^ 2) \\ 2 powr real (3 * n)\"\n by (subst Transcendental.log_le_iff) simp_all\n also have \"2 powr (3 * n) = real (2 ^ (3 * n))\" \n by (simp add: powr_realpow [symmetric])\n also have \"real ((numeral m) ^ 2) \\ \\ \\ numeral m ^ 2 \\ (2::nat) ^ (3 * n)\"\n by (rule of_nat_le_iff)\n finally show ?thesis using assms by blast\nqed\n\nprivate lemma eval_psi_ineq_aux_mono:\n assumes \"psi n = x\" \"psi m = x\" \"psi n \\ 3 / 2 * ln 2 * n\" \"n \\ m\"\n shows \"psi m \\ 3 / 2 * ln 2 * m\"\nproof -\n from assms have \"psi m = psi n\" by simp\n also have \"\\ \\ 3 / 2 * ln 2 * n\" by fact\n also from \\n \\ m\\ have \"\\ \\ 3 / 2 * ln 2 * m\" by simp\n finally show ?thesis .\nqed\n\nlemma not_primepow_1_nat: \"\\primepow (1 :: nat)\" by auto\n \nML_file \\bertrand.ML\\\n\nlocal_setup \\fn lthy =>\nlet\n fun tac ctxt =\n let\n val psi_cache = Bertrand.prove_psi ctxt 129\n fun prove_psi_ineqs ctxt =\n let\n fun tac goal_ctxt = \n HEADGOAL (resolve_tac goal_ctxt @{thms eval_psi_ineq_aux2} THEN'\n Simplifier.simp_tac goal_ctxt)\n fun prove_by_approx n thm =\n let\n val thm = thm RS @{thm eval_psi_ineq_aux}\n val [prem] = Thm.prems_of thm\n val prem = Goal.prove ctxt [] [] prem (tac o #context)\n in\n prem RS thm\n end\n fun prove_by_mono last_thm last_thm' thm =\n let\n val thm = @{thm eval_psi_ineq_aux_mono} OF [last_thm, thm, last_thm']\n val [prem] = Thm.prems_of thm\n val prem =\n Goal.prove ctxt [] [] prem (fn {context = goal_ctxt, ...} =>\n HEADGOAL (Simplifier.simp_tac goal_ctxt))\n in\n prem RS thm\n end\n fun go _ acc [] = acc\n | go last acc ((n, x, thm) :: xs) =\n let\n val thm' =\n case last of\n NONE => prove_by_approx n thm\n | SOME (last_x, last_thm, last_thm') => \n if last_x = x then \n prove_by_mono last_thm last_thm' thm \n else\n prove_by_approx n thm\n in\n go (SOME (x, thm, thm')) (thm' :: acc) xs\n end\n in\n rev o go NONE []\n end\n \n val psi_ineqs = prove_psi_ineqs ctxt psi_cache\n fun prove_ball ctxt (thm1 :: thm2 :: thms) =\n let\n val thm = @{thm Ball_atLeast0AtMost_doubleton} OF [thm1, thm2]\n fun solve_prem thm =\n let\n val thm' =\n Goal.prove ctxt [] [] (Thm.cprem_of thm 1 |> Thm.term_of)\n (fn {context = goal_ctxt, ...} =>\n HEADGOAL (Simplifier.simp_tac goal_ctxt))\n in\n thm' RS thm\n end\n fun go thm thm' = (@{thm Ball_atLeast0AtMost_insert} OF [thm', thm]) |> solve_prem\n in\n fold go thms thm\n end\n | prove_ball _ _ = raise Match\n in\n HEADGOAL (resolve_tac ctxt [prove_ball ctxt psi_ineqs])\n end\n val thm = Goal.prove lthy [] [] @{prop \"\\n\\{0..128}. psi n \\ 3 / 2 * ln 2 * n\"} (tac o #context)\nin\n Local_Theory.note ((@{binding psi_ubound_log_128}, []), [thm]) lthy |> snd\nend\n\\\n\nend\n\ncontext\nbegin\n \nprivate lemma psi_ubound_aux:\n defines \"f \\ \\x::real. (4 * ln x + 3) / (ln 2 * x)\"\n assumes \"x \\ 2\" \"x \\ y\"\n shows \"f x \\ f y\"\n by sorry\n\ntext \\\n These next rules are used in combination with @{thm psi_bounds_induct} and \n @{thm psi_ubound_log_128} to extend the upper bound for @{term \"psi\"} from values no greater \n than 128 to values no greater than 1024. The constant factor of the upper bound changes every \n time, but once we have reached 1024, the recurrence is self-sustaining in the sense that we do \n not have to adjust the constant factor anymore in order to double the range.\n\\\nlemma psi_ubound_log_double_cases':\n assumes \"\\n. n \\ m \\ psi n \\ c * ln 2 * real n\" \"n \\ m'\" \"m' = 2*m\"\n \"c \\ c'\" \"c \\ 0\" \"m \\ 1\" \"c' \\ 1 + c/2 + (4 * ln (m+1) + 3) / (ln 2 * (m+1))\"\n shows \"psi n \\ c' * ln 2 * real n\"\n by sorry\n\nend \n\nlemma psi_ubound_log_double_cases:\n assumes \"\\n\\m. psi n \\ c * ln 2 * real n\"\n \"c' \\ 1 + c/2 + (4 * ln (m+1) + 3) / (ln 2 * (m+1))\"\n \"m' = 2*m\" \"c \\ c'\" \"c \\ 0\" \"m \\ 1\" \n shows \"\\n\\m'. psi n \\ c' * ln 2 * real n\"\n by sorry\n\nlemma psi_ubound_log_1024:\n \"\\n\\1024. psi n \\ 551 / 256 * ln 2 * real n\"\n by sorry\n \nlemma psi_bounds_sustained_induct:\n assumes \"4 * ln (1 + 2 ^ j) + 3 \\ d * ln 2 * (1 + 2^j)\"\n assumes \"4 / (1 + 2^j) \\ d * ln 2\"\n assumes \"0 \\ c\"\n assumes \"c / 2 + d + 1 \\ c\"\n assumes \"j \\ k\"\n assumes \"\\n. n \\ 2^k \\ psi n \\ c * ln 2 * n\"\n assumes \"n \\ 2^(Suc k)\"\n shows \"psi n \\ c * ln 2 * n\"\n by sorry\n\nlemma psi_bounds_sustained:\n assumes \"\\n. n \\ 2^k \\ psi n \\ c * ln 2 * n\"\n assumes \"4 * ln (1 + 2^k) + 3 \\ (c/2 - 1) * ln 2 * (1 + 2^k)\"\n assumes \"4 / (1 + 2^k) \\ (c/2 - 1) * ln 2\"\n assumes \"c \\ 0\"\n shows \"psi n \\ c * ln 2 * n\"\n by sorry\n\nlemma psi_ubound_log: \"psi n \\ 551 / 256 * ln 2 * n\"\n by sorry\n\nlemma psi_ubound_3_2: \"psi n \\ 3/2 * n\"\n by sorry\n\nsubsection \\Doubling psi and theta\\ \n\nlemma psi_residues_compare_2:\n \"psi_odd_2 n \\ psi_even_2 n\"\n by sorry\n\nlemma psi_residues_compare:\n \"psi_odd n \\ psi_even n\"\n by sorry\n\nlemma primepow_iff_even_sqr:\n \"primepow n \\ primepow_even (n^2)\"\n by sorry\n\nlemma psi_sqrt: \"psi (floor_sqrt n) = psi_even n\"\n by sorry\n\nlemma mangoldt_split:\n \"mangoldt d = mangoldt_1 d + mangoldt_even d + mangoldt_odd d\"\n by sorry\n\nlemma psi_split: \"psi n = theta n + psi_even n + psi_odd n\"\n by sorry\n\nlemma psi_mono: \"m \\ n \\ psi m \\ psi n\" unfolding psi_def\n by sorry\n\nlemma psi_pos: \"0 \\ psi n\"\n by sorry\n\nlemma mangoldt_odd_pos: \"0 \\ mangoldt_odd d\"\n by sorry\n\nlemma psi_odd_mono: \"m \\ n \\ psi_odd m \\ psi_odd n\"\n by sorry\n\nlemma psi_odd_pos: \"0 \\ psi_odd n\"\n by sorry\n\nlemma psi_theta:\n \"theta n + psi (floor_sqrt n) \\ psi n\" \"psi n \\ theta n + 2 * psi (floor_sqrt n)\"\n by sorry\n\ncontext\nbegin\n\nprivate lemma sum_minus_one: \n \"(\\x \\ {1..y}. (- 1 :: real) ^ (x + 1)) = (if odd y then 1 else 0)\"\n by (induction y) simp_all\n \nprivate lemma div_invert:\n fixes x y n :: nat\n assumes \"x > 0\" \"y > 0\" \"y \\ n div x\"\n shows \"x \\ n div y\"\nproof -\n from assms(1,3) have \"y * x \\ (n div x) * x\"\n by simp\n also have \"\\ \\ n\"\n by (simp add: minus_mod_eq_div_mult[symmetric])\n finally have \"y * x \\ n\" .\n with assms(2) show ?thesis\n using div_le_mono[of \"y*x\" n y] by simp\nqed\n\nlemma sum_expand_lemma:\n \"(\\d=1..n. (-1) ^ (d + 1) * psi (n div d)) = \n (\\d = 1..n. (if odd (n div d) then 1 else 0) * mangoldt d)\"\n by sorry\n\nprivate lemma floor_half_interval:\n fixes n d :: nat\n assumes \"d \\ 0\"\n shows \"real (n div d) - real (2 * ((n div 2) div d)) = (if odd (n div d) then 1 else 0)\"\nproof -\n have \"((n div 2) div d) = (n div (2 * d))\"\n by (rule div_mult2_eq[symmetric])\n also have \"\\ = ((n div d) div 2)\"\n by (simp add: mult_ac div_mult2_eq)\n also have \"real (n div d) - real (2 * \\) = (if odd (n div d) then 1 else 0)\"\n by (cases \"odd (n div d)\", cases \"n div d = 0 \", simp_all)\n finally show ?thesis by simp\nqed\n\nlemma fact_expand_psi:\n \"ln (fact n) - 2 * ln (fact (n div 2)) = (\\d=1..n. (-1)^(d+1) * psi (n div d))\"\n by sorry\n \nend\n\nlemma psi_expansion_cutoff:\n assumes \"m \\ p\"\n shows \"(\\d=1..2*m. (-1)^(d+1) * psi (n div d)) \\ (\\d=1..2*p. (-1)^(d+1) * psi (n div d))\"\n \"(\\d=1..2*p+1. (-1)^(d+1) * psi (n div d)) \\ (\\d=1..2*m+1. (-1)^(d+1) * psi (n div d))\"\n by sorry\n\nlemma fact_psi_bound_even:\n assumes \"even k\"\n shows \"(\\d=1..k. (-1)^(d+1) * psi (n div d)) \\ ln (fact n) - 2 * ln (fact (n div 2))\"\n by sorry\n\nlemma fact_psi_bound_odd:\n assumes \"odd k\"\n shows \"ln (fact n) - 2 * ln (fact (n div 2)) \\ (\\d=1..k. (-1)^(d+1) * psi (n div d))\"\n by sorry\n\nlemma fact_psi_bound_2_3:\n \"psi n - psi (n div 2) \\ ln (fact n) - 2 * ln (fact (n div 2))\"\n \"ln (fact n) - 2 * ln (fact (n div 2)) \\ psi n - psi (n div 2) + psi (n div 3)\"\n by sorry\n\nlemma ub_ln_1200: \"ln 1200 \\ 57 / (8 :: real)\"\n by sorry\n \nlemma psi_double_lemma:\n assumes \"n \\ 1200\"\n shows \"real n / 6 \\ psi n - psi (n div 2)\"\n by sorry\n\nlemma theta_double_lemma:\n assumes \"n \\ 1200\"\n shows \"theta (n div 2) < theta n\"\n by sorry\n \nsubsection \\Proof of the main result\\\n\nlemma theta_mono: \"mono theta\"\n by sorry\n \nlemma theta_lessE:\n assumes \"theta m < theta n\" \"m \\ 1\"\n obtains p where \"p \\ {m<..n}\" \"prime p\"\n by sorry\n\ntheorem bertrand:\n fixes n :: nat\n assumes \"n > 1\"\n shows \"\\p\\{n<..<2*n}. prime p\"\n by sorry\n \nsubsection \\Proof of Mertens' first theorem\\\n\ntext \\\n The following proof of Mertens' first theorem was ported from John Harrison's HOL Light\n proof by Larry Paulson:\n\\\n\nlemma sum_integral_ubound_decreasing':\n fixes f :: \"real \\ real\"\n assumes \"m \\ n\"\n and der: \"\\x. x \\ {of_nat m - 1..of_nat n} \\ (g has_field_derivative f x) (at x)\"\n and le: \"\\x y. \\real m - 1 \\ x; x \\ y; y \\ real n\\ \\ f y \\ f x\"\n shows \"(\\k = m..n. f (of_nat k)) \\ g (of_nat n) - g (of_nat m - 1)\"\n by sorry\n\nlemma Mertens_lemma:\n assumes \"n \\ 0\"\n shows \"\\(\\d = 1..n. mangoldt d / real d) - ln n\\ \\ 4\"\n by sorry\n\nlemma Mertens_mangoldt_versus_ln:\n assumes \"I \\ {1..n}\"\n shows \"\\(\\i\\I. mangoldt i / i) - (\\p | prime p \\ p \\ I. ln p / p)\\ \\ 3\"\n (is \"\\?lhs\\ \\ 3\")\n by sorry\n\nproposition Mertens:\n assumes \"n \\ 0\"\n shows \"\\(\\p | prime p \\ p \\ n. ln p / of_nat p) - ln n\\ \\ 7\"\n by sorry\n\nend" }, { "theorem_id": 74, "title": "098_bertrand_s_postulate", "source": "hundred-theorems", "tier": "b", "prover": "lean4", "content": "/-\nCopyright (c) 2020 Patrick Stevens. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Stevens, Bolton Bailey\n-/\nmodule\n\npublic import Mathlib.Data.Nat.Choose.Factorization\npublic import Mathlib.NumberTheory.Primorial\npublic import Mathlib.Analysis.Convex.SpecificFunctions.Basic\npublic import Mathlib.Analysis.Convex.SpecificFunctions.Deriv\npublic import Mathlib.Tactic.NormNum.Prime\n\n/-!\n# Bertrand's Postulate\n\nThis file contains a proof of Bertrand's postulate: That between any positive number and its\ndouble there is a prime.\n\nThe proof follows the outline of the Erdős proof presented in \"Proofs from THE BOOK\": One considers\nthe prime factorization of `(2 * n).choose n`, and splits the constituent primes up into various\ngroups, then upper bounds the contribution of each group. This upper bounds the central binomial\ncoefficient, and if the postulate does not hold, this upper bound conflicts with a simple lower\nbound for large enough `n`. This proves the result holds for large enough `n`, and for smaller `n`\nan explicit list of primes is provided which covers the remaining cases.\n\nAs in the [Metamath implementation](carneiro2015arithmetic), we rely on some optimizations from\n[Shigenori Tochiori](tochiori_bertrand). In particular we use the cleaner bound on the central\nbinomial coefficient given in `Nat.four_pow_lt_mul_centralBinom`.\n\n## References\n\n* [M. Aigner and G. M. Ziegler _Proofs from THE BOOK_][aigner1999proofs]\n* [S. Tochiori, _Considering the Proof of “There is a Prime between n and 2n”_][tochiori_bertrand]\n* [M. Carneiro, _Arithmetic in Metamath, Case Study: Bertrand's Postulate_][carneiro2015arithmetic]\n\n## Tags\n\nBertrand, prime, binomial coefficients\n-/\n\npublic section\n\n\nsection Real\n\nopen Real\n\nnamespace Bertrand\n\n/-- A refined version of the `Bertrand.main_inequality` below.\nThis is not best possible: it actually holds for 464 ≤ x.\n-/\ntheorem real_main_inequality {x : ℝ} (x_large : (512 : ℝ) ≤ x) :\n x * (2 * x) ^ √(2 * x) * 4 ^ (2 * x / 3) ≤ 4 ^ x := by sorry\nend Bertrand\n\nend Real\n\nsection Nat\n\nopen Nat\n\n/-- The inequality which contradicts Bertrand's postulate, for large enough `n`.\n-/\ntheorem bertrand_main_inequality {n : ℕ} (n_large : 512 ≤ n) :\n n * (2 * n) ^ sqrt (2 * n) * 4 ^ (2 * n / 3) ≤ 4 ^ n := by sorry\ntheorem centralBinom_factorization_small (n : ℕ) (n_large : 2 < n)\n (no_prime : ∀ p : ℕ, p.Prime → n < p → 2 * n < p) :\n centralBinom n = ∏ p ∈ Finset.range (2 * n / 3 + 1), p ^ (centralBinom n).factorization p := by sorry\ntheorem centralBinom_le_of_no_bertrand_prime (n : ℕ) (n_large : 2 < n)\n (no_prime : ∀ p : ℕ, p.Prime → n < p → 2 * n < p) :\n centralBinom n ≤ (2 * n) ^ sqrt (2 * n) * 4 ^ (2 * n / 3) := by sorry\nnamespace Nat\n\n/-- Proves that **Bertrand's postulate** holds for all sufficiently large `n`.\n-/\ntheorem exists_prime_lt_and_le_two_mul_eventually (n : ℕ) (n_large : 512 ≤ n) :\n ∃ p : ℕ, p.Prime ∧ n < p ∧ p ≤ 2 * n := by sorry\ntheorem exists_prime_lt_and_le_two_mul_succ {n} (q) {p : ℕ} (prime_p : Nat.Prime p)\n (covering : p ≤ 2 * q) (H : n < q → ∃ p : ℕ, p.Prime ∧ n < p ∧ p ≤ 2 * n) (hn : n < p) :\n ∃ p : ℕ, p.Prime ∧ n < p ∧ p ≤ 2 * n := by sorry\ntheorem exists_prime_lt_and_le_two_mul (n : ℕ) (hn0 : n ≠ 0) :\n ∃ p, Nat.Prime p ∧ n < p ∧ p ≤ 2 * n := by sorry\n open Lean Elab Tactic in\n run_tac do\n for i in [317, 163, 83, 43, 23, 13, 7, 5, 3, 2] do\n let i : Term := quote i\n evalTactic <| ←\n `(tactic| refine exists_prime_lt_and_le_two_mul_succ $i (by norm_num1) (by norm_num1) ?_)\n exact fun h2 => ⟨2, prime_two, h2, Nat.mul_le_mul_left 2 (Nat.pos_of_ne_zero hn0)⟩\n\nalias bertrand := Nat.exists_prime_lt_and_le_two_mul\n\nend Nat\n\nend Nat\n" }, { "theorem_id": 74, "title": "098_bertrand_s_postulate", "source": "hundred-theorems", "tier": "b", "prover": "rocq", "content": "From Coq Require Export RIneq.\nFrom Coq Require Import Wf_nat Ranalysis Rtrigo ArithRing Lra.\nFrom Bertrand Require Export Raux PowerBinomial Check128 PrimeDirac.\n\nTheorem upper_bound :\n forall n : nat,\n power 2 7 <= n ->\n (forall p : nat, n < p -> p < 2 * n -> ~ prime p) ->\n binomial (2 * n) n <\n power (2 * n) (div (sqr (2 * n)) 2 - 1) * power 4 (div (2 * n) 3).\nProof.\nAdmitted.\n\nTheorem no_prime_imp_spec_inegality :\n forall n : nat,\n power 2 7 <= n ->\n (forall p : nat, n < p -> p < 2 * n -> ~ prime p) ->\n power 4 n < power (2 * n) (div (sqr (2 * n)) 2) * power 4 (div (2 * n) 3).\nProof.\nAdmitted.\n\nTheorem spec_fun_bound :\n forall x : R,\n (Rpower 2 (1 + (1 + (1 + (1 + 3)))) <= x)%R ->\n (Rpower (2 * x) (sqrt (2 * x) / 2) < Rpower (1 + 3) (x / 3))%R.\nProof.\nAdmitted.\n\nTheorem Bertrand :\n forall n : nat, 2 <= n -> exists p : nat, prime p /\\ n < p /\\ p < 2 * n.\nProof.\nAdmitted." }, { "theorem_id": 75, "title": "aime_1983_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let aime-1983-p1 = `!x:num y:num z:num w:num.\n ((1 < x) /\\ (1 < y) /\\ (1 < z)) /\\\n (0 <= w) /\\\n (ln (&w) / ln (&x) = &24) /\\\n (ln (&w) / ln (&y) = &40) /\\\n (ln (&w) / ln (&(x * y * z)) = &12)\n==>\n (ln (&w) / ln (&z) = &60)\n`;;\n" }, { "theorem_id": 75, "title": "aime_1983_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory aime_1983_p1 imports Complex_Main\nbegin\n\ntheorem aime_1983_p1:\n fixes x y z w :: nat\n assumes ht : \"1 < x \\ 1 < y \\ 1 < z\"\n and hw : \"0 \\ w\"\n and h0 : \"ln w / ln x = 24\"\n and h1 : \"ln w / ln y = 40\"\n and h2 : \"ln w / ln (x * y * z) = 12\"\n shows \"ln w / ln z = 60\"\n by sorry\n\nend" }, { "theorem_id": 75, "title": "aime_1983_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem aime_1983_p1 (x y z w : ℕ) (ht : 1 < x ∧ 1 < y ∧ 1 < z) (hw : 0 ≤ w)\n (h0 : Real.log w / Real.log x = 24) (h1 : Real.log w / Real.log y = 40)\n (h2 : Real.log w / Real.log (x * y * z) = 12) : Real.log w / Real.log z = 60 := by sorry" }, { "theorem_id": 75, "title": "aime_1983_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\n\nOpen Scope R_scope.\n\nTheorem aime_1983_p1 :\n forall (x y z w : R),\n 1 < x ->\n 1 < y ->\n 1 < z ->\n 0 < w ->\n ln w / ln x = 24 ->\n ln w / ln y = 40 ->\n ln w / ln (x * y * z) = 12 ->\n ln w / ln z = 60.\n\nProof.\nAdmitted.\n" }, { "theorem_id": 76, "title": "aime_1983_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let aime-1983-p2 = `!x p f. (&0 < p /\\ p < &15) /\\ (p <= x /\\ x <= &15) /\\ (f x = abs (x - p) + abs (x - &15) + abs (x - p - &15)) ==> &15 <= f x`;;\n" }, { "theorem_id": 76, "title": "aime_1983_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory aime_1983_p2 imports Complex_Main\nbegin\n\ntheorem aime_1983_p2:\n fixes x p ::real and f :: \"real \\ real\"\n assumes h0: \"0 < p \\ p < 15\"\n and h1: \"p \\ x \\ x \\ 15\"\n and h2: \"f x = abs (x - p) + abs (x - 15) + abs (x - p - 15)\" \n shows \"15 \\ f x\"\n by sorry\n\nend" }, { "theorem_id": 76, "title": "aime_1983_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem aime_1983_p2\n (x p : ℝ)\n (f : ℝ → ℝ)\n (h₀ : 0 < p ∧ p < 15)\n (h₁ : p ≤ x ∧ x ≤ 15)\n (h₂ : f x = abs (x - p) + abs (x - 15) + abs (x - p - 15)) :\n 15 ≤ f x := by sorry" }, { "theorem_id": 76, "title": "aime_1983_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem aime_1983_p2 :\n forall (x p : R) (f : R -> R),\n 0 < p -> p < 15 ->\n p <= x -> x <= 15 ->\n f x = Rabs (x - p) + Rabs (x - 15) + Rabs (x - p - 15) ->\n 15 <= f x.\nProof.\nAdmitted." }, { "theorem_id": 77, "title": "aime_1983_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let aime-1983-p3 = `!f:real->real.\n (!x. f x = (x pow 2 + &18 * x + &30 - &2 * sqrt (x pow 2 + &18 * x + &45))) /\\\n (FINITE {x | f x = &0})\n==>\n product {x | f x = &0} (\\x. x) = &20\n`;;\n\n" }, { "theorem_id": 77, "title": "aime_1983_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory aime_1983_p3 imports Complex_Main\nbegin\n\ntheorem aime_1983_p3:\n fixes f :: \"real \\ real\"\n assumes h0 : \"\\ x. f x = (x^2 + (18 * x + 30) - 2 \n * sqrt (x^2 + (18 * x + 45)))\"\n shows \"(\\ (f -` {0})) = 20\"\n by sorry\n\nend" }, { "theorem_id": 77, "title": "aime_1983_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem aime_1983_p3\n (f : ℝ → ℝ)\n (h₀ : ∀ x, f x = (x^2 + (18 * x + 30) - 2 * Real.sqrt (x^2 + (18 * x + 45))))\n (h₁ : Fintype (f⁻¹' {0})) :\n ∏ x ∈ (f⁻¹' {0}).toFinset, x = 20 := by sorry" }, { "theorem_id": 77, "title": "aime_1983_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import List.\nRequire Import SetoidList.\nOpen Scope R_scope.\n\nTheorem aime_1983_p3 :\n forall (f : R -> R)\n (roots : list R),\n (forall x, f x = x^2 + 18*x + 30 - 2 * sqrt(x^2 + 18*x + 45)) ->\n (forall x, In x roots <-> f x = 0) ->\n NoDup roots ->\n fold_left Rmult roots 1 = 20.\n\nProof.\n" }, { "theorem_id": 78, "title": "aime_1983_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let aime-1983-p9 = `!x:real.\n (&0 < x /\\ x < pi) ==>\n &12 <= ((&9 * (x pow 2 * (sin x) pow 2)) + &4) / (x * sin x)`;;\n" }, { "theorem_id": 78, "title": "aime_1983_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory aime_1983_p9 imports\n Complex_Main\nbegin\n\ntheorem aime_1983_p9:\n fixes x::real\n assumes \"0 ((9 * (x^2 * (sin x)^2)) + 4) / (x * sin x)\"\n by sorry\n\nend" }, { "theorem_id": 78, "title": "aime_1983_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem aime_1983_p9 (x : ℝ) (h₀ : 0 < x ∧ x < Real.pi) :\n 12 ≤ (9 * (x ^ 2 * Real.sin x ^ 2) + 4) / (x * Real.sin x) := by sorry" }, { "theorem_id": 78, "title": "aime_1983_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem aime_1983_p9 :\n forall (x : R), 0 < x -> x < PI ->\n 12 <= (9 * (x^2 * sin x^2) + 4) / (x * sin x).\nProof.\nAdmitted.\n" }, { "theorem_id": 79, "title": "aime_1984_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let aime-1984-p1 = `!u:num->real.\n (!n. rational (u n)) /\\\n (!n. u (n + 1) = u n + &1) /\\\n (sum (0..(98 - 1)) (\\k. u (k + 1)) = &137)\n==>\n (sum (0..(49 - 1)) (\\k. u (2 * (k + 1))) = &93)\n`;;\n" }, { "theorem_id": 79, "title": "aime_1984_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory aime_1984_p1 imports Complex_Main\nbegin\n\ntheorem aime_1984_p1:\n fixes u :: \"nat \\ rat\"\n assumes h0: \"\\ n. u (n + 1) = u n + 1\"\n and h1: \"(\\ k < 98. u (k+1)) = 137\" \n shows \"(\\ k < 49. u (2 * (k+1))) = 93\"\n by sorry\n\nend" }, { "theorem_id": 79, "title": "aime_1984_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem aime_1984_p1\n (u : ℕ → ℚ)\n (h₀ : ∀ n, u (n + 1) = u n + 1)\n (h₁ : ∑ k ∈ Finset.range 98, u k.succ = 137) :\n ∑ k ∈ Finset.range 49, u (2 * k.succ) = 93 := by sorry" }, { "theorem_id": 79, "title": "aime_1984_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\n\nOpen Scope R_scope.\n\nTheorem aime_1984_p1 :\n forall (u : nat -> R),\n (forall n, u (n + 1)%nat = u n + 1) ->\n sum_f_R0 (fun k => u (k + 1)%nat) 97 = 137 ->\n sum_f_R0 (fun k => u (2 * (k + 1))%nat) 48 = 93.\nProof.\n" }, { "theorem_id": 80, "title": "aime_1984_p15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let aime-1984-p15 = `!x:real y:real z:real w:real.\n (x pow 2 / (&2 pow 2 - &1)) +\n (y pow 2 / (&2 pow 2 - &3 pow 2)) +\n (z pow 2 / (&2 pow 2 - &5 pow 2)) +\n (w pow 2 / (&2 pow 2 - &7 pow 2)) =\n &1 /\\\n (x pow 2 / (&4 pow 2 - &1)) +\n (y pow 2 / (&4 pow 2 - &3 pow 2)) +\n (z pow 2 / (&4 pow 2 - &5 pow 2)) +\n (w pow 2 / (&4 pow 2 - &7 pow 2)) =\n &1 /\\\n (x pow 2 / (&6 pow 2 - &1)) +\n (y pow 2 / (&6 pow 2 - &3 pow 2)) +\n (z pow 2 / (&6 pow 2 - &5 pow 2)) +\n (w pow 2 / (&6 pow 2 - &7 pow 2)) =\n &1 /\\\n (x pow 2 / (&8 pow 2 - &1)) +\n (y pow 2 / (&8 pow 2 - &3 pow 2)) +\n (z pow 2 / (&8 pow 2 - &5 pow 2)) +\n (w pow 2 / (&8 pow 2 - &7 pow 2)) =\n &1\n==>\n x pow 2 + y pow 2 + z pow 2 + w pow 2 = &36\n`;;\n" }, { "theorem_id": 80, "title": "aime_1984_p15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory aime_1984_p15 imports Complex_Main\nbegin\n\ntheorem aime_1984_p15:\n fixes x y z w::real\n assumes \"(x^2 / (2^2 - 1)) + (y^2 / (2^2 - 3^2)) \n + (z^2 / (2^2 - 5^2)) + (w^2 / (2^2 - 7^2)) = 1\"\n \"(x^2 / (4^2 - 1)) + (y^2 / (4^2 - 3^2)) \n + (z^2 / (4^2 - 5^2)) + (w^2 / (4^2 - 7^2)) = 1\"\n \"(x^2 / (6^2 - 1)) + (y^2 / (6^2 - 3^2)) \n + (z^2 / (6^2 - 5^2)) + (w^2 / (6^2 - 7^2)) = 1\"\n \"(x^2 / (8^2 - 1)) + (y^2 / (8^2 - 3^2)) \n + (z^2 / (8^2 - 5^2)) + (w^2 / (8^2 - 7^2)) = 1\"\n shows \"x^2 + y^2 + z^2 + w^2 = 36\"\n by sorry\n\nend" }, { "theorem_id": 80, "title": "aime_1984_p15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem aime_1984_p15 (x y z w : ℝ)\n (h₀ :\n x ^ 2 / (2 ^ 2 - 1) + y ^ 2 / (2 ^ 2 - 3 ^ 2) + z ^ 2 / (2 ^ 2 - 5 ^ 2) +\n w ^ 2 / (2 ^ 2 - 7 ^ 2) =\n 1)\n (h₁ :\n x ^ 2 / (4 ^ 2 - 1) + y ^ 2 / (4 ^ 2 - 3 ^ 2) + z ^ 2 / (4 ^ 2 - 5 ^ 2) +\n w ^ 2 / (4 ^ 2 - 7 ^ 2) =\n 1)\n (h₂ :\n x ^ 2 / (6 ^ 2 - 1) + y ^ 2 / (6 ^ 2 - 3 ^ 2) + z ^ 2 / (6 ^ 2 - 5 ^ 2) +\n w ^ 2 / (6 ^ 2 - 7 ^ 2) =\n 1)\n (h₃ :\n x ^ 2 / (8 ^ 2 - 1) + y ^ 2 / (8 ^ 2 - 3 ^ 2) + z ^ 2 / (8 ^ 2 - 5 ^ 2) +\n w ^ 2 / (8 ^ 2 - 7 ^ 2) =\n 1) :\n x ^ 2 + y ^ 2 + z ^ 2 + w ^ 2 = 36 := by sorry" }, { "theorem_id": 80, "title": "aime_1984_p15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem aime_1984_p15:\n forall (x y z w : R),\n (x^2 / (2^2 - 1) + y^2 / (2^2 - 3^2) + z^2 / (2^2 - 5^2) + w^2 / (2^2 - 7^2) = 1) ->\n (x^2 / (4^2 - 1) + y^2 / (4^2 - 3^2) + z^2 / (4^2 - 5^2) + w^2 / (4^2 - 7^2) = 1) ->\n (x^2 / (6^2 - 1) + y^2 / (6^2 - 3^2) + z^2 / (6^2 - 5^2) + w^2 / (6^2 - 7^2) = 1) ->\n (x^2 / (8^2 - 1) + y^2 / (8^2 - 3^2) + z^2 / (8^2 - 5^2) + w^2 / (8^2 - 7^2) = 1) ->\n x^2 + y^2 + z^2 + w^2 = 36.\nProof.\nAdmitted." }, { "theorem_id": 81, "title": "aime_1984_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let aime-1984-p5 = `!a:real b:real.\n (ln a / ln (&8) + ln (b pow 2) / ln (&4) = &5) /\\\n (ln b / ln (&8) + ln (a pow 2) / ln (&4) = &7)\n==>\n a * b = &512\n`;;\n" }, { "theorem_id": 81, "title": "aime_1984_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory aime_1984_p5 imports Complex_Main\nbegin\n\ntheorem aime_1984_p5:\n fixes a b ::real\n assumes \"(ln a) / (ln 8) + (ln (b^2)) / (ln 4) = 5\"\n \"(ln b) / (ln 8) + (ln (a^2)) / (ln 4) = 7\"\n shows \"a * b = 512\"\n by sorry\n\nend" }, { "theorem_id": 81, "title": "aime_1984_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem aime_1984_p5 (a b : ℝ) (h₀ : Real.logb 8 a + Real.logb 4 (b ^ 2) = 5)\n (h₁ : Real.logb 8 b + Real.logb 4 (a ^ 2) = 7) : a * b = 512 := by sorry" }, { "theorem_id": 81, "title": "aime_1984_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem aime_1984_p5 :\n forall a b : R,\n 0 < a -> 0 < b ->\n (ln a) / (ln 8) + (ln (b * b)) / (ln 4) = 5 ->\n (ln b) / (ln 8) + (ln (a * a)) / (ln 4) = 7 ->\n a * b = 512.\nProof.\nAdmitted." }, { "theorem_id": 82, "title": "aime_1984_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let aime-1984-p7 = `!f. (!n. 1000 <= n ==> f n = n - 3) /\\ (!n. 0 < n /\\ n < 1000 ==> f n = f (f (n + 5))) ==> f 84 = 997`;;\n" }, { "theorem_id": 82, "title": "aime_1984_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory aime_1984_p7 imports Complex_Main\nbegin\n\ntheorem aime_1984_p7:\n fixes f :: \"nat \\ nat\"\n assumes h0: \"\\ n\\1000. f n = n - 3\"\n and h1: \"\\ n < 1000. f n = f (f (n + 5))\"\n shows \"f 84 = 997\"\n by sorry\n\nend" }, { "theorem_id": 82, "title": "aime_1984_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem aime_1984_p7\n (f : ℤ → ℤ)\n (h₀ : ∀ n, 1000 ≤ n → f n = n - 3)\n (h₁ : ∀ n, n < 1000 → f n = f (f (n + 5))) :\n f 84 = 997 := by sorry" }, { "theorem_id": 82, "title": "aime_1984_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.ZArith.ZArith.\n\nOpen Scope Z_scope.\n\nTheorem aime_1984_p7:\n forall (f : Z -> Z),\n (forall n, 1000 <= n -> f n = n - 3) ->\n (forall n, n < 1000 -> f n = f (f (n + 5))) ->\n f 84 = 997.\nProof.\nAdmitted." }, { "theorem_id": 83, "title": "aime_1994_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let aime-1994-p3 = `!x:int f:int->int.\n (f (x) + f (x - &1) = x pow 2) /\\\n (f (&19) = &94)\n==>\n ((f (&94) == &561) (mod &1000))\n`;;\n" }, { "theorem_id": 83, "title": "aime_1994_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory aime_1994_p3 imports Complex_Main\nbegin\n\ntheorem aime_1994_p3:\n fixes x :: int and f :: \"int \\ int\"\n assumes h0: \"f x + f (x-1) = x^2\"\n and h1: \"f 19 = 94\"\n shows \"f 94 mod 1000 = 561\"\n by sorry\n\nend" }, { "theorem_id": 83, "title": "aime_1994_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem aime_1994_p3\n (f : ℤ → ℤ)\n (h0 : ∀ x, f x + f (x - 1) = x^2)\n (h1 : f 19 = 94) :\n f 94 % 1000 = 561 := by sorry" }, { "theorem_id": 83, "title": "aime_1994_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem aime_1994_p3:\n forall (f : Z -> Z),\n (forall x, f x + f (x - 1) = x * x) -> (f 19 = 94) -> (f 94 mod 1000 = 561).\nProof.\nAdmitted." }, { "theorem_id": 84, "title": "aime_1995_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let aime-1995-p7 = `!k:num m:num n:num t:real.\n (k > 0 /\\ m > 0 /\\ n > 0) /\\\n (gcd(m,n) = 1) /\\\n ((&1 + sin t) * (&1 + cos t) = &5 / &4) /\\\n ((&1 - sin t) * (&1 - cos t) = &m / &n - sqrt (&k))\n==>\n k + m + n = 27\n`;;\n" }, { "theorem_id": 84, "title": "aime_1995_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory aime_1995_p7 imports Complex_Main\nbegin\n\ntheorem aime_1995_p7:\n fixes k m n :: nat and t :: real\n assumes h0: \"gcd m n = 1\"\n and h1: \"(1 + sin t) * (1 + cos t) = 5/4\"\n and h2: \"(1 - sin t) * (1- cos t) = m/n - sqrt k\"\n shows \"k + m + n = 27\"\n by sorry\n\nend " }, { "theorem_id": 84, "title": "aime_1995_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem aime_1995_p7\n (k m n : ℕ)\n (t : ℝ)\n (h₀ : 0 < k ∧ 0 < m ∧ 0 < n)\n (h₁ : Nat.gcd m n = 1)\n (h₂ : (1 + Real.sin t) * (1 + Real.cos t) = 5/4)\n (h₃ : (1 - Real.sin t) * (1- Real.cos t) = m/n - Real.sqrt k):\n k + m + n = 27 := by sorry" }, { "theorem_id": 84, "title": "aime_1995_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\n\nOpen Scope R_scope.\n\nTheorem aime_1995_p7 :\n forall (k m n : nat) (t : R),\n (0 < k)%nat -> (0 < m)%nat -> (0 < n)%nat ->\n (Nat.gcd m n = 1)%nat ->\n (1 + sin t) * (1 + cos t) = 5 / 4 ->\n (1 - sin t) * (1 - cos t) = INR m / INR n - sqrt (INR k) ->\n (k + m + n = 27)%nat.\nProof.\n" }, { "theorem_id": 85, "title": "algebra_2complexrootspoly_xsqp49eqxp7itxpn7i", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-2complexrootspoly-xsqp49eqxp7itxpn7i = `!x:complex. x pow 2 + Cx(&49) = (x + (Cx(&7) * ii)) * (x + (Cx(-- (&7)) * ii))`;;\n" }, { "theorem_id": 85, "title": "algebra_2complexrootspoly_xsqp49eqxp7itxpn7i", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_2complexrootspoly_xsqp49eqxp7itxpn7i imports\n Complex_Main\nbegin\n\ntheorem algebra_2complexrootspoly_xsqp49eqxp7itxpn7i:\n fixes x :: complex\n shows \"x^2 + 49 = (x + Im 7) * (x - Im 7)\"\n by sorry\n\nend" }, { "theorem_id": 85, "title": "algebra_2complexrootspoly_xsqp49eqxp7itxpn7i", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_2complexrootspoly_xsqp49eqxp7itxpn7i (x : ℂ) :\n x ^ 2 + 49 = (x + 7 * Complex.I) * (x + -7 * Complex.I) := by sorry" }, { "theorem_id": 85, "title": "algebra_2complexrootspoly_xsqp49eqxp7itxpn7i", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem algebra_2complexrootspoly_xsqp49eqxp7itxpn7i :\n forall x : C,\n x^2 + 49 = (x + 7*Ci) * (x - 7*Ci).\n\nProof.\n" }, { "theorem_id": 86, "title": "algebra_2rootsintpoly_am10tap11eqasqpam110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-2rootsintpoly-am10tap11eqasqpam110 = `!a:complex. (a - Cx(&10)) * (a + Cx(&11)) = a pow 2 + a - Cx(&110)`;;\n" }, { "theorem_id": 86, "title": "algebra_2rootsintpoly_am10tap11eqasqpam110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_2rootsintpoly_am10tap11eqasqpam110 imports\n Complex_Main\nbegin\n\ntheorem algebra_2rootsintpoly_am10tap11eqasqpam110:\n fixes a :: complex\n shows \"(a-10) * (a+11) = a^2 + a -110\"\n by sorry\n\nend" }, { "theorem_id": 86, "title": "algebra_2rootsintpoly_am10tap11eqasqpam110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_2rootsintpoly_am10tap11eqasqpam110 (a : ℂ) :\n (a - 10) * (a + 11) = a ^ 2 + a - 110 := by sorry" }, { "theorem_id": 86, "title": "algebra_2rootsintpoly_am10tap11eqasqpam110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem algebra_2rootsintpoly_am10tap11eqasqpam110\n (a : C) :\n (a - 10) * (a + 11) = a^2 + a - 110.\n\nProof.\n" }, { "theorem_id": 87, "title": "algebra_2rootspoly_apatapbeq2asqp2ab", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-2rootspoly-apatapbeq2asqp2ab = `!a:complex b:complex. (a + a) * (a + b) = Cx(&2) * a pow 2 + Cx(&2) * (a * b)`;;\n" }, { "theorem_id": 87, "title": "algebra_2rootspoly_apatapbeq2asqp2ab", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_2rootspoly_apatapbeq2asqp2ab imports\n Complex_Main\nbegin\n\ntheorem algebra_2rootspoly_apatapbeq2asqp2ab:\n fixes a b :: complex\n shows \"(a+a) * (a+b) = 2 * a^2 + 2 * (a*b)\"\n by sorry\n \nend" }, { "theorem_id": 87, "title": "algebra_2rootspoly_apatapbeq2asqp2ab", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_2rootspoly_apatapbeq2asqp2ab (a b : ℂ) :\n (a + a) * (a + b) = 2 * a ^ 2 + 2 * (a * b) := by sorry" }, { "theorem_id": 87, "title": "algebra_2rootspoly_apatapbeq2asqp2ab", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem algebra_2rootspoly_apatapbeq2asqp2ab :\n forall (a b : C), (a + a) * (a + b) = 2 * (a ^ 2) + 2 * (a * b).\n\n\n\nProof.\n" }, { "theorem_id": 88, "title": "algebra_2varlineareq_fp3zeq11_3tfm1m5zeqn68_feqn10_zeq7", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let algebra-2varlineareq-fp3zeq11-3tfm1m5zeqn68-feqn10-zeq7 = `!f:complex z:complex.\n (f + Cx(&3) * z = Cx(&11)) /\\\n (Cx(&3) * (f - Cx(&1)) - Cx(&5) * z = Cx(-- &68))\n==>\n (f = Cx(-- &10)) /\\\n (z = Cx(&7))\n`;;\n" }, { "theorem_id": 88, "title": "algebra_2varlineareq_fp3zeq11_3tfm1m5zeqn68_feqn10_zeq7", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory algebra_2varlineareq_fp3zeq11_3tfm1m5zeqn68_feqn10_zeq7\n imports Complex_Main\nbegin\n\ntheorem algebra_2varlineareq_fp3zeq11_3tfm1m5zeqn68_feqn10_zeq7:\n fixes f z::complex\n assumes h0: \"f + 3*z = 11\"\n and h1: \"3*(f - 1) - 5*z = -68\" \n shows \"f = -10 \\ z = 7\"\n by sorry\n\nend" }, { "theorem_id": 88, "title": "algebra_2varlineareq_fp3zeq11_3tfm1m5zeqn68_feqn10_zeq7", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_2varlineareq_fp3zeq11_3tfm1m5zeqn68_feqn10_zeq7\n (f z: ℂ)\n (h₀ : f + 3*z = 11)\n (h₁ : 3*(f - 1) - 5*z = -68) :\n f = -10 ∧ z = 7 := by sorry" }, { "theorem_id": 88, "title": "algebra_2varlineareq_fp3zeq11_3tfm1m5zeqn68_feqn10_zeq7", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem algebra_2varlineareq_fp3zeq11_3tfm1m5zeqn68_feqn10_zeq7:\n forall (f z : C),\n f + 3 * z = 11 ->\n 3 * (f - 1) - 5 * z = -68 ->\n f = -10 /\\ z = 7.\n\nProof.\n" }, { "theorem_id": 89, "title": "algebra_2varlineareq_xpeeq7_2xpeeq3_eeq11_xeqn4", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-2varlineareq-xpeeq7-2xpeeq3-eeq11-xeqn4 = `!x:complex e:complex.\n (x + e = Cx(&7)) /\\\n (Cx(&2) * x + e = Cx(&3))\n==>\n (e = Cx(&11) /\\ x = Cx(-- (&4)))\n`;;\n" }, { "theorem_id": 89, "title": "algebra_2varlineareq_xpeeq7_2xpeeq3_eeq11_xeqn4", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_2varlineareq_xpeeq7_2xpeeq3_eeq11_xeqn4 imports\nComplex_Main\n\nbegin\n\ntheorem algebra_2varlineareq_xpeeq7_2xpeeq3_eeq11_xeqn4:\n fixes x e :: complex\n assumes h0 : \"x + e = 7\"\n and h1 : \"2 * x + e = 3\"\n shows \"e=11 \\ x= (-4)\"\n by sorry\n\nend" }, { "theorem_id": 89, "title": "algebra_2varlineareq_xpeeq7_2xpeeq3_eeq11_xeqn4", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_2varlineareq_xpeeq7_2xpeeq3_eeq11_xeqn4 (x e : ℂ) (h₀ : x + e = 7)\n (h₁ : 2 * x + e = 3) : e = 11 ∧ x = -4 := by sorry" }, { "theorem_id": 89, "title": "algebra_2varlineareq_xpeeq7_2xpeeq3_eeq11_xeqn4", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem algebra_2varlineareq_xpeeq7_2xpeeq3_eeq11_xeqn4\n (x e : C)\n (h0 : x + e = 7)\n (h1 : 2 * x + e = 3) :\n e = 11 /\\ x = -4.\n\nProof.\n" }, { "theorem_id": 90, "title": "algebra_3rootspoly_amdtamctambeqnasqmbpctapcbtdpasqmbpctapcbta", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-3rootspoly-amdtamctambeqnasqmbpctapcbtdpasqmbpctapcbta = `!b:complex c:complex d:complex a:complex. (a - d) * (a - c) * (a - b) = -- (((a pow 2 - (b + c) * a) + c * b) * d) + (a pow 2 - (b + c) * a + c * b) * a`;;\n" }, { "theorem_id": 90, "title": "algebra_3rootspoly_amdtamctambeqnasqmbpctapcbtdpasqmbpctapcbta", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_3rootspoly_amdtamctambeqnasqmbpctapcbtdpasqmbpctapcbta imports\n Complex_Main\nbegin\n\ntheorem algebra_3rootspoly_amdtamctambeqnasqmbpctapcbtdpasqmbpctapcbta:\n fixes a b c d :: complex\n shows \"(a-d) * (a-c) * (a-b) = -(((a^2 - (b+c) * a) + c * b) * d) + (a^2 - (b+c) * a + c * b) * a\"\n by sorry\n\nend" }, { "theorem_id": 90, "title": "algebra_3rootspoly_amdtamctambeqnasqmbpctapcbtdpasqmbpctapcbta", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_3rootspoly_amdtamctambeqnasqmbpctapcbtdpasqmbpctapcbta (b c d a : ℂ) :\n (a - d) * (a - c) * (a - b) =\n -((a ^ 2 - (b + c) * a + c * b) * d) + (a ^ 2 - (b + c) * a + c * b) * a := by sorry" }, { "theorem_id": 90, "title": "algebra_3rootspoly_amdtamctambeqnasqmbpctapcbtdpasqmbpctapcbta", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem algebra_3rootspoly_amdtamctambeqnasqmbpctapcbtdpasqmbpctapcbta\n (a b c d : C) :\n (a - d) * (a - c) * (a - b) = -(((a ^ 2 - (b + c) * a) + c * b) * d) + (a ^ 2 - (b + c) * a + c * b) * a.\n\nProof.\n" }, { "theorem_id": 91, "title": "algebra_amgm_faxinrrp2msqrt2geq2mxm1div2x", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-amgm-faxinrrp2msqrt2geq2mxm1div2x = `!x:real.\n (x > &0)\n==>\n &2 - sqrt(&2) >= &2 - x - &1 / (&2 * x)\n`;;\n" }, { "theorem_id": 91, "title": "algebra_amgm_faxinrrp2msqrt2geq2mxm1div2x", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_amgm_faxinrrp2msqrt2geq2mxm1div2x imports\n Complex_Main\nbegin\n\ntheorem algebra_amgm_faxinrrp2msqrt2geq2mxm1div2x:\n \"\\x. (x>0) \\ 2 - sqrt 2 \\ 2 - x - 1/ (2 * x)\"\n by sorry\n\nend" }, { "theorem_id": 91, "title": "algebra_amgm_faxinrrp2msqrt2geq2mxm1div2x", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_amgm_faxinrrp2msqrt2geq2mxm1div2x :\n ∀ x > 0, 2 - Real.sqrt 2 ≥ 2 - x - 1 / (2 * x) := by sorry" }, { "theorem_id": 91, "title": "algebra_amgm_faxinrrp2msqrt2geq2mxm1div2x", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_amgm_faxinrrp2msqrt2geq2mxm1div2x :\n forall x : R, x > 0 -> 2 - sqrt 2 >= 2 - x - 1 / (2 * x).\nProof.\nAdmitted." }, { "theorem_id": 92, "title": "algebra_amgm_prod1toneq1_sum1tongeqn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-amgm-prod1toneq1-sum1tongeqn = `!a:num->real n:num.\n (!k. a k >= &0) /\\\n (product (0..(n-1)) a = &1)\n==>\n (sum (0..(n-1)) a >= &n)\n`;;\n" }, { "theorem_id": 92, "title": "algebra_amgm_prod1toneq1_sum1tongeqn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_amgm_prod1toneq1_sum1tongeqn \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem algebra_amgm_prod1toneq1_sum1tongeqn:\n fixes a :: \"nat \\ real\"\n and n :: nat\n assumes \"\\i. a i \\0\"\n and \"prod a {.. n\"\n by sorry\n\nend " }, { "theorem_id": 92, "title": "algebra_amgm_prod1toneq1_sum1tongeqn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_amgm_prod1toneq1_sum1tongeqn (a : ℕ → NNReal) (n : ℕ)\n (h₀ : Finset.prod (Finset.range n) a = 1) : Finset.sum (Finset.range n) a ≥ n := by sorry" }, { "theorem_id": 92, "title": "algebra_amgm_prod1toneq1_sum1tongeqn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "\nRequire Import Reals.\nRequire Import List.\nImport ListNotations.\nOpen Scope R_scope.\n\n\nDefinition Rsum (n : nat) (a : nat -> R) :=\n fold_right Rplus 0 (map a (seq 0 n)).\n\nDefinition Rprod (n : nat) (a : nat -> R) :=\n fold_right Rmult 1 (map a (seq 0 n)).\n\n\nTheorem algebra_amgm_prod1toneq1_sum1tongeqn :\n forall (a : nat -> R) (n : nat),\n (forall i, 0 <= a i) ->\n Rprod n a = 1 ->\n Rsum n a >= INR n.\n\nProof.\n" }, { "theorem_id": 93, "title": "algebra_amgm_sqrtxymulxmyeqxpy_xpygeq4", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-amgm-sqrtxymulxmyeqxpy-xpygeq4 = `!x:real y:real.\n (&0 < x /\\ &0 < y) /\\\n (y <= x) /\\\n (sqrt (x * y) * (x - y) = (x + y))\n==>\n (x + y >= &4)\n`;;\n" }, { "theorem_id": 93, "title": "algebra_amgm_sqrtxymulxmyeqxpy_xpygeq4", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_amgm_sqrtxymulxmyeqxpy_xpygeq4 imports\n Complex_Main\nbegin\n\ntheorem algebra_amgm_sqrtxymulxmyeqxpy_xpygeq4:\n fixes x y :: real\n assumes h0 : \"0 < x \\ 0 < y\"\n and h1 : \"y \\ x\"\n and h2 : \"sqrt (x * y) * (x - y) = (x + y)\"\n shows \"x + y \\ 4\"\n by sorry\n\nend" }, { "theorem_id": 93, "title": "algebra_amgm_sqrtxymulxmyeqxpy_xpygeq4", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_amgm_sqrtxymulxmyeqxpy_xpygeq4 (x y : ℝ) (h₀ : 0 < x ∧ 0 < y) (h₁ : y ≤ x)\n (h₂ : Real.sqrt (x * y) * (x - y) = x + y) : x + y ≥ 4 := by sorry" }, { "theorem_id": 93, "title": "algebra_amgm_sqrtxymulxmyeqxpy_xpygeq4", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_amgm_sqrtxymulxmyeqxpy_xpygeq4 :\n forall x y : R,\n (0 < x /\\ 0 < y) ->\n y <= x ->\n sqrt (x * y) * (x - y) = (x + y) ->\n x + y >= 4.\nProof.\nAdmitted." }, { "theorem_id": 94, "title": "algebra_amgm_sum1toneqn_prod1tonleq1", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let algebra-amgm-sum1toneqn-prod1tonleq1 = `!a:num->real n:num. (!k:num. a k >= &0) /\\ ((sum (0..(n-1)) (\\x. a x)) = &n) ==> (product (0..(n-1)) (\\x. a x)) <= &1`;;\n" }, { "theorem_id": 94, "title": "algebra_amgm_sum1toneqn_prod1tonleq1", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory algebra_amgm_sum1toneqn_prod1tonleq1\n imports Complex_Main\nbegin\n\ntheorem algebra_amgm_sum1toneqn_prod1tonleq1:\n fixes a :: \"nat \\ real\" and n :: nat\n assumes h0: \"(\\ x< n. a x) = n\" and \"\\x. a x\\0\"\n shows \"(\\ x 1\"\n by sorry\n\nend" }, { "theorem_id": 94, "title": "algebra_amgm_sum1toneqn_prod1tonleq1", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_amgm_sum1toneqn_prod1tonleq1\n (a : ℕ → NNReal)\n (n : ℕ)\n (h₀ : ∑ x ∈ Finset.range n, a x = n) :\n ∏ x ∈ Finset.range n, a x ≤ 1 := by sorry" }, { "theorem_id": 94, "title": "algebra_amgm_sum1toneqn_prod1tonleq1", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nOpen Scope R_scope.\n\n\nFixpoint sum_n (a : nat -> R) (n : nat) : R :=\n match n with\n | 0 => 0\n | S p => sum_n a p + a p\n end.\n\n\nFixpoint prod_n (a : nat -> R) (n : nat) : R :=\n match n with\n | 0 => 1\n | S p => prod_n a p * a p\n end.\n\n\nTheorem algebra_amgm_sum1toneqn_prod1tonleq1:\n forall (n : nat) (a : nat -> R),\n (forall i, (i < n)%nat -> 0 <= a i) ->\n sum_n a n = INR n ->\n prod_n a n <= 1.\n\nProof.\n" }, { "theorem_id": 95, "title": "algebra_amgm_sumasqdivbgeqsuma", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let algebra-amgm-sumasqdivbgeqsuma = `!a b c d. &0 < a /\\ &0 < b /\\ &0 < c /\\ &0 < d ==> a pow 2 / b + b pow 2 / c + c pow 2 / d + d pow 2 / a >= a + b + c + d`;;\n" }, { "theorem_id": 95, "title": "algebra_amgm_sumasqdivbgeqsuma", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory algebra_amgm_sumasqdivbgeqsuma\n imports Complex_Main\nbegin\n\ntheorem algebra_amgm_sumasqdivbgeqsuma:\n fixes a b c d ::real\n assumes h0: \"0 < a \\ 0 < b \\ 0 < c \\ 0 < d\" \n shows \"a^2 / b + b^2 / c + c^2 / d + d^2 / a \\ a + b + c + d\"\n by sorry\n\nend" }, { "theorem_id": 95, "title": "algebra_amgm_sumasqdivbgeqsuma", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_amgm_sumasqdivbgeqsuma\n (a b c d : ℝ)\n (h₀ : 0 < a ∧ 0 < b ∧ 0 < c ∧ 0 < d) :\n a^2 / b + b^2 / c + c^2 / d + d^2 / a ≥ a + b + c + d := by sorry" }, { "theorem_id": 95, "title": "algebra_amgm_sumasqdivbgeqsuma", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_amgm_sumasqdivbgeqsuma :\n forall a b c d : R,\n 0 < a /\\ 0 < b /\\ 0 < c /\\ 0 < d ->\n a^2 / b + b^2 / c + c^2 / d + d^2 / a >= a + b + c + d.\nProof.\nAdmitted." }, { "theorem_id": 96, "title": "algebra_amgm_sumasqdivbsqgeqsumbdiva", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-amgm-sumasqdivbsqgeqsumbdiva = `!a:real b:real c:real.\n (&0 < a /\\ &0 < b /\\ &0 < c)\n==>\n (a pow 2 / b pow 2 + b pow 2 / c pow 2 + c pow 2 / a pow 2 >= b / a + c / b + a / c)\n`;;\n" }, { "theorem_id": 96, "title": "algebra_amgm_sumasqdivbsqgeqsumbdiva", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_amgm_sumasqdivbsqgeqsumbdiva imports\nComplex_Main\n\nbegin\n\ntheorem algebra_amgm_sumasqdivbsqgeqsumbdiva:\n fixes a b c :: real\n assumes h0 : \"0 < a \\ 0 < b \\ 0 < c\"\n shows \"a^2 / b^2 + b^2 / c^2 + c^2 / a^2 \\ b / a + c / b + a / c\"\n by sorry\n\nend" }, { "theorem_id": 96, "title": "algebra_amgm_sumasqdivbsqgeqsumbdiva", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_amgm_sumasqdivbsqgeqsumbdiva (a b c : ℝ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c) :\n a ^ 2 / b ^ 2 + b ^ 2 / c ^ 2 + c ^ 2 / a ^ 2 ≥ b / a + c / b + a / c := by sorry" }, { "theorem_id": 96, "title": "algebra_amgm_sumasqdivbsqgeqsumbdiva", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_amgm_sumasqdivbsqgeqsumbdiva\n (a b c : R)\n (h₀ : 0 < a /\\ 0 < b /\\ 0 < c) :\n a^2 / b^2 + b^2 / c^2 + c^2 / a^2 >= b / a + c / b + a / c.\nProof.\nAdmitted." }, { "theorem_id": 97, "title": "algebra_binomnegdiscrineq_10alt28asqp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-binomnegdiscrineq-10alt28asqp1 = `!a:real. &10 * a <= &28 * a pow 2 + &1`;;\n" }, { "theorem_id": 97, "title": "algebra_binomnegdiscrineq_10alt28asqp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_binomnegdiscrineq_10alt28asqp1 imports\n Complex_Main\nbegin\n\ntheorem algebra_binomnegdiscrineq_10alt28asqp1:\n fixes a :: real\n shows \"10 * a \\ 28 * a^2 + 1\"\n by sorry\n\nend" }, { "theorem_id": 97, "title": "algebra_binomnegdiscrineq_10alt28asqp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_binomnegdiscrineq_10alt28asqp1 (a : ℝ) : 10 * a ≤ 28 * a ^ 2 + 1 := by sorry" }, { "theorem_id": 97, "title": "algebra_binomnegdiscrineq_10alt28asqp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_binomnegdiscrineq_10alt28asqp1:\n forall a : R, 10 * a <= 28 * a^2 + 1.\nProof.\nAdmitted." }, { "theorem_id": 98, "title": "algebra_ineq_nto1onlt2m1on", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let algebra-ineq-nto1onlt2m1on = `!n:num. exp ((&1 / &n) * ln(&n)) < &2 - &1 / &n`;;\n" }, { "theorem_id": 98, "title": "algebra_ineq_nto1onlt2m1on", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory algebra_ineq_nto1onlt2m1on\n imports Complex_Main\nbegin\n\ntheorem algebra_ineq_nto1onlt2m1on:\n fixes n ::nat \n shows \"(n::real) powr ((1::real) / n) < 2 - 1 / n\"\n by sorry\n\nend" }, { "theorem_id": 98, "title": "algebra_ineq_nto1onlt2m1on", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_ineq_nto1onlt2m1on\n (n : ℕ) :\n (n : ℝ) ^ (1 / n : ℝ) ≤ 2 - 1 / n := by sorry" }, { "theorem_id": 98, "title": "algebra_ineq_nto1onlt2m1on", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Arith.\n\nOpen Scope R_scope.\n\nTheorem algebra_ineq_nto1onlt2m1on :\n forall n : nat,\n (n >= 1)%nat ->\n Rpower (INR n) (1 / INR n) <= 2 - 1 / INR n.\n\nProof.\n" }, { "theorem_id": 99, "title": "algebra_manipexpr_2erprsqpesqeqnrpnesq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-manipexpr-2erprsqpesqeqnrpnesq = `!e:complex r:complex. Cx(&2) * (e * r) + (e pow 2 + r pow 2) = (-- r + (-- e)) pow 2`;;\n" }, { "theorem_id": 99, "title": "algebra_manipexpr_2erprsqpesqeqnrpnesq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_manipexpr_2erprsqpesqeqnrpnesq imports\nComplex_Main\n\nbegin\n\ntheorem algebra_manipexpr_2erprsqpesqeqnrpnesq:\n fixes e r :: complex\n shows \"2 * (e * r) + (e^2 + r^2) = (-r + (-e))^2\"\n by sorry\n\nend" }, { "theorem_id": 99, "title": "algebra_manipexpr_2erprsqpesqeqnrpnesq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_manipexpr_2erprsqpesqeqnrpnesq (e r : ℂ) :\n 2 * (e * r) + (e ^ 2 + r ^ 2) = (-r + -e) ^ 2 := by sorry" }, { "theorem_id": 99, "title": "algebra_manipexpr_2erprsqpesqeqnrpnesq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem algebra_manipexpr_2erprsqpesqeqnrpnesq\n (e r : C) :\n 2 * (e * r) + (e^2 + r^2) = (-r + (-e))^2.\n\nProof.\n" }, { "theorem_id": 100, "title": "algebra_manipexpr_apbeq2cceqiacpbceqm2", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-manipexpr-apbeq2cceqiacpbceqm2 = `!a:complex b:complex c:complex.\n (a + b = Cx(&2) * c) /\\\n (c = ii)\n==>\n (a * c + b * c = Cx(-- &2))\n`;;\n" }, { "theorem_id": 100, "title": "algebra_manipexpr_apbeq2cceqiacpbceqm2", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_manipexpr_apbeq2cceqiacpbceqm2 imports\nComplex_Main\n\nbegin\n\ntheorem algebra_manipexpr_apbeq2cceqiacpbceqm2:\n fixes a b c :: complex\n assumes h0 : \"a+b = 2*c\"\n and h1 : \"c = Im 1\"\n shows \"a*c+b*c=-2\"\n by sorry\n\nend" }, { "theorem_id": 100, "title": "algebra_manipexpr_apbeq2cceqiacpbceqm2", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_manipexpr_apbeq2cceqiacpbceqm2 (a b c : ℂ) (h₀ : a + b = 2 * c)\n (h₁ : c = Complex.I) : a * c + b * c = -2 := by sorry" }, { "theorem_id": 100, "title": "algebra_manipexpr_apbeq2cceqiacpbceqm2", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem algebra_manipexpr_apbeq2cceqiacpbceqm2:\n forall (a b c : C),\n a + b = 2 * c ->\n c = Ci ->\n a * c + b * c = -2.\n\nProof.\n" }, { "theorem_id": 101, "title": "algebra_others_exirrpowirrrat", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let algebra-others-exirrpowirrrat = `?a:real b:real. ~rational a /\\ ~rational b /\\ rational (exp (b * ln a))`;;\n" }, { "theorem_id": 101, "title": "algebra_others_exirrpowirrrat", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory algebra_others_exirrpowirrrat\n imports Complex_Main\nbegin\n\ntheorem algebra_others_exirrpowirrrat:\n \"\\ a b. a \\ \\ \\ b \\ \\ \\ a^b \\ \\\"\n by sorry\n\nend" }, { "theorem_id": 101, "title": "algebra_others_exirrpowirrrat", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_others_exirrpowirrrat :\n ∃ a b, Irrational a ∧ Irrational b ∧ ¬ Irrational (a^b) := by sorry" }, { "theorem_id": 101, "title": "algebra_others_exirrpowirrrat", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Psatz.\nRequire Import Classical.\n\nDefinition irrational (x : R) := \n ~ exists (p q : Z), q <> 0%Z /\\ x = (IZR p / IZR q)%R.\n\nTheorem algebra_others_exirrpowirrrat :\n exists a b : R, \n irrational a /\\ irrational b /\\ ~ irrational (Rpower a b).\n\nProof.\n" }, { "theorem_id": 102, "title": "algebra_sqineq_2at2pclta2c2p41pc", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-sqineq-2at2pclta2c2p41pc = `!a:real c:real. &2 * a * (&2 + c) <= a pow 2 + c pow 2 + &4 * (&1 + c)`;;\n" }, { "theorem_id": 102, "title": "algebra_sqineq_2at2pclta2c2p41pc", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_sqineq_2at2pclta2c2p41pc imports\n Complex_Main\nbegin\n\ntheorem algebra_sqineq_2at2pclta2c2p41pc:\n fixes a c :: real\n shows \"2 * a * (2+c) \\ a^2 + c^2 + 4 * (1+c)\"\n by sorry\n\nend" }, { "theorem_id": 102, "title": "algebra_sqineq_2at2pclta2c2p41pc", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_sqineq_2at2pclta2c2p41pc (a c : ℝ) :\n 2 * a * (2 + c) ≤ a ^ 2 + c ^ 2 + 4 * (1 + c) := by sorry" }, { "theorem_id": 102, "title": "algebra_sqineq_2at2pclta2c2p41pc", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_sqineq_2at2pclta2c2p41pc:\n forall a c : R, 2 * a * (2 + c) <= a^2 + c^2 + 4 * (1 + c).\nProof.\nAdmitted." }, { "theorem_id": 103, "title": "algebra_sqineq_2unitcircatblt1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-sqineq-2unitcircatblt1 = `!a:real b:real. a pow 2 + b pow 2 = &2 ==> a * b <= &1`;;\n" }, { "theorem_id": 103, "title": "algebra_sqineq_2unitcircatblt1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_sqineq_2unitcircatblt1 imports\nComplex_Main\n\nbegin\n\ntheorem algebra_sqineq_2unitcircatblt1:\n fixes a b :: real\n assumes \"a^2 + b^2 = 2\"\n shows \"a * b <= 1\"\n by sorry\n\nend" }, { "theorem_id": 103, "title": "algebra_sqineq_2unitcircatblt1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_sqineq_2unitcircatblt1 (a b : ℝ) (h₀ : a ^ 2 + b ^ 2 = 2) : a * b ≤ 1 := by sorry" }, { "theorem_id": 103, "title": "algebra_sqineq_2unitcircatblt1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_sqineq_2unitcircatblt1 : \n forall a b : R, \n a^2 + b^2 = 2 -> \n a * b <= 1.\nProof.\nAdmitted." }, { "theorem_id": 104, "title": "algebra_sqineq_36azm9asqle36zsq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-sqineq-36azm9asqle36zsq = `!z:real a:real. &36 * (a * z) - &9 * a pow 2 <= &36 * z pow 2`;;\n" }, { "theorem_id": 104, "title": "algebra_sqineq_36azm9asqle36zsq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_sqineq_36azm9asqle36zsq imports\n Complex_Main\nbegin\n\ntheorem algebra_sqineq_36azm9asqle36zsq:\n fixes z a :: real\n shows \"36 * (a * z) - 9 * a^2 \\ 36 * z^2\"\n by sorry\n\nend" }, { "theorem_id": 104, "title": "algebra_sqineq_36azm9asqle36zsq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_sqineq_36azm9asqle36zsq (z a : ℝ) : 36 * (a * z) - 9 * a ^ 2 ≤ 36 * z ^ 2 := by sorry" }, { "theorem_id": 104, "title": "algebra_sqineq_36azm9asqle36zsq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_sqineq_36azm9asqle36zsq (z a : R) :\n 36 * (a * z) - 9 * a^2 <= 36 * z^2.\nProof.\nAdmitted." }, { "theorem_id": 105, "title": "algebra_sqineq_4bap1lt4bsqpap1sq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let algebra-sqineq-4bap1lt4bsqpap1sq = `!a:real b:real. &4 * b * (a + &1) <= &4 * b pow 2 + (a + &1) pow 2`;;\n" }, { "theorem_id": 105, "title": "algebra_sqineq_4bap1lt4bsqpap1sq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory algebra_sqineq_4bap1lt4bsqpap1sq imports\n Complex_Main\nbegin\n\ntheorem algebra_sqineq_4bap1lt4bsqpap1sq:\n fixes a b :: real\n shows \"4 * b * (a+1) \\ 4 * b^2 + (a+1)^2\"\n by sorry\n\nend" }, { "theorem_id": 105, "title": "algebra_sqineq_4bap1lt4bsqpap1sq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_sqineq_4bap1lt4bsqpap1sq (a b : ℝ) : 4 * b * (a + 1) ≤ 4 * b ^ 2 + (a + 1) ^ 2 := by sorry" }, { "theorem_id": 105, "title": "algebra_sqineq_4bap1lt4bsqpap1sq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_sqineq_4bap1lt4bsqpap1sq :\n forall a b : R,\n 4 * b * (a + 1) <= 4 * (b * b) + (a + 1) * (a + 1).\nProof.\nAdmitted." }, { "theorem_id": 106, "title": "algebra_sqineq_at2malt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let algebra-sqineq-at2malt1 = `!a:real. a * (&2 - a) <= &1`;;\n" }, { "theorem_id": 106, "title": "algebra_sqineq_at2malt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory algebra_sqineq_at2malt1\n imports Complex_Main\nbegin\n\ntheorem algebra_sqineq_at2malt1:\n fixes a::real \n shows \"a * (2 - a) \\ 1\"\n by sorry\n\nend" }, { "theorem_id": 106, "title": "algebra_sqineq_at2malt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_sqineq_at2malt1\n (a : ℝ) :\n a * (2 - a) ≤ 1 := by sorry" }, { "theorem_id": 106, "title": "algebra_sqineq_at2malt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_sqineq_at2malt1 (a : R) : a * (2 - a) <= 1.\nProof.\nAdmitted." }, { "theorem_id": 107, "title": "algebra_sqineq_unitcircatbpabsamblt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let algebra-sqineq-unitcircatbpabsamblt1 = `!a:real b:real.\n (a pow 2 + b pow 2 = &1)\n==>\n (a * b + abs (a - b) <= &1)\n`;;\n" }, { "theorem_id": 107, "title": "algebra_sqineq_unitcircatbpabsamblt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory algebra_sqineq_unitcircatbpabsamblt1\n imports Complex_Main\nbegin\n\ntheorem algebra_sqineq_unitcircatbpabsamblt1:\n fixes a b :: real\n assumes h0: \"a^2 + b^2 = 1\" \n shows \"a * b + \\a - b\\ \\ 1\"\n by sorry\n\nend" }, { "theorem_id": 107, "title": "algebra_sqineq_unitcircatbpabsamblt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_sqineq_unitcircatbpabsamblt1\n (a b: ℝ)\n (h₀ : a^2 + b^2 = 1) :\n a * b + |a - b| ≤ 1 := by sorry" }, { "theorem_id": 107, "title": "algebra_sqineq_unitcircatbpabsamblt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_sqineq_unitcircatbpabsamblt1:\n forall (a b : R), (a^2 + b^2 = 1) -> (a * b + Rabs (a - b) <= 1).\nProof.\nAdmitted." }, { "theorem_id": 108, "title": "algebra_sqineq_unitcircatbpamblt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let algebra-sqineq-unitcircatbpamblt1 = `!a:real b:real. (a pow 2 + b pow 2 = &1) ==> a * b + (a - b) <= &1`;;\n" }, { "theorem_id": 108, "title": "algebra_sqineq_unitcircatbpamblt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory algebra_sqineq_unitcircatbpamblt1\n imports Complex_Main \"HOL-Library.Sum_of_Squares\"\nbegin\n\ntheorem algebra_sqineq_unitcircatbpamblt1:\n fixes a b:: real\n assumes h0: \"a^2 + b^2 = 1\"\n shows \"a * b + (a - b) \\ 1\"\n by sorry\n\nend" }, { "theorem_id": 108, "title": "algebra_sqineq_unitcircatbpamblt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem algebra_sqineq_unitcircatbpamblt1\n (a b: ℝ)\n (h₀ : a^2 + b^2 = 1) :\n a * b + (a - b) ≤ 1 := by sorry" }, { "theorem_id": 108, "title": "algebra_sqineq_unitcircatbpamblt1", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem algebra_sqineq_unitcircatbpamblt1 :\n forall a b : R, \n a^2 + b^2 = 1 -> a * b + (a - b) <= 1.\nProof.\nAdmitted." }, { "theorem_id": 109, "title": "amc12_2000_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12-2000-p1 = let amc12-2000-p1 = `!i m n. ~(i = 0) /\\ ~(m = 0) /\\ ~(n = 0) /\\ (i * m * n = 2001) ==> i + m + n <= 671`;;\n" }, { "theorem_id": 109, "title": "amc12_2000_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12_2000_p1\n imports Complex_Main\nbegin\n\ntheorem amc12_2000_p1:\n fixes i m k ::nat\n assumes h0 : \"i \\ 0 \\ m \\ 0 \\ k \\ 0\"\n and h1 : \"i*m*k = 2001\" \n shows \"i+m+k \\ 671\"\n by sorry\n\nend" }, { "theorem_id": 109, "title": "amc12_2000_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2000_p1\n (i m o : ℕ)\n (h₀ : i ≠ m ∧ m ≠ o ∧ o ≠ i)\n (h₁ : i*m*o = 2001) :\n i+m+o ≤ 671 := by sorry" }, { "theorem_id": 109, "title": "amc12_2000_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem amc12_2000_p1 :\n forall (i m o : nat),\n i <> m /\\ m <> o /\\ o <> i /\\ (i * m * o = 2001) -> \n i + m + o <= 671.\nProof.\nAdmitted." }, { "theorem_id": 110, "title": "amc12_2000_p11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12-2000-p11 = `!a:real b:real.\n (~(a = &0) /\\ ~(b = &0)) /\\\n (a * b = a - b) ==>\n a / b + b / a - a * b = &2`;;\n" }, { "theorem_id": 110, "title": "amc12_2000_p11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12_2000_p11 imports Complex_Main\nbegin\n\ntheorem amc12_2000_p11:\n fixes a b::real\n assumes \"a \\ 0\" \"b \\ 0\"\n and \"a * b = a - b\"\n shows \"a / b + b / a - a * b = 2\"\n by sorry\n\nend" }, { "theorem_id": 110, "title": "amc12_2000_p11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2000_p11 (a b : ℝ) (h₀ : a ≠ 0 ∧ b ≠ 0) (h₁ : a * b = a - b) :\n a / b + b / a - a * b = 2 := by sorry" }, { "theorem_id": 110, "title": "amc12_2000_p11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12_2000_p11 :\n forall a b : R,\n a <> 0 -> b <> 0 ->\n a * b = a - b ->\n a / b + b / a - a * b = 2.\nProof.\nAdmitted." }, { "theorem_id": 111, "title": "amc12_2000_p12", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12-2000-p12 = `!a m c. (a + m + c = 12) ==> a * m * c + a * m + m * c + a * c <= 112`;;\n" }, { "theorem_id": 111, "title": "amc12_2000_p12", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12_2000_p12\n imports Complex_Main\nbegin\n\ntheorem amc12_2000_p12:\n fixes a m c :: nat\n assumes h0: \"a + m + c = 12\" \n shows \"a*m*c + a*m + m*c + a*c \\ 112\"\n by sorry\n\nend " }, { "theorem_id": 111, "title": "amc12_2000_p12", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2000_p12\n (a m c : ℕ)\n (h₀ : a + m + c = 12) :\n a*m*c + a*m + m*c + a*c ≤ 112 := by sorry" }, { "theorem_id": 111, "title": "amc12_2000_p12", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Theorem amc12_2000_p12 (A M C : nat) (h0 : A + M + C = 12) : \n A * M * C + A * M + M * C + A * C <= 112.\nProof.\nAdmitted." }, { "theorem_id": 112, "title": "amc12_2000_p15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12-2000-p15 = `!f:complex->complex.\n (!x. f (x / Cx(&3)) = x pow 2 + x + Cx(&1)) /\\\n (FINITE {y | f y = Cx(&7)})\n==>\n vsum {y | f y = Cx(&7)} (\\y. y / Cx(&3)) = Cx(-- &1 / &9)\n`;;\n" }, { "theorem_id": 112, "title": "amc12_2000_p15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12_2000_p15 imports\n Complex_Main\n \"HOL-Computational_Algebra.Computational_Algebra\"\n \"Symmetric_Polynomials.Vieta\"\nbegin\n\ntheorem amc12_2000_p15:\n fixes f :: \"complex \\ complex\"\n assumes asm:\"\\ x. f (x / 3) = x^2 + x + 1\"\n shows \"(\\y\\f -` {7}. y / 3) = - 1 / 9\"\n by sorry\n\nend" }, { "theorem_id": 112, "title": "amc12_2000_p15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2000_p15 (f : ℂ → ℂ) (h₀ : ∀ x, f (x / 3) = x ^ 2 + x + 1)\n (h₁ : Fintype (f ⁻¹' {7})) : (∑ y ∈ (f ⁻¹' {7}).toFinset, y / 3) = -1 / 9 := by sorry" }, { "theorem_id": 112, "title": "amc12_2000_p15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\nRequire Import List.\n\nOpen Scope C_scope.\n\nTheorem amc12_2000_p15 :\n forall (f : C -> C),\n (forall x : C, f (x / 3) = x^2 + x + 1) ->\n (exists l : list C, NoDup l /\\\n (forall z : C, f (3*z) = 7 <-> In z l) /\\\n fold_left Cplus l 0 = -1/9).\nProof.\nAdmitted.\n" }, { "theorem_id": 113, "title": "amc12_2000_p20", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12-2000-p20 = `!x:real y z. (&0 < x /\\ &0 < y /\\ &0 < z) /\\ (x + &1 / y = &4) /\\ (y + &1 / z = &1) /\\ (z + &1 / x = &7 / &3) ==> x * y * z = &1`;;\n" }, { "theorem_id": 113, "title": "amc12_2000_p20", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12_2000_p20\n imports Complex_Main\nbegin\n\ntheorem amc12_2000_p20:\n fixes x y z :: real\n assumes h0: \"0 < x \\ 0 < y \\ 0 < z\"\n and h1: \"x + 1/y = 4\"\n and h2: \"y + 1/z = 1\"\n and h3: \"z + 1/x = 7/3\"\n shows \"x*y*z = 1\"\n by sorry\n\nend" }, { "theorem_id": 113, "title": "amc12_2000_p20", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2000_p20\n (x y z : ℝ)\n (h₀ : 0 < x ∧ 0 < y ∧ 0 < z)\n (h₁ : x + 1/y = 4)\n (h₂ : y + 1/z = 1)\n (h₃ : z + 1/x = 7/3) :\n x*y*z = 1 := by sorry" }, { "theorem_id": 113, "title": "amc12_2000_p20", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12_2000_p20 :\n forall x y z : R,\n 0 < x -> 0 < y -> 0 < z ->\n x + / y = 4 -> y + / z = 1 -> z + / x = 7 / 3 ->\n x * y * z = 1.\nProof.\nAdmitted." }, { "theorem_id": 114, "title": "amc12_2000_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12-2000-p5 = `!x:real p:real.\n (x < &2) /\\\n (abs (x - &2) = p)\n==>\n (x - p = &2 - &2 * p)\n`;;\n" }, { "theorem_id": 114, "title": "amc12_2000_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12_2000_p5 imports Complex_Main\nbegin\n\ntheorem amc12_2000_p5:\n fixes x p ::real\n assumes \"x<2\"\n and \"\\x -2\\ = p\"\n shows \"x - p = 2 - 2 * p\"\n by sorry\n\nend" }, { "theorem_id": 114, "title": "amc12_2000_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2000_p5 (x p : ℝ) (h₀ : x < 2) (h₁ : abs (x - 2) = p) : x - p = 2 - 2 * p := by sorry" }, { "theorem_id": 114, "title": "amc12_2000_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12_2000_p5:\n forall (x p : R),\n x < 2 ->\n Rabs (x - 2) = p ->\n x - p = 2 - 2 * p.\nProof.\nAdmitted." }, { "theorem_id": 115, "title": "amc12_2000_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12-2000-p6 = let amc12-2000-p6 = `!p q. (prime p /\\ prime q) /\\ (4 <= p /\\ p <= 18) /\\ (4 <= q /\\ q <= 18) ==> ~(p * q - (p + q) = 194)`;;\n" }, { "theorem_id": 115, "title": "amc12_2000_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12_2000_p6\n imports Complex_Main \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem amc12_2000_p6:\n fixes p q ::nat\n assumes h0: \"prime p \\ prime q\"\n and h1: \"4 \\ p \\ p \\ 18\"\n and h2: \"4 \\ q \\ q \\ 18\" \n shows \"((p * q)::int) - (p + q) \\ 194\"\n by sorry\n\nend" }, { "theorem_id": 115, "title": "amc12_2000_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2000_p6\n (p q : ℕ)\n (h₀ : Nat.Prime p ∧ Nat.Prime q)\n (h₁ : 4 ≤ p ∧ p ≤ 18)\n (h₂ : 4 ≤ q ∧ q ≤ 18) :\n p * q - (p + q) ≠ 194 := by sorry" }, { "theorem_id": 115, "title": "amc12_2000_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Nat.\nRequire Import PArith.\nRequire Import Arith.\nRequire Import Znumtheory.\nRequire Import Lia.\n\nTheorem amc12_2000_p6 (p q : Z) :\n 0 < p -> 0 < q ->\n prime p -> prime q ->\n (4 <= p <= 18)%Z ->\n (4 <= q <= 18)%Z ->\n p * q - (p + q) <> 194.\nProof.\n" }, { "theorem_id": 116, "title": "amc12_2001_p2", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12-2001-p2 = `!a:num b:num n:num.\n (1 <= a /\\ a <= 9) /\\\n (0 <= b /\\ b <= 9) /\\\n (n = 10 * a + b) /\\\n (n = a * b + a + b) ==>\n b = 9`;;\n" }, { "theorem_id": 116, "title": "amc12_2001_p2", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12_2001_p2 imports\n Complex_Main\nbegin\n\ntheorem amc12_2001_p2:\n fixes a b n::nat\n assumes \"1 \\ a \\ a \\ 9\"\n and \"0 \\ b \\ b \\ 9\"\n and \"n = 10 * a + b\"\n and \"n = a * b + a + b\"\n shows \"b=9\"\n by sorry\n\nend" }, { "theorem_id": 116, "title": "amc12_2001_p2", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2001_p2 (a b n : ℕ) (h₀ : 1 ≤ a ∧ a ≤ 9) (h₁ : 0 ≤ b ∧ b ≤ 9) (h₂ : n = 10 * a + b)\n (h₃ : n = a * b + a + b) : b = 9 := by sorry" }, { "theorem_id": 116, "title": "amc12_2001_p2", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\n\nTheorem amc12_2001_p2 (a b n : nat) :\n (1 <= a <= 9) -> (0 <= b <= 9) -> (n = 10 * a + b) -> (n = a * b + a + b) -> \n (b = 9).\nProof.\nAdmitted." }, { "theorem_id": 117, "title": "amc12_2001_p21", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12-2001-p21 = `!a b c d. a * b * c * d = FACT 8 /\\ a * b + a + b = 524 /\\ b * c + b + c = 146 /\\ c * d + c + d = 104 ==> a - d = 10`;;\n" }, { "theorem_id": 117, "title": "amc12_2001_p21", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12_2001_p21\n imports Complex_Main \nbegin\n\ntheorem amc12_2001_p21:\n fixes a b c d ::nat\n assumes h0: \"a*b*c*d = fact 8\"\n and h1: \"a*b + a + b = 524\"\n and h2: \"b*c + b + c = 146\"\n and h3: \"c*d + c + d = 104\" \n shows \"int a - d = 10\"\n by sorry\n\nend" }, { "theorem_id": 117, "title": "amc12_2001_p21", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2001_p21\n (a b c d : ℕ)\n (h₀ : a * b * c * d = Nat.factorial 8)\n (h₁ : a * b + a + b = 524)\n (h₂ : b * c + b + c = 146)\n (h₃ : c * d + c + d = 104) :\n ↑a - ↑d = (10 : ℤ) := by sorry" }, { "theorem_id": 117, "title": "amc12_2001_p21", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Lia.\n\nTheorem amc12_2001_p21 :\n forall (a b c d : nat),\n a * b * c * d = fact 8 ->\n a * b + a + b = 524 ->\n b * c + b + c = 146 ->\n c * d + c + d = 104 ->\n Z.sub (Z.of_nat a) (Z.of_nat d) = 10%Z.\n\nProof.\n" }, { "theorem_id": 118, "title": "amc12_2001_p5", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12-2001-p5 = `product {x | x < 10000 /\\ ODD x} (\\x. &x) = &(FACT 10000) / &((2 EXP 5000) * (FACT 5000))`;;\n" }, { "theorem_id": 118, "title": "amc12_2001_p5", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12_2001_p5\n imports Complex_Main \nbegin\n\ntheorem amc12_2001_p5:\n shows \"(\\x\\{x::nat. x<10000 \\ odd x}. x) \n = fact 10000 / ((2^5000) * fact 5000)\"\n by sorry\n\nend" }, { "theorem_id": 118, "title": "amc12_2001_p5", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2001_p5 :\n Finset.prod (Finset.filter (λ x => ¬ Even x) (Finset.range 10000)) (id : ℕ → ℕ) = (10000!) / ((2^5000) * (5000!)) := by sorry" }, { "theorem_id": 118, "title": "amc12_2001_p5", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\nRequire Import Coq.Lists.List.\nRequire Import Coq.Init.Nat.\nImport ListNotations.\n\nTheorem amc12_2001_p5 :\n \n (fold_left Nat.mul (filter Nat.odd (seq 1 9999)) 1)\n = (fact 10000) / (Nat.pow 2 5000 * fact 5000).\nProof.\nAdmitted." }, { "theorem_id": 119, "title": "amc12_2001_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12-2001-p9 = `!f:real->real.\n (!x y. (x > &0 /\\ y > &0) ==> f (x * y) = f x / y) /\\\n (f (&500) = &3)\n==>\n (f (&600) = &5 / &2)\n`;;\n" }, { "theorem_id": 119, "title": "amc12_2001_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12_2001_p9 imports Complex_Main\nbegin\n\ntheorem amc12_2001_p9:\n fixes f:: \"real \\ real\"\n assumes f_times:\"\\ x > 0. \\ y > 0. f (x * y) = f x / y\"\n and \"f 500 = 3\"\n shows \"f 600 = 5 / 2 \"\n by sorry\n\nend" }, { "theorem_id": 119, "title": "amc12_2001_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12_2001_p9 (f : ℝ → ℝ) (h₀ : ∀ x > 0, ∀ y > 0, f (x * y) = f x / y) (h₁ : f 500 = 3) :\n f 600 = 5 / 2 := by sorry" }, { "theorem_id": 119, "title": "amc12_2001_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Export Reals Lra.\nOpen Scope R_scope.\n\nTheorem amc12_2001_p9 (f : R -> R) :\n (forall x y : R, 0 < x -> 0 < y -> f (x * y) = f x / y) ->\n f 500 = 3 ->\n f 600 = 5 / 2.\nProof.\nAdmitted.\n" }, { "theorem_id": 120, "title": "amc12a_2002_p1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12a-2002-p1 = `!f:complex->complex.\n (!x. f x = (Cx(&2) * x + Cx(&3)) * (x - Cx(&4)) + (Cx(&2) * x + Cx(&3)) * (x - Cx(&6))) /\\\n (FINITE {x | f x = Cx(&0)})\n==>\n vsum {x | f x = Cx(&0)} (\\y. y) = Cx(&7 / &2)\n`;;\n" }, { "theorem_id": 120, "title": "amc12a_2002_p1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12a_2002_p1 imports\n Complex_Main\n \"HOL-Computational_Algebra.Computational_Algebra\"\n \"Symmetric_Polynomials.Vieta\"\nbegin\n\ntheorem amc12a_2002_p1:\n fixes f::\"complex \\ complex\"\n assumes \"\\ x. f x = (2 * x + 3) * (x - 4) + (2 * x + 3) * (x - 6)\"\n shows \"(\\ y \\ f -` {0}. y) = 7/2\"\n by sorry\n\nend" }, { "theorem_id": 120, "title": "amc12a_2002_p1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2002_p1 (f : ℂ → ℂ) (h₀ : ∀ x, f x = (2 * x + 3) * (x - 4) + (2 * x + 3) * (x - 6))\n (h₁ : Fintype (f ⁻¹' {0})) : (∑ y ∈ (f ⁻¹' {0}).toFinset, y) = 7 / 2 := by sorry" }, { "theorem_id": 120, "title": "amc12a_2002_p1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\nRequire Import List.\n\nOpen Scope C_scope.\n\nTheorem amc12a_2002_p1 :\n forall (f : C -> C) (roots : list C),\n (forall x, f x = (2 * x + 3) * (x - 4) + (2 * x + 3) * (x - 6)) ->\n NoDup roots ->\n (forall x, In x roots <-> f x = 0) ->\n fold_left (fun acc x => acc + x) roots 0 = 7/2.\n\nProof.\n" }, { "theorem_id": 121, "title": "amc12a_2002_p12", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12a-2002-p12 = `!f:real->real k:real.\n (!x. f x = x pow 2 - &63 * x + k) /\\\n ({x | f x = &0} SUBSET { x | ?n. &n = x /\\ prime n})\n==>\n k = &122\n`;;\n" }, { "theorem_id": 121, "title": "amc12a_2002_p12", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12a_2002_p12 imports\n Complex_Main\n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem amc12a_2002_p12:\n fixes f :: \"real => real\"\n and k :: real\n assumes \"\\ x. f x = x^2 - 63 * x + k\"\n and \"f -` {0} \\ {x ::real. \\ n :: nat. n = x \\ prime n}\"\n shows \"k=122\"\n by sorry\n\nend" }, { "theorem_id": 121, "title": "amc12a_2002_p12", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2002_p12 (f : ℝ → ℝ) (k : ℝ) (a b : ℕ) (h₀ : ∀ x, f x = x ^ 2 - 63 * x + k)\n (h₁ : f a = 0 ∧ f b = 0) (h₂ : a ≠ b) (h₃ : Nat.Prime a ∧ Nat.Prime b) : k = 122 := by sorry" }, { "theorem_id": 121, "title": "amc12a_2002_p12", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\nFrom Coq Require Import ZArith.\nFrom Coq Require Import Lia.\nFrom Coq Require Import Znumtheory. \n\nOpen Scope R_scope.\n\nTheorem amc12a_2002_p12 :\n forall (f : R -> R) (k : R) (a b : Z),\n (forall x : R, f x = x ^ 2 - 63 * x + k) ->\n f (IZR a) = 0 ->\n f (IZR b) = 0 ->\n a <> b ->\n prime a /\\ prime b ->\n k = 122.\n\n\nProof.\n" }, { "theorem_id": 122, "title": "amc12a_2002_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2002-p13 = `!a b. (&0 < a /\\ &0 < b) /\\ ~(a = b) /\\ (abs (a - &1 / a) = &1) /\\ (abs (b - &1 / b) = &1) ==> a + b = sqrt(&5)`;;\n" }, { "theorem_id": 122, "title": "amc12a_2002_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2002_p13\n imports Complex_Main \nbegin\n\ntheorem amc12a_2002_p13:\n fixes a b :: real\n assumes h0: \"0 < a \\ 0 < b\"\n and h1: \"a \\ b\"\n and h2: \"abs (a - 1/a) = 1\"\n and h3: \"abs (b - 1/b) = 1\" \n shows \"a + b = sqrt 5\"\n by sorry\n\nend" }, { "theorem_id": 122, "title": "amc12a_2002_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2002_p13\n (a b : ℝ)\n (h₀ : 0 < a ∧ 0 < b)\n (h₁ : a ≠ b)\n (h₂ : abs (a - 1/a) = 1)\n (h₃ : abs (b - 1/b) = 1) :\n a + b = Real.sqrt 5 := by sorry" }, { "theorem_id": 122, "title": "amc12a_2002_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Psatz.\n\nOpen Scope R_scope.\n\nTheorem amc12a_2002_p13 :\n forall a b : R,\n 0 < a -> 0 < b ->\n a <> b ->\n Rabs (a - 1/a) = 1 ->\n Rabs (b - 1/b) = 1 ->\n a + b = sqrt 5.\nProof.\nAdmitted." }, { "theorem_id": 123, "title": "amc12a_2002_p21", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12a-2002-p21 = `!u:num->num.\n (u 0 = 4) /\\\n (u 1 = 7) /\\\n (!n. n >= 2 ==> u (n + 2) = (u n + u (n + 1)) MOD 10)\n==>\n (!n. nsum (0..(n-1)) u > 10000 ==> 1999 <= n)\n`;;\n" }, { "theorem_id": 123, "title": "amc12a_2002_p21", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12a_2002_p21 imports\n Complex_Main\nbegin\n\ntheorem amc12a_2002_p21:\n fixes u:: \"nat\\nat\" and n::nat\n assumes \"u 0 =4\"\n and \"u 1=7\"\n and \"\\ n \\ 2. u (n + 2) = (u n + u (n + 1)) mod 10\"\n and \"(\\ k \\ {..n}. u k) > 10000\"\n shows \"1999 \\ n\"\n by sorry\n\nend" }, { "theorem_id": 123, "title": "amc12a_2002_p21", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2002_p21 (u : ℕ → ℕ) (h₀ : u 0 = 4) (h₁ : u 1 = 7)\n (h₂ : ∀ n ≥ 2, u (n + 2) = (u n + u (n + 1)) % 10) :\n ∀ n, (∑ k ∈ Finset.range n, u k) > 10000 → 1999 ≤ n := by sorry" }, { "theorem_id": 123, "title": "amc12a_2002_p21", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\nRequire Import Coq.Reals.Reals.\nRequire Import Coq.Reals.Rdefinitions.\nRequire Import Coq.Lists.List.\nImport ListNotations.\n\nTheorem amc12a_2002_p21\n (u : nat -> nat)\n (h0 : u 0 = 4)\n (h1 : u 1 = 7)\n (h2 : forall n, u (n + 2) = (u n + u (n + 1)) mod 10) :\n forall n, (fold_right plus 0 (map u (seq 0 n))) > 10000 -> 1999 <= n.\nProof.\nAdmitted.\n" }, { "theorem_id": 124, "title": "amc12a_2002_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2002-p6 = `!n. ~(n = 0) ==> (?m. m > n /\\ ?p. m * p <= m + p )`;;\n\n" }, { "theorem_id": 124, "title": "amc12a_2002_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2002_p6\n imports Complex_Main \nbegin\n\ntheorem amc12a_2002_p6:\n fixes n ::nat \n assumes \"n>0\"\n shows \"\\ m > n. \\ p. m * p \\ m + p\"\n by sorry\n\nend" }, { "theorem_id": 124, "title": "amc12a_2002_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2002_p6\n (n : ℕ)\n (h₀ : 0 < n) :\n ∃ m, (m > n ∧ ∃ p, m * p ≤ m + p) := by sorry" }, { "theorem_id": 124, "title": "amc12a_2002_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem amc12a_2002_p6\n (n : nat)\n (h₀ : 0 < n) :\n exists m, m > n /\\ exists p, m * p <= m + p.\nProof.\nAdmitted." }, { "theorem_id": 125, "title": "amc12a_2003_p1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12a-2003-p1 = `!u:num->num v:num->num.\n (!n. u n = 2 * n + 2) /\\\n (!n. v n = 2 * n + 1)\n==>\n (nsum (0..(2003 - 1)) u) - (nsum (0..(2003 - 1)) v) = 2003\n`;;\n" }, { "theorem_id": 125, "title": "amc12a_2003_p1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12a_2003_p1 imports\n Complex_Main\nbegin\n\ntheorem amc12a_2003_p1:\n fixes u v :: \"nat \\ nat\"\n assumes u:\"\\n. u n = 2 *n +2\"\n and v:\"\\n. v n= 2* n +1\"\n shows \"(\\ k \\{1..2003}. u k) - (\\ k \\{1..2003}. v k) = 2003\"\n (is \"?L = ?R\")\n by sorry\n\nend" }, { "theorem_id": 125, "title": "amc12a_2003_p1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2003_p1 (u v : ℕ → ℕ) (h₀ : ∀ n, u n = 2 * n + 2) (h₁ : ∀ n, v n = 2 * n + 1) :\n ((∑ k ∈ Finset.range 2003, u k) - ∑ k ∈ Finset.range 2003, v k) = 2003 := by sorry" }, { "theorem_id": 125, "title": "amc12a_2003_p1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Lists.List.\nImport ListNotations.\n\nFixpoint sum_f (f : nat -> nat) (n : nat) : nat :=\n match n with\n | 0 => 0\n | S n' => sum_f f n' + f n'\n end.\n\nTheorem amc12a_2003_p1:\n sum_f (fun n => 2*n+2) 2003 - sum_f (fun n => 2*n+1) 2003 = 2003.\nProof.\n" }, { "theorem_id": 126, "title": "amc12a_2003_p23", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2003-p23 = `FINITE {k:num | k > 0 /\\ (k * k) divides (nproduct (1..(10-1)) (\\i. FACT i))} ==> CARD {k:num | k > 0 /\\ (k * k) divides (nproduct (1..(10-1)) (\\i. FACT i))} = 672`;;\n" }, { "theorem_id": 126, "title": "amc12a_2003_p23", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2003_p23 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem amc12a_2003_p23:\n \"card {k::nat. (k * k) dvd (\\ i\\{1..<10}. fact i)} = 672\"\n by sorry\n\nend " }, { "theorem_id": 126, "title": "amc12a_2003_p23", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2003_p23\n (S : Finset ℕ)\n (h₀ : ∀ (k : ℕ), k ∈ S ↔ 0 < k ∧ ((k * k) : ℕ) ∣ (∏ i ∈ (Finset.Icc 1 9), i !)) :\n S.card = 672 := by sorry" }, { "theorem_id": 126, "title": "amc12a_2003_p23", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\nRequire Import List.\nRequire Import ZArith.\nRequire Import Arith.\nRequire Import FSets.\nRequire Import FSetFacts.\nRequire Import FSetProperties.\nModule NS := FSetWeakList.Make(Nat_as_OT).\n\nDefinition fact_prod := fold_right Nat.mul 1 (map fact (seq 1 9)).\n\nTheorem amc12a_2003_p23 :\n exists (S : NS.t),\n NS.cardinal S = 672 /\\\n forall k, NS.In k S <->\n (k > 0 /\\ exists n, n * n = k /\\ (Nat.divide k fact_prod)).\n\n\nProof.\n" }, { "theorem_id": 127, "title": "amc12a_2003_p24", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12a-2003-p24 = `!a:real b:real.\n (b <= a) /\\\n (&1 < b) ==>\n ln (a / b) / ln a + ln (b / a) / ln b <= &0`;;\n" }, { "theorem_id": 127, "title": "amc12a_2003_p24", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12a_2003_p24 imports\n Complex_Main\nbegin\n\ntheorem amc12a_2003_p24:\n fixes a b::real\n assumes \"b\\a\"\n and \"10\" (is \"?L \\ _\")\n by sorry\n\nend" }, { "theorem_id": 127, "title": "amc12a_2003_p24", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2003_p24 :\n IsGreatest { y : ℝ | ∃ a b : ℝ, 1 < b ∧ b ≤ a ∧ y = Real.logb a (a / b) + Real.logb b (b / a) }\n 0 := by sorry" }, { "theorem_id": 127, "title": "amc12a_2003_p24", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nOpen Scope R_scope.\n\n\n\nTheorem amc12a_2003_p24:\n forall (a b : R),\n b <= a ->\n 1 < b ->\n ln(a/b) / ln(a) + ln(b/a) / ln(b) <= 0.\n\nProof.\n" }, { "theorem_id": 128, "title": "amc12a_2003_p25", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12a-2003-p25 = `!a:real b:real f:real->real.\n (&0 < b) /\\\n (!x. f x = sqrt (a * x pow 2 + b * x)) /\\\n ({x | &0 <= f x} = {f x | x | x IN {x | &0 <= f x}})\n==>\n (a = &0) \\/ (a = -- &4)\n`;;\n" }, { "theorem_id": 128, "title": "amc12a_2003_p25", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12a_2003_p25 imports\n Complex_Main\nbegin\n\ntheorem amc12a_2003_p25:\n fixes a b::real and f ::\"real \\ real\"\n assumes \"b>0\" \n and \"\\ x. f x = sqrt (a * x^2 + b * x)\"\n and \"{x. 0 \\ f x} = f ` {x. 0 \\ f x}\"\n shows \"a=0 \\ a =4\"\n by sorry\n\nend" }, { "theorem_id": 128, "title": "amc12a_2003_p25", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2003_p25 (a b : ℝ) (f : ℝ → ℝ) (h₀ : 0 < b)\n (h₁ : ∀ x, f x = Real.sqrt (a * x ^ 2 + b * x)) (h₂ : { x | 0 ≤ f x } = f '' { x | 0 ≤ f x }) :\n a = 0 ∨ a = -4 := by sorry" }, { "theorem_id": 128, "title": "amc12a_2003_p25", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Sets.Ensembles.\nRequire Import Sets.Image.\n\nOpen Scope R_scope.\n\nTheorem amc12a_2003_p25 :\n forall (a b : R) (f : R -> R),\n b > 0 ->\n (forall x : R, f x = sqrt (a * x^2 + b * x)) ->\n (forall x : R, In R (fun y => 0 <= f y) x <-> \n exists z : R, In R (fun y => 0 <= f y) z /\\ f z = x) ->\n a = 0 \\/ a = -4.\n\nProof.\n" }, { "theorem_id": 129, "title": "amc12a_2003_p5", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2003-p5 = `!a m c. (a <= 9 /\\ m <= 9 /\\ c <= 9) /\\ (10 * (10 * (10 * (10 * a + m) + c) + 1) + 0 + (10 * (10 * (10 * (10 * a + m) + c) + 1) + 2) = 123422) ==> a + m + c = 14`;;\n" }, { "theorem_id": 129, "title": "amc12a_2003_p5", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2003_p5\n imports Complex_Main \nbegin\n\ntheorem amc12a_2003_p5:\n fixes a m c ::nat\n assumes h0: \"a \\ 9 \\ m \\ 9 \\ c \\ 9\"\n and h1: \"10*(10*(10*(10*a + m) + c) + 1) + 0 \n + (10*(10*(10*(10*a + m) + c) + 1) + 2) = 123422\"\n shows \"a + m + c = 14 \"\n by sorry\n\nend" }, { "theorem_id": 129, "title": "amc12a_2003_p5", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2003_p5\n (A M C : ℕ)\n (h₀ : A ≤ 9 ∧ M ≤ 9 ∧ C ≤ 9)\n (h₁ : Nat.ofDigits 10 [0,1,C,M,A] + Nat.ofDigits 10 [2,1,C,M,A] = 123422) :\n A + M + C = 14 := by sorry" }, { "theorem_id": 129, "title": "amc12a_2003_p5", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\n\nTheorem amc12a_2003_p5 :\n forall (A M C : nat),\n (A <= 9 /\\ M <= 9 /\\ C <= 9) ->\n (10000 * A + 1000 * M + 100 * C + 10 * 1 + 0) + \n (10000 * A + 1000 * M + 100 * C + 10 * 1 + 2) = 123422 ->\n A + M + C = 14.\nProof.\nAdmitted." }, { "theorem_id": 130, "title": "amc12a_2020_p10", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2020-p10 = `!n:num.\n (n > 0) /\\\n (ln (ln (&n) / ln (&16)) / ln (&2) = ln (ln (&n) / ln (&4)) / ln (&4))\n==>\n n = 256\n`;;\n" }, { "theorem_id": 130, "title": "amc12a_2020_p10", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2020_p10\n imports Complex_Main \nbegin\n\ntheorem amc12a_2020_p10:\n fixes n ::nat\n assumes \"n>0\"\n and h0: \"ln (ln n / ln 16) / ln 2 \n = ln (ln n / ln 4) / ln 4\" \n shows \"n = 256\"\n by sorry\n\nend" }, { "theorem_id": 130, "title": "amc12a_2020_p10", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2020_p10\n (n : ℕ)\n (h₀ : 1 < n)\n (h₁ : Real.logb 2 (Real.logb 16 n) = Real.logb 4 (Real.logb 4 n)) :\n (Nat.digits 10 n).sum = 13 := by sorry" }, { "theorem_id": 130, "title": "amc12a_2020_p10", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\nRequire Import ZArith.\nRequire Import List.\nRequire Import Nat.\n\nOpen Scope R_scope.\n\nDefinition log_base (b x : R) : R := ln x / ln b.\n\nFixpoint sum_digits_aux (fuel n acc: nat) {struct fuel} : nat :=\n match fuel with\n | 0 => acc\n | S fuel' => match n with\n | 0 => acc\n | _ => sum_digits_aux fuel' (n / 10) (acc + (n mod 10))\n end\n end.\n\nDefinition sum_digits (n: nat) : nat := sum_digits_aux (S n) n 0.\n\nTheorem amc12a_2020_p10 :\n exists! n : nat,\n (n > 0)%nat /\\\n log_base 2 (log_base 16 (INR n)) = log_base 4 (log_base 4 (INR n)) /\\\n sum_digits n = (13%nat).\n\n\nProof.\n" }, { "theorem_id": 131, "title": "amc12a_2020_p13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12a-2020-p13 = `!a:num b:num c:num n:real.\n (n >= 0) /\\\n ~(n = 1) /\\\n (1 < a /\\ 1 < b /\\ 1 < c) /\\\n (exp ((&1) / (&a) * ln (&n * (exp ((&1) / (&b) * ln (&n * (exp ((&1) / (&c) * ln (&n)))))))) = exp ((&1) / (&36) * ln (&(n EXP 25))))\n==>\n b = 3\n`;;\n\n" }, { "theorem_id": 131, "title": "amc12a_2020_p13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12a_2020_p13 imports\n Complex_Main\nbegin\n\ntheorem amc12a_2020_p13:\n fixes a b c::nat\n and n ::real\n assumes \"n>0\" and \"n \\ 1\" \n and \"1 < a \\ 1 < b \\ 1 < c\"\n and \"(n * ((n * (n powr (1 / c))) powr (1 / b))) powr (1 / a) = (n^25) powr (1 / 36)\"\n shows \"b=3\"\n by sorry\n\nend" }, { "theorem_id": 131, "title": "amc12a_2020_p13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2020_p13 (a b c : ℕ) (n : NNReal) (h₀ : n ≠ 1) (h₁ : 1 < a ∧ 1 < b ∧ 1 < c)\n (h₂ : (n * (n * n ^ (1 / c)) ^ (1 / b)) ^ (1 / a) = (n ^ 25) ^ (1 / 36)) : b = 3 := by sorry" }, { "theorem_id": 131, "title": "amc12a_2020_p13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import ZArith.\nOpen Scope R_scope.\n\nTheorem amc12a_2020_p13 :\n forall (a b c : nat) (n : R),\n 0 < n ->\n n <> 1 ->\n (1 < a)%nat /\\ (1 < b)%nat /\\ (1 < c)%nat ->\n Rpower (n * Rpower (n * Rpower n (/ INR c)) (/ INR b)) (/ INR a) = Rpower n (25/36) ->\n b = 3%nat.\n\nProof.\n" }, { "theorem_id": 132, "title": "amc12a_2020_p15", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2020-p15 = `!a:complex b:complex.\n (a pow 3 - Cx(&8) = Cx(&0)) /\\\n (b pow 3 - Cx(&8) * b pow 2 - Cx(&8) * b + Cx(&64) = Cx(&0))\n==>\n norm (a - b) <= &2 * sqrt (&21)\n`;;\n" }, { "theorem_id": 132, "title": "amc12a_2020_p15", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2020_p15\n imports Complex_Main \nbegin\n\ntheorem amc12a_2020_p15:\n fixes a b :: complex\n assumes h0: \"a^3 - 8 = 0\"\n and h1: \"b^3 - 8 * b^2 - 8 * b + 64 = 0\" \n shows \"norm (a - b) \\ 2 * sqrt 21\"\n by sorry\n\nend" }, { "theorem_id": 132, "title": "amc12a_2020_p15", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2020_p15\n (a b : ℂ)\n (h₀ : a^3 - 8 = 0)\n (h₁ : b^3 - 8 * b^2 - 8 * b + 64 = 0) :\n ‖a - b‖ ≤ 2 * Real.sqrt 21 := by sorry" }, { "theorem_id": 132, "title": "amc12a_2020_p15", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nTheorem amc12a_2020_p15 :\n forall (a b : C),\n (a^3 - 8 = 0)%C ->\n (b^3 - 8 * b^2 - 8 * b + 64 = 0)%C ->\n Cmod (a - b) <= 2 * sqrt 21.\nProof.\nAdmitted.\n" }, { "theorem_id": 133, "title": "amc12a_2020_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2020-p4 = `!a:num b:num c:num d:num.\n (1 <= a /\\ a <= 9 /\\ EVEN a) /\\\n (0 <= b /\\ b <= 9 /\\ EVEN b) /\\\n (0 <= c /\\ c <= 9 /\\ EVEN c) /\\\n (0 <= d /\\ d <= 9 /\\ EVEN d) /\\\n (FINITE {n:num | (n = 10 * (10*(10*a + b) + c) + d /\\ 5 divides n)})\n==>\n CARD {n:num | (n = 10 * (10*(10*a + b) + c) + d /\\ 5 divides n)} = 100\n`;;\n" }, { "theorem_id": 133, "title": "amc12a_2020_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2020_p4\n imports Complex_Main \nbegin\n\ntheorem amc12a_2020_p4:\n fixes a b c d :: nat\n assumes h0: \"1 \\ a \\ a \\ 9 \\ even a\"\n and h1: \"0 \\ b \\ b \\ 9 \\ even b\"\n and h2: \"0 \\ c \\ c \\ 9 \\ even c\"\n and h3: \"0 \\ d \\ d \\ 9 \\ even d\"\n shows \"card {n :: nat. n = 10 * (10*(10*a + b) + c) + d \\ 5 dvd n} = 100\"\n by sorry\n\nend" }, { "theorem_id": 133, "title": "amc12a_2020_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2020_p4\n (S : Finset ℕ)\n (h₀ : ∀ (n : ℕ), n ∈ S ↔ 1000 ≤ n ∧ n ≤ 9999 ∧ (∀ (d : ℕ), d ∈ Nat.digits 10 n → Even d) ∧ 5 ∣ n) :\n S.card = 100 := by sorry" }, { "theorem_id": 133, "title": "amc12a_2020_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Bool.\nRequire Import Arith.\nRequire Import List.\nImport ListNotations.\n\nDefinition condition '(a,b,c,d) : bool :=\n Nat.even a && Nat.even b && Nat.even c && Nat.even d &&\n ((1000 * a + 100 * b + 10 * c + d) mod 5 =? 0).\n\nTheorem amc12a_2020_p4 :\n length (filter condition\n (list_prod\n (list_prod\n (list_prod (seq 1 9) (seq 0 10))\n (seq 0 10))\n (seq 0 10))) = 100.\nProof.\n" }, { "theorem_id": 134, "title": "amc12a_2020_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2020-p7 = `!a:num->num.\n ((a 0) EXP 3 = 1) /\\\n ((a 1) EXP 3 = 8) /\\\n ((a 2) EXP 3 = 27) /\\\n ((a 3) EXP 3 = 64) /\\\n ((a 4) EXP 3 = 125) /\\\n ((a 5) EXP 3 = 216) /\\\n ((a 6) EXP 3 = 343)\n==>\n int_of_num (nsum (0..(7-1)) (\\k. 6 * (a k) EXP 2)) - int_of_num ((2 * nsum (0..(6-1)) (\\k. (a k) EXP 2))) = &658\n`;;\n" }, { "theorem_id": 134, "title": "amc12a_2020_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2020_p7\n imports Complex_Main \nbegin\n\ntheorem amc12a_2020_p7:\n fixes a:: \"nat\\nat\"\nassumes h0: \"(a 0)^3 = 1\"\n and h1: \"(a 1)^3 = 8\"\n and h2: \"(a 2)^3 = 27\"\n and h3: \"(a 3)^3 = 64\"\n and h4: \"(a 4)^3 = 125\"\n and h5: \"(a 5)^3 = 216\"\n and h6: \"(a 6)^3 = 343\" \n shows \"(\\ k < 7. (6 * (a k)^2)) \n - 2 * (\\ k < 6. (a k)^2) = (658::int)\"\n by sorry\n\nend" }, { "theorem_id": 134, "title": "amc12a_2020_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2020_p7\n (a : ℕ → ℕ)\n (h₀ : (a 0)^3 = 1)\n (h₁ : (a 1)^3 = 8)\n (h₂ : (a 2)^3 = 27)\n (h₃ : (a 3)^3 = 64)\n (h₄ : (a 4)^3 = 125)\n (h₅ : (a 5)^3 = 216)\n (h₆ : (a 6)^3 = 343) :\n ∑ k ∈ Finset.range 7, (6 * (a k)^2) - ↑(2 * ∑ k ∈ Finset.range 6, (a k)^2) = 658 := by sorry" }, { "theorem_id": 134, "title": "amc12a_2020_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import List.\nRequire Import Lia.\n\nOpen Scope nat_scope.\n\nTheorem amc12a_2020_p7 :\n forall a : nat -> nat,\n (a O)^3 = 1 ->\n (a 1)^3 = 8 ->\n (a 2)^3 = 27 ->\n (a 3)^3 = 64 ->\n (a 4)^3 = 125 ->\n (a 5)^3 = 216 ->\n (a 6)^3 = 343 ->\n Z.of_nat (6 * ((a O)^2 + (a 1)^2 + (a 2)^2 + (a 3)^2 + \n (a 4)^2 + (a 5)^2 + (a 6)^2) - \n 2 * ((a O)^2 + (a 1)^2 + (a 2)^2 + (a 3)^2 + \n (a 4)^2 + (a 5)^2)) = 658%Z.\n\nProof.\n" }, { "theorem_id": 135, "title": "amc12a_2020_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2020-p9 = `(FINITE {x:real | (&0 <= x) /\\ (x <= &2 * pi) /\\ (tan (&2 * x) = cos (x / &2))})\n==>\n (CARD {x:real | (&0 <= x) /\\ (x <= &2 * pi) /\\ (tan (&2 * x) = cos (x / &2))} = 5)\n`;;\n" }, { "theorem_id": 135, "title": "amc12a_2020_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2020_p9\n imports Complex_Main \nbegin\n\ntheorem amc12a_2020_p9:\n shows \"card { x::real. 0 \\ x \\ x \\ 2 * pi \\ \n tan (2 * x) = cos (x / 2)} = 5\" \n by sorry\n\nend" }, { "theorem_id": 135, "title": "amc12a_2020_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2020_p9\n (S : Finset ℝ)\n (h₀ : ∀ (x : ℝ), x ∈ S ↔ 0 ≤ x ∧ x ≤ 2 * Real.pi ∧ Real.tan (2 * x) = Real.cos (x / 2)) :\n S.card = 5 := by sorry" }, { "theorem_id": 135, "title": "amc12a_2020_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Sets.Ensembles.\nRequire Import Sets.Finite_sets.\n\nOpen Scope R_scope.\n\nDefinition solution_set : Ensemble R :=\n fun x => 0 <= x /\\ x <= 2 * PI /\\ tan (2 * x) = cos (x / 2).\n\nTheorem amc12a_2020_p9 :\n exists (S : Ensemble R),\n Same_set R S solution_set /\\\n Finite R S /\\\n cardinal R S 5.\n\nProof.\n" }, { "theorem_id": 136, "title": "amc12a_2021_p12", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2021-p12 = `!a:real b:real c:real d:real f:complex->complex.\n (!z. f z = z pow 6 - Cx(&10) * z pow 5 + Cx(a) * z pow 4 + Cx(b) * z pow 3 + Cx(c) * z pow 2 + Cx(d) * z + Cx(&16)) /\\\n (!z. f z = Cx(&0) ==> (Im z = &0 /\\ &0 < Re z /\\ (floor (Re z)) = Re z))\n==>\n b = &88\n`;;\n" }, { "theorem_id": 136, "title": "amc12a_2021_p12", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2021_p12\n imports Complex_Main \nbegin\n\ntheorem amc12a_2021_p12:\n fixes a b c d ::real\n and f :: \"complex \\ complex\"\n assumes h0: \"\\ z. f z = z^6 - 10 * z^5 + a * z^4 + b * z^3 \n + c * z^2 + d * z + 16\"\n and h1: \"\\ z. f z = 0 \\ (Im z = 0 \\ 0 < Re z \\ (floor (Re z)) = (Re z))\" \n shows \"b = 88\"\n by sorry\n\nend" }, { "theorem_id": 136, "title": "amc12a_2021_p12", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2021_p12\n (a b c d : ℝ)\n (f : ℂ → ℂ)\n (h₀ : ∀ z, f z = z^6 - 10 * z^5 + a * z^4 + b * z^3 + c * z^2 + d * z + 16)\n (h₁ : ∀ z, f z = 0 → (z.im = 0 ∧ 0 < z.re ∧ ↑(Int.floor z.re) = z.re)) :\n b = -88 := by sorry" }, { "theorem_id": 136, "title": "amc12a_2021_p12", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope R_scope.\nOpen Scope C_scope.\n\nTheorem amc12a_2021_p12 \n (a b c d : R)\n (f : C -> C)\n (h0 : forall z, f z = z^6 - 10 * z^5 + a * z^4 + b * z^3 + c * z^2 + d * z + 16)\n (h1 : forall z, f z = 0 -> \n Im z = 0 /\\ (0 < Re z)%R /\\ IZR (floor (Re z)) = Re z) :\n b = -88.\n\nProof.\n" }, { "theorem_id": 137, "title": "amc12a_2021_p14", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2021-p14 = `sum (1..(21-1)) (\\k. ln (&(3 EXP (k EXP 2))) / ln (&(5 EXP k))) * sum (1..(101-1)) (\\k. ln (&(25 EXP k)) / ln (&(9 EXP k))) = &21000`;;\n" }, { "theorem_id": 137, "title": "amc12a_2021_p14", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2021_p14\n imports Complex_Main \nbegin\n\ntheorem amc12a_2021_p14 :\n shows \"(\\ k\\{1..<21}.\n ln (3^(k^2)) / ln (5^k)) * (\\ k \\{1..<101}. ln (25^k) \n / ln (9^k))= 21000\"\n by sorry\n \nend" }, { "theorem_id": 137, "title": "amc12a_2021_p14", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2021_p14 :\n (∑ k ∈ (Finset.Icc 1 20), (Real.logb (5^k) (3^(k^2)))) * (∑ k ∈ (Finset.Icc 1 100), (Real.logb (9^k) (25^k))) = 21000 := by sorry" }, { "theorem_id": 137, "title": "amc12a_2021_p14", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nRequire Import Coq.Init.Nat.\nRequire Import Coq.micromega.Lra.\n\nOpen Scope R_scope.\n\n\n\nTheorem amc12a_2021_p14 :\n ( (sum_f_R0 (fun i => ln (3 ^ ((i+1)*(i+1))) / ln (5 ^ (i+1))) 19)\n * (sum_f_R0 (fun i => ln (25 ^ (i+1)) / ln (9 ^ (i+1))) 99)\n ) = 21000.\n\nProof.\n" }, { "theorem_id": 138, "title": "amc12a_2021_p18", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2021-p18 = `!f:real->real.\n (!x:real y:real. ((rational x) /\\ (rational y) /\\ (x > &0) /\\ (y > &0)) ==> (f (x * y) = f (x) + f (y))) /\\\n (!p:num. prime p ==> f (&p) = &p)\n==>\n f (&25 / &11) < &0\n`;;\n" }, { "theorem_id": 138, "title": "amc12a_2021_p18", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2021_p18\n imports Complex_Main \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem amc12a_2021_p18:\n fixes f :: \"rat \\ real\"\n assumes h0: \"\\x>0. \\y>0. f (x * y) = f x + f y\"\n and h1: \"\\p. prime p \\ f (of_nat p) = p\"\n shows \"f (25 / 11) < 0\"\n by sorry\n\nend" }, { "theorem_id": 138, "title": "amc12a_2021_p18", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2021_p18\n (f : ℚ → ℝ)\n (h₀ : ∀x>0, ∀y>0, f (x * y) = f x + f y)\n (h₁ : ∀p, Nat.Prime p → f p = p) :\n f (25 / 11) < 0 := by sorry" }, { "theorem_id": 138, "title": "amc12a_2021_p18", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import QArith.\nRequire Import Znumtheory.\nFrom Stdlib Require Import Qreals.\n\nTheorem amc12a_2021_p18\n (f : Q -> R)\n (hcompat : forall x y : Q, Qeq x y -> f x = f y)\n (h0 : forall x y : Q, (0 < x)%Q -> (0 < y)%Q -> f (Qmult x y) = Rplus (f x) (f y))\n (h1 : forall p : Z, prime p -> f (inject_Z p) = IZR p) :\n (f (Qmake 25 11) < 0)%R.\n\nProof.\nAdmitted.\n" }, { "theorem_id": 139, "title": "amc12a_2021_p19", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2021-p19 = `(FINITE {x:real | (&0 <= x) /\\ (x <= pi) /\\ (sin (pi / &2 * cos x) = cos (pi / &2 * sin x))})\n==>\n (CARD {x:real | (&0 <= x) /\\ (x <= pi) /\\ (sin (pi / &2 * cos x) = cos (pi / &2 * sin x))} = 2)\n`;;\n" }, { "theorem_id": 139, "title": "amc12a_2021_p19", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2021_p19\n imports Complex_Main\nbegin\n\ntheorem amc12a_2021_p19:\n shows \"card {x ::real. 0 \\ x \\ x \\ pi \\ sin \n (pi / 2 * cos x) = cos (pi / 2 * \n sin x)} = 2\"\n by sorry\n\nend" }, { "theorem_id": 139, "title": "amc12a_2021_p19", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2021_p19\n (S : Finset ℝ)\n (h₀ : ∀ (x : ℝ), x ∈ S ↔ 0 ≤ x ∧ x ≤ Real.pi ∧ Real.sin (Real.pi / 2 * Real.cos x) = Real.cos (Real.pi / 2 * Real.sin x)) :\n S.card = 2 := by sorry" }, { "theorem_id": 139, "title": "amc12a_2021_p19", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import FunctionalExtensionality.\nRequire Import RIneq.\nRequire Import Classical_Pred_Type.\nRequire Import ClassicalEpsilon.\n\nOpen Scope R_scope.\n\nTheorem amc12a_2021_p19 :\n exists S : R -> Prop,\n (forall x, S x <-> (0 <= x /\\ x <= PI /\\ \n sin (PI/2 * cos x) = cos (PI/2 * sin x))) /\\\n exists x1 x2, \n x1 <> x2 /\\\n S x1 /\\ S x2 /\\\n forall x, S x -> (x = x1 \\/ x = x2).\n\nProof.\n" }, { "theorem_id": 140, "title": "amc12a_2021_p22", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2021-p22 = `!a:real b:real c:real f:real->real.\n (!x. f x = x pow 3 + a * x pow 2 + b * x + c) /\\\n ({x | f x = &0} = {cos (&2 * pi / &7), cos (&4 * pi / &7), cos (&6 * pi / &7)})\n==>\n a * b * c = &1 / &32\n`;;\n" }, { "theorem_id": 140, "title": "amc12a_2021_p22", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2021_p22\n imports Complex_Main \nbegin\n\ntheorem amc12a_2021_p22:\n fixes a b c ::real\n and f :: \"real \\ real\"\n assumes h0: \"\\ x. f x = x^3 + a * x^2 + b * x + c\"\n and h1: \"(f-`{0}) = {cos (2 * pi / 7), \n cos (4 * pi / 7), cos (6 * pi / 7)}\"\n shows \"a * b * c = 1 / 32\"\n by sorry\n\nend" }, { "theorem_id": 140, "title": "amc12a_2021_p22", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2021_p22\n (a b c : ℝ)\n (f : ℝ → ℝ)\n (h₀ : ∀ x, f x = x^3 + a * x^2 + b * x + c)\n (h₁ : f⁻¹' {0} = {Real.cos (2 * Real.pi / 7), Real.cos (4 * Real.pi / 7), Real.cos (6 * Real.pi / 7)}) :\n a * b * c = 1 / 32 := by sorry" }, { "theorem_id": 140, "title": "amc12a_2021_p22", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12a_2021_p22:\n forall (a b c : R) (f : R -> R),\n (forall x : R, f x = x^3 + a*x^2 + b*x + c) ->\n (forall x : R, f x = 0 <-> \n x = cos((2*PI)/7) \\/ x = cos((4*PI)/7) \\/ x = cos((6*PI)/7)) ->\n a * b * c = 1/32.\nProof.\nAdmitted." }, { "theorem_id": 141, "title": "amc12a_2021_p25", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2021-p25 = `!n:num f:num->real.\n (n > 0 /\\ !n. n > 0 ==> f n = sum {k | k divides n} (\\k. &k) / (exp (&1 / &3 * ln (&n)))) /\\\n (!p. ~(p = n) ==> f p < f n)\n==>\n n = 2520\n`;;\n" }, { "theorem_id": 141, "title": "amc12a_2021_p25", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2021_p25\n imports Complex_Main \nbegin\n\ntheorem amc12a_2021_p25:\n fixes n :: nat and f :: \"nat \\ real\"\n assumes\n h0: \"\\ n. f n = (\\ k\\ {k::nat. k dvd n}. 1) / (n powr (1 / 3))\"\n and h1: \"\\ p \\ n. f p < f n\" \n shows \"n = 2520\"\n by sorry\n\nend" }, { "theorem_id": 141, "title": "amc12a_2021_p25", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2021_p25\n (N : ℕ)\n (hN : N > 0)\n (f : ℕ → ℝ)\n (h₀ : ∀ n, 0 < n → f n = ((Nat.divisors n).card)/(n^((1:ℝ)/3)))\n (h₁ : ∀ n ≠ N, 0 < n → f n < f N) :\n (Nat.digits 10 N).sum = 9 := by sorry" }, { "theorem_id": 141, "title": "amc12a_2021_p25", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\nRequire Import List.\nRequire Import Reals.\n\nOpen Scope R_scope.\n\nDefinition divisors (n : nat) : list nat :=\n filter (fun d => n mod d =? 0) (seq 1 n).\n\nFixpoint fueled_sum_digits (fuel n : nat) : nat :=\n match fuel with\n | 0 => 0\n | S fuel' =>\n if n mod 10 =? n then n else n mod 10 + fueled_sum_digits fuel' (n / 10)\n end.\n\nDefinition sum_digits n := fueled_sum_digits (S n) n.\n\nTheorem amc12a_2021_p25 :\n forall (N : nat) (f : nat -> R),\n (forall n, (0 < n)%nat ->\n f n = INR (length (divisors n)) / Rpower (INR n) (1 / 3)) ->\n (forall n, n <> N -> f n < f N) ->\n (sum_digits N = 9)%nat.\nProof.\n" }, { "theorem_id": 142, "title": "amc12a_2021_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2021-p3 = `!x:num y:num.\n (x + y = 17402) /\\\n (10 divides x) /\\\n (x DIV 10 = y)\n==>\n (int_of_num (x) - &y = &14238)\n`;;\n" }, { "theorem_id": 142, "title": "amc12a_2021_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2021_p3\n imports Complex_Main \nbegin\n\ntheorem amc12a_2021_p3:\n fixes x y :: nat\n assumes h0: \"x + y = 17402\"\n and h1: \"10 dvd x\"\n and h2: \"x div 10 = y\" \n shows \"x - y = 14238\"\n by sorry\n\nend" }, { "theorem_id": 142, "title": "amc12a_2021_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2021_p3\n (x y : ℕ)\n (h₀ : x + y = 17402)\n (h₁ : 10∣x)\n (h₂ : x / 10 = y) :\n ↑x - ↑y = (14238:ℤ) := by sorry" }, { "theorem_id": 142, "title": "amc12a_2021_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Nat.\nRequire Import Lia.\n\nTheorem amc12a_2021_p3:\n forall (x y : nat),\n x + y = 17402 ->\n (exists k, x = 10 * k)%nat ->\n (x / 10 = y)%nat ->\n (Z.of_nat x - Z.of_nat y = 14238)%Z.\n\nProof.\n" }, { "theorem_id": 143, "title": "amc12a_2021_p7", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12a-2021-p7 = `!x:real y:real. &1 <= ((x * y) - &1) pow 2 + (x + y) pow 2`;;\n" }, { "theorem_id": 143, "title": "amc12a_2021_p7", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12a_2021_p7 imports\n Complex_Main\nbegin\n\ntheorem amc12a_2021_p7:\n fixes x y ::real\n shows \"1 \\ ((x * y) - 1)^2 + (x + y)^2\"\n by sorry\n\nend" }, { "theorem_id": 143, "title": "amc12a_2021_p7", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2021_p7 (x y : ℝ) : 1 ≤ (x * y - 1) ^ 2 + (x + y) ^ 2 := by sorry" }, { "theorem_id": 143, "title": "amc12a_2021_p7", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12a_2021_p7 : forall x y : R, \n 1 <= ((x * y) - 1)^2 + (x + y)^2.\nProof.\nAdmitted." }, { "theorem_id": 144, "title": "amc12a_2021_p8", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2021-p8 = `!d:num->num.\n (d 0 = 0) /\\\n (d 1 = 0) /\\\n (d 2 = 1) /\\\n (!n. n >=3 ==> d n = d (n - 1) + d (n - 3))\n==>\n EVEN (d 2021) /\\ ODD (d 2022) /\\ EVEN (d 2023)\n`;;\n" }, { "theorem_id": 144, "title": "amc12a_2021_p8", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2021_p8\n imports Complex_Main \nbegin\n\ntheorem amc12a_2021_p8:\n fixes d :: \"nat \\ nat\"\n assumes h0: \"d 0 = 0\"\n and h1: \"d 1 = 0\"\n and h2: \"d 2 = 1\"\n and h3: \"\\ n\\3. d n = d (n - 1) + d (n - 3)\"\n shows \"even (d 2021) \\ odd (d 2022) \\ even (d 2023)\" \n by sorry\n\nend" }, { "theorem_id": 144, "title": "amc12a_2021_p8", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2021_p8\n (d : ℕ → ℕ)\n (h₀ : d 0 = 0)\n (h₁ : d 1 = 0)\n (h₂ : d 2 = 1)\n (h₃ : ∀ n≥3, d n = d (n - 1) + d (n - 3)) :\n Even (d 2021) ∧ Odd (d 2022) ∧ Even (d 2023) := by sorry" }, { "theorem_id": 144, "title": "amc12a_2021_p8", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem amc12a_2021_p8 :\n forall (d : nat -> nat),\n d 0 = 0 ->\n d 1 = 0 ->\n d 2 = 1 ->\n (forall n : nat, n >= 3 -> d n = d (n-1) + d (n-3)) ->\n (Nat.even (d 2021)) = true /\\\n (Nat.even (d 2022)) = false /\\\n (Nat.even (d 2023)) = true.\n\nProof.\n" }, { "theorem_id": 145, "title": "amc12a_2021_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12a-2021-p9 = `&(nproduct (0..(7-1)) (\\k. 2 EXP (2 EXP k) + 3 EXP (2 EXP k))) = int_of_num (3 EXP 128) - &(2 EXP 128)`;;\n" }, { "theorem_id": 145, "title": "amc12a_2021_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12a_2021_p9\n imports Complex_Main \"HOL-Library.Code_Target_Numeral\"\nbegin\n\ntheorem amc12a_2021_p9 :\n shows \"(\\ k<7. (2^(2^k) + 3^(2^k))) = (3::nat)^128 - 2^128\"\n by sorry\n\nend" }, { "theorem_id": 145, "title": "amc12a_2021_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12a_2021_p9 :\n ∏ k ∈ Finset.range 7, (2^(2^k) + 3^(2^k)) = 3^128 - 2^128 := by sorry" }, { "theorem_id": 145, "title": "amc12a_2021_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.PeanoNat.\nRequire Import Coq.Lists.List.\nRequire Import Coq.Numbers.Natural.Abstract.NDiv.\n\nTheorem amc12a_2021_p9 :\n fold_left Nat.mul \n (map (fun k => (2^(2^k) + 3^(2^k))) (seq 0 7)) 1 = \n 3^128 - 2^128.\nProof.\nAdmitted." }, { "theorem_id": 146, "title": "amc12b_2002_p11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12b-2002-p11 = `!a:num b:num.\n (prime a) /\\\n (prime b) /\\\n (prime (a + b)) /\\\n (prime (a - b))\n ==> prime (a + b + (a - b + (a + b)))`;;\n" }, { "theorem_id": 146, "title": "amc12b_2002_p11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12b_2002_p11 imports\n Complex_Main\n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem amc12b_2002_p11:\n fixes a b::nat\n assumes \"prime a\" and \"prime b\"\n and \"prime (a+b)\" and \"prime (a-b)\"\n shows \"prime (a + b + (a - b + (a + b)))\"\n by sorry\n\nend " }, { "theorem_id": 146, "title": "amc12b_2002_p11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2002_p11 (a b : ℕ) (h₀ : Nat.Prime a) (h₁ : Nat.Prime b) (h₂ : Nat.Prime (a + b))\n (h₃ : Nat.Prime (a - b)) : Nat.Prime (a + b + (a - b + (a + b))) := by sorry" }, { "theorem_id": 146, "title": "amc12b_2002_p11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Znumtheory.\n\nTheorem amc12b_2002_p11:\n forall (a b : Z),\n prime a ->\n prime b ->\n prime (a + b) ->\n prime (a - b) ->\n prime (a + b + (a - b + (a + b))).\n\nProof.\n" }, { "theorem_id": 147, "title": "amc12b_2002_p19", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2002-p19 = `!a:real b:real c:real.\n (&0 < a /\\ &0 < b /\\ &0 < c) /\\\n (a * (b + c) = &152) /\\\n (b * (c + a) = &162) /\\\n (c * (a + b) = &170)\n ==> a * b * c = &720`;;\n" }, { "theorem_id": 147, "title": "amc12b_2002_p19", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2002_p19\n imports Complex_Main\nbegin\n\ntheorem amc12b_2002_p19:\n fixes a b c::real\n assumes h0: \"0 < a \\ 0 < b \\ 0 < c\"\n and h1: \"a * (b + c) = 152\"\n and h2: \"b * (c + a) = 162\"\n and h3: \"c * (a + b) = 170\"\n shows \"a * b * c = 720\"\n by sorry\n\nend" }, { "theorem_id": 147, "title": "amc12b_2002_p19", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2002_p19\n (a b c: ℝ)\n (h₀ : 0 < a ∧ 0 < b ∧ 0 < c)\n (h₁ : a * (b + c) = 152)\n (h₂ : b * (c + a) = 162)\n (h₃ : c * (a + b) = 170) :\n a * b * c = 720 := by sorry" }, { "theorem_id": 147, "title": "amc12b_2002_p19", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2002_p19 :\n forall (a b c : R),\n 0 < a -> 0 < b -> 0 < c ->\n a * (b + c) = 152 -> \n b * (c + a) = 162 ->\n c * (a + b) = 170 ->\n a * b * c = 720.\nProof.\nAdmitted." }, { "theorem_id": 148, "title": "amc12b_2002_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2002-p2 = `!x:int. (x = &4) ==> ( &3 * x - &2 ) * ( &4 * x + &1 ) - ( &3 * x - &2 ) * ( &4 * x ) + &1 = &11`;;\n" }, { "theorem_id": 148, "title": "amc12b_2002_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2002_p2\n imports Complex_Main \nbegin\n\ntheorem amc12b_2002_p2:\n fixes x ::int\n assumes h0: \"x = 4\" \n shows \"(3 * x - 2) * (4 * x + 1) - (3 * x - 2) * (4 * x) + 1 = 11\"\n by sorry\n\nend" }, { "theorem_id": 148, "title": "amc12b_2002_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2002_p2\n (x : ℤ)\n (h₀ : x = 4) :\n (3 * x - 2) * (4 * x + 1) - (3 * x - 2) * (4 * x) + 1 = 11 := by sorry" }, { "theorem_id": 148, "title": "amc12b_2002_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem amc12b_2002_p2 (x : Z) (h0 : x = 4) :\n (3 * x - 2) * (4 * x + 1) - (3 * x - 2) * (4 * x) + 1 = 11.\nProof.\nAdmitted." }, { "theorem_id": 149, "title": "amc12b_2002_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12b-2002-p3 = `!n:num.\n (0 < n) /\\\n (prime (n EXP 2 + 2 - 3 * n))\n==>\n n = 3\n`;;\n" }, { "theorem_id": 149, "title": "amc12b_2002_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12b_2002_p3 imports\n Complex_Main\n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem amc12b_2002_p3:\n fixes n ::nat\n assumes \"n>0\"\n and prime:\"prime (n^2+2-3*n)\"\n shows \"n=3\"\n by sorry\n\nend" }, { "theorem_id": 149, "title": "amc12b_2002_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2002_p3 (S : Finset ℕ)\n -- note: we use (n^2 + 2 - 3 * n) over (n^2 - 3 * n + 2) because nat subtraction truncates the latter at 1 and 2\n (h₀ : ∀ n : ℕ, n ∈ S ↔ 0 < n ∧ Nat.Prime (n ^ 2 + 2 - 3 * n)) :\n S.card = 1 := by sorry" }, { "theorem_id": 149, "title": "amc12b_2002_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import ZArith.\nRequire Import Znumtheory.\n\nTheorem amc12b_2002_p3 :\n forall (n : Z),\n (n > 0)%Z -> \n prime (n * n - 3 * n + 2)%Z ->\n n = 3%Z.\n\nProof.\n" }, { "theorem_id": 150, "title": "amc12b_2002_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2002-p4 = `!n:num.\n (n > &0) /\\\n (?p. (&1 / &2 + &1 / &3 + &1 / &7 + &1 / &n) = &p)\n==>\n (n = 42)\n`;;\n" }, { "theorem_id": 150, "title": "amc12b_2002_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2002_p4\n imports Complex_Main\nbegin\n\ntheorem amc12b_2002_p4:\n fixes n :: nat\n assumes h0 : \"fst (quotient_of (1 / 2 + 1 / 3 + 1 / 7 \n + 1 /(rat_of_nat n))) = 1\" \n shows \"n = 42\"\n by sorry\n\nend" }, { "theorem_id": 150, "title": "amc12b_2002_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2002_p4\n (n : ℕ)\n (h₀ : 0 < n)\n (h₁ : ((1 / 2 + 1 / 3 + 1 / 7 + 1 / n) : ℚ).den = 1) :\n n = 42 := by sorry" }, { "theorem_id": 150, "title": "amc12b_2002_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import ZArith.\nRequire Import Reals.Rfunctions.\nRequire Import Lia.\n\nOpen Scope R_scope.\n\nTheorem amc12b_2002_p4 :\n forall (n : nat),\n (n > 0)%nat ->\n exists k : Z, \n (1/2 + 1/3 + 1/7 + 1/(INR n))%R = IZR k ->\n n = 42%nat.\n\n\n\nProof.\n" }, { "theorem_id": 151, "title": "amc12b_2002_p6", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12b-2002-p6 = `!a:real b:real.\n (~(a = &0) /\\ ~(b = &0)) /\\\n (!x. x pow 2 + a * x + b = (x - a) * (x - b))\n ==> a = &1 /\\ b = -- &2`;;\n" }, { "theorem_id": 151, "title": "amc12b_2002_p6", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12b_2002_p6 \n imports Complex_Main\nbegin\n\ntheorem amc12b_2002_p6:\n fixes a b :: real\n assumes \"a \\ 0 \\ b \\ 0\"\n and \"\\ x. x^2 + a * x + b = (x - a) * (x - b)\"\n shows \" a = 1 \\ b = -2\"\n by sorry\nend " }, { "theorem_id": 151, "title": "amc12b_2002_p6", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2002_p6 (a b : ℝ) (h₀ : a ≠ 0 ∧ b ≠ 0)\n (h₁ : ∀ x, x ^ 2 + a * x + b = (x - a) * (x - b)) : a = 1 ∧ b = -2 := by sorry" }, { "theorem_id": 151, "title": "amc12b_2002_p6", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2002_p6 :\n forall a b : R,\n (a <> 0) /\\ (b <> 0) ->\n (forall x, x^2 + a * x + b = (x - a) * (x - b)) ->\n a = 1 /\\ b = -2.\nProof.\nAdmitted." }, { "theorem_id": 152, "title": "amc12b_2002_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2002-p7 = `!a:num b:num c:num.\n ~(a = 0) /\\\n ~(b = 0) /\\\n ~(c = 0) /\\\n (b = a + 1) /\\\n (c = b + 1) /\\\n (a * b * c = 8 * (a + b + c) )\n ==> a EXP 2 + ( b EXP 2 + c EXP 2 ) = 77`;;\n" }, { "theorem_id": 152, "title": "amc12b_2002_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2002_p7\n imports Complex_Main \nbegin\n\ntheorem amc12b_2002_p7:\n fixes a b c :: nat\n assumes h0: \"b = a + 1\"\n and h1: \"c = b + 1\"\n and h2: \"a * b * c = 8 * (a + b + c)\" \n shows \"a^2 + b^2 + c^2 = 77\"\n by sorry\n\nend" }, { "theorem_id": 152, "title": "amc12b_2002_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2002_p7\n (a b c : ℕ)\n (h₀ : 0 < a ∧ 0 < b ∧ 0 < c)\n (h₁ : b = a + 1)\n (h₂ : c = b + 1)\n (h₃ : a * b * c = 8 * (a + b + c)) :\n a^2 + (b^2 + c^2) = 77 := by sorry" }, { "theorem_id": 152, "title": "amc12b_2002_p7", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem amc12b_2002_p7 :\n forall a b c : nat,\n (0 < a) -> (0 < b) -> (0 < c) ->\n (b = a + 1) ->\n (c = b + 1) ->\n (a * b * c = 8 * (a + b + c)) ->\n (a^2 + b^2 + c^2 = 77).\nProof.\nAdmitted." }, { "theorem_id": 153, "title": "amc12b_2003_p17", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12b-2003-p17 = `!x:real y:real.\n (&0 < x /\\ &0 < y) /\\\n (ln (x * y pow 3) = &1) /\\\n (ln (x pow 2 * y) = &1)\n==>\n ln (x * y) = &3 / &5\n`;;\n" }, { "theorem_id": 153, "title": "amc12b_2003_p17", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12b_2003_p17 imports\n Complex_Main\nbegin\n\ntheorem amc12b_2003_p17:\n fixes x y ::real\n assumes \"x>0\" \"y>0\"\n and \"ln (x * y^3) =1\"\n and \"ln (x^2 * y) = 1\"\n shows \"ln (x*y) = 3/5\"\n by sorry\n\nend" }, { "theorem_id": 153, "title": "amc12b_2003_p17", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2003_p17 (x y : ℝ) (h₀ : 0 < x ∧ 0 < y) (h₁ : Real.log (x * y ^ 3) = 1)\n (h₂ : Real.log (x ^ 2 * y) = 1) : Real.log (x * y) = 3 / 5 := by sorry" }, { "theorem_id": 153, "title": "amc12b_2003_p17", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2003_p17:\n forall x y : R,\n 0 < x -> 0 < y ->\n ln (x * y ^ 3) = 1 ->\n ln (x ^ 2 * y) = 1 ->\n ln (x * y) = 3 / 5.\nProof.\nAdmitted." }, { "theorem_id": 154, "title": "amc12b_2003_p6", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12b-2003-p6 = `!a:real r:real u:num->real.\n (!k. u k = a * r pow k) /\\\n (u 1 = &2) /\\\n (u 3 = &6)\n==>\n u 0 = &2 / (sqrt (&3)) \\/ u 0 = -- (&2 / (sqrt (&3)))\n`;;\n" }, { "theorem_id": 154, "title": "amc12b_2003_p6", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12b_2003_p6 imports\n Complex_Main\nbegin\n\ntheorem amc12b_2003_p6:\n fixes a r::real and u::\"nat \\ real\"\n assumes \"\\ k. u k = a * r^k\"\n and \"u 1= 2\"\n and \"u 3=6\"\n shows \"u 0 = 2/ sqrt 3 \\ u 0 = - 2/sqrt 3\"\n by sorry\n\nend" }, { "theorem_id": 154, "title": "amc12b_2003_p6", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2003_p6 (a r : ℝ) (u : ℕ → ℝ) (h₀ : ∀ k, u k = a * r ^ k) (h₁ : u 1 = 2)\n (h₂ : u 3 = 6) : u 0 = 2 / Real.sqrt 3 ∨ u 0 = -(2 / Real.sqrt 3) := by sorry" }, { "theorem_id": 154, "title": "amc12b_2003_p6", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2003_p6 :\n forall (a r : R) (u : nat -> R),\n (forall k : nat, u k = a * pow r k) ->\n u 1%nat = 2 ->\n u 3%nat = 6 ->\n u 0%nat = 2/sqrt(3) \\/ u 0%nat = -(2/sqrt(3)).\n\nProof.\n" }, { "theorem_id": 155, "title": "amc12b_2003_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12b-2003-p9 = `!a:real b:real f:real->real.\n (!x. f x = a * x + b) /\\\n (f (&6) - f (&2) = &12)\n ==> f (&12) - f (&2) = &30`;;\n" }, { "theorem_id": 155, "title": "amc12b_2003_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12b_2003_p9 imports\n Complex_Main\nbegin\n\ntheorem amc12b_2003_p9:\n fixes a b ::real and f :: \"real \\ real\"\n assumes \"\\ x. f x = a * x + b\"\n and \" f 6 - f 2 = 12\"\n shows \"f 12 - f 2 = 30\"\n by sorry\n \nend " }, { "theorem_id": 155, "title": "amc12b_2003_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2003_p9 (a b : ℝ) (f : ℝ → ℝ) (h₀ : ∀ x, f x = a * x + b) (h₁ : f 6 - f 2 = 12) :\n f 12 - f 2 = 30 := by sorry" }, { "theorem_id": 155, "title": "amc12b_2003_p9", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2003_p9 :\n forall (a b : R) (f : R -> R),\n (forall x : R, f x = a * x + b) ->\n f 6 - f 2 = 12 ->\n f 12 - f 2 = 30.\nProof.\nAdmitted." }, { "theorem_id": 156, "title": "amc12b_2004_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12b-2004-p3 = `!x:num y:num. 2 EXP x * 3 EXP y = 1296 ==> x + y = 8`;;\n" }, { "theorem_id": 156, "title": "amc12b_2004_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12b_2004_p3 imports\n Complex_Main\nbegin\n\ntheorem amc12b_2004_p3:\n fixes x y :: nat\n assumes \"2^x * 3^y = 1296\"\n shows \"x + y = 8\" \n by sorry\n\nend" }, { "theorem_id": 156, "title": "amc12b_2004_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2004_p3 (x y : ℕ) (h₀ : 2 ^ x * 3 ^ y = 1296) : x + y = 8 := by sorry" }, { "theorem_id": 156, "title": "amc12b_2004_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem amc12b_2004_p3:\n forall x y : nat,\n 2^x * 3^y = 1296 -> x + y = 8.\nProof.\nAdmitted." }, { "theorem_id": 157, "title": "amc12b_2020_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2020-p13 = `sqrt (ln (&6) / ln (&2) + ln (&6) / ln (&3)) = sqrt (ln (&3) / ln (&2)) + sqrt (ln (&2) / ln (&3))`;;\n" }, { "theorem_id": 157, "title": "amc12b_2020_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2020_p13\n imports Complex_Main\nbegin\n\ntheorem amc12b_2020_p13 :\n shows \"sqrt (ln 6 / ln 2 + ln 6 / ln 3) \n = sqrt (ln 3 / ln 2) + sqrt (ln 2 / ln 3)\"\n by sorry\n\nend" }, { "theorem_id": 157, "title": "amc12b_2020_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2020_p13 :\n Real.sqrt (Real.log 6 / Real.log 2 + Real.log 6 / Real.log 3) = Real.sqrt (Real.log 3 / Real.log 2) + Real.sqrt (Real.log 2 / Real.log 3) := by sorry" }, { "theorem_id": 157, "title": "amc12b_2020_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2020_p13:\n sqrt ((ln 6 / ln 2) + (ln 6 / ln 3)) = sqrt (ln 3 / ln 2) + sqrt (ln 2 / ln 3).\nProof.\nAdmitted." }, { "theorem_id": 158, "title": "amc12b_2020_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2020-p2 = `real_of_int (int_of_num (100 EXP 2) - &(7 EXP 2)) / real_of_int (int_of_num (70 EXP 2) - &(11 EXP 2)) * (&(70 - 11) * &(70 + 11) / &((100 - 7) * (100 + 7))) = &1`;;\n" }, { "theorem_id": 158, "title": "amc12b_2020_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2020_p2\n imports Complex_Main \"HOL-Library.Code_Target_Numeral\"\nbegin\n\ntheorem amc12b_2020_p2 :\n shows \"((100 ^ 2 - 7 ^ 2)) / (70 ^ 2 - 11 ^ 2) * \n ((70 - 11) * (70 + 11) / ((100 - 7) * (100 + 7))) = (1::real)\"\n by sorry\n\nend" }, { "theorem_id": 158, "title": "amc12b_2020_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2020_p2 :\n ((100 ^ 2 - 7 ^ 2):ℝ) / (70 ^ 2 - 11 ^ 2) * ((70 - 11) * (70 + 11) / ((100 - 7) * (100 + 7))) = 1 := by sorry" }, { "theorem_id": 158, "title": "amc12b_2020_p2", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2020_p2 :\n ((100 ^ 2 - 7 ^ 2) / (70 ^ 2 - 11 ^ 2)) * \n ((70 - 11) * (70 + 11) / ((100 - 7) * (100 + 7))) = 1.\nProof.\nAdmitted." }, { "theorem_id": 159, "title": "amc12b_2020_p21", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2020-p21 = `FINITE {n | n > 0 /\\ &(n + 1000) / &70 = floor (sqrt (&n))} ==> CARD {n | n > 0 /\\ &(n + 1000) / &70 = floor (sqrt (&n))} = 6`;;\n" }, { "theorem_id": 159, "title": "amc12b_2020_p21", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2020_p21\n imports Complex_Main \nbegin\n\ntheorem amc12b_2020_p21:\n shows \"card {n. (n + 1000) / 70 = floor (sqrt n)} = 6\"\n by sorry\n\nend" }, { "theorem_id": 159, "title": "amc12b_2020_p21", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2020_p21\n (S : Finset ℕ)\n (h₀ : ∀ (n : ℕ), n ∈ S ↔ 0 < n ∧ (↑n + (1000 : ℝ)) / 70 = Int.floor (Real.sqrt n)) :\n S.card = 6 := by sorry" }, { "theorem_id": 159, "title": "amc12b_2020_p21", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Rfunctions.\nRequire Import Sets.Ensembles.\nRequire Import Sets.Finite_sets.\nRequire Import ZArith.\n\nOpen Scope R_scope.\n\nTheorem amc12b_2020_p21:\n let S := fun n:nat => \n (0 < n)%nat /\\ \n exists k:Z, \n (IZR k = (INR n + 1000) / 70) /\\\n k = Z.of_nat (Z.to_nat (up (sqrt (INR n)) - 1)) in\n Finite nat S /\\ cardinal nat S 6.\n\nProof.\n" }, { "theorem_id": 160, "title": "amc12b_2020_p22", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2020-p22 = `!t:real. ((exp (t * ln (&2)) - &3 * t) * t) / (exp(t * ln (&4))) <= &1 / &12`;;\n" }, { "theorem_id": 160, "title": "amc12b_2020_p22", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2020_p22\n imports Complex_Main \"HOL-Library.Code_Target_Numeral\"\nbegin\n\ntheorem amc12b_2020_p22:\n fixes t :: real\n shows \"((2 powr t - 3 * t) * t) / (4 powr t) \\ 1 / 12\"\n by sorry\n\nend" }, { "theorem_id": 160, "title": "amc12b_2020_p22", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2020_p22\n (t : ℝ) :\n ((2^t - 3 * t) * t) / (4^t) ≤ 1 / 12 := by sorry" }, { "theorem_id": 160, "title": "amc12b_2020_p22", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2020_p22 : forall t : R,\n ((exp (t * ln 2) - 3 * t) * t) / (exp (t * ln 4)) <= 1 / 12 /\\\n exists t, ((exp (t * ln 2) - 3 * t) * t) / (exp (t * ln 4)) = 1/12.\nProof.\n" }, { "theorem_id": 161, "title": "amc12b_2020_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12b-2020-p5 = `!a:num b:num.\n (a > 0 /\\ b > 0) /\\\n (&5 / &8 * &b - &2 / &3 * &a = &7) /\\\n (&b - &5 / &8 * &b - (&a - &2 / &3 * &a) = &7)\n==>\n a = 42\n`;;\n" }, { "theorem_id": 161, "title": "amc12b_2020_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12b_2020_p5 imports\n Complex_Main\nbegin\n\ntheorem amc12b_2020_p5:\n fixes a b :: nat\n assumes \"(5::real) / 8 * b - 2 / 3 * a = 7\"\n and \"of_nat b - (5::real) / 8 * b - (a - 2 / 3 * a) = 7\"\n shows \"a = 42\"\n by sorry\n\nend" }, { "theorem_id": 161, "title": "amc12b_2020_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2020_p5 (a b : ℕ) (h₀ : (5 : ℚ) / 8 * b = 2 / 3 * a + 7)\n (h₁ : (b : ℚ) - 5 / 8 * b = a - 2 / 3 * a + 7) : a = 42 := by sorry" }, { "theorem_id": 161, "title": "amc12b_2020_p5", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\n\nTheorem amc12b_2020_p5 :\n forall (ap bp aw al bw bl : nat),\n ap = aw + al -> \n bp = bw + bl ->\n 3* aw = 2 * ap ->\n 8* bw = 5 * bp ->\n aw = 7+bw ->\n al = 7+bl ->\n ap = 42.\nProof.\nAdmitted." }, { "theorem_id": 162, "title": "amc12b_2020_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2020-p6 = `!n:num. 9 <= n ==> ?x. &(x EXP 2) = real_of_int (int_of_num (FACT (n + 2)) - &(FACT (n + 1))) / &(FACT n)`;;\n" }, { "theorem_id": 162, "title": "amc12b_2020_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2020_p6\n imports Complex_Main \nbegin\n\ntheorem amc12b_2020_p6:\n fixes n :: nat\n assumes h0: \"9 \\ n\" \n shows \"\\x::nat. (real_of_nat x)^2 = (fact (n + 2) \n - fact (n + 1)) / fact n\"\n by sorry\n\nend" }, { "theorem_id": 162, "title": "amc12b_2020_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2020_p6\n (n : ℕ)\n (h₀ : 9 ≤ n) :\n ∃ (x : ℕ), (x : ℝ)^2 = (Nat.factorial (n + 2) - Nat.factorial (n + 1)) / n ! := by sorry" }, { "theorem_id": 162, "title": "amc12b_2020_p6", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "\n\nRequire Import Coq.Arith.Arith.\nRequire Import Coq.Arith.PeanoNat.\n\nTheorem amc12b_2020_p6:\n forall (n : nat),\n 9 <= n ->\n exists x : nat,\n x ^ 2 = (fact (n + 2) - fact (n + 1)) / fact n.\n\nProof.\n" }, { "theorem_id": 163, "title": "amc12b_2021_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2021-p1 = `(FINITE {x:int | real_of_int (abs x) < &3 * pi}) ==> (CARD {x:int | real_of_int (abs x) < &3 * pi} = 19)`;;\n" }, { "theorem_id": 163, "title": "amc12b_2021_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2021_p1\n imports Complex_Main \nbegin\n\ntheorem amc12b_2021_p1:\n shows \"card {x::int. \\real_of_int x\\ < 3 * pi} = 19\"\n by sorry\n\nend" }, { "theorem_id": 163, "title": "amc12b_2021_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2021_p1\n (S : Finset ℤ)\n (h₀ : ∀ (x : ℤ), x ∈ S ↔ ↑(abs x) < 3 * Real.pi):\n S.card = 19 := by sorry" }, { "theorem_id": 163, "title": "amc12b_2021_p1", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import ZArith.\nRequire Import Finite_sets_facts.\nRequire Import Coquelicot.Coquelicot.\n\nTheorem amc12b_2021_p1:\n let S := fun x:Z => (Rabs (IZR x) < 3 * PI)%R in\n cardinal Z S 19%nat.\n\nProof.\n" }, { "theorem_id": 164, "title": "amc12b_2021_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2021-p13 = `FINITE {x | &0 < x /\\ x <= &2 * pi /\\ &1 - &3 * sin x + &5 * cos (&3 * x) = &0} ==> CARD {x | &0 < x /\\ x <= &2 * pi /\\ &1 - &3 * sin x + &5 * cos (&3 * x) = &0} = 6`;;\n" }, { "theorem_id": 164, "title": "amc12b_2021_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2021_p13\n imports Complex_Main\nbegin\n\ntheorem amc12b_2021_p13:\n shows \"card {x :: real. 0 < x \\ x \\ 2 * pi \\ 1 - 3 * sin x \n + 5 * cos (3 * x) = 0} = 6\"\n by sorry\n\nend" }, { "theorem_id": 164, "title": "amc12b_2021_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2021_p13\n (S : Finset ℝ)\n (h₀ : ∀ (x : ℝ), x ∈ S ↔ 0 < x ∧ x ≤ 2 * Real.pi ∧ 1 - 3 * Real.sin x + 5 * Real.cos (3 * x) = 0) :\n S.card = 6 := by sorry" }, { "theorem_id": 164, "title": "amc12b_2021_p13", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Sets.Ensembles.\nRequire Import Sets.Finite_sets_facts.\nOpen Scope R_scope.\n\nTheorem amc12b_2021_p13 :\n exists (S : Ensemble R), \n (forall x : R, In R S x <-> \n (0 < x /\\ x <= 2 * PI /\\ 1 - 3 * sin x + 5 * cos (3 * x) = 0)) /\\\n cardinal R S 6.\n\nProof.\n" }, { "theorem_id": 165, "title": "amc12b_2021_p18", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2021-p18 = `!z:complex.\n (&12 * (norm z) pow 2 = &2 * (norm (z + Cx (&2))) pow 2 + (norm (z pow 2 + Cx (&1))) pow 2 + &31)\n==>\n z + Cx (&6) / z = -- Cx(&2)`;;\n" }, { "theorem_id": 165, "title": "amc12b_2021_p18", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2021_p18\n imports Complex_Main\nbegin\n\ntheorem amc12b_2021_p18:\n fixes z :: complex\n assumes h0: \"12 * norm z = 2 * \n norm (z + 2) + norm (z^2 + 1) + 31\"\n shows \"z + 6 / z = -2\"\n by sorry\n\nend" }, { "theorem_id": 165, "title": "amc12b_2021_p18", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2021_p18\n (z : ℂ)\n (h₀ : 12 * Complex.normSq z = 2 * Complex.normSq (z + 2) + Complex.normSq (z^2 + 1) + 31) :\n z + 6 / z = -2 := by sorry" }, { "theorem_id": 165, "title": "amc12b_2021_p18", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem amc12b_2021_p18 :\n forall z : C,\n 12 * (Cmod z)² = \n 2 * (Cmod (z + 2))² + \n (Cmod (z * z + 1))² + 31 ->\n z + 6 / z = -2.\n\nProof.\n" }, { "theorem_id": 166, "title": "amc12b_2021_p21", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let amc12b-2021-p21 = `(FINITE {x:real | (&0 < x) /\\ (exp ((exp (sqrt (&2) * ln (&2))) * ln (x)) = exp ((exp (x * ln (&2))) * ln (sqrt (&2))))})\n==>\n (&2 <= sum {x:real | (&0 < x) /\\ (exp ((exp (sqrt (&2) * ln (&2))) * ln (x)) = exp ((exp (x * ln (&2))) * ln (sqrt (&2))))} (\\k. k)) /\\\n (sum {x:real | (&0 < x) /\\ (exp ((exp (sqrt (&2) * ln (&2))) * ln (x)) = exp ((exp (x * ln (&2))) * ln (sqrt (&2))))} (\\k. k) < &6)\n`;;\n" }, { "theorem_id": 166, "title": "amc12b_2021_p21", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory amc12b_2021_p21 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem amc12b_2021_p21:\n \"2 \\ (\\ k \\ {x ::real. 0 < x \\ x powr (2 powr (sqrt 2))\n = (sqrt 2) powr (2 powr x)}. k) \\ \n (\\ k \\ {x :: real. 0 < x \\ x powr (2 powr (sqrt 2)) \n = (sqrt 2)powr (2 powr x)}. k) < 6\"\n by sorry\n\nend " }, { "theorem_id": 166, "title": "amc12b_2021_p21", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2021_p21 (S : Finset ℝ)\n (h₀ : ∀ x : ℝ, x ∈ S ↔ 0 < x ∧ x ^ (2 : ℝ) ^ Real.sqrt 2 = Real.sqrt 2 ^ (2 : ℝ) ^ x) :\n (↑2 ≤ ∑ k ∈ S, k) ∧ (∑ k ∈ S, k) < 6 := by sorry" }, { "theorem_id": 166, "title": "amc12b_2021_p21", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\nRequire Import List.\n\nOpen Scope R_scope.\n\nTheorem amc12b_2021_p21 (S : list R) :\n NoDup S ->\n (forall x : R, In x S <-> \n (0 < x /\\ Rpower x (Rpower 2 (sqrt 2)) = Rpower (sqrt 2) (Rpower 2 x))) ->\n 2 <= fold_right Rplus 0 S /\\ fold_right Rplus 0 S < 6.\n\nProof.\n" }, { "theorem_id": 167, "title": "amc12b_2021_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2021-p3 = `!x:real.\n (&2 + &1 / (&1 + &1 / (&2 + &2 / (&3 + x))) = &144 / &53)\n==>\n (x = &3 / &4)\n`;;\n" }, { "theorem_id": 167, "title": "amc12b_2021_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2021_p3\n imports Complex_Main\nbegin\n\ntheorem amc12b_2021_p3:\n fixes x :: real\n assumes h0: \"2 + 1 / (1 + 1 / (2 + 2 / (3 + x))) = 144 / 53\" \n shows \"x = 3 / 4\"\n by sorry\n\nend" }, { "theorem_id": 167, "title": "amc12b_2021_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2021_p3\n (x : ℝ)\n (h₀ : 2 + 1 / (1 + 1 / (2 + 2 / (3 + x))) = 144 / 53) :\n x = 3 / 4 := by sorry" }, { "theorem_id": 167, "title": "amc12b_2021_p3", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2021_p3:\n forall x : R,\n 2 + 1 / (1 + 1 / (2 + 2 / (3 + x))) = 144 / 53 -> \n x = 3 / 4.\nProof.\nAdmitted." }, { "theorem_id": 168, "title": "amc12b_2021_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2021-p4 = `!m:num a:num.\n (m > 0 /\\ a > 0) /\\\n (&m / &a = &3 / &4)\n==>\n (&84 * &m + &70 * &a) / (&m + &a) = &76\n`;;\n" }, { "theorem_id": 168, "title": "amc12b_2021_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2021_p4\n imports Complex_Main\nbegin\n\ntheorem amc12b_2021_p4:\n fixes m a :: nat\n assumes h0: \"m / a = 3 / (4::real)\" \n shows \"84 * m + 70 * a / (m + a) = (76::real)\" \n by sorry\n\nend" }, { "theorem_id": 168, "title": "amc12b_2021_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2021_p4\n (m a : ℕ)\n (h₀ : 0 < m ∧ 0 < a)\n (h₁ : ↑m / ↑a = (3:ℝ) / 4) :\n (84 * ↑m + 70 * ↑a) / (↑m + ↑a) = (76:ℝ) := by sorry" }, { "theorem_id": 168, "title": "amc12b_2021_p4", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2021_p4 :\n forall (m a : nat),\n (0 < m)%nat ->\n (0 < a)%nat ->\n INR m / INR a = 3 / 4 ->\n (84 * INR m + 70 * INR a) / (INR m + INR a) = 76.\n\nProof.\n" }, { "theorem_id": 169, "title": "amc12b_2021_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let amc12b-2021-p9 = `(ln (&80) / ln (&2)) / (ln (&2) / ln (&40)) - (ln (&160) / ln (&2)) / (ln (&2) / ln (&20)) = &2`;;\n" }, { "theorem_id": 169, "title": "amc12b_2021_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory amc12b_2021_p9\n imports Complex_Main\nbegin\n\ntheorem amc12b_2021_p9:\n shows \"(ln 80 / ln 2) / (ln 2 / ln 40) - (ln 160 / ln 2) \n / (ln 2 / ln 20) = (2::real)\"\n by sorry\n\nend" }, { "theorem_id": 169, "title": "amc12b_2021_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem amc12b_2021_p9 :\n (Real.log 80 / Real.log 2) / (Real.log 2 / Real.log 40) - (Real.log 160 / Real.log 2) / (Real.log 2 / Real.log 20) = 2 := by sorry" }, { "theorem_id": 169, "title": "amc12b_2021_p9", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem amc12b_2021_p9 :\n (ln 80 / ln 2) / (ln 2 / ln 40) - (ln 160 / ln 2) / (ln 2 / ln 20) = 2.\nProof.\nAdmitted." }, { "theorem_id": 170, "title": "imo_1990_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let imo-1990-p3 = `!n:num.\n (2 <= n) /\\\n ((n EXP 2) divides (2 EXP n + 1))\n ==> n = 3`;;\n" }, { "theorem_id": 170, "title": "imo_1990_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory imo_1990_p3 imports\n Complex_Main\nbegin\ntheorem imo_1990_p3:\n fixes n :: nat\n assumes \"2 \\ n\"\n and \"n^2 dvd 2^n + 1\"\n shows \"n = 3\"\n by sorry\n\nend" }, { "theorem_id": 170, "title": "imo_1990_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem imo_1990_p3 (n : ℕ) (h₀ : 2 ≤ n) (h₁ : n ^ 2 ∣ 2 ^ n + 1) : n = 3 := by sorry" }, { "theorem_id": 170, "title": "imo_1990_p3", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\n\nTheorem imo_1990_p3 :\n forall n : nat,\n 2 <= n ->\n (exists k, k * (n * n) = 2^n + 1) ->\n n = 3.\nProof.\nAdmitted." }, { "theorem_id": 171, "title": "induction_11div10tonmn1ton", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let induction-11div10tonmn1ton = `!n. 11 divides num_of_int (&(10 EXP n) - (-- &1) pow n)`;;\n" }, { "theorem_id": 171, "title": "induction_11div10tonmn1ton", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory induction_11div10tonmn1ton\n imports Complex_Main\nbegin\n\ntheorem induction_11div10tonmn1ton:\n fixes n :: nat\n shows \"(11::int) dvd (10^n - (-1)^n)\"\n by sorry\n\nend" }, { "theorem_id": 171, "title": "induction_11div10tonmn1ton", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_11div10tonmn1ton\n (n : ℕ) :\n 11 ∣ (10^n - (-1 : ℤ)^n) := by sorry" }, { "theorem_id": 171, "title": "induction_11div10tonmn1ton", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith ZArith Znumtheory.\n\nTheorem induction_11div10tonmn1ton:\n forall n : nat,\n Z.divide 11 (Z.pow 10 (Z.of_nat n) - Z.pow (-1) (Z.of_nat n)).\nProof.\nAdmitted.\n" }, { "theorem_id": 172, "title": "induction_12dvd4expnp1p20", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let induction-12dvd4expnp1p20 = `!n. 12 divides 4 EXP (n+1) + 20`;;\n" }, { "theorem_id": 172, "title": "induction_12dvd4expnp1p20", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory induction_12dvd4expnp1p20\n imports Complex_Main\nbegin\n\ntheorem induction_12dvd4expnp1p20:\n fixes n :: nat\n shows \"(12::int) dvd 4^(n+1) + 20\"\n by sorry\n\nend" }, { "theorem_id": 172, "title": "induction_12dvd4expnp1p20", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_12dvd4expnp1p20\n (n : ℕ) :\n 12 ∣ 4^(n+1) + 20 := by sorry" }, { "theorem_id": 172, "title": "induction_12dvd4expnp1p20", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem induction_12dvd4expnp1p20 :\n forall n : nat, exists k : nat, 4^(n+1) + 20 = 12 * k.\n\nProof.\n" }, { "theorem_id": 173, "title": "induction_1pxpownlt1pnx", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let induction-1pxpownlt1pnx = `!x n. n > 0 /\\ -- &1 < x ==> (&1 + x) pow n <= &1 + &n * x`;;\n" }, { "theorem_id": 173, "title": "induction_1pxpownlt1pnx", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory induction_1pxpownlt1pnx \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem induction_1pxpownlt1pnx:\n fixes x :: real and n :: nat\n assumes \"-1 < x\"\n shows \"(1 + n*x) \\ (1 + x)^n\"\n by sorry\n\nend " }, { "theorem_id": 173, "title": "induction_1pxpownlt1pnx", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_1pxpownlt1pnx\n (x : ℝ)\n (n : ℕ)\n (h₀ : -1 < x)\n (h₁ : 0 < n) :\n (1 + ↑n*x) ≤ (1 + x)^(n:ℕ) := by sorry" }, { "theorem_id": 173, "title": "induction_1pxpownlt1pnx", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\n\nOpen Scope R_scope.\n\nTheorem induction_1pxpownlt1pnx\n (x : R)\n (n : nat)\n (h₀ : -1 < x) :\n (1 + INR n * x) <= Rpower (1 + x) (INR n).\n\nProof.\n" }, { "theorem_id": 174, "title": "induction_divisibility_3div2tooddnp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let induction-divisibility-3div2tooddnp1 = `!n:num. 3 divides (2 EXP (2 * n + 1) + 1)`;;\n" }, { "theorem_id": 174, "title": "induction_divisibility_3div2tooddnp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory induction_divisibility_3div2tooddnp1\n imports\n Complex_Main\nbegin\n\ntheorem induction_divisibility_3div2tooddnp1:\n fixes n ::nat\n shows \"(3::nat) dvd (2^(2 * n + 1) + 1)\"\n by sorry\n\nend " }, { "theorem_id": 174, "title": "induction_divisibility_3div2tooddnp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_divisibility_3div2tooddnp1 (n : ℕ) : 3 ∣ 2 ^ (2 * n + 1) + 1 := by sorry" }, { "theorem_id": 174, "title": "induction_divisibility_3div2tooddnp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import ZArith.\nRequire Import Znumtheory.\n\nTheorem induction_divisibility_3div2tooddnp1:\n forall n : nat,\n (exists k, 2^(2 * n + 1) + 1 = 3 * k)%nat.\nProof.\nAdmitted." }, { "theorem_id": 175, "title": "induction_divisibility_3divnto3m2n", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let induction-divisibility-3divnto3m2n = `!n:num. 3 divides n EXP 3 + 2 * n`;;\n" }, { "theorem_id": 175, "title": "induction_divisibility_3divnto3m2n", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory induction_divisibility_3divnto3m2n\n imports\n Complex_Main\nbegin\n\ntheorem induction_divisibility_3divnto3m2n:\n fixes n::nat\n shows \"3 dvd n^3 + 2 * n\"\n by sorry\n\nend" }, { "theorem_id": 175, "title": "induction_divisibility_3divnto3m2n", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_divisibility_3divnto3m2n (n : ℕ) : 3 ∣ n ^ 3 + 2 * n := by sorry" }, { "theorem_id": 175, "title": "induction_divisibility_3divnto3m2n", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import Arith.\n\nTheorem induction_divisibility_3divnto3m2n :\n forall n : nat, exists k : nat, n^3 + 2*n = 3*k.\nProof.\nAdmitted." }, { "theorem_id": 176, "title": "induction_divisibility_9div10tonm1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let induction-divisibility-9div10tonm1 = `!n:num. (n > 0) ==> 9 divides (10 EXP n - 1)`;;\n" }, { "theorem_id": 176, "title": "induction_divisibility_9div10tonm1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory induction_divisibility_9div10tonm1\n imports\n Complex_Main\nbegin\n\ntheorem induction_divisibility_9div10tonm1:\n fixes n::nat\n shows \"(9::nat) dvd 10^n - 1\"\n by sorry\n\nend" }, { "theorem_id": 176, "title": "induction_divisibility_9div10tonm1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_divisibility_9div10tonm1 (n : ℕ) (h₀ : 0 < n) : 9 ∣ 10 ^ n - 1 := by sorry" }, { "theorem_id": 176, "title": "induction_divisibility_9div10tonm1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Numbers.Natural.Abstract.NDiv.\nRequire Import Coq.Arith.PeanoNat.\n\nTheorem induction_divisibility_9div10tonm1 :\n forall n : nat, 0 < n -> Nat.divide 9 (10^n - 1).\n\nProof.\n" }, { "theorem_id": 177, "title": "induction_ineq_nsqlefactn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let induction-ineq-nsqlefactn = `!n:num. 4 <= n ==> n EXP 2 <= FACT n`;;\n" }, { "theorem_id": 177, "title": "induction_ineq_nsqlefactn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory induction_ineq_nsqlefactn\n imports\n Complex_Main\nbegin\n\ntheorem induction_ineq_nsqlefactn:\n fixes n::nat\n assumes \" 4 \\ n\"\n shows \"n^2 \\ fact n\" using assms\n by sorry\n\nend" }, { "theorem_id": 177, "title": "induction_ineq_nsqlefactn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_ineq_nsqlefactn (n : ℕ) (h₀ : 4 ≤ n) : n ^ 2 ≤ n ! := by sorry" }, { "theorem_id": 177, "title": "induction_ineq_nsqlefactn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\nRequire Import Coq.Arith.PeanoNat.\nRequire Import Coq.Init.Nat.\nRequire Import Coq.ZArith.BinInt.\n\nTheorem induction_ineq_nsqlefactn :\n forall n : nat,\n 4 <= n ->\n n^2 <= fact n.\nProof.\nAdmitted." }, { "theorem_id": 178, "title": "induction_nfactltnexpnm1ngt3", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let induction-nfactltnexpnm1ngt3 = `!n. 3 <= n ==> FACT n < n EXP (n - 1)`;;\n" }, { "theorem_id": 178, "title": "induction_nfactltnexpnm1ngt3", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory induction_nfactltnexpnm1ngt3 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem induction_nfactltnexpnm1ngt3:\n fixes n ::nat\n assumes \"3 \\ n\" \n shows \"fact n < n^(n - 1)\"\n by sorry\n\nend" }, { "theorem_id": 178, "title": "induction_nfactltnexpnm1ngt3", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_nfactltnexpnm1ngt3\n (n : ℕ)\n (h₀ : 3 ≤ n) :\n (n)! < n^(n - 1) := by sorry" }, { "theorem_id": 178, "title": "induction_nfactltnexpnm1ngt3", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem induction_nfactltnexpnm1ngt3:\n forall (n : nat),\n 3 <= n ->\n fact n < n^(n - 1).\nProof.\nAdmitted." }, { "theorem_id": 179, "title": "induction_seq_mul2pnp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let induction-seq-mul2pnp1 = `!n:num u:num->num.\n (u 0 = 0) /\\\n (!n. u (n + 1) = 2 * u n + (n + 1))\n==>\n (u n = 2 EXP (n + 1) - (n + 2))\n`;;\n" }, { "theorem_id": 179, "title": "induction_seq_mul2pnp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory induction_seq_mul2pnp1 imports\nComplex_Main\n\nbegin\n\ntheorem induction_seq_mul2pnp1:\n fixes n :: nat\n and u :: \"nat \\ nat\"\n assumes h0 : \"u 0 = 0\"\n and h1 : \"\\(n::nat). u (n+1) = 2 * u n + (n+1)\"\n shows \"u n = 2 ^ (n+1) - (n+2)\"\n by sorry\n\nend" }, { "theorem_id": 179, "title": "induction_seq_mul2pnp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_seq_mul2pnp1 (n : ℕ) (u : ℕ → ℕ) (h₀ : u 0 = 0)\n (h₁ : ∀ n, u (n + 1) = 2 * u n + (n + 1)) : u n = 2 ^ (n + 1) - (n + 2) := by sorry" }, { "theorem_id": 179, "title": "induction_seq_mul2pnp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\n\nTheorem induction_seq_mul2pnp1 :\n forall n : nat,\n forall u : nat -> nat,\n (u 0 = 0) ->\n (forall n, u (n + 1) = 2 * u n + (n + 1)) ->\n (u n = 2 ^ (n + 1) - (n + 2)).\nProof.\nAdmitted." }, { "theorem_id": 180, "title": "induction_sum2kp1npqsqm1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let induction-sum2kp1npqsqm1 = `!n:num. &(nsum (0..(n-1)) (\\k. 2 * k + 3)) = int_of_num (n + 1) pow 2 - &1`;;\n" }, { "theorem_id": 180, "title": "induction_sum2kp1npqsqm1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory induction_sum2kp1npqsqm1 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem induction_sum2kp1npqsqm1:\n fixes n :: nat \n shows \"(\\ k nat) (n : nat) : nat :=\n match n with\n | 0 => 0\n | S m => f m + sum_f f m\n end.\n\nTheorem induction_sum2kp1npqsqm1 : forall n : nat,\n sum_f (fun k => 2 * k + 3) n = (n + 1) * (n + 1) - 1.\nProof.\nAdmitted." }, { "theorem_id": 181, "title": "induction_sum_1oktkp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let induction-sum-1oktkp1 = `!n:num. sum(0..(n-1)) (\\k. (&1) / (&((k + 1) * (k + 2)))) = (&n) / (&(n + 1))`;;\n" }, { "theorem_id": 181, "title": "induction_sum_1oktkp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory induction_sum_1oktkp1 imports\n Complex_Main\nbegin\n\ntheorem induction_sum_1oktkp1:\n fixes n :: nat\n shows \"n=0 \\ (\\(k::nat) = 0..(n-1). (1::real)/((k+1)*(k+2))) = n / (n+1)\"\n by sorry\n \nend" }, { "theorem_id": 181, "title": "induction_sum_1oktkp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_sum_1oktkp1 (n : ℕ) :\n (∑ k ∈ Finset.range n, (1 : ℝ) / ((k + 1) * (k + 2))) = n / (n + 1) := by sorry" }, { "theorem_id": 181, "title": "induction_sum_1oktkp1", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nOpen Scope R_scope.\n\n\n\nTheorem induction_sum_1oktkp1 :\n forall (n : nat),\n (1 <= n)%nat ->\n (sum_f_R0 (fun k => / (INR (k + 1) * INR (k + 2))) (n - 1)) = (INR n) / (INR n + 1).\n\nProof.\n" }, { "theorem_id": 182, "title": "induction_sum_odd", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let induction-sum-odd = `!n:num. nsum(0..(n-1)) (\\k. 2 * k + 1) = n EXP 2`;;\n" }, { "theorem_id": 182, "title": "induction_sum_odd", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory induction_sum_odd imports\n Complex_Main\nbegin\n\ntheorem induction_sum_odd:\n fixes n :: nat\n assumes \"n > 0\"\n shows \"(\\(k::nat) = 0..(n-1). 2 * k + 1) = n^2\"\n by sorry\n\nend" }, { "theorem_id": 182, "title": "induction_sum_odd", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem induction_sum_odd (n : ℕ) : (∑ k ∈ Finset.range n, (2 * k + 1)) = n ^ 2 := by sorry" }, { "theorem_id": 182, "title": "induction_sum_odd", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\n\nFixpoint sum_n (f : nat -> nat) (n : nat) : nat :=\n match n with\n | 0 => 0\n | S m => f m + sum_n f m\n end.\n\nTheorem induction_sum_odd : forall n : nat,\n n > 0 ->\n sum_n (fun k => 2 * k + 1) n = n * n.\nProof.\nAdmitted." }, { "theorem_id": 183, "title": "mathd_algebra_10", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-10 = `abs ((&120) / (&100) * (&30) - (&130) / (&100) * (&20)) = &10`;;\n" }, { "theorem_id": 183, "title": "mathd_algebra_10", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_10 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_10:\n \"abs ((120::real) / 100 * 30 - 130 / 100 * 20) = 10\"\n by sorry\n\nend" }, { "theorem_id": 183, "title": "mathd_algebra_10", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_10 : abs ((120 : ℝ) / 100 * 30 - 130 / 100 * 20) = 10 := by sorry" }, { "theorem_id": 183, "title": "mathd_algebra_10", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_10:\n Rabs ((120 / 100) * 30 - (130 / 100) * 20) = 10.\nProof.\nAdmitted." }, { "theorem_id": 184, "title": "mathd_algebra_101", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-101 = `!x:real. (x pow 2 - &5 * x - &4 <= &10) ==> x >= -- &2 /\\ x <= &7`;;\n" }, { "theorem_id": 184, "title": "mathd_algebra_101", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_101 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_101:\n fixes x :: real\n assumes h0 : \"x^2 - 5 * x - 4 \\ 10\"\n shows \"x\\ -2 \\ x \\ 7\"\n by sorry\n\nend" }, { "theorem_id": 184, "title": "mathd_algebra_101", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_101 (x : ℝ) (h₀ : x ^ 2 - 5 * x - 4 ≤ 10) : x ≥ -2 ∧ x ≤ 7 := by sorry" }, { "theorem_id": 184, "title": "mathd_algebra_101", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_101:\n forall x : R, (x^2 - 5 * x - 4 <= 10) -> (x >= -2) /\\ (x <= 7).\nProof.\nAdmitted." }, { "theorem_id": 185, "title": "mathd_algebra_104", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-104 = `!x:real.\n ((&125) / (&8) = x / (&12))\n==>\n (x = (&375) / (&2))\n`;;\n" }, { "theorem_id": 185, "title": "mathd_algebra_104", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_104 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_104:\n fixes x :: real\n assumes h0 : \"125/8 = x /12\"\n shows \"x = 375/2\"\n by sorry\n\nend" }, { "theorem_id": 185, "title": "mathd_algebra_104", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_104 (x : ℝ) (h₀ : 125 / 8 = x / 12) : x = 375 / 2 := by sorry" }, { "theorem_id": 185, "title": "mathd_algebra_104", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_104 (x : R) (h0 : 125 / 8 = x / 12) : x = 375 / 2.\nProof.\nAdmitted." }, { "theorem_id": 186, "title": "mathd_algebra_107", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-107 = `!x y. x pow 2 + &8 * x + y pow 2 - &6 * y = &0 ==> (x + &4) pow 2 + (y - &3) pow 2 = &5 pow 2`;;\n" }, { "theorem_id": 186, "title": "mathd_algebra_107", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_107 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_107:\n fixes x y :: real\n assumes \"x^2 + 8 * x + y^2 - 6 * y = 0\" \n shows \"(x + 4)^2 + (y-3)^2 = 5^2\"\n by sorry\n\nend" }, { "theorem_id": 186, "title": "mathd_algebra_107", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_107\n (x y : ℝ)\n (h₀ : x^2 + 8 * x + y^2 - 6 * y = 0) :\n (x + 4)^2 + (y-3)^2 = 5^2 := by sorry" }, { "theorem_id": 186, "title": "mathd_algebra_107", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_107:\n forall (x y : R),\n (x^2 + 8 * x + y^2 - 6 * y = 0) ->\n (x + 4)^2 + (y - 3)^2 = 5^2.\nProof.\nAdmitted." }, { "theorem_id": 187, "title": "mathd_algebra_109", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-109 = `!a:real b:real.\n (&3 * a + &2 * b = &12) /\\\n (a = &4)\n==>\n b = &0\n`;;\n" }, { "theorem_id": 187, "title": "mathd_algebra_109", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_109 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_109:\n fixes a b :: real\n assumes h0 : \"3*a+2*b=12\"\n and h1 : \"a=4\"\n shows \"b=0\"\n by sorry\n\nend" }, { "theorem_id": 187, "title": "mathd_algebra_109", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_109 (a b : ℝ) (h₀ : 3 * a + 2 * b = 12) (h₁ : a = 4) : b = 0 := by sorry" }, { "theorem_id": 187, "title": "mathd_algebra_109", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_109 (a b : R) :\n 3 * a + 2 * b = 12 ->\n a = 4 ->\n b = 0.\nProof.\nAdmitted.\n" }, { "theorem_id": 188, "title": "mathd_algebra_11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-11 = `!a:real b:real.\n (~(a = b)) /\\\n (~(a = &2 * b)) /\\\n ((&4 * a + &3 * b) / (a - &2 * b) = &5)\n==>\n ((a + &11 * b) / (a - b) = &2)\n`;;\n" }, { "theorem_id": 188, "title": "mathd_algebra_11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_11 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_11:\n fixes a b :: real\n assumes h0 : \"a \\ b\"\n and h1 : \"a \\ 2 * b\"\n and h2 : \"(4*a+3*b) / (a-2*b) = 5\"\n shows \"(a+11*b) / (a-b) = 2\"\n by sorry\n\nend" }, { "theorem_id": 188, "title": "mathd_algebra_11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_11 (a b : ℝ) (h₀ : a ≠ b) (h₁ : a ≠ 2 * b)\n (h₂ : (4 * a + 3 * b) / (a - 2 * b) = 5) : (a + 11 * b) / (a - b) = 2 := by sorry" }, { "theorem_id": 188, "title": "mathd_algebra_11", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_11:\n forall (a b : R),\n a <> b ->\n a <> 2 * b ->\n (4 * a + 3 * b) / (a - 2 * b) = 5 ->\n (a + 11 * b) / (a - b) = 2.\nProof.\nAdmitted." }, { "theorem_id": 189, "title": "mathd_algebra_110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-110 = `!q:complex e:complex.\n (q = Cx(&2) - Cx(&2) * ii) /\\\n (e = Cx(&5) + Cx(&5) * ii)\n==>\n q * e = Cx(&20)\n`;;\n" }, { "theorem_id": 189, "title": "mathd_algebra_110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_110 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_110:\n fixes q e :: complex\n assumes h0 : \"q = Complex (Re 2) (Im (-2))\"\n and h1 : \"e = Complex (Re 5) (Im 5)\"\n shows \"q * e = 20\"\n by sorry\n\nend" }, { "theorem_id": 189, "title": "mathd_algebra_110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_110 (q e : ℂ) (h₀ : q = 2 - 2 * Complex.I) (h₁ : e = 5 + 5 * Complex.I) :\n q * e = 20 := by sorry" }, { "theorem_id": 189, "title": "mathd_algebra_110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem mathd_algebra_110 :\n forall q e : C,\n q = 2 - 2 * Ci ->\n e = 5 + 5 * Ci ->\n q * e = 20.\n\nProof.\n" }, { "theorem_id": 190, "title": "mathd_algebra_113", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-113 = `!x. x pow 2 - &14 * x + &3 >= &7 pow 2 - &14 * &7 + &3`;;\n" }, { "theorem_id": 190, "title": "mathd_algebra_113", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_113 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_113:\n fixes x ::real\n shows \"x^2 - 14 * x + 3 \\ 7^2 - 14 * 7 + 3\"\n by sorry\n\nend " }, { "theorem_id": 190, "title": "mathd_algebra_113", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_113\n (x : ℝ) :\n x^2 - 14 * x + 3 ≥ 7^2 - 14 * 7 + 3 := by sorry" }, { "theorem_id": 190, "title": "mathd_algebra_113", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_113 (x : R) :\n x^2 - 14 * x + 3 >= 7^2 - 14 * 7 + 3.\nProof.\nAdmitted." }, { "theorem_id": 191, "title": "mathd_algebra_114", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-114 = `!a:real. (a = &8) ==> exp (&1 / &3 * ln (exp (&1 / &3 * ln (&16 * (a pow 2))))) = &4`;;\n" }, { "theorem_id": 191, "title": "mathd_algebra_114", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_114 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_114:\n fixes a :: real\n assumes \"a = 8\" \n shows \"(16 * (a^2) powr (1 / 3)) powr (1 / 3) = 4\"\n by sorry\n\nend " }, { "theorem_id": 191, "title": "mathd_algebra_114", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_114\n (a : ℝ)\n (h₀ : a = 8) :\n (16 * (a^2) ^ (1 / 3 : ℝ)) ^ (1 / 3 : ℝ) = 4 := by sorry" }, { "theorem_id": 191, "title": "mathd_algebra_114", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_114 (a : R)\n (H : a = 8) :\n Rpower (16 * Rpower (a ^ 2) (1/3)) (1/3) = 4.\n\nProof.\n" }, { "theorem_id": 192, "title": "mathd_algebra_116", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-116 = `!k:real x:real.\n (x = (&13 - sqrt (&131)) / (&4)) /\\\n (&2 * x pow 2 - &13 * x + k = &0)\n==>\n (k = (&19) / (&4))\n`;;\n" }, { "theorem_id": 192, "title": "mathd_algebra_116", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_116 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_116:\n fixes k x :: real\n assumes h0 : \"x = (13 - sqrt 131) / 4\"\n and h1 : \"2 * x^2 - 13 * x + k = 0\"\n shows \"k = 19/4\"\n by sorry\nend" }, { "theorem_id": 192, "title": "mathd_algebra_116", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_116 (k x : ℝ) (h₀ : x = (13 - Real.sqrt 131) / 4)\n (h₁ : 2 * x ^ 2 - 13 * x + k = 0) : k = 19 / 4 := by sorry" }, { "theorem_id": 192, "title": "mathd_algebra_116", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_116 :\n forall (k x : R),\n x = (13 - sqrt 131) / 4 ->\n 2 * x^2 - 13 * x + k = 0 ->\n k = 19/4.\nProof.\nAdmitted." }, { "theorem_id": 193, "title": "mathd_algebra_119", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-119 = `!d:real e:real.\n (&2 * d = &17 * e - &8) /\\\n (&2 * e = d - &9)\n==>\n e = &2\n`;;\n" }, { "theorem_id": 193, "title": "mathd_algebra_119", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_119 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_119:\n fixes d e :: real\n assumes h0 : \"2 * d = 17 * e - 8\"\n and h1 : \"2 * e = d - 9\"\n shows \"e = 2\"\n by sorry\n\nend" }, { "theorem_id": 193, "title": "mathd_algebra_119", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_119 (d e : ℝ) (h₀ : 2 * d = 17 * e - 8) (h₁ : 2 * e = d - 9) : e = 2 := by sorry" }, { "theorem_id": 193, "title": "mathd_algebra_119", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_119:\n forall (d e : R), \n (2 * d = 17 * e - 8) -> \n (2 * e = d - 9) -> \n e = 2.\nProof.\nAdmitted." }, { "theorem_id": 194, "title": "mathd_algebra_123", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-123 = `!a:int b:int.\n (a > &0 /\\ b > &0) /\\\n (a + b = &20) /\\\n (a = &3 * b)\n==>\n a - b = &10\n`;;\n" }, { "theorem_id": 194, "title": "mathd_algebra_123", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_123 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_123:\n fixes a b :: nat\n assumes h0 : \"a + b = 20\"\n and h1 : \"a = 3 * b\"\n shows \"a - b = 10\"\n by sorry\n\nend" }, { "theorem_id": 194, "title": "mathd_algebra_123", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_123 (a b : ℕ) (h₀ : 0 < a ∧ 0 < b) (h₁ : a + b = 20) (h₂ : a = 3 * b) :\n a - b = 10 := by sorry" }, { "theorem_id": 194, "title": "mathd_algebra_123", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_algebra_123\n (a b : nat)\n (h₀ : a + b = 20)\n (h₁ : a = 3 * b) :\n a - b = 10.\nProof.\nAdmitted." }, { "theorem_id": 195, "title": "mathd_algebra_125", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-125 = `!x:int y:int. x > &0 /\\ y > &0 /\\ &5 * x = y /\\ x - &3 + y - &3 = &30 ==> x = &6`;;\n" }, { "theorem_id": 195, "title": "mathd_algebra_125", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_125 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_125:\n fixes x y :: nat\n assumes \"5 * x = y\"\n and \"(x - 3) + (y - 3) = 30\" \n shows \"x = 6\"\n by sorry\nend " }, { "theorem_id": 195, "title": "mathd_algebra_125", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_125\n (x y : ℕ)\n (h₀ : 0 < x ∧ 0 < y)\n (h₁ : 5 * x = y)\n (h₂ : (↑x - (3:ℤ)) + (y - (3:ℤ)) = 30) :\n x = 6 := by sorry" }, { "theorem_id": 195, "title": "mathd_algebra_125", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_algebra_125 :\n forall x y : nat,\n 0 < x -> 0 < y ->\n 5 * x = y ->\n (x - 3) + (y - 3) = 30 ->\n x = 6.\nProof.\nAdmitted.\n" }, { "theorem_id": 196, "title": "mathd_algebra_126", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-126 = `!x:real y:real.\n (&2 * &3 = x - &9) /\\\n (&2 * (-- &5) = y + &1)\n==>\n (x = &15) /\\\n (y = -- &11)\n`;;\n" }, { "theorem_id": 196, "title": "mathd_algebra_126", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_126 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_126:\n fixes x y :: real\n assumes h0 : \"2 * 3 = x - 9\"\n and h1 : \"2 * (-5) = y + 1\"\n shows \"x=15 \\ y = -11\"\n by sorry\n\nend" }, { "theorem_id": 196, "title": "mathd_algebra_126", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_126 (x y : ℝ) (h₀ : 2 * 3 = x - 9) (h₁ : 2 * -5 = y + 1) : x = 15 ∧ y = -11 := by sorry" }, { "theorem_id": 196, "title": "mathd_algebra_126", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_126 (x y : R) :\n 2 * IZR(3) = x - IZR(9) ->\n 2 * IZR(-5) = y + IZR(1) ->\n x = IZR(15) /\\ y = IZR(-11).\n\nProof.\n" }, { "theorem_id": 197, "title": "mathd_algebra_129", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-129 = `!a:real.\n ~(a = &0) /\\\n ((&1 / &8) / (&1 / &4) - (&1 / a) = &1)\n==>\n a = -- &2\n`;;\n" }, { "theorem_id": 197, "title": "mathd_algebra_129", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_129 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_129:\n fixes a :: real\n assumes \"a \\ 0\"\n and \"(inverse 8) / (inverse 4) - (inverse a) = 1\" \n shows \"a = -2\"\n by sorry\n\nend " }, { "theorem_id": 197, "title": "mathd_algebra_129", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_129\n (a : ℝ)\n (h₀ : a ≠ 0)\n (h₁ : 8⁻¹ / 4⁻¹ - a⁻¹ = 1) :\n a = -2 := by sorry" }, { "theorem_id": 197, "title": "mathd_algebra_129", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_129:\n forall a : R,\n a <> 0 ->\n (/ 8) / (/ 4) - / a = 1 ->\n a = -2.\nProof.\nAdmitted." }, { "theorem_id": 198, "title": "mathd_algebra_13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-13 = `!a:real b:real.\n (!x. &4 * x / (x pow 2 - &8 * x + &15) = a / (x - &3) + b / (x - &5))\n==>\n a = -- &6 /\\ b = &10\n`;;\n" }, { "theorem_id": 198, "title": "mathd_algebra_13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_13 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_13:\n fixes a b :: real\n assumes h0: \"\\(x::real). (x-3 \\ 0 \\ x - 5 \\ 0) \\ \n 4 * x / (x^2 - 8 * x + 15) = a / (x-3) + b / (x-5)\"\n shows \"a = -6 \\ b = 10\"\n by sorry\n\nend" }, { "theorem_id": 198, "title": "mathd_algebra_13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_13 (a b : ℝ)\n (h₀ : ∀ x, x - 3 ≠ 0 ∧ x - 5 ≠ 0 → 4 * x / (x ^ 2 - 8 * x + 15) = a / (x - 3) + b / (x - 5)) :\n a = -6 ∧ b = 10 := by sorry" }, { "theorem_id": 198, "title": "mathd_algebra_13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_13:\n forall (A B : R),\n (forall x : R, (x - 3 <> 0) /\\ (x - 5 <> 0) -> \n 4 * x / (x ^ 2 - 8 * x + 15) = A / (x - 3) + B / (x - 5)) ->\n A = -6 /\\ B = 10.\nProof.\nAdmitted." }, { "theorem_id": 199, "title": "mathd_algebra_131", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-131 = `!a:real b:real f:real->real.\n (!x. f x = &2 * x pow 2 - &7 * x + &2) /\\\n (f a = &0) /\\\n (f b = &0) /\\\n ~(a = b)\n==>\n &1 / (a - &1) + &1 / (b - &1) = -- &1\n`;;\n" }, { "theorem_id": 199, "title": "mathd_algebra_131", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_131 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_131:\n fixes a b :: real\n and f :: \"real \\ real\"\n assumes h0 : \"\\x. f x = 2 * x^2 - 7 * x + 2\"\n and h1 : \"f a = 0\"\n and h2 : \"f b = 0\"\n and h3 : \"a \\ b\"\n shows \"1 / (a-1) + 1 / (b-1) = -1\"\n by sorry\n\nend" }, { "theorem_id": 199, "title": "mathd_algebra_131", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_131 (a b : ℝ) (f : ℝ → ℝ) (h₀ : ∀ x, f x = 2 * x ^ 2 - 7 * x + 2)\n (h₁ : f a = 0) (h₂ : f b = 0) (h₃ : a ≠ b) : 1 / (a - 1) + 1 / (b - 1) = -1 := by sorry" }, { "theorem_id": 199, "title": "mathd_algebra_131", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_131 :\n forall (a b : R) (f : R -> R),\n (forall x, f x = 2 * x^2 - 7 * x + 2) ->\n f a = 0 ->\n f b = 0 ->\n a <> b ->\n 1 / (a - 1) + 1 / (b - 1) = -1.\nProof.\nAdmitted." }, { "theorem_id": 200, "title": "mathd_algebra_132", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-132 = `!x:real f:real->real g:real->real.\n (!x. f x = x + &2) /\\\n (!x. g x = x pow 2) /\\\n (f (g x) = g (f x))\n==>\n x = -- (&1) / (&2)\n`;;\n" }, { "theorem_id": 200, "title": "mathd_algebra_132", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_132 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_132:\n fixes x :: real\n and f g :: \"real \\ real\"\n assumes h0 : \"\\x. f x = x + 2\"\n and h1 : \"\\x. g x = x^2\"\n and h2 : \"f (g x) = g (f x)\"\n shows \"x = -1/2\"\n by sorry\n\nend" }, { "theorem_id": 200, "title": "mathd_algebra_132", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_132 (x : ℝ) (f g : ℝ → ℝ) (h₀ : ∀ x, f x = x + 2) (h₁ : ∀ x, g x = x ^ 2)\n (h₂ : f (g x) = g (f x)) : x = -1 / 2 := by sorry" }, { "theorem_id": 200, "title": "mathd_algebra_132", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_132 :\n forall (x : R) (f g : R -> R),\n (forall x, f x = x + 2) ->\n (forall x, g x = x^2) ->\n (f (g x) = g (f x)) ->\n x = -1 / 2.\nProof.\nAdmitted." }, { "theorem_id": 201, "title": "mathd_algebra_137", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-137 = `!x:num.\n (&x + &4 / &100 * &x = &598)\n==>\n (x = 575)\n`;;\n" }, { "theorem_id": 201, "title": "mathd_algebra_137", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_137 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_137:\n fixes x::nat\n assumes \" x + 4 / 100 * x = 598\" \n shows \"x = 575\"\n by sorry\n\nend" }, { "theorem_id": 201, "title": "mathd_algebra_137", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_137\n (x : ℕ)\n (h₀ : ↑x + (4:ℝ) / (100:ℝ) * ↑x = 598) :\n x = 575 := by sorry" }, { "theorem_id": 201, "title": "mathd_algebra_137", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Nat.\nRequire Import Coq.Init.Nat.\n\nTheorem mathd_algebra_137 :\n forall x : nat,\n (IZR (Z_of_nat x) + (4/100) * IZR (Z_of_nat x))%R = 598%R ->\n x = 575.\nProof.\nAdmitted.\n" }, { "theorem_id": 202, "title": "mathd_algebra_139", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-139 = `!s:real->real->real.\n (!x y.\n ~(x = &0) /\\ ~(y = &0)\n ==>\n (s x y = ((&1) / y - (&1) / x) / (x-y))\n )\n==>\n (s (&3) (&11) = (&1) / (&33))\n`;;\n" }, { "theorem_id": 202, "title": "mathd_algebra_139", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_139 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_139:\n fixes s :: \"real \\ real \\ real\"\n assumes \"\\ x\\0. \\y\\0. s x y = (1/y - 1/x) / (x-y)\"\n shows \"s 3 11 = 1/33\"\n by sorry\n\nend " }, { "theorem_id": 202, "title": "mathd_algebra_139", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_139\n (s : ℝ → ℝ → ℝ)\n (h₀ : ∀ x, ∀ y, x≠0 -> y≠0 -> s x y = (1/y - 1/x) / (x-y)) :\n s 3 11 = 1/33 := by sorry" }, { "theorem_id": 202, "title": "mathd_algebra_139", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_139 : \n forall s : R -> R -> R,\n (forall x y : R, x <> 0 -> y <> 0 -> s x y = (1/y - 1/x)/(x - y)) ->\n s 3 11 = 1/33.\nProof.\nAdmitted." }, { "theorem_id": 203, "title": "mathd_algebra_140", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-140 = `!a:real b:real c:real.\n (&0 < a /\\ &0 < b /\\ &0 < c) /\\\n (!x. &24 * x pow 2 - &19 * x - &35 = (((a * x) - &5) * ((&2 * (b * x)) + c)))\n==>\n (a * b - &3 * c = -- &9)\n`;;\n" }, { "theorem_id": 203, "title": "mathd_algebra_140", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_140 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_140:\n fixes a b c :: real\n assumes h0 : \"0 < a \\ 0 < b \\ 0 < c\"\n and h1 : \"\\x. 24 * x^2 - 19 * x - 35 = ((a*x-5) * (2 * (b*x) + c))\"\n shows \"a * b - 3 * c = -9\"\n by sorry\n\nend" }, { "theorem_id": 203, "title": "mathd_algebra_140", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_140 (a b c : ℝ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c)\n (h₁ : ∀ x, 24 * x ^ 2 - 19 * x - 35 = (a * x - 5) * (2 * (b * x) + c)) : a * b - 3 * c = -9 := by sorry" }, { "theorem_id": 203, "title": "mathd_algebra_140", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_140 :\n forall a b c : R,\n (0 < a) -> (0 < b) -> (0 < c) ->\n (forall x : R, 24 * x^2 - 19 * x - 35 = (a * x - 5) * (2 * (b * x) + c)) ->\n a * b - 3 * c = -9.\nProof.\nAdmitted." }, { "theorem_id": 204, "title": "mathd_algebra_141", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-141 = `!a:real b:real.\n (a >= &0) /\\ (b >= &0) /\\\n ((a * b) = &180) /\\\n (&2 * (a + b) = &54)\n==>\n a pow 2 + b pow 2 = &369\n`;;\n" }, { "theorem_id": 204, "title": "mathd_algebra_141", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_141 imports Complex_Main\nbegin\n\ntheorem mathd_algebra_141:\n fixes a b ::real\n assumes \"(a * b)=180\"\n and \"2 * (a + b)=54\"\n shows \"a^2 + b^2 = 369\" \n by sorry\n\nend " }, { "theorem_id": 204, "title": "mathd_algebra_141", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_141\n (a b : ℝ)\n (h₁ : (a * b)=180)\n (h₂ : 2 * (a + b)=54) :\n (a^2 + b^2) = 369 := by sorry" }, { "theorem_id": 204, "title": "mathd_algebra_141", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_141\n (a b : R)\n (h₁ : a * b = 180)\n (h₂ : 2 * (a + b) = 54) :\n a^2 + b^2 = 369.\nProof.\nAdmitted." }, { "theorem_id": 205, "title": "mathd_algebra_142", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-142 = `!m:real b:real.\n (m * &7 + b = -- &1) /\\\n (m * (-- &1) + b = &7)\n==>\n m + b = &5\n`;;\n" }, { "theorem_id": 205, "title": "mathd_algebra_142", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_142 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_142:\n fixes m b ::real\n assumes \"m * 7 + b = -1\"\n and \"m * (-1) + b = 7\" \n shows \"m + b = 5\"\n by sorry\n\nend " }, { "theorem_id": 205, "title": "mathd_algebra_142", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_142\n (m b : ℝ)\n (h₀ : m * 7 + b = -1)\n (h₁ : m * (-1) + b = 7) :\n m + b = 5 := by sorry" }, { "theorem_id": 205, "title": "mathd_algebra_142", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_142 :\n forall (m b : R), \n (m * 7 + b = -1) -> \n (m * (-1) + b = 7) -> \n (m + b = 5).\nProof.\nAdmitted." }, { "theorem_id": 206, "title": "mathd_algebra_143", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-143 = `!f:real->real g:real->real.\n (!x. f x = x + &1) /\\\n (!x. g x = x pow 2 + &3)\n==>\n (f (g (&2)) = &8)\n`;;\n" }, { "theorem_id": 206, "title": "mathd_algebra_143", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_143 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_143:\n fixes f g :: \"real \\ real\"\n assumes \"\\ x. f x = x + 1\"\n and \"\\ x. g x = x^2 + 3\" \n shows \"f (g 2) = 8\"\n by sorry\n\nend " }, { "theorem_id": 206, "title": "mathd_algebra_143", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_143\n (f g : ℝ → ℝ)\n (h₀ : ∀ x, f x = x + 1)\n (h₁ : ∀ x, g x = x^2 + 3) :\n f (g 2) = 8 := by sorry" }, { "theorem_id": 206, "title": "mathd_algebra_143", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_143 :\n forall (f g : R -> R),\n (forall x, f x = x + 1) ->\n (forall x, g x = x^2 + 3) ->\n f (g 2) = 8.\nProof.\nAdmitted." }, { "theorem_id": 207, "title": "mathd_algebra_144", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-144 = `!a:int b:int c:int d:int.\n (a > &0 /\\ b > &0 /\\ c > &0 /\\ d > &0) /\\\n (c - b = d) /\\\n (b - a = d) /\\\n (a + b + c = &60) /\\\n (a + b > c)\n==>\n d < &10\n`;;\n" }, { "theorem_id": 207, "title": "mathd_algebra_144", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_144 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_144:\n fixes a b c d :: nat\n assumes h0:\"c - b = d\"\n and h1:\"b - a = d\"\n and h2: \"a+b+c = 60\"\n and h3: \"a + b > c\"\n shows \"d < 10\"\n by sorry\n\nend" }, { "theorem_id": 207, "title": "mathd_algebra_144", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_144 (a b c d : ℕ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c ∧ 0 < d) (h₀ : (c : ℤ) - b = d)\n (h₁ : (b : ℤ) - a = d) (h₂ : a + b + c = 60) (h₃ : a + b > c) : d < 10 := by sorry" }, { "theorem_id": 207, "title": "mathd_algebra_144", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.PeanoNat.\n\nTheorem mathd_algebra_144\n (a b c d : nat)\n (h0 : 0 < a) (h1 : 0 < b) (h2 : 0 < c) (h3 : 0 < d)\n (h4 : c - b = d)\n (h5 : b - a = d)\n (h6 : a + b + c = 60)\n (h7 : a + b > c) :\n d < 10.\nProof.\nAdmitted." }, { "theorem_id": 208, "title": "mathd_algebra_148", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-148 = `!c:real f:real->real.\n (!x. f x = c * x pow 3 - &9 * x + &3) /\\\n (f (&2) = &9)\n==>\n c = &3\n`;;\n" }, { "theorem_id": 208, "title": "mathd_algebra_148", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_148 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_148:\n fixes c :: real and f :: \"real \\ real\"\n assumes \"\\ x. f x = c * x^3 - 9 * x + 3\"\n and \"f 2 = 9\" \n shows \"c = 3\"\n by sorry\n\nend " }, { "theorem_id": 208, "title": "mathd_algebra_148", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_148\n (c : ℝ)\n (f : ℝ → ℝ)\n (h₀ : ∀ x, f x = c * x^3 - 9 * x + 3)\n (h₁ : f 2 = 9) :\n c = 3 := by sorry" }, { "theorem_id": 208, "title": "mathd_algebra_148", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_148 :\n forall (c : R) (f : R -> R),\n (forall x, f x = c * x^3 - 9 * x + 3) ->\n f 2 = 9 ->\n c = 3.\nProof.\nAdmitted." }, { "theorem_id": 209, "title": "mathd_algebra_149", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-149 = `!f:real->real.\n (!x. x < -- &5 ==> f x = x pow 2 + &5) /\\\n (!x. x >= -- &5 ==> f x = &3 * x - &8) /\\\n (FINITE {x | f x = &10})\n==>\n sum {x | f x = &10} (\\k. k) = &6\n`;;\n" }, { "theorem_id": 209, "title": "mathd_algebra_149", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_149 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_149:\n fixes f :: \"real \\ real\"\n assumes \"\\ x < -5. f x = x^2 + 5\"\n and \"\\ x \\ -5. f x = 3 * x -8\"\n shows \"(\\ k \\ (f -` {10}). k) = 6\" \n by sorry\n\nend " }, { "theorem_id": 209, "title": "mathd_algebra_149", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_149 (f : ℝ → ℝ) (h₀ : ∀ x < -5, f x = x ^ 2 + 5)\n (h₁ : ∀ x ≥ -5, f x = 3 * x - 8) (h₂ : Fintype (f ⁻¹' {10})) :\n (∑ k ∈ (f ⁻¹' {10}).toFinset, k) = 6 := by sorry" }, { "theorem_id": 209, "title": "mathd_algebra_149", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\nRequire Import List.\nRequire Import Sets.Finite_sets.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_149 :\n forall (f : R -> R),\n (forall x, x < -5 -> f x = x^2 + 5) ->\n (forall x, x >= -5 -> f x = 3 * x - 8) ->\n exists (l : list R),\n NoDup l /\\\n (forall x, In x l <-> f x = 10) /\\\n fold_right Rplus 0 l = 6.\n\nProof.\n" }, { "theorem_id": 210, "title": "mathd_algebra_15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-15 = `!s:num->num->num.\n (!a:num b:num. (a > 0 /\\ b > 0) ==> (s a b = a EXP b + b EXP a))\n==>\n (s 2 6 = 100)\n`;;\n" }, { "theorem_id": 210, "title": "mathd_algebra_15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_15 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_15:\n fixes s :: \"nat \\ nat \\ nat\"\n assumes h0: \"\\a b. s a b = a ^ b + b ^ a\"\n shows \"s 2 6 = 100\"\n by sorry\n\nend" }, { "theorem_id": 210, "title": "mathd_algebra_15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_15 (s : ℕ → ℕ → ℕ)\n (h₀ : ∀ a b, 0 < a ∧ 0 < b → s a b = a ^ (b : ℕ) + b ^ (a : ℕ)) : s 2 6 = 100 := by sorry" }, { "theorem_id": 210, "title": "mathd_algebra_15", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import Arith.\n\nTheorem mathd_algebra_15\n (s : nat -> nat -> nat)\n (h0 : forall a b, 0 < a -> 0 < b -> s a b = a ^ b + b ^ a) :\n s 2 6 = 100.\nProof.\nAdmitted." }, { "theorem_id": 211, "title": "mathd_algebra_151", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-151 = `!c:int.\n (sqrt (&27) <= real_of_int c) /\\\n (!z:int. (sqrt (&27) <= real_of_int z) ==> (c <= z))\n==>\n real_of_int c - floor (sqrt (&26)) = &1\n`;;\n" }, { "theorem_id": 211, "title": "mathd_algebra_151", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_151 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_151:\n shows \"ceiling (sqrt 27) - floor (sqrt 26) = 1\"\n by sorry\n\nend " }, { "theorem_id": 211, "title": "mathd_algebra_151", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_151 : Int.ceil (Real.sqrt 27) - Int.floor (Real.sqrt 26) = 1 := by sorry" }, { "theorem_id": 211, "title": "mathd_algebra_151", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Rfunctions.\nRequire Import ZArith.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_151:\n Z.sub (up (sqrt 27)) (up (sqrt 26) - 1) = 1%Z.\n\nProof.\n" }, { "theorem_id": 212, "title": "mathd_algebra_153", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-153 = `!n:real.\n (n = &1 / &3)\n==>\n floor (&10 * n) + floor (&100 * n) + floor (&1000 * n) + floor (&10000 * n) = &3702\n`;;\n" }, { "theorem_id": 212, "title": "mathd_algebra_153", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_153 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_153:\n fixes n :: real\n assumes \"n = 1 / 3\" \n shows \"floor (10 * n) + floor (100 * n) \n + floor (1000 * n) + floor (10000 * n) = 3702\"\n by sorry\n\nend" }, { "theorem_id": 212, "title": "mathd_algebra_153", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_153\n (n : ℝ)\n (h₀ : n = 1 / 3) :\n Int.floor (10 * n) + Int.floor (100 * n) + Int.floor (1000 * n) + Int.floor (10000 * n) = 3702 := by sorry" }, { "theorem_id": 212, "title": "mathd_algebra_153", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_153 :\n forall n : R,\n n = 1/3 ->\n IZR (Int_part (10 * n)) + IZR (Int_part (100 * n)) + \n IZR (Int_part (1000 * n)) + IZR (Int_part (10000 * n)) = 3702.\n\nProof.\n" }, { "theorem_id": 213, "title": "mathd_algebra_156", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-156 = `!x y f g. (!t. f t = t pow 4) /\\ (!t. g t = &5*t pow 2 - &6) /\\ (f x = g x) /\\ (f y = g y) /\\ (x pow 2 < y pow 2) ==> y pow 2 - x pow 2 = &1`;;\n" }, { "theorem_id": 213, "title": "mathd_algebra_156", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_156 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_156:\n fixes x y :: real\n and f g :: \"real \\ real\"\n assumes \"\\t. f t = t^4\"\n and \"\\t. g t = 5 * t^2 - 6\"\n and \"f x = g x\"\n and \"f y = g y\"\n and \"x^2 < y^2\" \n shows \"y^2 - x^2 = 1\"\n by sorry\n\nend" }, { "theorem_id": 213, "title": "mathd_algebra_156", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_156\n (x y : ℝ)\n (f g : ℝ → ℝ)\n (h₀ : ∀t, f t = t^4)\n (h₁ : ∀t, g t = 5 * t^2 - 6)\n (h₂ : f x = g x)\n (h₃ : f y = g y)\n (h₄ : x^2 < y^2) :\n y^2 - x^2 = 1 := by sorry" }, { "theorem_id": 213, "title": "mathd_algebra_156", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_156 (x y : R) (f g : R -> R) :\n (forall t, f t = t^4) ->\n (forall t, g t = 5 * t^2 - 6) ->\n f x = g x ->\n f y = g y ->\n x^2 < y^2 ->\n y^2 - x^2 = 1.\nProof.\nAdmitted.\n" }, { "theorem_id": 214, "title": "mathd_algebra_158", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-158 = `!a:num.\n (EVEN a) /\\\n (&(nsum (0..(8-1)) (\\k. 2 * k + 1)) - &(nsum (0..(5-1)) (\\k. a + 2 * k)) = int_of_num 4)\n==>\n a = 8\n`;;\n" }, { "theorem_id": 214, "title": "mathd_algebra_158", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_158 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_158:\n fixes a :: nat\n assumes \"even a\"\n and \"(\\ k < 8. (2 * k + 1)) - \n (\\ k<5. (a + 2 * k)) = 4\"\n shows \"a = 8\"\n by sorry\n\nend " }, { "theorem_id": 214, "title": "mathd_algebra_158", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_158\n (a : ℕ)\n (h₀ : Even a)\n (h₁ : ∑ k ∈ Finset.range 8, (2 * k + 1) - ∑ k ∈ Finset.range 5, (a + 2 * k) = (4:ℤ)) :\n a = 8 := by sorry" }, { "theorem_id": 214, "title": "mathd_algebra_158", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import NArith.\nRequire Import List.\nImport ListNotations.\n\nTheorem mathd_algebra_158 a :\n list_sum (map (fun k => 2 * k + 1) (seq 0 8)) -\n list_sum (map (fun k => a + 2 * k) (seq 0 5)) = 4 ->\n a = 8.\nProof.\nAdmitted.\n" }, { "theorem_id": 215, "title": "mathd_algebra_159", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-159 = `!b:real f:real->real.\n (!x. f x = &3 * x pow 4 - &7 * x pow 3 + &2 * x pow 2 - b * x + &1) /\\\n (f (&1) = &1)\n==>\n (b = -- &2)\n`;;\n" }, { "theorem_id": 215, "title": "mathd_algebra_159", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_159 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_159:\n fixes b :: real\n and f :: \"real \\ real\"\n assumes h0 : \"\\x. f x = 3 * x^4 - 7 * x^3 + 2*x^2 - b*x +1\"\n and h1 : \"f 1 = 1\"\n shows \"b = -2\"\n by sorry\n\nend" }, { "theorem_id": 215, "title": "mathd_algebra_159", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_159 (b : ℝ) (f : ℝ → ℝ)\n (h₀ : ∀ x, f x = 3 * x ^ 4 - 7 * x ^ 3 + 2 * x ^ 2 - b * x + 1) (h₁ : f 1 = 1) : b = -2 := by sorry" }, { "theorem_id": 215, "title": "mathd_algebra_159", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_159:\n forall (b : R) (f : R -> R),\n (forall x, f x = 3 * (x^4) - 7 * (x^3) + 2 * (x^2) - b * x + 1) ->\n f 1 = 1 ->\n b = -2.\nProof.\nAdmitted." }, { "theorem_id": 216, "title": "mathd_algebra_160", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-160 = `!n:real x:real.\n (n + x = &97) /\\\n (n + &5 * x = &265)\n==>\n (n + &2 * x = &139)\n`;;\n\n\n" }, { "theorem_id": 216, "title": "mathd_algebra_160", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_160 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_160:\n fixes n x ::real\n assumes \"n + x = 97\"\n and \"n + 5 * x = 265\"\n shows \"n + 2 * x = 139\" \n by sorry\n\nend" }, { "theorem_id": 216, "title": "mathd_algebra_160", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_160\n (n x : ℝ)\n (h₀ : n + x = 97)\n (h₁ : n + 5 * x = 265) :\n n + 2 * x = 139 := by sorry" }, { "theorem_id": 216, "title": "mathd_algebra_160", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_160 (n x : R) :\n (n + x = 97) ->\n (n + 5 * x = 265) ->\n (n + 2 * x = 139).\nProof.\nAdmitted." }, { "theorem_id": 217, "title": "mathd_algebra_17", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-17 = `!a. sqrt (&4 + sqrt (&16 + &16 * a)) + sqrt (&1 + sqrt (&1 + a)) = &6 ==> a = &8`;;\n" }, { "theorem_id": 217, "title": "mathd_algebra_17", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_17 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_17:\n fixes a :: real\n assumes \"sqrt (4 + sqrt (16 + 16 * a)) \n + sqrt (1 + sqrt (1 + a)) = 6\" \n shows \"a = 8\"\n by sorry\n\nend" }, { "theorem_id": 217, "title": "mathd_algebra_17", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_17\n (a : ℝ)\n (h₀ : Real.sqrt (4 + Real.sqrt (16 + 16 * a)) + Real.sqrt (1 + Real.sqrt (1 + a)) = 6) :\n a = 8 := by sorry" }, { "theorem_id": 217, "title": "mathd_algebra_17", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_17 (a : R) \n (h : sqrt (4 + sqrt (16 + 16 * a)) + sqrt (1 + sqrt (1 + a)) = 6) :\n a = 8.\nProof.\nAdmitted." }, { "theorem_id": 218, "title": "mathd_algebra_170", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-170 = `FINITE {n:int | abs (real_of_int n - &2) <= &5 + &6 / &10} ==> CARD {n:int | abs (real_of_int n - &2) <= &5 + &6 / &10} = 11`;;\n" }, { "theorem_id": 218, "title": "mathd_algebra_170", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_170 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_170:\n \"card { n::int. abs (n - 2) \\ 5 + 6 / 10} = 11\"\n by sorry\n\nend" }, { "theorem_id": 218, "title": "mathd_algebra_170", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_170\n (S : Finset ℤ)\n (h₀ : ∀ (n : ℤ), n ∈ S ↔ abs (n - 2) ≤ 5 + 6 / 10) :\n S.card = 11 := by sorry" }, { "theorem_id": 218, "title": "mathd_algebra_170", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import ZArith.\nRequire Import List.\nRequire Import SetoidList.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_170:\n forall (S: list Z),\n NoDup S ->\n (forall n:Z, In n S <-> (Rabs (IZR n - 2) <= 5.6)%R) ->\n length S = 11%nat.\n\nProof.\n" }, { "theorem_id": 219, "title": "mathd_algebra_171", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-171 = `!f. (!x. f x = &5 * x + &4) ==> f (&1) = &9`;;\n" }, { "theorem_id": 219, "title": "mathd_algebra_171", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_171 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_171:\n fixes f :: \"real \\ real\"\n assumes \"\\x. f x = 5 * x + 4\" \n shows \"f 1 = 9\"\n by sorry\n\nend" }, { "theorem_id": 219, "title": "mathd_algebra_171", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_171\n (f : ℝ → ℝ)\n (h₀ : ∀x, f x = 5 * x + 4) :\n f 1 = 9 := by sorry" }, { "theorem_id": 219, "title": "mathd_algebra_171", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_171 (f : R -> R) :\n (forall x, f x = 5 * x + 4) -> f 1 = 9.\nProof.\nAdmitted.\n" }, { "theorem_id": 220, "title": "mathd_algebra_176", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-176 = `!x:real. (x + &1) pow 2 * x = x pow 3 + &2 * x pow 2 + x`;;\n" }, { "theorem_id": 220, "title": "mathd_algebra_176", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_176 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_176:\n fixes x ::real\n shows \"(x + 1)^2 * x = x^3 + 2 * x^2 + x\"\n by sorry\n\nend" }, { "theorem_id": 220, "title": "mathd_algebra_176", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_176\n (x : ℝ) :\n (x + 1)^2 * x = x^3 + 2 * x^2 + x := by sorry" }, { "theorem_id": 220, "title": "mathd_algebra_176", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_176 (x : R) : (x + 1)^2 * x = x^3 + 2 * x^2 + x.\nProof.\nAdmitted." }, { "theorem_id": 221, "title": "mathd_algebra_181", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-181 = `!n:real.\n ~(n = &3) /\\\n ((n + &5) / (n - &3) = &2)\n==>\n n = &11\n`;;\n" }, { "theorem_id": 221, "title": "mathd_algebra_181", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_181 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_181:\n fixes n :: real\n assumes h0 : \"n \\ 3\"\n and h1 : \"(n+5) / (n-3) = 2\"\n shows \"n=11\"\n by sorry\n\nend" }, { "theorem_id": 221, "title": "mathd_algebra_181", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_181 (n : ℝ) (h₀ : n ≠ 3) (h₁ : (n + 5) / (n - 3) = 2) : n = 11 := by sorry" }, { "theorem_id": 221, "title": "mathd_algebra_181", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_181 : \n forall n : R,\n n <> 3 ->\n (n + 5) / (n - 3) = 2 ->\n n = 11.\nProof.\nAdmitted." }, { "theorem_id": 222, "title": "mathd_algebra_182", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-182 = `!y:complex. Cx(&7) * (Cx(&3) * y + Cx(&2)) = Cx(&21) * y + Cx(&14)`;;\n" }, { "theorem_id": 222, "title": "mathd_algebra_182", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_182 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_182:\n fixes y:: complex\n shows \"7*(3*y+2) = 21 * y + 14\"\n by sorry\n \nend" }, { "theorem_id": 222, "title": "mathd_algebra_182", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_182 (y : ℂ) : 7 * (3 * y + 2) = 21 * y + 14 := by sorry" }, { "theorem_id": 222, "title": "mathd_algebra_182", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem mathd_algebra_182\n (y : C) :\n 7 * (3 * y + 2) = 21 * y + 14.\n\nProof.\n" }, { "theorem_id": 223, "title": "mathd_algebra_184", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-184 = `!a:real b:real.\n (&0 < a /\\ &0 < b) /\\\n ((a pow 2) = &6 * b) /\\\n ((a pow 2) = &54 / b)\n==>\n a = &3 * sqrt (&2)\n`;;\n" }, { "theorem_id": 223, "title": "mathd_algebra_184", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_184 imports Complex_Main\nbegin\n\ntheorem mathd_algebra_184:\n fixes a b ::real\n assumes \"0 < a \\ 0 < b\"\n and \"(a^2) = 6*b\"\n and \"(a^2) = 54/b\" \n shows \"a = 3 * sqrt 2\"\n by sorry\n\nend" }, { "theorem_id": 223, "title": "mathd_algebra_184", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_184\n (a b : NNReal)\n (h₀ : 0 < a ∧ 0 < b)\n (h₁ : (a^2) = 6*b)\n (h₂ : (a^2) = 54/b) :\n a = 3 * NNReal.sqrt 2 := by sorry" }, { "theorem_id": 223, "title": "mathd_algebra_184", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coq.Reals.Reals.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_184 (a b : R)\n (h₀ : 0 < a) (h₁ : 0 < b)\n (h₂ : a^2 = 6 * b)\n (h₃ : a^2 = 54 / b) :\n a = 3 * sqrt 2.\nProof.\nAdmitted." }, { "theorem_id": 224, "title": "mathd_algebra_185", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-185 = `!f:int->int.\n (!x. f x = abs (x + &4)) /\\\n (FINITE {x | f x < &9})\n==>\n CARD {x | f x < &9 } = 17\n`;;\n" }, { "theorem_id": 224, "title": "mathd_algebra_185", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_185 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_185:\n fixes f :: \"int \\ int\"\n assumes h0 : \"\\x. (f x = abs (x+4))\"\n shows \"card {(x::int). (f x < 9)} = 17\"\n by sorry\n\nend" }, { "theorem_id": 224, "title": "mathd_algebra_185", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_185 (s : Finset ℤ) (f : ℤ → ℤ) (h₀ : ∀ x, f x = abs (x + 4))\n (h₁ : ∀ x, x ∈ s ↔ f x < 9) : s.card = 17 := by sorry" }, { "theorem_id": 224, "title": "mathd_algebra_185", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Sets.Ensembles.\nRequire Import Sets.Finite_sets.\n\nOpen Scope Z_scope.\n\nTheorem mathd_algebra_185:\n exists S : Ensemble Z,\n Finite Z S /\\\n (forall x, In Z S x <-> Z.abs (x + 4) < 9) /\\\n cardinal _ S (Z.to_nat 17).\n\n\nProof.\n" }, { "theorem_id": 225, "title": "mathd_algebra_190", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-190 = `(&3 / &8 + &7 / &8) / (&4 / &5) = &25 / &16`;;\n" }, { "theorem_id": 225, "title": "mathd_algebra_190", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_190 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_190:\n \"((3::real) / 8 + 7 / 8) / (4 / 5) = 25 / 16\"\n by sorry\n\nend" }, { "theorem_id": 225, "title": "mathd_algebra_190", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_190 : ((3 : ℝ) / 8 + 7 / 8) / (4 / 5) = 25 / 16 := by sorry" }, { "theorem_id": 225, "title": "mathd_algebra_190", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import QArith.\n\nTheorem mathd_algebra_190 :\n ((3/8 + 7/8) / (4/5) == 25/16)%Q.\nProof.\nAdmitted." }, { "theorem_id": 226, "title": "mathd_algebra_192", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-192 = `!q:complex e:complex d:complex.\n (q = Cx(&11) - (Cx(&5) * ii)) /\\\n (e = Cx(&11) + (Cx(&5) * ii)) /\\\n (d = Cx(&2) * ii)\n==>\n q * e * d = Cx(&292) * ii\n`;;\n" }, { "theorem_id": 226, "title": "mathd_algebra_192", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_192 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_192:\n fixes q e d :: complex\n assumes h0 : \"q = Complex (Re 11) (Im (-5))\"\n and h1 : \"e = Complex (Re 11) (Im 5)\"\n and h2 : \"d = Complex (Re 0) (Im 2)\"\n shows \"q * e * d = Complex (Re 0) (Im 292)\"\n by sorry\n\nend" }, { "theorem_id": 226, "title": "mathd_algebra_192", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_192 (q e d : ℂ) (h₀ : q = 11 - 5 * Complex.I) (h₁ : e = 11 + 5 * Complex.I)\n (h₂ : d = 2 * Complex.I) : q * e * d = 292 * Complex.I := by sorry" }, { "theorem_id": 226, "title": "mathd_algebra_192", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem mathd_algebra_192\n (q e d : C)\n (h0 : q = 11 - 5 * Ci)\n (h1 : e = 11 + 5 * Ci)\n (h2 : d = 2 * Ci) :\n q * e * d = 292 * Ci.\n\nProof.\n" }, { "theorem_id": 227, "title": "mathd_algebra_196", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-196 = `FINITE {x:real | abs (&2 - x) = &3} ==> sum {x:real | abs (&2 - x) = &3} (\\k. k) = &4`;;\n" }, { "theorem_id": 227, "title": "mathd_algebra_196", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_196 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_196:\n \"(\\ k \\ {x ::real. abs (2 - x) = 3}. k) = 4\"\n by sorry\n\nend " }, { "theorem_id": 227, "title": "mathd_algebra_196", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_196\n (S : Finset ℝ)\n (h₀ : ∀ (x : ℝ), x ∈ S ↔ abs (2 - x) = 3) :\n ∑ k ∈ S, k = 4 := by sorry" }, { "theorem_id": 227, "title": "mathd_algebra_196", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import ClassicalDescription.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_196 :\n exists (S : R -> Prop),\n (forall x, S x <-> Rabs (2 - x) = 3) /\\\n exists sumS, \n (forall x, S x -> x = -1 \\/ x = 5) /\\\n (S (-1) /\\ S 5) /\\\n sumS = -1 + 5 /\\\n sumS = 4.\n\nProof.\n" }, { "theorem_id": 228, "title": "mathd_algebra_206", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-206 = `!a:real b:real f:real->real.\n (!x. f x = x pow 2 + a * x + b) /\\\n ~(&2 * a = b) /\\\n (f (&2 * a) = &0) /\\\n (f b = &0)\n==>\n a + b = -- (&1)\n`;;\n" }, { "theorem_id": 228, "title": "mathd_algebra_206", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_206 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_206:\n fixes a b :: real\n and f :: \"real \\ real\"\n assumes h0 : \"\\x. f x = x^2 + a*x + b\"\n and h1 : \"2 * a \\ b\"\n and h2 : \"f (2 * a) = 0\"\n and h3 : \"f b = 0\"\n shows \"a + b = -1\"\n by sorry\n\nend" }, { "theorem_id": 228, "title": "mathd_algebra_206", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_206 (a b : ℝ) (f : ℝ → ℝ) (h₀ : ∀ x, f x = x ^ 2 + a * x + b) (h₁ : 2 * a ≠ b)\n (h₂ : f (2 * a) = 0) (h₃ : f b = 0) : a + b = -1 := by sorry" }, { "theorem_id": 228, "title": "mathd_algebra_206", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_206:\n forall (a b : R) (f : R -> R),\n (forall x, f x = x^2 + a*x + b) ->\n 2*a <> b ->\n f (2*a) = 0 ->\n f b = 0 ->\n a + b = -1.\nProof.\nAdmitted." }, { "theorem_id": 229, "title": "mathd_algebra_208", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-208 = `sqrt (&1000000) - exp ((&1 / &3) * ln (&1000000)) = &900`;;\n\n\n" }, { "theorem_id": 229, "title": "mathd_algebra_208", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_208 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_208 :\n \"sqrt 1000000 - 1000000 powr (1/3) = 900\"\n by sorry\n\nend" }, { "theorem_id": 229, "title": "mathd_algebra_208", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_208 :\n Real.sqrt 1000000 - 1000000^(1/3) = 900 := by sorry" }, { "theorem_id": 229, "title": "mathd_algebra_208", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_208 :\n sqrt 1000000 - Rpower 1000000 (1/3) = 900.\n\nProof.\n" }, { "theorem_id": 230, "title": "mathd_algebra_214", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-214 = `!a:real f:real->real.\n (!x. f x = a * (x - &2) pow 2 + &3) /\\\n (f (&4) = &4)\n==>\n f (&6) = &7\n`;;\n" }, { "theorem_id": 230, "title": "mathd_algebra_214", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_214 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_214:\n fixes a :: real\n and f :: \"real \\ real\"\n assumes h0 : \"\\x. f x = a * (x-2)^2 + 3\"\n and h1 : \"f 4 = 4\"\n shows \"f 6 = 7\"\n by sorry\n\nend" }, { "theorem_id": 230, "title": "mathd_algebra_214", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_214 (a : ℝ) (f : ℝ → ℝ) (h₀ : ∀ x, f x = a * (x - 2) ^ 2 + 3) (h₁ : f 4 = 4) :\n f 6 = 7 := by sorry" }, { "theorem_id": 230, "title": "mathd_algebra_214", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_214 :\n forall (a : R) (f : R -> R),\n (forall x, f x = a * (x - 2)^2 + 3) ->\n f 4 = 4 ->\n f 6 = 7.\nProof.\nAdmitted." }, { "theorem_id": 231, "title": "mathd_algebra_215", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-215 = `(FINITE {x:real | (x + &3) pow 2 = &121}) ==> (sum ({x:real | (x + &3) pow 2 = &121}) (\\k. k) = -- &6)`;;\n" }, { "theorem_id": 231, "title": "mathd_algebra_215", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_215 imports Complex_Main\nbegin\n\ntheorem mathd_algebra_215:\n \"(\\ k \\ {x::real. (x + 3)^2 = 121}. k) = -6\"\n by sorry\n\nend" }, { "theorem_id": 231, "title": "mathd_algebra_215", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_215\n (S : Finset ℝ)\n (h₀ : ∀ (x : ℝ), x ∈ S ↔ (x + 3)^2 = 121) :\n ∑ k ∈ S, k = -6 := by sorry" }, { "theorem_id": 231, "title": "mathd_algebra_215", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import List.\nRequire Import Lra.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_215 (S : list R)\n (h₀ : forall x, In x S <-> (x + 3)^2 = 121) \n (h₁ : NoDup S) :\n fold_right Rplus 0 S = -6.\n\nProof.\n" }, { "theorem_id": 232, "title": "mathd_algebra_22", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-22 = `ln (&(5 EXP 4)) / ln (&(5 EXP 2)) = &2`;;\n" }, { "theorem_id": 232, "title": "mathd_algebra_22", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_22 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_22:\n \"(log 2 (5^4)) / (log 2 (5^2)) = 2\"\n by sorry\n\nend" }, { "theorem_id": 232, "title": "mathd_algebra_22", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_22 : Real.logb (5 ^ 2) (5 ^ 4) = 2 := by sorry" }, { "theorem_id": 232, "title": "mathd_algebra_22", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\n\nOpen Scope R_scope.\n\n\n\nDefinition logb (a b : R) := ln b / ln a.\n\nTheorem mathd_algebra_22 : logb (5^2) (5^4) = 2.\n\nProof.\n" }, { "theorem_id": 233, "title": "mathd_algebra_224", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-224 = `(FINITE {n:num | (sqrt (&n) < &7 / &2) /\\ (&2 < sqrt (&n))}) ==> (CARD {n:num | (sqrt (&n) < &7 / &2) /\\ (&2 < sqrt (&n))} = 8)`;;\n" }, { "theorem_id": 233, "title": "mathd_algebra_224", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_224 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_224:\n \"card { n :: nat. sqrt n < 7 / 2 \\ 2 < sqrt n} = 8\"\n by sorry\n\nend " }, { "theorem_id": 233, "title": "mathd_algebra_224", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_224 (S : Finset ℕ)\n (h₀ : ∀ n : ℕ, n ∈ S ↔ Real.sqrt n < 7 / 2 ∧ 2 < Real.sqrt n) : S.card = 8 := by sorry" }, { "theorem_id": 233, "title": "mathd_algebra_224", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Finite_sets.\nRequire Import Finite_sets_facts.\nRequire Import Ensembles.\n\nOpen Scope R_scope.\n\nDefinition satisfies_condition (n : nat) : Prop :=\n (2 < sqrt (INR n))%R /\\ (sqrt (INR n) < 7/2)%R.\n\nTheorem mathd_algebra_224:\n cardinal nat (fun n => satisfies_condition n) 8.\n\nProof.\n" }, { "theorem_id": 234, "title": "mathd_algebra_234", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-234 = `!d:real.\n (&27 / &125 * d = &9 / &25)\n==>\n (&3 / &5 * d pow 3 = &25 / &9)\n`;;\n" }, { "theorem_id": 234, "title": "mathd_algebra_234", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_234 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_234:\n fixes d :: real\n assumes h0 : \"27/125 * d = 9/25\"\n shows \"3/5 * d^3 = 25/9\"\n by sorry\n\nend" }, { "theorem_id": 234, "title": "mathd_algebra_234", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_234 (d : ℝ) (h₀ : 27 / 125 * d = 9 / 25) : 3 / 5 * d ^ 3 = 25 / 9 := by sorry" }, { "theorem_id": 234, "title": "mathd_algebra_234", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Rfunctions.\nRequire Import Rbasic_fun.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_234 :\n forall d : R,\n 27/125 * d = 9/25 ->\n 3/5 * (d^3) = 25/9.\nProof.\nAdmitted." }, { "theorem_id": 235, "title": "mathd_algebra_24", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-24 = `!x. (x / &50 = &40) ==> x = &2000`;;\n" }, { "theorem_id": 235, "title": "mathd_algebra_24", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_24 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_24:\n fixes x :: real\n assumes \"x / 50 = 40\"\n shows \"x = 2000\"\n by sorry\n\nend" }, { "theorem_id": 235, "title": "mathd_algebra_24", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_24\n (x : ℝ)\n (h₀ : x / 50 = 40) :\n x = 2000 := by sorry" }, { "theorem_id": 235, "title": "mathd_algebra_24", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_24 :\n forall x : R,\n (x / 50 = 40) ->\n x = 2000.\nProof.\nAdmitted." }, { "theorem_id": 236, "title": "mathd_algebra_245", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-245 = `!x:real.\n ~(x = &0)\n==>\n inv (&4 / x) * ((&3 * x pow 3) / x) pow 2 * (inv (&1 / (&2 * x))) pow 3 = &18 * x pow 8\n`;;\n" }, { "theorem_id": 236, "title": "mathd_algebra_245", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_245 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_245:\n fixes x :: real\n assumes h0 : \"x \\ 0\"\n shows \"1/(4/x) * ((3*x^3)/x)^2 * (1/(1 / (2 * x)))^3 = 18 * x^8\"\n by sorry\nend" }, { "theorem_id": 236, "title": "mathd_algebra_245", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_245 (x : ℝ) (h₀ : x ≠ 0) :\n (4 / x)⁻¹ * (3 * x ^ 3 / x) ^ 2 * (1 / (2 * x))⁻¹ ^ 3 = 18 * x ^ 8 := by sorry" }, { "theorem_id": 236, "title": "mathd_algebra_245", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_245 :\n forall x : R,\n x <> 0 ->\n (/ (4 / x)) * (((3 * x^3) / x)^2) * ((/ (1 / (2 * x)))^3) = 18 * x^8.\n\nProof.\n" }, { "theorem_id": 237, "title": "mathd_algebra_246", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-246 = `!a:real b:real f:real->real.\n (!x. f x = a * x pow 4 - b * x pow 2 + x + &5) /\\\n (f (-- &3) = &2)\n==>\n f (&3) = &8\n`;;\n" }, { "theorem_id": 237, "title": "mathd_algebra_246", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_246 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_246:\n fixes a b :: real\n and f :: \"real \\ real\"\n assumes \"\\ x. f x = a * x^4 - b * x^2 + x + 5\"\n and \"f (-3) = 2\" \n shows \"f 3 = 8\"\n by sorry\n\nend " }, { "theorem_id": 237, "title": "mathd_algebra_246", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_246\n (a b : ℝ)\n (f : ℝ → ℝ)\n (h₀ : ∀ x, f x = a * x^4 - b * x^2 + x + 5)\n (h₂ : f (-3) = 2) :\n f 3 = 8 := by sorry" }, { "theorem_id": 237, "title": "mathd_algebra_246", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_246\n (a b : R)\n (f : R -> R)\n (h₀ : forall x, f x = a * x^4 - b * x^2 + x + 5)\n (h₂ : f (-3) = 2) :\n f 3 = 8.\nProof.\nAdmitted." }, { "theorem_id": 238, "title": "mathd_algebra_247", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-247 = `!t:real s:real n:int.\n (t = &2 * s - s pow 2) /\\\n (s = real_of_int (n pow 2) - exp (real_of_int (n) * ln (&2)) + &1) /\\\n (n = &3)\n==>\n (t = &0)\n`;;\n" }, { "theorem_id": 238, "title": "mathd_algebra_247", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_247 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_247:\n fixes t s :: real\n and n :: nat\n assumes h0 : \"t = 2 * s - s^2\"\n and h1 : \"s = n^2 - 2^n + 1\"\n and h2 : \"n=3\"\n shows \"t=0\"\n by sorry\n\nend" }, { "theorem_id": 238, "title": "mathd_algebra_247", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_247 (t s : ℝ) (n : ℤ) (h₀ : t = 2 * s - s ^ 2) (h₁ : s = n ^ 2 - 2 ^ n + 1)\n (_ : n = 3) : t = 0 := by sorry" }, { "theorem_id": 238, "title": "mathd_algebra_247", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_247 :\n forall (t s : R) (n : nat),\n t = 2 * s - s ^ 2 ->\n s = INR(n*n) - 2^(n) + 1 ->\n n = 3%nat ->\n t = 0.\n\nProof.\n" }, { "theorem_id": 239, "title": "mathd_algebra_251", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-251 = `!x:real.\n ~(x = &0) /\\\n (&3 + &1 / x = &7 / x)\n==>\n x = &2\n`;;\n" }, { "theorem_id": 239, "title": "mathd_algebra_251", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_251 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_251:\n fixes x :: real\n assumes h0: \"x \\ 0\"\n and h1: \"3 + 1/x = 7/x\"\n shows \"x = 2\"\n by sorry\n\nend" }, { "theorem_id": 239, "title": "mathd_algebra_251", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_251 (x : ℝ) (h₀ : x ≠ 0) (h₁ : 3 + 1 / x = 7 / x) : x = 2 := by sorry" }, { "theorem_id": 239, "title": "mathd_algebra_251", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_251:\n forall x : R,\n x <> 0 ->\n 3 + 1/x = 7/x ->\n x = 2.\nProof.\nAdmitted." }, { "theorem_id": 240, "title": "mathd_algebra_263", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-263 = `!y:real.\n (&0 <= &19 + &3 * y) /\\\n (sqrt (&19 + &3 * y) = &7)\n==>\n (y = &10)\n`;;\n" }, { "theorem_id": 240, "title": "mathd_algebra_263", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_263 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_263:\n fixes y :: real\n assumes \"0 \\ 19 + 3 * y\"\n and \"sqrt (19 + 3 * y) = 7\" \n shows \"y = 10\"\n by sorry\n\nend" }, { "theorem_id": 240, "title": "mathd_algebra_263", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_263\n (y : ℝ)\n (h₀ : 0 ≤ 19 + 3 * y)\n (h₁ : Real.sqrt (19 + 3 * y) = 7) :\n y = 10 := by sorry" }, { "theorem_id": 240, "title": "mathd_algebra_263", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_263 :\n forall y : R,\n (0 <= 19 + 3 * y) ->\n (sqrt (19 + 3 * y) = 7) ->\n y = 10.\nProof.\nAdmitted." }, { "theorem_id": 241, "title": "mathd_algebra_267", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-267 = `!x:real.\n ~(x = &1) /\\\n ~(x = -- &2) /\\\n ((x + &1) / (x - &1) = (x - &2) / (x + &2))\n==>\n (x = &0)\n`;;\n" }, { "theorem_id": 241, "title": "mathd_algebra_267", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_267 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_267:\n fixes x :: real\n assumes h0 : \"x \\ 1\"\n and h1 : \"x \\ -2\"\n and h2 : \"(x + 1) / (x - 1) = (x - 2) / (x + 2)\"\n shows \"x=0\"\n by sorry\n\nend" }, { "theorem_id": 241, "title": "mathd_algebra_267", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_267 (x : ℝ) (h₀ : x ≠ 1) (h₁ : x ≠ -2)\n (h₂ : (x + 1) / (x - 1) = (x - 2) / (x + 2)) : x = 0 := by sorry" }, { "theorem_id": 241, "title": "mathd_algebra_267", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_267:\n forall (x : R),\n x <> 1 -> x <> -2 -> (x + 1) / (x - 1) = (x - 2) / (x + 2) -> x = 0.\nProof.\nAdmitted." }, { "theorem_id": 242, "title": "mathd_algebra_270", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-270 = `!f:real->real.\n (!x. ~(x = -- &2) ==> f x = &1 / (x + &2))\n==>\n f (f (&1)) = &3 / &7\n`;;\n" }, { "theorem_id": 242, "title": "mathd_algebra_270", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_270 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_270:\n fixes f :: \"real \\ real\"\n assumes \"\\ x \\ -2. f x = 1 / (x + 2)\" \n shows \"f (f 1) = 3/7\"\n by sorry\n\nend " }, { "theorem_id": 242, "title": "mathd_algebra_270", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_270\n (f : ℝ → ℝ)\n (h₀ : ∀ x, x ≠ -2 -> f x = 1 / (x + 2)) :\n f (f 1) = 3/7 := by sorry" }, { "theorem_id": 242, "title": "mathd_algebra_270", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_270\n (f : R -> R)\n (h₀ : forall x : R, x <> -2 -> f x = 1 / (x + 2)) :\n f (f 1) = 3 / 7.\nProof.\nAdmitted.\n" }, { "theorem_id": 243, "title": "mathd_algebra_275", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-275 = `!x:real.\n (exp ((&3 * x - &3) * ln (exp ((&1 / &4) * ln(&11)))) = &1 / &5)\n==>\n (exp ((&6 * x + &2) * ln (exp ((&1 / &4) * ln(&11)))) = &121 / &25)\n`;;\n" }, { "theorem_id": 243, "title": "mathd_algebra_275", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_275 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_275:\n fixes x :: real\n assumes \"(11 powr (1 / 4)) powr (3 * x - 3) = 1 / 5\" \n shows \"(11 powr (1 / 4)) powr (6 * x + 2) = 121 / 25\"\n by sorry\n\nend" }, { "theorem_id": 243, "title": "mathd_algebra_275", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_275\n (x : ℝ)\n (h : ((11:ℝ)^(1 / 4))^(3 * x - 3) = 1 / 5) :\n ((11:ℝ)^(1 / 4))^(6 * x + 2) = 121 / 25 := by sorry" }, { "theorem_id": 243, "title": "mathd_algebra_275", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope R_scope.\n\n\n\nTheorem mathd_algebra_275 : \n forall x : R,\n Rpower (Rpower 11 (1/4)) (3*x - 3) = 1/5 ->\n Rpower (Rpower 11 (1/4)) (6*x + 2) = 121/25.\n\nProof.\n" }, { "theorem_id": 244, "title": "mathd_algebra_276", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-276 = `!a:int b:int.\n (!x:real. &10 * x pow 2 - x - &24 = (real_of_int a * x - &8) * (real_of_int b * x + &3))\n==>\n a + b = &12\n`;;\n" }, { "theorem_id": 244, "title": "mathd_algebra_276", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_276 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_276:\n fixes a b :: int\n assumes \"\\ x :: real. 10 * x^2 - x - 24 = (a * x - 8) * (b * x + 3)\"\n shows \"a + b = 12\"\n by sorry\n\nend" }, { "theorem_id": 244, "title": "mathd_algebra_276", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_276\n (a b : ℤ)\n (h₀ : ∀ x : ℝ, 10 * x^2 - x - 24 = (a * x - 8) * (b * x + 3)) :\n a * b + b = 12 := by sorry" }, { "theorem_id": 244, "title": "mathd_algebra_276", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import ZArith.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_276 :\n forall (a b : Z),\n (forall x : R, 10 * x^2 - x - 24 = (IZR a * x - 8) * (IZR b * x + 3)) ->\n Z.add (Z.mul a b) b = 12%Z.\n\nProof.\n" }, { "theorem_id": 245, "title": "mathd_algebra_28", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-28 = `!c:real f:real->real.\n (!x. f x = &2 * x pow 2 + &5 * x + c) /\\\n (?x. f x <= &0)\n==>\n c <= &25 / &8\n`;;\n" }, { "theorem_id": 245, "title": "mathd_algebra_28", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_28 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_28:\n fixes c :: real\n and f :: \"real \\ real\"\n assumes h0 : \"\\x. f x = 2 * x^2 + 5 * x + c\"\n and h1 : \"\\x. f x \\ 0\"\n shows \"c \\ 25/8\"\n by sorry\n\nend" }, { "theorem_id": 245, "title": "mathd_algebra_28", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_28 (c : ℝ) (f : ℝ → ℝ) (h₀ : ∀ x, f x = 2 * x ^ 2 + 5 * x + c)\n (h₁ : ∃ x, f x ≤ 0) : c ≤ 25 / 8 := by sorry" }, { "theorem_id": 245, "title": "mathd_algebra_28", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_28 :\n forall (c : R) (f : R -> R),\n (forall x, f x = 2 * x^2 + 5 * x + c) ->\n (exists x, f x <= 0) ->\n c <= 25 / 8.\nProof.\nAdmitted." }, { "theorem_id": 246, "title": "mathd_algebra_282", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-282 = `!f:real->real.\n (!x. (rational x) ==> f x = abs (floor x)) /\\\n\n !x. ~(rational x) ==> (\n !c:int. (\n (x <= real_of_int c) /\\ (!z:int. (x <= real_of_int z) ==> (c <= z))\n ==>\n f x = (real_of_int c) pow 2\n )\n )\n==>\n f (exp (&1 / &3 * ln (&8))) + f (-- pi) + f (sqrt (&50)) + f (&9 / &2) = &79\n`;;\n" }, { "theorem_id": 246, "title": "mathd_algebra_282", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_282 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_282:\n fixes f :: \"real \\ real\"\n assumes \"\\ x. (x \\ \\ ) \\ f x = abs (floor x)\"\n and \"\\ x. (x \\ \\) \\ f x = (ceiling x)^2\" \n shows \"f (8 powr (1/3)) + f (-pi) + f (sqrt 50) + f (9/2) = 79\"\n by sorry\n\nend " }, { "theorem_id": 246, "title": "mathd_algebra_282", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_282 (f : ℝ → ℝ) (h₀ : ∀ x : ℝ, ¬ (Irrational x) → f x = abs (Int.floor x))\n (h₁ : ∀ x, Irrational x → f x = (Int.ceil x) ^ 2) :\n f (8 ^ (1 / 3)) + f (-Real.pi) + f (Real.sqrt 50) + f (9 / 2) = 79 := by sorry" }, { "theorem_id": 246, "title": "mathd_algebra_282", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\nRequire Import Reals.Rfunctions.\nRequire Import QArith.QArith_base.\nRequire Import Coq.Reals.Rbasic_fun.\nOpen Scope R_scope.\n\nDefinition is_rational (x : R) := \n exists (p q : Z), (q <> 0%Z) /\\ x = (IZR p / IZR q)%R.\n\nTheorem mathd_algebra_282\n (f : R -> R)\n (h0 : forall x, is_rational x -> f x = Rabs (IZR (Int_part x)))\n (h1 : forall x, ~is_rational x -> f x = (IZR (up x))^2) :\n f (Rpower 8 (1/3)) + f (-PI) + f (sqrt 50) + f (9/2) = 79.\n\nProof.\n" }, { "theorem_id": 247, "title": "mathd_algebra_288", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-288 = `!x:real y:real n:real.\n (n >= &0) /\\\n (x < &0 /\\ y < &0) /\\\n (abs x = &6) /\\\n (sqrt ((x - &8) pow 2 + (y - &3) pow 2) = &15) /\\\n (sqrt (x pow 2 + y pow 2) = sqrt n)\n==>\n (n = &52)\n`;;\n" }, { "theorem_id": 247, "title": "mathd_algebra_288", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_288 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_288:\n fixes x y :: real\n and n :: real\n assumes \"x < 0 \\ y < 0\"\n and \"abs x = 6\"\n and \"sqrt ((x - 8)^2 + (y - 3)^2) = 15\"\n and \"sqrt (x^2 + y^2) = sqrt n\"\n shows \"n = 52\"\n by sorry\n\nend " }, { "theorem_id": 247, "title": "mathd_algebra_288", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_288\n (x y : ℝ)\n (n : NNReal)\n (h₀ : x < 0 ∧ y < 0)\n (h₁ : abs y = 6)\n (h₂ : Real.sqrt ((x - 8)^2 + (y - 3)^2) = 15)\n (h₃ : Real.sqrt (x^2 + y^2) = Real.sqrt n) :\n n = 52 := by sorry" }, { "theorem_id": 247, "title": "mathd_algebra_288", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_288:\n forall (x y n : R),\n x < 0 /\\ y < 0 ->\n Rabs y = 6 ->\n sqrt ((x - 8)^2 + (y - 3)^2) = 15 ->\n sqrt (x^2 + y^2) = sqrt n ->\n n = 52.\nProof.\nAdmitted." }, { "theorem_id": 248, "title": "mathd_algebra_289", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-289 = `!k:num t:num m:num n:num.\n (prime m /\\ prime n) /\\\n (t < k) /\\\n (int_of_num (k EXP 2) - &(m * k) + &n = &0) /\\\n (int_of_num (t EXP 2) - &(m * t) + &n = &0)\n==>\n m EXP n + n EXP m + k EXP t + t EXP k = 20\n`;;\n" }, { "theorem_id": 248, "title": "mathd_algebra_289", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_289 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_289:\n fixes k t m n :: nat\n assumes \"prime m \\ prime n\"\n and \"t < k\"\n and \"k^2 + n - m * k = 0\"\n and \"t^2 + n - m * t = 0\" \n shows \"m^n + n^m + k^t + t^k = 20\"\n by sorry\n\nend " }, { "theorem_id": 248, "title": "mathd_algebra_289", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_289\n (k t m n : ℕ)\n (h₀ : Nat.Prime m ∧ Nat.Prime n)\n (h₁ : t < k)\n (h₂ : k^2 - m * k + n = 0)\n (h₃ : t^2 - m * t + n = 0) :\n m^n + n^m + k^t + t^k = 20 := by sorry" }, { "theorem_id": 248, "title": "mathd_algebra_289", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Nat.\n\nDefinition is_prime (p: nat) := \n p > 1 /\\ forall m : nat, m > 0 /\\ m < p -> p mod m <> 0 \\/ m = 1.\n\nTheorem mathd_algebra_289:\n forall (k t m n : nat),\n is_prime m -> is_prime n ->\n t < k ->\n (Z.of_nat (k * k) - Z.of_nat (m * k) + Z.of_nat n)%Z = 0%Z ->\n (Z.of_nat (t * t) - Z.of_nat (m * t) + Z.of_nat n)%Z = 0%Z ->\n m ^ n + n ^ m + k ^ t + t ^ k = 20.\n\nProof.\n" }, { "theorem_id": 249, "title": "mathd_algebra_293", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-293 = `!x:real. (x >= &0) ==> sqrt (&60 * x) * sqrt (&12 * x) * sqrt (&63 * x) = &36 * x * sqrt (&35 * x)`;;\n" }, { "theorem_id": 249, "title": "mathd_algebra_293", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_293 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_293:\n fixes x :: real \n shows \"sqrt (60 * x) * sqrt (12 * x) * sqrt (63 * x) \n = 36 * x * sqrt (35 * x)\"\n by sorry\n\nend " }, { "theorem_id": 249, "title": "mathd_algebra_293", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_293\n (x : NNReal) :\n Real.sqrt (60 * x) * Real.sqrt (12 * x) * Real.sqrt (63 * x) = 36 * x * Real.sqrt (35 * x) := by sorry" }, { "theorem_id": 249, "title": "mathd_algebra_293", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_293 : forall x : R, 0 <= x ->\n sqrt (60 * x) * sqrt (12 * x) * sqrt (63 * x) = 36 * x * sqrt (35 * x).\nProof.\nAdmitted." }, { "theorem_id": 250, "title": "mathd_algebra_296", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-296 = `abs ((int_of_num (3491) - &60) * &(3491 + 60) - &(3491 EXP 2)) = &3600`;;\n" }, { "theorem_id": 250, "title": "mathd_algebra_296", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_296 imports Complex_Main\nbegin\n\ntheorem mathd_algebra_296 :\n \"abs (((3491 - 60) * (3491 + 60) - 3491^2)) = (3600::int)\"\n by sorry\n\nend" }, { "theorem_id": 250, "title": "mathd_algebra_296", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_296 :\n abs (((3491 - 60) * (3491 + 60) - 3491^2):ℤ) = 3600 := by sorry" }, { "theorem_id": 250, "title": "mathd_algebra_296", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem mathd_algebra_296 :\n Z.abs (((3491 - 60) * (3491 + 60) - 3491^2)) = 3600.\nProof.\nAdmitted." }, { "theorem_id": 251, "title": "mathd_algebra_302", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-302 = `(ii / Cx(&2)) pow 2 = Cx(-- (&1 / &4))`;;\n" }, { "theorem_id": 251, "title": "mathd_algebra_302", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_302 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_302:\n \"(\\ / 2)^2 = -(1 / 4)\"\n by sorry\n\nend " }, { "theorem_id": 251, "title": "mathd_algebra_302", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_302 :\n (Complex.I / 2)^2 = -(1 / 4) := by sorry" }, { "theorem_id": 251, "title": "mathd_algebra_302", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem mathd_algebra_302 :\n (Ci / 2)^2 = - (1 / 4).\n\nProof.\n" }, { "theorem_id": 252, "title": "mathd_algebra_304", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-304 = `91 EXP 2 = 8281`;;\n" }, { "theorem_id": 252, "title": "mathd_algebra_304", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_304 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_304:\n \"91^2 = (8281::nat)\"\n by sorry\n\nend " }, { "theorem_id": 252, "title": "mathd_algebra_304", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_304 :\n 91^2 = 8281 := by sorry" }, { "theorem_id": 252, "title": "mathd_algebra_304", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\nRequire Import ZArith.\n\nTheorem mathd_algebra_304:\n 91^2 = 8281.\nProof.\nAdmitted." }, { "theorem_id": 253, "title": "mathd_algebra_313", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-313 = `!v:complex i:complex z:complex.\n (v = i * z) /\\\n (v = Cx(&1) + ii) /\\\n (z = Cx(&2) - ii)\n==>\n i = Cx(&1 / &5) + Cx(&3 / &5) * ii\n`;;\n" }, { "theorem_id": 253, "title": "mathd_algebra_313", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_313 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\nterm \\\n\ntheorem mathd_algebra_313:\n fixes v i z ::complex\n assumes \"v = i * z\"\n and \"v = 1 + \\\"\n and \"z = 2 - \\\" \n shows \"i = 1/5 + 3/5 * \\\"\n by sorry\n\nend " }, { "theorem_id": 253, "title": "mathd_algebra_313", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_313\n (v i z : ℂ)\n (h₀ : v = i * z)\n (h₁ : v = 1 + Complex.I)\n (h₂ : z = 2 - Complex.I) :\n i = 1/5 + 3/5 * Complex.I := by sorry" }, { "theorem_id": 253, "title": "mathd_algebra_313", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem mathd_algebra_313\n (v i z : C)\n (h0 : v = i * z)\n (h1 : v = 1 + Ci)\n (h2 : z = 2 - Ci) :\n i = 1/5 + 3/5 * Ci.\n\nProof.\n" }, { "theorem_id": 254, "title": "mathd_algebra_314", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-314 = `!n:num.\n (n = 11)\n==>\n (&1 / &4) pow (n + 1) * &(2 EXP (2 * n)) = &1 / &4\n`;;\n" }, { "theorem_id": 254, "title": "mathd_algebra_314", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_314 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_314:\n fixes n :: nat\n assumes \"n = 11\" \n shows \"(1 / 4)^(n + 1) * 2^(2 * n) = 1 / (4::real)\"\n by sorry\n\nend " }, { "theorem_id": 254, "title": "mathd_algebra_314", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_314\n (n : ℕ)\n (h₀ : n = 11) :\n (1 / 4)^(n + 1) * 2^(2 * n) = 1 / 4 := by sorry" }, { "theorem_id": 254, "title": "mathd_algebra_314", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_314\n (n : nat)\n (h₀ : n = 11%nat) :\n (1 / 4) ^ (n + 1) * 2 ^ (2 * n) = 1 / 4.\n\nProof.\n" }, { "theorem_id": 255, "title": "mathd_algebra_320", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-320 = `!x:real a:num b:num c:num.\n (x >= &0 /\\ a > 0 /\\ b > 0 /\\ c > 0) /\\\n (&2 * x pow 2 = &4 * x + &9) /\\\n (x = (&a + sqrt (&b)) / &c)\n==>\n a + b + c = 26\n`;;\n" }, { "theorem_id": 255, "title": "mathd_algebra_320", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_320 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_320:\n fixes x :: real\n and a b c :: nat\n assumes \"2 * x^2 = 4 * x + 9\"\n and \"x = (a + sqrt b) / c\"\n and \"x\\0\" \"a>0\" \"b>0\" \"c>0\"\n shows \"a + b + c = 26\"\n by sorry\n\nend" }, { "theorem_id": 255, "title": "mathd_algebra_320", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_320\n (x : ℝ)\n (a b c : ℕ)\n (h₀ : 0 < a ∧ 0 < b ∧ 0 < c ∧ 0 ≤ x)\n (h₁ : 2 * x^2 = 4 * x + 9)\n (h₂ : x = (a + Real.sqrt b) / c)\n (h₃ : c = 2) :\n a + b + c = 26 := by sorry" }, { "theorem_id": 255, "title": "mathd_algebra_320", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_320\n (x : R) (a b c : nat)\n (H_pos_a : (INR a > 0)%R)\n (H_pos_b : (INR b > 0)%R)\n (H_pos_c : (INR c > 0)%R)\n (H_pos_x : x >= 0)\n (H_quad : 2 * x^2 = 4 * x + 9)\n (H_repr : x = (INR a + sqrt (INR b)) / INR c)\n (H_c_val : c = 2%nat) :\n (INR (a + b + c) = 26)%R.\n\nProof.\n" }, { "theorem_id": 256, "title": "mathd_algebra_327", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-327 = `!a:real.\n (&1 / &5 * abs (&9 + &2 * a) < &1)\n==>\n -- &7 < a /\\ a < -- &2\n`;;\n" }, { "theorem_id": 256, "title": "mathd_algebra_327", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_327 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_327:\n fixes a :: real\n assumes h0 : \"1 / 5 * abs(9 + 2 * a) < 1\"\n shows \"-7 < a \\ a < -2\"\n by sorry\n\nend" }, { "theorem_id": 256, "title": "mathd_algebra_327", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_327 (a : ℝ) (h₀ : 1 / 5 * abs (9 + 2 * a) < 1) : -7 < a ∧ a < -2 := by sorry" }, { "theorem_id": 256, "title": "mathd_algebra_327", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_327 : forall a : R,\n (1 / 5 * Rabs (9 + 2 * a) < 1) ->\n -7 < a /\\ a < -2.\n\nProof.\n" }, { "theorem_id": 257, "title": "mathd_algebra_329", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-329 = `!x:real y:real.\n (&3 * y = x) /\\\n (&2 * x + &5 * y = &11)\n==>\n (x + y = &4)\n`;;\n" }, { "theorem_id": 257, "title": "mathd_algebra_329", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_329 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_329:\n fixes x y :: real\n assumes \"3 * y = x\"\n and \"2 * x + 5 * y = 11\" \n shows \"x + y = 4\"\n by sorry\n\nend" }, { "theorem_id": 257, "title": "mathd_algebra_329", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_329\n (x y : ℝ)\n (h₀ : 3 * y = x)\n (h₁ : 2 * x + 5 * y = 11) :\n x + y = 4 := by sorry" }, { "theorem_id": 257, "title": "mathd_algebra_329", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_329 :\n forall x y : R,\n (3 * y = x) ->\n (2 * x + 5 * y = 11) ->\n (x + y = 4).\nProof.\nAdmitted.\n" }, { "theorem_id": 258, "title": "mathd_algebra_33", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-33 = `!x y z. ~(x = &0) /\\ &2 * x = &5 * y /\\ &7 * y = &10 * z ==> z / x = &7 / &25`;;\n" }, { "theorem_id": 258, "title": "mathd_algebra_33", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_33 imports Complex_Main\nbegin\n\ntheorem mathd_algebra_33:\n fixes x y z :: real \n assumes \"x \\ 0\"\n and \"2 * x = 5 * y\"\n and \"7 * y = 10 * z\"\n shows \"z / x = 7 / 25\"\n by sorry\n\nend" }, { "theorem_id": 258, "title": "mathd_algebra_33", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_33\n (x y z : ℝ)\n (h₀ : x ≠ 0)\n (h₁ : 2 * x = 5 * y)\n (h₂ : 7 * y = 10 * z) :\n z / x = 7 / 25 := by sorry" }, { "theorem_id": 258, "title": "mathd_algebra_33", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_33 :\n forall (x y z : R),\n x <> 0 ->\n 2 * x = 5 * y ->\n 7 * y = 10 * z ->\n z / x = 7 / 25.\nProof.\nAdmitted." }, { "theorem_id": 259, "title": "mathd_algebra_332", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-332 = `!x:real y:real.\n (x >= &0 /\\ y >= &0) /\\\n ((x + y) / &2 = &7) /\\\n (sqrt (x * y) = sqrt (&19))\n==>\n x pow 2 * y pow 2 = &158\n`;;\n" }, { "theorem_id": 259, "title": "mathd_algebra_332", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_332 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_332:\n fixes x y ::real\n assumes \"(x + y) / 2 = 7\"\n and \"sqrt (x * y) = sqrt 19\" \n shows \"x^2 * y^2 = 158\"\n by sorry\n\nend " }, { "theorem_id": 259, "title": "mathd_algebra_332", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_332\n (x y : ℝ)\n (h₀ : (x + y) / 2 = 7)\n (h₁ : Real.sqrt (x * y) = Real.sqrt 19) :\n x^2 + y^2 = 158 := by sorry" }, { "theorem_id": 259, "title": "mathd_algebra_332", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_332 :\n forall (x y : R),\n (x + y) / 2 = 7 ->\n sqrt (x * y) = sqrt 19 ->\n x^2 + y^2 = 158.\nProof.\nAdmitted." }, { "theorem_id": 260, "title": "mathd_algebra_338", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-338 = `!a:real b:real c:real.\n (&3 * a + b + c = -- &3) /\\\n (a + &3 * b + c = &9) /\\\n (a + b + &3 * c = &19)\n==>\n (a * b * c = -- &56)\n`;;\n" }, { "theorem_id": 260, "title": "mathd_algebra_338", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_338 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_338:\n fixes a b c :: real\n assumes \"3 * a + b + c = -3\"\n and \"a + 3 * b + c = 9\"\n and \"a + b + 3 * c = 19\" \n shows \"a * b * c = -56\"\n by sorry\n\nend " }, { "theorem_id": 260, "title": "mathd_algebra_338", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_338\n (a b c : ℝ)\n (h₀ : 3 * a + b + c = -3)\n (h₁ : a + 3 * b + c = 9)\n (h₂ : a + b + 3 * c = 19) :\n a * b * c = -56 := by sorry" }, { "theorem_id": 260, "title": "mathd_algebra_338", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_338 :\n forall a b c : R,\n (3 * a + b + c = -3) ->\n (a + 3 * b + c = 9) ->\n (a + b + 3 * c = 19) ->\n a * b * c = -56.\nProof.\nAdmitted." }, { "theorem_id": 261, "title": "mathd_algebra_342", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-342 = `!a:real d:real.\n (sum (0..(5-1)) (\\k. a + &k * d) = &70) /\\\n (sum (0..(10-1)) (\\k. a + &k * d) = &210)\n==>\n a = &42 / &5\n`;;\n" }, { "theorem_id": 261, "title": "mathd_algebra_342", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_342 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_342:\n fixes a d::real\n assumes \"(\\ k<5. (a + k * d)) = 70\"\n and \"(\\ k <10. (a + k * d)) = 210\" \n shows \"a = 42/5\"\n by sorry\n\nend " }, { "theorem_id": 261, "title": "mathd_algebra_342", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_342\n (a d: ℝ)\n (h₀ : ∑ k ∈ (Finset.range 5), (a + k * d) = 70)\n (h₁ : ∑ k ∈ (Finset.range 10), (a + k * d) = 210) :\n a = 42/5 := by sorry" }, { "theorem_id": 261, "title": "mathd_algebra_342", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nOpen Scope R_scope.\n\n\nFixpoint sum_f_R0 (f : nat -> R) (n : nat) : R :=\n match n with\n | O => 0\n | S n' => sum_f_R0 f n' + f n'\n end.\n\nTheorem mathd_algebra_342 :\n forall (a d : R),\n sum_f_R0 (fun k => a + INR k * d) 5 = 70 ->\n sum_f_R0 (fun k => a + INR k * d) 10 = 210 ->\n a = 42 / 5.\n\nProof.\n" }, { "theorem_id": 262, "title": "mathd_algebra_346", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-346 = `!f:real->real g:real->real.\n (!x. f x = &2 * x - &3) /\\\n (!x. g x = x + &1)\n==>\n (g (f (&5) - &1) = &7)\n`;;\n" }, { "theorem_id": 262, "title": "mathd_algebra_346", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_346 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_346:\n fixes f g :: \"real \\ real\"\n assumes \"\\ x. f x = 2 * x - 3\"\n and \"\\ x. g x = x + 1\"\n shows \"g (f 5 - 1) = 7\"\n by sorry\n\nend" }, { "theorem_id": 262, "title": "mathd_algebra_346", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_346\n (f g : ℝ → ℝ)\n (h₀ : ∀ x, f x = 2 * x - 3)\n (h₁ : ∀ x, g x = x + 1) :\n g (f 5 - 1) = 7 := by sorry" }, { "theorem_id": 262, "title": "mathd_algebra_346", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_346 :\n forall f g : R -> R,\n (forall x, f x = 2 * x - 3) ->\n (forall x, g x = x + 1) ->\n g (f 5 - 1) = 7.\nProof.\nAdmitted." }, { "theorem_id": 263, "title": "mathd_algebra_35", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-35 = `!p:real->real q:real->real.\n (!x. p x = &2 - x pow 2) /\\\n (!x. ~(x = &0) ==> q x = &6 / x)\n==>\n p (q (&2)) = -- &7\n`;;\n" }, { "theorem_id": 263, "title": "mathd_algebra_35", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_35 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_35:\n fixes p q :: \"real \\ real\"\n assumes h0 : \"\\x. p x = 2 - x^2\"\n and h1 : \"\\x. (x\\0) \\ q x = 6 / x\"\n shows \"p (q 2) = -7\"\n by sorry\n\nend" }, { "theorem_id": 263, "title": "mathd_algebra_35", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_35 (p q : ℝ → ℝ) (h₀ : ∀ x, p x = 2 - x ^ 2)\n (h₁ : ∀ x : ℝ, x ≠ 0 → q x = 6 / x) : p (q 2) = -7 := by sorry" }, { "theorem_id": 263, "title": "mathd_algebra_35", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_35\n (p q : R -> R)\n (h₀ : forall x, p x = 2 - x^2)\n (h₁ : forall x, x <> 0 -> q x = 6 / x) :\n p (q 2) = -7.\nProof.\nAdmitted." }, { "theorem_id": 264, "title": "mathd_algebra_354", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-354 = `!a:real d:real.\n (a + &6 * d = &30) /\\\n (a + &10 * d = &60)\n==>\n a + &20 * d = &135\n`;;\n" }, { "theorem_id": 264, "title": "mathd_algebra_354", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_354 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_354:\n fixes a d :: real\n assumes \"a + 6 * d = 30\"\n and \"a + 10 * d = 60\" \n shows \"a + 20 * d = 135\"\n by sorry\n\nend " }, { "theorem_id": 264, "title": "mathd_algebra_354", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_354\n (a d : ℝ)\n (h₀ : a + 6 * d = 30)\n (h₁ : a + 10 * d = 60) :\n a + 20 * d = 135 := by sorry" }, { "theorem_id": 264, "title": "mathd_algebra_354", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_354 :\n forall a d : R,\n (a + 6 * d = 30) ->\n (a + 10 * d = 60) ->\n (a + 20 * d = 135).\nProof.\nAdmitted." }, { "theorem_id": 265, "title": "mathd_algebra_362", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-362 = `!a:real b:real.\n (a pow 2 * b pow 3 = &32 / &27) /\\\n (a / (b pow 3) = &27 / &4)\n==>\n (a + b = &8 / &3)\n`;;\n" }, { "theorem_id": 265, "title": "mathd_algebra_362", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_362 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_362:\n fixes a b :: real\n assumes \"a^2 * b^3 = 32 / 27\"\n and \"a / b^3 = 27 / 4\" \n shows \"a + b = 8 / 3\"\n by sorry\n\nend " }, { "theorem_id": 265, "title": "mathd_algebra_362", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_362\n (a b : ℝ)\n (h₀ : a^2 * b^3 = 32 / 27)\n (h₁ : a / b^3 = 27 / 4) :\n a + b = 8 / 3 := by sorry" }, { "theorem_id": 265, "title": "mathd_algebra_362", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_362:\n forall (a b : R),\n a^2 * b^3 = 32 / 27 ->\n a / b^3 = 27 / 4 ->\n a + b = 8 / 3.\nProof.\nAdmitted." }, { "theorem_id": 266, "title": "mathd_algebra_37", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-37 = `!x:real y:real.\n (x + y = &7) /\\\n (&3 * x + y = &45)\n==>\n (x pow 2 - y pow 2 = &217)\n`;;\n" }, { "theorem_id": 266, "title": "mathd_algebra_37", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_37 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_37:\n fixes x y :: real\n assumes h0 : \"x+y=7\"\n and h1 : \"3 * x + y = 45\"\n shows \"x^2 - y^2 = 217\"\n by sorry\n\nend" }, { "theorem_id": 266, "title": "mathd_algebra_37", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_37 (x y : ℝ) (h₀ : x + y = 7) (h₁ : 3 * x + y = 45) : x ^ 2 - y ^ 2 = 217 := by sorry" }, { "theorem_id": 266, "title": "mathd_algebra_37", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_37 :\n forall x y : R,\n x + y = 7 ->\n 3 * x + y = 45 ->\n x^2 - y^2 = 217.\nProof.\nAdmitted." }, { "theorem_id": 267, "title": "mathd_algebra_388", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-388 = `!x:real y:real z:real.\n (&3 * x + &4 * y - &12 * z = &10) /\\\n ((-- &2) * x - &3 * y + &9 * z = -- &4)\n==>\n x = &14\n`;;\n" }, { "theorem_id": 267, "title": "mathd_algebra_388", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_388 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_388:\n fixes x y z :: real\n assumes \"3 * x + 4 * y - 12 * z = 10\"\n and \"-2 * x - 3 * y + 9 * z = -4\"\n shows \"x = 14\"\n by sorry\n\nend" }, { "theorem_id": 267, "title": "mathd_algebra_388", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_388\n (x y z : ℝ)\n (h₀ : 3 * x + 4 * y - 12 * z = 10)\n (h₁ : -2 * x - 3 * y + 9 * z = -4) :\n x = 14 := by sorry" }, { "theorem_id": 267, "title": "mathd_algebra_388", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Lra.\n\nOpen Scope R_scope.\n\nTheorem mathd_algebra_388 :\n forall (x y z : R),\n 3 * x + 4 * y - 12 * z = 10 ->\n -2 * x - 3 * y + 9 * z = -4 ->\n x = 14.\nProof.\nAdmitted.\n" }, { "theorem_id": 268, "title": "mathd_algebra_392", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-392 = `!n:num.\n (EVEN n) /\\\n ((int_of_num (n) - &2) pow 2 + &n pow 2 + (&n + &2) pow 2 = &12296)\n==>\n (int_of_real (real_of_int ((int_of_num (n) - &2) * &n * (&n + &2)) / &8) = &32736)`;;\n" }, { "theorem_id": 268, "title": "mathd_algebra_392", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_392 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_392:\n fixes n :: nat\n assumes \"even n\"\n and \"(n - 2)^2 + n^2 + (n + 2)^2 = (12296::int)\" \n shows \"((n - 2) * n * (n + 2)) / 8 = (32736::int)\"\n by sorry\n\nend" }, { "theorem_id": 268, "title": "mathd_algebra_392", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_392\n (n : ℕ)\n (h₀ : Even n)\n (h₁ : ((n:ℤ) - 2)^2 + (n:ℤ)^2 + ((n:ℤ) + 2)^2 = 12296) :\n ((n - 2) * n * (n + 2)) / 8 = 32736 := by sorry" }, { "theorem_id": 268, "title": "mathd_algebra_392", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\nRequire Import Lia.\n\nTheorem mathd_algebra_392 :\n forall (n : nat),\n Nat.even n = true ->\n n^2 + (n + 2)^2 + (n + 4)^2 = 12296 ->\n (n * (n + 2) * (n + 4)) / 8 = 32736.\nProof.\nAdmitted.\n" }, { "theorem_id": 269, "title": "mathd_algebra_398", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-398 = `!a:real b:real c:real.\n (&0 < a /\\ &0 < b /\\ &0 < c) /\\\n (&9 * b = &20 * c) /\\\n (&7 * a = &4 * b)\n==>\n &63 * a = &80 * c\n`;;\n" }, { "theorem_id": 269, "title": "mathd_algebra_398", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_398 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_398:\n fixes a b c ::real\n assumes \"0 < a \\ 0 < b \\ 0 < c\"\n and \"9 * b = 20 * c\"\n and \"7 * a = 4 * b\"\n shows \"63 * a = 80 * c\"\n by sorry\n\nend" }, { "theorem_id": 269, "title": "mathd_algebra_398", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_398\n (a b c : ℝ)\n (h₀ : 0 < a ∧ 0 < b ∧ 0 < c)\n (h₁ : 9 * b = 20 * c)\n (h₂ : 7 * a = 4 * b) :\n 63 * a = 80 * c := by sorry" }, { "theorem_id": 269, "title": "mathd_algebra_398", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_398:\n forall (a b c : R),\n 0 < a /\\ 0 < b /\\ 0 < c ->\n 9 * b = 20 * c ->\n 7 * a = 4 * b ->\n 63 * a = 80 * c.\nProof.\nAdmitted." }, { "theorem_id": 270, "title": "mathd_algebra_400", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-400 = `!x:real.\n (&5 + &500 / &100 * &10 = &110 / &100 * x)\n==>\n (x = &50)\n`;;\n" }, { "theorem_id": 270, "title": "mathd_algebra_400", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_400 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_400:\n fixes x :: real\n assumes \"5 + 500 / 100 * 10 = 110 / 100 * x\" \n shows \"x = 50\"\n by sorry\n\nend " }, { "theorem_id": 270, "title": "mathd_algebra_400", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_400\n (x : ℝ)\n (h₀ : 5 + 500 / 100 * 10 = 110 / 100 * x) :\n x = 50 := by sorry" }, { "theorem_id": 270, "title": "mathd_algebra_400", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_400:\n forall x : R,\n (5 + 500 / 100 * 10 = 110 / 100 * x) ->\n x = 50.\nProof.\nAdmitted." }, { "theorem_id": 271, "title": "mathd_algebra_412", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-412 = `!x:real y:real.\n (x + y = &25) /\\\n (x - y = &11)\n==>\n x = &18\n`;;\n" }, { "theorem_id": 271, "title": "mathd_algebra_412", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_412 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_412:\n fixes x y :: real\n assumes \"x + y = 25\"\n and \"x - y = 11\" \n shows \"x = 18\"\n by sorry\n\nend" }, { "theorem_id": 271, "title": "mathd_algebra_412", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_412\n (x y : ℝ)\n (h₀ : x + y = 25)\n (h₁ : x - y = 11) :\n x = 18 := by sorry" }, { "theorem_id": 271, "title": "mathd_algebra_412", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_412:\n forall (x y : R),\n (x + y = 25) ->\n (x - y = 11) ->\n x = 18.\nProof.\nAdmitted." }, { "theorem_id": 272, "title": "mathd_algebra_419", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-419 = `!a:real b:real.\n (a = -- &1) /\\\n (b = &5)\n==>\n (--a - b pow 2 + &3 * (a * b) = -- &39)\n`;;\n" }, { "theorem_id": 272, "title": "mathd_algebra_419", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_419 imports Complex_Main\nbegin\n\ntheorem mathd_algebra_419:\n fixes a b :: real\n assumes \"a = -1\"\n and \"b = 5\"\n shows \"-a - b^2 + 3 * (a * b) = -39\"\n by sorry\n\nend" }, { "theorem_id": 272, "title": "mathd_algebra_419", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_419\n (a b : ℝ)\n (h₀ : a = -1)\n (h₁ : b = 5) :\n -a - b^2 + 3 * (a * b) = -39 := by sorry" }, { "theorem_id": 272, "title": "mathd_algebra_419", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_419 :\n forall a b : R, \n a = -1 -> \n b = 5 -> \n -a - b^2 + 3 * (a * b) = -39.\nProof.\nAdmitted." }, { "theorem_id": 273, "title": "mathd_algebra_421", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-421 = `!a:real b:real c:real d:real.\n (b = a pow 2 + &4 * a + &6) /\\\n (b = &1 / &2 * a pow 2 + a + &6) /\\\n (d = c pow 2 + &4 * c + &6) /\\\n (d = &1 / &2 * c pow 2 + c + &6) /\\\n (a <= c)\n==>\n (c - a = &6)\n`;;\n" }, { "theorem_id": 273, "title": "mathd_algebra_421", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_421 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_421:\n fixes a b c d :: real\n assumes h0 : \"b = a^2 + 4 * a + 6\"\n and h1 : \"b = 1 / 2 * a^2 + a + 6\"\n and h2 : \"d = c^2 + 4 * c + 6\"\n and h3 : \"d = 1 / 2 * c^2 + c + 6\"\n and h4 : \"a \\ c\"\n shows \"c-a=6\"\n by sorry\n\nend" }, { "theorem_id": 273, "title": "mathd_algebra_421", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_421 (a b c d : ℝ) (h₀ : b = a ^ 2 + 4 * a + 6)\n (h₁ : b = 1 / 2 * a ^ 2 + a + 6) (h₂ : d = c ^ 2 + 4 * c + 6) (h₃ : d = 1 / 2 * c ^ 2 + c + 6)\n (h₄ : a < c) : c - a = 6 := by sorry" }, { "theorem_id": 273, "title": "mathd_algebra_421", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_421 :\n forall (a b c d : R),\n b = a^2 + 4 * a + 6 ->\n b = (1 / 2) * a^2 + a + 6 ->\n d = c^2 + 4 * c + 6 ->\n d = (1 / 2) * c^2 + c + 6 ->\n a < c ->\n c - a = 6.\nProof.\nAdmitted." }, { "theorem_id": 274, "title": "mathd_algebra_427", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-427 = `!x:real y:real z:real.\n (&3 * x + y = &17) /\\\n (&5 * y + z = &14) /\\\n (&3 * x + &5 * z = &41)\n==>\n x + y + z = &12\n`;;\n" }, { "theorem_id": 274, "title": "mathd_algebra_427", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_427 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_427:\n fixes x y z :: real\n assumes \"3 * x + y = 17\"\n and \"5 * y + z = 14\"\n and \"3 * x + 5 * z = 41\" \n shows \"x + y + z = 12\"\n by sorry\n\nend" }, { "theorem_id": 274, "title": "mathd_algebra_427", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_427\n (x y z : ℝ)\n (h₀ : 3 * x + y = 17)\n (h₁ : 5 * y + z = 14)\n (h₂ : 3 * x + 5 * z = 41) :\n x + y + z = 12 := by sorry" }, { "theorem_id": 274, "title": "mathd_algebra_427", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_427 :\n forall (x y z : R),\n (3 * x + y = 17) ->\n (5 * y + z = 14) ->\n (3 * x + 5 * z = 41) ->\n (x + y + z = 12).\nProof.\nAdmitted." }, { "theorem_id": 275, "title": "mathd_algebra_43", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-43 = `!a:real b:real f:real->real.\n (!x. f x = a * x + b) /\\\n (f (&7) = &4) /\\\n (f (&6) = &3)\n==>\n f (&3) = &0\n`;;\n" }, { "theorem_id": 275, "title": "mathd_algebra_43", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_43 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_43:\n fixes a b :: real\n and f :: \"real \\ real\"\n assumes h0 : \"\\x. f x = a * x + b\"\n and h1 : \"f 7 = 4\"\n and h2 : \"f 6 = 3\"\n shows \"f 3 = 0\"\n by sorry\n\nend" }, { "theorem_id": 275, "title": "mathd_algebra_43", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_43 (a b : ℝ) (f : ℝ → ℝ) (h₀ : ∀ x, f x = a * x + b) (h₁ : f 7 = 4)\n (h₂ : f 6 = 3) : f 3 = 0 := by sorry" }, { "theorem_id": 275, "title": "mathd_algebra_43", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_43\n (a b : R)\n (f : R -> R)\n (h0 : forall x, f x = a * x + b)\n (h1 : f 7 = 4)\n (h2 : f 6 = 3) :\n f 3 = 0.\nProof.\nAdmitted." }, { "theorem_id": 276, "title": "mathd_algebra_432", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-432 = `!x:real. (x + &3) * (&2 * x - &6) = &2 * x pow 2 - &18`;;\n" }, { "theorem_id": 276, "title": "mathd_algebra_432", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_432 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_432:\n fixes x ::real \n shows \"(x + 3) * (2 * x - 6) = 2 * x^2 - 18\"\n by sorry\n\nend" }, { "theorem_id": 276, "title": "mathd_algebra_432", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_432\n (x : ℝ) :\n (x + 3) * (2 * x - 6) = 2 * x^2 - 18 := by sorry" }, { "theorem_id": 276, "title": "mathd_algebra_432", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_432 (x : R) : (x + 3) * (2 * x - 6) = 2 * x^2 - 18.\nProof.\nAdmitted." }, { "theorem_id": 277, "title": "mathd_algebra_440", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-440 = `!x:real. (&3 / &2 / &3 = x / &10) ==> x = &5`;;\n" }, { "theorem_id": 277, "title": "mathd_algebra_440", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_440 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_440:\n fixes x ::real\n assumes \"3 / 2 / 3 = x / 10\"\n shows \"x = 5\"\n by sorry\n\nend " }, { "theorem_id": 277, "title": "mathd_algebra_440", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_440\n (x : ℝ)\n (h₀ : 3 / 2 / 3 = x / 10) :\n x = 5 := by sorry" }, { "theorem_id": 277, "title": "mathd_algebra_440", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_440:\n forall x : R, (1.5 / 3 = x / 10) -> x = 5.\nProof.\nAdmitted.\n" }, { "theorem_id": 278, "title": "mathd_algebra_455", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-455 = `!x:real.\n (&2 * (&2 * (&2 * (&2 * x))) = &48)\n==>\n x = &3\n`;;\n" }, { "theorem_id": 278, "title": "mathd_algebra_455", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_455 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_455:\n fixes x :: real\n assumes h0 : \"2 * (2 * (2 * (2 * x))) = 48\"\n shows \"x=3\"\n by sorry\n\nend" }, { "theorem_id": 278, "title": "mathd_algebra_455", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_455 (x : ℝ) (h₀ : 2 * (2 * (2 * (2 * x))) = 48) : x = 3 := by sorry" }, { "theorem_id": 278, "title": "mathd_algebra_455", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_algebra_455 :\n forall x : nat,\n 2 * (2 * (2 * (2 * x))) = 48 ->\n x = 3.\nProof.\nAdmitted.\n" }, { "theorem_id": 279, "title": "mathd_algebra_478", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-478 = `!b:real h:real v:real.\n (&0 < b /\\ &0 < h /\\ &0 < v) /\\\n (v = &1 / &3 * (b * h)) /\\\n (b = &30) /\\\n (h = &13 / &2)\n==>\n (v = &65)\n`;;\n" }, { "theorem_id": 279, "title": "mathd_algebra_478", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_478 imports Complex_Main\nbegin\n\ntheorem mathd_algebra_478:\n fixes b h v ::real\n assumes \"0 < b \\ 0 < h \\ 0 < v\"\n and \"v = 1 / 3 * (b * h)\"\n and \"b = 30\"\n and \"h = 13 / 2\"\n shows \"v = 65\"\n by sorry\n\nend" }, { "theorem_id": 279, "title": "mathd_algebra_478", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_478\n (b h v : ℝ)\n (h₀ : 0 < b ∧ 0 < h ∧ 0 < v)\n (h₁ : v = 1 / 3 * (b * h))\n (h₂ : b = 30)\n (h₃ : h = 13 / 2) :\n v = 65 := by sorry" }, { "theorem_id": 279, "title": "mathd_algebra_478", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_478:\n forall (b h v : R),\n (0 < b /\\ 0 < h /\\ 0 < v) ->\n v = (1/3) * (b * h) ->\n b = 30 ->\n h = 13/2 ->\n v = 65.\nProof.\nAdmitted." }, { "theorem_id": 280, "title": "mathd_algebra_48", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-48 = `!q:complex e:complex.\n (q = Cx(&9) - Cx(&4) * ii) /\\\n (e = Cx(-- (&3)) - Cx(&4) * ii)\n==>\n (q - e = Cx(&12))\n`;;\n" }, { "theorem_id": 280, "title": "mathd_algebra_48", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_48 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_48:\n fixes q e :: complex\n assumes h0 : \"q = Complex (Re 9) (Im (-4))\"\n and h1 : \"e = Complex (Re (-3)) (Im (-4))\"\n shows \"q - e = 12\"\n by sorry\n\nend" }, { "theorem_id": 280, "title": "mathd_algebra_48", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_48 (q e : ℂ) (h₀ : q = 9 - 4 * Complex.I) (h₁ : e = -3 - 4 * Complex.I) :\n q - e = 12 := by sorry" }, { "theorem_id": 280, "title": "mathd_algebra_48", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope C_scope.\n\nTheorem mathd_algebra_48 :\n (9 - 4 * Ci) - ( -3 - 4 * Ci) = 12.\nProof.\n" }, { "theorem_id": 281, "title": "mathd_algebra_484", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-484 = `ln (&27) / ln (&3) = &3`;;\n" }, { "theorem_id": 281, "title": "mathd_algebra_484", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_484 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_484 :\n \"(ln 27) / (ln 3) = (3::real)\"\n by sorry\n\nend " }, { "theorem_id": 281, "title": "mathd_algebra_484", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_484 :\n Real.log 27 / Real.log 3 = 3 := by sorry" }, { "theorem_id": 281, "title": "mathd_algebra_484", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_484 :\n ln 27 / ln 3 = 3.\nProof.\nAdmitted." }, { "theorem_id": 282, "title": "mathd_algebra_487", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-487 = `!a:real b:real c:real d:real.\n (b = a pow 2) /\\\n (a + b = &1) /\\\n (d = c pow 2) /\\\n (c + d = &1)\n==>\n (sqrt ((a - c) pow 2 + (b - d) pow 2) = sqrt (&10))\n`;;\n" }, { "theorem_id": 282, "title": "mathd_algebra_487", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_487 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_487:\n fixes a b c d :: real\n assumes \"b = a^2\"\n and \"a + b = 1\"\n and \"d = c^2\"\n and \"c + d = 1\"\n shows \"sqrt ((a - c)^2 + (b - d)^2)= sqrt 10\"\n by sorry\n\nend" }, { "theorem_id": 282, "title": "mathd_algebra_487", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_487\n (a b c d : ℝ)\n (h₀ : b = a^2)\n (h₁ : a + b = 1)\n (h₂ : d = c^2)\n (h₃ : c + d = 1)\n (h₄ : a ≠ c) :\n Real.sqrt ((a - c)^2 + (b - d)^2)= Real.sqrt 10 := by sorry" }, { "theorem_id": 282, "title": "mathd_algebra_487", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_487\n (a b c d : R)\n (h₀ : b = a^2)\n (h₁ : a + b = 1)\n (h₂ : d = c^2)\n (h₃ : c + d = 1)\n (h₄ : a <> c) :\n sqrt ((a - c)^2 + (b - d)^2) = sqrt 10.\nProof.\nAdmitted.\n" }, { "theorem_id": 283, "title": "mathd_algebra_51", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-51 = `!a:real b:real.\n (&0 < a /\\ &0 < b) /\\\n (a + b = &35) /\\\n (a = (&2 / &5) * b)\n==>\n b - a = &15\n`;;\n" }, { "theorem_id": 283, "title": "mathd_algebra_51", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_51 imports Complex_Main\nbegin\n\ntheorem mathd_algebra_51:\n fixes a b ::real\n assumes \"0 < a \\ 0 < b\"\n and \"a + b = 35\"\n and \"a = (2/5) * b\"\n shows \"b - a = 15\"\n by sorry\n\nend" }, { "theorem_id": 283, "title": "mathd_algebra_51", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_51 (a b : ℝ) (h₀ : 0 < a ∧ 0 < b) (h₁ : a + b = 35) (h₂ : a = 2 / 5 * b) :\n b - a = 15 := by sorry" }, { "theorem_id": 283, "title": "mathd_algebra_51", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_51:\n forall a b : R,\n 0 < a -> 0 < b ->\n a + b = 35 ->\n a = (2/5) * b ->\n b - a = 15.\nProof.\nAdmitted." }, { "theorem_id": 284, "title": "mathd_algebra_513", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-513 = `!a:real b:real.\n (&3 * a + &2 * b = &5) /\\\n (a + b = &2)\n==>\n a = &1 /\\ b = &1\n`;;\n" }, { "theorem_id": 284, "title": "mathd_algebra_513", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_513 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_algebra_513:\n fixes a b :: real\n assumes \"3 * a + 2 * b = 5\"\n and \"a + b = 2\" \n shows \"a = 1 \\ b = 1\"\n by sorry\n\nend " }, { "theorem_id": 284, "title": "mathd_algebra_513", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_513\n (a b : ℝ)\n (h₀ : 3 * a + 2 * b = 5)\n (h₁ : a + b = 2) :\n a = 1 ∧ b = 1 := by sorry" }, { "theorem_id": 284, "title": "mathd_algebra_513", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_513 :\n forall (a b : R),\n (3 * a + 2 * b = 5) -> \n (a + b = 2) -> \n (a = 1 /\\ b = 1).\nProof.\nAdmitted." }, { "theorem_id": 285, "title": "mathd_algebra_55", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-55 = `!q:real p:real.\n (q = &2 - &4 + &6 - &8 + &10 - &12 + &14) /\\\n (p = &3 - &6 + &9 - &12 + &15 - &18 + &21)\n==>\n (q / p = (&2) / (&3))\n`;;\n" }, { "theorem_id": 285, "title": "mathd_algebra_55", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_55 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_55:\n fixes q p :: real\n assumes h0 : \"q = 2 - 4 + 6 - 8 + 10 -12 + 14\"\n and h1 : \"p = 3 - 6 + 9 - 12 + 15 - 18 + 21\"\n shows \"q/p = 2/3\"\n by sorry\n\nend" }, { "theorem_id": 285, "title": "mathd_algebra_55", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_55 (q p : ℝ) (h₀ : q = 2 - 4 + 6 - 8 + 10 - 12 + 14)\n (h₁ : p = 3 - 6 + 9 - 12 + 15 - 18 + 21) : q / p = 2 / 3 := by sorry" }, { "theorem_id": 285, "title": "mathd_algebra_55", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_55:\n (2 - 4 + 6 - 8 + 10 - 12 + 14) / (3 - 6 + 9 - 12 + 15 - 18 + 21) = 2 / 3.\nProof.\nAdmitted.\n" }, { "theorem_id": 286, "title": "mathd_algebra_59", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-59 = `!b:real. exp (b * ln (&4)) + &(2 EXP 3) = &12 ==> b = &1`;;\n" }, { "theorem_id": 286, "title": "mathd_algebra_59", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_59 imports Complex_Main\nbegin\n\ntheorem mathd_algebra_59:\n fixes b :: real\n assumes \"4 powr b + 2^3 = 12\"\n shows \"b=1\"\n by sorry\n\nend" }, { "theorem_id": 286, "title": "mathd_algebra_59", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_59 (b : ℝ) (h₀ : (4 : ℝ) ^ b + 2 ^ 3 = 12) : b = 1 := by sorry" }, { "theorem_id": 286, "title": "mathd_algebra_59", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals Rpower.\n\nOpen Scope R_scope.\n\n\n\nTheorem mathd_algebra_59 :\n forall b : R,\n Rpower 4 b + Rpower 2 3 = 12 ->\n b = 1.\n\nProof.\n" }, { "theorem_id": 287, "title": "mathd_algebra_67", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-67 = `!f:real->real g:real->real.\n (!x. f x = &5 * x + &3) /\\\n (!x. g x = x pow 2 - &2)\n==>\n g (f (-- &1)) = &2`;;\n" }, { "theorem_id": 287, "title": "mathd_algebra_67", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_67 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_67:\n fixes f g :: \"real \\ real\"\n assumes h0 : \"\\x. f x = 5 * x + 3\"\n and h1 : \"\\x. g x = x^2 - 2\"\n shows \"g (f (-1)) = 2\"\n by sorry\n\nend" }, { "theorem_id": 287, "title": "mathd_algebra_67", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_67 (f g : ℝ → ℝ) (h₀ : ∀ x, f x = 5 * x + 3) (h₁ : ∀ x, g x = x ^ 2 - 2) :\n g (f (-1)) = 2 := by sorry" }, { "theorem_id": 287, "title": "mathd_algebra_67", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_67 \n (f g : R -> R)\n (h0 : forall x, f x = 5 * x + 3)\n (h1 : forall x, g x = x^2 - 2) :\n g (f (-1)) = 2.\nProof.\nAdmitted." }, { "theorem_id": 288, "title": "mathd_algebra_69", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-69 = `!r:num s:num.\n (~(r = 0) /\\ ~(s = 0)) /\\\n (r * s = 450) /\\\n ((&r + &5) * (int_of_num s - &3) = &450)\n==>\n r = 25\n`;;\n" }, { "theorem_id": 288, "title": "mathd_algebra_69", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_69 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_69:\n fixes r s :: nat\n assumes \"r * s = 450\"\n and \"(r + 5) * (s - 3) = 450\" \n shows \"r = 25\" \n by sorry\n\nend " }, { "theorem_id": 288, "title": "mathd_algebra_69", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_69 (rows seats : ℕ) (h₀ : rows * seats = 450)\n (h₁ : (rows + 5) * (seats - 3) = 450) : rows = 25 := by sorry" }, { "theorem_id": 288, "title": "mathd_algebra_69", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_algebra_69 :\n forall (rows seats : nat),\n (rows * seats = 450) ->\n ((rows + 5) * (seats - 3) = 450) ->\n rows = 25.\nProof.\nAdmitted." }, { "theorem_id": 289, "title": "mathd_algebra_73", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-73 = `!p:complex q:complex r:complex x:complex.\n ((x - p) * (x - q) = (r - p) * (r - q)) /\\\n ~(x = r)\n==>\n (x = p + q - r)\n`;;\n" }, { "theorem_id": 289, "title": "mathd_algebra_73", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_73 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_73:\n fixes p q r x :: complex\n assumes h0 : \"(x-p) * (x-q) = (r-p) * (r-q)\"\n and h1 : \"x \\ r\"\n shows \"x = p + q -r\"\n by sorry\n\nend" }, { "theorem_id": 289, "title": "mathd_algebra_73", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_73 (p q r x : ℂ) (h₀ : (x - p) * (x - q) = (r - p) * (r - q)) (h₁ : x ≠ r) :\n x = p + q - r := by sorry" }, { "theorem_id": 289, "title": "mathd_algebra_73", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coquelicot.Coquelicot.\nOpen Scope C_scope.\n\nTheorem mathd_algebra_73:\n forall (p q r x: C),\n (x - p) * (x - q) = (r - p) * (r - q) ->\n x <> r ->\n x = p + q - r.\n\nProof.\n" }, { "theorem_id": 290, "title": "mathd_algebra_76", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-76 = `!f:int->int.\n (!n. ODD (num_of_int (abs n)) ==> f n = n pow 2) /\\\n (!n. EVEN (num_of_int (abs n)) ==> f n = n pow 2 - &4 * n - &1)\n==>\n f (&4) = -- &1\n`;;\n" }, { "theorem_id": 290, "title": "mathd_algebra_76", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_76 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_algebra_76:\n fixes f :: \"int \\ int\"\n assumes \"\\n. odd n \\ f n = n^2\"\n and \"\\ n. even n \\ f n = n^2 - 4*n -1\" \n shows \"f 4 = -1\"\n by sorry\n\nend" }, { "theorem_id": 290, "title": "mathd_algebra_76", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_76\n (f : ℤ → ℤ)\n (h₀ : ∀n, Odd n → f n = n^2)\n (h₁ : ∀ n, Even n → f n = n^2 - 4*n -1) :\n f 4 = -1 := by sorry" }, { "theorem_id": 290, "title": "mathd_algebra_76", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem mathd_algebra_76 :\n forall f : Z -> Z,\n (forall n, Z.odd n = true -> f n = n * n) ->\n (forall n, Z.even n = true -> f n = n * n - 4 * n - 1) ->\n f 4 = -1.\nProof.\nAdmitted." }, { "theorem_id": 291, "title": "mathd_algebra_77", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-77 = `!a:real b:real f:real->real.\n (~(a = &0) /\\ ~(b = &0)) /\\\n (!x. f x = x pow 2 + a * x + b) /\\\n (f a = &0) /\\\n (f b = &0)\n==>\n a = &1 /\\ b = -- &2\n`;;\n" }, { "theorem_id": 291, "title": "mathd_algebra_77", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_77 imports\n Complex_Main\nbegin\n\ntheorem mathd_algebra_77:\n fixes a b :: real\n and f :: \"real \\ real\"\n assumes h0 : \"a \\ 0 \\ b \\ 0\"\n and h1 : \"\\x. f x = x^2 + a*x + b\"\n and h2 : \"f a = 0\"\n and h3 : \"f b = 0\"\n shows \"a=1 \\ b = -2\"\n by sorry\n\nend" }, { "theorem_id": 291, "title": "mathd_algebra_77", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_77 (a b : ℝ) (f : ℝ → ℝ) (h₀ : a ≠ 0 ∧ b ≠ 0) (h₁ : a ≠ b)\n (h₂ : ∀ x, f x = x ^ 2 + a * x + b) (h₃ : f a = 0) (h₄ : f b = 0) : a = 1 ∧ b = -2 := by sorry" }, { "theorem_id": 291, "title": "mathd_algebra_77", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_77 :\n forall a b : R,\n a <> 0 -> b <> 0 -> a <> b ->\n (forall x, (fun x => x^2 + a*x + b) x = x^2 + a*x + b) ->\n (fun x => x^2 + a*x + b) a = 0 ->\n (fun x => x^2 + a*x + b) b = 0 ->\n a = 1 /\\ b = -2.\nProof.\nAdmitted." }, { "theorem_id": 292, "title": "mathd_algebra_80", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-algebra-80 = `!x. ~(x = -- &1) /\\ ((x - &9) / (x + &1) = &2) ==> x = -- &11`;;\n" }, { "theorem_id": 292, "title": "mathd_algebra_80", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_algebra_80 imports Complex_Main\nbegin\n\ntheorem mathd_algebra_80:\n fixes x :: real\n assumes \"x \\ -1\"\n and \"(x - 9) / (x + 1) = 2\"\n shows \"x = -11\"\n by sorry\n\nend" }, { "theorem_id": 292, "title": "mathd_algebra_80", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_80\n (x : ℝ)\n (h₀ : x ≠ -1)\n (h₁ : (x - 9) / (x + 1) = 2) :\n x = -11 := by sorry" }, { "theorem_id": 292, "title": "mathd_algebra_80", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "From Coq Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_80:\n forall (x : R), x <> -1 -> (x - 9) / (x + 1) = 2 -> x = -11.\nProof.\nAdmitted." }, { "theorem_id": 293, "title": "mathd_algebra_89", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-89 = `!b:real.\n ~(b = &0)\n==>\n ((&7 * b pow 3) pow 2 * inv ((&4 * b pow 2) pow 3) = &49 / &64)\n`;;\n" }, { "theorem_id": 293, "title": "mathd_algebra_89", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_89 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_algebra_89:\n fixes b :: real\n assumes h0 : \"b\\0\"\n shows \"(7 * b^3)^2 * 1/((4 * b^2)^3) = 49 / 64\"\n by sorry\n\nend" }, { "theorem_id": 293, "title": "mathd_algebra_89", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_89 (b : ℝ) (h₀ : b ≠ 0) :\n (7 * b ^ 3) ^ 2 * (4 * b ^ 2) ^ (-(3 : ℤ)) = 49 / 64 := by sorry" }, { "theorem_id": 293, "title": "mathd_algebra_89", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_89:\n forall b : R,\n b <> 0 ->\n (7 * b^3)^2 * (1/((4 * b^2)^3)) = 49/64.\nProof.\nAdmitted." }, { "theorem_id": 294, "title": "mathd_algebra_96", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-algebra-96 = `!x:real y:real z:real a:real.\n (&0 < x /\\ &0 < y /\\ &0 < z /\\ &0 < a) /\\\n (ln x - ln y = a) /\\\n (ln y - ln z = &15) /\\\n (ln z - ln x = -- &7)\n==>\n a = -- &8\n`;;\n" }, { "theorem_id": 294, "title": "mathd_algebra_96", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_algebra_96 \n imports Complex_Main\nbegin\n\ntheorem mathd_algebra_96:\n fixes x y z a ::real\n assumes \"x>0\" \"y>0\" \"z>0\" \n and \"ln x - ln y = a\"\n and \"ln y - ln z = 15\"\n and \"ln z - ln x=-7\"\n shows \"a = -8\"\n by sorry\n\nend" }, { "theorem_id": 294, "title": "mathd_algebra_96", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_algebra_96 (x y z a : ℝ) (h₀ : 0 < x ∧ 0 < y ∧ 0 < z)\n (h₁ : Real.log x - Real.log y = a) (h₂ : Real.log y - Real.log z = 15)\n (h₃ : Real.log z - Real.log x = -7) : a = -8 := by sorry" }, { "theorem_id": 294, "title": "mathd_algebra_96", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Lra.\nOpen Scope R_scope.\n\nTheorem mathd_algebra_96:\n forall (x y z a : R),\n (0 < x) -> (0 < y) -> (0 < z) ->\n (ln x - ln y = a) ->\n (ln y - ln z = 15) ->\n (ln z - ln x = -7) ->\n a = -8.\nProof.\nAdmitted.\n" }, { "theorem_id": 295, "title": "mathd_numbertheory_100", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-100 = `!n:num.\n (n > 0) /\\\n (gcd (n, 40) = 10) /\\\n (lcm (n, 40) = 280)\n==>\n n = 70\n`;;\n" }, { "theorem_id": 295, "title": "mathd_numbertheory_100", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_100 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_100:\n fixes n :: nat\n assumes \"gcd n 40 = 10\"\n and \"lcm n 40 = 280\" \n shows \"n = 70\"\n by sorry\n\nend " }, { "theorem_id": 295, "title": "mathd_numbertheory_100", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_100\n (n : ℕ)\n (h₀ : 0 < n)\n (h₁ : Nat.gcd n 40 = 10)\n (h₂ : Nat.lcm n 40 = 280) :\n n = 70 := by sorry" }, { "theorem_id": 295, "title": "mathd_numbertheory_100", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.PeanoNat.\nRequire Import Coq.Init.Nat.\nRequire Import Coq.ZArith.Znat.\nOpen Scope nat_scope.\n\nTheorem mathd_numbertheory_100:\n forall n : nat,\n 0 < n ->\n Nat.gcd n 40 = 10 ->\n Nat.lcm n 40 = 280 ->\n n = 70.\nProof.\nAdmitted." }, { "theorem_id": 296, "title": "mathd_numbertheory_101", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-101 = `(17 * 18) MOD 4 = 2`;;\n" }, { "theorem_id": 296, "title": "mathd_numbertheory_101", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_101 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_101:\n \"(17 * 18) mod 4 = (2::nat)\"\n by sorry\n\nend" }, { "theorem_id": 296, "title": "mathd_numbertheory_101", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_101 : 17 * 18 % 4 = 2 := by sorry" }, { "theorem_id": 296, "title": "mathd_numbertheory_101", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_101 :\n (17 * 18) mod 4 = 2.\nProof.\nAdmitted." }, { "theorem_id": 297, "title": "mathd_numbertheory_102", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-102 = `(2 EXP 8) MOD 5 = 1`;;\n" }, { "theorem_id": 297, "title": "mathd_numbertheory_102", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_102 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_102:\n \"(2^8) mod 5 = (1::nat)\"\n by sorry\n\nend" }, { "theorem_id": 297, "title": "mathd_numbertheory_102", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_102 : 2 ^ 8 % 5 = 1 := by sorry" }, { "theorem_id": 297, "title": "mathd_numbertheory_102", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import ZArith.\n\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_102 :\n (2^8) mod 5 = 1.\nProof.\nAdmitted." }, { "theorem_id": 298, "title": "mathd_numbertheory_109", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-109 = `!v:num->num. (!n. v n = 2 * n - 1) ==> (nsum (1..(101-1)) v) MOD 7 = 4`;;\n" }, { "theorem_id": 298, "title": "mathd_numbertheory_109", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_109 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \nbegin\n\ntheorem mathd_numbertheory_109:\n fixes v :: \"nat \\ nat\"\n assumes \"\\ n. v n = 2 * n - 1\" \n shows \"(\\ k \\{1..<101}. v k) mod 7 = 4\"\n by sorry\n\nend " }, { "theorem_id": 298, "title": "mathd_numbertheory_109", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_109 (v : ℕ → ℕ) (h₀ : ∀ n, v n = 2 * n - 1) :\n (∑ k ∈ Finset.Icc 1 100, v k) % 7 = 4 := by sorry" }, { "theorem_id": 298, "title": "mathd_numbertheory_109", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\nRequire Import List.\nImport ListNotations.\n\nTheorem mathd_numbertheory_109 :\n forall (v : nat -> nat),\n (forall n, v n = 2 * n - 1) ->\n (list_sum (map v (seq 1 100))) mod 7 = 4.\nProof.\nAdmitted.\n" }, { "theorem_id": 299, "title": "mathd_numbertheory_110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-110 = `!a:num b:num.\n (0 < a /\\ 0 < b /\\ b <= a) /\\\n ((a + b) MOD 10 = 2) /\\\n ((2 * a + b) MOD 10 = 1)\n==>\n ((a - b) MOD 10 = 6)\n`;;\n" }, { "theorem_id": 299, "title": "mathd_numbertheory_110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_110 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_numbertheory_110:\n fixes a b :: nat\n assumes h0 : \"0 < a \\ 0 < b \\ b \\ a\"\n and h1 : \"(a+b) mod 10 = 2\"\n and h2 : \"(2*a + b) mod 10 = 1\"\n shows \"(a-b) mod 10 = 6\"\n by sorry\n\nend" }, { "theorem_id": 299, "title": "mathd_numbertheory_110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_110 (a b : ℕ) (h₀ : 0 < a ∧ 0 < b ∧ b ≤ a) (h₁ : (a + b) % 10 = 2)\n (h₂ : (2 * a + b) % 10 = 1) : (a - b) % 10 = 6 := by sorry" }, { "theorem_id": 299, "title": "mathd_numbertheory_110", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\nRequire Import ZArith.\n\nTheorem mathd_numbertheory_110:\n forall a b : nat,\n (0 < a)%nat -> (0 < b)%nat -> (b <= a)%nat ->\n (a + b) mod 10 = 2 ->\n (2 * a + b) mod 10 = 1 ->\n (a - b) mod 10 = 6.\nProof.\nAdmitted." }, { "theorem_id": 300, "title": "mathd_numbertheory_126", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-126 = `!x:num a:num.\n (~(x = 0) /\\ ~(a = 0)) /\\\n (gcd(a,40) = x + 3) /\\\n (lcm(a,40) = x * (x + 3)) /\\\n (!b:num.\n ~(b = 0) /\\\n (gcd(b,40) = x + 3) /\\\n (lcm(b,40) = x * (x + 3))\n ==>\n (a <= b)\n )\n==>\n (a = 8)\n`;;\n" }, { "theorem_id": 300, "title": "mathd_numbertheory_126", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_126 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_126:\n fixes x a :: nat\n assumes \"x>0\" \"a>0\"\n and \"gcd a 40 = x + 3\"\n and \"lcm a 40 = x * (x + 3)\"\n and \"\\b :: nat. gcd b 40 = x + 3 \\ lcm b 40 = x * (x + 3) \\ a \\ b\" \n shows \"a = 8\"\n by sorry\n\nend " }, { "theorem_id": 300, "title": "mathd_numbertheory_126", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_126 (x a : ℕ) (h₀ : 0 < x ∧ 0 < a) (h₁ : Nat.gcd a 40 = x + 3)\n (h₂ : Nat.lcm a 40 = x * (x + 3))\n (h₃ : ∀ b : ℕ, 0 < b → Nat.gcd b 40 = x + 3 ∧ Nat.lcm b 40 = x * (x + 3) → a ≤ b) : a = 8 := by sorry" }, { "theorem_id": 300, "title": "mathd_numbertheory_126", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import PeanoNat.\n\nTheorem mathd_numbertheory_126:\n forall (x a : nat),\n (0 < x) -> (0 < a) ->\n (Nat.gcd a 40 = x + 3) ->\n (Nat.lcm a 40 = x * (x + 3)) ->\n (forall b : nat, (0 < b) -> (Nat.gcd b 40 = x + 3 /\\ Nat.lcm b 40 = x * (x + 3) -> a <= b)) ->\n a = 8.\nProof.\nAdmitted.\n" }, { "theorem_id": 301, "title": "mathd_numbertheory_127", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-127 = `(nsum (0..(101-1)) (\\k. 2 EXP k)) MOD 7 = 3`;;\n" }, { "theorem_id": 301, "title": "mathd_numbertheory_127", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_127 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_127 :\n \"(\\ k<101. 2^k) mod 7 = (3::nat)\" sorry \n\nend " }, { "theorem_id": 301, "title": "mathd_numbertheory_127", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_127 :\n (∑ k ∈ (Finset.range 101), 2^k) % 7 = 3 := by sorry" }, { "theorem_id": 301, "title": "mathd_numbertheory_127", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\nRequire Import Coq.Lists.List.\nImport ListNotations.\n\n\n\nTheorem mathd_numbertheory_127 :\n (fold_left (fun acc k => acc + 2 ^ k) (seq 0 101) 0) mod 7 = 3.\n\nProof.\n" }, { "theorem_id": 302, "title": "mathd_numbertheory_13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-13 = `!u:num v:num.\n (~(u = 0) /\\ ~(v = 0)) /\\\n ((14 * u) MOD 100 = 46) /\\\n ((14 * v) MOD 100 = 46) /\\\n (u < 50) /\\\n (v < 100) /\\\n (50 < v)\n==>\n ((u + v) DIV 2 = 64)\n`;;\n" }, { "theorem_id": 302, "title": "mathd_numbertheory_13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_13 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_13:\n fixes u v :: nat\n assumes \"u>0 \\ v>0\"\n and \"(14 * u) mod 100 = 46\"\n and \"(14 * v) mod 100 = 46\"\n and \"u < 50\"\n and \"v < 100\"\n and \"50 < v\" \n shows \"(u + v) / 2 = 64\" \n by sorry\n\nend " }, { "theorem_id": 302, "title": "mathd_numbertheory_13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_13 (u v : ℕ) (S : Set ℕ)\n (h₀ : ∀ n : ℕ, n ∈ S ↔ 0 < n ∧ 14 * n % 100 = 46) (h₁ : IsLeast S u)\n (h₂ : IsLeast (S \\ {u}) v) : (u + v : ℚ) / 2 = 64 := by sorry" }, { "theorem_id": 302, "title": "mathd_numbertheory_13", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import ZArith.\nRequire Import Lia.\n\nTheorem mathd_numbertheory_13 :\n forall u v : nat,\n u > 0 -> v > 0 ->\n (14 * u) mod 100 = 46 ->\n (14 * v) mod 100 = 46 ->\n u < 50 ->\n 50 < v ->\n v < 100 ->\n (u + v)%nat / 2 = 64.\nProof.\nAdmitted." }, { "theorem_id": 303, "title": "mathd_numbertheory_132", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-132 = `2004 MOD 12 = 0`;;\n" }, { "theorem_id": 303, "title": "mathd_numbertheory_132", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_132 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_132:\n \"2004 mod 12 = (0::nat)\"\n by sorry\n \nend" }, { "theorem_id": 303, "title": "mathd_numbertheory_132", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_132 : 2004 % 12 = 0 := by sorry" }, { "theorem_id": 303, "title": "mathd_numbertheory_132", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\n\nTheorem mathd_numbertheory_132 : 2004 mod 12 = 0.\nProof.\nAdmitted." }, { "theorem_id": 304, "title": "mathd_numbertheory_135", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-135 = `!n:num a:num b:num c:num.\n (n = 3 EXP 17 + 3 EXP 10) /\\\n (11 divides (n + 1)) /\\\n (ODD a /\\ ODD c) /\\\n ~(3 divides b) /\\\n (n = 10 * (10 * (10 * (10 * (10 * (10 * (10 * (10 * a + b) + c) + a) + c) + c) + b) + a) + b)\n==>\n 10 * (10 * a + b) + c = 129\n`;;\n" }, { "theorem_id": 304, "title": "mathd_numbertheory_135", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_135 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_135:\n fixes n a b c::nat\n assumes \"n = 3^17 + 3^10\"\n and \"11 dvd (n + 1)\"\n and \"odd a \\ odd c\"\n and \"\\ 3 dvd b\"\n and \"n = 10*(10*(10*(10*(10*(10*(10*(10*a +b) +c) +a) +c) +c) +b) +a) +b\" \n shows \"10*(10 * a + b) + c = 129\"\n by sorry\n\nend" }, { "theorem_id": 304, "title": "mathd_numbertheory_135", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_135\n (n A B C : ℕ)\n (h₀ : n = 3^17 + 3^10)\n (h₁ : 11 ∣ (n + 1))\n (h₂ : [A,B,C].Pairwise (·≠·))\n (h₃ : {A,B,C} ⊂ Finset.Icc 0 9)\n (h₄ : Odd A ∧ Odd C)\n (h₅ : ¬ 3 ∣ B)\n (h₆ : Nat.digits 10 n = [B,A,B,C,C,A,C,B,A]) :\n 100 * A + 10 * B + C = 129 := by sorry" }, { "theorem_id": 304, "title": "mathd_numbertheory_135", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\nRequire Import List.\nImport ListNotations.\n\nTheorem mathd_numbertheory_135 \n (n A B C : nat)\n (H0 : n = 3^17 + 3^10)\n (H1 : exists k, n + 1 = 11 * k)\n (H2 : A <> B /\\ B <> C /\\ A <> C)\n (H3 : A <= 9 /\\ B <= 9 /\\ C <= 9)\n (H4 : Nat.odd A = true /\\ Nat.odd C = true)\n (H5 : ~(exists k, B = 3 * k))\n (H6 : n = B * 10^8 + A * 10^7 + B * 10^6 + C * 10^5 + C * 10^4 + \n A * 10^3 + C * 10^2 + B * 10 + A) :\n 100 * A + 10 * B + C = 129.\n\nProof.\n" }, { "theorem_id": 305, "title": "mathd_numbertheory_136", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-136 = `!n:num. (123 * n + 17 = 39500) ==> n = 321`;;\n" }, { "theorem_id": 305, "title": "mathd_numbertheory_136", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_136 imports Complex_Main\nbegin\n\ntheorem mathd_numbertheory_136:\n fixes n ::nat\n assumes \"123 * n + 17 = 39500\"\n shows \"n = 321\"\n by sorry\n\nend" }, { "theorem_id": 305, "title": "mathd_numbertheory_136", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_136 (n : ℕ) (h₀ : 123 * n + 17 = 39500) : n = 321 := by sorry" }, { "theorem_id": 305, "title": "mathd_numbertheory_136", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_136 (n : nat) :\n 123 * n + 17 = 39500 -> n = 321.\nProof.\nAdmitted." }, { "theorem_id": 306, "title": "mathd_numbertheory_149", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-149 = `nsum {x:num | (x MOD 8 = 5) /\\ (x MOD 6 = 3) /\\ x < 50} (\\k. k) = 66`;;\n" }, { "theorem_id": 306, "title": "mathd_numbertheory_149", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_149 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_149:\n \"(\\ k\\ {x::nat. x<50 \\ x mod 8 =5 \\ x mod 6=3}. k) = 66\"\n by sorry\n\nend " }, { "theorem_id": 306, "title": "mathd_numbertheory_149", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_149 :\n (∑ k ∈ Finset.filter (fun x => x % 8 = 5 ∧ x % 6 = 3) (Finset.range 50), k) = 66 := by sorry" }, { "theorem_id": 306, "title": "mathd_numbertheory_149", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import List.\nRequire Import Nat.\nRequire Import PArith.\nRequire Import Bool.\nImport ListNotations.\n\nTheorem mathd_numbertheory_149:\n fold_left plus\n (filter (fun x => andb (Nat.eqb (x mod 8) 5) (Nat.eqb (x mod 6) 3))\n (seq 0 50))\n 0 = 66.\n\nProof.\n" }, { "theorem_id": 307, "title": "mathd_numbertheory_150", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-150 = `!n:num. ~(prime (7 + 30 * n)) ==> 6 <= n`;;\n" }, { "theorem_id": 307, "title": "mathd_numbertheory_150", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_150 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_150:\n fixes n :: nat\n assumes \" \\ prime (7 + 30 * n)\" \n shows \"6 \\ n\"\n by sorry\n\nend " }, { "theorem_id": 307, "title": "mathd_numbertheory_150", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_150\n (n : ℕ)\n (h₀ : ¬ Nat.Prime (7 + 30 * n)) :\n 6 ≤ n := by sorry" }, { "theorem_id": 307, "title": "mathd_numbertheory_150", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\nRequire Import PeanoNat.\nRequire Import Arith.\nRequire Import ZArith.\nRequire Import Znumtheory.\n\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_150 :\n forall n : nat,\n ~ prime (Z.of_nat (7 + 30 * n)) -> Z.of_nat 6 <= Z.of_nat n.\n\nProof.\n" }, { "theorem_id": 308, "title": "mathd_numbertheory_155", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-155 = `CARD {x:num | x <= 1000-1 /\\ x >= 100 /\\ x MOD 19 = 7} = 52`;;\n" }, { "theorem_id": 308, "title": "mathd_numbertheory_155", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_155 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_155:\n \"card ({x::nat. x mod 19 = 7 \\ 100\\x \\ x < 1000}) = 52\"\n by sorry\n\nend " }, { "theorem_id": 308, "title": "mathd_numbertheory_155", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_155 :\n Finset.card (Finset.filter (fun x => x % 19 = 7) (Finset.Icc 100 999)) = 48 := by sorry" }, { "theorem_id": 308, "title": "mathd_numbertheory_155", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\nRequire Import Coq.Lists.List.\nImport ListNotations.\n\n\n\nTheorem mathd_numbertheory_155 :\n length (filter (fun x => Nat.eqb (x mod 19) 7)\n (seq 100 (999 - 100 + 1))) = 48.\n\nProof.\n" }, { "theorem_id": 309, "title": "mathd_numbertheory_156", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-156 = `!n:num.\n ~(n = 0)\n==>\n gcd (n + 7, 2 * n + 1) <= 13\n`;;\n" }, { "theorem_id": 309, "title": "mathd_numbertheory_156", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_156 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_156:\n fixes n :: nat\n assumes h0: \"n > 0\"\n shows \"gcd (n+7) (2*n+1) \\ 13\"\n by sorry\n\nend" }, { "theorem_id": 309, "title": "mathd_numbertheory_156", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_156 (n : ℕ) (h₀ : 0 < n) : Nat.gcd (n + 7) (2 * n + 1) ≤ 13 := by sorry" }, { "theorem_id": 309, "title": "mathd_numbertheory_156", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import Arith.\n\nTheorem mathd_numbertheory_156 :\n forall n : nat,\n n > 0 ->\n gcd (n + 7) (2 * n + 1) <= 13.\nProof.\nAdmitted." }, { "theorem_id": 310, "title": "mathd_numbertheory_169", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-169 = `gcd ((FACT 20), 200000) = 40000`;;\n" }, { "theorem_id": 310, "title": "mathd_numbertheory_169", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_169 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_numbertheory_169:\n \"gcd (fact 20) 200000 = (40000::nat)\"\n by sorry\n\nend" }, { "theorem_id": 310, "title": "mathd_numbertheory_169", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_169 : Nat.gcd 20! 200000 = 40000 := by sorry" }, { "theorem_id": 310, "title": "mathd_numbertheory_169", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_169 :\n Nat.gcd (fact 20) 200000 = 40000.\nProof.\nAdmitted." }, { "theorem_id": 311, "title": "mathd_numbertheory_175", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-175 = `(2 EXP 2010) MOD 10 = 4`;;\n" }, { "theorem_id": 311, "title": "mathd_numbertheory_175", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_175 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_175 :\n \"(2^2010) mod 10 = (4::nat)\"\n by sorry\n\nend" }, { "theorem_id": 311, "title": "mathd_numbertheory_175", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_175 :\n (2^2010) % 10 = 4 := by sorry" }, { "theorem_id": 311, "title": "mathd_numbertheory_175", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_175 :\n (2^2010) mod 10 = 4.\nProof.\nAdmitted." }, { "theorem_id": 312, "title": "mathd_numbertheory_185", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-185 = `!n:num. (n MOD 5 = 3) ==> (2 * n) MOD 5 = 1`;;\n" }, { "theorem_id": 312, "title": "mathd_numbertheory_185", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_185 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_185:\n fixes n ::nat\n assumes \"n mod 5 = 3\" \n shows \"(2 * n) mod 5 = 1\"\n by sorry\n\nend " }, { "theorem_id": 312, "title": "mathd_numbertheory_185", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_185\n (n : ℕ)\n (h₀ : n % 5 = 3) :\n (2 * n) % 5 = 1 := by sorry" }, { "theorem_id": 312, "title": "mathd_numbertheory_185", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\n\nTheorem mathd_numbertheory_185:\n forall n : nat,\n n mod 5 = 3 ->\n (2 * n) mod 5 = 1.\nProof.\nAdmitted." }, { "theorem_id": 313, "title": "mathd_numbertheory_198", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-198 = `(5 EXP 2005) MOD 100 = 25`;;\n" }, { "theorem_id": 313, "title": "mathd_numbertheory_198", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_198 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_198:\n \"(5^2005) mod 100 = (25::nat)\"\n by sorry\n\nend" }, { "theorem_id": 313, "title": "mathd_numbertheory_198", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_198 : 5 ^ 2005 % 100 = 25 := by sorry" }, { "theorem_id": 313, "title": "mathd_numbertheory_198", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import ZArith.\n\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_198 :\n (5 ^ 2005) mod 100 = 25.\nProof.\nAdmitted." }, { "theorem_id": 314, "title": "mathd_numbertheory_200", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-200 = `139 MOD 11 = 7`;;\n" }, { "theorem_id": 314, "title": "mathd_numbertheory_200", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_200 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_200:\n \"139 mod 11 = (7::nat)\"\n by sorry\n\nend" }, { "theorem_id": 314, "title": "mathd_numbertheory_200", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_200 : 139 % 11 = 7 := by sorry" }, { "theorem_id": 314, "title": "mathd_numbertheory_200", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_200 :\n 139 mod 11 = 7.\nProof.\nAdmitted." }, { "theorem_id": 315, "title": "mathd_numbertheory_202", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-202 = `(19 EXP 19 + 99 EXP 99) MOD 10 = 8`;;\n" }, { "theorem_id": 315, "title": "mathd_numbertheory_202", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_202 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_numbertheory_202:\n \"(19^19 + 99^99) mod 10 = (8::nat)\"\n by sorry\n\nend" }, { "theorem_id": 315, "title": "mathd_numbertheory_202", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_202 : (19 ^ 19 + 99 ^ 99) % 10 = 8 := by sorry" }, { "theorem_id": 315, "title": "mathd_numbertheory_202", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.PeanoNat.\n\nTheorem mathd_numbertheory_202 :\n (19^19 + 99^99) mod 10 = 8.\nProof.\nAdmitted." }, { "theorem_id": 316, "title": "mathd_numbertheory_207", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-207 = `8 * 9 EXP 2 + 5 * 9 + 2 = 695`;;\n" }, { "theorem_id": 316, "title": "mathd_numbertheory_207", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_207 imports Complex_Main\nbegin\n\ntheorem mathd_numbertheory_207:\n \"8 * 9^2 + 5 * 9 + 2 = (695::nat)\"\n by sorry\n\nend" }, { "theorem_id": 316, "title": "mathd_numbertheory_207", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_207 :\n 8 * 9^2 + 5 * 9 + 2 = 695 := by sorry" }, { "theorem_id": 316, "title": "mathd_numbertheory_207", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_207 :\n 8 * 9^2 + 5 * 9 + 2 = 695.\nProof.\nAdmitted." }, { "theorem_id": 317, "title": "mathd_numbertheory_211", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-211 = `CARD ({n:num | (n < 60) /\\ (6 divides num_of_int (abs (&4 * int_of_num n - &2)))}) = 20`;;\n" }, { "theorem_id": 317, "title": "mathd_numbertheory_211", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_211 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_211 :\n \"card {n::nat. n<60 \\ 6 dvd (4 * n - 2)} = 20\"\n by sorry\n\nend " }, { "theorem_id": 317, "title": "mathd_numbertheory_211", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_211 :\n Finset.card (Finset.filter (fun n => 6 ∣ 4 * ↑n - (2 : ℤ)) (Finset.range 60)) = 20 := by sorry" }, { "theorem_id": 317, "title": "mathd_numbertheory_211", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import List.\nImport ListNotations.\nRequire Import Arith.\n\nTheorem mathd_numbertheory_211 :\n length (filter (fun n => (4 * n - 2) mod 6 =? 0) (List.seq 1 59)) = 20.\n\nProof.\n" }, { "theorem_id": 318, "title": "mathd_numbertheory_212", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-212 = `(16 EXP 17 * 17 EXP 18 * 18 EXP 19) MOD 10 = 8`;;\n" }, { "theorem_id": 318, "title": "mathd_numbertheory_212", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_212 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_212 :\n \"(16^17 * 17^18 * 18^19) mod 10 = (8::nat)\"\n by sorry\n\nend " }, { "theorem_id": 318, "title": "mathd_numbertheory_212", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_212 :\n (16^17 * 17^18 * 18^19) % 10 = 8 := by sorry" }, { "theorem_id": 318, "title": "mathd_numbertheory_212", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_212 :\n (16^17 * 17^18 * 18^19) mod 10 = 8.\nProof.\nAdmitted." }, { "theorem_id": 319, "title": "mathd_numbertheory_22", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-22 = `!b:num.\n (b < 10) /\\\n floor (sqrt (&(10 * b + 6))) * floor (sqrt (&(10 * b + 6))) = &(10 * b + 6)\n==>\n (b = 3 \\/ b = 1)\n`;;\n" }, { "theorem_id": 319, "title": "mathd_numbertheory_22", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_22 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_22:\n fixes b :: nat\n assumes h0 : \"b < 10\"\n and h1 : \"\\a. (10*b+6) = a^2\"\n shows \"b=3 \\ b =1\"\n by sorry\n\nend" }, { "theorem_id": 319, "title": "mathd_numbertheory_22", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_22 (b : ℕ) (h₀ : b < 10)\n (h₁ : Nat.sqrt (10 * b + 6) * Nat.sqrt (10 * b + 6) = 10 * b + 6) : b = 3 ∨ b = 1 := by sorry" }, { "theorem_id": 319, "title": "mathd_numbertheory_22", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\nRequire Import Nat.\n\nTheorem mathd_numbertheory_22 :\n forall b : nat,\n b < 10 ->\n exists a : nat, (10 * b + 6) = a * a ->\n (b = 3 \\/ b = 1).\nProof.\nAdmitted." }, { "theorem_id": 320, "title": "mathd_numbertheory_221", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-221 = `(FINITE {x:num | (0 < x) /\\ (x < 1000) /\\ (CARD {d:num | d divides x} = 3)}) ==> (CARD {x:num | (0 < x) /\\ (x < 1000) /\\ (CARD {d:num | d divides x} = 3)} = 11)`;;\n" }, { "theorem_id": 320, "title": "mathd_numbertheory_221", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_221 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_221:\n \"card {x ::nat. 0 < x \\ x < 1000 \\ card ({n. n dvd x}) = 3} = 11\"\n by sorry\n\nend " }, { "theorem_id": 320, "title": "mathd_numbertheory_221", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_221 (S : Finset ℕ)\n (h₀ : ∀ x : ℕ, x ∈ S ↔ 0 < x ∧ x < 1000 ∧ x.divisors.card = 3) : S.card = 11 := by sorry" }, { "theorem_id": 320, "title": "mathd_numbertheory_221", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import List.\n\nDefinition has_three_divisors (n : nat) : bool :=\n length (filter (fun d => n mod d =? 0) (seq 1 n)) =? 3.\n\nTheorem mathd_numbertheory_221:\n length (filter has_three_divisors (seq 1 999)) = 11.\nProof.\nAdmitted.\n" }, { "theorem_id": 321, "title": "mathd_numbertheory_222", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-222 = `!b:num.\n (lcm (120, b) = 3720) /\\\n (gcd (120, b) = 8)\n==>\n (b = 248)\n`;;\n" }, { "theorem_id": 321, "title": "mathd_numbertheory_222", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_222 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_222:\n fixes b :: nat\n assumes \"lcm 120 b = 3720\"\n and \"gcd 120 b = 8\" \n shows \"b = 248\"\n by sorry\n\nend " }, { "theorem_id": 321, "title": "mathd_numbertheory_222", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_222\n (b : ℕ)\n (h₀ : Nat.lcm 120 b = 3720)\n (h₁ : Nat.gcd 120 b = 8) :\n b = 248 := by sorry" }, { "theorem_id": 321, "title": "mathd_numbertheory_222", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_222:\n forall b : nat,\n Nat.lcm 120 b = 3720 ->\n Nat.gcd 120 b = 8 ->\n b = 248.\nProof.\nAdmitted." }, { "theorem_id": 322, "title": "mathd_numbertheory_227", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-227 = `!x:num y:num n:num. (x > 0 /\\ y > 0 /\\ n > 0) /\\ (&x / &4 + &y / &6 = &(x + y) / &n) ==> n = 5`;;\n" }, { "theorem_id": 322, "title": "mathd_numbertheory_227", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_227 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_227:\n fixes x y n ::nat\n assumes \"x / 4 + y / 6 = (x + y) / n\"\n and \"n\\0\" \"x\\0\" \"y\\0\"\n shows \"n = 5\"\n by sorry\n\nend" }, { "theorem_id": 322, "title": "mathd_numbertheory_227", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_227\n (x y n : ℕ+)\n (h₀ : ↑x / (4:ℝ) + y / 6 = (x + y) / n) :\n n = 5 := by sorry" }, { "theorem_id": 322, "title": "mathd_numbertheory_227", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Reals.Reals.\nOpen Scope R_scope.\n\n\n\nTheorem mathd_numbertheory_227:\n forall (x y n : nat),\n x <> 0%nat ->\n y <> 0%nat ->\n n <> 0%nat ->\n (INR x / 4 + INR y / 6 = (INR x + INR y) / INR n) ->\n n = 5%nat.\n\nProof.\n" }, { "theorem_id": 323, "title": "mathd_numbertheory_229", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-229 = `(5 EXP 30) MOD 7 = 1`;;\n" }, { "theorem_id": 323, "title": "mathd_numbertheory_229", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_229 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_229:\n \"(5^30) mod 7 = (1::nat)\"\n by sorry\n\nend " }, { "theorem_id": 323, "title": "mathd_numbertheory_229", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_229 :\n (5^30) % 7 = 1 := by sorry" }, { "theorem_id": 323, "title": "mathd_numbertheory_229", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\n\n\n\nTheorem mathd_numbertheory_229:\n (5 ^ 30) mod 7 = 1.\n\nProof.\n" }, { "theorem_id": 324, "title": "mathd_numbertheory_232", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-232 = `!x:int y:int z:int.\n (&0 <= x /\\ x < &31) /\\\n (&0 <= y /\\ y < &31) /\\\n (&0 <= z /\\ z < &31) /\\\n (x * &3 == &1) (mod &31) /\\\n (y * &5 == &1) (mod &31) /\\\n ((z * &((num_of_int (x + y)) MOD 31)) == &1) (mod &31)\n==>\n z = &29\n`;;\n" }, { "theorem_id": 324, "title": "mathd_numbertheory_232", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_232 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_232:\n fixes x y z::nat\n assumes \"x<31\" \"y<31\" \"z<31\"\n and \"[x *3 = 1] (mod 31)\"\n and \"[y * 5 = 1] (mod 31)\"\n and \"[z * (x + y) =1] (mod 31)\" \n shows \"z = 29\"\n by sorry\n\nend " }, { "theorem_id": 324, "title": "mathd_numbertheory_232", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_232 (x y z : ZMod 31) (h₀ : x = 3⁻¹) (h₁ : y = 5⁻¹)\n (h₂ : z = (x + y)⁻¹) : z = 29 := by sorry" }, { "theorem_id": 324, "title": "mathd_numbertheory_232", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Ring.\nRequire Import Znumtheory.\n\nTheorem mathd_numbertheory_232 :\n forall x y z : Z,\n (x * 3) mod 31 = 1 ->\n (y * 5) mod 31 = 1 ->\n (z * (x + y)) mod 31 = 1 ->\n 0 <= x < 31 ->\n 0 <= y < 31 ->\n 0 <= z < 31 ->\n z = 29.\nProof.\nAdmitted." }, { "theorem_id": 325, "title": "mathd_numbertheory_233", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-233 = `!b:int.\n &0 <= b /\\ b < &11 pow 2 /\\\n (b * &24 == &1) (mod (&11 pow 2))\n==>\n b = &116\n`;;\n" }, { "theorem_id": 325, "title": "mathd_numbertheory_233", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_233 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_233:\n fixes b::int\n assumes \"\\b::int. 0\\b \\ b\\11^2 \\ [b * 24 = 1] (mod (11^2))\"\n shows \"b = 116\"\n by sorry\n\nend" }, { "theorem_id": 325, "title": "mathd_numbertheory_233", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_233\n (b : ZMod (11^2))\n (h₀ : b = 24⁻¹) :\n b = 116 := by sorry" }, { "theorem_id": 325, "title": "mathd_numbertheory_233", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Znumtheory.\n\nTheorem mathd_numbertheory_233:\n forall b : Z,\n 0 <= b < 11 * 11 ->\n (b * 24) mod (11 * 11) = 1 ->\n b = 116.\nProof.\nAdmitted." }, { "theorem_id": 326, "title": "mathd_numbertheory_234", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-234 = `!a:num b:num.\n (1 <= a /\\ a <= 9 /\\ b <= 9) /\\\n ((10 * a + b) EXP 3 = 912673)\n==>\n (a + b = 16)\n`;;\n" }, { "theorem_id": 326, "title": "mathd_numbertheory_234", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_234 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_234:\n fixes a b :: nat\n assumes \"1 \\ a \\ a \\ 9 \\ b \\ 9\"\n and \"(10 * a + b)^3 = 912673\" \n shows \"a + b = 16\"\n by sorry\n\nend" }, { "theorem_id": 326, "title": "mathd_numbertheory_234", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_234\n (a b : ℕ)\n (h₀ : 1 ≤ a ∧ a ≤ 9 ∧ b ≤ 9)\n (h₁ : (10 * a + b)^3 = 912673) :\n a + b = 16 := by sorry" }, { "theorem_id": 326, "title": "mathd_numbertheory_234", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.PeanoNat.\nRequire Import Coq.Arith.Arith.\n\nTheorem mathd_numbertheory_234 :\n forall a b : nat, \n (1 <= a /\\ a <= 9 /\\ b <= 9) ->\n (10 * a + b)^3 = 912673 ->\n a + b = 16.\nProof.\nAdmitted." }, { "theorem_id": 327, "title": "mathd_numbertheory_235", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-235 = `(29 * 79 + 31 * 81) MOD 10 = 2`;;\n" }, { "theorem_id": 327, "title": "mathd_numbertheory_235", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_235 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_235 :\n \"(29 * 79 + 31 * 81) mod 10 = (2::nat)\"\n by sorry\n\nend " }, { "theorem_id": 327, "title": "mathd_numbertheory_235", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_235 :\n (29 * 79 + 31 * 81) % 10 = 2 := by sorry" }, { "theorem_id": 327, "title": "mathd_numbertheory_235", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.PeanoNat.\n\nTheorem mathd_numbertheory_235 : \n (29 * 79 + 31 * 81) mod 10 = 2.\nProof.\nAdmitted." }, { "theorem_id": 328, "title": "mathd_numbertheory_236", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-236 = `(1999 EXP 2000) MOD 5 = 1`;;\n" }, { "theorem_id": 328, "title": "mathd_numbertheory_236", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_236 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_236:\n \"(1999^2000) mod 5 = (1::nat)\"\n by sorry\n\nend" }, { "theorem_id": 328, "title": "mathd_numbertheory_236", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_236 : 1999 ^ 2000 % 5 = 1 := by sorry" }, { "theorem_id": 328, "title": "mathd_numbertheory_236", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\n\nTheorem mathd_numbertheory_236:\n (1999 ^ 2000) mod 5 = 1.\nProof.\nAdmitted." }, { "theorem_id": 329, "title": "mathd_numbertheory_237", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-237 = `(nsum (0..(101-1)) (\\k. k)) MOD 6 = 4`;;\n" }, { "theorem_id": 329, "title": "mathd_numbertheory_237", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_237 imports Complex_Main\nbegin\n\ntheorem mathd_numbertheory_237 :\n \"(\\ k<101. k) mod 6 = (4::nat)\"\n by sorry\n\nend" }, { "theorem_id": 329, "title": "mathd_numbertheory_237", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_237 :\n (∑ k ∈ (Finset.range 101), k) % 6 = 4 := by sorry" }, { "theorem_id": 329, "title": "mathd_numbertheory_237", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Lists.List.\nRequire Import Coq.Arith.Arith.\nImport ListNotations.\n\nOpen Scope nat_scope.\n\n\n\nTheorem mathd_numbertheory_237:\n Nat.modulo (fold_left plus (seq 0 101) 0) 6 = 4.\n\nProof.\n" }, { "theorem_id": 330, "title": "mathd_numbertheory_24", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-24 = `nsum (1..(10-1)) (\\k. 11 EXP k) MOD 100 = 59`;;\n" }, { "theorem_id": 330, "title": "mathd_numbertheory_24", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_24 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \nbegin\n\ntheorem mathd_numbertheory_24:\n \"(\\ k \\{1..<10}. 11^k) mod 100 = (59::nat)\"\n by sorry\n\nend " }, { "theorem_id": 330, "title": "mathd_numbertheory_24", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_24 : (∑ k ∈ Finset.Icc 1 9, 11 ^ k) % 100 = 59 := by sorry" }, { "theorem_id": 330, "title": "mathd_numbertheory_24", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import List.\nImport ListNotations.\nRequire Import Arith.\n\nTheorem mathd_numbertheory_24 :\n (fold_right plus 0 (map (fun k => 11 ^ k) (seq 1 9))) mod 100 = 59.\nProof.\nAdmitted." }, { "theorem_id": 331, "title": "mathd_numbertheory_247", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-247 = `!n:num. ((3 * n) MOD 2 = 11) ==> n MOD 11 = 8`;;\n" }, { "theorem_id": 331, "title": "mathd_numbertheory_247", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_247 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_247:\n fixes n ::nat\n assumes \"(3 * n) mod 2 = 11\" \n shows \"n mod 11 = 8\"\n by sorry\n\nend" }, { "theorem_id": 331, "title": "mathd_numbertheory_247", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_247\n (n : ℕ)\n (h₀ : (3 * n) % 11 = 2) :\n n % 11 = 8 := by sorry" }, { "theorem_id": 331, "title": "mathd_numbertheory_247", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_247 : forall n : nat,\n (3 * n) mod 11 = 2 -> n mod 11 = 8.\nProof.\nAdmitted.\n" }, { "theorem_id": 332, "title": "mathd_numbertheory_252", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-252 = `(FACT 7) MOD 23 = 3`;;\n" }, { "theorem_id": 332, "title": "mathd_numbertheory_252", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_252 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_252:\n \"(fact 7) mod 23 = (3::nat)\"\n by sorry\n\nend" }, { "theorem_id": 332, "title": "mathd_numbertheory_252", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_252 : 7! % 23 = 3 := by sorry" }, { "theorem_id": 332, "title": "mathd_numbertheory_252", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\nRequire Import Coq.Arith.Factorial.\n\n\n\nTheorem mathd_numbertheory_252 :\n (fact 7) mod 23 = 3.\n\nProof.\n" }, { "theorem_id": 333, "title": "mathd_numbertheory_254", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-254 = `(239 + 174 + 83) MOD 10 = 6`;;\n" }, { "theorem_id": 333, "title": "mathd_numbertheory_254", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_254 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_254:\n \"(239 + 174 + 83) mod 10 = (6::nat)\"\n by sorry\n\nend " }, { "theorem_id": 333, "title": "mathd_numbertheory_254", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_254 :\n (239 + 174 + 83) % 10 = 6 := by sorry" }, { "theorem_id": 333, "title": "mathd_numbertheory_254", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_254 : (239 + 174 + 83) mod 10 = 6.\nProof.\nAdmitted." }, { "theorem_id": 334, "title": "mathd_numbertheory_257", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-257 = `!x:num.\n (1 <= x /\\ x <= 100) /\\\n (77 divides (nsum (0..(101-1)) (\\k. k - x)))\n==>\n (x = 45)\n`;;\n" }, { "theorem_id": 334, "title": "mathd_numbertheory_257", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_257 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_257:\n fixes x :: nat\n assumes h0 : \"1 \\ x \\ x \\ 100\"\n and h1 : \"77 dvd ((\\k::nat=0..100. k)-x)\"\n shows \"x=45\"\n by sorry\n\nend" }, { "theorem_id": 334, "title": "mathd_numbertheory_257", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_257 (x : ℕ) (h₀ : 1 ≤ x ∧ x ≤ 100)\n (h₁ : 77 ∣ (∑ k ∈ Finset.range 101, k) - x) : x = 45 := by sorry" }, { "theorem_id": 334, "title": "mathd_numbertheory_257", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import List.\nImport ListNotations.\n\nTheorem mathd_numbertheory_257 :\n forall x : nat,\n (1 <= x /\\ x <= 100) ->\n (exists k, k * 77 = fold_right plus 0 (seq 0 101) - x) ->\n x = 45.\n\nProof.\n" }, { "theorem_id": 335, "title": "mathd_numbertheory_277", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-277 = `!m:num n:num.\n (gcd(m, n) = 6) /\\\n (lcm(m, n) = 126)\n==>\n 60 <= m + n\n`;;\n" }, { "theorem_id": 335, "title": "mathd_numbertheory_277", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_277 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_277:\n fixes m n ::nat\n assumes \"gcd m n = 6\"\n and \"lcm m n = 126\" \n shows \"60 \\ m + n\"\n by sorry\n\nend" }, { "theorem_id": 335, "title": "mathd_numbertheory_277", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_277\n (m n : ℕ)\n (h₀ : Nat.gcd m n = 6)\n (h₁ : Nat.lcm m n = 126) :\n 60 ≤ m + n := by sorry" }, { "theorem_id": 335, "title": "mathd_numbertheory_277", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\n\n\n\nTheorem mathd_numbertheory_277 :\n forall (m n : nat),\n Nat.gcd m n = 6 ->\n Nat.lcm m n = 126 ->\n 60 <= m + n.\n\nProof.\n" }, { "theorem_id": 336, "title": "mathd_numbertheory_284", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-284 = `!a:num b:num.\n (1 <= a /\\ a <= 9 /\\ b <= 9) /\\\n (10 * a + b = 2 * (a + b))\n==>\n 10 * a + b = 18\n`;;\n" }, { "theorem_id": 336, "title": "mathd_numbertheory_284", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_284 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_284:\n fixes a b :: nat\n assumes h0 : \"1\\a \\ a \\9 \\ b \\9\"\n and h1 : \"10 * a + b = 2 * (a+b)\"\n shows \"10 * a + b = 18\"\n by sorry\n\nend" }, { "theorem_id": 336, "title": "mathd_numbertheory_284", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_284 (a b : ℕ) (h₀ : 1 ≤ a ∧ a ≤ 9 ∧ b ≤ 9)\n (h₁ : 10 * a + b = 2 * (a + b)) : 10 * a + b = 18 := by sorry" }, { "theorem_id": 336, "title": "mathd_numbertheory_284", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import ZArith.\n\nTheorem mathd_numbertheory_284 :\n forall a b : nat,\n 1 <= a /\\ a <= 9 /\\ b <= 9 ->\n 10 * a + b = 2 * (a + b) ->\n 10 * a + b = 18.\nProof.\nAdmitted." }, { "theorem_id": 337, "title": "mathd_numbertheory_299", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-299 = `(1 * 3 * 5 * 7 * 9 * 11 * 13) MOD 10 = 5`;;\n" }, { "theorem_id": 337, "title": "mathd_numbertheory_299", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_299 imports Complex_Main\nbegin\n\ntheorem mathd_numbertheory_299 :\n \"(1 * 3 * 5 * 7 * 9 * 11 * 13) mod 10 = (5::nat)\"\n by sorry\n\nend" }, { "theorem_id": 337, "title": "mathd_numbertheory_299", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_299 :\n (1 * 3 * 5 * 7 * 9 * 11 * 13) % 10 = 5 := by sorry" }, { "theorem_id": 337, "title": "mathd_numbertheory_299", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\n\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_299 :\n (1 * 3 * 5 * 7 * 9 * 11 * 13) mod 10 = 5.\nProof.\nAdmitted." }, { "theorem_id": 338, "title": "mathd_numbertheory_3", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-3 = `(nsum (0..(10-1)) (\\x. (x + 1) EXP 2)) MOD 10 = 5`;;\n" }, { "theorem_id": 338, "title": "mathd_numbertheory_3", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_3 imports Complex_Main\nbegin\n\ntheorem mathd_numbertheory_3 :\n \"(\\ x < 10. ((x + 1)^2)) mod 10 = (5::nat)\"\n by sorry\n\nend " }, { "theorem_id": 338, "title": "mathd_numbertheory_3", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_3 :\n (∑ x ∈ Finset.range 10, ((x + 1)^2)) % 10 = 5 := by sorry" }, { "theorem_id": 338, "title": "mathd_numbertheory_3", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\n\n\n\nTheorem mathd_numbertheory_3 :\n ((1 * 1) +\n (2 * 2) +\n (3 * 3) +\n (4 * 4) +\n (5 * 5) +\n (6 * 6) +\n (7 * 7) +\n (8 * 8) +\n (9 * 9)) mod 10 = 5.\n\nProof.\n" }, { "theorem_id": 339, "title": "mathd_numbertheory_30", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-30 = `(33818 EXP 2 + 33819 EXP 2 + 33820 EXP 2 + 33821 EXP 2 + 33822 EXP 2) MOD 17 = 0`;;\n" }, { "theorem_id": 339, "title": "mathd_numbertheory_30", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_30 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_numbertheory_30:\n \"(33818^2 + 33819^2 + 33820^2 + 33821^2 + 33822^2) mod 17 = (0::nat)\"\n by sorry\n\nend" }, { "theorem_id": 339, "title": "mathd_numbertheory_30", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_30 :\n (33818 ^ 2 + 33819 ^ 2 + 33820 ^ 2 + 33821 ^ 2 + 33822 ^ 2) % 17 = 0 := by sorry" }, { "theorem_id": 339, "title": "mathd_numbertheory_30", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\nRequire Import ZArith.\n\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_30:\n (33818^2 + 33819^2 + 33820^2 + 33821^2 + 33822^2) mod 17 = 0.\nProof.\nAdmitted." }, { "theorem_id": 340, "title": "mathd_numbertheory_301", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-301 = `!j:num.\n ~(j = 0)\n==>\n ((3 * (7 * j + 3)) MOD 7 = 2)\n`;;\n" }, { "theorem_id": 340, "title": "mathd_numbertheory_301", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_301 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_301:\n fixes j :: nat \n assumes \"j>0\"\n shows \"(3 * (7 * j + 3)) mod 7 = 2\"\n by sorry\n\nend " }, { "theorem_id": 340, "title": "mathd_numbertheory_301", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_301 (j : ℕ) (h₀ : 0 < j) : 3 * (7 * ↑j + 3) % 7 = 2 := by sorry" }, { "theorem_id": 340, "title": "mathd_numbertheory_301", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\nRequire Import ZArith.\n\nOpen Scope nat_scope.\n\nTheorem mathd_numbertheory_301:\n forall j : nat,\n j > 0 ->\n (3 * (7 * j + 3)) mod 7 = 2.\nProof.\nAdmitted." }, { "theorem_id": 341, "title": "mathd_numbertheory_303", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-303 = `(FINITE {n:num | ((2 <= n) /\\ ((171 == 80) (mod n)) /\\ ((468 == 13) (mod n)))}) ==> (nsum {n:num | ((2 <= n) /\\ ((171 == 80) (mod n)) /\\ ((468 == 13) (mod n)))} (\\k. k) = 111)`;;\n" }, { "theorem_id": 341, "title": "mathd_numbertheory_303", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_303 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_303:\n \"(\\ k \\ {n ::nat. 2 \\ n \\ [171 = 80] (mod n) \\ [468 = 13] (mod n)}. k) = 111\"\n by sorry\n\nend " }, { "theorem_id": 341, "title": "mathd_numbertheory_303", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_303 (S : Finset ℕ)\n (h₀ : ∀ n : ℕ, n ∈ S ↔ 2 ≤ n ∧ 171 ≡ 80 [MOD n] ∧ 468 ≡ 13 [MOD n]) : (∑ k ∈ S, k) = 111 := by sorry" }, { "theorem_id": 341, "title": "mathd_numbertheory_303", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import List.\nImport ListNotations.\n\n\n\nTheorem mathd_numbertheory_303 (l : list nat)\n (H : forall n, In n l <-> 2 <= n\n /\\ (171 mod n = 80 mod n)\n /\\ (468 mod n = 13 mod n)):\n NoDup l ->\n list_sum l = 111.\nProof.\n" }, { "theorem_id": 342, "title": "mathd_numbertheory_32", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-32 = `FINITE {n | n divides 36} ==> nsum {n | n divides 36} (\\k. k) = 91`;;\n" }, { "theorem_id": 342, "title": "mathd_numbertheory_32", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_32 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_32:\n \"(\\ k \\ { n ::nat. n dvd 36}. k) = 91\"\n by sorry\n\nend " }, { "theorem_id": 342, "title": "mathd_numbertheory_32", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_32 (S : Finset ℕ) (h₀ : ∀ n : ℕ, n ∈ S ↔ n ∣ 36) : (∑ k ∈ S, k) = 91 := by sorry" }, { "theorem_id": 342, "title": "mathd_numbertheory_32", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Init.Nat.\nRequire Import Coq.Lists.List.\nImport ListNotations.\n\n\nDefinition divides (d n : nat) : bool :=\n Nat.eqb (n mod d) 0.\n\n\nDefinition divisors (n : nat) : list nat :=\n filter (fun d => divides d n) (seq 1 n).\n\n\nFixpoint sum_list (l : list nat) : nat :=\n match l with\n | [] => 0\n | x :: xs => x + sum_list xs\n end.\n\n\nTheorem mathd_numbertheory_32 : sum_list (divisors 36) = 91.\n\nProof.\n" }, { "theorem_id": 343, "title": "mathd_numbertheory_321", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-321 = `!n:int.\n &0 <= n /\\ n < &1399 /\\\n (n * &160 == &1) (mod &1399)\n==>\n n = &1058\n`;;\n" }, { "theorem_id": 343, "title": "mathd_numbertheory_321", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_321 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_321:\n fixes n::int\n assumes \"\\n::int. 1\\n \\ n\\ 1399 \\ [n*160 = 1] (mod 1399)\"\n shows \"n = 1058\"\n by sorry\n\nend" }, { "theorem_id": 343, "title": "mathd_numbertheory_321", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_321\n (n : ZMod 1399)\n (h₁ : n = 160⁻¹) :\n n = 1058 := by sorry" }, { "theorem_id": 343, "title": "mathd_numbertheory_321", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_321:\n forall n : Z,\n (0 <= n < 1399) /\\ (n * 160 mod 1399 = 1) ->\n n = 1058.\nProof.\nAdmitted.\n" }, { "theorem_id": 344, "title": "mathd_numbertheory_326", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-326 = `!n:num.\n ((int_of_num n - &1) * &n * (&n + &1) = &720)\n==>\n (n + 1) = 10\n`;;\n" }, { "theorem_id": 344, "title": "mathd_numbertheory_326", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_326 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_326:\n fixes n :: nat\n assumes \"(n - 1) * n * (n + 1) = 720\" \n shows \"(n + 1) = 10\"\n by sorry\n\nend " }, { "theorem_id": 344, "title": "mathd_numbertheory_326", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_326 (n : ℤ) (h₀ : (n - 1) * n * (n + 1) = 720 ) : n + 1 = 10 := by sorry" }, { "theorem_id": 344, "title": "mathd_numbertheory_326", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Theorem mathd_numbertheory_326 :\n forall n : nat,\n (n - 1) * n * (n + 1) = 720 ->\n n + 1 = 10.\nProof.\nAdmitted." }, { "theorem_id": 345, "title": "mathd_numbertheory_328", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-328 = `(5 EXP 999999) MOD 7 = 6`;;\n" }, { "theorem_id": 345, "title": "mathd_numbertheory_328", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_328 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_328 :\n \"(5^999999) mod 7 = (6::nat)\"\n by sorry\n\nend" }, { "theorem_id": 345, "title": "mathd_numbertheory_328", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_328 :\n (5^999999) % 7 = 6 := by sorry" }, { "theorem_id": 345, "title": "mathd_numbertheory_328", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import NArith.\n\nOpen Scope N_scope.\n\nTheorem mathd_numbertheory_328 :\n (5^999999 mod 7) = 6.\nProof.\nAdmitted.\n" }, { "theorem_id": 346, "title": "mathd_numbertheory_33", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-33 = `!n:num.\n (n < 398) /\\\n ((n * 7) MOD 398 = 1)\n==>\n (n = 57)\n`;;\n" }, { "theorem_id": 346, "title": "mathd_numbertheory_33", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_33 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_33:\n fixes n :: nat\n assumes h0 : \"n < 398\"\n and h1 : \"(n * 7) mod 398 = 1\"\n shows \"n=57\"\n by sorry\n\nend" }, { "theorem_id": 346, "title": "mathd_numbertheory_33", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_33 (n : ℕ) (h₀ : n < 398) (h₁ : n * 7 % 398 = 1) : n = 57 := by sorry" }, { "theorem_id": 346, "title": "mathd_numbertheory_33", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\n\nTheorem mathd_numbertheory_33:\n forall (n : nat),\n (n < 398) ->\n (n * 7 mod 398 = 1) ->\n n = 57.\nProof.\nAdmitted." }, { "theorem_id": 347, "title": "mathd_numbertheory_335", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-335 = `!n:num.\n (n MOD 7 = 5)\n==>\n ((5 * n) MOD 7 = 4)\n`;;\n" }, { "theorem_id": 347, "title": "mathd_numbertheory_335", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_335 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_335:\n fixes n :: nat\n assumes h0 : \"n mod 7 = 5\"\n shows \"(5 * n) mod 7 = 4\"\n by sorry\n\nend" }, { "theorem_id": 347, "title": "mathd_numbertheory_335", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_335 (n : ℕ) (h₀ : n % 7 = 5) : 5 * n % 7 = 4 := by sorry" }, { "theorem_id": 347, "title": "mathd_numbertheory_335", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\n\nTheorem mathd_numbertheory_335 :\n forall n : nat,\n n mod 7 = 5 -> (5 * n) mod 7 = 4.\nProof.\nAdmitted." }, { "theorem_id": 348, "title": "mathd_numbertheory_34", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-34 = `!x:num.\n (x < 100) /\\\n ((x * 9) MOD 100 = 1)\n==>\n x = 89\n`;;\n" }, { "theorem_id": 348, "title": "mathd_numbertheory_34", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_34 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_34:\n fixes x::nat\n assumes \"x < 100\"\n and \"x*9 mod 100 = 1\" \n shows \"x = 89\"\n by sorry\n\nend" }, { "theorem_id": 348, "title": "mathd_numbertheory_34", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_34\n (x: ℕ)\n (h₀ : x < 100)\n (h₁ : x*9 % 100 = 1) :\n x = 89 := by sorry" }, { "theorem_id": 348, "title": "mathd_numbertheory_34", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.PeanoNat.\nRequire Import Coq.Arith.Arith.\n\nTheorem mathd_numbertheory_34 : \n forall x : nat, \n (x < 100) -> \n (x * 9 mod 100 = 1) -> \n (x = 89).\nProof.\nAdmitted." }, { "theorem_id": 349, "title": "mathd_numbertheory_341", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-341 = `!a:num b:num c:num.\n (a <= 9 /\\ b <= 9 /\\ c <= 9) /\\\n ((5 EXP 100) MOD 1000 = 10*(10*a + b) + c)\n==>\n (a + b + c = 13)\n`;;\n" }, { "theorem_id": 349, "title": "mathd_numbertheory_341", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_341 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_341:\n fixes a b c ::nat\n assumes \"a \\ 9 \\ b \\ 9 \\ c \\ 9\"\n and \"(5^100) mod 1000 = 10*(10*a + b) + c\"\n shows \"a + b + c = 13\"\n by sorry\n\nend " }, { "theorem_id": 349, "title": "mathd_numbertheory_341", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_341\n (a b c : ℕ)\n (h₀ : a ≤ 9 ∧ b ≤ 9 ∧ c ≤ 9)\n (h₁ : Nat.digits 10 ((5^100) % 1000) = [c,b,a]) :\n a + b + c = 13 := by sorry" }, { "theorem_id": 349, "title": "mathd_numbertheory_341", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\n\nTheorem mathd_numbertheory_341 :\n forall a b c : nat,\n (a <= 9) -> (b <= 9) -> (c <= 9) ->\n (5^100 mod 1000 = 100*a + 10*b + c) ->\n a + b + c = 13.\nProof.\nAdmitted." }, { "theorem_id": 350, "title": "mathd_numbertheory_342", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-342 = `54 MOD 6 = 0`;;\n" }, { "theorem_id": 350, "title": "mathd_numbertheory_342", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_342 imports Complex_Main\nbegin\n\ntheorem mathd_numbertheory_342:\n \"54 mod 6 = (0::nat)\"\n by sorry\n\nend" }, { "theorem_id": 350, "title": "mathd_numbertheory_342", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_342 :\n 54 % 6 = 0 := by sorry" }, { "theorem_id": 350, "title": "mathd_numbertheory_342", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_342 : 54 mod 6 = 0.\nProof.\nAdmitted." }, { "theorem_id": 351, "title": "mathd_numbertheory_345", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-345 = `(2000 + 2001 + 2002 + 2003 + 2004 + 2005 + 2006) MOD 7 = 0`;;\n" }, { "theorem_id": 351, "title": "mathd_numbertheory_345", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_345 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_345 :\n \"(2000 + 2001 + 2002 + 2003 + 2004 + 2005 + 2006) mod 7 = (0::nat)\"\n by sorry\n\nend" }, { "theorem_id": 351, "title": "mathd_numbertheory_345", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_345 :\n (2000 + 2001 + 2002 + 2003 + 2004 + 2005 + 2006) % 7 = 0 := by sorry" }, { "theorem_id": 351, "title": "mathd_numbertheory_345", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_345 :\n (2000 + 2001 + 2002 + 2003 + 2004 + 2005 + 2006) mod 7 = 0.\nProof.\nAdmitted." }, { "theorem_id": 352, "title": "mathd_numbertheory_35", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-35 = `\n (FINITE {n | n divides (num_of_int (int_of_real (sqrt (&196))))})\n==>\n (nsum {n | n divides (num_of_int (int_of_real (sqrt (&196))))} (\\k. k) = 24)\n`;;\n" }, { "theorem_id": 352, "title": "mathd_numbertheory_35", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_35 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_35:\n assumes \"k^2 = 196\"\n shows \"(\\ k \\ { n ::nat. n dvd k}. k) = (24::nat)\"\n by sorry\n\nend " }, { "theorem_id": 352, "title": "mathd_numbertheory_35", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_35 (S : Finset ℕ) (h₀ : ∀ n : ℕ, n ∈ S ↔ n ∣ Nat.sqrt 196) :\n (∑ k ∈ S, k) = 24 := by sorry" }, { "theorem_id": 352, "title": "mathd_numbertheory_35", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\nRequire Import Coq.Lists.List.\nImport ListNotations.\n\nTheorem mathd_numbertheory_35 : \n (1 + 2 + 7 + 14) = 24. \nProof.\nAdmitted." }, { "theorem_id": 353, "title": "mathd_numbertheory_37", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-37 = `lcm(9999,100001) = 90900909`;;\n" }, { "theorem_id": 353, "title": "mathd_numbertheory_37", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_37 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_37:\n \"lcm 9999 100001 = (90900909::nat)\"\n by sorry\n\nend" }, { "theorem_id": 353, "title": "mathd_numbertheory_37", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_37 : Nat.lcm 9999 100001 = 90900909 := by sorry" }, { "theorem_id": 353, "title": "mathd_numbertheory_37", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_37 :\n Nat.lcm 9999 100001 = 90900909.\nProof.\nAdmitted.\n" }, { "theorem_id": 354, "title": "mathd_numbertheory_370", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-370 = `!n:num.\n (n MOD 7 = 3)\n==>\n ((2 * n + 1) MOD 7 = 0)\n`;;\n" }, { "theorem_id": 354, "title": "mathd_numbertheory_370", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_370 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_numbertheory_370:\n fixes n :: nat\n assumes h0 : \"n mod 7 = (3::nat)\"\n shows \"(2*n+1) mod 7 = (0::nat)\"\n by sorry\n\nend" }, { "theorem_id": 354, "title": "mathd_numbertheory_370", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_370 (n : ℕ) (h₀ : n % 7 = 3) : (2 * n + 1) % 7 = 0 := by sorry" }, { "theorem_id": 354, "title": "mathd_numbertheory_370", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\nRequire Import Nat.\n\nTheorem mathd_numbertheory_370:\n forall n : nat, \n (n mod 7 = 3) -> \n (2 * n + 1) mod 7 = 0.\nProof.\nAdmitted." }, { "theorem_id": 355, "title": "mathd_numbertheory_403", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-403 = `nsum {k | k divides 198 /\\ ~(k = 198)} (\\k. k) = 270`;;\n" }, { "theorem_id": 355, "title": "mathd_numbertheory_403", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_403 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_403:\n \"(\\ k \\ ({n. n dvd 198 \\ n\\ 198}). k) = (270::nat)\"\n by sorry\n\nend " }, { "theorem_id": 355, "title": "mathd_numbertheory_403", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_403 : (∑ k ∈ Nat.properDivisors 198, k) = 270 := by sorry" }, { "theorem_id": 355, "title": "mathd_numbertheory_403", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\nRequire Import Coq.Lists.List.\nImport ListNotations.\n\nOpen Scope nat_scope.\n\n\nDefinition dividesb (d n : nat) : bool :=\n (n mod d) =? 0.\n\n\n\nTheorem mathd_numbertheory_403 :\n fold_right plus 0\n (filter (fun x => andb (dividesb x 198) (negb (x =? 198))) (seq 1 198))\n = 270.\n\nProof.\n" }, { "theorem_id": 356, "title": "mathd_numbertheory_405", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-405 = `!a:num b:num c:num t:num->num.\n (t 0 = 0) /\\\n (t 1 = 1) /\\\n (!n. (n > 1) ==> (t n = t (num_of_int (int_of_num (n) - &2)) + t (num_of_int (int_of_num (n) - &1)))) /\\\n ((a == 5) (mod 16)) /\\\n ((b == 10) (mod 16)) /\\\n ((c == 15) (mod 16))\n==>\n (t a + t b + t c) MOD 7 = 5\n`;;\n" }, { "theorem_id": 356, "title": "mathd_numbertheory_405", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_405 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_numbertheory_405:\n fixes a b c :: nat\n and t :: \"nat \\ nat\"\n assumes h0 : \"t 0 = 0\"\n and h1 : \"t 1 = 1\"\n and h2 : \"\\n. (n > 1) \\ t n = t (n-2) + t (n-1)\"\n and h3 : \"a mod 16 = 5\"\n and h4 : \"b mod 16 = 10\"\n and h5 : \"c mod 16 = 15\"\n shows \"(t a + t b + t c) mod 7 = 5\"\n by sorry\n\nend" }, { "theorem_id": 356, "title": "mathd_numbertheory_405", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_405 (a b c : ℕ) (t : ℕ → ℕ) (h₀ : t 0 = 0) (h₁ : t 1 = 1)\n (h₂ : ∀ n > 1, t n = t (n - 2) + t (n - 1)) (h₃ : a ≡ 5 [MOD 16]) (h₄ : b ≡ 10 [MOD 16])\n (h₅ : c ≡ 15 [MOD 16]) : (t a + t b + t c) % 7 = 5 := by sorry" }, { "theorem_id": 356, "title": "mathd_numbertheory_405", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import PeanoNat.\nRequire Import ZArith.\n\nTheorem mathd_numbertheory_405\n (a b c : nat)\n (t : nat -> nat)\n (h0 : t 0 = 0)\n (h1 : t 1 = 1)\n (h2 : forall n, n > 1 -> t n = t (n - 2) + t (n - 1))\n (h3 : a mod 16 = 5)\n (h4 : b mod 16 = 10)\n (h5 : c mod 16 = 15) :\n (t a + t b + t c) mod 7 = 5.\nProof.\nAdmitted." }, { "theorem_id": 357, "title": "mathd_numbertheory_412", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-412 = `!x:num y:num.\n (x MOD 19 = 4) /\\\n (y MOD 19 = 7)\n==>\n ((x + 1) EXP 2 * (y + 5) EXP 3) MOD 19 = 13\n`;;\n" }, { "theorem_id": 357, "title": "mathd_numbertheory_412", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_412 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_numbertheory_412:\n fixes x y :: nat\n assumes h0 : \"x mod 19 = (4:: nat)\"\n and h1 : \"y mod 19 = (7:: nat)\"\n shows \"(x+1)^2 * (y+5)^3 mod 19 = (13:: nat)\"\n by sorry\n\nend" }, { "theorem_id": 357, "title": "mathd_numbertheory_412", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_412 (x y : ℤ) (h₀ : x % 19 = 4) (h₁ : y % 19 = 7) :\n (x + 1) ^ 2 * (y + 5) ^ 3 % 19 = 13 := by sorry" }, { "theorem_id": 357, "title": "mathd_numbertheory_412", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import ZArith.\nOpen Scope nat_scope.\n\nTheorem mathd_numbertheory_412 :\n forall (x y : nat),\n (x mod 19 = 4) ->\n (y mod 19 = 7) ->\n ((x + 1)^2 * (y + 5)^3) mod 19 = 13.\nProof.\nAdmitted." }, { "theorem_id": 358, "title": "mathd_numbertheory_42", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-42 = `!u:num v:num.\n (~(u = 0) /\\ ~(v = 0)) /\\\n ((27 * u) MOD 40 = 17) /\\\n ((27 * v) MOD 40 = 17) /\\\n (u < 40) /\\\n (v < 80) /\\\n (40 < v)\n==>\n ((u + v) = 62)\n`;;\n" }, { "theorem_id": 358, "title": "mathd_numbertheory_42", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_42 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_42:\n fixes u v :: nat\n assumes \"27 * u mod 40 = 17\"\n and \"27 * v mod 40 = 17\"\n and \"u < 40\"\n and \"v < 80\"\n and \"40 < v\" \n shows \"(u + v) = 62\"\n by sorry\n\nend " }, { "theorem_id": 358, "title": "mathd_numbertheory_42", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_42 (S : Set ℕ) (u v : ℕ) (h₀ : ∀ a : ℕ, a ∈ S ↔ 0 < a ∧ 27 * a % 40 = 17)\n (h₁ : IsLeast S u) (h₂ : IsLeast (S \\ {u}) v) : u + v = 62 := by sorry" }, { "theorem_id": 358, "title": "mathd_numbertheory_42", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import PeanoNat.\nRequire Import Arith.\n\nTheorem mathd_numbertheory_42 :\n forall u v : nat,\n (27 * u mod 40 = 17) ->\n (27 * v mod 40 = 17) ->\n (u < 40) ->\n (v < 80) ->\n (40 < v) ->\n (u + v = 62).\nProof.\nAdmitted." }, { "theorem_id": 359, "title": "mathd_numbertheory_427", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-427 = `!a:num.\n (a = nsum ({d:num | d divides 500}) (\\k. k))\n==>\n nsum ({x:num | (prime x /\\ x divides a)}) (\\k. k) = 25`;;\n" }, { "theorem_id": 359, "title": "mathd_numbertheory_427", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_427 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_427:\n fixes a :: nat\n assumes \"a = (\\ k\\ {n. n dvd 500}. k)\" \n shows \"(\\ k \\ {n. prime n \\ n dvd a}. k) = 25\"\n by sorry\n\nend" }, { "theorem_id": 359, "title": "mathd_numbertheory_427", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_427\n (a : ℕ)\n (h₀ : a = (∑ k ∈ (Nat.divisors 500), k)) :\n ∑ k ∈ Finset.filter (λ x => Nat.Prime x) (Nat.divisors a), k = 25 := by sorry" }, { "theorem_id": 359, "title": "mathd_numbertheory_427", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\nRequire Import List.\nRequire Import Arith.\nRequire Import List.\nImport ListNotations.\n\n\nDefinition get_divisors (n : nat) :=\n filter (fun k => Nat.eqb (n mod k) 0) (seq 1 (S n)).\n\n\nDefinition sum_list := fold_right plus 0.\n\n\nDefinition is_prime (p : nat) :=\n match p with\n | 0 | 1 => false\n | n => forallb (fun d => negb (Nat.eqb (n mod d) 0)) (seq 2 (n - 2))\n end.\n\nTheorem mathd_numbertheory_427 :\n forall (a : nat),\n a = sum_list (get_divisors 500) ->\n sum_list (filter (fun k => andb (is_prime k) (Nat.eqb (a mod k) 0)) (seq 1 (S a))) = 25.\n\nProof.\nAdmitted.\n" }, { "theorem_id": 360, "title": "mathd_numbertheory_43", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-43 = `!n:num.\n (n > 0) /\\\n (15 EXP n divides FACT 942) /\\\n (!m. 15 EXP m divides FACT 942 ==> m <= n)\n==>\n n = 233`;;\n" }, { "theorem_id": 360, "title": "mathd_numbertheory_43", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_43 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_43:\n fixes n :: nat\n assumes h0 : \"15^n dvd (fact 942)\"\n and h1 : \"\\(m::nat). ((15::nat)^m dvd (fact 942)) \\ m \\ n\"\n shows \"n=233\"\n by sorry\n\nend" }, { "theorem_id": 360, "title": "mathd_numbertheory_43", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_43 : IsGreatest { n : ℕ | 15 ^ n ∣ 942! } 233 := by sorry" }, { "theorem_id": 360, "title": "mathd_numbertheory_43", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import Arith.\n\nDefinition is_greatest (P : nat -> Prop) (n : nat) : Prop :=\n P n /\\ (forall m, P m -> m <= n).\n\nTheorem mathd_numbertheory_43 :\n is_greatest (fun n => exists k, k * (15^n) = fact 942) 233.\n\nProof.\n" }, { "theorem_id": 361, "title": "mathd_numbertheory_447", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-447 = `nsum {k:num | k >= 1 /\\ k <= (50-1) /\\ 3 divides k} (\\k. k MOD 10) = 78`;;\n" }, { "theorem_id": 361, "title": "mathd_numbertheory_447", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_447 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_447:\n \"(\\ k \\{n. 3 dvd n \\ 0 n<50}. k mod 3) = (78::nat)\"\n by sorry\n\nend" }, { "theorem_id": 361, "title": "mathd_numbertheory_447", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_447 :\n ∑ k ∈ Finset.filter (λ x => 3∣x) (Finset.Icc 1 49), (k % 10) = 78 := by sorry" }, { "theorem_id": 361, "title": "mathd_numbertheory_447", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Lists.List.\nRequire Import Coq.Arith.PeanoNat.\nImport ListNotations.\n\n\n\nTheorem mathd_numbertheory_447 :\n fold_right plus 0\n (map (fun k => k mod 10)\n (filter (fun x => Nat.eqb (x mod 3) 0)\n (seq 1 49))) = 78.\n\nProof.\n" }, { "theorem_id": 362, "title": "mathd_numbertheory_45", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-45 = `gcd(6432,132) + 11 = 23`;;\n" }, { "theorem_id": 362, "title": "mathd_numbertheory_45", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_45 imports Complex_Main\nbegin\n\ntheorem mathd_numbertheory_45 :\n \"(gcd 6432 132) + 11 = (23::nat)\"\n by sorry\n\nend" }, { "theorem_id": 362, "title": "mathd_numbertheory_45", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_45 : Nat.gcd 6432 132 + 11 = 23 := by sorry" }, { "theorem_id": 362, "title": "mathd_numbertheory_45", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import ZArith.\n\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_45 :\n (Z.gcd 6432 132) + 11 = 23.\nProof.\nAdmitted." }, { "theorem_id": 363, "title": "mathd_numbertheory_451", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-451 = `(FINITE {n:num | 2010 <= n /\\ n <= 2019 /\\ ?m. (CARD {p | p divides m} = 4 /\\ nsum {p | p divides m} (\\p. p) = n)})\n==>\nnsum {n:num | 2010 <= n /\\ n <= 2019 /\\ ?m. (CARD {p | p divides m} = 4 /\\ nsum {p | p divides m} (\\p. p) = n)} (\\k. k) = 2016`;;\n" }, { "theorem_id": 363, "title": "mathd_numbertheory_451", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_451 imports \n Complex_Main \n \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_451:\n shows \"(\\ k \\ {n ::nat. 2010 \\ n \\ n \\ 2019 \n \\ (\\ m. (card {i. i dvd m} = 4) \n \\ (\\ p \\ {i. i dvd m}. p) = n)}. k) = 2016\"\n by sorry\n\nend" }, { "theorem_id": 363, "title": "mathd_numbertheory_451", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_451\n (S : Finset ℕ)\n (h₀ : ∀ (n : ℕ), n ∈ S ↔ 2010 ≤ n ∧ n ≤ 2019 ∧ ∃ m, ((Nat.divisors m).card = 4 ∧ ∑ p ∈ (Nat.divisors m), p = n)) :\n ∑ k ∈ S, k = 2016 := by sorry" }, { "theorem_id": 363, "title": "mathd_numbertheory_451", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\nRequire Import List.\nRequire Import ZArith.\nRequire Import SetoidList.\n\nDefinition divisors n := filter (fun k => n mod k =? 0) (seq 1 n).\n\nTheorem mathd_numbertheory_451:\n forall (l: list nat),\n NoDup l ->\n (forall n, In n l <->\n 2010 <= n /\\ n <= 2019 /\\\n exists m, length (divisors m) = 4 /\\\n list_sum (divisors m) = n) ->\n list_sum l = 2016.\nProof.\n" }, { "theorem_id": 364, "title": "mathd_numbertheory_458", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-458 = `!n:num.\n (n MOD 8 = 7)\n==>\n (n MOD 4 = 3)\n`;;\n" }, { "theorem_id": 364, "title": "mathd_numbertheory_458", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_458 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_458:\n fixes n :: nat\n assumes h0 : \"n mod 8 = (7::nat)\"\n shows \"n mod 4 = 3\"\n by sorry\n\nend" }, { "theorem_id": 364, "title": "mathd_numbertheory_458", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_458 (n : ℕ) (h₀ : n % 8 = 7) : n % 4 = 3 := by sorry" }, { "theorem_id": 364, "title": "mathd_numbertheory_458", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_458:\n forall n : nat,\n n mod 8 = 7 -> n mod 4 = 3.\nProof.\nAdmitted." }, { "theorem_id": 365, "title": "mathd_numbertheory_466", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-466 = `(nsum (0..(11-1)) (\\k. k)) MOD 9 = 1`;;\n" }, { "theorem_id": 365, "title": "mathd_numbertheory_466", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_466 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_466:\n \"(\\ k< 11. k) mod 9 = (1::nat)\"\n by sorry\n\nend " }, { "theorem_id": 365, "title": "mathd_numbertheory_466", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_466 : (∑ k ∈ Finset.range 11, k) % 9 = 1 := by sorry" }, { "theorem_id": 365, "title": "mathd_numbertheory_466", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_466 : \n (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10) mod 9 = 1.\nProof.\nAdmitted." }, { "theorem_id": 366, "title": "mathd_numbertheory_48", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-48 = `!b:num.\n (0 < b) /\\\n (3 * b EXP 2 + 2 * b + 1 = 57)\n==>\n (b = 4)\n`;;\n" }, { "theorem_id": 366, "title": "mathd_numbertheory_48", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_48 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_48:\n fixes b :: nat\n assumes h0 : \"0\n 3 * b^2 + 2 * b + 1 = 57 -> \n b = 4.\nProof.\nAdmitted." }, { "theorem_id": 367, "title": "mathd_numbertheory_495", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-495 = `!a:num b:num.\n (0 < a /\\ 0 < b) /\\\n (a MOD 10 = 2) /\\\n (b MOD 10 = 4) /\\\n (gcd (a, b) = 6)\n==>\n (108 <= lcm (a, b))\n`;;\n" }, { "theorem_id": 367, "title": "mathd_numbertheory_495", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_495 imports Complex_Main\nbegin\n\ntheorem mathd_numbertheory_495:\n fixes a b :: nat\n assumes \"0 < a \\ 0 < b\"\n and \"a mod 10 = 2\"\n and \"b mod 10 = 4\"\n and \"gcd a b = 6\"\n shows \"108 \\ lcm a b\"\n by sorry\n\nend" }, { "theorem_id": 367, "title": "mathd_numbertheory_495", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_495\n (a b : ℕ)\n (h₀ : 0 < a ∧ 0 < b)\n (h₁ : a % 10 = 2)\n (h₂ : b % 10 = 4)\n (h₃ : Nat.gcd a b = 6) :\n 108 ≤ Nat.lcm a b := by sorry" }, { "theorem_id": 367, "title": "mathd_numbertheory_495", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\nRequire Import ZArith.\n\nTheorem mathd_numbertheory_495 :\n forall (a b : nat),\n (0 < a /\\ 0 < b) ->\n (a mod 10 = 2) ->\n (b mod 10 = 4) ->\n (Nat.gcd a b = 6) ->\n 108 <= Nat.lcm a b.\nProof.\nAdmitted." }, { "theorem_id": 368, "title": "mathd_numbertheory_530", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-530 = `!n:num k:num.\n (n > 0 /\\ k > 0) /\\\n (&n / &k < &6) /\\\n (&5 < &n / &k)\n==>\n &22 <= &(lcm(n, k)) / &(gcd(n, k))\n`;;\n" }, { "theorem_id": 368, "title": "mathd_numbertheory_530", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_530 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_530:\n fixes n k :: nat\n assumes \"n / k < 6\"\n and \"5 < n / k\" \n shows \"22 \\ (lcm n k) / (gcd n k)\"\n by sorry\n\nend " }, { "theorem_id": 368, "title": "mathd_numbertheory_530", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_530 (n k : ℕ) (h₀ : 0 < n ∧ 0 < k) (h₀ : (n : ℝ) / k < 6)\n (h₁ : (5 : ℝ) < n / k) : 22 ≤ Nat.lcm n k / Nat.gcd n k := by sorry" }, { "theorem_id": 368, "title": "mathd_numbertheory_530", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Arith.\nRequire Import Nat.\nRequire Import ZArith.\n\nOpen Scope R_scope.\n\nTheorem mathd_numbertheory_530 :\n forall (n k : nat),\n (0 < n)%nat ->\n (0 < k)%nat ->\n (IZR (Z_of_nat n) / IZR (Z_of_nat k) < 6)%R ->\n (5 < IZR (Z_of_nat n) / IZR (Z_of_nat k))%R ->\n (22 <= Nat.div (Nat.lcm n k) (Nat.gcd n k))%nat.\n\nProof.\n" }, { "theorem_id": 369, "title": "mathd_numbertheory_551", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-551 = `1529 MOD 6 = 5`;;\n" }, { "theorem_id": 369, "title": "mathd_numbertheory_551", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_551 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_551 :\n \"1529 mod 6 = (5::nat)\"\n by sorry\n\nend " }, { "theorem_id": 369, "title": "mathd_numbertheory_551", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_551 :\n 1529 % 6 = 5 := by sorry" }, { "theorem_id": 369, "title": "mathd_numbertheory_551", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\n\nTheorem mathd_numbertheory_551 :\n 1529 mod 6 = 5.\nProof.\nAdmitted.\n" }, { "theorem_id": 370, "title": "mathd_numbertheory_552", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-552 = `!f:num->num g:num->num h:num->num.\n (!x. (x > 0) ==> (f x = 12 * x + 7)) /\\\n (!x. (x > 0) ==> (g x = 5 * x + 2)) /\\\n (!x. (x > 0) ==> (h x = gcd (f x, g x))) /\\\n (FINITE {h x | x | x > 0})\n==>\n (nsum {h x | x | x > 0} (\\k. k) = 12)\n`;;\n" }, { "theorem_id": 370, "title": "mathd_numbertheory_552", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_552 imports Complex_Main\nbegin\n\ntheorem mathd_numbertheory_552:\n fixes f g h :: \"nat \\ nat\"\n assumes \"\\ x>0. f x = 12 * x + 7\"\n and \"\\ x>0. g x = 5 * x + 2\"\n and \"\\ x>0. h x = gcd (f x) (g x)\"\n shows \"(\\ k \\ range h. k) = 12\"\n by sorry\n\nend" }, { "theorem_id": 370, "title": "mathd_numbertheory_552", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_552\n (f g h : ℕ+ → ℕ)\n (h₀ : ∀ x, f x = 12 * x + 7)\n (h₁ : ∀ x, g x = 5 * x + 2)\n (h₂ : ∀ x, h x = Nat.gcd (f x) (g x))\n (h₃ : Fintype (Set.range h)) :\n ∑ k ∈ (Set.range h).toFinset, k = 12 := by sorry" }, { "theorem_id": 370, "title": "mathd_numbertheory_552", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\nRequire Import Coq.Lists.List.\nRequire Import Coq.Init.Nat.\nRequire Import Coq.Bool.Bool.\n\nImport ListNotations.\n\nTheorem mathd_numbertheory_552 :\n forall (f g h : nat -> nat),\n (forall x, x > 0 -> f x = 12 * x + 7) ->\n (forall x, x > 0 -> g x = 5 * x + 2) ->\n (forall x, x > 0 -> h x = Nat.gcd (f x) (g x)) ->\n \n exists l : list nat,\n NoDup l /\\\n (forall y, In y l <-> exists x, x > 0 /\\ h x = y) /\\\n List.fold_left Nat.add l 0 = 12.\n\nProof.\nAdmitted.\n" }, { "theorem_id": 371, "title": "mathd_numbertheory_618", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-618 = `!n:num p:num->num.\n (!x. &(p x) = int_of_num (x EXP 2) - &x + &41) /\\\n (1 < gcd (p (n), p (n+1)))\n==>\n (41 <= n)\n`;;\n" }, { "theorem_id": 371, "title": "mathd_numbertheory_618", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_618 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_618:\n fixes n :: nat\n and p :: \"nat \\ nat\"\n assumes \"\\ x. p x = x^2 - x + 41\"\n and \"1 < gcd (p n) (p (n+1))\"\n shows \"41 \\ n\"\n by sorry\n\nend" }, { "theorem_id": 371, "title": "mathd_numbertheory_618", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_618\n (n : ℕ)\n (hn : n > 0)\n (p : ℕ → ℕ)\n (h₀ : ∀ x, p x = x^2 - x + 41)\n (h₁ : 1 < Nat.gcd (p n) (p (n+1))) :\n 41 ≤ n := by sorry" }, { "theorem_id": 371, "title": "mathd_numbertheory_618", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\nRequire Import Coq.ZArith.BinInt.\n\nTheorem mathd_numbertheory_618:\n forall n : nat,\n forall p : nat -> nat,\n (forall x, p x = x*x - x + 41) ->\n 0 < n ->\n 1 < Nat.gcd (p n) (p (S n)) ->\n 41 <= n.\nProof.\nAdmitted.\n" }, { "theorem_id": 372, "title": "mathd_numbertheory_629", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-629 = `(18 IN {t:num | (t > 0) /\\ ((lcm (12, t)) EXP 3 = (12 * t) EXP 2)}) /\\ (!t:num. (t IN {t:num | (t > 0) /\\ ((lcm (12, t)) EXP 3 = (12 * t) EXP 2)}) ==> (t >= 18))`;;\n" }, { "theorem_id": 372, "title": "mathd_numbertheory_629", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_629 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_629 :\n \"(LEAST t::nat. (lcm 12 t)^3 = (12 * t)^2) = 18\"\n by sorry\n\nend " }, { "theorem_id": 372, "title": "mathd_numbertheory_629", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_629 : IsLeast { t : ℕ | 0 < t ∧ Nat.lcm 12 t ^ 3 = (12 * t) ^ 2 } 18 := by sorry" }, { "theorem_id": 372, "title": "mathd_numbertheory_629", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\nRequire Import Nat.\n\nDefinition Least (P:nat->Prop) n :=\n P n /\\ forall m, P m -> n <= m.\n\nTheorem mathd_numbertheory_629:\n Least (fun t => t > 0 /\\ (Nat.lcm 12 t)^3 = (12 * t)^2) 18.\nProof.\nAdmitted.\n" }, { "theorem_id": 373, "title": "mathd_numbertheory_64", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-64 = `\n 39 IN {x:num | ~(x = 0) /\\ ((30 * x == 42) (mod 47))} /\\\n (!x:num.\n (x IN {x:num | ~(x = 0) /\\ ((30 * x == 42) (mod 47))})\n ==>\n (x >= 39)\n )\n`;;\n" }, { "theorem_id": 373, "title": "mathd_numbertheory_64", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_64 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_64 :\n \"(LEAST x ::nat. [30 * x = 42] (mod 47)) = 39\"\n by sorry\n\nend " }, { "theorem_id": 373, "title": "mathd_numbertheory_64", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_64 : IsLeast { x : ℕ | 30 * x ≡ 42 [MOD 47] } 39 := by sorry" }, { "theorem_id": 373, "title": "mathd_numbertheory_64", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Init.Nat.\n\n\n\nTheorem mathd_numbertheory_64 :\n (30 * 39) mod 47 = 42 /\\\n (forall x, (30 * x) mod 47 = 42 -> 39 <= x).\n\nProof.\n" }, { "theorem_id": 374, "title": "mathd_numbertheory_640", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-640 = `(91145 + 91146 + 91147 + 91148) MOD 4 = 2`;;\n" }, { "theorem_id": 374, "title": "mathd_numbertheory_640", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_640 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_640:\n \"(91145+91146+91147+91148) mod 4 = (2::nat)\"\n by sorry\n\nend" }, { "theorem_id": 374, "title": "mathd_numbertheory_640", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_640 : (91145 + 91146 + 91147 + 91148) % 4 = 2 := by sorry" }, { "theorem_id": 374, "title": "mathd_numbertheory_640", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\n\nTheorem mathd_numbertheory_640 :\n (91145 + 91146 + 91147 + 91148) mod 4 = 2.\nProof.\nAdmitted." }, { "theorem_id": 375, "title": "mathd_numbertheory_66", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-66 = `194 MOD 11 = 7`;;\n" }, { "theorem_id": 375, "title": "mathd_numbertheory_66", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_66 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_66:\n \"194 mod 11 = (7::nat)\"\n by sorry\n\nend " }, { "theorem_id": 375, "title": "mathd_numbertheory_66", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_66 :\n 194 % 11 = 7 := by sorry" }, { "theorem_id": 375, "title": "mathd_numbertheory_66", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_66 : 194 mod 11 = 7.\nProof.\nAdmitted." }, { "theorem_id": 376, "title": "mathd_numbertheory_668", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-668 = `!l:int r:int.\n &0 <= l /\\ l < &7 /\\\n &0 <= r /\\ r < &7 /\\\n (l * &(2 + 3) == &1) (mod &7) /\\\n ?x:int y:int. (\n &0 <= x /\\ x < &7 /\\\n &0 <= y /\\ y < &7 /\\\n (x * &2 == &1) (mod &7) /\\\n (y * &3 == &1) (mod &7) /\\\n (r == x + y) (mod &7)\n )\n==>\n (l - r == &1) (mod &7)\n`;;\n" }, { "theorem_id": 376, "title": "mathd_numbertheory_668", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_668 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_668:\n fixes l r::int\n assumes \"0\\l\" \"l<7\" \"0\\r\" \"r<7\"\n and \"[l * (2 + 3) = 1] (mod 7)\" \n and \"\\x y::int. [x*2=1] (mod 7) \\ [x*3=1] (mod 7) \\ r=x+y\"\n shows \"l - r = 1\"\n by sorry\n\nend " }, { "theorem_id": 376, "title": "mathd_numbertheory_668", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_668 (l r : ZMod 7) (h₀ : l = (2 + 3)⁻¹) (h₁ : r = 2⁻¹ + 3⁻¹) :\n l - r = 1 := by sorry" }, { "theorem_id": 376, "title": "mathd_numbertheory_668", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem mathd_numbertheory_668 (l r : Z) : \n (0 <= l < 7)%Z -> (0 <= r < 7)%Z ->\n (l * (2 + 3) mod 7 = 1)%Z ->\n (exists a b, (0 <= a < 7)%Z /\\ (0 <= b < 7)%Z /\\\n (a * 2 mod 7 = 1)%Z /\\ (b * 3 mod 7 = 1)%Z /\\\n (r = (a + b) mod 7)%Z) ->\n l - r = 1.\nProof.\nAdmitted." }, { "theorem_id": 377, "title": "mathd_numbertheory_690", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-690 = `\n (314 IN {a:num | ((a > 0) /\\ ((a == 2) (mod 3)) /\\ ((a == 4) (mod 5)) /\\ ((a == 6) (mod 7)) /\\ ((a == 8) (mod 9)))}) /\\\n (!a:num.\n (a IN {a:num | ((a > 0) /\\ ((a == 2) (mod 3)) /\\ ((a == 4) (mod 5)) /\\ ((a == 6) (mod 7)) /\\ ((a == 8) (mod 9)))})\n ==>\n (a >= 314)\n )\n`;;\n" }, { "theorem_id": 377, "title": "mathd_numbertheory_690", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_690 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_690 :\n \"(LEAST a ::nat. [a = 2] (mod 3) \\ [a = 4] (mod 5) \n \\ [a = 6] (mod 7) \\ [a = 8] (mod 9)) = 314\"\n by sorry\n\nend " }, { "theorem_id": 377, "title": "mathd_numbertheory_690", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_690 :\n IsLeast { a : ℕ | 0 < a ∧ a ≡ 2 [MOD 3] ∧ a ≡ 4 [MOD 5] ∧ a ≡ 6 [MOD 7] ∧ a ≡ 8 [MOD 9] } 314 := by sorry" }, { "theorem_id": 377, "title": "mathd_numbertheory_690", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Arith.Arith.\n\nTheorem mathd_numbertheory_690 :\n 314 mod 3 = 2 /\\\n 314 mod 5 = 4 /\\\n 314 mod 7 = 6 /\\\n 314 mod 9 = 8 /\\\n (forall n : nat,\n n mod 3 = 2 /\\\n n mod 5 = 4 /\\\n n mod 7 = 6 /\\\n n mod 9 = 8 ->\n 314 <= n).\n\nProof.\n" }, { "theorem_id": 378, "title": "mathd_numbertheory_709", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-709 = `!n:num.\n (n > 0) /\\\n (CARD {k | k divides (2 * n)} = 28) /\\\n (CARD {k | k divides (3 * n)} = 30)\n==>\n CARD {k | k divides (6 * n)} = 35\n`;;\n" }, { "theorem_id": 378, "title": "mathd_numbertheory_709", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_709 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_709:\n fixes n :: nat\n assumes \"n>0\" \n and \"card ({k. k dvd (2*n)}) = 28\"\n and \"card ({k. k dvd (3*n)}) = 30\" \n shows \"card ({k. k dvd (6*n)}) = 35\"\n by sorry\n\nend " }, { "theorem_id": 378, "title": "mathd_numbertheory_709", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_709 (n : ℕ) (h₀ : 0 < n) (h₁ : Finset.card (Nat.divisors (2 * n)) = 28)\n (h₂ : Finset.card (Nat.divisors (3 * n)) = 30) : Finset.card (Nat.divisors (6 * n)) = 35 := by sorry" }, { "theorem_id": 378, "title": "mathd_numbertheory_709", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Coq.Init.Nat.\nRequire Import Coq.Lists.List.\nRequire Import Coq.Arith.EqNat.\nRequire Import Coq.Arith.PeanoNat.\nImport ListNotations.\n\nFixpoint divisors (n : nat) : list nat :=\n if n =? 0 then []\n else filter (fun d => Nat.modulo n d =? 0) (seq 1 n).\n\nTheorem mathd_numbertheory_709\n (n : nat)\n (h₀ : n > 0)\n (h₁ : length (divisors (2 * n)) = 28)\n (h₂ : length (divisors (3 * n)) = 30) :\n length (divisors (6 * n)) = 35.\n\nProof.\n" }, { "theorem_id": 379, "title": "mathd_numbertheory_739", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-739 = `(FACT 9) MOD 10 = 0`;;\n" }, { "theorem_id": 379, "title": "mathd_numbertheory_739", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_739 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_739:\n \"(fact 9) mod 10 = (0::nat)\"\n by sorry\n\nend" }, { "theorem_id": 379, "title": "mathd_numbertheory_739", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_739 : 9! % 10 = 0 := by sorry" }, { "theorem_id": 379, "title": "mathd_numbertheory_739", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\nRequire Import Nat.\n\nTheorem mathd_numbertheory_739:\n (fact 9) mod 10 = 0.\nProof.\nAdmitted." }, { "theorem_id": 380, "title": "mathd_numbertheory_81", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-81 = `71 MOD 3 = 2`;;\n" }, { "theorem_id": 380, "title": "mathd_numbertheory_81", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_81 imports\n Complex_Main\nbegin\n\ntheorem mathd_numbertheory_81:\n \"71 mod 3 = (2::nat)\"\n by sorry\n\nend" }, { "theorem_id": 380, "title": "mathd_numbertheory_81", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_81 : 71 % 3 = 2 := by sorry" }, { "theorem_id": 380, "title": "mathd_numbertheory_81", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\n\nTheorem mathd_numbertheory_81 : \n 71 mod 3 = 2.\nProof.\nAdmitted." }, { "theorem_id": 381, "title": "mathd_numbertheory_84", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-84 = `floor (&9 / &160 * &100) = &5`;;\n" }, { "theorem_id": 381, "title": "mathd_numbertheory_84", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_84 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_numbertheory_84:\n \"floor ((9::real) / 160 * 100) = (5::int)\"\n by sorry\n\nend" }, { "theorem_id": 381, "title": "mathd_numbertheory_84", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_84 : Int.floor ((9 : ℝ) / 160 * 100) = 5 := by sorry" }, { "theorem_id": 381, "title": "mathd_numbertheory_84", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Reals.\nRequire Import Coquelicot.Coquelicot.\n\nOpen Scope R_scope.\n\nTheorem mathd_numbertheory_84 :\n floor ((9 / 160) * 100) = 5%Z.\n\nProof.\n" }, { "theorem_id": 382, "title": "mathd_numbertheory_85", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-85 = `1 * 3 EXP 3 + 2 * 3 EXP 2 + 2*3 + 2 = 53`;;\n" }, { "theorem_id": 382, "title": "mathd_numbertheory_85", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_85 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem mathd_numbertheory_85:\n \"1 * 3^3 + 2 * 3^2 + 2*3 + 2 = (53::nat)\"\n by sorry\n\nend " }, { "theorem_id": 382, "title": "mathd_numbertheory_85", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_85 :\n 1 * 3^3 + 2 * 3^2 + 2*3 + 2 = 53 := by sorry" }, { "theorem_id": 382, "title": "mathd_numbertheory_85", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_85 :\n 1 * 3^3 + 2 * 3^2 + 2 * 3 + 2 = 53.\nProof.\nAdmitted." }, { "theorem_id": 383, "title": "mathd_numbertheory_92", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let mathd-numbertheory-92 = `!n:num.\n ((5 * n) MOD 17 = 8)\n==>\n (n MOD 17 = 5)\n`;;\n" }, { "theorem_id": 383, "title": "mathd_numbertheory_92", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory mathd_numbertheory_92 imports\nComplex_Main\n\nbegin\n\ntheorem mathd_numbertheory_92:\n fixes n :: nat\n assumes h0 : \"(5 * n) mod 17 = 8\"\n shows \"n mod 17 = 5\"\n by sorry\n\nend" }, { "theorem_id": 383, "title": "mathd_numbertheory_92", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_92 (n : ℕ) (h₀ : 5 * n % 17 = 8) : n % 17 = 5 := by sorry" }, { "theorem_id": 383, "title": "mathd_numbertheory_92", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Arith.\n\nTheorem mathd_numbertheory_92:\n forall n : nat, \n (5 * n mod 17 = 8) -> \n (n mod 17 = 5).\nProof.\nAdmitted." }, { "theorem_id": 384, "title": "mathd_numbertheory_99", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let mathd-numbertheory-99 = `!n:num. ((2 * n) MOD 47 = 15) ==> n MOD 47 = 31`;;\n" }, { "theorem_id": 384, "title": "mathd_numbertheory_99", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory mathd_numbertheory_99 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem mathd_numbertheory_99:\n fixes n :: nat\n assumes \"(2 * n) mod 47 = 15\" \n shows \"n mod 47 = 31\"\n by sorry\n\nend" }, { "theorem_id": 384, "title": "mathd_numbertheory_99", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem mathd_numbertheory_99\n (n : ℕ)\n (h₀ : (2 * n) % 47 = 15) :\n n % 47 = 31 := by sorry" }, { "theorem_id": 384, "title": "mathd_numbertheory_99", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import Nat.\nRequire Import ZArith.\n\nTheorem mathd_numbertheory_99:\n forall n : nat,\n (2 * n) mod 47 = 15 ->\n n mod 47 = 31.\nProof.\nAdmitted." }, { "theorem_id": 385, "title": "numbertheory_2dvd4expn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let numbertheory-2dvd4expn = `!n:num. ~(n = 0) ==> 2 divides 4 EXP n`;;\n" }, { "theorem_id": 385, "title": "numbertheory_2dvd4expn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory numbertheory_2dvd4expn imports\nComplex_Main\n\nbegin\n\ntheorem numbertheory_2dvd4expn:\n fixes n :: nat\n assumes h0 : \"n \\ 0\"\n shows \"(2::nat) dvd 4^n\"\n by sorry\n\nend" }, { "theorem_id": 385, "title": "numbertheory_2dvd4expn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem numbertheory_2dvd4expn (n : ℕ) (h₀ : n ≠ 0) : 2 ∣ 4 ^ n := by sorry" }, { "theorem_id": 385, "title": "numbertheory_2dvd4expn", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import Nat.\nRequire Import Arith.\n\nTheorem numbertheory_2dvd4expn :\n forall n : nat,\n n <> 0 ->\n Nat.divide 2 (4^n).\n\nProof.\n" }, { "theorem_id": 386, "title": "numbertheory_aoddbdiv4asqpbsqmod8eq1", "source": "minif2f", "tier": "b", "split": "test", "prover": "hol-light", "content": "let numbertheory-aoddbdiv4asqpbsqmod8eq1 = `!a:int b:num.\n (ODD (num_of_int (abs a))) /\\\n (4 divides b)\n==>\n num_of_int (a pow 2 + &b pow 2) MOD 8 = 1\n`;;\n" }, { "theorem_id": 386, "title": "numbertheory_aoddbdiv4asqpbsqmod8eq1", "source": "minif2f", "tier": "b", "split": "test", "prover": "isabelle", "content": "theory numbertheory_aoddbdiv4asqpbsqmod8eq1 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem numbertheory_aoddbdiv4asqpbsqmod8eq1:\n fixes a :: int and b :: nat\n assumes \"odd a\"\n and \"4 dvd b\" \n shows \"(a^2 + b^2) mod 8 = 1 \"\n by sorry\n\nend" }, { "theorem_id": 386, "title": "numbertheory_aoddbdiv4asqpbsqmod8eq1", "source": "minif2f", "tier": "b", "split": "test", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem numbertheory_aoddbdiv4asqpbsqmod8eq1\n (a : ℤ)\n (b : ℤ)\n (h₀ : Odd a)\n (h₁ : 4 ∣ b)\n (h₂ : b >= 0) :\n (a^2 + b^2) % 8 = 1 := by sorry" }, { "theorem_id": 386, "title": "numbertheory_aoddbdiv4asqpbsqmod8eq1", "source": "minif2f", "tier": "b", "split": "test", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Nat.\nRequire Import Lia.\n\nOpen Scope Z_scope.\n\nTheorem numbertheory_aoddbdiv4asqpbsqmod8eq1 :\n forall (a : Z) (b : nat),\n Z.odd a = true ->\n (exists k : nat, b = 4 * k)%nat ->\n (a * a + Z.of_nat (b * b)) mod 8 = 1.\n\nProof.\n" }, { "theorem_id": 387, "title": "numbertheory_prmdvsneqnsqmodpeq0", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let numbertheory-prmdvsneqnsqmodpeq0 = `!n:int p:num.\n (prime p)\n==>\n (&p divides n)\n <=>\n (num_of_int(n pow 2) MOD p = 0)\n`;;\n" }, { "theorem_id": 387, "title": "numbertheory_prmdvsneqnsqmodpeq0", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory numbertheory_prmdvsneqnsqmodpeq0 \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\nbegin\n\ntheorem numbertheory_prmdvsneqnsqmodpeq0:\n fixes n :: int\n and p :: nat\n assumes \"prime p\" \n shows \"p dvd n \\ (n^2) mod p = 0\"\n by sorry\n\nend " }, { "theorem_id": 387, "title": "numbertheory_prmdvsneqnsqmodpeq0", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem numbertheory_prmdvsneqnsqmodpeq0 (n : ℤ) (p : ℕ) (h₀ : Nat.Prime p) :\n ↑p ∣ n ↔ n ^ 2 % p = 0 := by sorry" }, { "theorem_id": 387, "title": "numbertheory_prmdvsneqnsqmodpeq0", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import ZArith.\nRequire Import Znumtheory.\n\nTheorem numbertheory_prmdvsneqnsqmodpeq0:\n forall (n : Z) (p : positive),\n prime (Z.pos p) -> (Z.divide (Z.pos p) n <-> (n * n) mod (Z.pos p) = 0%Z).\n\nProof.\n" }, { "theorem_id": 388, "title": "numbertheory_sqmod3in01d", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let numbertheory-sqmod3in01d = `!a:int.\n ((num_of_int(a pow 2) MOD 3) = 0) \\/\n ((num_of_int(a pow 2) MOD 3) = 1)\n`;;\n" }, { "theorem_id": 388, "title": "numbertheory_sqmod3in01d", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory numbertheory_sqmod3in01d imports\n Complex_Main\nbegin\n\ntheorem numbertheory_sqmod3in01d:\n fixes a :: int\n shows \"a^2 mod 3 = 0 \\ a^2 mod 3 = 1\"\n by sorry\n\nend" }, { "theorem_id": 388, "title": "numbertheory_sqmod3in01d", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem numbertheory_sqmod3in01d (a : ℤ) : a ^ 2 % 3 = 0 ∨ a ^ 2 % 3 = 1 := by sorry" }, { "theorem_id": 388, "title": "numbertheory_sqmod3in01d", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem numbertheory_sqmod3in01d (a : Z) :\n (a^2 mod 3 = 0) \\/ (a^2 mod 3 = 1).\nProof.\nAdmitted." }, { "theorem_id": 389, "title": "numbertheory_sqmod4in01d", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let numbertheory-sqmod4in01d = `!a:int.\n ((num_of_int(a pow 2) MOD 4) = 0) \\/\n ((num_of_int(a pow 2) MOD 4) = 1)\n`;;\n" }, { "theorem_id": 389, "title": "numbertheory_sqmod4in01d", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory numbertheory_sqmod4in01d imports\n Complex_Main\nbegin\n\ntheorem numbertheory_sqmod4in01d:\n fixes a :: int\n shows \"(a^2 mod 4 = 0) \\ (a^2 mod 4 = 1)\"\n by sorry\n\nend" }, { "theorem_id": 389, "title": "numbertheory_sqmod4in01d", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem numbertheory_sqmod4in01d (a : ℤ) : a ^ 2 % 4 = 0 ∨ a ^ 2 % 4 = 1 := by sorry" }, { "theorem_id": 389, "title": "numbertheory_sqmod4in01d", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import ZArith.\nOpen Scope Z_scope.\n\nTheorem numbertheory_sqmod4in01d :\n forall a : Z, (a^2 mod 4 = 0) \\/ (a^2 mod 4 = 1).\nProof.\nAdmitted." }, { "theorem_id": 390, "title": "numbertheory_xsqpysqintdenomeq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "hol-light", "content": "let numbertheory-xsqpysqintdenomeq = `!x:real y:real\n (rational x /\\ rational y) /\\\n integer(x pow 2 + y pow 2)\n==>\n denominator x = denominator y\n`;;\n" }, { "theorem_id": 390, "title": "numbertheory_xsqpysqintdenomeq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "isabelle", "content": "theory numbertheory_xsqpysqintdenomeq \n imports Complex_Main \"HOL-Computational_Algebra.Computational_Algebra\"\n \"HOL-Number_Theory.Number_Theory\"\nbegin\n\ntheorem numbertheory_xsqpysqintdenomeq:\n fixes x y :: rat\n assumes \"snd (quotient_of (x^2 + y^2)) = 1\"\n shows \"snd (quotient_of x) = snd (quotient_of y)\"\n by sorry\n\nend " }, { "theorem_id": 390, "title": "numbertheory_xsqpysqintdenomeq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "lean4", "content": "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\ntheorem numbertheory_xsqpysqintdenomeq (x y : ℚ) (h₀ : (x ^ 2 + y ^ 2).den = 1) : x.den = y.den := by sorry" }, { "theorem_id": 390, "title": "numbertheory_xsqpysqintdenomeq", "source": "minif2f", "tier": "b", "split": "valid", "prover": "rocq", "content": "Require Import QArith.\nRequire Import Reals.\n\nTheorem numbertheory_xsqpysqintdenomeq:\n forall (x y : Q),\n Qden (x * x + y * y) = 1%positive ->\n Qden x = Qden y.\nProof.\nAdmitted." } ]