diff --git a/README.md b/README.md index 411eccc..e4a7d76 100644 --- a/README.md +++ b/README.md @@ -514,7 +514,7 @@ stack/ │ ├── scripts/ Code generators, bootstrap, supply chain tools │ ├── hooks/ Git hooks (tracked, core.hooksPath = dev/hooks) │ ├── seeds/ Reference data (BCDA samples + v3 crosswalk, CMS docs) -│ ├── vendor/ Sparse pins of upstream (CMSgov/bcda-app, bcda.cms.gov) — MANIFEST.toml +│ ├── vendor/ Sparse pins: MANIFEST.toml (BCDA), mathematics_in_lean.toml (the textbook) │ └── pipelines/ CI-agnostic pipeline specs ├── tests/ 14,010 tests at 99% coverage ├── notebooks/ Marimo notebooks diff --git a/dev/vendor/mathematics_in_lean.toml b/dev/vendor/mathematics_in_lean.toml new file mode 100644 index 0000000..ce805c9 --- /dev/null +++ b/dev/vendor/mathematics_in_lean.toml @@ -0,0 +1,402 @@ +# Mathematics in Lean — pin of leanprover-community/mathematics_in_lean +# master @ cff01285931648054c4fe6817baed0ccd45c0372 +# Apache-2.0. Not part of the BCDA vendor manifest: that list is the +# CMS sources the bcda screen checks. Mathlib is a lake dependency, not a copy. + +[[source]] +name = "mathematics_in_lean" +kind = "github" +repo = "leanprover-community/mathematics_in_lean" +ref = "master" +commit = "cff01285931648054c4fe6817baed0ccd45c0372" +license = "LICENSE" +files = [ + ".gitignore", + "LICENSE", + "MIL.lean", + "MIL/C01_Introduction/S01_Getting_Started.lean", + "MIL/C01_Introduction/S02_Overview.lean", + "MIL/C01_Introduction/solutions/Solutions_S01_Getting_Started.lean", + "MIL/C01_Introduction/solutions/Solutions_S02_Overview.lean", + "MIL/C02_Basics/S01_Calculating.lean", + "MIL/C02_Basics/S02_Proving_Identities_in_Algebraic_Structures.lean", + "MIL/C02_Basics/S03_Using_Theorems_and_Lemmas.lean", + "MIL/C02_Basics/S04_More_on_Order_and_Divisibility.lean", + "MIL/C02_Basics/S05_Proving_Facts_about_Algebraic_Structures.lean", + "MIL/C02_Basics/solutions/Solutions_S01_Calculating.lean", + "MIL/C02_Basics/solutions/Solutions_S02_Proving_Identities_in_Algebraic_Structures.lean", + "MIL/C02_Basics/solutions/Solutions_S03_Using_Theorems_and_Lemmas.lean", + "MIL/C02_Basics/solutions/Solutions_S04_More_on_Order_and_Divisibility.lean", + "MIL/C02_Basics/solutions/Solutions_S05_Proving_Facts_about_Algebraic_Structures.lean", + "MIL/C03_Logic/S01_Implication_and_the_Universal_Quantifier.lean", + "MIL/C03_Logic/S02_The_Existential_Quantifier.lean", + "MIL/C03_Logic/S03_Negation.lean", + "MIL/C03_Logic/S04_Conjunction_and_Iff.lean", + "MIL/C03_Logic/S05_Disjunction.lean", + "MIL/C03_Logic/S06_Sequences_and_Convergence.lean", + "MIL/C03_Logic/solutions/Solutions_S01_Implication_and_the_Universal_Quantifier.lean", + "MIL/C03_Logic/solutions/Solutions_S02_The_Existential_Quantifier.lean", + "MIL/C03_Logic/solutions/Solutions_S03_Negation.lean", + "MIL/C03_Logic/solutions/Solutions_S04_Conjunction_and_Iff.lean", + "MIL/C03_Logic/solutions/Solutions_S05_Disjunction.lean", + "MIL/C03_Logic/solutions/Solutions_S06_Sequences_and_Convergence.lean", + "MIL/C04_Sets_and_Functions/S01_Sets.lean", + "MIL/C04_Sets_and_Functions/S02_Functions.lean", + "MIL/C04_Sets_and_Functions/S03_The_Schroeder_Bernstein_Theorem.lean", + "MIL/C04_Sets_and_Functions/solutions/Solutions_S01_Sets.lean", + "MIL/C04_Sets_and_Functions/solutions/Solutions_S02_Functions.lean", + "MIL/C04_Sets_and_Functions/solutions/Solutions_S03_The_Schroeder_Bernstein_Theorem.lean", + "MIL/C05_Elementary_Number_Theory/S01_Irrational_Roots.lean", + "MIL/C05_Elementary_Number_Theory/S02_Induction_and_Recursion.lean", + "MIL/C05_Elementary_Number_Theory/S03_Infinitely_Many_Primes.lean", + "MIL/C05_Elementary_Number_Theory/S04_More_Induction.lean", + "MIL/C05_Elementary_Number_Theory/solutions/Solutions_S01_Irrational_Roots.lean", + "MIL/C05_Elementary_Number_Theory/solutions/Solutions_S02_Induction_and_Recursion.lean", + "MIL/C05_Elementary_Number_Theory/solutions/Solutions_S03_Infinitely_Many_Primes.lean", + "MIL/C05_Elementary_Number_Theory/solutions/Solutions_S04_More_Induction.lean", + "MIL/C06_Discrete_Mathematics/S01_Finsets_and_Fintypes.lean", + "MIL/C06_Discrete_Mathematics/S02_Counting_Arguments.lean", + "MIL/C06_Discrete_Mathematics/S03_Inductive_Structures.lean", + "MIL/C06_Discrete_Mathematics/solutions/Solutions_S01_Finsets_and_Fintypes.lean", + "MIL/C06_Discrete_Mathematics/solutions/Solutions_S02_Counting_Arguments.lean", + "MIL/C06_Discrete_Mathematics/solutions/Solutions_S03_Inductive_Structures.lean", + "MIL/C07_Structures/S01_Structures.lean", + "MIL/C07_Structures/S02_Algebraic_Structures.lean", + "MIL/C07_Structures/S03_Building_the_Gaussian_Integers.lean", + "MIL/C07_Structures/solutions/Solutions_S01_Structures.lean", + "MIL/C07_Structures/solutions/Solutions_S02_Algebraic_Structures.lean", + "MIL/C07_Structures/solutions/Solutions_S03_Building_the_Gaussian_Integers.lean", + "MIL/C08_Hierarchies/S01_Basics.lean", + "MIL/C08_Hierarchies/S02_Morphisms.lean", + "MIL/C08_Hierarchies/S03_Subobjects.lean", + "MIL/C08_Hierarchies/solutions/Solutions_S01_Basics.lean", + "MIL/C08_Hierarchies/solutions/Solutions_S02_Morphisms.lean", + "MIL/C08_Hierarchies/solutions/Solutions_S03_Subobjects.lean", + "MIL/C09_Groups_and_Rings/S01_Groups.lean", + "MIL/C09_Groups_and_Rings/S02_Rings.lean", + "MIL/C09_Groups_and_Rings/solutions/Solutions_S01_Groups.lean", + "MIL/C09_Groups_and_Rings/solutions/Solutions_S02_Rings.lean", + "MIL/C10_Linear_Algebra/S01_Vector_Spaces.lean", + "MIL/C10_Linear_Algebra/S02_Subspaces.lean", + "MIL/C10_Linear_Algebra/S03_Endomorphisms.lean", + "MIL/C10_Linear_Algebra/S04_Bases.lean", + "MIL/C10_Linear_Algebra/solutions/Solutions_S01_Vector_Spaces.lean", + "MIL/C10_Linear_Algebra/solutions/Solutions_S02_Subspaces.lean", + "MIL/C10_Linear_Algebra/solutions/Solutions_S03_Endomorphisms.lean", + "MIL/C10_Linear_Algebra/solutions/Solutions_S04_Bases.lean", + "MIL/C11_Topology/S01_Filters.lean", + "MIL/C11_Topology/S02_Metric_Spaces.lean", + "MIL/C11_Topology/S03_Topological_Spaces.lean", + "MIL/C11_Topology/solutions/Solutions_S01_Filters.lean", + "MIL/C11_Topology/solutions/Solutions_S02_Metric_Spaces.lean", + "MIL/C11_Topology/solutions/Solutions_S03_Topological_Spaces.lean", + "MIL/C12_Differential_Calculus/S01_Elementary_Differential_Calculus.lean", + "MIL/C12_Differential_Calculus/S02_Differential_Calculus_in_Normed_Spaces.lean", + "MIL/C12_Differential_Calculus/solutions/Solutions_S01_Elementary_Differential_Calculus.lean", + "MIL/C12_Differential_Calculus/solutions/Solutions_S02_Differential_Calculus_in_Normed_Spaces.lean", + "MIL/C13_Integration_and_Measure_Theory/S01_Elementary_Integration.lean", + "MIL/C13_Integration_and_Measure_Theory/S02_Measure_Theory.lean", + "MIL/C13_Integration_and_Measure_Theory/S03_Integration.lean", + "MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S01_Elementary_Integration.lean", + "MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S02_Measure_Theory.lean", + "MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S03_Integration.lean", + "MIL/Common.lean", + "MIL_solutions.lean", + "README.md", + "html/.buildinfo", + "html/C01_Introduction.html", + "html/C02_Basics.html", + "html/C03_Logic.html", + "html/C04_Sets_and_Functions.html", + "html/C05_Elementary_Number_Theory.html", + "html/C06_Discrete_Mathematics.html", + "html/C07_Structures.html", + "html/C08_Hierarchies.html", + "html/C09_Groups_and_Rings.html", + "html/C10_Linear_Algebra.html", + "html/C11_Topology.html", + "html/C12_Differential_Calculus.html", + "html/C13_Integration_and_Measure_Theory.html", + "html/_images/schroeder_bernstein1.png", + "html/_images/schroeder_bernstein2.png", + "html/_images/schroeder_bernstein3.png", + "html/_sources/C01_Introduction.rst.txt", + "html/_sources/C02_Basics.rst.txt", + "html/_sources/C03_Logic.rst.txt", + "html/_sources/C04_Sets_and_Functions.rst.txt", + "html/_sources/C05_Elementary_Number_Theory.rst.txt", + "html/_sources/C06_Discrete_Mathematics.rst.txt", + "html/_sources/C07_Structures.rst.txt", + "html/_sources/C08_Hierarchies.rst.txt", + "html/_sources/C09_Groups_and_Rings.rst.txt", + "html/_sources/C10_Linear_Algebra.rst.txt", + "html/_sources/C11_Topology.rst.txt", + "html/_sources/C12_Differential_Calculus.rst.txt", + "html/_sources/C13_Integration_and_Measure_Theory.rst.txt", + "html/_sources/genindex.rst.txt", + "html/_sources/index.rst.txt", + "html/_static/_sphinx_javascript_frameworks_compat.js", + "html/_static/basic.css", + "html/_static/css/badge_only.css", + "html/_static/css/custom.css", + "html/_static/css/fonts/Roboto-Slab-Bold.woff", + "html/_static/css/fonts/Roboto-Slab-Bold.woff2", + "html/_static/css/fonts/Roboto-Slab-Regular.woff", + "html/_static/css/fonts/Roboto-Slab-Regular.woff2", + "html/_static/css/fonts/fontawesome-webfont.eot", + "html/_static/css/fonts/fontawesome-webfont.svg", + "html/_static/css/fonts/fontawesome-webfont.ttf", + "html/_static/css/fonts/fontawesome-webfont.woff", + "html/_static/css/fonts/fontawesome-webfont.woff2", + "html/_static/css/fonts/lato-bold-italic.woff", + "html/_static/css/fonts/lato-bold-italic.woff2", + "html/_static/css/fonts/lato-bold.woff", + "html/_static/css/fonts/lato-bold.woff2", + "html/_static/css/fonts/lato-normal-italic.woff", + "html/_static/css/fonts/lato-normal-italic.woff2", + "html/_static/css/fonts/lato-normal.woff", + "html/_static/css/fonts/lato-normal.woff2", + "html/_static/css/theme.css", + "html/_static/doctools.js", + "html/_static/documentation_options.js", + "html/_static/favicon.ico", + "html/_static/file.png", + "html/_static/fonts/Lato/lato-bold.eot", + "html/_static/fonts/Lato/lato-bold.ttf", + "html/_static/fonts/Lato/lato-bold.woff", + "html/_static/fonts/Lato/lato-bold.woff2", + "html/_static/fonts/Lato/lato-bolditalic.eot", + "html/_static/fonts/Lato/lato-bolditalic.ttf", + "html/_static/fonts/Lato/lato-bolditalic.woff", + "html/_static/fonts/Lato/lato-bolditalic.woff2", + "html/_static/fonts/Lato/lato-italic.eot", + "html/_static/fonts/Lato/lato-italic.ttf", + "html/_static/fonts/Lato/lato-italic.woff", + "html/_static/fonts/Lato/lato-italic.woff2", + "html/_static/fonts/Lato/lato-regular.eot", + "html/_static/fonts/Lato/lato-regular.ttf", + "html/_static/fonts/Lato/lato-regular.woff", + "html/_static/fonts/Lato/lato-regular.woff2", + "html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot", + "html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf", + "html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff", + "html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2", + "html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot", + "html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf", + "html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff", + "html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2", + "html/_static/jquery.js", + "html/_static/js/badge_only.js", + "html/_static/js/theme.js", + "html/_static/js/versions.js", + "html/_static/language_data.js", + "html/_static/minus.png", + "html/_static/plus.png", + "html/_static/pygments.css", + "html/_static/searchtools.js", + "html/_static/sphinx_highlight.js", + "html/genindex.html", + "html/index.html", + "html/objects.inv", + "html/search.html", + "html/searchindex.js", + "lake-manifest.json", + "lakefile.toml", + "lean-toolchain", + "mathematics_in_lean.pdf", +] + +[sha256] +"mathematics_in_lean/.gitignore" = "56c6b0a424c1bd1695f313d2fce1adbf04609f713e5b57eb7cb140919e998f23" +"mathematics_in_lean/LICENSE" = "b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1" +"mathematics_in_lean/MIL.lean" = "12c05b1c695f5744b41900846e9991c0fb44603a192cc612c6cffa8cefb01aaa" +"mathematics_in_lean/MIL/C01_Introduction/S01_Getting_Started.lean" = "5285aec7011fa7b73a5daff4d69f646761abb1872ffc2d61a230130d12edecc7" +"mathematics_in_lean/MIL/C01_Introduction/S02_Overview.lean" = "452b154fc8018a256b0c660e48e68e4ac5d9db7ac07c5edca309dbdac29d3194" +"mathematics_in_lean/MIL/C01_Introduction/solutions/Solutions_S01_Getting_Started.lean" = "ac255051373b0ee71bcaf575bd128f969f0c464493b83a8a7fe64226c3e14077" +"mathematics_in_lean/MIL/C01_Introduction/solutions/Solutions_S02_Overview.lean" = "0054fdf17ef5790169a8a480d209a8b8468db7a96ddaaa539a17881f412e28b6" +"mathematics_in_lean/MIL/C02_Basics/S01_Calculating.lean" = "630bb0e10638ad751e465c40d85ebbb94713b77771134c2824c82c0746a55093" +"mathematics_in_lean/MIL/C02_Basics/S02_Proving_Identities_in_Algebraic_Structures.lean" = "3fc6f1f296f4d1552648f7d62950584ea6a683026b4da309f88b7beb19ce6fc0" +"mathematics_in_lean/MIL/C02_Basics/S03_Using_Theorems_and_Lemmas.lean" = "402345c223e6da720921b5aadb797c3bc5df01283c2212044dc28def6a8acb7a" +"mathematics_in_lean/MIL/C02_Basics/S04_More_on_Order_and_Divisibility.lean" = "ee80003f8df605be156d55e9d70cfe0fb88274c89dab370ce33cef1bcd76f269" +"mathematics_in_lean/MIL/C02_Basics/S05_Proving_Facts_about_Algebraic_Structures.lean" = "aa5eaacbddcdd31f2aa5dd0c3c69dfc41d955380c60142e8e835760fffd474e6" +"mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S01_Calculating.lean" = "f42d923afeee167f9dab2c07f3e91cea7daa603f645f87117f9f65ec222a5c25" +"mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S02_Proving_Identities_in_Algebraic_Structures.lean" = "73c79faaca8a7fcd86057dd5461cfa41c3bc854d89901a6b6f1c324e5865cc2b" +"mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S03_Using_Theorems_and_Lemmas.lean" = "fa118c8b741608ffc5c1df0b65586b84abd4f59ab90dba5f10db16919a77d73e" +"mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S04_More_on_Order_and_Divisibility.lean" = "35b1c7bc780324b082f2539f63d886e7ec2d67b3e7b59ae640d425b7d924ec54" +"mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S05_Proving_Facts_about_Algebraic_Structures.lean" = "c146d2dc8d17579ebc8eccb72d1cec30947311f751d9810b78af8fd94edd6080" +"mathematics_in_lean/MIL/C03_Logic/S01_Implication_and_the_Universal_Quantifier.lean" = "9513f26e16b993d933db76eeda598c5a2506ea01fdb00b14dd4bea3f8bed1789" +"mathematics_in_lean/MIL/C03_Logic/S02_The_Existential_Quantifier.lean" = "7802f2039b1cf8143c9dc1077d9c156ca6d28f00aea7598ed274cf7884268395" +"mathematics_in_lean/MIL/C03_Logic/S03_Negation.lean" = "2a263b489d2b4f40173ee5aebfe082c32a115983e384e32b5033cc6b3e1bd8c8" +"mathematics_in_lean/MIL/C03_Logic/S04_Conjunction_and_Iff.lean" = "95c832a70c7515cd2aa1394a4df28b2f576f4c5e549d52f84a17abdddf91bafe" +"mathematics_in_lean/MIL/C03_Logic/S05_Disjunction.lean" = "7c067ca5c4d3aa722d6168e100e2a38e7a240c1779a3182e9dbedc6699c27a59" +"mathematics_in_lean/MIL/C03_Logic/S06_Sequences_and_Convergence.lean" = "0257a9a032be9b019383ab8710c77992b1bd92489c9135e2fc9cd8d97c9ab8c7" +"mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S01_Implication_and_the_Universal_Quantifier.lean" = "ba08f614d00afd93e19ef9c0fe6fc09cc15d3ae1940ffdd0b7c040b9cb0c7799" +"mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S02_The_Existential_Quantifier.lean" = "486b2a9eef1074ec0e9e8ecd145dddc0d50a69db34fa2c0df7516416e9bd6988" +"mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S03_Negation.lean" = "3ec9e16faf5eedde97fe6f9e443cc31d6c55439247be48849c2a96bc9c332258" +"mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S04_Conjunction_and_Iff.lean" = "068b4015d005ab22cfb1ce02dc445f949faf643e583abfc866d18b235dbcfd57" +"mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S05_Disjunction.lean" = "f4b405934a189b00c66b2e5c764ca2b9b828d667df9bd6b60c1cdea02258e010" +"mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S06_Sequences_and_Convergence.lean" = "650e506d6d747bb8f3a0c8a5cc3899d14e5959e26ed49c5ca38b864efc165a68" +"mathematics_in_lean/MIL/C04_Sets_and_Functions/S01_Sets.lean" = "aaa8ef14b49eb15704e18925ca3912efa52cafdeedc48d73928ccb91b027276e" +"mathematics_in_lean/MIL/C04_Sets_and_Functions/S02_Functions.lean" = "671e356d6e6ad373cb596c6b869bda43afe2087ea04203201e584e662573c8cc" +"mathematics_in_lean/MIL/C04_Sets_and_Functions/S03_The_Schroeder_Bernstein_Theorem.lean" = "c1e2ecf73d7a70bf720e78fe72b793aad06f6244ce8f26f5cb718b19aa979614" +"mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S01_Sets.lean" = "67bf30e71b662d3ebbe606955ad3663e5019c7102aa959f4e58f59d2d99fb5c1" +"mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S02_Functions.lean" = "b4897a4545eefe4da59c776b22c3e060cb9785dc6db9cd92cd36bb12202fa383" +"mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S03_The_Schroeder_Bernstein_Theorem.lean" = "937f709980b697c7772d3325ef9334a74d74e13efb29a2ccaa789a9fecb83c83" +"mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S01_Irrational_Roots.lean" = "f4049f49f85353f1b08b5901315f82b686828f784ab0306ca48374e3c7856759" +"mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S02_Induction_and_Recursion.lean" = "300745cbf6fb7ff333e248a0c71b14a45f5f1648693edc96ef238558cf022f53" +"mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S03_Infinitely_Many_Primes.lean" = "39c067ed4da36d17f67d9f7adad1f2bb27ad421531f38d514d5ad2b8e949dc5d" +"mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S04_More_Induction.lean" = "e15295ceca3e9ed615ce92c0cdc0a2bb00640fb6d431e01273444d2a288c5a25" +"mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S01_Irrational_Roots.lean" = "3c278be7e34ed83324974e22b725787514f20bbe3a585865a40384ad045120cd" +"mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S02_Induction_and_Recursion.lean" = "3eb2fcb9a3bf1abcd41e9aee580e14a5725fbca15fd86d27dad74a7248eb1cf3" +"mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S03_Infinitely_Many_Primes.lean" = "67e887b2c9094aa2ed36d3a9e7f69193c7d5bae8b0ed7cfccbcbbbcd0b897907" +"mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S04_More_Induction.lean" = "db99ef5c93a284ade91fdda97601de2e65228f4805cfdc062daac091762ed7b5" +"mathematics_in_lean/MIL/C06_Discrete_Mathematics/S01_Finsets_and_Fintypes.lean" = "ce5626a7de669a281ccc079357200d28db2d3fa7e192bd54b51b5f427a1dc86b" +"mathematics_in_lean/MIL/C06_Discrete_Mathematics/S02_Counting_Arguments.lean" = "5907fa4e2d2125d3576968cc8ad9afd80dbd63ebc1ac5cf095b10605cec519d1" +"mathematics_in_lean/MIL/C06_Discrete_Mathematics/S03_Inductive_Structures.lean" = "a6bf4c79da70b8ec2f297ea2011da06629348036506435f0cea738fc8ffe4231" +"mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S01_Finsets_and_Fintypes.lean" = "6be9aa71e7de4d3cd920dc391c48ac0f9d4ee537067fa616aeb777ec4bea99cc" +"mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S02_Counting_Arguments.lean" = "a2d8954c8fdac1ad8b8fc68a10bb3b97a28dea0f6553e85bcba0afe10a7b4053" +"mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S03_Inductive_Structures.lean" = "9536575453877815bbbdd5df93e5a78e42b1ddfc15b83ea752c3eb9072a4ae43" +"mathematics_in_lean/MIL/C07_Structures/S01_Structures.lean" = "fa7e6999fe104bc3eb8fc7ece65cf2d0f769b7fd03ca0b92e881ea65d3c7b878" +"mathematics_in_lean/MIL/C07_Structures/S02_Algebraic_Structures.lean" = "b7e0c514e090e95426bdce95bced488776239675985b8220f5ac6c7c135b3abd" +"mathematics_in_lean/MIL/C07_Structures/S03_Building_the_Gaussian_Integers.lean" = "b2aef1e3f7ab30242b959efb286bfef4372a14893a0718d45b42ffb93b4d7e1d" +"mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S01_Structures.lean" = "25f4ee84f5b0ec6cc81ee5d03ac3c7707000284476761536706817dc046d1c54" +"mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S02_Algebraic_Structures.lean" = "e28eba8edb7d15f5882b573886d47af2ec57817347cc66f31a448fbbb6a0daf0" +"mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S03_Building_the_Gaussian_Integers.lean" = "66c6b1ea64ebb33139ba9efc6cf26d7804e874f7017397e1ec206e9492debff1" +"mathematics_in_lean/MIL/C08_Hierarchies/S01_Basics.lean" = "6041de6a91b5ddde60d73ebadd16ab0546ed0fcc42b47209059491d2360fae19" +"mathematics_in_lean/MIL/C08_Hierarchies/S02_Morphisms.lean" = "024ed56ee50250853d98bcc0156c01904adc1fc3bf434546d371f6373fcdd153" +"mathematics_in_lean/MIL/C08_Hierarchies/S03_Subobjects.lean" = "98765f8e0257b35f45f5c81a12f3a17981cc65d9dbfecbfd3a1825223d379b8e" +"mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S01_Basics.lean" = "4319ebc167572d4e5d359433d68effcd637154f51261b05df15381d2b7168ac8" +"mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S02_Morphisms.lean" = "3bc43754e0996f1ffa446b2d0689ce180ecd0c4cf6f87cef8af91e39ee08bc95" +"mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S03_Subobjects.lean" = "ebdbb6894dd575666c51b4e1c7333d84145443bb699bc02e051642d6d976b632" +"mathematics_in_lean/MIL/C09_Groups_and_Rings/S01_Groups.lean" = "68d40ca03c06916bda37ea53fc56471b8789b908b5f600925f48d411e44a830f" +"mathematics_in_lean/MIL/C09_Groups_and_Rings/S02_Rings.lean" = "5a3b920ef5ec044f4dfb00c08b6582944ffe83aa5cdafd3ace17b0f5d0a617d8" +"mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S01_Groups.lean" = "cabb02e5cf01de865e2b2827c54eb5bac6c0b21082b58f6801fefb989d00c4ae" +"mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S02_Rings.lean" = "02956ea44490bc8b8c1e8b1c50e04599745847c5ba0d99a84243fd82517e238f" +"mathematics_in_lean/MIL/C10_Linear_Algebra/S01_Vector_Spaces.lean" = "23b857c9353ea90b9921813b921378562bf38d05cb8715c73db9ac7f4695defc" +"mathematics_in_lean/MIL/C10_Linear_Algebra/S02_Subspaces.lean" = "fb865b5c3435e961bc5874d5191e0f98594341862e7a278d51b2c19facf1f52e" +"mathematics_in_lean/MIL/C10_Linear_Algebra/S03_Endomorphisms.lean" = "d4786291cb8b2ebfa66516157a4985b2aa74130176efcd9f72e8b2a6c87e59b6" +"mathematics_in_lean/MIL/C10_Linear_Algebra/S04_Bases.lean" = "fb32de8a334d286d76f7e62168a686b434883e5cd68be998ca44bb8b2cbf5c0b" +"mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S01_Vector_Spaces.lean" = "daf916d3f96ff57e4017c9e1fa550abe837f92a3111c501c5a6c3eb79932e866" +"mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S02_Subspaces.lean" = "cdd4f35a7c01a4191796bb01535f300ce5341c0cd23f38cf52c375c56f808af4" +"mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S03_Endomorphisms.lean" = "d6cd865b60ee6685dd124bd23d3c4c7a4b2f4818e305f04c64a8a147aebf724a" +"mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S04_Bases.lean" = "d60349f67b0da3b3bba991888baf5976724d304b0f9ce0755da3a6afff3c8dcb" +"mathematics_in_lean/MIL/C11_Topology/S01_Filters.lean" = "b5ed65f9d38b94dc767cb2e8df44491081dea08cf7d63e616d9f5bc38887878c" +"mathematics_in_lean/MIL/C11_Topology/S02_Metric_Spaces.lean" = "8d9826f5e21446dda37068704c6a1d0a8d503674561403b32506680e33edb9d1" +"mathematics_in_lean/MIL/C11_Topology/S03_Topological_Spaces.lean" = "12589d91b5c5f30604359d0d6cf70e6fe91e34dcb53cd2acc1c798563f86640f" +"mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S01_Filters.lean" = "8727ca2888301bf32fc8cd9f9823d746338c056258055b2e7af97267758a858b" +"mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S02_Metric_Spaces.lean" = "669a9c71bb9abc801786f7b1e4217f697bd48bedcf1193f01dbe2f82e2c3640b" +"mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S03_Topological_Spaces.lean" = "4a1ba59c9f5455853e2b35b8c3f05653ec017890052304e2bae5007f650570a6" +"mathematics_in_lean/MIL/C12_Differential_Calculus/S01_Elementary_Differential_Calculus.lean" = "fcd0e01f132255e96ba7d71c3cda3119da36365b18711b81411031def743218d" +"mathematics_in_lean/MIL/C12_Differential_Calculus/S02_Differential_Calculus_in_Normed_Spaces.lean" = "0469267460c36130e015097fa65b7ccdfd87c5e556b903d2e4a881ad4deb0801" +"mathematics_in_lean/MIL/C12_Differential_Calculus/solutions/Solutions_S01_Elementary_Differential_Calculus.lean" = "dc58168c3c8b228bd1b8557d8dbcc15f73861f7b3825368768adc755f543a0b6" +"mathematics_in_lean/MIL/C12_Differential_Calculus/solutions/Solutions_S02_Differential_Calculus_in_Normed_Spaces.lean" = "6211e9549f7271810a1ae8cc176340f22bfe12e9b0be0438bf7414a075ca4688" +"mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S01_Elementary_Integration.lean" = "a2b8e282c15162ceb24f3c195e17bb309edc54cd340065fdbdd24bb3bbf6fc00" +"mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S02_Measure_Theory.lean" = "a30fdc7dff096c9ca3726b177506f3352c6acc09f329e495f684a9efb6bdb8a1" +"mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S03_Integration.lean" = "a2f3ab573459ee71db94c6cf5bf73231fc78a0289ee95cf5db56764ca2b1d883" +"mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S01_Elementary_Integration.lean" = "5b02c70745eb1f0a058bf7628dc64dc10d50608c99305918ee3272050fe22629" +"mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S02_Measure_Theory.lean" = "1bb06ec9a6e8f6bfb29b8bffe814501bd639ad3aa4b465be33b4e79084d80ffe" +"mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S03_Integration.lean" = "18dba65d7ac70dee677102e40f3038abfd95fee45e871f186abe78f73dcc59f2" +"mathematics_in_lean/MIL/Common.lean" = "d4e65bed8451c84eeae873577c57a258607edb7e8582eafa976c643c534d50b7" +"mathematics_in_lean/MIL_solutions.lean" = "0c6ecaa0b7d50f124a79b435f3df163ec9e15d2731db00e9a4485bef845d380a" +"mathematics_in_lean/README.md" = "56f180ff3448dec40bdb53ea32ce45b7d1777f14bc7dfed94e870989243df4ae" +"mathematics_in_lean/html/.buildinfo" = "d5eff33ec2883e2c011f0b6e3620c9c69deb90a0025bb10cec9438f7f55cf352" +"mathematics_in_lean/html/C01_Introduction.html" = "51fba43a5838946c5cbd2fcf74ff03cd4e6eb2038bbe8074c2036d49f89b114d" +"mathematics_in_lean/html/C02_Basics.html" = "5a3d9adff49ab95899bc4e9a267b0d2f7d0868c96e89be98fee4fdb87240a900" +"mathematics_in_lean/html/C03_Logic.html" = "7922257e9fb3040ea4c94e3c6a89bd68bd405401ceefbe032c39b293755f6d61" +"mathematics_in_lean/html/C04_Sets_and_Functions.html" = "cc2783fee5ca40dbb15c5833bd5927eae4f34e3b2f8fe634dea81989c512b7a8" +"mathematics_in_lean/html/C05_Elementary_Number_Theory.html" = "daab03935b7a60ad80e12b8e4640503a4e4943d0d2c78fa31d9686765fe8778e" +"mathematics_in_lean/html/C06_Discrete_Mathematics.html" = "10db7cf9e7cbd4bab6b289b85f5d5a0c0a0d8afe2280259631c98c44475e1809" +"mathematics_in_lean/html/C07_Structures.html" = "085c3488a38160646bc0e1955a3054fcd61c3596031d992468a5dd7eb4d2b44b" +"mathematics_in_lean/html/C08_Hierarchies.html" = "adb10062402124d6cab57ca6d5317cdfb5eec468e7614bfa1c85b75d3c2413c7" +"mathematics_in_lean/html/C09_Groups_and_Rings.html" = "046f60514a788623f5c91ea2835cb90678dcaafad06ae172bcd1aee90e7b0bf4" +"mathematics_in_lean/html/C10_Linear_Algebra.html" = "0b56b1eadbbe3dc22478642ac4cb9db87c03b62db61701f4c560b80e28c31b70" +"mathematics_in_lean/html/C11_Topology.html" = "58cb3e54d3f20784b0c75cd4915707d4b5874c1956c41ecfe70c6f7082adb450" +"mathematics_in_lean/html/C12_Differential_Calculus.html" = "d5f51025e23fa3b7852b9ba1d8847ca56adcaa4f10d197a2718b29da1d578d6a" +"mathematics_in_lean/html/C13_Integration_and_Measure_Theory.html" = "79be0a6bd8eb706f6d79d512e7f7e8c6e7f925eabd333c5d5a75e672d687f6fa" +"mathematics_in_lean/html/_images/schroeder_bernstein1.png" = "5526e06804b6eb444741d2eeb98aea90bf9f6680cbdacf501ba0a759901bf729" +"mathematics_in_lean/html/_images/schroeder_bernstein2.png" = "7c96e39bc471db106bafe86b53372ff19457400b354b192b8ae9f14bdf491b5e" +"mathematics_in_lean/html/_images/schroeder_bernstein3.png" = "32cc1742330da59754ee04c9f85c27866a5d2f6bb1bc0ecafc69130bfc52e9f6" +"mathematics_in_lean/html/_sources/C01_Introduction.rst.txt" = "2f98440a5d1d876e8d6aa0e4118ebc0e7da08b994983bedf67ee21128df061e6" +"mathematics_in_lean/html/_sources/C02_Basics.rst.txt" = "a53edaef959a3cb4f531a89df25fa4f67dc51baff3abeae5e724649da2f31199" +"mathematics_in_lean/html/_sources/C03_Logic.rst.txt" = "511e255e1ebc6f23d7919de7022c331bf3db8758e506aa448fd5078c91d922ed" +"mathematics_in_lean/html/_sources/C04_Sets_and_Functions.rst.txt" = "453254bc61061fed1eb2cc594010777a4dcbf0697ff41752b40a9ef47474554e" +"mathematics_in_lean/html/_sources/C05_Elementary_Number_Theory.rst.txt" = "dc4a1ca053929169f7492211b7725fd455cd1c3a413561f0fde486a20c0822b2" +"mathematics_in_lean/html/_sources/C06_Discrete_Mathematics.rst.txt" = "7d2045c3ca247b6ce72906bcf18a7ad979a387c2a211c43cb94ebc12b3d78131" +"mathematics_in_lean/html/_sources/C07_Structures.rst.txt" = "b3876426017bcd61d93749074cde7df17ef085f23f974049963c4159419c3d34" +"mathematics_in_lean/html/_sources/C08_Hierarchies.rst.txt" = "9422369c4c706464cf5a8a6f2b99d91d0cf2d36c059871e9c48f762ea9cbcd86" +"mathematics_in_lean/html/_sources/C09_Groups_and_Rings.rst.txt" = "65f89e326e96b3b88a23d51aa747b8d97c521c7554168496ce9fe709ec100d7d" +"mathematics_in_lean/html/_sources/C10_Linear_Algebra.rst.txt" = "41bb529f6d49dcb21c7542abfa040d7e282b11efef14e8b91ddba1934e565c64" +"mathematics_in_lean/html/_sources/C11_Topology.rst.txt" = "37947a1ce4667b897ac76c95d213a9e5f67e9de8829456a3bda0147bd3d8f214" +"mathematics_in_lean/html/_sources/C12_Differential_Calculus.rst.txt" = "063d9c82fd6845bedb50a1141a1288e0dcb174c23cdb16e0eafa1da8907a9310" +"mathematics_in_lean/html/_sources/C13_Integration_and_Measure_Theory.rst.txt" = "b2bb5519f141b3fdaeb31ab7a3fbfccad0192e980f743e04bcd854ea01790565" +"mathematics_in_lean/html/_sources/genindex.rst.txt" = "585dd1c9c847b51f814dde251250fe923a2d8d589460cfc9730081778ffee136" +"mathematics_in_lean/html/_sources/index.rst.txt" = "1aa757466e745ba804bef888e7e9d5533d3f6b09c94cac4ededd26133b13d14e" +"mathematics_in_lean/html/_static/_sphinx_javascript_frameworks_compat.js" = "480a2c7377252c14a11bca4d3a49dfa16ea540a998fa637fae0189aee1b89113" +"mathematics_in_lean/html/_static/basic.css" = "656ff1bacd6f260fc7d71b97f9c2f1fcbf692dc84bf469cd952034efcb9eefed" +"mathematics_in_lean/html/_static/css/badge_only.css" = "f1399e4fc48c3ff17b5037d3512fcc451fb0abc2c95b4b8d12aab50cdd9d1d6f" +"mathematics_in_lean/html/_static/css/custom.css" = "cba28350f7dbbda47fa315479122f805bbeca7ac1f6f8cfab6748ac0c96f3250" +"mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Bold.woff" = "9fec87cadbe2413b255f1ec577573a83f1ca2e1c37aa023dbebcd3a7b864636a" +"mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Bold.woff2" = "1a0c024dd1a267c52d5575469ffe8570d1e84164de7d393cf3414bafd17d7a0c" +"mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Regular.woff" = "9f32630e2c0c5135bf1e86e36cb65b3932e4410644235bc2bd995e9c7f6ff117" +"mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Regular.woff2" = "874e42222856d7af03b3f438d21d923a4280d47fe67c48510e2174a1579795ef" +"mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.eot" = "7bfcab6db99d5cfbf1705ca0536ddc78585432cc5fa41bbd7ad0f009033b2979" +"mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.svg" = "ad6157926c1622ba4e1d03d478f1541368524bfc46f51e42fe0d945f7ef323e4" +"mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.ttf" = "aa58f33f239a0fb02f5c7a6c45c043d7a9ac9a093335806694ecd6d4edc0d6a8" +"mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.woff" = "ba0c59deb5450f5cb41b3f93609ee2d0d995415877ddfa223e8a8a7533474f07" +"mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.woff2" = "2adefcbc041e7d18fcf2d417879dc5a09997aa64d675b7a3c4b6ce33da13f3fe" +"mathematics_in_lean/html/_static/css/fonts/lato-bold-italic.woff" = "980c8592e5488df256192c999e92db8fd302db8cd8909b7fa266a684e37e45f8" +"mathematics_in_lean/html/_static/css/fonts/lato-bold-italic.woff2" = "c0916a33340d063f7b05679e08031e729d1888444706f04804705da5966d895d" +"mathematics_in_lean/html/_static/css/fonts/lato-bold.woff" = "0e56b17d142eb366c8007031d14e34da48c70b4a9d9a0ca492e696a7bae45e1e" +"mathematics_in_lean/html/_static/css/fonts/lato-bold.woff2" = "ae88fc0d7a961832f809527d30bd3983a6866d42f66a56ade23f543681594db6" +"mathematics_in_lean/html/_static/css/fonts/lato-normal-italic.woff" = "26318a1467a5e5caf10b04cfa942d079632560cd7a29cec565fd1dc9f7ec5081" +"mathematics_in_lean/html/_static/css/fonts/lato-normal-italic.woff2" = "4465765f2f6eddcdad34ffd7cab559e56bc0e75e45e192f85e9562b0771481dc" +"mathematics_in_lean/html/_static/css/fonts/lato-normal.woff" = "5b9025dda4d7688e3311b0c17eddc501133b807def33effaef6593843cf5416e" +"mathematics_in_lean/html/_static/css/fonts/lato-normal.woff2" = "983b0caf336e8542214fc17019a4fc5e0360864b92806ca14d55c1fc1c2c5a0f" +"mathematics_in_lean/html/_static/css/theme.css" = "73c4334fefad3ea9a5dbb91709cfb8561cac96571946eae127516a496e4ff99c" +"mathematics_in_lean/html/_static/doctools.js" = "2992c09df91826a8d33e3b48b645ee77e457adcf7c712d776a814e1e2c448b43" +"mathematics_in_lean/html/_static/documentation_options.js" = "edd18396e41a6927359632ee72e140c018cfe05fc0d9e89121c13b9baa7567c5" +"mathematics_in_lean/html/_static/favicon.ico" = "60ea6ffab2fa3eb952d27d3aed8d91232925cba81b00ceeac9032e6cf446fff9" +"mathematics_in_lean/html/_static/file.png" = "5c4bc9a16aebf38c4b950f59b8e501ca36495328cb9eb622218bce9064a35e3e" +"mathematics_in_lean/html/_static/fonts/Lato/lato-bold.eot" = "b91fc1ca55df440dc11354b32a39b45db663d24bb17b16dcb2e706330955b0d1" +"mathematics_in_lean/html/_static/fonts/Lato/lato-bold.ttf" = "f71f833c099f450606f8107b83ef208ae918c0ea00779466d45e9be96b0bc7cc" +"mathematics_in_lean/html/_static/fonts/Lato/lato-bold.woff" = "0e56b17d142eb366c8007031d14e34da48c70b4a9d9a0ca492e696a7bae45e1e" +"mathematics_in_lean/html/_static/fonts/Lato/lato-bold.woff2" = "ae88fc0d7a961832f809527d30bd3983a6866d42f66a56ade23f543681594db6" +"mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.eot" = "b3d585879a02f48c5d43d8f91d06b167e367a31934bb3b8147c0a90b5ca32bfc" +"mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.ttf" = "f98d040631714eabffd0ffb747576674fa78c2910f6d9e3dc0c58481d03c1898" +"mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.woff" = "980c8592e5488df256192c999e92db8fd302db8cd8909b7fa266a684e37e45f8" +"mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.woff2" = "c0916a33340d063f7b05679e08031e729d1888444706f04804705da5966d895d" +"mathematics_in_lean/html/_static/fonts/Lato/lato-italic.eot" = "bc24dbe04f5b2415678f978e7e2f630cc6610670d684e088e73ad29c439eafe3" +"mathematics_in_lean/html/_static/fonts/Lato/lato-italic.ttf" = "12d825af88eafea1ce3aa469f83c03acaecd0d03f690f409c8643529f1205b4f" +"mathematics_in_lean/html/_static/fonts/Lato/lato-italic.woff" = "26318a1467a5e5caf10b04cfa942d079632560cd7a29cec565fd1dc9f7ec5081" +"mathematics_in_lean/html/_static/fonts/Lato/lato-italic.woff2" = "4465765f2f6eddcdad34ffd7cab559e56bc0e75e45e192f85e9562b0771481dc" +"mathematics_in_lean/html/_static/fonts/Lato/lato-regular.eot" = "e735410675eacc363b257112f39eb819a854b03077d7b1f0caa6e7660ffbd8b3" +"mathematics_in_lean/html/_static/fonts/Lato/lato-regular.ttf" = "089ab6d4a57e0e6c4dd3b681b6fd50a5184f1b902429d35e1227e52d6ccad1bd" +"mathematics_in_lean/html/_static/fonts/Lato/lato-regular.woff" = "5b9025dda4d7688e3311b0c17eddc501133b807def33effaef6593843cf5416e" +"mathematics_in_lean/html/_static/fonts/Lato/lato-regular.woff2" = "983b0caf336e8542214fc17019a4fc5e0360864b92806ca14d55c1fc1c2c5a0f" +"mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot" = "4438991a12ff951cc8d0e83348ec06d9f910591b1b014c476e9595d4da099e48" +"mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf" = "ba12d2eab1fa765b6b05398fa7e047dd76293f0c051ce57a8f7b0c591c14d42b" +"mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff" = "9fec87cadbe2413b255f1ec577573a83f1ca2e1c37aa023dbebcd3a7b864636a" +"mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2" = "1a0c024dd1a267c52d5575469ffe8570d1e84164de7d393cf3414bafd17d7a0c" +"mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot" = "b3809b71d417c6c225e77a55880aa7915b4e4b4f77a5e2d243f3563731e7f55c" +"mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf" = "13aa5f54c6f2fa2e388fe0e675cdbcc6a81f6270a8bf9c03a5df8af9cb022810" +"mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff" = "9f32630e2c0c5135bf1e86e36cb65b3932e4410644235bc2bd995e9c7f6ff117" +"mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2" = "874e42222856d7af03b3f438d21d923a4280d47fe67c48510e2174a1579795ef" +"mathematics_in_lean/html/_static/jquery.js" = "ff1523fb7389539c84c65aba19260648793bb4f5e29329d2ee8804bc37a3fe6e" +"mathematics_in_lean/html/_static/js/badge_only.js" = "f0a4808d04c4d55378751ac096a8376b64b1a704c82584b0ee590212cf413013" +"mathematics_in_lean/html/_static/js/theme.js" = "536ad2d746e944c5570cc15badaeccc3c0582a1b66e45511fe4edce32b6da510" +"mathematics_in_lean/html/_static/js/versions.js" = "0998cc5239113cb6009ab1730e24ede85673759810ee8fb1e2f912305282a4aa" +"mathematics_in_lean/html/_static/language_data.js" = "3bc311563b7fc5e80fcab2f8629774bf3cb6b30202000df36dff8e695a9023b7" +"mathematics_in_lean/html/_static/minus.png" = "47e7fc50db3699f1ca41ce9a2ffa202c00c5d1d5180c55f62ba859b1bd6cc008" +"mathematics_in_lean/html/_static/plus.png" = "54115199b96a130cba02147c47c0deb43dcc9b9f08b5162bba8642b34980ac63" +"mathematics_in_lean/html/_static/pygments.css" = "1391123c90891f96f975870647f0b2c364fbfda7cd9e9b02bbd84f2077608034" +"mathematics_in_lean/html/_static/searchtools.js" = "371b49c7f094b525244e2a59d7809a6b946fc1c8791201d10dda1dd191133bb7" +"mathematics_in_lean/html/_static/sphinx_highlight.js" = "096231e9c87df80ec3273da9c5b71bc81503206726a07a4dd4de44c256ff859c" +"mathematics_in_lean/html/genindex.html" = "5c6cae1e66a7a9518f4d7b0ec261c13e887d5579f932e2be70f1385d24bb247a" +"mathematics_in_lean/html/index.html" = "840057d3eb47faad2bd53ac872a52eb8f17b47e6ba68a2a9af0a19ab0bc4dee7" +"mathematics_in_lean/html/objects.inv" = "414beb72ef89f1c86d24088f313d8a4ca3e1332d950643fd5be6f8988c8a9484" +"mathematics_in_lean/html/search.html" = "f045abfa3ddb77e5301858414e2092f896bcc13956747999236d2fecd5dcf5bb" +"mathematics_in_lean/html/searchindex.js" = "e1422f76efdbb7dbd81f2134fc908f696de1d3bb40fdf5311eebef762b6f1350" +"mathematics_in_lean/lake-manifest.json" = "9b4ea8e3a4c8ce240b3dcc556aa39f92de082b2dd8cfaa7cbfef2889991cfba4" +"mathematics_in_lean/lakefile.toml" = "6de6ef24bd332b6ad290876992b0d0237b78c00fdb637f79fa3249d438146735" +"mathematics_in_lean/lean-toolchain" = "8733782dc070a99b312039cda424f601b80f3be6f6f512627da5ba25adc27632" +"mathematics_in_lean/mathematics_in_lean.pdf" = "6ae62fd8909042e194b5e64d892ce47168735d4fdfeb44da909fb27a5121dbdc" diff --git a/dev/vendor/mathematics_in_lean/.gitignore b/dev/vendor/mathematics_in_lean/.gitignore new file mode 100644 index 0000000..9a26f5c --- /dev/null +++ b/dev/vendor/mathematics_in_lean/.gitignore @@ -0,0 +1,6 @@ +/.vscode +/build +/lake-packages +.lake +/.cache +.DS_Store diff --git a/dev/vendor/mathematics_in_lean/LICENSE b/dev/vendor/mathematics_in_lean/LICENSE new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/dev/vendor/mathematics_in_lean/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/dev/vendor/mathematics_in_lean/MIL.lean b/dev/vendor/mathematics_in_lean/MIL.lean new file mode 100644 index 0000000..213aa08 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL.lean @@ -0,0 +1,44 @@ +import MIL.C01_Introduction.S01_Getting_Started +import MIL.C01_Introduction.S02_Overview +import MIL.C02_Basics.S01_Calculating +import MIL.C02_Basics.S02_Proving_Identities_in_Algebraic_Structures +import MIL.C02_Basics.S03_Using_Theorems_and_Lemmas +import MIL.C02_Basics.S04_More_on_Order_and_Divisibility +import MIL.C02_Basics.S05_Proving_Facts_about_Algebraic_Structures +import MIL.C03_Logic.S01_Implication_and_the_Universal_Quantifier +import MIL.C03_Logic.S02_The_Existential_Quantifier +import MIL.C03_Logic.S03_Negation +import MIL.C03_Logic.S04_Conjunction_and_Iff +import MIL.C03_Logic.S05_Disjunction +import MIL.C03_Logic.S06_Sequences_and_Convergence +import MIL.C04_Sets_and_Functions.S01_Sets +import MIL.C04_Sets_and_Functions.S02_Functions +import MIL.C04_Sets_and_Functions.S03_The_Schroeder_Bernstein_Theorem +import MIL.C05_Elementary_Number_Theory.S01_Irrational_Roots +import MIL.C05_Elementary_Number_Theory.S02_Induction_and_Recursion +import MIL.C05_Elementary_Number_Theory.S03_Infinitely_Many_Primes +import MIL.C05_Elementary_Number_Theory.S04_More_Induction +import MIL.C06_Discrete_Mathematics.S01_Finsets_and_Fintypes +import MIL.C06_Discrete_Mathematics.S02_Counting_Arguments +import MIL.C06_Discrete_Mathematics.S03_Inductive_Structures +import MIL.C07_Structures.S01_Structures +import MIL.C07_Structures.S02_Algebraic_Structures +import MIL.C07_Structures.S03_Building_the_Gaussian_Integers +import MIL.C08_Hierarchies.S01_Basics +import MIL.C08_Hierarchies.S02_Morphisms +import MIL.C08_Hierarchies.S03_Subobjects +import MIL.C09_Groups_and_Rings.S01_Groups +import MIL.C09_Groups_and_Rings.S02_Rings +import MIL.C10_Linear_Algebra.S01_Vector_Spaces +import MIL.C10_Linear_Algebra.S02_Subspaces +import MIL.C10_Linear_Algebra.S03_Endomorphisms +import MIL.C10_Linear_Algebra.S04_Bases +import MIL.C11_Topology.S01_Filters +import MIL.C11_Topology.S02_Metric_Spaces +import MIL.C11_Topology.S03_Topological_Spaces +import MIL.C12_Differential_Calculus.S01_Elementary_Differential_Calculus +import MIL.C12_Differential_Calculus.S02_Differential_Calculus_in_Normed_Spaces +import MIL.C13_Integration_and_Measure_Theory.S01_Elementary_Integration +import MIL.C13_Integration_and_Measure_Theory.S02_Measure_Theory +import MIL.C13_Integration_and_Measure_Theory.S03_Integration +import MIL.Common diff --git a/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/S01_Getting_Started.lean b/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/S01_Getting_Started.lean new file mode 100644 index 0000000..53c48d7 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/S01_Getting_Started.lean @@ -0,0 +1,3 @@ +module +#eval "Hello, World!" + diff --git a/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/S02_Overview.lean b/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/S02_Overview.lean new file mode 100644 index 0000000..37afff8 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/S02_Overview.lean @@ -0,0 +1,56 @@ +module +public import MIL.Common + +open Nat + +-- These are pieces of data. +#check 2 + 2 + +def f (x : ℕ) := + x + 3 + +#check f + +-- These are propositions, of type `Prop`. +#check 2 + 2 = 4 + +def FermatLastTheorem := + ∀ x y z n : ℕ, n > 2 ∧ x * y * z ≠ 0 → x ^ n + y ^ n ≠ z ^ n + +#check FermatLastTheorem + +-- These are proofs of propositions. +theorem easy : 2 + 2 = 4 := + rfl + +#check easy + +theorem hard : FermatLastTheorem := + sorry + +#check hard + +-- Here are some proofs. +example : ∀ m n : Nat, Even n → Even (m * n) := fun m n ⟨k, (hk : n = k + k)⟩ ↦ + have hmn : m * n = m * k + m * k := by rw [hk, mul_add] + show ∃ l, m * n = l + l from ⟨_, hmn⟩ + +example : ∀ m n : Nat, Even n → Even (m * n) := +fun m n ⟨k, hk⟩ ↦ ⟨m * k, by rw [hk, mul_add]⟩ + +example : ∀ m n : Nat, Even n → Even (m * n) := by + -- Say `m` and `n` are natural numbers, and assume `n = 2 * k`. + rintro m n ⟨k, hk⟩ + -- We need to prove `m * n` is twice a natural number. Let's show it's twice `m * k`. + use m * k + -- Substitute for `n`, + rw [hk] + -- and now it's obvious. + ring + +example : ∀ m n : Nat, Even n → Even (m * n) := by + rintro m n ⟨k, hk⟩; use m * k; rw [hk]; ring + +example : ∀ m n : Nat, Even n → Even (m * n) := by + intros; simp [*, parity_simps] + diff --git a/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/solutions/Solutions_S01_Getting_Started.lean b/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/solutions/Solutions_S01_Getting_Started.lean new file mode 100644 index 0000000..0cca093 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/solutions/Solutions_S01_Getting_Started.lean @@ -0,0 +1 @@ +module diff --git a/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/solutions/Solutions_S02_Overview.lean b/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/solutions/Solutions_S02_Overview.lean new file mode 100644 index 0000000..e42733e --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C01_Introduction/solutions/Solutions_S02_Overview.lean @@ -0,0 +1,6 @@ +module +public import MIL.Common + +open Nat + +-- There are no exercises in this section. diff --git a/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S01_Calculating.lean b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S01_Calculating.lean new file mode 100644 index 0000000..681a9c7 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S01_Calculating.lean @@ -0,0 +1,145 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic +-- An example. +example (a b c : ℝ) : a * b * c = b * (a * c) := by + rw [mul_comm a b] + rw [mul_assoc b a c] + +-- Try these. +example (a b c : ℝ) : c * b * a = b * (a * c) := by + sorry + +example (a b c : ℝ) : a * (b * c) = b * (a * c) := by + sorry + +-- An example. +example (a b c : ℝ) : a * b * c = b * c * a := by + rw [mul_assoc] + rw [mul_comm] + +/- Try doing the first of these without providing any arguments at all, + and the second with only one argument. -/ +example (a b c : ℝ) : a * (b * c) = b * (c * a) := by + sorry + +example (a b c : ℝ) : a * (b * c) = b * (a * c) := by + sorry + +-- Using facts from the local context. +example (a b c d e f : ℝ) (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by + rw [h'] + rw [← mul_assoc] + rw [h] + rw [mul_assoc] + +example (a b c d e f : ℝ) (h : b * c = e * f) : a * b * c * d = a * e * f * d := by + sorry + +example (a b c d : ℝ) (hyp : c = b * a - d) (hyp' : d = a * b) : c = 0 := by + sorry + +example (a b c d e f : ℝ) (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by + rw [h', ← mul_assoc, h, mul_assoc] + +section + +variable (a b c d e f : ℝ) + +example (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by + rw [h', ← mul_assoc, h, mul_assoc] + +end + +section +variable (a b c : ℝ) + +#check a +#check a + b +#check (a : ℝ) +#check mul_comm a b +#check (mul_comm a b : a * b = b * a) +#check mul_assoc c a b +#check mul_comm a +#check mul_comm + +end + +section +variable (a b : ℝ) + +example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by + rw [mul_add, add_mul, add_mul] + rw [← add_assoc, add_assoc (a * a)] + rw [mul_comm b a, ← two_mul] + +example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := + calc + (a + b) * (a + b) = a * a + b * a + (a * b + b * b) := by + rw [mul_add, add_mul, add_mul] + _ = a * a + (b * a + a * b) + b * b := by + rw [← add_assoc, add_assoc (a * a)] + _ = a * a + 2 * (a * b) + b * b := by + rw [mul_comm b a, ← two_mul] + +example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := + calc + (a + b) * (a + b) = a * a + b * a + (a * b + b * b) := by + sorry + _ = a * a + (b * a + a * b) + b * b := by + sorry + _ = a * a + 2 * (a * b) + b * b := by + sorry + +end + +-- Try these. For the second, use the theorems listed underneath. +section +variable (a b c d : ℝ) + +example : (a + b) * (c + d) = a * c + a * d + b * c + b * d := by + sorry +-- EXAMPLES. + +example (a b : ℝ) : (a + b) * (a - b) = a ^ 2 - b ^ 2 := by + sorry + +#check pow_two a +#check mul_sub a b c +#check add_mul a b c +#check add_sub a b c +#check sub_sub a b c +#check sub_add a b c +#check add_zero a +#check sub_zero a +#check sub_self a + + +section +variable (a b c d : ℝ) + +example (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := by + rw [hyp'] at hyp + rw [mul_comm d a] at hyp + rw [← two_mul (a * d)] at hyp + rw [← mul_assoc 2 a d] at hyp + exact hyp + +example : c * b * a = b * (a * c) := by + ring + +example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by + ring + +example : (a + b) * (a - b) = a ^ 2 - b ^ 2 := by + ring + +example (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := by + rw [hyp, hyp'] + ring + +end + +example (a b c : ℕ) (h : a + b = c) : (a + b) * (a + b) = a * c + b * c := by + nth_rw 2 [h] + rw [add_mul] diff --git a/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S02_Proving_Identities_in_Algebraic_Structures.lean b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S02_Proving_Identities_in_Algebraic_Structures.lean new file mode 100644 index 0000000..c1bfce2 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S02_Proving_Identities_in_Algebraic_Structures.lean @@ -0,0 +1,147 @@ +module +public import Mathlib.Algebra.Ring.Defs +public import Mathlib.Basic.Real.Basic +public import MIL.Common + +section +variable (R : Type*) [Ring R] + +#check (add_assoc : ∀ a b c : R, a + b + c = a + (b + c)) +#check (add_comm : ∀ a b : R, a + b = b + a) +#check (zero_add : ∀ a : R, 0 + a = a) +#check (neg_add_cancel : ∀ a : R, -a + a = 0) +#check (mul_assoc : ∀ a b c : R, a * b * c = a * (b * c)) +#check (mul_one : ∀ a : R, a * 1 = a) +#check (one_mul : ∀ a : R, 1 * a = a) +#check (mul_add : ∀ a b c : R, a * (b + c) = a * b + a * c) +#check (add_mul : ∀ a b c : R, (a + b) * c = a * c + b * c) + +end + +section +variable (R : Type*) [CommRing R] +variable (a b c d : R) + +example : c * b * a = b * (a * c) := by ring + +example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by ring + +example : (a + b) * (a - b) = a ^ 2 - b ^ 2 := by ring + +example (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := by + rw [hyp, hyp'] + ring + +end + +namespace MyRing +variable {R : Type*} [Ring R] + +theorem add_zero (a : R) : a + 0 = a := by rw [add_comm, zero_add] + +theorem add_neg_cancel (a : R) : a + -a = 0 := by rw [add_comm, neg_add_cancel] + +#check MyRing.add_zero +#check add_zero + +end MyRing + +namespace MyRing +variable {R : Type*} [Ring R] + +theorem neg_add_cancel_left (a b : R) : -a + (a + b) = b := by + rw [← add_assoc, neg_add_cancel, zero_add] + +-- Prove these: +theorem add_neg_cancel_right (a b : R) : a + b + -b = a := by + sorry + +theorem add_left_cancel {a b c : R} (h : a + b = a + c) : b = c := by + sorry + +theorem add_right_cancel {a b c : R} (h : a + b = c + b) : a = c := by + sorry + +theorem mul_zero (a : R) : a * 0 = 0 := by + have h : a * 0 + a * 0 = a * 0 + 0 := by + rw [← mul_add, add_zero, add_zero] + rw [add_left_cancel h] + +theorem zero_mul (a : R) : 0 * a = 0 := by + sorry + +theorem neg_eq_of_add_eq_zero {a b : R} (h : a + b = 0) : -a = b := by + sorry + +theorem eq_neg_of_add_eq_zero {a b : R} (h : a + b = 0) : a = -b := by + sorry + +theorem neg_zero : (-0 : R) = 0 := by + apply neg_eq_of_add_eq_zero + rw [add_zero] + +theorem neg_neg (a : R) : - -a = a := by + sorry + +end MyRing + +-- Examples. +section +variable {R : Type*} [Ring R] + +example (a b : R) : a - b = a + -b := + sub_eq_add_neg a b + +end + +example (a b : ℝ) : a - b = a + -b := + rfl + +example (a b : ℝ) : a - b = a + -b := by + rfl + +namespace MyRing +variable {R : Type*} [Ring R] + +theorem self_sub (a : R) : a - a = 0 := by + sorry + +theorem one_add_one_eq_two : 1 + 1 = (2 : R) := by + norm_num + +theorem two_mul (a : R) : 2 * a = a + a := by + sorry + +end MyRing + +section +variable (A : Type*) [AddGroup A] + +#check (add_assoc : ∀ a b c : A, a + b + c = a + (b + c)) +#check (zero_add : ∀ a : A, 0 + a = a) +#check (neg_add_cancel : ∀ a : A, -a + a = 0) + +end + +section +variable {G : Type*} [Group G] + +#check (mul_assoc : ∀ a b c : G, a * b * c = a * (b * c)) +#check (one_mul : ∀ a : G, 1 * a = a) +#check (inv_mul_cancel : ∀ a : G, a⁻¹ * a = 1) + +namespace MyGroup + +theorem mul_inv_cancel (a : G) : a * a⁻¹ = 1 := by + sorry + +theorem mul_one (a : G) : a * 1 = a := by + sorry + +theorem mul_inv_rev (a b : G) : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by + sorry + +end MyGroup + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S03_Using_Theorems_and_Lemmas.lean b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S03_Using_Theorems_and_Lemmas.lean new file mode 100644 index 0000000..eb0310d --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S03_Using_Theorems_and_Lemmas.lean @@ -0,0 +1,127 @@ +module +public import Mathlib.Analysis.SpecialFunctions.Log.Basic +public import MIL.Common + +variable (a b c d e : ℝ) +open Real + +#check (le_refl : ∀ a : ℝ, a ≤ a) +#check (le_trans : a ≤ b → b ≤ c → a ≤ c) + +section +variable (h : a ≤ b) (h' : b ≤ c) + +#check (le_refl : ∀ a : Real, a ≤ a) +#check (le_refl a : a ≤ a) +#check (le_trans : a ≤ b → b ≤ c → a ≤ c) +#check (le_trans h : b ≤ c → a ≤ c) +#check (le_trans h h' : a ≤ c) + +end + +example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := by + apply le_trans + · apply h₀ + · apply h₁ + +example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := by + apply le_trans h₀ + apply h₁ + +example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := + le_trans h₀ h₁ + +example (x : ℝ) : x ≤ x := by + apply le_refl + +example (x : ℝ) : x ≤ x := + le_refl x + +#check (le_refl : ∀ a, a ≤ a) +#check (le_trans : a ≤ b → b ≤ c → a ≤ c) +#check (lt_of_le_of_lt : a ≤ b → b < c → a < c) +#check (lt_of_lt_of_le : a < b → b ≤ c → a < c) +#check (lt_trans : a < b → b < c → a < c) + +-- Try this. +example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := by + sorry + +example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := by + linarith + +section + +example (h : 2 * a ≤ 3 * b) (h' : 1 ≤ a) (h'' : d = 2) : d + a ≤ 5 * b := by + linarith + +end + +example (h : 1 ≤ a) (h' : b ≤ c) : 2 + a + exp b ≤ 3 * a + exp c := by + linarith [exp_le_exp.mpr h'] + +#check (exp_le_exp : exp a ≤ exp b ↔ a ≤ b) +#check (exp_lt_exp : exp a < exp b ↔ a < b) +#check (log_le_log : 0 < a → a ≤ b → log a ≤ log b) +#check (log_lt_log : 0 < a → a < b → log a < log b) +#check (add_le_add : a ≤ b → c ≤ d → a + c ≤ b + d) +#check (add_le_add_right : a ≤ b → ∀ c, c + a ≤ c + b) +#check (add_le_add_left : a ≤ b → ∀ c, a + c ≤ b + c) +#check (add_lt_add_of_le_of_lt : a ≤ b → c < d → a + c < b + d) +#check (add_lt_add_of_lt_of_le : a < b → c ≤ d → a + c < b + d) +#check (add_lt_add_right : a < b → ∀ c, c + a < c + b) +#check (add_lt_add_left : a < b → ∀ c, a + c < b + c) +#check (add_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a + b) +#check (add_pos : 0 < a → 0 < b → 0 < a + b) +#check (add_pos_of_pos_of_nonneg : 0 < a → 0 ≤ b → 0 < a + b) +#check (exp_pos : ∀ a, 0 < exp a) + +example (h : a ≤ b) : exp a ≤ exp b := by + rw [exp_le_exp] + exact h + +example (h₀ : a ≤ b) (h₁ : c < d) : a + exp c + e < b + exp d + e := by + apply add_lt_add_of_lt_of_le + · apply add_lt_add_of_le_of_lt h₀ + apply exp_lt_exp.mpr h₁ + apply le_refl + +example (h₀ : d ≤ e) : c + exp (a + d) ≤ c + exp (a + e) := by sorry + +example : (0 : ℝ) < 1 := by norm_num + +example (h : a ≤ b) : log (1 + exp a) ≤ log (1 + exp b) := by + have h₀ : 0 < 1 + exp a := by sorry + apply log_le_log h₀ + sorry + +example : 0 ≤ a ^ 2 := by + -- apply? + exact sq_nonneg a + +example (h : a ≤ b) : c - exp b ≤ c - exp a := by + sorry + +example : 2*a*b ≤ a^2 + b^2 := by + have h : 0 ≤ a^2 - 2*a*b + b^2 + calc + a^2 - 2*a*b + b^2 = (a - b)^2 := by ring + _ ≥ 0 := by apply pow_two_nonneg + + calc + 2*a*b = 2*a*b + 0 := by ring + _ ≤ 2*a*b + (a^2 - 2*a*b + b^2) := add_le_add (le_refl _) h + _ = a^2 + b^2 := by ring + +example : 2*a*b ≤ a^2 + b^2 := by + have h : 0 ≤ a^2 - 2*a*b + b^2 + calc + a^2 - 2*a*b + b^2 = (a - b)^2 := by ring + _ ≥ 0 := by apply pow_two_nonneg + linarith + +example : |a*b| ≤ (a^2 + b^2)/2 := by + sorry + +#check abs_le'.mpr + diff --git a/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S04_More_on_Order_and_Divisibility.lean b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S04_More_on_Order_and_Divisibility.lean new file mode 100644 index 0000000..fe9f8e9 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S04_More_on_Order_and_Divisibility.lean @@ -0,0 +1,85 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C02S04 + +section +variable (a b c d : ℝ) + +#check (min_le_left a b : min a b ≤ a) +#check (min_le_right a b : min a b ≤ b) +#check (le_min : c ≤ a → c ≤ b → c ≤ min a b) + +example : min a b = min b a := by + apply le_antisymm + · show min a b ≤ min b a + apply le_min + · apply min_le_right + apply min_le_left + · show min b a ≤ min a b + apply le_min + · apply min_le_right + apply min_le_left + +example : min a b = min b a := by + have h : ∀ x y : ℝ, min x y ≤ min y x := by + intro x y + apply le_min + apply min_le_right + apply min_le_left + apply le_antisymm + apply h + apply h + +example : min a b = min b a := by + apply le_antisymm + repeat + apply le_min + apply min_le_right + apply min_le_left + +example : max a b = max b a := by + sorry +example : min (min a b) c = min a (min b c) := by + sorry +theorem aux : min a b + c ≤ min (a + c) (b + c) := by + sorry +example : min a b + c = min (a + c) (b + c) := by + sorry +#check (abs_add_le : ∀ a b : ℝ, |a + b| ≤ |a| + |b|) + +example : |a| - |b| ≤ |a - b| := + sorry +end + +section +variable (w x y z : ℕ) + +example (h₀ : x ∣ y) (h₁ : y ∣ z) : x ∣ z := + dvd_trans h₀ h₁ + +example : x ∣ y * x * z := by + apply dvd_mul_of_dvd_left + apply dvd_mul_left + +example : x ∣ x ^ 2 := by + apply dvd_mul_left + +example (h : x ∣ w) : x ∣ y * (x * z) + x ^ 2 + w ^ 2 := by + sorry +end + +section +variable (m n : ℕ) + +#check (Nat.gcd_zero_right n : Nat.gcd n 0 = n) +#check (Nat.gcd_zero_left n : Nat.gcd 0 n = n) +#check (Nat.lcm_zero_right n : Nat.lcm n 0 = 0) +#check (Nat.lcm_zero_left n : Nat.lcm 0 n = 0) + +example : Nat.gcd m n = Nat.gcd n m := by + sorry +end + + diff --git a/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S05_Proving_Facts_about_Algebraic_Structures.lean b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S05_Proving_Facts_about_Algebraic_Structures.lean new file mode 100644 index 0000000..d89eb6d --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/S05_Proving_Facts_about_Algebraic_Structures.lean @@ -0,0 +1,113 @@ +module +public import MIL.Common +public import Mathlib.Topology.MetricSpace.Basic + +section +variable {α : Type*} [PartialOrder α] +variable (x y z : α) + +#check x ≤ y +#check (le_refl x : x ≤ x) +#check (le_trans : x ≤ y → y ≤ z → x ≤ z) +#check (le_antisymm : x ≤ y → y ≤ x → x = y) + + +#check x < y +#check (lt_irrefl x : ¬ (x < x)) +#check (lt_trans : x < y → y < z → x < z) +#check (lt_of_le_of_lt : x ≤ y → y < z → x < z) +#check (lt_of_lt_of_le : x < y → y ≤ z → x < z) + +example : x < y ↔ x ≤ y ∧ x ≠ y := + lt_iff_le_and_ne + +end + +section +variable {α : Type*} [Lattice α] +variable (x y z : α) + +#check x ⊓ y +#check (inf_le_left : x ⊓ y ≤ x) +#check (inf_le_right : x ⊓ y ≤ y) +#check (le_inf : z ≤ x → z ≤ y → z ≤ x ⊓ y) +#check x ⊔ y +#check (le_sup_left : x ≤ x ⊔ y) +#check (le_sup_right : y ≤ x ⊔ y) +#check (sup_le : x ≤ z → y ≤ z → x ⊔ y ≤ z) + +example : x ⊓ y = y ⊓ x := by + sorry + +example : x ⊓ y ⊓ z = x ⊓ (y ⊓ z) := by + sorry + +example : x ⊔ y = y ⊔ x := by + sorry + +example : x ⊔ y ⊔ z = x ⊔ (y ⊔ z) := by + sorry + +theorem absorb1 : x ⊓ (x ⊔ y) = x := by + sorry + +theorem absorb2 : x ⊔ x ⊓ y = x := by + sorry + +end + +section +variable {α : Type*} [DistribLattice α] +variable (x y z : α) + +#check (inf_sup_left x y z : x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z) +#check (inf_sup_right x y z : (x ⊔ y) ⊓ z = x ⊓ z ⊔ y ⊓ z) +#check (sup_inf_left x y z : x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z)) +#check (sup_inf_right x y z : x ⊓ y ⊔ z = (x ⊔ z) ⊓ (y ⊔ z)) +end + +section +variable {α : Type*} [Lattice α] +variable (a b c : α) + +example (h : ∀ x y z : α, x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z) : a ⊔ b ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) := by + sorry + +example (h : ∀ x y z : α, x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z)) : a ⊓ (b ⊔ c) = a ⊓ b ⊔ a ⊓ c := by + sorry + +end + +section +variable {R : Type*} [Ring R] [PartialOrder R] [IsStrictOrderedRing R] +variable (a b c : R) + +#check (add_le_add_right : a ≤ b → ∀ c, c + a ≤ c + b) +#check (mul_pos : 0 < a → 0 < b → 0 < a * b) + +#check (mul_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a * b) + +example (h : a ≤ b) : 0 ≤ b - a := by + sorry + +example (h: 0 ≤ b - a) : a ≤ b := by + sorry + +example (h : a ≤ b) (h' : 0 ≤ c) : a * c ≤ b * c := by + sorry + +end + +section +variable {X : Type*} [MetricSpace X] +variable (x y z : X) + +#check (dist_self x : dist x x = 0) +#check (dist_comm x y : dist x y = dist y x) +#check (dist_triangle x y z : dist x z ≤ dist x y + dist y z) + +example (x y : X) : 0 ≤ dist x y := by + sorry + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S01_Calculating.lean b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S01_Calculating.lean new file mode 100644 index 0000000..c23c34a --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S01_Calculating.lean @@ -0,0 +1,52 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic +example (a b c : ℝ) : c * b * a = b * (a * c) := by + rw [mul_comm c b] + rw [mul_assoc b c a] + rw [mul_comm c a] + +example (a b c : ℝ) : a * (b * c) = b * (a * c) := by + rw [← mul_assoc a b c] + rw [mul_comm a b] + rw [mul_assoc b a c] + +example (a b c : ℝ) : a * (b * c) = b * (c * a) := by + rw [mul_comm] + rw [mul_assoc] + +example (a b c : ℝ) : a * (b * c) = b * (a * c) := by + rw [← mul_assoc] + rw [mul_comm a] + rw [mul_assoc] + +example (a b c d e f : ℝ) (h : b * c = e * f) : a * b * c * d = a * e * f * d := by + rw [mul_assoc a] + rw [h] + rw [← mul_assoc] + +example (a b c d : ℝ) (hyp : c = b * a - d) (hyp' : d = a * b) : c = 0 := by + rw [hyp] + rw [hyp'] + rw [mul_comm] + rw [sub_self] + +-- Try these. For the second, use the theorems listed underneath. +section +variable (a b c d : ℝ) + + +example : (a + b) * (c + d) = a * c + a * d + b * c + b * d := by + rw [add_mul, mul_add, mul_add, ← add_assoc] + +example : (a + b) * (c + d) = a * c + a * d + b * c + b * d := by + calc (a + b) * (c + d) = a*(c+d) + b*(c+d) := by rw [add_mul] + _ = (a*c+a*d) + (b*c+b*d) := by rw [mul_add, mul_add] + _ = a * c + a * d + b * c + b * d := by rw [← add_assoc] + +example (a b : ℝ) : (a + b) * (a - b) = a ^ 2 - b ^ 2 := by + rw [add_mul, mul_sub, mul_sub, add_sub, mul_comm b a, + ← pow_two, ← pow_two, sub_add, sub_self, sub_zero] + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S02_Proving_Identities_in_Algebraic_Structures.lean b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S02_Proving_Identities_in_Algebraic_Structures.lean new file mode 100644 index 0000000..4722054 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S02_Proving_Identities_in_Algebraic_Structures.lean @@ -0,0 +1,74 @@ +module +public import Mathlib.Algebra.Ring.Defs +public import Mathlib.Basic.Real.Basic +public import MIL.Common + +namespace MyRing +variable {R : Type*} [Ring R] + +theorem add_neg_cancel_right (a b : R) : a + b + -b = a := by + rw [add_assoc, add_neg_cancel, add_zero] + +theorem add_left_cancel {a b c : R} (h : a + b = a + c) : b = c := by + rw [← neg_add_cancel_left a b, h, neg_add_cancel_left] + +theorem add_right_cancel {a b c : R} (h : a + b = c + b) : a = c := by + rw [← add_neg_cancel_right a b, h, add_neg_cancel_right] + +theorem zero_mul (a : R) : 0 * a = 0 := by + have h : 0 * a + 0 * a = 0 * a + 0 := by rw [← add_mul, add_zero, add_zero] + rw [add_left_cancel h] + +theorem neg_eq_of_add_eq_zero {a b : R} (h : a + b = 0) : -a = b := by + rw [← neg_add_cancel_left a b, h, add_zero] + +theorem eq_neg_of_add_eq_zero {a b : R} (h : a + b = 0) : a = -b := by + apply Eq.symm + apply neg_eq_of_add_eq_zero + rw [add_comm, h] + +theorem neg_zero : (-0 : R) = 0 := by + apply neg_eq_of_add_eq_zero + rw [add_zero] + +theorem neg_neg (a : R) : - -a = a := by + apply neg_eq_of_add_eq_zero + rw [neg_add_cancel] + +end MyRing + +namespace MyRing +variable {R : Type*} [Ring R] + +theorem self_sub (a : R) : a - a = 0 := by + rw [sub_eq_add_neg, add_neg_cancel] + +theorem one_add_one_eq_two : 1 + 1 = (2 : R) := by + norm_num + +theorem two_mul (a : R) : 2 * a = a + a := by + rw [← one_add_one_eq_two, add_mul, one_mul] + +end MyRing + +section +variable {G : Type*} [Group G] + +namespace MyGroup + +theorem mul_inv_cancel (a : G) : a * a⁻¹ = 1 := by + have h : (a * a⁻¹)⁻¹ * (a * a⁻¹ * (a * a⁻¹)) = 1 := by + rw [mul_assoc, ← mul_assoc a⁻¹ a, inv_mul_cancel, one_mul, inv_mul_cancel] + rw [← h, ← mul_assoc, inv_mul_cancel, one_mul] + +theorem mul_one (a : G) : a * 1 = a := by + rw [← inv_mul_cancel a, ← mul_assoc, mul_inv_cancel, one_mul] + +theorem mul_inv_rev (a b : G) : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by + rw [← one_mul (b⁻¹ * a⁻¹), ← inv_mul_cancel (a * b), mul_assoc, mul_assoc, ← mul_assoc b b⁻¹, + mul_inv_cancel, one_mul, mul_inv_cancel, mul_one] + +end MyGroup + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S03_Using_Theorems_and_Lemmas.lean b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S03_Using_Theorems_and_Lemmas.lean new file mode 100644 index 0000000..ddf0019 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S03_Using_Theorems_and_Lemmas.lean @@ -0,0 +1,60 @@ +module +public import Mathlib.Analysis.SpecialFunctions.Log.Basic +public import MIL.Common + +variable (a b c d e : ℝ) +open Real + +example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := by + apply lt_of_le_of_lt h₀ + apply lt_trans h₁ + exact lt_of_le_of_lt h₂ h₃ + +example (h₀ : d ≤ e) : c + exp (a + d) ≤ c + exp (a + e) := by + apply add_le_add_right + rw [exp_le_exp] + apply add_le_add_right h₀ + +-- an alternative using `linarith`. +example (h₀ : d ≤ e) : c + exp (a + d) ≤ c + exp (a + e) := by + have : exp (a + d) ≤ exp (a + e) := by + rw [exp_le_exp] + linarith + linarith [this] + +example (h : a ≤ b) : log (1 + exp a) ≤ log (1 + exp b) := by + have h₀ : 0 < 1 + exp a := by linarith [exp_pos a] + apply log_le_log h₀ + apply add_le_add_right (exp_le_exp.mpr h) + +example (h : a ≤ b) : c - exp b ≤ c - exp a := by + apply sub_le_sub_left + exact exp_le_exp.mpr h + +-- alternatively: +example (h : a ≤ b) : c - exp b ≤ c - exp a := by + linarith [exp_le_exp.mpr h] + +theorem fact1 : a*b*2 ≤ a^2 + b^2 := by + have h : 0 ≤ a^2 - 2*a*b + b^2 + calc + a^2 - 2*a*b + b^2 = (a - b)^2 := by ring + _ ≥ 0 := by apply pow_two_nonneg + linarith + +theorem fact2 : -(a*b)*2 ≤ a^2 + b^2 := by + have h : 0 ≤ a^2 + 2*a*b + b^2 + calc + a^2 + 2*a*b + b^2 = (a + b)^2 := by ring + _ ≥ 0 := by apply pow_two_nonneg + linarith + +example : |a*b| ≤ (a^2 + b^2)/2 := by + have h : (0 : ℝ) < 2 := by norm_num + apply abs_le'.mpr + constructor + · rw [le_div_iff₀ h] + apply fact1 + rw [le_div_iff₀ h] + apply fact2 + diff --git a/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S04_More_on_Order_and_Divisibility.lean b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S04_More_on_Order_and_Divisibility.lean new file mode 100644 index 0000000..47a363a --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S04_More_on_Order_and_Divisibility.lean @@ -0,0 +1,118 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C02S04 + +section +variable (a b c d : ℝ) + +#check (min_le_left a b : min a b ≤ a) +#check (min_le_right a b : min a b ≤ b) +#check (le_min : c ≤ a → c ≤ b → c ≤ min a b) + +example : max a b = max b a := by + apply le_antisymm + repeat + apply max_le + apply le_max_right + apply le_max_left + +example : min (min a b) c = min a (min b c) := by + apply le_antisymm + · apply le_min + · apply le_trans + apply min_le_left + apply min_le_left + apply le_min + · apply le_trans + apply min_le_left + apply min_le_right + apply min_le_right + apply le_min + · apply le_min + · apply min_le_left + apply le_trans + apply min_le_right + apply min_le_left + apply le_trans + apply min_le_right + apply min_le_right + +theorem aux : min a b + c ≤ min (a + c) (b + c) := by + apply le_min + · apply add_le_add_left + apply min_le_left + apply add_le_add_left + apply min_le_right + +example : min a b + c = min (a + c) (b + c) := by + apply le_antisymm + · apply aux + have h : min (a + c) (b + c) = min (a + c) (b + c) - c + c := by rw [sub_add_cancel] + rw [h] + apply add_le_add_left + rw [sub_eq_add_neg] + apply le_trans + apply aux + rw [add_neg_cancel_right, add_neg_cancel_right] + +example : |a| - |b| ≤ |a - b| := + calc + |a| - |b| = |a - b + b| - |b| := by rw [sub_add_cancel] + _ ≤ |a - b| + |b| - |b| := by + apply sub_le_sub_right + apply abs_add_le + _ ≤ |a - b| := by rw [add_sub_cancel_right] + + +-- alternatively +example : |a| - |b| ≤ |a - b| := by + have h := abs_add_le (a - b) b + rw [sub_add_cancel] at h + linarith + +end + +section +variable (w x y z : ℕ) + +example (h₀ : x ∣ y) (h₁ : y ∣ z) : x ∣ z := + dvd_trans h₀ h₁ + +example : x ∣ y * x * z := by + apply dvd_mul_of_dvd_left + apply dvd_mul_left + +example : x ∣ x ^ 2 := by + apply dvd_mul_left + +example (h : x ∣ w) : x ∣ y * (x * z) + x ^ 2 + w ^ 2 := by + apply dvd_add + · apply dvd_add + · apply dvd_mul_of_dvd_right + apply dvd_mul_right + apply dvd_mul_left + rw [pow_two] + apply dvd_mul_of_dvd_right + exact h + +end + +section +variable (m n : ℕ) + +#check (Nat.gcd_zero_right n : Nat.gcd n 0 = n) +#check (Nat.gcd_zero_left n : Nat.gcd 0 n = n) +#check (Nat.lcm_zero_right n : Nat.lcm n 0 = 0) +#check (Nat.lcm_zero_left n : Nat.lcm 0 n = 0) + +example : Nat.gcd m n = Nat.gcd n m := by + apply Nat.dvd_antisymm + repeat + apply Nat.dvd_gcd + apply Nat.gcd_dvd_right + apply Nat.gcd_dvd_left + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S05_Proving_Facts_about_Algebraic_Structures.lean b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S05_Proving_Facts_about_Algebraic_Structures.lean new file mode 100644 index 0000000..09007bf --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S05_Proving_Facts_about_Algebraic_Structures.lean @@ -0,0 +1,135 @@ +module +public import MIL.Common +public import Mathlib.Topology.MetricSpace.Basic + +section +variable {α : Type*} [Lattice α] +variable (x y z : α) + +example : x ⊓ y = y ⊓ x := by + apply le_antisymm + repeat + apply le_inf + · apply inf_le_right + apply inf_le_left + +example : x ⊓ y ⊓ z = x ⊓ (y ⊓ z) := by + apply le_antisymm + · apply le_inf + · trans x ⊓ y + apply inf_le_left + apply inf_le_left + apply le_inf + · trans x ⊓ y + apply inf_le_left + apply inf_le_right + apply inf_le_right + apply le_inf + · apply le_inf + · apply inf_le_left + trans y ⊓ z + apply inf_le_right + apply inf_le_left + trans y ⊓ z + apply inf_le_right + apply inf_le_right + +example : x ⊔ y = y ⊔ x := by + apply le_antisymm + repeat + apply sup_le + · apply le_sup_right + apply le_sup_left + +example : x ⊔ y ⊔ z = x ⊔ (y ⊔ z) := by + apply le_antisymm + · apply sup_le + · apply sup_le + apply le_sup_left + · trans y ⊔ z + apply le_sup_left + apply le_sup_right + trans y ⊔ z + apply le_sup_right + apply le_sup_right + apply sup_le + · trans x ⊔ y + apply le_sup_left + apply le_sup_left + apply sup_le + · trans x ⊔ y + apply le_sup_right + apply le_sup_left + apply le_sup_right + +theorem absorb1 : x ⊓ (x ⊔ y) = x := by + apply le_antisymm + · apply inf_le_left + apply le_inf + · apply le_refl + apply le_sup_left + +theorem absorb2 : x ⊔ x ⊓ y = x := by + apply le_antisymm + · apply sup_le + · apply le_refl + apply inf_le_left + apply le_sup_left + +end + +section +variable {α : Type*} [DistribLattice α] +variable (x y z : α) + +#check (inf_sup_left x y z : x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z) +#check (inf_sup_right x y z : (x ⊔ y) ⊓ z = x ⊓ z ⊔ y ⊓ z) +#check (sup_inf_left x y z : x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z)) +#check (sup_inf_right x y z : x ⊓ y ⊔ z = (x ⊔ z) ⊓ (y ⊔ z)) +end + +section +variable {α : Type*} [Lattice α] +variable (a b c : α) + +example (h : ∀ x y z : α, x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z) : a ⊔ b ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) := by + rw [h, @inf_comm _ _ (a ⊔ b), absorb1, @inf_comm _ _ (a ⊔ b), h, ← sup_assoc, @inf_comm _ _ c a, + absorb2, inf_comm] + +example (h : ∀ x y z : α, x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z)) : a ⊓ (b ⊔ c) = a ⊓ b ⊔ a ⊓ c := by + rw [h, @sup_comm _ _ (a ⊓ b), absorb2, @sup_comm _ _ (a ⊓ b), h, ← inf_assoc, @sup_comm _ _ c a, + absorb1, sup_comm] + +end + +section +variable {R : Type*} [Ring R] [PartialOrder R] [IsStrictOrderedRing R] +variable (a b c : R) + +theorem aux1 (h : a ≤ b) : 0 ≤ b - a := by + rw [← sub_self a, sub_eq_add_neg, sub_eq_add_neg, add_comm, add_comm b] + apply add_le_add_right h + +theorem aux2 (h : 0 ≤ b - a) : a ≤ b := by + rw [← add_zero a, ← sub_add_cancel b a, add_comm (b - a)] + apply add_le_add_right h + +example (h : a ≤ b) (h' : 0 ≤ c) : a * c ≤ b * c := by + have h1 : 0 ≤ (b - a) * c := mul_nonneg (aux1 _ _ h) h' + rw [sub_mul] at h1 + exact aux2 _ _ h1 + +end + +section +variable {X : Type*} [MetricSpace X] +variable (x y z : X) + +example (x y : X) : 0 ≤ dist x y :=by + have : 0 ≤ dist x y + dist y x := by + rw [← dist_self x] + apply dist_triangle + linarith [dist_comm x y] + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S01_Implication_and_the_Universal_Quantifier.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S01_Implication_and_the_Universal_Quantifier.lean new file mode 100644 index 0000000..bfb4777 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S01_Implication_and_the_Universal_Quantifier.lean @@ -0,0 +1,181 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C03S01 + +#check ∀ x : ℝ, 0 ≤ x → |x| = x + +#check ∀ x y ε : ℝ, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε + +theorem my_lemma : ∀ x y ε : ℝ, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε := + sorry + +section +variable (a b δ : ℝ) +variable (h₀ : 0 < δ) (h₁ : δ ≤ 1) +variable (ha : |a| < δ) (hb : |b| < δ) + +#check my_lemma a b δ +#check my_lemma a b δ h₀ h₁ +#check my_lemma a b δ h₀ h₁ ha hb + +end + +theorem my_lemma2 : ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε := + sorry + +section +variable (a b δ : ℝ) +variable (h₀ : 0 < δ) (h₁ : δ ≤ 1) +variable (ha : |a| < δ) (hb : |b| < δ) + +#check my_lemma2 h₀ h₁ ha hb + +end + +theorem my_lemma3 : + ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε := by + intro x y ε epos ele1 xlt ylt + sorry + +theorem my_lemma4 : + ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε := by + intro x y ε epos ele1 xlt ylt + calc + |x * y| = |x| * |y| := sorry + _ ≤ |x| * ε := sorry + _ < 1 * ε := sorry + _ = ε := sorry + +def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, f x ≤ a + +def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, a ≤ f x + +section +variable (f g : ℝ → ℝ) (a b : ℝ) + +example (hfa : FnUb f a) (hgb : FnUb g b) : FnUb (fun x ↦ f x + g x) (a + b) := by + intro x + dsimp + apply add_le_add + apply hfa + apply hgb + +example (hfa : FnLb f a) (hgb : FnLb g b) : FnLb (fun x ↦ f x + g x) (a + b) := + sorry + +example (nnf : FnLb f 0) (nng : FnLb g 0) : FnLb (fun x ↦ f x * g x) 0 := + sorry + +example (hfa : FnUb f a) (hgb : FnUb g b) (nng : FnLb g 0) (nna : 0 ≤ a) : + FnUb (fun x ↦ f x * g x) (a * b) := + sorry + +end + +section +variable {α : Type*} {R : Type*} [AddCommMonoid R] [PartialOrder R] [IsOrderedCancelAddMonoid R] + +#check add_le_add + +def FnUb' (f : α → R) (a : R) : Prop := + ∀ x, f x ≤ a + +theorem fnUb_add {f g : α → R} {a b : R} (hfa : FnUb' f a) (hgb : FnUb' g b) : + FnUb' (fun x ↦ f x + g x) (a + b) := fun x ↦ add_le_add (hfa x) (hgb x) + +end + +example (f : ℝ → ℝ) (h : Monotone f) : ∀ {a b}, a ≤ b → f a ≤ f b := + @h + +section +variable (f g : ℝ → ℝ) + +example (mf : Monotone f) (mg : Monotone g) : Monotone fun x ↦ f x + g x := by + intro a b aleb + apply add_le_add + apply mf aleb + apply mg aleb + +example (mf : Monotone f) (mg : Monotone g) : Monotone fun x ↦ f x + g x := + fun _a _b aleb ↦ add_le_add (mf aleb) (mg aleb) + +example {c : ℝ} (mf : Monotone f) (nnc : 0 ≤ c) : Monotone fun x ↦ c * f x := + sorry + +example (mf : Monotone f) (mg : Monotone g) : Monotone fun x ↦ f (g x) := + sorry + +def FnEven (f : ℝ → ℝ) : Prop := + ∀ x, f x = f (-x) + +def FnOdd (f : ℝ → ℝ) : Prop := + ∀ x, f x = -f (-x) + +example (ef : FnEven f) (eg : FnEven g) : FnEven fun x ↦ f x + g x := by + intro x + calc + (fun x ↦ f x + g x) x = f x + g x := rfl + _ = f (-x) + g (-x) := by rw [ef, eg] + + +example (of : FnOdd f) (og : FnOdd g) : FnEven fun x ↦ f x * g x := by + sorry + +example (ef : FnEven f) (og : FnOdd g) : FnOdd fun x ↦ f x * g x := by + sorry + +example (ef : FnEven f) (og : FnOdd g) : FnEven fun x ↦ f (g x) := by + sorry + +end + +section + +variable {α : Type*} (r s t : Set α) + +example : s ⊆ s := by + intro x xs + exact xs + +theorem Subset.refl : s ⊆ s := fun _x xs ↦ xs + +theorem Subset.trans : r ⊆ s → s ⊆ t → r ⊆ t := by + sorry + +end + +section +variable {α : Type*} [PartialOrder α] +variable (s : Set α) (a b : α) + +def SetUb (s : Set α) (a : α) := + ∀ x, x ∈ s → x ≤ a + +example (h : SetUb s a) (h' : a ≤ b) : SetUb s b := + sorry + +end + +section + +open Function + +example (c : ℝ) : Injective fun x ↦ x + c := by + intro x₁ x₂ h' + exact (add_left_inj c).mp h' + +example {c : ℝ} (h : c ≠ 0) : Injective fun x ↦ c * x := by + sorry + +variable {α : Type*} {β : Type*} {γ : Type*} +variable {g : β → γ} {f : α → β} + +example (injg : Injective g) (injf : Injective f) : Injective fun x ↦ g (f x) := by + sorry + +end diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S02_The_Existential_Quantifier.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S02_The_Existential_Quantifier.lean new file mode 100644 index 0000000..e60910b --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S02_The_Existential_Quantifier.lean @@ -0,0 +1,169 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +set_option autoImplicit true + +namespace C03S02 + +example : ∃ x : ℝ, 2 < x ∧ x < 3 := by + use 5 / 2 + norm_num + +example : ∃ x : ℝ, 2 < x ∧ x < 3 := by + have h1 : 2 < (5 : ℝ) / 2 := by norm_num + have h2 : (5 : ℝ) / 2 < 3 := by norm_num + use 5 / 2, h1, h2 + +example : ∃ x : ℝ, 2 < x ∧ x < 3 := by + have h : 2 < (5 : ℝ) / 2 ∧ (5 : ℝ) / 2 < 3 := by norm_num + use 5 / 2 + +example : ∃ x : ℝ, 2 < x ∧ x < 3 := + have h : 2 < (5 : ℝ) / 2 ∧ (5 : ℝ) / 2 < 3 := by norm_num + ⟨5 / 2, h⟩ + +example : ∃ x : ℝ, 2 < x ∧ x < 3 := + ⟨5 / 2, by norm_num⟩ + +def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, f x ≤ a + +def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, a ≤ f x + +def FnHasUb (f : ℝ → ℝ) := + ∃ a, FnUb f a + +def FnHasLb (f : ℝ → ℝ) := + ∃ a, FnLb f a + +theorem fnUb_add {f g : ℝ → ℝ} {a b : ℝ} (hfa : FnUb f a) (hgb : FnUb g b) : + FnUb (fun x ↦ f x + g x) (a + b) := + fun x ↦ add_le_add (hfa x) (hgb x) + +section + +variable {f g : ℝ → ℝ} + +example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := by + rcases ubf with ⟨a, ubfa⟩ + rcases ubg with ⟨b, ubgb⟩ + use a + b + apply fnUb_add ubfa ubgb + +example (lbf : FnHasLb f) (lbg : FnHasLb g) : FnHasLb fun x ↦ f x + g x := by + sorry + +example {c : ℝ} (ubf : FnHasUb f) (h : c ≥ 0) : FnHasUb fun x ↦ c * f x := by + sorry + +example : FnHasUb f → FnHasUb g → FnHasUb fun x ↦ f x + g x := by + rintro ⟨a, ubfa⟩ ⟨b, ubgb⟩ + exact ⟨a + b, fnUb_add ubfa ubgb⟩ + +example : FnHasUb f → FnHasUb g → FnHasUb fun x ↦ f x + g x := + fun ⟨a, ubfa⟩ ⟨b, ubgb⟩ ↦ ⟨a + b, fnUb_add ubfa ubgb⟩ + +end + +example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := by + obtain ⟨a, ubfa⟩ := ubf + obtain ⟨b, ubgb⟩ := ubg + exact ⟨a + b, fnUb_add ubfa ubgb⟩ + +example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := by + cases ubf + case intro a ubfa => + cases ubg + case intro b ubgb => + exact ⟨a + b, fnUb_add ubfa ubgb⟩ + +example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := by + cases ubf + next a ubfa => + cases ubg + next b ubgb => + exact ⟨a + b, fnUb_add ubfa ubgb⟩ + +example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := by + match ubf, ubg with + | ⟨a, ubfa⟩, ⟨b, ubgb⟩ => + exact ⟨a + b, fnUb_add ubfa ubgb⟩ + +example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := + match ubf, ubg with + | ⟨a, ubfa⟩, ⟨b, ubgb⟩ => + ⟨a + b, fnUb_add ubfa ubgb⟩ + +section + +variable {α : Type*} [CommRing α] + +def SumOfSquares (x : α) := + ∃ a b, x = a ^ 2 + b ^ 2 + +theorem sumOfSquares_mul {x y : α} (sosx : SumOfSquares x) (sosy : SumOfSquares y) : + SumOfSquares (x * y) := by + rcases sosx with ⟨a, b, xeq⟩ + rcases sosy with ⟨c, d, yeq⟩ + rw [xeq, yeq] + use a * c - b * d, a * d + b * c + ring + +theorem sumOfSquares_mul' {x y : α} (sosx : SumOfSquares x) (sosy : SumOfSquares y) : + SumOfSquares (x * y) := by + rcases sosx with ⟨a, b, rfl⟩ + rcases sosy with ⟨c, d, rfl⟩ + use a * c - b * d, a * d + b * c + ring + +end + +section +variable {a b c : ℕ} + +example (divab : a ∣ b) (divbc : b ∣ c) : a ∣ c := by + rcases divab with ⟨d, beq⟩ + rcases divbc with ⟨e, ceq⟩ + rw [ceq, beq] + use d * e; ring + +example (divab : a ∣ b) (divac : a ∣ c) : a ∣ b + c := by + sorry + +end + +section + +open Function + +example {c : ℝ} : Surjective fun x ↦ x + c := by + intro y + use y - c + dsimp; ring + +example {c : ℝ} (h : c ≠ 0) : Surjective fun x ↦ c * x := by + sorry + +example (x y : ℝ) (h : x - y ≠ 0) : (x ^ 2 - y ^ 2) / (x - y) = x + y := by + field_simp [h] + ring + +example {f : ℝ → ℝ} (h : Surjective f) : ∃ x, f x ^ 2 = 4 := by + rcases h 2 with ⟨x, hx⟩ + use x + rw [hx] + norm_num + +end + +section +open Function +variable {α : Type*} {β : Type*} {γ : Type*} +variable {g : β → γ} {f : α → β} + +example (surjg : Surjective g) (surjf : Surjective f) : Surjective fun x ↦ g (f x) := by + sorry + +end diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S03_Negation.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S03_Negation.lean new file mode 100644 index 0000000..46a056e --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S03_Negation.lean @@ -0,0 +1,140 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C03S03 + +section +variable (a b : ℝ) + +example (h : a < b) : ¬b < a := by + intro h' + have : a < a := lt_trans h h' + apply lt_irrefl a this + +def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, f x ≤ a + +def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, a ≤ f x + +def FnHasUb (f : ℝ → ℝ) := + ∃ a, FnUb f a + +def FnHasLb (f : ℝ → ℝ) := + ∃ a, FnLb f a + +variable (f : ℝ → ℝ) + +example (h : ∀ a, ∃ x, f x > a) : ¬FnHasUb f := by + intro fnub + rcases fnub with ⟨a, fnuba⟩ + rcases h a with ⟨x, hx⟩ + have : f x ≤ a := fnuba x + linarith + +example (h : ∀ a, ∃ x, f x < a) : ¬FnHasLb f := + sorry + +example : ¬FnHasUb fun x ↦ x := + sorry + +#check (not_le_of_gt : a > b → ¬a ≤ b) +#check (not_lt_of_ge : a ≥ b → ¬a < b) +#check (lt_of_not_ge : ¬a ≥ b → a < b) +#check (le_of_not_gt : ¬a > b → a ≤ b) + +example (h : Monotone f) (h' : f a < f b) : a < b := by + sorry + +example (h : a ≤ b) (h' : f b < f a) : ¬Monotone f := by + sorry + +example : ¬∀ {f : ℝ → ℝ}, Monotone f → ∀ {a b}, f a ≤ f b → a ≤ b := by + intro h + let f := fun x : ℝ ↦ (0 : ℝ) + have monof : Monotone f := by sorry + have h' : f 1 ≤ f 0 := le_refl _ + sorry + +example (x : ℝ) (h : ∀ ε > 0, x < ε) : x ≤ 0 := by + sorry + +end + +section +variable {α : Type*} (P : α → Prop) (Q : Prop) + +example (h : ¬∃ x, P x) : ∀ x, ¬P x := by + sorry + +example (h : ∀ x, ¬P x) : ¬∃ x, P x := by + sorry + +example (h : ¬∀ x, P x) : ∃ x, ¬P x := by + sorry + +example (h : ∃ x, ¬P x) : ¬∀ x, P x := by + sorry + +example (h : ¬∀ x, P x) : ∃ x, ¬P x := by + by_contra h' + apply h + intro x + show P x + by_contra h'' + exact h' ⟨x, h''⟩ + +example (h : ¬¬Q) : Q := by + sorry + +example (h : Q) : ¬¬Q := by + sorry + +end + +section +variable (f : ℝ → ℝ) + +example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by + sorry + +example (h : ¬∀ a, ∃ x, f x > a) : FnHasUb f := by + push Not at h + exact h + +example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by + dsimp only [FnHasUb, FnUb] at h + push Not at h + exact h + +example (h : ¬Monotone f) : ∃ x y, x ≤ y ∧ f y < f x := by + sorry + +example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by + contrapose! h + exact h + +example (x : ℝ) (h : ∀ ε > 0, x ≤ ε) : x ≤ 0 := by + contrapose! h + use x / 2 + constructor <;> linarith + +end + +section +variable (a : ℕ) + +example (h : 0 < 0) : a > 37 := by + exfalso + apply lt_irrefl 0 h + +example (h : 0 < 0) : a > 37 := + absurd h (lt_irrefl 0) + +example (h : 0 < 0) : a > 37 := by + have h' : ¬0 < 0 := lt_irrefl 0 + contradiction + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S04_Conjunction_and_Iff.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S04_Conjunction_and_Iff.lean new file mode 100644 index 0000000..6f71eab --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S04_Conjunction_and_Iff.lean @@ -0,0 +1,158 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic +public import Mathlib.Data.Nat.Prime.Basic + +namespace C03S04 + +example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬y ≤ x) : x ≤ y ∧ x ≠ y := by + constructor + · assumption + intro h + apply h₁ + rw [h] + +example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬y ≤ x) : x ≤ y ∧ x ≠ y := + ⟨h₀, fun h ↦ h₁ (by rw [h])⟩ + +example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬y ≤ x) : x ≤ y ∧ x ≠ y := + have h : x ≠ y := by + contrapose! h₁ + rw [h₁] + ⟨h₀, h⟩ + +example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by + rcases h with ⟨h₀, h₁⟩ + contrapose! h₁ + exact le_antisymm h₀ h₁ + +example {x y : ℝ} : x ≤ y ∧ x ≠ y → ¬y ≤ x := by + rintro ⟨h₀, h₁⟩ h' + exact h₁ (le_antisymm h₀ h') + +example {x y : ℝ} : x ≤ y ∧ x ≠ y → ¬y ≤ x := + fun ⟨h₀, h₁⟩ h' ↦ h₁ (le_antisymm h₀ h') + +example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by + have ⟨h₀, h₁⟩ := h + contrapose! h₁ + exact le_antisymm h₀ h₁ + +example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by + cases h + case intro h₀ h₁ => + contrapose! h₁ + exact le_antisymm h₀ h₁ + +example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by + cases h + next h₀ h₁ => + contrapose! h₁ + exact le_antisymm h₀ h₁ + +example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by + match h with + | ⟨h₀, h₁⟩ => + contrapose! h₁ + exact le_antisymm h₀ h₁ + +example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by + intro h' + apply h.right + exact le_antisymm h.left h' + +example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := + fun h' ↦ h.right (le_antisymm h.left h') + +example {m n : ℕ} (h : m ∣ n ∧ m ≠ n) : m ∣ n ∧ ¬n ∣ m := + sorry + +example : ∃ x : ℝ, 2 < x ∧ x < 4 := + ⟨5 / 2, by norm_num, by norm_num⟩ + +example (x y : ℝ) : (∃ z : ℝ, x < z ∧ z < y) → x < y := by + rintro ⟨z, xltz, zlty⟩ + exact lt_trans xltz zlty + +example (x y : ℝ) : (∃ z : ℝ, x < z ∧ z < y) → x < y := + fun ⟨_z, xltz, zlty⟩ ↦ lt_trans xltz zlty + +example : ∃ x : ℝ, 2 < x ∧ x < 4 := by + use 5 / 2 + constructor <;> norm_num + +example : ∃ m n : ℕ, 4 < m ∧ m < n ∧ n < 10 ∧ Nat.Prime m ∧ Nat.Prime n := by + use 5 + use 7 + norm_num + +example {x y : ℝ} : x ≤ y ∧ x ≠ y → x ≤ y ∧ ¬y ≤ x := by + rintro ⟨h₀, h₁⟩ + use h₀ + exact fun h' ↦ h₁ (le_antisymm h₀ h') + +example {x y : ℝ} (h : x ≤ y) : ¬y ≤ x ↔ x ≠ y := by + constructor + · contrapose! + rintro rfl + rfl + contrapose! + exact le_antisymm h + +example {x y : ℝ} (h : x ≤ y) : ¬y ≤ x ↔ x ≠ y := + ⟨fun h₀ h₁ ↦ h₀ (by rw [h₁]), fun h₀ h₁ ↦ h₀ (le_antisymm h h₁)⟩ + +example {x y : ℝ} : x ≤ y ∧ ¬y ≤ x ↔ x ≤ y ∧ x ≠ y := + sorry + +theorem aux {x y : ℝ} (h : x ^ 2 + y ^ 2 = 0) : x = 0 := + have h' : x ^ 2 = 0 := by sorry + eq_zero_of_pow_eq_zero h' + +example (x y : ℝ) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := + sorry + +section + +example (x : ℝ) : |x + 3| < 5 → -8 < x ∧ x < 2 := by + rw [abs_lt] + intro h + constructor <;> linarith + +example : 3 ∣ Nat.gcd 6 15 := by + rw [Nat.dvd_gcd_iff] + constructor <;> norm_num + +end + +theorem not_monotone_iff {f : ℝ → ℝ} : ¬Monotone f ↔ ∃ x y, x ≤ y ∧ f x > f y := by + rw [Monotone] + push Not + rfl + +example : ¬Monotone fun x : ℝ ↦ -x := by + sorry + +section +variable {α : Type*} [PartialOrder α] +variable (a b : α) + +example : a < b ↔ a ≤ b ∧ a ≠ b := by + rw [lt_iff_le_not_ge] + sorry + +end + +section +variable {α : Type*} [Preorder α] +variable (a b c : α) + +example : ¬a < a := by + rw [lt_iff_le_not_ge] + sorry + +example : a < b → b < c → a < c := by + simp only [lt_iff_le_not_ge] + sorry + +end diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S05_Disjunction.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S05_Disjunction.lean new file mode 100644 index 0000000..22f36b4 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S05_Disjunction.lean @@ -0,0 +1,129 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C03S05 + +section + +variable {x y : ℝ} + +example (h : y > x ^ 2) : y > 0 ∨ y < -1 := by + left + linarith [pow_two_nonneg x] + +example (h : -y > x ^ 2 + 1) : y > 0 ∨ y < -1 := by + right + linarith [pow_two_nonneg x] + +example (h : y > 0) : y > 0 ∨ y < -1 := + Or.inl h + +example (h : y < -1) : y > 0 ∨ y < -1 := + Or.inr h + +example : x < |y| → x < y ∨ x < -y := by + rcases le_or_gt 0 y with h | h + · rw [abs_of_nonneg h] + intro h; left; exact h + · rw [abs_of_neg h] + intro h; right; exact h + +example : x < |y| → x < y ∨ x < -y := by + cases le_or_gt 0 y + case inl h => + rw [abs_of_nonneg h] + intro h; left; exact h + case inr h => + rw [abs_of_neg h] + intro h; right; exact h + +example : x < |y| → x < y ∨ x < -y := by + cases le_or_gt 0 y + next h => + rw [abs_of_nonneg h] + intro h; left; exact h + next h => + rw [abs_of_neg h] + intro h; right; exact h + +example : x < |y| → x < y ∨ x < -y := by + match le_or_gt 0 y with + | Or.inl h => + rw [abs_of_nonneg h] + intro h; left; exact h + | Or.inr h => + rw [abs_of_neg h] + intro h; right; exact h + +namespace MyAbs + +theorem le_abs_self (x : ℝ) : x ≤ |x| := by + sorry + +theorem neg_le_abs (x : ℝ) : -x ≤ |x| := by + sorry + +theorem abs_add_le (x y : ℝ) : |x + y| ≤ |x| + |y| := by + sorry + +theorem lt_abs : x < |y| ↔ x < y ∨ x < -y := by + sorry + +theorem abs_lt : |x| < y ↔ -y < x ∧ x < y := by + sorry + +end MyAbs + +end + +example {x : ℝ} (h : x ≠ 0) : x < 0 ∨ x > 0 := by + rcases lt_trichotomy x 0 with xlt | xeq | xgt + · left + exact xlt + · contradiction + · right; exact xgt + +example {m n k : ℕ} (h : m ∣ n ∨ m ∣ k) : m ∣ n * k := by + rcases h with ⟨a, rfl⟩ | ⟨b, rfl⟩ + · rw [mul_assoc] + apply dvd_mul_right + · rw [mul_comm, mul_assoc] + apply dvd_mul_right + +example {z : ℝ} (h : ∃ x y, z = x ^ 2 + y ^ 2 ∨ z = x ^ 2 + y ^ 2 + 1) : z ≥ 0 := by + sorry + +example {x : ℝ} (h : x ^ 2 = 1) : x = 1 ∨ x = -1 := by + sorry + +example {x y : ℝ} (h : x ^ 2 = y ^ 2) : x = y ∨ x = -y := by + sorry + +section +variable {R : Type*} [CommRing R] [IsDomain R] +variable (x y : R) + +example (h : x ^ 2 = 1) : x = 1 ∨ x = -1 := by + sorry + +example (h : x ^ 2 = y ^ 2) : x = y ∨ x = -y := by + sorry + +end + +example (P : Prop) : ¬¬P → P := by + intro h + cases em P + · assumption + · contradiction + +example (P : Prop) : ¬¬P → P := by + intro h + by_cases h' : P + · assumption + contradiction + +example (P Q : Prop) : P → Q ↔ ¬P ∨ Q := by + sorry + diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S06_Sequences_and_Convergence.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S06_Sequences_and_Convergence.lean new file mode 100644 index 0000000..c2333dd --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/S06_Sequences_and_Convergence.lean @@ -0,0 +1,104 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C03S06 + +def ConvergesTo (s : ℕ → ℝ) (a : ℝ) := + ∀ ε > 0, ∃ N, ∀ n ≥ N, |s n - a| < ε + +example : (fun x y : ℝ ↦ (x + y) ^ 2) = fun x y : ℝ ↦ x ^ 2 + 2 * x * y + y ^ 2 := by + ext + ring + +example (a b : ℝ) : |a| = |a - b + b| := by + congr + ring + +example {a : ℝ} (h : 1 < a) : a < a * a := by + convert! (mul_lt_mul_iff_left₀ _).2 h + · rw [one_mul] + exact lt_trans zero_lt_one h + +theorem convergesTo_const (a : ℝ) : ConvergesTo (fun _x : ℕ ↦ a) a := by + intro ε εpos + use 0 + intro n nge + rw [sub_self, abs_zero] + apply εpos + +theorem convergesTo_add {s t : ℕ → ℝ} {a b : ℝ} + (cs : ConvergesTo s a) (ct : ConvergesTo t b) : + ConvergesTo (fun n ↦ s n + t n) (a + b) := by + intro ε εpos + dsimp -- this line is not needed but cleans up the goal a bit. + have ε2pos : 0 < ε / 2 := by linarith + rcases cs (ε / 2) ε2pos with ⟨Ns, hs⟩ + rcases ct (ε / 2) ε2pos with ⟨Nt, ht⟩ + use max Ns Nt + sorry + +theorem convergesTo_mul_const {s : ℕ → ℝ} {a : ℝ} (c : ℝ) (cs : ConvergesTo s a) : + ConvergesTo (fun n ↦ c * s n) (c * a) := by + by_cases h : c = 0 + · convert convergesTo_const 0 + · rw [h] + ring + rw [h] + ring + have acpos : 0 < |c| := abs_pos.mpr h + sorry + +theorem exists_abs_le_of_convergesTo {s : ℕ → ℝ} {a : ℝ} (cs : ConvergesTo s a) : + ∃ N b, ∀ n, N ≤ n → |s n| < b := by + rcases cs 1 zero_lt_one with ⟨N, h⟩ + use N, |a| + 1 + sorry + +theorem aux {s t : ℕ → ℝ} {a : ℝ} (cs : ConvergesTo s a) (ct : ConvergesTo t 0) : + ConvergesTo (fun n ↦ s n * t n) 0 := by + intro ε εpos + dsimp + rcases exists_abs_le_of_convergesTo cs with ⟨N₀, B, h₀⟩ + have Bpos : 0 < B := lt_of_le_of_lt (abs_nonneg _) (h₀ N₀ (le_refl _)) + have pos₀ : ε / B > 0 := div_pos εpos Bpos + rcases ct _ pos₀ with ⟨N₁, h₁⟩ + sorry + +theorem convergesTo_mul {s t : ℕ → ℝ} {a b : ℝ} + (cs : ConvergesTo s a) (ct : ConvergesTo t b) : + ConvergesTo (fun n ↦ s n * t n) (a * b) := by + have h₁ : ConvergesTo (fun n ↦ s n * (t n + -b)) 0 := by + apply aux cs + convert convergesTo_add ct (convergesTo_const (-b)) + ring + have := convergesTo_add h₁ (convergesTo_mul_const b cs) + convert convergesTo_add h₁ (convergesTo_mul_const b cs) using 1 + · ext; ring + ring + +theorem convergesTo_unique {s : ℕ → ℝ} {a b : ℝ} + (sa : ConvergesTo s a) (sb : ConvergesTo s b) : + a = b := by + by_contra abne + have : |a - b| > 0 := by sorry + let ε := |a - b| / 2 + have εpos : ε > 0 := by + change |a - b| / 2 > 0 + linarith + rcases sa ε εpos with ⟨Na, hNa⟩ + rcases sb ε εpos with ⟨Nb, hNb⟩ + let N := max Na Nb + have absa : |s N - a| < ε := by sorry + have absb : |s N - b| < ε := by sorry + have : |a - b| < |a - b| := by sorry + exact lt_irrefl _ this + +section +variable {α : Type*} [LinearOrder α] + +def ConvergesTo' (s : α → ℝ) (a : ℝ) := + ∀ ε > 0, ∃ N, ∀ n ≥ N, |s n - a| < ε + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S01_Implication_and_the_Universal_Quantifier.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S01_Implication_and_the_Universal_Quantifier.lean new file mode 100644 index 0000000..2fbb266 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S01_Implication_and_the_Universal_Quantifier.lean @@ -0,0 +1,141 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C03S01 + +theorem my_lemma4 : + ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε := by + intro x y ε epos ele1 xlt ylt + calc + |x * y| = |x| * |y| := by apply abs_mul + _ ≤ |x| * ε := by apply mul_le_mul; linarith; linarith; apply abs_nonneg; apply abs_nonneg; + _ < 1 * ε := by apply mul_lt_mul_of_pos_right _ epos; linarith + _ = ε := by apply one_mul + +def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, f x ≤ a + +def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, a ≤ f x + +section +variable (f g : ℝ → ℝ) (a b : ℝ) + +example (hfa : FnLb f a) (hgb : FnLb g b) : FnLb (fun x ↦ f x + g x) (a + b) := by + intro x + apply add_le_add + apply hfa + apply hgb + +example (nnf : FnLb f 0) (nng : FnLb g 0) : FnLb (fun x ↦ f x * g x) 0 := by + intro x + apply mul_nonneg + apply nnf + apply nng + +example (hfa : FnUb f a) (hgb : FnUb g b) (nng : FnLb g 0) (nna : 0 ≤ a) : + FnUb (fun x ↦ f x * g x) (a * b) := by + intro x + apply mul_le_mul + apply hfa + apply hgb + apply nng + apply nna + +end + +section +variable (f g : ℝ → ℝ) + +example {c : ℝ} (mf : Monotone f) (nnc : 0 ≤ c) : Monotone fun x ↦ c * f x := by + intro a b aleb + apply mul_le_mul_of_nonneg_left _ nnc + apply mf aleb + +example {c : ℝ} (mf : Monotone f) (nnc : 0 ≤ c) : Monotone fun x ↦ c * f x := + fun _a _b aleb ↦ mul_le_mul_of_nonneg_left (mf aleb) nnc + +example (mf : Monotone f) (mg : Monotone g) : Monotone fun x ↦ f (g x) := by + intro a b aleb + apply mf + apply mg + apply aleb + +example (mf : Monotone f) (mg : Monotone g) : Monotone fun x ↦ f (g x) := + fun _a _b aleb ↦ mf (mg aleb) + +def FnEven (f : ℝ → ℝ) : Prop := + ∀ x, f x = f (-x) + +def FnOdd (f : ℝ → ℝ) : Prop := + ∀ x, f x = -f (-x) + +example (of : FnOdd f) (og : FnOdd g) : FnEven fun x ↦ f x * g x := by + intro x + calc + (fun x ↦ f x * g x) x = f x * g x := rfl + _ = f (-x) * g (-x) := by rw [of, og, neg_mul_neg] + + +example (ef : FnEven f) (og : FnOdd g) : FnOdd fun x ↦ f x * g x := by + intro x + dsimp + rw [ef, og, neg_mul_eq_mul_neg] + +example (ef : FnEven f) (og : FnOdd g) : FnEven fun x ↦ f (g x) := by + intro x + dsimp + rw [og, ← ef] + +end + +section + +variable {α : Type*} (r s t : Set α) + +example : r ⊆ s → s ⊆ t → r ⊆ t := by + intro rsubs ssubt x xr + apply ssubt + apply rsubs + apply xr + +theorem Subset.trans : r ⊆ s → s ⊆ t → r ⊆ t := + fun rsubs ssubt _x xr ↦ ssubt (rsubs xr) + +end + +section +variable {α : Type*} [PartialOrder α] +variable (s : Set α) (a b : α) + +def SetUb (s : Set α) (a : α) := + ∀ x, x ∈ s → x ≤ a + +example (h : SetUb s a) (h' : a ≤ b) : SetUb s b := by + intro x xs + apply le_trans (h x xs) h' + +example (h : SetUb s a) (h' : a ≤ b) : SetUb s b := + fun x xs ↦ le_trans (h x xs) h' + +end + +section + +open Function + +example {c : ℝ} (h : c ≠ 0) : Injective fun x ↦ c * x := by + intro x₁ x₂ h' + apply (mul_right_inj' h).mp h' + +variable {α : Type*} {β : Type*} {γ : Type*} +variable {g : β → γ} {f : α → β} + +example (injg : Injective g) (injf : Injective f) : Injective fun x ↦ g (f x) := by + intro x₁ x₂ h + apply injf + apply injg + apply h + +end diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S02_The_Existential_Quantifier.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S02_The_Existential_Quantifier.lean new file mode 100644 index 0000000..097a548 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S02_The_Existential_Quantifier.lean @@ -0,0 +1,86 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +set_option autoImplicit true + +namespace C03S02 + +def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, f x ≤ a + +def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, a ≤ f x + +def FnHasUb (f : ℝ → ℝ) := + ∃ a, FnUb f a + +def FnHasLb (f : ℝ → ℝ) := + ∃ a, FnLb f a + +theorem fnUb_add {f g : ℝ → ℝ} {a b : ℝ} (hfa : FnUb f a) (hgb : FnUb g b) : + FnUb (fun x ↦ f x + g x) (a + b) := + fun x ↦ add_le_add (hfa x) (hgb x) + +section + +variable {f g : ℝ → ℝ} + +example (lbf : FnHasLb f) (lbg : FnHasLb g) : FnHasLb fun x ↦ f x + g x := by + rcases lbf with ⟨a, lbfa⟩ + rcases lbg with ⟨b, lbgb⟩ + use a + b + intro x + exact add_le_add (lbfa x) (lbgb x) + +example {c : ℝ} (ubf : FnHasUb f) (h : c ≥ 0) : FnHasUb fun x ↦ c * f x := by + rcases ubf with ⟨a, ubfa⟩ + use c * a + intro x + exact mul_le_mul_of_nonneg_left (ubfa x) h + +end + +section +variable {a b c : ℕ} + +example (divab : a ∣ b) (divbc : b ∣ c) : a ∣ c := by + rcases divab with ⟨d, rfl⟩ + rcases divbc with ⟨e, rfl⟩ + use d * e; ring + +example (divab : a ∣ b) (divac : a ∣ c) : a ∣ b + c := by + rcases divab with ⟨d, rfl⟩ + rcases divac with ⟨e, rfl⟩ + use d + e; ring + +end + +section + +open Function + +example {c : ℝ} (h : c ≠ 0) : Surjective fun x ↦ c * x := by + intro y + use y / c + dsimp; rw [mul_div_cancel₀ _ h] + +example {c : ℝ} (h : c ≠ 0) : Surjective fun x ↦ c * x := by + intro y + use y / c + field_simp + +end + +section +open Function +variable {α : Type*} {β : Type*} {γ : Type*} +variable {g : β → γ} {f : α → β} + +example (surjg : Surjective g) (surjf : Surjective f) : Surjective fun x ↦ g (f x) := by + intro z + rcases surjg z with ⟨y, rfl⟩ + rcases surjf y with ⟨x, rfl⟩ + use x + +end diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S03_Negation.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S03_Negation.lean new file mode 100644 index 0000000..d66021f --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S03_Negation.lean @@ -0,0 +1,112 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C03S03 + +section +variable (a b : ℝ) + +def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, f x ≤ a + +def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := + ∀ x, a ≤ f x + +def FnHasUb (f : ℝ → ℝ) := + ∃ a, FnUb f a + +def FnHasLb (f : ℝ → ℝ) := + ∃ a, FnLb f a + +variable (f : ℝ → ℝ) + +example (h : ∀ a, ∃ x, f x < a) : ¬FnHasLb f := by + rintro ⟨a, ha⟩ + rcases h a with ⟨x, hx⟩ + have := ha x + linarith + +example : ¬FnHasUb fun x ↦ x := by + rintro ⟨a, ha⟩ + have : a + 1 ≤ a := ha (a + 1) + linarith + +example (h : Monotone f) (h' : f a < f b) : a < b := by + apply lt_of_not_ge + intro h'' + apply absurd h' + apply not_lt_of_ge (h h'') + +example (h : a ≤ b) (h' : f b < f a) : ¬Monotone f := by + intro h'' + apply absurd h' + apply not_lt_of_ge + apply h'' h + +example : ¬∀ {f : ℝ → ℝ}, Monotone f → ∀ {a b}, f a ≤ f b → a ≤ b := by + intro h + let f := fun x : ℝ ↦ (0 : ℝ) + have monof : Monotone f := by + intro a b leab + rfl + have h' : f 1 ≤ f 0 := le_refl _ + have : (1 : ℝ) ≤ 0 := h monof h' + linarith + +example (x : ℝ) (h : ∀ ε > 0, x < ε) : x ≤ 0 := by + apply le_of_not_gt + intro h' + linarith [h _ h'] + +end + +section +variable {α : Type*} (P : α → Prop) (Q : Prop) + +example (h : ¬∃ x, P x) : ∀ x, ¬P x := by + intro x Px + apply h + use x + +example (h : ∀ x, ¬P x) : ¬∃ x, P x := by + rintro ⟨x, Px⟩ + exact h x Px + +example (h : ∃ x, ¬P x) : ¬∀ x, P x := by + intro h' + rcases h with ⟨x, nPx⟩ + apply nPx + apply h' + +example (h : ¬¬Q) : Q := by + by_contra h' + exact h h' + +example (h : Q) : ¬¬Q := by + intro h' + exact h' h + +end + +section +variable (f : ℝ → ℝ) + +example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by + intro a + by_contra h' + apply h + use a + intro x + apply le_of_not_gt + intro h'' + apply h' + use x + +example (h : ¬Monotone f) : ∃ x y, x ≤ y ∧ f y < f x := by + rw [Monotone] at h + push Not at h + exact h + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S04_Conjunction_and_Iff.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S04_Conjunction_and_Iff.lean new file mode 100644 index 0000000..7390257 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S04_Conjunction_and_Iff.lean @@ -0,0 +1,95 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic +public import Mathlib.Data.Nat.Prime.Basic + +namespace C03S04 + +example {m n : ℕ} (h : m ∣ n ∧ m ≠ n) : m ∣ n ∧ ¬n ∣ m := by + rcases h with ⟨h0, h1⟩ + constructor + · exact h0 + intro h2 + apply h1 + apply Nat.dvd_antisymm h0 h2 + +example {x y : ℝ} : x ≤ y ∧ ¬y ≤ x ↔ x ≤ y ∧ x ≠ y := by + constructor + · rintro ⟨h0, h1⟩ + constructor + · exact h0 + intro h2 + apply h1 + rw [h2] + rintro ⟨h0, h1⟩ + constructor + · exact h0 + intro h2 + apply h1 + apply le_antisymm h0 h2 + +theorem aux {x y : ℝ} (h : x ^ 2 + y ^ 2 = 0) : x = 0 := + have h' : x ^ 2 = 0 := by linarith [pow_two_nonneg x, pow_two_nonneg y] + eq_zero_of_pow_eq_zero h' + +example (x y : ℝ) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by + constructor + · intro h + constructor + · exact aux h + rw [add_comm] at h + exact aux h + rintro ⟨rfl, rfl⟩ + norm_num + +theorem not_monotone_iff {f : ℝ → ℝ} : ¬Monotone f ↔ ∃ x y, x ≤ y ∧ f x > f y := by + rw [Monotone] + push Not + rfl + +example : ¬Monotone fun x : ℝ ↦ -x := by + rw [not_monotone_iff] + use 0, 1 + norm_num + +section +variable {α : Type*} [PartialOrder α] +variable (a b : α) + +example : a < b ↔ a ≤ b ∧ a ≠ b := by + rw [lt_iff_le_not_ge] + constructor + · rintro ⟨h0, h1⟩ + constructor + · exact h0 + intro h2 + apply h1 + rw [h2] + rintro ⟨h0, h1⟩ + constructor + · exact h0 + intro h2 + apply h1 + apply le_antisymm h0 h2 + +end + +section +variable {α : Type*} [Preorder α] +variable (a b c : α) + +example : ¬a < a := by + rw [lt_iff_le_not_ge] + rintro ⟨h0, h1⟩ + exact h1 h0 + +example : a < b → b < c → a < c := by + simp only [lt_iff_le_not_ge] + rintro ⟨h0, h1⟩ ⟨h2, h3⟩ + constructor + · apply le_trans h0 h2 + intro h4 + apply h1 + apply le_trans h2 h4 + +end diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S05_Disjunction.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S05_Disjunction.lean new file mode 100644 index 0000000..03bcf88 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S05_Disjunction.lean @@ -0,0 +1,142 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C03S05 + +section + +variable {x y : ℝ} + +namespace MyAbs + +theorem le_abs_self (x : ℝ) : x ≤ |x| := by + rcases le_or_gt 0 x with h | h + · rw [abs_of_nonneg h] + · rw [abs_of_neg h] + linarith + +theorem neg_le_abs (x : ℝ) : -x ≤ |x| := by + rcases le_or_gt 0 x with h | h + · rw [abs_of_nonneg h] + linarith + · rw [abs_of_neg h] + +theorem abs_add_le (x y : ℝ) : |x + y| ≤ |x| + |y| := by + rcases le_or_gt 0 (x + y) with h | h + · rw [abs_of_nonneg h] + linarith [le_abs_self x, le_abs_self y] + · rw [abs_of_neg h] + linarith [neg_le_abs x, neg_le_abs y] + +theorem lt_abs : x < |y| ↔ x < y ∨ x < -y := by + rcases le_or_gt 0 y with h | h + · rw [abs_of_nonneg h] + constructor + · intro h' + left + exact h' + · intro h' + rcases h' with h' | h' + · exact h' + · linarith + rw [abs_of_neg h] + constructor + · intro h' + right + exact h' + · intro h' + rcases h' with h' | h' + · linarith + · exact h' + +theorem abs_lt : |x| < y ↔ -y < x ∧ x < y := by + rcases le_or_gt 0 x with h | h + · rw [abs_of_nonneg h] + constructor + · intro h' + constructor + · linarith + exact h' + · intro h' + rcases h' with ⟨h1, h2⟩ + exact h2 + · rw [abs_of_neg h] + constructor + · intro h' + constructor + · linarith + · linarith + · intro h' + linarith + +end MyAbs + +end + +example {z : ℝ} (h : ∃ x y, z = x ^ 2 + y ^ 2 ∨ z = x ^ 2 + y ^ 2 + 1) : z ≥ 0 := by + rcases h with ⟨x, y, rfl | rfl⟩ <;> linarith [sq_nonneg x, sq_nonneg y] + +example {x : ℝ} (h : x ^ 2 = 1) : x = 1 ∨ x = -1 := by + have h' : x ^ 2 - 1 = 0 := by rw [h, sub_self] + have h'' : (x + 1) * (x - 1) = 0 := by + rw [← h'] + ring + rcases eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 | h1 + · right + exact eq_neg_iff_add_eq_zero.mpr h1 + · left + exact eq_of_sub_eq_zero h1 + +example {x y : ℝ} (h : x ^ 2 = y ^ 2) : x = y ∨ x = -y := by + have h' : x ^ 2 - y ^ 2 = 0 := by rw [h, sub_self] + have h'' : (x + y) * (x - y) = 0 := by + rw [← h'] + ring + rcases eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 | h1 + · right + exact eq_neg_iff_add_eq_zero.mpr h1 + · left + exact eq_of_sub_eq_zero h1 + +section +variable {R : Type*} [CommRing R] [IsDomain R] +variable (x y : R) + +example (h : x ^ 2 = 1) : x = 1 ∨ x = -1 := by + have h' : x ^ 2 - 1 = 0 := by rw [h, sub_self] + have h'' : (x + 1) * (x - 1) = 0 := by + rw [← h'] + ring + rcases eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 | h1 + · right + exact eq_neg_iff_add_eq_zero.mpr h1 + · left + exact eq_of_sub_eq_zero h1 + +example (h : x ^ 2 = y ^ 2) : x = y ∨ x = -y := by + have h' : x ^ 2 - y ^ 2 = 0 := by rw [h, sub_self] + have h'' : (x + y) * (x - y) = 0 := by + rw [← h'] + ring + rcases eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 | h1 + · right + exact eq_neg_iff_add_eq_zero.mpr h1 + · left + exact eq_of_sub_eq_zero h1 + +end + +example (P Q : Prop) : P → Q ↔ ¬P ∨ Q := by + constructor + · intro h + by_cases h' : P + · right + exact h h' + · left + exact h' + rintro (h | h) + · intro h' + exact absurd h' h + · intro + exact h diff --git a/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S06_Sequences_and_Convergence.lean b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S06_Sequences_and_Convergence.lean new file mode 100644 index 0000000..42d5fc6 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S06_Sequences_and_Convergence.lean @@ -0,0 +1,132 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C03S06 + +def ConvergesTo (s : ℕ → ℝ) (a : ℝ) := + ∀ ε > 0, ∃ N, ∀ n ≥ N, |s n - a| < ε + +theorem convergesTo_const (a : ℝ) : ConvergesTo (fun _x : ℕ ↦ a) a := by + intro ε εpos + use 0 + intro n nge + rw [sub_self, abs_zero] + apply εpos + +theorem convergesTo_add {s t : ℕ → ℝ} {a b : ℝ} + (cs : ConvergesTo s a) (ct : ConvergesTo t b) : + ConvergesTo (fun n ↦ s n + t n) (a + b) := by + intro ε εpos + dsimp + have ε2pos : 0 < ε / 2 := by linarith + rcases cs (ε / 2) ε2pos with ⟨Ns, hs⟩ + rcases ct (ε / 2) ε2pos with ⟨Nt, ht⟩ + use max Ns Nt + intro n hn + have ngeNs : n ≥ Ns := le_of_max_le_left hn + have ngeNt : n ≥ Nt := le_of_max_le_right hn + calc + |s n + t n - (a + b)| = |s n - a + (t n - b)| := by + congr + ring + _ ≤ |s n - a| + |t n - b| := (abs_add_le _ _) + _ < ε / 2 + ε / 2 := (add_lt_add (hs n ngeNs) (ht n ngeNt)) + _ = ε := by norm_num + +theorem convergesTo_mul_const {s : ℕ → ℝ} {a : ℝ} (c : ℝ) (cs : ConvergesTo s a) : + ConvergesTo (fun n ↦ c * s n) (c * a) := by + by_cases h : c = 0 + · convert convergesTo_const 0 + · rw [h] + ring + rw [h] + ring + have acpos : 0 < |c| := abs_pos.mpr h + intro ε εpos + dsimp + have εcpos : 0 < ε / |c| := by apply div_pos εpos acpos + rcases cs (ε / |c|) εcpos with ⟨Ns, hs⟩ + use Ns + intro n ngt + calc + |c * s n - c * a| = |c| * |s n - a| := by rw [← abs_mul, mul_sub] + _ < |c| * (ε / |c|) := (mul_lt_mul_of_pos_left (hs n ngt) acpos) + _ = ε := mul_div_cancel₀ _ (ne_of_lt acpos).symm + +theorem exists_abs_le_of_convergesTo {s : ℕ → ℝ} {a : ℝ} (cs : ConvergesTo s a) : + ∃ N b, ∀ n, N ≤ n → |s n| < b := by + rcases cs 1 zero_lt_one with ⟨N, h⟩ + use N, |a| + 1 + intro n ngt + calc + |s n| = |s n - a + a| := by + congr + abel + _ ≤ |s n - a| + |a| := (abs_add_le _ _) + _ < |a| + 1 := by linarith [h n ngt] + +theorem aux {s t : ℕ → ℝ} {a : ℝ} (cs : ConvergesTo s a) (ct : ConvergesTo t 0) : + ConvergesTo (fun n ↦ s n * t n) 0 := by + intro ε εpos + dsimp + rcases exists_abs_le_of_convergesTo cs with ⟨N₀, B, h₀⟩ + have Bpos : 0 < B := lt_of_le_of_lt (abs_nonneg _) (h₀ N₀ (le_refl _)) + have pos₀ : ε / B > 0 := div_pos εpos Bpos + rcases ct _ pos₀ with ⟨N₁, h₁⟩ + use max N₀ N₁ + intro n ngt + have ngeN₀ : n ≥ N₀ := le_of_max_le_left ngt + have ngeN₁ : n ≥ N₁ := le_of_max_le_right ngt + calc + |s n * t n - 0| = |s n| * |t n - 0| := by rw [sub_zero, abs_mul, sub_zero] + _ < B * (ε / B) := (mul_lt_mul'' (h₀ n ngeN₀) (h₁ n ngeN₁) (abs_nonneg _) (abs_nonneg _)) + _ = ε := mul_div_cancel₀ _ (ne_of_lt Bpos).symm + +theorem convergesTo_mul {s t : ℕ → ℝ} {a b : ℝ} + (cs : ConvergesTo s a) (ct : ConvergesTo t b) : + ConvergesTo (fun n ↦ s n * t n) (a * b) := by + have h₁ : ConvergesTo (fun n ↦ s n * (t n + -b)) 0 := by + apply aux cs + convert convergesTo_add ct (convergesTo_const (-b)) + ring + have := convergesTo_add h₁ (convergesTo_mul_const b cs) + convert convergesTo_add h₁ (convergesTo_mul_const b cs) using 1 + · ext; ring + ring + +theorem convergesTo_unique {s : ℕ → ℝ} {a b : ℝ} + (sa : ConvergesTo s a) (sb : ConvergesTo s b) : + a = b := by + by_contra abne + have : |a - b| > 0 := by + apply lt_of_le_of_ne + · apply abs_nonneg + intro h'' + apply abne + apply eq_of_abs_sub_eq_zero h''.symm + let ε := |a - b| / 2 + have εpos : ε > 0 := by + change |a - b| / 2 > 0 + linarith + rcases sa ε εpos with ⟨Na, hNa⟩ + rcases sb ε εpos with ⟨Nb, hNb⟩ + let N := max Na Nb + have absa : |s N - a| < ε := by + apply hNa + apply le_max_left + have absb : |s N - b| < ε := by + apply hNb + apply le_max_right + have : |a - b| < |a - b| + calc + |a - b| = |(-(s N - a)) + (s N - b)| := by + congr + ring + _ ≤ |(-(s N - a))| + |s N - b| := (abs_add_le _ _) + _ = |s N - a| + |s N - b| := by rw [abs_neg] + _ < ε + ε := (add_lt_add absa absb) + _ = |a - b| := by norm_num [ε] + + exact lt_irrefl _ this + diff --git a/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S01_Sets.lean b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S01_Sets.lean new file mode 100644 index 0000000..1192fdc --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S01_Sets.lean @@ -0,0 +1,238 @@ +module +public import Mathlib.Data.Nat.Prime.Basic +public import MIL.Common + +section +variable {α : Type*} +variable (s t u : Set α) +open Set + +example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by + rw [subset_def, inter_def, inter_def] + rw [subset_def] at h + simp only [mem_ofPred] + rintro x ⟨xs, xu⟩ + exact ⟨h _ xs, xu⟩ + +example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by + simp only [subset_def, mem_inter_iff] at * + rintro x ⟨xs, xu⟩ + exact ⟨h _ xs, xu⟩ + +example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by + intro x xsu + exact ⟨h xsu.1, xsu.2⟩ + +example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := + fun _x ⟨xs, xu⟩ ↦ ⟨h xs, xu⟩ + +example : s ∩ (t ∪ u) ⊆ s ∩ t ∪ s ∩ u := by + intro x hx + have xs : x ∈ s := hx.1 + have xtu : x ∈ t ∪ u := hx.2 + rcases xtu with xt | xu + · left + show x ∈ s ∩ t + exact ⟨xs, xt⟩ + · right + show x ∈ s ∩ u + exact ⟨xs, xu⟩ + +example : s ∩ (t ∪ u) ⊆ s ∩ t ∪ s ∩ u := by + rintro x ⟨xs, xt | xu⟩ + · left; exact ⟨xs, xt⟩ + · right; exact ⟨xs, xu⟩ + +example : s ∩ t ∪ s ∩ u ⊆ s ∩ (t ∪ u) := by + sorry +example : (s \ t) \ u ⊆ s \ (t ∪ u) := by + intro x xstu + have xs : x ∈ s := xstu.1.1 + have xnt : x ∉ t := xstu.1.2 + have xnu : x ∉ u := xstu.2 + constructor + · exact xs + intro xtu + -- x ∈ t ∨ x ∈ u + rcases xtu with xt | xu + · show False; exact xnt xt + · show False; exact xnu xu + +example : (s \ t) \ u ⊆ s \ (t ∪ u) := by + rintro x ⟨⟨xs, xnt⟩, xnu⟩ + use xs + rintro (xt | xu) <;> contradiction + +example : s \ (t ∪ u) ⊆ (s \ t) \ u := by + sorry +example : s ∩ t = t ∩ s := by + ext x + simp only [mem_inter_iff] + constructor + · rintro ⟨xs, xt⟩; exact ⟨xt, xs⟩ + · rintro ⟨xt, xs⟩; exact ⟨xs, xt⟩ + +example : s ∩ t = t ∩ s := + Set.ext fun _x ↦ ⟨fun ⟨xs, xt⟩ ↦ ⟨xt, xs⟩, fun ⟨xt, xs⟩ ↦ ⟨xs, xt⟩⟩ + +example : s ∩ t = t ∩ s := by ext x; simp [and_comm] + +example : s ∩ t = t ∩ s := by + apply Subset.antisymm + · rintro x ⟨xs, xt⟩; exact ⟨xt, xs⟩ + · rintro x ⟨xt, xs⟩; exact ⟨xs, xt⟩ + +example : s ∩ t = t ∩ s := + Subset.antisymm sorry sorry +example : s ∩ (s ∪ t) = s := by + sorry + +example : s ∪ s ∩ t = s := by + sorry + +example : s \ t ∪ t = s ∪ t := by + sorry + +example : s \ t ∪ t \ s = (s ∪ t) \ (s ∩ t) := by + sorry + +def evens : Set ℕ := + { n | Even n } + +def odds : Set ℕ := + { n | ¬Even n } + +example : evens ∪ odds = univ := by + rw [evens, odds] + ext n + simp [-Nat.not_even_iff_odd] + apply Classical.em + +example (x : ℕ) (h : x ∈ (∅ : Set ℕ)) : False := + h + +example (x : ℕ) : x ∈ (univ : Set ℕ) := + trivial + +example : { n | Nat.Prime n } ∩ { n | n > 2 } ⊆ { n | ¬Even n } := by + sorry + +#print Prime + +#print Nat.Prime + +example (n : ℕ) : Prime n ↔ Nat.Prime n := + Nat.prime_iff.symm + +example (n : ℕ) (h : Prime n) : Nat.Prime n := by + rw [Nat.prime_iff] + exact h + +example (n : ℕ) (h : Prime n) : Nat.Prime n := by + rwa [Nat.prime_iff] + +end + +section + +variable (s t : Set ℕ) + +example (h₀ : ∀ x ∈ s, ¬Even x) (h₁ : ∀ x ∈ s, Prime x) : ∀ x ∈ s, ¬Even x ∧ Prime x := by + intro x xs + constructor + · apply h₀ x xs + apply h₁ x xs + +example (h : ∃ x ∈ s, ¬Even x ∧ Prime x) : ∃ x ∈ s, Prime x := by + rcases h with ⟨x, xs, _, prime_x⟩ + use x, xs + +section +variable (ssubt : s ⊆ t) + +example (h₀ : ∀ x ∈ t, ¬Even x) (h₁ : ∀ x ∈ t, Prime x) : ∀ x ∈ s, ¬Even x ∧ Prime x := by + sorry + +example (h : ∃ x ∈ s, ¬Even x ∧ Prime x) : ∃ x ∈ t, Prime x := by + sorry + +end + +end + +section +variable {α I : Type*} +variable (A B : I → Set α) +variable (s : Set α) + +open Set + +example : (s ∩ ⋃ i, A i) = ⋃ i, A i ∩ s := by + ext x + simp only [mem_inter_iff, mem_iUnion] + constructor + · rintro ⟨xs, ⟨i, xAi⟩⟩ + exact ⟨i, xAi, xs⟩ + rintro ⟨i, xAi, xs⟩ + exact ⟨xs, ⟨i, xAi⟩⟩ + +example : (⋂ i, A i ∩ B i) = (⋂ i, A i) ∩ ⋂ i, B i := by + ext x + simp only [mem_inter_iff, mem_iInter] + constructor + · intro h + constructor + · intro i + exact (h i).1 + intro i + exact (h i).2 + rintro ⟨h1, h2⟩ i + constructor + · exact h1 i + exact h2 i + + +example : (s ∪ ⋂ i, A i) = ⋂ i, A i ∪ s := by + sorry + +def primes : Set ℕ := + { x | Nat.Prime x } + +example : (⋃ p ∈ primes, { x | p ^ 2 ∣ x }) = { x | ∃ p ∈ primes, p ^ 2 ∣ x } :=by + ext + rw [mem_iUnion₂] + simp + +example : (⋃ p ∈ primes, { x | p ^ 2 ∣ x }) = { x | ∃ p ∈ primes, p ^ 2 ∣ x } := by + ext + simp + +example : (⋂ p ∈ primes, { x | ¬p ∣ x }) ⊆ { x | x = 1 } := by + intro x + contrapose! + simp + apply Nat.exists_prime_and_dvd + +example : (⋃ p ∈ primes, { x | x ≤ p }) = univ := by + sorry + +end + +section + +open Set + +variable {α : Type*} (s : Set (Set α)) + +example : ⋃₀ s = ⋃ t ∈ s, t := by + ext x + rw [mem_iUnion₂] + simp + +example : ⋂₀ s = ⋂ t ∈ s, t := by + ext x + rw [mem_iInter₂] + rfl + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S02_Functions.lean b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S02_Functions.lean new file mode 100644 index 0000000..e691d46 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S02_Functions.lean @@ -0,0 +1,191 @@ +module +public import MIL.Common +public import Mathlib.Data.Set.Function +public import Mathlib.Analysis.SpecialFunctions.Log.Basic + +section + +variable {α β : Type*} +variable (f : α → β) +variable (s t : Set α) +variable (u v : Set β) + +open Function +open Set + +example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := by + ext + rfl + +example : f '' (s ∪ t) = f '' s ∪ f '' t := by + ext y; constructor + · rintro ⟨x, xs | xt, rfl⟩ + · left + use x, xs + right + use x, xt + rintro (⟨x, xs, rfl⟩ | ⟨x, xt, rfl⟩) + · use x, Or.inl xs + use x, Or.inr xt + +example : s ⊆ f ⁻¹' (f '' s) := by + intro x xs + show f x ∈ f '' s + use x, xs + +example : f '' s ⊆ v ↔ s ⊆ f ⁻¹' v := by + sorry + +example (h : Injective f) : f ⁻¹' (f '' s) ⊆ s := by + sorry + +example : f '' (f ⁻¹' u) ⊆ u := by + sorry + +example (h : Surjective f) : u ⊆ f '' (f ⁻¹' u) := by + sorry + +example (h : s ⊆ t) : f '' s ⊆ f '' t := by + sorry + +example (h : u ⊆ v) : f ⁻¹' u ⊆ f ⁻¹' v := by + sorry + +example : f ⁻¹' (u ∪ v) = f ⁻¹' u ∪ f ⁻¹' v := by + sorry + +example : f '' (s ∩ t) ⊆ f '' s ∩ f '' t := by + sorry + +example (h : Injective f) : f '' s ∩ f '' t ⊆ f '' (s ∩ t) := by + sorry + +example : f '' s \ f '' t ⊆ f '' (s \ t) := by + sorry + +example : f ⁻¹' u \ f ⁻¹' v ⊆ f ⁻¹' (u \ v) := by + sorry + +example : f '' s ∩ v = f '' (s ∩ f ⁻¹' v) := by + sorry + +example : f '' (s ∩ f ⁻¹' u) ⊆ f '' s ∩ u := by + sorry + +example : s ∩ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∩ u) := by + sorry + +example : s ∪ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∪ u) := by + sorry + +variable {I : Type*} (A : I → Set α) (B : I → Set β) + +example : (f '' ⋃ i, A i) = ⋃ i, f '' A i := by + sorry + +example : (f '' ⋂ i, A i) ⊆ ⋂ i, f '' A i := by + sorry + +example (i : I) (injf : Injective f) : (⋂ i, f '' A i) ⊆ f '' ⋂ i, A i := by + sorry + +example : (f ⁻¹' ⋃ i, B i) = ⋃ i, f ⁻¹' B i := by + sorry + +example : (f ⁻¹' ⋂ i, B i) = ⋂ i, f ⁻¹' B i := by + sorry + +example : InjOn f s ↔ ∀ x₁ ∈ s, ∀ x₂ ∈ s, f x₁ = f x₂ → x₁ = x₂ := + Iff.refl _ + +end + +section + +open Set Real + +example : InjOn log { x | x > 0 } := by + intro x xpos y ypos e + calc + x = exp (log x) := by rw [exp_log xpos] + _ = exp (log y) := by rw [e] + _ = y := by rw [exp_log ypos] + + +example : range exp = { y | y > 0 } := by + ext y; constructor + · rintro ⟨x, rfl⟩ + apply exp_pos + intro ypos + use log y + rw [exp_log ypos] + +example : InjOn sqrt { x | x ≥ 0 } := by + sorry + +example : InjOn (fun x ↦ x ^ 2) { x : ℝ | x ≥ 0 } := by + sorry + +example : sqrt '' { x | x ≥ 0 } = { y | y ≥ 0 } := by + sorry + +example : (range fun x ↦ x ^ 2) = { y : ℝ | y ≥ 0 } := by + sorry + +end + +section +variable {α β : Type*} [Inhabited α] + +#check (default : α) + +variable (P : α → Prop) (h : ∃ x, P x) + +#check Classical.choose h + +example : P (Classical.choose h) := + Classical.choose_spec h + +noncomputable section + +open Classical + +def inverse (f : α → β) : β → α := fun y : β ↦ + if h : ∃ x, f x = y then Classical.choose h else default + +theorem inverse_spec {f : α → β} (y : β) (h : ∃ x, f x = y) : f (inverse f y) = y := by + rw [inverse, dite_eq_left h] + exact Classical.choose_spec h + +variable (f : α → β) + +open Function + +example : Injective f ↔ LeftInverse (inverse f) f := + sorry + +example : Surjective f ↔ RightInverse (inverse f) f := + sorry + +end + +section +variable {α : Type*} +open Function + +theorem Cantor : ∀ f : α → Set α, ¬Surjective f := by + intro f surjf + let S := { i | i ∉ f i } + rcases surjf S with ⟨j, h⟩ + have h₁ : j ∉ f j := by + intro h' + have : j ∉ f j := by rwa [h] at h' + contradiction + have h₂ : j ∈ S + sorry + have h₃ : j ∉ S + sorry + contradiction + +-- COMMENTS: TODO: improve this +end diff --git a/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S03_The_Schroeder_Bernstein_Theorem.lean b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S03_The_Schroeder_Bernstein_Theorem.lean new file mode 100644 index 0000000..3aa98bb --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S03_The_Schroeder_Bernstein_Theorem.lean @@ -0,0 +1,97 @@ +module +public import Mathlib.Data.Set.Function +public import MIL.Common + +open Set +open Function + +noncomputable section +open Classical +variable {α β : Type*} [Nonempty β] + +section +variable (f : α → β) (g : β → α) + +def sbAux : ℕ → Set α + | 0 => univ \ g '' univ + | n + 1 => g '' (f '' sbAux n) + +def sbSet := + ⋃ n, sbAux f g n + +def sbFun (x : α) : β := + if x ∈ sbSet f g then f x else invFun g x + +theorem sb_right_inv {x : α} (hx : x ∉ sbSet f g) : g (invFun g x) = x := by + have : x ∈ g '' univ := by + contrapose! hx + rw [sbSet, mem_iUnion] + use 0 + rw [sbAux, mem_sdiff] + sorry + have : ∃ y, g y = x := by + sorry + sorry + +theorem sb_injective (hf : Injective f) : Injective (sbFun f g) := by + set A := sbSet f g with A_def + set h := sbFun f g with h_def + intro x₁ x₂ (hxeq : h x₁ = h x₂) + show x₁ = x₂ + simp only [h_def, sbFun, ← A_def] at hxeq + by_cases xA : x₁ ∈ A ∨ x₂ ∈ A + · wlog x₁A : x₁ ∈ A generalizing x₁ x₂ hxeq xA + · symm + apply this hxeq.symm xA.symm (xA.resolve_left x₁A) + have x₂A : x₂ ∈ A := by + apply _root_.not_imp_self.mp + intro (x₂nA : x₂ ∉ A) + rw [ite_eq_left x₁A, ite_eq_right x₂nA] at hxeq + rw [A_def, sbSet, mem_iUnion] at x₁A + have x₂eq : x₂ = g (f x₁) := by + sorry + rcases x₁A with ⟨n, hn⟩ + rw [A_def, sbSet, mem_iUnion] + use n + 1 + simp [sbAux] + exact ⟨x₁, hn, x₂eq.symm⟩ + sorry + push Not at xA + sorry + +theorem sb_surjective (hg : Injective g) : Surjective (sbFun f g) := by + set A := sbSet f g with A_def + set h := sbFun f g with h_def + intro y + by_cases gyA : g y ∈ A + · rw [A_def, sbSet, mem_iUnion] at gyA + rcases gyA with ⟨n, hn⟩ + rcases n with _ | n + · simp [sbAux] at hn + simp [sbAux] at hn + rcases hn with ⟨x, xmem, hx⟩ + use x + have : x ∈ A := by + rw [A_def, sbSet, mem_iUnion] + exact ⟨n, xmem⟩ + rw [h_def, sbFun, ite_eq_left this] + apply hg hx + + sorry + +end + +theorem schroeder_bernstein {f : α → β} {g : β → α} (hf : Injective f) (hg : Injective g) : + ∃ h : α → β, Bijective h := + ⟨sbFun f g, sb_injective f g hf, sb_surjective f g hg⟩ + +-- Auxiliary information +section +variable (g : β → α) (x : α) + +#check (invFun g : α → β) +#check (leftInverse_invFun : Injective g → LeftInverse (invFun g) g) +#check (leftInverse_invFun : Injective g → ∀ y, invFun g (g y) = y) +#check (invFun_eq : (∃ y, g y = x) → g (invFun g x) = x) + +end diff --git a/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S01_Sets.lean b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S01_Sets.lean new file mode 100644 index 0000000..e7e2389 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S01_Sets.lean @@ -0,0 +1,150 @@ +module +public import Mathlib.Data.Nat.Prime.Basic +public import MIL.Common + +section +variable {α : Type*} +variable (s t u : Set α) +open Set + +example : s ∩ t ∪ s ∩ u ⊆ s ∩ (t ∪ u) := by + rintro x (⟨xs, xt⟩ | ⟨xs, xu⟩) + · use xs; left; exact xt + · use xs; right; exact xu + +example : s \ (t ∪ u) ⊆ (s \ t) \ u := by + rintro x ⟨xs, xntu⟩ + constructor + use xs + · intro xt + exact xntu (Or.inl xt) + intro xu + apply xntu (Or.inr xu) + +example : s ∩ t = t ∩ s := + Subset.antisymm + (fun _x ⟨xs, xt⟩ ↦ ⟨xt, xs⟩) fun _x ⟨xt, xs⟩ ↦ ⟨xs, xt⟩ + +example : s ∩ (s ∪ t) = s := by + ext x; constructor + · rintro ⟨xs, _⟩ + exact xs + · intro xs + use xs; left; exact xs + +example : s ∪ s ∩ t = s := by + ext x; constructor + · rintro (xs | ⟨xs, xt⟩) <;> exact xs + · intro xs; left; exact xs + +example : s \ t ∪ t = s ∪ t := by + ext x; constructor + · rintro (⟨xs, nxt⟩ | xt) + · left + exact xs + · right + exact xt + by_cases h : x ∈ t + · intro + right + exact h + rintro (xs | xt) + · left + use xs + right; exact xt + +example : s \ t ∪ t \ s = (s ∪ t) \ (s ∩ t) := by + ext x; constructor + · rintro (⟨xs, xnt⟩ | ⟨xt, xns⟩) + · constructor + left + exact xs + rintro ⟨_, xt⟩ + contradiction + · constructor + right + exact xt + rintro ⟨xs, _⟩ + contradiction + rintro ⟨xs | xt, nxst⟩ + · left + use xs + intro xt + apply nxst + constructor <;> assumption + · right; use xt; intro xs + apply nxst + constructor <;> assumption + +example : { n | Nat.Prime n } ∩ { n | n > 2 } ⊆ { n | ¬Even n } := by + intro n + simp + intro nprime n_gt + rcases Nat.Prime.eq_two_or_odd nprime with h | h + · rw [h] + linarith + · rw [Nat.odd_iff, h] + +end + +section + +variable (s t : Set ℕ) + +section +variable (ssubt : s ⊆ t) + +example (h₀ : ∀ x ∈ t, ¬Even x) (h₁ : ∀ x ∈ t, Prime x) : ∀ x ∈ s, ¬Even x ∧ Prime x := by + intro x xs + constructor + · apply h₀ x (ssubt xs) + apply h₁ x (ssubt xs) + +example (h : ∃ x ∈ s, ¬Even x ∧ Prime x) : ∃ x ∈ t, Prime x := by + rcases h with ⟨x, xs, _, px⟩ + use x, ssubt xs + +end + +end + +section +variable {α I : Type*} +variable (A B : I → Set α) +variable (s : Set α) + +open Set + +example : (s ∪ ⋂ i, A i) = ⋂ i, A i ∪ s := by + ext x + simp only [mem_union, mem_iInter] + constructor + · rintro (xs | xI) + · intro i + right + exact xs + intro i + left + exact xI i + intro h + by_cases xs : x ∈ s + · left + exact xs + right + intro i + cases h i + · assumption + contradiction + +def primes : Set ℕ := + { x | Nat.Prime x } + +example : (⋃ p ∈ primes, { x | x ≤ p }) = univ := by + apply eq_univ_of_forall + intro x + simp + rcases Nat.exists_infinite_primes x with ⟨p, pge, primep⟩ + use p, primep + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S02_Functions.lean b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S02_Functions.lean new file mode 100644 index 0000000..7b1415d --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S02_Functions.lean @@ -0,0 +1,249 @@ +module +public import MIL.Common +public import Mathlib.Data.Set.Function +public import Mathlib.Analysis.SpecialFunctions.Log.Basic + +section + +variable {α β : Type*} +variable (f : α → β) +variable (s t : Set α) +variable (u v : Set β) + +open Function +open Set + +example : f '' s ⊆ v ↔ s ⊆ f ⁻¹' v := by + constructor + · intro h x xs + have : f x ∈ f '' s := mem_image_of_mem _ xs + exact h this + intro h y ymem + rcases ymem with ⟨x, xs, fxeq⟩ + rw [← fxeq] + apply h xs + +example (h : Injective f) : f ⁻¹' (f '' s) ⊆ s := by + rintro x ⟨y, ys, fxeq⟩ + rw [← h fxeq] + exact ys + +example : f '' (f ⁻¹' u) ⊆ u := by + rintro y ⟨x, xmem, rfl⟩ + exact xmem + +example (h : Surjective f) : u ⊆ f '' (f ⁻¹' u) := by + intro y yu + rcases h y with ⟨x, fxeq⟩ + use x + constructor + · show f x ∈ u + rw [fxeq] + exact yu + exact fxeq + +example (h : s ⊆ t) : f '' s ⊆ f '' t := by + rintro y ⟨x, xs, fxeq⟩ + use x, h xs + +example (h : u ⊆ v) : f ⁻¹' u ⊆ f ⁻¹' v := by + intro x; apply h + +example : f ⁻¹' (u ∪ v) = f ⁻¹' u ∪ f ⁻¹' v := by + ext x; rfl + +example : f '' (s ∩ t) ⊆ f '' s ∩ f '' t := by + rintro y ⟨x, ⟨xs, xt⟩, rfl⟩ + constructor + · use x, xs + · use x, xt + +example (h : Injective f) : f '' s ∩ f '' t ⊆ f '' (s ∩ t) := by + rintro y ⟨⟨x₁, x₁s, rfl⟩, ⟨x₂, x₂t, fx₂eq⟩⟩ + use x₁ + constructor + · use x₁s + rw [← h fx₂eq] + exact x₂t + · rfl + +example : f '' s \ f '' t ⊆ f '' (s \ t) := by + rintro y ⟨⟨x₁, x₁s, rfl⟩, h⟩ + use x₁ + constructor + · constructor + · exact x₁s + · intro h' + apply h + use x₁, h' + · rfl + +example : f ⁻¹' u \ f ⁻¹' v ⊆ f ⁻¹' (u \ v) := + fun _x ↦ id + +example : f '' s ∩ v = f '' (s ∩ f ⁻¹' v) := by + ext y; constructor + · rintro ⟨⟨x, xs, rfl⟩, fxv⟩ + use x, ⟨xs, fxv⟩ + rintro ⟨x, ⟨⟨xs, fxv⟩, rfl⟩⟩ + exact ⟨⟨x, xs, rfl⟩, fxv⟩ + +example : f '' (s ∩ f ⁻¹' u) ⊆ f '' s ∩ u := by + rintro y ⟨x, ⟨xs, fxu⟩, rfl⟩ + exact ⟨⟨x, xs, rfl⟩, fxu⟩ + +example : s ∩ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∩ u) := by + rintro x ⟨xs, fxu⟩ + exact ⟨⟨x, xs, rfl⟩, fxu⟩ + +example : s ∪ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∪ u) := by + rintro x (xs | fxu) + · left + exact ⟨x, xs, rfl⟩ + right; exact fxu + +variable {I : Type*} (A : I → Set α) (B : I → Set β) + +example : (f '' ⋃ i, A i) = ⋃ i, f '' A i := by + ext y; simp + constructor + · rintro ⟨x, ⟨i, xAi⟩, fxeq⟩ + use i, x + rintro ⟨i, x, xAi, fxeq⟩ + exact ⟨x, ⟨i, xAi⟩, fxeq⟩ + +example : (f '' ⋂ i, A i) ⊆ ⋂ i, f '' A i := by + intro y; simp + intro x h fxeq i + use x + exact ⟨h i, fxeq⟩ + +example (i : I) (injf : Injective f) : (⋂ i, f '' A i) ⊆ f '' ⋂ i, A i := by + intro y; simp + intro h + rcases h i with ⟨x, xAi, fxeq⟩ + use x; constructor + · intro i' + rcases h i' with ⟨x', x'Ai, fx'eq⟩ + have : f x = f x' := by rw [fxeq, fx'eq] + have : x = x' := injf this + rw [this] + exact x'Ai + exact fxeq + +example : (f ⁻¹' ⋃ i, B i) = ⋃ i, f ⁻¹' B i := by + ext x + simp + +example : (f ⁻¹' ⋂ i, B i) = ⋂ i, f ⁻¹' B i := by + ext x + simp + +end + +section + +open Set Real + +example : InjOn sqrt { x | x ≥ 0 } := by + intro x xnonneg y ynonneg e + calc + x = sqrt x ^ 2 := by rw [sq_sqrt xnonneg] + _ = sqrt y ^ 2 := by rw [e] + _ = y := by rw [sq_sqrt ynonneg] + + +example : InjOn (fun x ↦ x ^ 2) { x : ℝ | x ≥ 0 } := by + intro x xnonneg y ynonneg e + dsimp at * + calc + x = sqrt (x ^ 2) := by rw [sqrt_sq xnonneg] + _ = sqrt (y ^ 2) := by rw [e] + _ = y := by rw [sqrt_sq ynonneg] + + +example : sqrt '' { x | x ≥ 0 } = { y | y ≥ 0 } := by + ext y; constructor + · rintro ⟨x, ⟨xnonneg, rfl⟩⟩ + apply sqrt_nonneg + intro ynonneg + use y ^ 2 + dsimp at * + constructor + apply pow_nonneg ynonneg + apply sqrt_sq + assumption + +example : (range fun x ↦ x ^ 2) = { y : ℝ | y ≥ 0 } := by + ext y + constructor + · rintro ⟨x, rfl⟩ + dsimp at * + apply pow_two_nonneg + intro ynonneg + use sqrt y + exact sq_sqrt ynonneg + +end + +section +variable {α β : Type*} [Inhabited α] + +noncomputable section + +open Classical + +def inverse (f : α → β) : β → α := fun y : β ↦ + if h : ∃ x, f x = y then Classical.choose h else default + +theorem inverse_spec {f : α → β} (y : β) (h : ∃ x, f x = y) : f (inverse f y) = y := by + rw [inverse, dite_eq_left h] + exact Classical.choose_spec h + +variable (f : α → β) + +open Function + +example : Injective f ↔ LeftInverse (inverse f) f := by + constructor + · intro h y + apply h + apply inverse_spec + use y + intro h x1 x2 e + rw [← h x1, ← h x2, e] + +example : Injective f ↔ LeftInverse (inverse f) f := + ⟨fun h y ↦ h (inverse_spec _ ⟨y, rfl⟩), fun h x1 x2 e ↦ by rw [← h x1, ← h x2, e]⟩ + +example : Surjective f ↔ RightInverse (inverse f) f := by + constructor + · intro h y + apply inverse_spec + apply h + intro h y + use inverse f y + apply h + +example : Surjective f ↔ RightInverse (inverse f) f := + ⟨fun h _y ↦ inverse_spec _ (h _), fun h y ↦ ⟨inverse f y, h _⟩⟩ + +end + +section +variable {α : Type*} +open Function + +theorem Cantor : ∀ f : α → Set α, ¬Surjective f := by + intro f surjf + let S := { i | i ∉ f i } + rcases surjf S with ⟨j, h⟩ + have h₁ : j ∉ f j := by + intro h' + have : j ∉ f j := by rwa [h] at h' + contradiction + have h₂ : j ∈ S := h₁ + have h₃ : j ∉ S := by rwa [h] at h₁ + contradiction + +end diff --git a/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S03_The_Schroeder_Bernstein_Theorem.lean b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S03_The_Schroeder_Bernstein_Theorem.lean new file mode 100644 index 0000000..6a4b56e --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S03_The_Schroeder_Bernstein_Theorem.lean @@ -0,0 +1,88 @@ +module +public import Mathlib.Data.Set.Function +public import MIL.Common + +open Set +open Function + +noncomputable section +open Classical +variable {α β : Type*} [Nonempty β] + +section +variable (f : α → β) (g : β → α) + +def sbAux : ℕ → Set α + | 0 => univ \ g '' univ + | n + 1 => g '' (f '' sbAux n) + +def sbSet := + ⋃ n, sbAux f g n + +def sbFun (x : α) : β := + if x ∈ sbSet f g then f x else invFun g x + +theorem sb_right_inv {x : α} (hx : x ∉ sbSet f g) : g (invFun g x) = x := by + have : x ∈ g '' univ := by + contrapose! hx + rw [sbSet, mem_iUnion] + use 0 + rw [sbAux, mem_sdiff] + exact ⟨mem_univ _, hx⟩ + have : ∃ y, g y = x := by + simp at this + assumption + exact invFun_eq this + +theorem sb_injective (hf : Injective f) : Injective (sbFun f g) := by + set A := sbSet f g with A_def + set h := sbFun f g with h_def + intro x₁ x₂ (hxeq : h x₁ = h x₂) + show x₁ = x₂ + simp only [h_def, sbFun, ← A_def] at hxeq + by_cases xA : x₁ ∈ A ∨ x₂ ∈ A + · wlog x₁A : x₁ ∈ A generalizing x₁ x₂ hxeq xA + · symm + apply this hxeq.symm xA.symm (xA.resolve_left x₁A) + have x₂A : x₂ ∈ A := by + apply _root_.not_imp_self.mp + intro (x₂nA : x₂ ∉ A) + rw [ite_eq_left x₁A, ite_eq_right x₂nA] at hxeq + rw [A_def, sbSet, mem_iUnion] at x₁A + have x₂eq : x₂ = g (f x₁) := by + rw [hxeq, sb_right_inv f g x₂nA] + rcases x₁A with ⟨n, hn⟩ + rw [A_def, sbSet, mem_iUnion] + use n + 1 + simp [sbAux] + exact ⟨x₁, hn, x₂eq.symm⟩ + rw [ite_eq_left x₁A, ite_eq_left x₂A] at hxeq + exact hf hxeq + push Not at xA + rw [ite_eq_right xA.1, ite_eq_right xA.2] at hxeq + rw [← sb_right_inv f g xA.1, hxeq, sb_right_inv f g xA.2] + +theorem sb_surjective (hg : Injective g) : Surjective (sbFun f g) := by + set A := sbSet f g with A_def + set h := sbFun f g with h_def + intro y + by_cases gyA : g y ∈ A + · rw [A_def, sbSet, mem_iUnion] at gyA + rcases gyA with ⟨n, hn⟩ + rcases n with _ | n + · simp [sbAux] at hn + simp [sbAux] at hn + rcases hn with ⟨x, xmem, hx⟩ + use x + have : x ∈ A := by + rw [A_def, sbSet, mem_iUnion] + exact ⟨n, xmem⟩ + rw [h_def, sbFun, ite_eq_left this] + apply hg hx + + use g y + rw [h_def, sbFun, ite_eq_right gyA] + apply leftInverse_invFun hg + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S01_Irrational_Roots.lean b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S01_Irrational_Roots.lean new file mode 100644 index 0000000..18557a6 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S01_Irrational_Roots.lean @@ -0,0 +1,121 @@ +module +public import MIL.Common +public import Mathlib.Data.Nat.Factorization.Basic +public import Mathlib.Data.Nat.Prime.Basic + +#print Nat.Coprime + +example (m n : Nat) (h : m.Coprime n) : m.gcd n = 1 := + h + +example (m n : Nat) (h : m.Coprime n) : m.gcd n = 1 := by + rw [Nat.Coprime] at h + exact h + +example : Nat.Coprime 12 7 := by norm_num + +example : Nat.gcd 12 8 = 4 := by norm_num + +#check Nat.prime_def_lt + +example (p : ℕ) (prime_p : Nat.Prime p) : 2 ≤ p ∧ ∀ m : ℕ, m < p → m ∣ p → m = 1 := by + rwa [Nat.prime_def_lt] at prime_p + +#check Nat.Prime.eq_one_or_self_of_dvd + +example (p : ℕ) (prime_p : Nat.Prime p) : ∀ m : ℕ, m ∣ p → m = 1 ∨ m = p := + prime_p.eq_one_or_self_of_dvd + +example : Nat.Prime 17 := by norm_num + +-- commonly used +example : Nat.Prime 2 := + Nat.prime_two + +example : Nat.Prime 3 := + Nat.prime_three + +#check Nat.Prime.dvd_mul +#check Nat.Prime.dvd_mul Nat.prime_two +#check Nat.prime_two.dvd_mul + +theorem even_of_even_sqr {m : ℕ} (h : 2 ∣ m ^ 2) : 2 ∣ m := by + rw [pow_two, Nat.prime_two.dvd_mul] at h + cases h <;> assumption + +example {m : ℕ} (h : 2 ∣ m ^ 2) : 2 ∣ m := + Nat.Prime.dvd_of_dvd_pow Nat.prime_two h + +example (a b c : Nat) (h : a * b = a * c) (h' : a ≠ 0) : b = c := + -- apply? suggests the following: + (mul_right_inj' h').mp h + +example {m n : ℕ} (coprime_mn : m.Coprime n) : m ^ 2 ≠ 2 * n ^ 2 := by + intro sqr_eq + have : 2 ∣ m := by + sorry + obtain ⟨k, meq⟩ := dvd_iff_exists_eq_mul_left.mp this + have : 2 * (2 * k ^ 2) = 2 * n ^ 2 := by + rw [← sqr_eq, meq] + ring + have : 2 * k ^ 2 = n ^ 2 := + sorry + have : 2 ∣ n := by + sorry + have : 2 ∣ m.gcd n := by + sorry + have : 2 ∣ 1 := by + sorry + norm_num at this + +example {m n p : ℕ} (coprime_mn : m.Coprime n) (prime_p : p.Prime) : m ^ 2 ≠ p * n ^ 2 := by + sorry +#check Nat.primeFactorsList +#check Nat.prime_of_mem_primeFactorsList +#check Nat.prod_primeFactorsList +#check Nat.primeFactorsList_unique + +theorem factorization_mul' {m n : ℕ} (mnez : m ≠ 0) (nnez : n ≠ 0) (p : ℕ) : + (m * n).factorization p = m.factorization p + n.factorization p := by + rw [Nat.factorization_mul mnez nnez] + rfl + +theorem factorization_pow' (n k p : ℕ) : + (n ^ k).factorization p = k * n.factorization p := by + rw [Nat.factorization_pow] + rfl + +theorem Nat.Prime.factorization' {p : ℕ} (prime_p : p.Prime) : + p.factorization p = 1 := by + rw [prime_p.factorization] + simp + +example {m n p : ℕ} (nnz : n ≠ 0) (prime_p : p.Prime) : m ^ 2 ≠ p * n ^ 2 := by + intro sqr_eq + have nsqr_nez : n ^ 2 ≠ 0 := by simpa + have eq1 : Nat.factorization (m ^ 2) p = 2 * m.factorization p := by + sorry + have eq2 : (p * n ^ 2).factorization p = 2 * n.factorization p + 1 := by + sorry + have : 2 * m.factorization p % 2 = (2 * n.factorization p + 1) % 2 := by + rw [← eq1, sqr_eq, eq2] + rw [add_comm, Nat.add_mul_mod_self_left, Nat.mul_mod_right] at this + norm_num at this + +example {m n k r : ℕ} (nnz : n ≠ 0) (pow_eq : m ^ k = r * n ^ k) {p : ℕ} : + k ∣ r.factorization p := by + rcases r with _ | r + · simp + have npow_nz : n ^ k ≠ 0 := fun npowz ↦ nnz (eq_zero_of_pow_eq_zero npowz) + have eq1 : (m ^ k).factorization p = k * m.factorization p := by + sorry + have eq2 : ((r + 1) * n ^ k).factorization p = + k * n.factorization p + (r + 1).factorization p := by + sorry + have : r.succ.factorization p = k * m.factorization p - k * n.factorization p := by + rw [← eq1, pow_eq, eq2, add_comm, Nat.add_sub_cancel] + rw [this] + sorry + +#check multiplicity + diff --git a/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S02_Induction_and_Recursion.lean b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S02_Induction_and_Recursion.lean new file mode 100644 index 0000000..a9d55b5 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S02_Induction_and_Recursion.lean @@ -0,0 +1,147 @@ +module +public import Mathlib.Data.Nat.GCD.Basic +public import MIL.Common + +example (n : Nat) : n.succ ≠ Nat.zero := + Nat.succ_ne_zero n + +example (m n : Nat) (h : m.succ = n.succ) : m = n := + Nat.succ.inj h + +def fac : ℕ → ℕ + | 0 => 1 + | n + 1 => (n + 1) * fac n + +example : fac 0 = 1 := + rfl + +example : fac 0 = 1 := by + rw [fac] + +example : fac 0 = 1 := by + simp [fac] + +example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := + rfl + +example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := by + rw [fac] + +example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := by + simp [fac] + +theorem fac_pos (n : ℕ) : 0 < fac n := by + induction' n with n ih + · rw [fac] + exact zero_lt_one + rw [fac] + exact mul_pos n.succ_pos ih + +theorem dvd_fac {i n : ℕ} (ipos : 0 < i) (ile : i ≤ n) : i ∣ fac n := by + induction' n with n ih + · exact absurd ipos (not_lt_of_ge ile) + rw [fac] + rcases Nat.of_le_succ ile with h | h + · apply dvd_mul_of_dvd_right (ih h) + rw [h] + apply dvd_mul_right + +theorem pow_two_le_fac (n : ℕ) : 2 ^ (n - 1) ≤ fac n := by + rcases n with _ | n + · simp [fac] + sorry +section + +variable {α : Type*} (s : Finset ℕ) (f : ℕ → ℕ) (n : ℕ) + +#check Finset.sum s f +#check Finset.prod s f + +open BigOperators +open Finset + +example : s.sum f = ∑ x ∈ s, f x := + rfl + +example : s.prod f = ∏ x ∈ s, f x := + rfl + +example : (range n).sum f = ∑ x ∈ range n, f x := + rfl + +example : (range n).prod f = ∏ x ∈ range n, f x := + rfl + +example (f : ℕ → ℕ) : ∑ x ∈ range 0, f x = 0 := + Finset.sum_range_zero f + +example (f : ℕ → ℕ) (n : ℕ) : ∑ x ∈ range n.succ, f x = ∑ x ∈ range n, f x + f n := + Finset.sum_range_succ f n + +example (f : ℕ → ℕ) : ∏ x ∈ range 0, f x = 1 := + Finset.prod_range_zero f + +example (f : ℕ → ℕ) (n : ℕ) : ∏ x ∈ range n.succ, f x = (∏ x ∈ range n, f x) * f n := + Finset.prod_range_succ f n + +example (n : ℕ) : fac n = ∏ i ∈ range n, (i + 1) := by + induction' n with n ih + · simp [fac] + simp [fac, ih, prod_range_succ, mul_comm] + +example (a b c d e f : ℕ) : a * (b * c * f * (d * e)) = d * (a * f * e) * (c * b) := by + simp [mul_comm, mul_left_comm] + +theorem sum_id (n : ℕ) : ∑ i ∈ range (n + 1), i = n * (n + 1) / 2 := by + symm; apply Nat.div_eq_of_eq_mul_right (by norm_num : 0 < 2) + induction' n with n ih + · simp + rw [Finset.sum_range_succ, mul_add 2, ← ih] + ring + +theorem sum_sqr (n : ℕ) : ∑ i ∈ range (n + 1), i ^ 2 = n * (n + 1) * (2 * n + 1) / 6 := by + sorry +end + +inductive MyNat where + | zero : MyNat + | succ : MyNat → MyNat + +namespace MyNat + +def add : MyNat → MyNat → MyNat + | x, zero => x + | x, succ y => succ (add x y) + +def mul : MyNat → MyNat → MyNat + | _, zero => zero + | x, succ y => add (mul x y) x + +theorem zero_add (n : MyNat) : add zero n = n := by + induction' n with n ih + · rfl + rw [add, ih] + +theorem succ_add (m n : MyNat) : add (succ m) n = succ (add m n) := by + induction' n with n ih + · rfl + rw [add, ih] + rfl + +theorem add_comm (m n : MyNat) : add m n = add n m := by + induction' n with n ih + · rw [zero_add] + rfl + rw [add, succ_add, ih] + +theorem add_assoc (m n k : MyNat) : add (add m n) k = add m (add n k) := by + sorry +theorem mul_add (m n k : MyNat) : mul m (add n k) = add (mul m n) (mul m k) := by + sorry +theorem zero_mul (n : MyNat) : mul zero n = zero := by + sorry +theorem succ_mul (m n : MyNat) : mul (succ m) n = add (mul m n) n := by + sorry +theorem mul_comm (m n : MyNat) : mul m n = mul n m := by + sorry +end MyNat diff --git a/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S03_Infinitely_Many_Primes.lean b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S03_Infinitely_Many_Primes.lean new file mode 100644 index 0000000..145617e --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S03_Infinitely_Many_Primes.lean @@ -0,0 +1,227 @@ +module +public import Mathlib.Data.Nat.Prime.Basic +public import MIL.Common + +open BigOperators + +namespace C05S03 + +theorem two_le {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by + cases m; contradiction + case succ m => + cases m; contradiction + repeat apply Nat.succ_le_succ + apply zero_le + +example {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by + by_contra h + push Not at h + interval_cases m <;> contradiction + +example {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by + by_contra h + push Not at h + revert h0 h1 + revert h m + decide + +theorem exists_prime_factor {n : Nat} (h : 2 ≤ n) : ∃ p : Nat, p.Prime ∧ p ∣ n := by + by_cases np : n.Prime + · use n, np + induction' n using Nat.strong_induction_on with n ih + rw [Nat.prime_def_lt] at np + push Not at np + rcases np h with ⟨m, mltn, mdvdn, mne1⟩ + have : m ≠ 0 := by + intro mz + rw [mz, zero_dvd_iff] at mdvdn + linarith + have mgt2 : 2 ≤ m := two_le this mne1 + by_cases mp : m.Prime + · use m, mp + · rcases ih m mltn mgt2 mp with ⟨p, pp, pdvd⟩ + use p, pp + apply pdvd.trans mdvdn + +theorem primes_infinite : ∀ n, ∃ p > n, Nat.Prime p := by + intro n + have : 2 ≤ Nat.factorial n + 1 := by + sorry + rcases exists_prime_factor this with ⟨p, pp, pdvd⟩ + refine ⟨p, ?_, pp⟩ + show p > n + by_contra ple + push Not at ple + have : p ∣ Nat.factorial n := by + sorry + have : p ∣ 1 := by + sorry + show False + sorry +open Finset + +section +variable {α : Type*} [DecidableEq α] (r s t : Finset α) + +example : r ∩ (s ∪ t) ⊆ r ∩ s ∪ r ∩ t := by + rw [subset_iff] + intro x + rw [mem_inter, mem_union, mem_union, mem_inter, mem_inter] + tauto + +example : r ∩ (s ∪ t) ⊆ r ∩ s ∪ r ∩ t := by + simp [subset_iff] + intro x + tauto + +example : r ∩ s ∪ r ∩ t ⊆ r ∩ (s ∪ t) := by + simp [subset_iff] + intro x + tauto + +example : r ∩ s ∪ r ∩ t = r ∩ (s ∪ t) := by + ext x + simp + tauto + +end + +section +variable {α : Type*} [DecidableEq α] (r s t : Finset α) + +example : (r ∪ s) ∩ (r ∪ t) = r ∪ s ∩ t := by + sorry +example : (r \ s) \ t = r \ (s ∪ t) := by + sorry + +end + +example (s : Finset ℕ) (n : ℕ) (h : n ∈ s) : n ∣ ∏ i ∈ s, i := + Finset.dvd_prod_of_mem _ h + +theorem _root_.Nat.Prime.eq_of_dvd_of_prime {p q : ℕ} + (prime_p : Nat.Prime p) (prime_q : Nat.Prime q) (h : p ∣ q) : + p = q := by + sorry + +theorem mem_of_dvd_prod_primes {s : Finset ℕ} {p : ℕ} (prime_p : p.Prime) : + (∀ n ∈ s, Nat.Prime n) → (p ∣ ∏ n ∈ s, n) → p ∈ s := by + intro h₀ h₁ + induction' s using Finset.induction_on with a s ans ih + · simp at h₁ + linarith [prime_p.two_le] + simp [Finset.prod_insert ans, prime_p.dvd_mul] at h₀ h₁ + rw [mem_insert] + sorry +example (s : Finset ℕ) (x : ℕ) : x ∈ s.filter Nat.Prime ↔ x ∈ s ∧ x.Prime := + mem_filter + +theorem primes_infinite' : ∀ s : Finset Nat, ∃ p, Nat.Prime p ∧ p ∉ s := by + intro s + by_contra h + push Not at h + set s' := s.filter Nat.Prime with s'_def + have mem_s' : ∀ {n : ℕ}, n ∈ s' ↔ n.Prime := by + intro n + simp [s'_def] + apply h + have : 2 ≤ (∏ i ∈ s', i) + 1 := by + sorry + rcases exists_prime_factor this with ⟨p, pp, pdvd⟩ + have : p ∣ ∏ i ∈ s', i := by + sorry + have : p ∣ 1 := by + convert Nat.dvd_sub pdvd this + simp + show False + sorry +theorem bounded_of_ex_finset (Q : ℕ → Prop) : + (∃ s : Finset ℕ, ∀ k, Q k → k ∈ s) → ∃ n, ∀ k, Q k → k < n := by + rintro ⟨s, hs⟩ + use s.sup id + 1 + intro k Qk + apply Nat.lt_succ_of_le + show id k ≤ s.sup id + apply le_sup (hs k Qk) + +theorem ex_finset_of_bounded (Q : ℕ → Prop) [DecidablePred Q] : + (∃ n, ∀ k, Q k → k ≤ n) → ∃ s : Finset ℕ, ∀ k, Q k ↔ k ∈ s := by + rintro ⟨n, hn⟩ + use (range (n + 1)).filter Q + intro k + simpa using hn k + +example : 27 % 4 = 3 := by norm_num + +example (n : ℕ) : (4 * n + 3) % 4 = 3 := by + rw [add_comm, Nat.add_mul_mod_self_left] + +theorem mod_4_eq_3_or_mod_4_eq_3 {m n : ℕ} (h : m * n % 4 = 3) : m % 4 = 3 ∨ n % 4 = 3 := by + revert h + rw [Nat.mul_mod] + have : m % 4 < 4 := Nat.mod_lt m (by norm_num) + interval_cases m % 4 <;> simp [-Nat.mul_mod_mod] + have : n % 4 < 4 := Nat.mod_lt n (by norm_num) + interval_cases n % 4 <;> simp + +theorem two_le_of_mod_4_eq_3 {n : ℕ} (h : n % 4 = 3) : 2 ≤ n := by + apply two_le <;> + · intro neq + rw [neq] at h + norm_num at h + +theorem aux {m n : ℕ} (h₀ : m ∣ n) (h₁ : 2 ≤ m) (h₂ : m < n) : n / m ∣ n ∧ n / m < n := by + sorry +theorem exists_prime_factor_mod_4_eq_3 {n : Nat} (h : n % 4 = 3) : + ∃ p : Nat, p.Prime ∧ p ∣ n ∧ p % 4 = 3 := by + by_cases np : n.Prime + · use n + induction' n using Nat.strong_induction_on with n ih + rw [Nat.prime_def_lt] at np + push Not at np + rcases np (two_le_of_mod_4_eq_3 h) with ⟨m, mltn, mdvdn, mne1⟩ + have mge2 : 2 ≤ m := by + apply two_le _ mne1 + intro mz + rw [mz, zero_dvd_iff] at mdvdn + linarith + have neq : m * (n / m) = n := Nat.mul_div_cancel' mdvdn + have : m % 4 = 3 ∨ n / m % 4 = 3 := by + apply mod_4_eq_3_or_mod_4_eq_3 + rw [neq, h] + rcases this with h1 | h1 + . sorry + . sorry +example (m n : ℕ) (s : Finset ℕ) (h : m ∈ erase s n) : m ≠ n ∧ m ∈ s := by + rwa [mem_erase] at h + +example (m n : ℕ) (s : Finset ℕ) (h : m ∈ erase s n) : m ≠ n ∧ m ∈ s := by + simp at h + assumption + +theorem primes_mod_4_eq_3_infinite : ∀ n, ∃ p > n, Nat.Prime p ∧ p % 4 = 3 := by + by_contra h + push Not at h + rcases h with ⟨n, hn⟩ + have : ∃ s : Finset Nat, ∀ p : ℕ, p.Prime ∧ p % 4 = 3 ↔ p ∈ s := by + apply ex_finset_of_bounded + use n + contrapose! hn + rcases hn with ⟨p, ⟨pp, p4⟩, pltn⟩ + exact ⟨p, pltn, pp, p4⟩ + rcases this with ⟨s, hs⟩ + have h₁ : ((4 * ∏ i ∈ erase s 3, i) + 3) % 4 = 3 := by + sorry + rcases exists_prime_factor_mod_4_eq_3 h₁ with ⟨p, pp, pdvd, p4eq⟩ + have ps : p ∈ s := by + sorry + have pne3 : p ≠ 3 := by + sorry + have : p ∣ 4 * ∏ i ∈ erase s 3, i := by + sorry + have : p ∣ 3 := by + sorry + have : p = 3 := by + sorry + contradiction + diff --git a/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S04_More_Induction.lean b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S04_More_Induction.lean new file mode 100644 index 0000000..1881c27 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S04_More_Induction.lean @@ -0,0 +1,138 @@ +module +public import MIL.Common +public import Mathlib.Analysis.Calculus.Taylor +public import Mathlib.Data.Nat.GCD.Basic + +namespace more_induction + +def fac : ℕ → ℕ + | 0 => 1 + | n + 1 => (n + 1) * fac n + +theorem fac_pos (n : ℕ) : 0 < fac n := by + induction' n with n ih + · rw [fac] + exact zero_lt_one + rw [fac] + exact mul_pos n.succ_pos ih + +example (n : ℕ) : 0 < fac n := by + induction n + case zero => + rw [fac] + exact zero_lt_one + case succ n ih => + rw [fac] + exact mul_pos n.succ_pos ih + +example (n : ℕ) : 0 < fac n := by + induction n with + | zero => + rw [fac] + exact zero_lt_one + | succ n ih => + rw [fac] + exact mul_pos n.succ_pos ih + +theorem fac_pos' : ∀ n, 0 < fac n + | 0 => by + rw [fac] + exact zero_lt_one + | n + 1 => by + rw [fac] + exact mul_pos n.succ_pos (fac_pos' n) + +@[simp] def fib : ℕ → ℕ + | 0 => 0 + | 1 => 1 + | n + 2 => fib n + fib (n + 1) + +theorem fib_add_two (n : ℕ) : fib (n + 2) = fib n + fib (n + 1) := rfl + +example (n : ℕ) : fib (n + 2) = fib n + fib (n + 1) := by rw [fib] + +noncomputable section + +def phi : ℝ := (1 + √5) / 2 +def phi' : ℝ := (1 - √5) / 2 + +theorem fib_eq : ∀ n, fib n = (phi^n - phi'^n) / √5 + | 0 => by simp + | 1 => by unfold fib; grind [phi, phi'] + | n+2 => by unfold fib; simp [fib_eq n, fib_eq (n+1), phi, phi']; grind + +end + +theorem fib_coprime_fib_succ (n : ℕ) : Nat.Coprime (fib n) (fib (n + 1)) := by + induction n with + | zero => simp + | succ n ih => + simp only [fib, Nat.coprime_add_self_right] + exact ih.symm + +#eval fib 6 +#eval List.range 20 |>.map fib + +def fib' (n : Nat) : Nat := + aux n 0 1 +where aux + | 0, x, _ => x + | n+1, x, y => aux n y (x + y) + +theorem fib'.aux_eq (m n : ℕ) : fib'.aux n (fib m) (fib (m + 1)) = fib (n + m) := by + induction n generalizing m with + | zero => simp [fib'.aux] + | succ n ih => rw [fib'.aux, ←fib_add_two, ih, add_assoc, add_comm 1] + +theorem fib'_eq_fib : fib' = fib := by + ext n + erw [fib', fib'.aux_eq 0 n]; rfl + +#eval fib' 10000 + +theorem fib_add (m n : ℕ) : fib (m + n + 1) = fib m * fib n + fib (m + 1) * fib (n + 1) := by + induction n generalizing m with + | zero => simp + | succ n ih => + specialize ih (m + 1) + rw [add_assoc m 1 n, add_comm 1 n] at ih + simp only [fib_add_two, ih] + ring + +theorem fib_add' : ∀ m n, fib (m + n + 1) = fib m * fib n + fib (m + 1) * fib (n + 1) + | _, 0 => by simp + | m, n + 1 => by + have := fib_add' (m + 1) n + rw [add_assoc m 1 n, add_comm 1 n] at this + simp only [fib_add_two, this] + ring + +example (n : ℕ): (fib n) ^ 2 + (fib (n + 1)) ^ 2 = fib (2 * n + 1) := by + sorry +#check (@Nat.not_prime_iff_exists_dvd_lt : + ∀ {n : ℕ}, 2 ≤ n → (¬Nat.Prime n ↔ ∃ m, m ∣ n ∧ 2 ≤ m ∧ m < n)) + +theorem ne_one_iff_exists_prime_dvd : ∀ {n}, n ≠ 1 ↔ ∃ p : ℕ, p.Prime ∧ p ∣ n + | 0 => by simpa using Exists.intro 2 Nat.prime_two + | 1 => by simp [Nat.not_prime_one] + | n + 2 => by + have hn : n + 2 ≠ 1 := by omega + simp only [Ne, not_false_iff, true_iff, hn] + by_cases h : Nat.Prime (n + 2) + · use n + 2, h + · have : 2 ≤ n + 2 := by omega + rw [Nat.not_prime_iff_exists_dvd_lt this] at h + rcases h with ⟨m, mdvdn, mge2, -⟩ + have : m ≠ 1 := by omega + rw [ne_one_iff_exists_prime_dvd] at this + rcases this with ⟨p, primep, pdvdm⟩ + use p, primep + exact pdvdm.trans mdvdn + +theorem zero_lt_of_mul_eq_one (m n : ℕ) : n * m = 1 → 0 < n ∧ 0 < m := by + cases n <;> cases m <;> simp + +example (m n : ℕ) : n*m = 1 → 0 < n ∧ 0 < m := by + rcases m with (_ | m); simp + rcases n with (_ | n) <;> simp + diff --git a/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S01_Irrational_Roots.lean b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S01_Irrational_Roots.lean new file mode 100644 index 0000000..70a7718 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S01_Irrational_Roots.lean @@ -0,0 +1,105 @@ +module +public import MIL.Common +public import Mathlib.Data.Nat.Factorization.Basic +public import Mathlib.Data.Nat.Prime.Basic + +theorem even_of_even_sqr {m : ℕ} (h : 2 ∣ m ^ 2) : 2 ∣ m := by + rw [pow_two, Nat.prime_two.dvd_mul] at h + cases h <;> assumption + +example {m n : ℕ} (coprime_mn : m.Coprime n) : m ^ 2 ≠ 2 * n ^ 2 := by + intro sqr_eq + have : 2 ∣ m := by + apply even_of_even_sqr + rw [sqr_eq] + apply dvd_mul_right + obtain ⟨k, meq⟩ := dvd_iff_exists_eq_mul_left.mp this + have : 2 * (2 * k ^ 2) = 2 * n ^ 2 := by + rw [← sqr_eq, meq] + ring + have : 2 * k ^ 2 = n ^ 2 := + (mul_right_inj' (by norm_num)).mp this + have : 2 ∣ n := by + apply even_of_even_sqr + rw [← this] + apply dvd_mul_right + have : 2 ∣ m.gcd n := by + apply Nat.dvd_gcd <;> + assumption + have : 2 ∣ 1 := by + convert this + symm + exact coprime_mn + norm_num at this + +example {m n p : ℕ} (coprime_mn : m.Coprime n) (prime_p : p.Prime) : m ^ 2 ≠ p * n ^ 2 := by + intro sqr_eq + have : p ∣ m := by + apply prime_p.dvd_of_dvd_pow + rw [sqr_eq] + apply dvd_mul_right + obtain ⟨k, meq⟩ := dvd_iff_exists_eq_mul_left.mp this + have : p * (p * k ^ 2) = p * n ^ 2 := by + rw [← sqr_eq, meq] + ring + have : p * k ^ 2 = n ^ 2 := by + apply (mul_right_inj' _).mp this + exact prime_p.ne_zero + have : p ∣ n := by + apply prime_p.dvd_of_dvd_pow + rw [← this] + apply dvd_mul_right + have : p ∣ Nat.gcd m n := by apply Nat.dvd_gcd <;> assumption + have : p ∣ 1 := by + convert this + symm + exact coprime_mn + have : 2 ≤ 1 := by + apply prime_p.two_le.trans + exact Nat.le_of_dvd zero_lt_one this + norm_num at this + +theorem factorization_mul' {m n : ℕ} (mnez : m ≠ 0) (nnez : n ≠ 0) (p : ℕ) : + (m * n).factorization p = m.factorization p + n.factorization p := by + rw [Nat.factorization_mul mnez nnez] + rfl + +theorem factorization_pow' (n k p : ℕ) : + (n ^ k).factorization p = k * n.factorization p := by + rw [Nat.factorization_pow] + rfl + +theorem Nat.Prime.factorization' {p : ℕ} (prime_p : p.Prime) : + p.factorization p = 1 := by + rw [prime_p.factorization] + simp + +example {m n p : ℕ} (nnz : n ≠ 0) (prime_p : p.Prime) : m ^ 2 ≠ p * n ^ 2 := by + intro sqr_eq + have nsqr_nez : n ^ 2 ≠ 0 := by simpa + have eq1 : Nat.factorization (m ^ 2) p = 2 * m.factorization p := by + rw [factorization_pow'] + have eq2 : (p * n ^ 2).factorization p = 2 * n.factorization p + 1 := by + rw [factorization_mul' prime_p.ne_zero nsqr_nez, prime_p.factorization', factorization_pow', + add_comm] + have : 2 * m.factorization p % 2 = (2 * n.factorization p + 1) % 2 := by + rw [← eq1, sqr_eq, eq2] + rw [add_comm, Nat.add_mul_mod_self_left, Nat.mul_mod_right] at this + norm_num at this + +example {m n k r : ℕ} (nnz : n ≠ 0) (pow_eq : m ^ k = r * n ^ k) {p : ℕ} : + k ∣ r.factorization p := by + rcases r with _ | r + · simp + have npow_nz : n ^ k ≠ 0 := fun npowz ↦ nnz (eq_zero_of_pow_eq_zero npowz) + have eq1 : (m ^ k).factorization p = k * m.factorization p := by + rw [factorization_pow'] + have eq2 : ((r + 1) * n ^ k).factorization p = + k * n.factorization p + (r + 1).factorization p := by + rw [factorization_mul' r.succ_ne_zero npow_nz, factorization_pow', add_comm] + have : r.succ.factorization p = k * m.factorization p - k * n.factorization p := by + rw [← eq1, pow_eq, eq2, add_comm, Nat.add_sub_cancel] + rw [this] + apply Nat.dvd_sub <;> + apply Nat.dvd_mul_right + diff --git a/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S02_Induction_and_Recursion.lean b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S02_Induction_and_Recursion.lean new file mode 100644 index 0000000..d327b71 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S02_Induction_and_Recursion.lean @@ -0,0 +1,97 @@ +module +public import Mathlib.Data.Nat.GCD.Basic +public import MIL.Common + +def fac : ℕ → ℕ + | 0 => 1 + | n + 1 => (n + 1) * fac n + +theorem pow_two_le_fac (n : ℕ) : 2 ^ (n - 1) ≤ fac n := by + rcases n with _ | n + · simp [fac] + induction' n with n ih + · simp [fac] + simp at * + rw [pow_succ', fac] + apply Nat.mul_le_mul _ ih + repeat apply Nat.succ_le_succ + apply zero_le + +section + +variable {α : Type*} (s : Finset ℕ) (f : ℕ → ℕ) (n : ℕ) + +open BigOperators +open Finset + +theorem sum_sqr (n : ℕ) : ∑ i ∈ range (n + 1), i ^ 2 = n * (n + 1) * (2 * n + 1) / 6 := by + symm; + apply Nat.div_eq_of_eq_mul_right (by norm_num : 0 < 6) + induction' n with n ih + · simp + rw [Finset.sum_range_succ, mul_add 6, ← ih] + ring + +end + +inductive MyNat where + | zero : MyNat + | succ : MyNat → MyNat + +namespace MyNat + +def add : MyNat → MyNat → MyNat + | x, zero => x + | x, succ y => succ (add x y) + +def mul : MyNat → MyNat → MyNat + | _, zero => zero + | x, succ y => add (mul x y) x + +theorem zero_add (n : MyNat) : add zero n = n := by + induction' n with n ih + · rfl + rw [add, ih] + +theorem succ_add (m n : MyNat) : add (succ m) n = succ (add m n) := by + induction' n with n ih + · rfl + rw [add, ih] + rfl + +theorem add_comm (m n : MyNat) : add m n = add n m := by + induction' n with n ih + · rw [zero_add] + rfl + rw [add, succ_add, ih] + +theorem add_assoc (m n k : MyNat) : add (add m n) k = add m (add n k) := by + induction' k with k ih + · rfl + rw [add, ih] + rfl + +theorem mul_add (m n k : MyNat) : mul m (add n k) = add (mul m n) (mul m k) := by + induction' k with k ih + · rfl + rw [add, mul, mul, ih, add_assoc] + +theorem zero_mul (n : MyNat) : mul zero n = zero := by + induction' n with n ih + · rfl + rw [mul, ih] + rfl + +theorem succ_mul (m n : MyNat) : mul (succ m) n = add (mul m n) n := by + induction' n with n ih + · rfl + rw [mul, mul, ih, add_assoc, add_assoc, add_comm n, succ_add] + rfl + +theorem mul_comm (m n : MyNat) : mul m n = mul n m := by + induction' n with n ih + · rw [zero_mul] + rfl + rw [mul, ih, succ_mul] + +end MyNat diff --git a/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S03_Infinitely_Many_Primes.lean b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S03_Infinitely_Many_Primes.lean new file mode 100644 index 0000000..f1ee7ea --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S03_Infinitely_Many_Primes.lean @@ -0,0 +1,234 @@ +module +public import Mathlib.Data.Nat.Prime.Basic +public import MIL.Common + +open BigOperators + +namespace C05S03 + +theorem two_le {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by + cases m; contradiction + case succ m => + cases m; contradiction + repeat apply Nat.succ_le_succ + apply zero_le + +theorem exists_prime_factor {n : Nat} (h : 2 ≤ n) : ∃ p : Nat, p.Prime ∧ p ∣ n := by + by_cases np : n.Prime + · use n, np + induction' n using Nat.strong_induction_on with n ih + rw [Nat.prime_def_lt] at np + push Not at np + rcases np h with ⟨m, mltn, mdvdn, mne1⟩ + have : m ≠ 0 := by + intro mz + rw [mz, zero_dvd_iff] at mdvdn + linarith + have mgt2 : 2 ≤ m := two_le this mne1 + by_cases mp : m.Prime + · use m, mp + · rcases ih m mltn mgt2 mp with ⟨p, pp, pdvd⟩ + use p, pp + apply pdvd.trans mdvdn + +theorem primes_infinite : ∀ n, ∃ p > n, Nat.Prime p := by + intro n + have : 2 ≤ Nat.factorial n + 1 := by + apply Nat.succ_le_succ + exact Nat.succ_le_of_lt (Nat.factorial_pos _) + rcases exists_prime_factor this with ⟨p, pp, pdvd⟩ + refine ⟨p, ?_, pp⟩ + show p > n + by_contra ple + push Not at ple + have : p ∣ Nat.factorial n := by + apply Nat.dvd_factorial + apply pp.pos + linarith + have : p ∣ 1 := by + convert Nat.dvd_sub pdvd this + simp + show False + have := Nat.le_of_dvd zero_lt_one this + linarith [pp.two_le] + +open Finset + +section +variable {α : Type*} [DecidableEq α] (r s t : Finset α) + +example : (r ∪ s) ∩ (r ∪ t) = r ∪ s ∩ t := by + ext x + rw [mem_inter, mem_union, mem_union, mem_union, mem_inter] + tauto + +example : (r ∪ s) ∩ (r ∪ t) = r ∪ s ∩ t := by + ext x + simp + tauto + +example : (r \ s) \ t = r \ (s ∪ t) := by + ext x + rw [mem_sdiff, mem_sdiff, mem_sdiff, mem_union] + tauto + +example : (r \ s) \ t = r \ (s ∪ t) := by + ext x + simp + tauto + +end + +theorem _root_.Nat.Prime.eq_of_dvd_of_prime {p q : ℕ} + (prime_p : Nat.Prime p) (prime_q : Nat.Prime q) (h : p ∣ q) : + p = q := by + cases prime_q.eq_one_or_self_of_dvd _ h + · linarith [prime_p.two_le] + assumption + +theorem mem_of_dvd_prod_primes {s : Finset ℕ} {p : ℕ} (prime_p : p.Prime) : + (∀ n ∈ s, Nat.Prime n) → (p ∣ ∏ n ∈ s, n) → p ∈ s := by + intro h₀ h₁ + induction' s using Finset.induction_on with a s ans ih + · simp at h₁ + linarith [prime_p.two_le] + simp [Finset.prod_insert ans, prime_p.dvd_mul] at h₀ h₁ + rw [mem_insert] + rcases h₁ with h₁ | h₁ + · left + exact prime_p.eq_of_dvd_of_prime h₀.1 h₁ + right + exact ih h₀.2 h₁ + +theorem primes_infinite' : ∀ s : Finset Nat, ∃ p, Nat.Prime p ∧ p ∉ s := by + intro s + by_contra h + push Not at h + set s' := s.filter Nat.Prime with s'_def + have mem_s' : ∀ {n : ℕ}, n ∈ s' ↔ n.Prime := by + intro n + simp [s'_def] + apply h + have : 2 ≤ (∏ i ∈ s', i) + 1 := by + apply Nat.succ_le_succ + apply Nat.succ_le_of_lt + apply Finset.prod_pos + intro n ns' + apply (mem_s'.mp ns').pos + rcases exists_prime_factor this with ⟨p, pp, pdvd⟩ + have : p ∣ ∏ i ∈ s', i := by + apply dvd_prod_of_mem + rw [mem_s'] + apply pp + have : p ∣ 1 := by + convert Nat.dvd_sub pdvd this + simp + show False + have := Nat.le_of_dvd zero_lt_one this + linarith [pp.two_le] + +theorem bounded_of_ex_finset (Q : ℕ → Prop) : + (∃ s : Finset ℕ, ∀ k, Q k → k ∈ s) → ∃ n, ∀ k, Q k → k < n := by + rintro ⟨s, hs⟩ + use s.sup id + 1 + intro k Qk + apply Nat.lt_succ_of_le + show id k ≤ s.sup id + apply le_sup (hs k Qk) + +theorem ex_finset_of_bounded (Q : ℕ → Prop) [DecidablePred Q] : + (∃ n, ∀ k, Q k → k ≤ n) → ∃ s : Finset ℕ, ∀ k, Q k ↔ k ∈ s := by + rintro ⟨n, hn⟩ + use (range (n + 1)).filter Q + intro k + simpa using hn k + +theorem mod_4_eq_3_or_mod_4_eq_3 {m n : ℕ} (h : m * n % 4 = 3) : m % 4 = 3 ∨ n % 4 = 3 := by + revert h + rw [Nat.mul_mod] + have : m % 4 < 4 := Nat.mod_lt m (by norm_num) + interval_cases m % 4 <;> simp [-Nat.mul_mod_mod] + have : n % 4 < 4 := Nat.mod_lt n (by norm_num) + interval_cases n % 4 <;> simp + +theorem two_le_of_mod_4_eq_3 {n : ℕ} (h : n % 4 = 3) : 2 ≤ n := by + apply two_le <;> + · intro neq + rw [neq] at h + norm_num at h + +theorem aux {m n : ℕ} (h₀ : m ∣ n) (h₁ : 2 ≤ m) (h₂ : m < n) : n / m ∣ n ∧ n / m < n := by + constructor + · exact Nat.div_dvd_of_dvd h₀ + exact Nat.div_lt_self (lt_of_le_of_lt zero_le h₂) h₁ + +theorem exists_prime_factor_mod_4_eq_3 {n : Nat} (h : n % 4 = 3) : + ∃ p : Nat, p.Prime ∧ p ∣ n ∧ p % 4 = 3 := by + by_cases np : n.Prime + · use n + induction' n using Nat.strong_induction_on with n ih + rw [Nat.prime_def_lt] at np + push Not at np + rcases np (two_le_of_mod_4_eq_3 h) with ⟨m, mltn, mdvdn, mne1⟩ + have mge2 : 2 ≤ m := by + apply two_le _ mne1 + intro mz + rw [mz, zero_dvd_iff] at mdvdn + linarith + have neq : m * (n / m) = n := Nat.mul_div_cancel' mdvdn + have : m % 4 = 3 ∨ n / m % 4 = 3 := by + apply mod_4_eq_3_or_mod_4_eq_3 + rw [neq, h] + rcases this with h1 | h1 + · by_cases mp : m.Prime + · use m + rcases ih m mltn h1 mp with ⟨p, pp, pdvd, p4eq⟩ + use p + exact ⟨pp, pdvd.trans mdvdn, p4eq⟩ + obtain ⟨nmdvdn, nmltn⟩ := aux mdvdn mge2 mltn + by_cases nmp : (n / m).Prime + · use n / m + rcases ih (n / m) nmltn h1 nmp with ⟨p, pp, pdvd, p4eq⟩ + use p + exact ⟨pp, pdvd.trans nmdvdn, p4eq⟩ + +theorem primes_mod_4_eq_3_infinite : ∀ n, ∃ p > n, Nat.Prime p ∧ p % 4 = 3 := by + by_contra h + push Not at h + rcases h with ⟨n, hn⟩ + have : ∃ s : Finset Nat, ∀ p : ℕ, p.Prime ∧ p % 4 = 3 ↔ p ∈ s := by + apply ex_finset_of_bounded + use n + contrapose! hn + rcases hn with ⟨p, ⟨pp, p4⟩, pltn⟩ + exact ⟨p, pltn, pp, p4⟩ + rcases this with ⟨s, hs⟩ + have h₁ : ((4 * ∏ i ∈ erase s 3, i) + 3) % 4 = 3 := by + rw [add_comm, Nat.add_mul_mod_self_left] + rcases exists_prime_factor_mod_4_eq_3 h₁ with ⟨p, pp, pdvd, p4eq⟩ + have ps : p ∈ s := by + rw [← hs p] + exact ⟨pp, p4eq⟩ + have pne3 : p ≠ 3 := by + intro peq + rw [peq, ← Nat.dvd_add_iff_left (dvd_refl 3)] at pdvd + rw [Nat.prime_three.dvd_mul] at pdvd + norm_num at pdvd + have : 3 ∈ s.erase 3 := by + apply mem_of_dvd_prod_primes Nat.prime_three _ pdvd + intro n + simp [← hs n] + tauto + simp at this + have : p ∣ 4 * ∏ i ∈ erase s 3, i := by + apply dvd_trans _ (dvd_mul_left _ _) + apply dvd_prod_of_mem + simp + constructor <;> assumption + have : p ∣ 3 := by + convert Nat.dvd_sub pdvd this + simp + have : p = 3 := by + apply pp.eq_of_dvd_of_prime Nat.prime_three this + contradiction + diff --git a/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S04_More_Induction.lean b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S04_More_Induction.lean new file mode 100644 index 0000000..4cb3aba --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/solutions/Solutions_S04_More_Induction.lean @@ -0,0 +1,26 @@ +module +public import MIL.Common +public import Mathlib.Analysis.Calculus.Taylor +public import Mathlib.Data.Nat.GCD.Basic + +namespace more_induction + +@[simp] def fib : ℕ → ℕ + | 0 => 0 + | 1 => 1 + | n + 2 => fib n + fib (n + 1) + +theorem fib_add_two (n : ℕ) : fib (n + 2) = fib n + fib (n + 1) := rfl + +theorem fib_add (m n : ℕ) : fib (m + n + 1) = fib m * fib n + fib (m + 1) * fib (n + 1) := by + induction n generalizing m with + | zero => simp + | succ n ih => + specialize ih (m + 1) + rw [add_assoc m 1 n, add_comm 1 n] at ih + simp only [fib_add_two, ih] + ring + +example (n : ℕ): (fib n) ^ 2 + (fib (n + 1)) ^ 2 = fib (2 * n + 1) := by + rw [two_mul, fib_add, pow_two, pow_two] + diff --git a/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S01_Finsets_and_Fintypes.lean b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S01_Finsets_and_Fintypes.lean new file mode 100644 index 0000000..a97efe8 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S01_Finsets_and_Fintypes.lean @@ -0,0 +1,158 @@ +module + +public meta import Mathlib.Data.Finset.Card -- for the #eval of Finset.card below +public meta import Mathlib.Data.Finset.Fold -- for the #eval of Finset.fold below + +public import Mathlib.Data.Finset.Powerset +public import Mathlib.Data.Finset.Max +public import Mathlib.Data.Nat.Prime.Basic +public import Mathlib.Data.Fintype.BigOperators + +public section + +section +variable {α : Type*} [DecidableEq α] (a : α) (s t : Finset α) + +#check a ∈ s +#check s ∩ t + +end + +open Finset + +variable (a b c : Finset ℕ) +variable (n : ℕ) + +#check a ∩ b +#check a ∪ b +#check a \ b +#check (∅ : Finset ℕ) + +example : a ∩ (b ∪ c) = (a ∩ b) ∪ (a ∩ c) := by + ext x; simp only [mem_inter, mem_union]; tauto + +example : a ∩ (b ∪ c) = (a ∩ b) ∪ (a ∩ c) := by rw [inter_union_distrib_left] + +#check ({0, 2, 5} : Finset Nat) + +def example1 : Finset ℕ := {0, 1, 2} + +example : ({0, 1, 2} : Finset ℕ) = {1, 2, 0} := by decide + +example : ({0, 1, 2} : Finset ℕ) = {0, 1, 1, 2} := by decide + +example : ({0, 1} : Finset ℕ) = {1, 0} := by rw [Finset.pair_comm] + +example (x : Nat) : ({x, x} : Finset ℕ) = {x} := by simp + +example (x y z : Nat) : ({x, y, z, y, z, x} : Finset ℕ) = {x, y, z} := by + ext i; simp [or_comm, or_left_comm] + +example (x y z : Nat) : ({x, y, z, y, z, x} : Finset ℕ) = {x, y, z} := by + ext i; simp; tauto + +example (s : Finset ℕ) (a : ℕ) (h : a ∉ s) : (insert a s |>.erase a) = s := + Finset.erase_insert h + +example (s : Finset ℕ) (a : ℕ) (h : a ∈ s) : insert a (s.erase a) = s := + Finset.insert_erase h + +set_option pp.notation false in +#check ({0, 1, 2} : Finset ℕ) + +example : {m ∈ range n | Even m} = (range n).filter Even := rfl +example : {m ∈ range n | Even m ∧ m ≠ 3} = (range n).filter (fun m ↦ Even m ∧ m ≠ 3) := rfl + +example : {m ∈ range 10 | Even m} = {0, 2, 4, 6, 8} := by decide + +#check (range 5).image (fun x ↦ x * 2) + +example : (range 5).image (fun x ↦ x * 2) = {x ∈ range 10 | Even x} := by decide + +section +variable (s t : Finset Nat) +#check s ×ˢ t +#check s.powerset + +end + +namespace finsets_and_fintypes +#check Finset.fold + +def f (n : ℕ) : Int := (↑n)^2 + +#check (range 5).fold (fun x y : Int ↦ x + y) 0 f +#eval (range 5).fold (fun x y : Int ↦ x + y) 0 f + +#check ∑ i ∈ range 5, i^2 +#check ∏ i ∈ range 5, i + 1 + +variable (g : Nat → Finset Int) + +#check (range 5).biUnion g + +end finsets_and_fintypes + +#check Finset.induction + +example {α : Type*} [DecidableEq α] (f : α → ℕ) (s : Finset α) (h : ∀ x ∈ s, f x ≠ 0) : + ∏ x ∈ s, f x ≠ 0 := by + induction s using Finset.induction_on with + | empty => simp + | @insert a s anins ih => + rw [prod_insert anins] + apply mul_ne_zero + · apply h; apply mem_insert_self + apply ih + intros x xs + exact h x (mem_insert_of_mem xs) + +noncomputable example (s : Finset ℕ) (h : s.Nonempty) : ℕ := Classical.choose h + +example (s : Finset ℕ) (h : s.Nonempty) : Classical.choose h ∈ s := Classical.choose_spec h + +noncomputable example (s : Finset ℕ) : List ℕ := s.toList + +example (s : Finset ℕ) (a : ℕ) : a ∈ s.toList ↔ a ∈ s := mem_toList + +#check Finset.min +#check Finset.min' +#check Finset.max +#check Finset.max' +#check Finset.inf +#check Finset.inf' +#check Finset.sup +#check Finset.sup' + +example : Finset.Nonempty {2, 6, 7} := ⟨6, by trivial⟩ +example : Finset.min' {2, 6, 7} ⟨6, by trivial⟩ = 2 := by trivial + +#check Finset.card + +#eval (range 5).card + +example (s : Finset ℕ) : s.card = #s := by rfl + +example (s : Finset ℕ) : s.card = ∑ _i ∈ s, 1 := by rw [card_eq_sum_ones] + +example (s : Finset ℕ) : s.card = ∑ _i ∈ s, 1 := by simp + +section +variable {α : Type*} [Fintype α] + +example : ∀ x : α, x ∈ Finset.univ := by + intro x; exact mem_univ x + +example : Fintype.card α = (Finset.univ : Finset α).card := rfl +end + +example : Fintype.card (Fin 5) = 5 := by simp +example : Fintype.card ((Fin 5) × (Fin 3)) = 15 := by simp + +section +variable (s : Finset ℕ) + +example : (↑s : Type) = {x : ℕ // x ∈ s} := rfl +example : Fintype.card ↑s = s.card := by simp +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S02_Counting_Arguments.lean b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S02_Counting_Arguments.lean new file mode 100644 index 0000000..295f0cb --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S02_Counting_Arguments.lean @@ -0,0 +1,137 @@ +module +public import Mathlib.Data.Fintype.BigOperators +public import Mathlib.Combinatorics.Pigeonhole +public import Mathlib.Tactic + +open Finset + +variable {α β : Type*} [DecidableEq α] [DecidableEq β] (s t : Finset α) (f : α → β) + +example : #(s ×ˢ t) = #s * #t := by rw [card_product] +example : #(s ×ˢ t) = #s * #t := by simp + +example : #(s ∪ t) = #s + #t - #(s ∩ t) := by rw [card_union] + +example (h : Disjoint s t) : #(s ∪ t) = #s + #t := by rw [card_union_of_disjoint h] +example (h : Disjoint s t) : #(s ∪ t) = #s + #t := by simp [h] + +example (h : Function.Injective f) : #(s.image f) = #s := by rw [card_image_of_injective _ h] + +example (h : Set.InjOn f s) : #(s.image f) = #s := by rw [card_image_of_injOn h] + +section +open Fintype + +variable {α β : Type*} [Fintype α] [Fintype β] + +example : card (α × β) = card α * card β := by simp + +example : card (α ⊕ β) = card α + card β := by simp + +example (n : ℕ) : card (Fin n → α) = (card α)^n := by simp + +variable {n : ℕ} {γ : Fin n → Type*} [∀ i, Fintype (γ i)] + +example : card ((i : Fin n) → γ i) = ∏ i, card (γ i) := by simp + +example : card (Σ i, γ i) = ∑ i, card (γ i) := by simp + +end + +#check Disjoint + +example (m n : ℕ) (h : m ≥ n) : + card (range n ∪ (range n).image (fun i ↦ m + i)) = 2 * n := by + rw [card_union_of_disjoint, card_range, card_image_of_injective, card_range]; omega + . apply add_right_injective + . simp [disjoint_iff_ne]; omega + +def triangle (n : ℕ) : Finset (ℕ × ℕ) := {p ∈ range (n+1) ×ˢ range (n+1) | p.1 < p.2} + +example (n : ℕ) : #(triangle n) = (n + 1) * n / 2 := by + have : triangle n = (range (n+1)).biUnion (fun j ↦ (range j).image (., j)) := by + ext p + simp only [triangle, mem_filter, mem_product, mem_range, mem_biUnion, mem_image] + constructor + . rintro ⟨⟨hp1, hp2⟩, hp3⟩ + use p.2, hp2, p.1, hp3 + . rintro ⟨p1, hp1, p2, hp2, rfl⟩ + omega + rw [this, card_biUnion]; swap + · -- take care of disjointness first + intro x _ y _ xney + simp [disjoint_iff_ne, xney] + -- continue the calculation + transitivity (∑ i ∈ range (n + 1), i) + · congr; ext i + rw [card_image_of_injective, card_range] + intros i1 i2; simp + rw [sum_range_id]; rfl + +example (n : ℕ) : #(triangle n) = (n + 1) * n / 2 := by + have : triangle n ≃ Σ i : Fin (n + 1), Fin i.val := + { toFun := by + rintro ⟨⟨i, j⟩, hp⟩ + have : (i ≤ n ∧ j ≤ n) ∧ i < j := by simpa [triangle] using hp + exact ⟨⟨j, by linarith⟩, ⟨i, by linarith⟩⟩ + invFun := by + rintro ⟨i, j⟩ + use ⟨j, i⟩ + suffices j ≤ n ∧ i ≤ n by simpa [triangle] + constructor <;> linarith [i.2, j.2] + left_inv := by intro i; rfl + right_inv := by intro i; rfl } + rw [←Fintype.card_coe] + trans; apply (Fintype.card_congr this) + rw [Fintype.card_sigma, sum_fin_eq_sum_range] + convert! Finset.sum_range_id (n + 1) + simp_all + +example (n : ℕ) : #(triangle n) = (n + 1) * n / 2 := by + apply Nat.eq_div_of_mul_eq_right (by norm_num) + let turn (p : ℕ × ℕ) : ℕ × ℕ := (n - 1 - p.1, n - p.2) + calc 2 * #(triangle n) + = #(triangle n) + #(triangle n) := by + sorry + _ = #(triangle n) + #(triangle n |>.image turn) := by + sorry + _ = #(range n ×ˢ range (n + 1)) := by + sorry + _ = (n + 1) * n := by + sorry + +def triangle' (n : ℕ) : Finset (ℕ × ℕ) := {p ∈ range n ×ˢ range n | p.1 ≤ p.2} + +example (n : ℕ) : #(triangle' n) = #(triangle n) := by sorry + +section +open Classical +variable (s t : Finset ℕ) (a b : ℕ) + +theorem doubleCounting {α β : Type*} (s : Finset α) (t : Finset β) + (r : α → β → Prop) + (h_left : ∀ a ∈ s, 3 ≤ #{b ∈ t | r a b}) + (h_right : ∀ b ∈ t, #{a ∈ s | r a b} ≤ 1) : + 3 * #(s) ≤ #(t) := by + calc 3 * #(s) + = ∑ a ∈ s, 3 := by simp [mul_comm] + _ ≤ ∑ a ∈ s, #({b ∈ t | r a b}) := sum_le_sum h_left + _ = ∑ a ∈ s, ∑ b ∈ t, if r a b then 1 else 0 := by simp + _ = ∑ b ∈ t, ∑ a ∈ s, if r a b then 1 else 0 := sum_comm + _ = ∑ b ∈ t, #({a ∈ s | r a b}) := by simp + _ ≤ ∑ b ∈ t, 1 := sum_le_sum h_right + _ ≤ #(t) := by simp + +example (m k : ℕ) (h : m ≠ k) (h' : m / 2 = k / 2) : m = k + 1 ∨ k = m + 1 := by omega + +example {n : ℕ} (A : Finset ℕ) + (hA : #(A) = n + 1) + (hA' : A ⊆ range (2 * n)) : + ∃ m ∈ A, ∃ k ∈ A, Nat.Coprime m k := by + have : ∃ t ∈ range n, 1 < #({u ∈ A | u / 2 = t}) := by + apply exists_lt_card_fiber_of_mul_lt_card_of_maps_to + · sorry + · sorry + rcases this with ⟨t, ht, ht'⟩ + simp only [one_lt_card, mem_filter] at ht' + sorry diff --git a/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S03_Inductive_Structures.lean b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S03_Inductive_Structures.lean new file mode 100644 index 0000000..8cfb065 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S03_Inductive_Structures.lean @@ -0,0 +1,161 @@ +module +public import Mathlib.Tactic + +namespace MyListSpace + +inductive List (α : Type*) where + | nil : List α + | cons : α → List α → List α + +end MyListSpace + +namespace MyListSpace2 + +def append {α : Type*} : List α → List α → List α + | [], bs => bs + | a :: as, bs => a :: append as bs + +def map {α β : Type*} (f : α → β) : List α → List β + | [] => [] + | a :: as => f a :: map f as + +#eval append [1, 2, 3] [4, 5, 6] +#eval map (fun n => n^2) [1, 2, 3, 4, 5] + +theorem nil_append {α : Type*} (as : List α) : append [] as = as := rfl + +theorem cons_append {α : Type*} (a : α) (as : List α) (bs : List α) : + append (a :: as) bs = a :: append as bs := rfl + +theorem map_nil {α β : Type*} (f : α → β) : map f [] = [] := rfl + +theorem map_cons {α β : Type*} (f : α → β) (a : α) (as : List α) : + map f (a :: as) = f a :: map f as := rfl + +end MyListSpace2 + +namespace MyListSpace3 + +variable {α β γ : Type*} +variable (as bs cs : List α) +variable (a b c : α) + +open List + +theorem append_nil : ∀ as : List α, as ++ [] = as + | [] => rfl + | a :: as => by rw [cons_append, append_nil as] + +theorem map_map (f : α → β) (g : β → γ) : + ∀ as : List α, map g (map f as) = map (g ∘ f) as + | [] => rfl + | a :: as => by rw [map_cons, map_cons, map_cons, map_map f g as]; rfl + +theorem append_nil' : as ++ [] = as := by + induction' as with a as ih + . rfl + . rw [cons_append, ih] + +theorem map_map' (f : α → β) (g : β → γ) (as : List α) : + map g (map f as) = map (g ∘ f) as := by + induction' as with a as ih + . rfl + . simp [map, ih] + +def reverse : List α → List α := sorry + +theorem reverse_append (as bs : List α) : reverse (as ++ bs) = reverse bs ++ reverse as := by + sorry + +theorem reverse_reverse (as : List α) : reverse (reverse as) = as := by sorry + +end MyListSpace3 + +inductive BinTree where + | empty : BinTree + | node : BinTree → BinTree → BinTree + +namespace BinTree + +def size : BinTree → ℕ + | empty => 0 + | node l r => size l + size r + 1 + +def depth : BinTree → ℕ + | empty => 0 + | node l r => max (depth l) (depth r) + 1 + +theorem size_le : ∀ t : BinTree, size t ≤ 2^depth t - 1 + | empty => Nat.zero_le _ + | node l r => by + simp only [depth, size] + calc l.size + r.size + 1 + ≤ (2^l.depth - 1) + (2^r.depth - 1) + 1 := by + gcongr <;> apply size_le + _ ≤ (2 ^ max l.depth r.depth - 1) + (2 ^ max l.depth r.depth - 1) + 1 := by + gcongr <;> simp + _ ≤ 2 ^ (max l.depth r.depth + 1) - 1 := by + have : 0 < 2 ^ max l.depth r.depth := by simp + omega + +theorem depth_le_size : ∀ t : BinTree, depth t ≤ size t := by sorry + +def flip : BinTree → BinTree := sorry + +example: flip (node (node empty (node empty empty)) (node empty empty)) = + node (node empty empty) (node (node empty empty) empty) := sorry + +theorem size_flip : ∀ t, size (flip t) = size t := by sorry +end BinTree + +inductive PropForm : Type where + | var (n : ℕ) : PropForm + | fls : PropForm + | conj (A B : PropForm) : PropForm + | disj (A B : PropForm) : PropForm + | impl (A B : PropForm) : PropForm +namespace PropForm + +def eval : PropForm → (ℕ → Bool) → Bool + | var n, v => v n + | fls, _ => false + | conj A B, v => A.eval v && B.eval v + | disj A B, v => A.eval v || B.eval v + | impl A B, v => ! A.eval v || B.eval v + +def vars : PropForm → Finset ℕ + | var n => {n} + | fls => ∅ + | conj A B => A.vars ∪ B.vars + | disj A B => A.vars ∪ B.vars + | impl A B => A.vars ∪ B.vars + +theorem eval_eq_eval : ∀ (A : PropForm) (v1 v2 : ℕ → Bool), + (∀ n ∈ A.vars, v1 n = v2 n) → A.eval v1 = A.eval v2 + | var n, v1, v2, h => by simp_all [vars, eval] + | fls, v1, v2, h => by simp_all [eval] + | conj A B, v1, v2, h => by + simp_all [vars, eval, eval_eq_eval A v1 v2, eval_eq_eval B v1 v2] + | disj A B, v1, v2, h => by + simp_all [vars, eval, eval_eq_eval A v1 v2, eval_eq_eval B v1 v2] + | impl A B, v1, v2, h => by + simp_all [vars, eval, eval_eq_eval A v1 v2, eval_eq_eval B v1 v2] + +theorem eval_eq_eval' (A : PropForm) (v1 v2 : ℕ → Bool) (h : ∀ n ∈ A.vars, v1 n = v2 n) : + A.eval v1 = A.eval v2 := by + cases A <;> simp_all [eval, vars, fun A => eval_eq_eval' A v1 v2] + +def subst : PropForm → ℕ → PropForm → PropForm + | var n, m, C => if n = m then C else var n + | fls, _, _ => fls + | conj A B, m, C => conj (A.subst m C) (B.subst m C) + | disj A B, m, C => disj (A.subst m C) (B.subst m C) + | impl A B, m, C => impl (A.subst m C) (B.subst m C) + +theorem subst_eq_of_not_mem_vars : + ∀ (A : PropForm) (n : ℕ) (C : PropForm), n ∉ A.vars → A.subst n C = A := sorry + +theorem subst_eval_eq : ∀ (A : PropForm) (n : ℕ) (C : PropForm) (v : ℕ → Bool), + (A.subst n C).eval v = A.eval (fun m => if m = n then C.eval v else v m) := sorry + +end PropForm diff --git a/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S01_Finsets_and_Fintypes.lean b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S01_Finsets_and_Fintypes.lean new file mode 100644 index 0000000..59a9787 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S01_Finsets_and_Fintypes.lean @@ -0,0 +1,12 @@ +module + +public meta import Mathlib.Data.Finset.Card -- for the #eval of Finset.card below +public meta import Mathlib.Data.Finset.Fold -- for the #eval of Finset.fold below + +public import Mathlib.Data.Finset.Powerset +public import Mathlib.Data.Finset.Max +public import Mathlib.Data.Nat.Prime.Basic +public import Mathlib.Data.Fintype.BigOperators + +public section + diff --git a/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S02_Counting_Arguments.lean b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S02_Counting_Arguments.lean new file mode 100644 index 0000000..205d764 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S02_Counting_Arguments.lean @@ -0,0 +1,69 @@ +module +public import Mathlib.Data.Fintype.BigOperators +public import Mathlib.Combinatorics.Pigeonhole +public import Mathlib.Tactic + +open Finset + +def triangle (n : ℕ) : Finset (ℕ × ℕ) := {p ∈ range (n+1) ×ˢ range (n+1) | p.1 < p.2} + +example (n : ℕ) : #(triangle n) = (n + 1) * n / 2 := by + apply Nat.eq_div_of_mul_eq_right (by norm_num) + let turn (p : ℕ × ℕ) : ℕ × ℕ := (n - 1 - p.1, n - p.2) + calc 2 * #(triangle n) + = #(triangle n) + #(triangle n) := by + ring + _ = #(triangle n) + #(triangle n |>.image turn) := by + rw [Finset.card_image_of_injOn] + rintro ⟨p1, p2⟩ hp ⟨q1, q2⟩ hq; simp [turn] + simp_all [triangle]; omega + _ = #(range n ×ˢ range (n + 1)) := by + rw [←Finset.card_union_of_disjoint]; swap + . rw [Finset.disjoint_iff_ne] + rintro ⟨p1, p2⟩ hp ⟨q1, q2⟩ hq; simp [turn] at * + simp_all [triangle]; omega + congr; ext p; rcases p with ⟨p1, p2⟩ + simp [triangle, turn] + constructor + . rintro (h | h) <;> omega + rcases Nat.lt_or_ge p1 p2 with h | h + . omega + . intro h' + right + use n - 1 - p1, n - p2 + omega + _ = (n + 1) * n := by + simp [mul_comm] + +def triangle' (n : ℕ) : Finset (ℕ × ℕ) := {p ∈ range n ×ˢ range n | p.1 ≤ p.2} + +example (n : ℕ) : #(triangle' n) = #(triangle n) := by + let f (p : ℕ × ℕ) : ℕ × ℕ := (p.1, p.2 + 1) + have : triangle n = (triangle' n |>.image f) := by + ext p; rcases p with ⟨p1, p2⟩ + simp [triangle, triangle', f] + constructor + . intro h + use p2 - 1 + omega + . simp; omega + rw [this, card_image_of_injOn] + rintro ⟨p1, p2⟩ hp ⟨q1, q2⟩ hq; simp [f] + +example {n : ℕ} (A : Finset ℕ) + (hA : #(A) = n + 1) + (hA' : A ⊆ range (2 * n)) : + ∃ m ∈ A, ∃ k ∈ A, Nat.Coprime m k := by + have : ∃ t ∈ range n, 1 < #({u ∈ A | u / 2 = t}) := by + apply exists_lt_card_fiber_of_mul_lt_card_of_maps_to + · intro u hu + specialize hA' hu + simp only [mem_range] at * + exact Nat.div_lt_of_lt_mul hA' + · simp [hA] + rcases this with ⟨t, ht, ht'⟩ + simp only [one_lt_card, mem_filter] at ht' + rcases ht' with ⟨m, ⟨hm, hm'⟩, k, ⟨hk, hk'⟩, hmk⟩ + use m, hm, k, hk + have : m = k + 1 ∨ k = m + 1 := by omega + rcases this with h | h <;> simp [h] diff --git a/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S03_Inductive_Structures.lean b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S03_Inductive_Structures.lean new file mode 100644 index 0000000..6825e31 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/solutions/Solutions_S03_Inductive_Structures.lean @@ -0,0 +1,132 @@ +module +public import Mathlib.Tactic + +namespace MyListSpace3 + +variable {α β γ : Type*} +variable (as bs cs : List α) +variable (a b c : α) + +open List + +def reverse : List α → List α + | [] => [] + | a :: as => reverse as ++ [a] + +theorem reverse_append (as bs : List α) : reverse (as ++ bs) = reverse bs ++ reverse as := by + induction' as with a as ih + . rw [nil_append, reverse, append_nil] + rw [cons_append, reverse, ih, reverse, append_assoc] + +theorem reverse_reverse (as : List α) : reverse (reverse as) = as := by + induction' as with a as ih + . rfl + rw [reverse, reverse_append, ih, reverse, reverse, nil_append, cons_append, nil_append] + +end MyListSpace3 + +inductive BinTree where + | empty : BinTree + | node : BinTree → BinTree → BinTree + +namespace BinTree + +def size : BinTree → ℕ + | empty => 0 + | node l r => size l + size r + 1 + +def depth : BinTree → ℕ + | empty => 0 + | node l r => max (depth l) (depth r) + 1 + +theorem depth_le_size : ∀ t : BinTree, depth t ≤ size t + | BinTree.empty => Nat.zero_le _ + | BinTree.node l r => by + simp only [depth, size, add_le_add_iff_right, max_le_iff] + constructor + . apply le_add_right + apply depth_le_size + . apply le_add_left + apply depth_le_size + +def flip : BinTree → BinTree + | empty => empty + | node l r => node (flip r) (flip l) + +example: flip (node (node empty (node empty empty)) (node empty empty)) = + node (node empty empty) (node (node empty empty) empty) := rfl + +theorem size_flip : ∀ t, size (flip t) = size t + | empty => rfl + | node l r => by + dsimp [size, flip] + rw [size_flip l, size_flip r]; omega + +end BinTree + +inductive PropForm : Type where + | var (n : ℕ) : PropForm + | fls : PropForm + | conj (A B : PropForm) : PropForm + | disj (A B : PropForm) : PropForm + | impl (A B : PropForm) : PropForm +namespace PropForm + +def eval : PropForm → (ℕ → Bool) → Bool + | var n, v => v n + | fls, _ => false + | conj A B, v => A.eval v && B.eval v + | disj A B, v => A.eval v || B.eval v + | impl A B, v => ! A.eval v || B.eval v + +def vars : PropForm → Finset ℕ + | var n => {n} + | fls => ∅ + | conj A B => A.vars ∪ B.vars + | disj A B => A.vars ∪ B.vars + | impl A B => A.vars ∪ B.vars + +def subst : PropForm → ℕ → PropForm → PropForm + | var n, m, C => if n = m then C else var n + | fls, _, _ => fls + | conj A B, m, C => conj (A.subst m C) (B.subst m C) + | disj A B, m, C => disj (A.subst m C) (B.subst m C) + | impl A B, m, C => impl (A.subst m C) (B.subst m C) + +theorem subst_eq_of_not_mem_vars : + ∀ (A : PropForm) (n : ℕ) (C : PropForm), n ∉ A.vars → A.subst n C = A + | var m, n, C, h => by simp_all [subst, vars]; tauto + | fls, n, C, _ => by rw [subst] + | conj A B, n, C, h => by + simp_all [subst, vars, subst_eq_of_not_mem_vars A, subst_eq_of_not_mem_vars B] + | disj A B, n, C, h => by + simp_all [subst, vars, subst_eq_of_not_mem_vars A, subst_eq_of_not_mem_vars B] + | impl A B, n, C, h => by + simp_all [subst, vars, subst_eq_of_not_mem_vars A, subst_eq_of_not_mem_vars B] + +-- alternative proof: +theorem subst_eq_of_not_mem_vars' (A : PropForm) (n : ℕ) (C : PropForm): + n ∉ A.vars → A.subst n C = A := by + cases A <;> simp_all [subst, vars, subst_eq_of_not_mem_vars']; tauto + +theorem subst_eval_eq : ∀ (A : PropForm) (n : ℕ) (C : PropForm) (v : ℕ → Bool), + (A.subst n C).eval v = A.eval (fun m => if m = n then C.eval v else v m) + | var m, n, C, v => by + simp [subst, eval] + split <;> simp [eval] + | fls, n, C, v => by + simp [subst, eval] + | conj A B, n, C, v => by + simp [subst, eval, subst_eval_eq A n C v, subst_eval_eq B n C v] + | disj A B, n, C, v => by + simp [subst, eval, subst_eval_eq A n C v, subst_eval_eq B n C v] + | impl A B, n, C, v => by + simp [subst, eval, subst_eval_eq A n C v, subst_eval_eq B n C v] + +-- alternative proof: +theorem subst_eval_eq' (A : PropForm) (n : ℕ) (C : PropForm) (v : ℕ → Bool) : + (A.subst n C).eval v = A.eval (fun m => if m = n then C.eval v else v m) := by + cases A <;> simp [subst, eval, subst_eval_eq']; + split <;> simp_all [eval] + +end PropForm diff --git a/dev/vendor/mathematics_in_lean/MIL/C07_Structures/S01_Structures.lean b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/S01_Structures.lean new file mode 100644 index 0000000..6e91ec6 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/S01_Structures.lean @@ -0,0 +1,213 @@ +module +public import MIL.Common +public import Mathlib.Algebra.BigOperators.Ring.List +public import Mathlib.Basic.Real.Basic + +namespace C06S01 +@[expose] public noncomputable section + +@[ext] +structure Point where + x : ℝ + y : ℝ + z : ℝ + +#check Point.ext + +example (a b : Point) (hx : a.x = b.x) (hy : a.y = b.y) (hz : a.z = b.z) : a = b := by + ext + repeat assumption + +def myPoint1 : Point where + x := 2 + y := -1 + z := 4 + +def myPoint2 : Point := + { x := 2, y := -1, z := 4 } + +def myPoint3 : Point := + ⟨2, -1, 4⟩ + +def myPoint4 := + Point.mk 2 (-1) 4 + +structure Point' where build :: + x : ℝ + y : ℝ + z : ℝ + +#check Point'.build 2 (-1) 4 + +namespace Point + +def add (a b : Point) : Point := + ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ + +def add' (a b : Point) : Point where + x := a.x + b.x + y := a.y + b.y + z := a.z + b.z + +#check add myPoint1 myPoint2 +#check myPoint1.add myPoint2 + +end Point + +#check Point.add myPoint1 myPoint2 +#check myPoint1.add myPoint2 + +namespace Point + +protected theorem add_comm (a b : Point) : add a b = add b a := by + rw [add, add] + ext <;> dsimp + repeat apply add_comm + +example (a b : Point) : add a b = add b a := by simp [add, add_comm] + +theorem add_x (a b : Point) : (a.add b).x = a.x + b.x := + rfl + +def addAlt : Point → Point → Point + | Point.mk x₁ y₁ z₁, Point.mk x₂ y₂ z₂ => ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩ + +def addAlt' : Point → Point → Point + | ⟨x₁, y₁, z₁⟩, ⟨x₂, y₂, z₂⟩ => ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩ + +theorem addAlt_x (a b : Point) : (a.addAlt b).x = a.x + b.x := by + rfl + +theorem addAlt_comm (a b : Point) : addAlt a b = addAlt b a := by + rw [addAlt, addAlt] + -- the same proof still works + ext <;> dsimp + repeat apply add_comm + +protected theorem add_assoc (a b c : Point) : (a.add b).add c = a.add (b.add c) := by + sorry + +def smul (r : ℝ) (a : Point) : Point := + sorry + +theorem smul_distrib (r : ℝ) (a b : Point) : + (smul r a).add (smul r b) = smul r (a.add b) := by + sorry + +end Point + +structure StandardTwoSimplex where + x : ℝ + y : ℝ + z : ℝ + x_nonneg : 0 ≤ x + y_nonneg : 0 ≤ y + z_nonneg : 0 ≤ z + sum_eq : x + y + z = 1 + +namespace StandardTwoSimplex + +def swapXy (a : StandardTwoSimplex) : StandardTwoSimplex + where + x := a.y + y := a.x + z := a.z + x_nonneg := a.y_nonneg + y_nonneg := a.x_nonneg + z_nonneg := a.z_nonneg + sum_eq := by rw [add_comm a.y a.x, a.sum_eq] + +noncomputable section + +def midpoint (a b : StandardTwoSimplex) : StandardTwoSimplex + where + x := (a.x + b.x) / 2 + y := (a.y + b.y) / 2 + z := (a.z + b.z) / 2 + x_nonneg := div_nonneg (add_nonneg a.x_nonneg b.x_nonneg) (by norm_num) + y_nonneg := div_nonneg (add_nonneg a.y_nonneg b.y_nonneg) (by norm_num) + z_nonneg := div_nonneg (add_nonneg a.z_nonneg b.z_nonneg) (by norm_num) + sum_eq := by field_simp; linarith [a.sum_eq, b.sum_eq] + +def weightedAverage (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) + (a b : StandardTwoSimplex) : StandardTwoSimplex := + sorry + +end + +end StandardTwoSimplex + +open BigOperators + +structure StandardSimplex (n : ℕ) where + V : Fin n → ℝ + NonNeg : ∀ i : Fin n, 0 ≤ V i + sum_eq_one : (∑ i, V i) = 1 + +namespace StandardSimplex + +def midpoint (n : ℕ) (a b : StandardSimplex n) : StandardSimplex n + where + V i := (a.V i + b.V i) / 2 + NonNeg := by + intro i + apply div_nonneg + · linarith [a.NonNeg i, b.NonNeg i] + norm_num + sum_eq_one := by + simp [div_eq_mul_inv, ← Finset.sum_mul, Finset.sum_add_distrib, + a.sum_eq_one, b.sum_eq_one] + norm_num + +end StandardSimplex + +structure IsLinear (f : ℝ → ℝ) where + is_additive : ∀ x y, f (x + y) = f x + f y + preserves_mul : ∀ x c, f (c * x) = c * f x + +section +variable (f : ℝ → ℝ) (linf : IsLinear f) + +#check linf.is_additive +#check linf.preserves_mul + +end + +def Point'' := + ℝ × ℝ × ℝ + +def IsLinear' (f : ℝ → ℝ) := + (∀ x y, f (x + y) = f x + f y) ∧ ∀ x c, f (c * x) = c * f x + +def PReal := + { y : ℝ // 0 < y } + +section +variable (x : PReal) + +#check x.val +#check x.property +#check x.1 +#check x.2 + +end + +def StandardTwoSimplex' := + { p : ℝ × ℝ × ℝ // 0 ≤ p.1 ∧ 0 ≤ p.2.1 ∧ 0 ≤ p.2.2 ∧ p.1 + p.2.1 + p.2.2 = 1 } + +def StandardSimplex' (n : ℕ) := + { v : Fin n → ℝ // (∀ i : Fin n, 0 ≤ v i) ∧ (∑ i, v i) = 1 } + +def StdSimplex := Σ n : ℕ, StandardSimplex n + +section +variable (s : StdSimplex) + +#check s.fst +#check s.snd + +#check s.1 +#check s.2 + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C07_Structures/S02_Algebraic_Structures.lean b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/S02_Algebraic_Structures.lean new file mode 100644 index 0000000..d4ccd6a --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/S02_Algebraic_Structures.lean @@ -0,0 +1,174 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C06S02 + +structure Group₁ (α : Type*) where + mul : α → α → α + one : α + inv : α → α + mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z) + mul_one : ∀ x : α, mul x one = x + one_mul : ∀ x : α, mul one x = x + inv_mul_cancel : ∀ x : α, mul (inv x) x = one + +structure Grp₁ where + α : Type* + str : Group₁ α + +section +variable (α β γ : Type*) +variable (f : α ≃ β) (g : β ≃ γ) + +#check Equiv α β +#check (f.toFun : α → β) +#check (f.invFun : β → α) +#check (f.right_inv : ∀ x : β, f (f.invFun x) = x) +#check (f.left_inv : ∀ x : α, f.invFun (f x) = x) +#check (Equiv.refl α : α ≃ α) +#check (f.symm : β ≃ α) +#check (f.trans g : α ≃ γ) + +example (x : α) : (f.trans g).toFun x = g.toFun (f.toFun x) := + rfl + +example (x : α) : (f.trans g) x = g (f x) := + rfl + +example : (f.trans g : α → γ) = g ∘ f := + rfl + +end + +example (α : Type*) : Equiv.Perm α = (α ≃ α) := + rfl + +def permGroup {α : Type*} : Group₁ (Equiv.Perm α) + where + mul f g := Equiv.trans g f + one := Equiv.refl α + inv := Equiv.symm + mul_assoc f g h := (Equiv.trans_assoc h g f).symm + one_mul := Equiv.trans_refl + mul_one := Equiv.refl_trans + inv_mul_cancel := Equiv.self_trans_symm + +structure AddGroup₁ (α : Type*) where + (add : α → α → α) + -- fill in the rest +@[ext] +structure Point where + x : ℝ + y : ℝ + z : ℝ + +namespace Point + +def add (a b : Point) : Point := + ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ + +def neg (a : Point) : Point := sorry + +def zero : Point := sorry + +def addGroupPoint : AddGroup₁ Point := sorry + +end Point + +section +variable {α : Type*} (f g : Equiv.Perm α) (n : ℕ) + +#check f * g +#check mul_assoc f g g⁻¹ + +-- group power, defined for any group +#check g ^ n + +example : f * g * g⁻¹ = f := by rw [mul_assoc, mul_inv_cancel, mul_one] + +example : f * g * g⁻¹ = f := + mul_inv_cancel_right f g + +example {α : Type*} (f g : Equiv.Perm α) : g.symm.trans (g.trans f) = f := + mul_inv_cancel_right f g + +end + +class Group₂ (α : Type*) where + mul : α → α → α + one : α + inv : α → α + mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z) + mul_one : ∀ x : α, mul x one = x + one_mul : ∀ x : α, mul one x = x + inv_mul_cancel : ∀ x : α, mul (inv x) x = one + +instance {α : Type*} : Group₂ (Equiv.Perm α) where + mul f g := Equiv.trans g f + one := Equiv.refl α + inv := Equiv.symm + mul_assoc f g h := (Equiv.trans_assoc h g f).symm + one_mul := Equiv.trans_refl + mul_one := Equiv.refl_trans + inv_mul_cancel := Equiv.self_trans_symm + +#check Group₂.mul + +def mySquare {α : Type*} [Group₂ α] (x : α) := + Group₂.mul x x + +#check mySquare + +section +variable {β : Type*} (f g : Equiv.Perm β) + +example : Group₂.mul f g = g.trans f := + rfl + +example : mySquare f = f.trans f := + rfl + +end + +instance : Inhabited Point where default := ⟨0, 0, 0⟩ + +#check (default : Point) + +example : ([] : List Point).headI = default := + rfl + +instance : Add Point where add := Point.add + +section +variable (x y : Point) + +#check x + y + +example : x + y = Point.add x y := + rfl + +end + +instance {α : Type*} [Group₂ α] : Mul α := + ⟨Group₂.mul⟩ + +instance {α : Type*} [Group₂ α] : One α := + ⟨Group₂.one⟩ + +instance {α : Type*} [Group₂ α] : Inv α := + ⟨Group₂.inv⟩ + +section +variable {α : Type*} (f g : Equiv.Perm α) + +#check f * 1 * g⁻¹ + +lemma foo : f * 1 * g⁻¹ = g.symm.trans ((Equiv.refl α).trans f) := + rfl + +end + +class AddGroup₂ (α : Type*) where + add : α → α → α + -- fill in the rest diff --git a/dev/vendor/mathematics_in_lean/MIL/C07_Structures/S03_Building_the_Gaussian_Integers.lean b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/S03_Building_the_Gaussian_Integers.lean new file mode 100644 index 0000000..97ff61f --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/S03_Building_the_Gaussian_Integers.lean @@ -0,0 +1,278 @@ +module +public import Mathlib.Algebra.EuclideanDomain.Basic +public import Mathlib.RingTheory.PrincipalIdealDomain +public import MIL.Common + +@[ext] +structure GaussInt where + re : ℤ + im : ℤ + +namespace GaussInt + +instance : Zero GaussInt := + ⟨⟨0, 0⟩⟩ + +instance : One GaussInt := + ⟨⟨1, 0⟩⟩ + +instance : Add GaussInt := + ⟨fun x y ↦ ⟨x.re + y.re, x.im + y.im⟩⟩ + +instance : Neg GaussInt := + ⟨fun x ↦ ⟨-x.re, -x.im⟩⟩ + +instance : Mul GaussInt := + ⟨fun x y ↦ ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩⟩ + +theorem zero_def : (0 : GaussInt) = ⟨0, 0⟩ := + rfl + +theorem one_def : (1 : GaussInt) = ⟨1, 0⟩ := + rfl + +theorem add_def (x y : GaussInt) : x + y = ⟨x.re + y.re, x.im + y.im⟩ := + rfl + +theorem neg_def (x : GaussInt) : -x = ⟨-x.re, -x.im⟩ := + rfl + +theorem mul_def (x y : GaussInt) : + x * y = ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩ := + rfl + +@[simp] +theorem zero_re : (0 : GaussInt).re = 0 := + rfl + +@[simp] +theorem zero_im : (0 : GaussInt).im = 0 := + rfl + +@[simp] +theorem one_re : (1 : GaussInt).re = 1 := + rfl + +@[simp] +theorem one_im : (1 : GaussInt).im = 0 := + rfl + +@[simp] +theorem add_re (x y : GaussInt) : (x + y).re = x.re + y.re := + rfl + +@[simp] +theorem add_im (x y : GaussInt) : (x + y).im = x.im + y.im := + rfl + +@[simp] +theorem neg_re (x : GaussInt) : (-x).re = -x.re := + rfl + +@[simp] +theorem neg_im (x : GaussInt) : (-x).im = -x.im := + rfl + +@[simp] +theorem mul_re (x y : GaussInt) : (x * y).re = x.re * y.re - x.im * y.im := + rfl + +@[simp] +theorem mul_im (x y : GaussInt) : (x * y).im = x.re * y.im + x.im * y.re := + rfl + +instance instCommRing : CommRing GaussInt where + zero := 0 + one := 1 + add := (· + ·) + neg x := -x + mul := (· * ·) + nsmul := nsmulRec + zsmul := zsmulRec + add_assoc := by + intros + ext <;> simp <;> ring + zero_add := by + intro + ext <;> simp + add_zero := by + intro + ext <;> simp + neg_add_cancel := by + intro + ext <;> simp + add_comm := by + intros + ext <;> simp <;> ring + mul_assoc := by + intros + ext <;> simp <;> ring + one_mul := by + intro + ext <;> simp + mul_one := by + intro + ext <;> simp + left_distrib := by + intros + ext <;> simp <;> ring + right_distrib := by + intros + ext <;> simp <;> ring + mul_comm := by + intros + ext <;> simp <;> ring + zero_mul := by + intros + ext <;> simp + mul_zero := by + intros + ext <;> simp + +@[simp] +theorem sub_re (x y : GaussInt) : (x - y).re = x.re - y.re := + rfl + +@[simp] +theorem sub_im (x y : GaussInt) : (x - y).im = x.im - y.im := + rfl + +instance : Nontrivial GaussInt := by + use 0, 1 + rw [Ne, GaussInt.ext_iff] + simp + +end GaussInt + +example (a b : ℤ) : a = b * (a / b) + a % b := + Eq.symm (Int.mul_ediv_add_emod a b) + +example (a b : ℤ) : b ≠ 0 → 0 ≤ a % b := + Int.emod_nonneg a + +example (a b : ℤ) : b ≠ 0 → a % b < |b| := + Int.emod_lt_abs a + +namespace Int + +def div' (a b : ℤ) := + (a + b / 2) / b + +def mod' (a b : ℤ) := + (a + b / 2) % b - b / 2 + +theorem div'_add_mod' (a b : ℤ) : b * div' a b + mod' a b = a := by + rw [div', mod'] + linarith [Int.mul_ediv_add_emod (a + b / 2) b] + +theorem abs_mod'_le (a b : ℤ) (h : 0 < b) : |mod' a b| ≤ b / 2 := by + rw [mod', abs_le] + constructor + · linarith [Int.emod_nonneg (a + b / 2) h.ne'] + have := Int.emod_lt_of_pos (a + b / 2) h + have := Int.mul_ediv_add_emod b 2 + have := Int.emod_lt_of_pos b zero_lt_two + linarith + +theorem mod'_eq (a b : ℤ) : mod' a b = a - b * div' a b := by linarith [div'_add_mod' a b] + +end Int + +theorem square_add_sq_eq_zero {α : Type*} [Ring α] [LinearOrder α] [IsStrictOrderedRing α] + (x y : α) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by + sorry +namespace GaussInt + +def norm (x : GaussInt) := + x.re ^ 2 + x.im ^ 2 + +@[simp] +theorem norm_nonneg (x : GaussInt) : 0 ≤ norm x := by + sorry +theorem norm_eq_zero (x : GaussInt) : norm x = 0 ↔ x = 0 := by + sorry +theorem norm_pos (x : GaussInt) : 0 < norm x ↔ x ≠ 0 := by + sorry +theorem norm_mul (x y : GaussInt) : norm (x * y) = norm x * norm y := by + sorry +def conj (x : GaussInt) : GaussInt := + ⟨x.re, -x.im⟩ + +@[simp] +theorem conj_re (x : GaussInt) : (conj x).re = x.re := + rfl + +@[simp] +theorem conj_im (x : GaussInt) : (conj x).im = -x.im := + rfl + +theorem norm_conj (x : GaussInt) : norm (conj x) = norm x := by simp [norm] + +instance : Div GaussInt := + ⟨fun x y ↦ ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩⟩ + +instance : Mod GaussInt := + ⟨fun x y ↦ x - y * (x / y)⟩ + +theorem div_def (x y : GaussInt) : + x / y = ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩ := + rfl + +theorem mod_def (x y : GaussInt) : x % y = x - y * (x / y) := + rfl + +theorem norm_mod_lt (x : GaussInt) {y : GaussInt} (hy : y ≠ 0) : + (x % y).norm < y.norm := by + have norm_y_pos : 0 < norm y := by rwa [norm_pos] + have H1 : x % y * conj y = ⟨Int.mod' (x * conj y).re (norm y), Int.mod' (x * conj y).im (norm y)⟩ + · ext <;> simp [Int.mod'_eq, mod_def, div_def, norm] <;> ring + have H2 : norm (x % y) * norm y ≤ norm y / 2 * norm y + · calc + norm (x % y) * norm y = norm (x % y * conj y) := by simp only [norm_mul, norm_conj] + _ = |Int.mod' (x.re * y.re + x.im * y.im) (norm y)| ^ 2 + + |Int.mod' (-(x.re * y.im) + x.im * y.re) (norm y)| ^ 2 := by simp [H1, norm, sq_abs] + _ ≤ (y.norm / 2) ^ 2 + (y.norm / 2) ^ 2 := by gcongr <;> apply Int.abs_mod'_le _ _ norm_y_pos + _ = norm y / 2 * (norm y / 2 * 2) := by ring + _ ≤ norm y / 2 * norm y := by gcongr; apply Int.ediv_mul_le; norm_num + calc norm (x % y) ≤ norm y / 2 := le_of_mul_le_mul_right H2 norm_y_pos + _ < norm y := by + apply Int.ediv_lt_of_lt_mul + · norm_num + · linarith + +theorem coe_natAbs_norm (x : GaussInt) : (x.norm.natAbs : ℤ) = x.norm := + Int.natAbs_of_nonneg (norm_nonneg _) + +theorem natAbs_norm_mod_lt (x y : GaussInt) (hy : y ≠ 0) : + (x % y).norm.natAbs < y.norm.natAbs := by + apply Int.ofNat_lt.1 + simp only [Int.natCast_natAbs, abs_of_nonneg, norm_nonneg] + exact norm_mod_lt x hy + +theorem not_norm_mul_left_lt_norm (x : GaussInt) {y : GaussInt} (hy : y ≠ 0) : + ¬(norm (x * y)).natAbs < (norm x).natAbs := by + apply not_lt_of_ge + rw [norm_mul, Int.natAbs_mul] + apply le_mul_of_one_le_right (Nat.zero_le _) + apply Int.ofNat_le.1 + rw [coe_natAbs_norm] + exact Int.add_one_le_of_lt ((norm_pos _).mpr hy) + +instance : EuclideanDomain GaussInt := + { GaussInt.instCommRing with + quotient := (· / ·) + remainder := (· % ·) + quotient_mul_add_remainder_eq := + fun x y ↦ by rw [mod_def, add_comm] ; ring + quotient_zero := fun x ↦ by + simp [div_def, norm, Int.div'] + rfl + r := (measure (Int.natAbs ∘ norm)).1 + r_wellFounded := (measure (Int.natAbs ∘ norm)).2 + remainder_lt := natAbs_norm_mod_lt + mul_left_not_lt := not_norm_mul_left_lt_norm } + +example (x : GaussInt) : Irreducible x ↔ Prime x := + irreducible_iff_prime + +end GaussInt diff --git a/dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S01_Structures.lean b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S01_Structures.lean new file mode 100644 index 0000000..5a31e14 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S01_Structures.lean @@ -0,0 +1,101 @@ +module +public import MIL.Common +public import Mathlib.Algebra.BigOperators.Ring.List +public import Mathlib.Basic.Real.Basic + +namespace C06S01 +@[expose] public noncomputable section + +@[ext] +structure Point where + x : ℝ + y : ℝ + z : ℝ + +namespace Point + +def add (a b : Point) : Point := + ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ + +protected theorem add_assoc (a b c : Point) : (a.add b).add c = a.add (b.add c) := by + simp [add, add_assoc] + +def smul (r : ℝ) (a : Point) : Point := + ⟨r * a.x, r * a.y, r * a.z⟩ + +theorem smul_distrib (r : ℝ) (a b : Point) : + (smul r a).add (smul r b) = smul r (a.add b) := by + simp [add, smul, mul_add] + +end Point + +structure StandardTwoSimplex where + x : ℝ + y : ℝ + z : ℝ + x_nonneg : 0 ≤ x + y_nonneg : 0 ≤ y + z_nonneg : 0 ≤ z + sum_eq : x + y + z = 1 + +namespace StandardTwoSimplex + +noncomputable section + +def weightedAverage (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) + (a b : StandardTwoSimplex) : StandardTwoSimplex +where + x := lambda * a.x + (1 - lambda) * b.x + y := lambda * a.y + (1 - lambda) * b.y + z := lambda * a.z + (1 - lambda) * b.z + x_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.x_nonneg) (mul_nonneg (by linarith) b.x_nonneg) + y_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.y_nonneg) (mul_nonneg (by linarith) b.y_nonneg) + z_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.z_nonneg) (mul_nonneg (by linarith) b.z_nonneg) + sum_eq := by + trans (a.x + a.y + a.z) * lambda + (b.x + b.y + b.z) * (1 - lambda) + · ring + simp [a.sum_eq, b.sum_eq] + +end + +end StandardTwoSimplex + +open BigOperators + +structure StandardSimplex (n : ℕ) where + V : Fin n → ℝ + NonNeg : ∀ i : Fin n, 0 ≤ V i + sum_eq_one : (∑ i, V i) = 1 + +namespace StandardSimplex + +def midpoint (n : ℕ) (a b : StandardSimplex n) : StandardSimplex n + where + V i := (a.V i + b.V i) / 2 + NonNeg := by + intro i + apply div_nonneg + · linarith [a.NonNeg i, b.NonNeg i] + norm_num + sum_eq_one := by + simp [div_eq_mul_inv, ← Finset.sum_mul, Finset.sum_add_distrib, + a.sum_eq_one, b.sum_eq_one] + norm_num + +end StandardSimplex + +namespace StandardSimplex + +def weightedAverage {n : ℕ} (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) + (a b : StandardSimplex n) : StandardSimplex n + where + V i := lambda * a.V i + (1 - lambda) * b.V i + NonNeg i := + add_nonneg (mul_nonneg lambda_nonneg (a.NonNeg i)) (mul_nonneg (by linarith) (b.NonNeg i)) + sum_eq_one := by + trans (lambda * ∑ i, a.V i) + (1 - lambda) * ∑ i, b.V i + · rw [Finset.sum_add_distrib, Finset.mul_sum, Finset.mul_sum] + simp [a.sum_eq_one, b.sum_eq_one] + +end StandardSimplex + diff --git a/dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S02_Algebraic_Structures.lean b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S02_Algebraic_Structures.lean new file mode 100644 index 0000000..1fc57e1 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S02_Algebraic_Structures.lean @@ -0,0 +1,77 @@ +module +public import MIL.Common +public import Mathlib.Basic.Real.Basic + +namespace C06S02 + +structure AddGroup₁ (α : Type*) where + add : α → α → α + zero : α + neg : α → α + add_assoc : ∀ x y z : α, add (add x y) z = add x (add y z) + add_zero : ∀ x : α, add x zero = x + zero_add : ∀ x : α, add zero x = x + neg_add_cancel : ∀ x : α, add (neg x) x = zero + +@[ext] +structure Point where + x : ℝ + y : ℝ + z : ℝ + +namespace Point + +def add (a b : Point) : Point := + ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ + +def neg (a : Point) : Point := + ⟨-a.x, -a.y, -a.z⟩ + +def zero : Point := + ⟨0, 0, 0⟩ + +def addGroupPoint : AddGroup₁ Point where + add := Point.add + zero := Point.zero + neg := Point.neg + add_assoc := by simp [Point.add, add_assoc] + add_zero := by simp [Point.add, Point.zero] + zero_add := by simp [Point.add, Point.zero] + neg_add_cancel := by simp [Point.add, Point.neg, Point.zero] + +end Point + +class AddGroup₂ (α : Type*) where + add : α → α → α + zero : α + neg : α → α + add_assoc : ∀ x y z : α, add (add x y) z = add x (add y z) + add_zero : ∀ x : α, add x zero = x + zero_add : ∀ x : α, add zero x = x + neg_add_cancel : ∀ x : α, add (neg x) x = zero + +instance hasAddAddGroup₂ {α : Type*} [AddGroup₂ α] : Add α := + ⟨AddGroup₂.add⟩ + +instance hasZeroAddGroup₂ {α : Type*} [AddGroup₂ α] : Zero α := + ⟨AddGroup₂.zero⟩ + +instance hasNegAddGroup₂ {α : Type*} [AddGroup₂ α] : Neg α := + ⟨AddGroup₂.neg⟩ + +instance : AddGroup₂ Point where + add := Point.add + zero := Point.zero + neg := Point.neg + add_assoc := by simp [Point.add, add_assoc] + add_zero := by simp [Point.add, Point.zero] + zero_add := by simp [Point.add, Point.zero] + neg_add_cancel := by simp [Point.add, Point.neg, Point.zero] + +section +variable (x y : Point) + +#check x + -y + 0 + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S03_Building_the_Gaussian_Integers.lean b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S03_Building_the_Gaussian_Integers.lean new file mode 100644 index 0000000..b5ca33c --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S03_Building_the_Gaussian_Integers.lean @@ -0,0 +1,292 @@ +module +public import Mathlib.Algebra.EuclideanDomain.Basic +public import Mathlib.RingTheory.PrincipalIdealDomain +public import MIL.Common + +@[ext] +structure GaussInt where + re : ℤ + im : ℤ + +namespace GaussInt + +instance : Zero GaussInt := + ⟨⟨0, 0⟩⟩ + +instance : One GaussInt := + ⟨⟨1, 0⟩⟩ + +instance : Add GaussInt := + ⟨fun x y ↦ ⟨x.re + y.re, x.im + y.im⟩⟩ + +instance : Neg GaussInt := + ⟨fun x ↦ ⟨-x.re, -x.im⟩⟩ + +instance : Mul GaussInt := + ⟨fun x y ↦ ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩⟩ + +theorem zero_def : (0 : GaussInt) = ⟨0, 0⟩ := + rfl + +theorem one_def : (1 : GaussInt) = ⟨1, 0⟩ := + rfl + +theorem add_def (x y : GaussInt) : x + y = ⟨x.re + y.re, x.im + y.im⟩ := + rfl + +theorem neg_def (x : GaussInt) : -x = ⟨-x.re, -x.im⟩ := + rfl + +theorem mul_def (x y : GaussInt) : + x * y = ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩ := + rfl + +@[simp] +theorem zero_re : (0 : GaussInt).re = 0 := + rfl + +@[simp] +theorem zero_im : (0 : GaussInt).im = 0 := + rfl + +@[simp] +theorem one_re : (1 : GaussInt).re = 1 := + rfl + +@[simp] +theorem one_im : (1 : GaussInt).im = 0 := + rfl + +@[simp] +theorem add_re (x y : GaussInt) : (x + y).re = x.re + y.re := + rfl + +@[simp] +theorem add_im (x y : GaussInt) : (x + y).im = x.im + y.im := + rfl + +@[simp] +theorem neg_re (x : GaussInt) : (-x).re = -x.re := + rfl + +@[simp] +theorem neg_im (x : GaussInt) : (-x).im = -x.im := + rfl + +@[simp] +theorem mul_re (x y : GaussInt) : (x * y).re = x.re * y.re - x.im * y.im := + rfl + +@[simp] +theorem mul_im (x y : GaussInt) : (x * y).im = x.re * y.im + x.im * y.re := + rfl + +instance instCommRing : CommRing GaussInt where + zero := 0 + one := 1 + add := (· + ·) + neg x := -x + mul := (· * ·) + nsmul := nsmulRec + zsmul := zsmulRec + add_assoc := by + intros + ext <;> simp <;> ring + zero_add := by + intro + ext <;> simp + add_zero := by + intro + ext <;> simp + neg_add_cancel := by + intro + ext <;> simp + add_comm := by + intros + ext <;> simp <;> ring + mul_assoc := by + intros + ext <;> simp <;> ring + one_mul := by + intro + ext <;> simp + mul_one := by + intro + ext <;> simp + left_distrib := by + intros + ext <;> simp <;> ring + right_distrib := by + intros + ext <;> simp <;> ring + mul_comm := by + intros + ext <;> simp <;> ring + zero_mul := by + intros + ext <;> simp + mul_zero := by + intros + ext <;> simp + +@[simp] +theorem sub_re (x y : GaussInt) : (x - y).re = x.re - y.re := + rfl + +@[simp] +theorem sub_im (x y : GaussInt) : (x - y).im = x.im - y.im := + rfl + +instance : Nontrivial GaussInt := by + use 0, 1 + rw [Ne, GaussInt.ext_iff] + simp + +end GaussInt + +namespace Int + +def div' (a b : ℤ) := + (a + b / 2) / b + +def mod' (a b : ℤ) := + (a + b / 2) % b - b / 2 + +theorem div'_add_mod' (a b : ℤ) : b * div' a b + mod' a b = a := by + rw [div', mod'] + linarith [Int.mul_ediv_add_emod (a + b / 2) b] + +theorem abs_mod'_le (a b : ℤ) (h : 0 < b) : |mod' a b| ≤ b / 2 := by + rw [mod', abs_le] + constructor + · linarith [Int.emod_nonneg (a + b / 2) h.ne'] + have := Int.emod_lt_of_pos (a + b / 2) h + have := Int.mul_ediv_add_emod b 2 + have := Int.emod_lt_of_pos b zero_lt_two + linarith + +theorem mod'_eq (a b : ℤ) : mod' a b = a - b * div' a b := by linarith [div'_add_mod' a b] + +end Int + +private theorem aux {α : Type*} [Ring α] [LinearOrder α] [IsStrictOrderedRing α] {x y : α} (h : x ^ 2 + y ^ 2 = 0) : x = 0 := + haveI h' : x ^ 2 = 0 := by + apply le_antisymm _ (sq_nonneg x) + rw [← h] + apply le_add_of_nonneg_right (sq_nonneg y) + eq_zero_of_pow_eq_zero h' + +theorem square_add_sq_eq_zero {α : Type*} [Ring α] [LinearOrder α] [IsStrictOrderedRing α] + (x y : α) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by + constructor + · intro h + constructor + · exact aux h + rw [add_comm] at h + exact aux h + rintro ⟨rfl, rfl⟩ + norm_num + +namespace GaussInt + +def norm (x : GaussInt) := + x.re ^ 2 + x.im ^ 2 + +@[simp] +theorem norm_nonneg (x : GaussInt) : 0 ≤ norm x := by + apply add_nonneg <;> + apply sq_nonneg + +theorem norm_eq_zero (x : GaussInt) : norm x = 0 ↔ x = 0 := by + rw [norm, square_add_sq_eq_zero, GaussInt.ext_iff] + rfl + +theorem norm_pos (x : GaussInt) : 0 < norm x ↔ x ≠ 0 := by + rw [lt_iff_le_and_ne, ne_comm, Ne, norm_eq_zero] + simp [norm_nonneg] + +theorem norm_mul (x y : GaussInt) : norm (x * y) = norm x * norm y := by + simp [norm] + ring + +def conj (x : GaussInt) : GaussInt := + ⟨x.re, -x.im⟩ + +@[simp] +theorem conj_re (x : GaussInt) : (conj x).re = x.re := + rfl + +@[simp] +theorem conj_im (x : GaussInt) : (conj x).im = -x.im := + rfl + +theorem norm_conj (x : GaussInt) : norm (conj x) = norm x := by simp [norm] + +instance : Div GaussInt := + ⟨fun x y ↦ ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩⟩ + +instance : Mod GaussInt := + ⟨fun x y ↦ x - y * (x / y)⟩ + +theorem div_def (x y : GaussInt) : + x / y = ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩ := + rfl + +theorem mod_def (x y : GaussInt) : x % y = x - y * (x / y) := + rfl + +theorem norm_mod_lt (x : GaussInt) {y : GaussInt} (hy : y ≠ 0) : + (x % y).norm < y.norm := by + have norm_y_pos : 0 < norm y := by rwa [norm_pos] + have H1 : x % y * conj y = ⟨Int.mod' (x * conj y).re (norm y), Int.mod' (x * conj y).im (norm y)⟩ + · ext <;> simp [Int.mod'_eq, mod_def, div_def, norm] <;> ring + have H2 : norm (x % y) * norm y ≤ norm y / 2 * norm y + · calc + norm (x % y) * norm y = norm (x % y * conj y) := by simp only [norm_mul, norm_conj] + _ = |Int.mod' (x.re * y.re + x.im * y.im) (norm y)| ^ 2 + + |Int.mod' (-(x.re * y.im) + x.im * y.re) (norm y)| ^ 2 := by simp [H1, norm, sq_abs] + _ ≤ (y.norm / 2) ^ 2 + (y.norm / 2) ^ 2 := by gcongr <;> apply Int.abs_mod'_le _ _ norm_y_pos + _ = norm y / 2 * (norm y / 2 * 2) := by ring + _ ≤ norm y / 2 * norm y := by gcongr; apply Int.ediv_mul_le; norm_num + calc norm (x % y) ≤ norm y / 2 := le_of_mul_le_mul_right H2 norm_y_pos + _ < norm y := by + apply Int.ediv_lt_of_lt_mul + · norm_num + · linarith + +theorem coe_natAbs_norm (x : GaussInt) : (x.norm.natAbs : ℤ) = x.norm := + Int.natAbs_of_nonneg (norm_nonneg _) + +theorem natAbs_norm_mod_lt (x y : GaussInt) (hy : y ≠ 0) : + (x % y).norm.natAbs < y.norm.natAbs := by + apply Int.ofNat_lt.1 + simp only [Int.natCast_natAbs, abs_of_nonneg, norm_nonneg] + exact norm_mod_lt x hy + +theorem not_norm_mul_left_lt_norm (x : GaussInt) {y : GaussInt} (hy : y ≠ 0) : + ¬(norm (x * y)).natAbs < (norm x).natAbs := by + apply not_lt_of_ge + rw [norm_mul, Int.natAbs_mul] + apply le_mul_of_one_le_right (Nat.zero_le _) + apply Int.ofNat_le.1 + rw [coe_natAbs_norm] + exact Int.add_one_le_of_lt ((norm_pos _).mpr hy) + +instance : EuclideanDomain GaussInt := + { GaussInt.instCommRing with + quotient := (· / ·) + remainder := (· % ·) + quotient_mul_add_remainder_eq := + fun x y ↦ by rw [mod_def, add_comm] ; ring + quotient_zero := fun x ↦ by + simp [div_def, norm, Int.div'] + rfl + r := (measure (Int.natAbs ∘ norm)).1 + r_wellFounded := (measure (Int.natAbs ∘ norm)).2 + remainder_lt := natAbs_norm_mod_lt + mul_left_not_lt := not_norm_mul_left_lt_norm } + +example (x : GaussInt) : Irreducible x ↔ Prime x := + irreducible_iff_prime + +end GaussInt diff --git a/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S01_Basics.lean b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S01_Basics.lean new file mode 100644 index 0000000..f80b60d --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S01_Basics.lean @@ -0,0 +1,316 @@ +module +public import MIL.Common +public import Mathlib.Algebra.BigOperators.Ring.List +public import Mathlib.Basic.Real.Basic + +public section +set_option autoImplicit true + + +class One₁ (α : Type) where + /-- The element one -/ + one : α + + +#check One₁.one -- One₁.one {α : Type} [self : One₁ α] : α + +@[class] structure One₂ (α : Type) where + /-- The element one -/ + one : α + +#check One₂.one + + +example (α : Type) [One₁ α] : α := One₁.one + +example (α : Type) [One₁ α] := (One₁.one : α) + +@[inherit_doc] +notation "𝟙" => One₁.one + +example {α : Type} [One₁ α] : α := 𝟙 + +example {α : Type} [One₁ α] : (𝟙 : α) = 𝟙 := rfl + + +class Dia₁ (α : Type) where + dia : α → α → α + +infixl:70 " ⋄ " => Dia₁.dia + + +class Semigroup₀ (α : Type) where + toDia₁ : Dia₁ α + /-- Diamond is associative -/ + dia_assoc : ∀ a b c : α, a ⋄ b ⋄ c = a ⋄ (b ⋄ c) + + +attribute [reducible, instance] Semigroup₀.toDia₁ + +example {α : Type} [Semigroup₀ α] (a b : α) : α := a ⋄ b + + +class Semigroup₁ (α : Type) extends toDia₁ : Dia₁ α where + /-- Diamond is associative -/ + dia_assoc : ∀ a b c : α, a ⋄ b ⋄ c = a ⋄ (b ⋄ c) + +example {α : Type} [Semigroup₁ α] (a b : α) : α := a ⋄ b + + +class Semigroup₂ (α : Type) extends Dia₁ α where + /-- Diamond is associative -/ + dia_assoc : ∀ a b c : α, a ⋄ b ⋄ c = a ⋄ (b ⋄ c) + +class DiaOneClass₁ (α : Type) extends One₁ α, Dia₁ α where + /-- One is a left neutral element for diamond. -/ + one_dia : ∀ a : α, 𝟙 ⋄ a = a + /-- One is a right neutral element for diamond -/ + dia_one : ∀ a : α, a ⋄ 𝟙 = a + + + +set_option trace.Meta.synthInstance true in +example {α : Type} [DiaOneClass₁ α] (a b : α) : Prop := a ⋄ b = 𝟙 + + +class Monoid₁ (α : Type) extends Semigroup₁ α, DiaOneClass₁ α + + +class Monoid₂ (α : Type) where + toSemigroup₁ : Semigroup₁ α + toDiaOneClass₁ : DiaOneClass₁ α + + +example {α : Type} [Monoid₁ α] : + (Monoid₁.toSemigroup₁.toDia₁.dia : α → α → α) = Monoid₁.toDiaOneClass₁.toDia₁.dia := rfl + + +/- Monoid₂.mk {α : Type} (toSemigroup₁ : Semigroup₁ α) (toDiaOneClass₁ : DiaOneClass₁ α) : Monoid₂ α -/ +#check Monoid₂.mk + +/- Monoid₁.mk {α : Type} [toSemigroup₁ : Semigroup₁ α] [toOne₁ : One₁ α] (one_dia : ∀ (a : α), 𝟙 ⋄ a = a) (dia_one : ∀ (a : α), a ⋄ 𝟙 = a) : Monoid₁ α -/ +#check Monoid₁.mk + + +#check Monoid₁.toSemigroup₁ +#check Monoid₁.toDiaOneClass₁ + + +class Inv₁ (α : Type) where + /-- The inversion function -/ + inv : α → α + +@[inherit_doc] +postfix:max "⁻¹" => Inv₁.inv + +class Group₁ (G : Type) extends Monoid₁ G, Inv₁ G where + inv_dia : ∀ a : G, a⁻¹ ⋄ a = 𝟙 + + +lemma left_inv_eq_right_inv₁ {M : Type} [Monoid₁ M] {a b c : M} (hba : b ⋄ a = 𝟙) (hac : a ⋄ c = 𝟙) : b = c := by + rw [← DiaOneClass₁.one_dia c, ← hba, Semigroup₁.dia_assoc, hac, DiaOneClass₁.dia_one b] + + +export DiaOneClass₁ (one_dia dia_one) +export Semigroup₁ (dia_assoc) +export Group₁ (inv_dia) + + +example {M : Type} [Monoid₁ M] {a b c : M} (hba : b ⋄ a = 𝟙) (hac : a ⋄ c = 𝟙) : b = c := by + rw [← one_dia c, ← hba, dia_assoc, hac, dia_one b] + + +lemma inv_eq_of_dia [Group₁ G] {a b : G} (h : a ⋄ b = 𝟙) : a⁻¹ = b := + sorry + +lemma dia_inv [Group₁ G] (a : G) : a ⋄ a⁻¹ = 𝟙 := + sorry + + + + +class AddSemigroup₃ (α : Type) extends Add α where + /-- Addition is associative -/ + add_assoc₃ : ∀ a b c : α, a + b + c = a + (b + c) + +@[to_additive AddSemigroup₃] +class Semigroup₃ (α : Type) extends Mul α where + /-- Multiplication is associative -/ + mul_assoc₃ : ∀ a b c : α, a * b * c = a * (b * c) + +class AddMonoid₃ (α : Type) extends AddSemigroup₃ α, AddZeroClass α + +@[to_additive AddMonoid₃] +class Monoid₃ (α : Type) extends Semigroup₃ α, MulOneClass α + +export Semigroup₃ (mul_assoc₃) +export AddSemigroup₃ (add_assoc₃) + +#whats_new in +@[to_additive] +lemma left_inv_eq_right_inv' {M : Type} [Monoid₃ M] {a b c : M} (hba : b * a = 1) (hac : a * c = 1) : b = c := by + rw [← one_mul c, ← hba, mul_assoc₃, hac, mul_one b] + +#check left_neg_eq_right_neg' + +class AddCommSemigroup₃ (α : Type) extends AddSemigroup₃ α where + add_comm : ∀ a b : α, a + b = b + a + +@[to_additive AddCommSemigroup₃] +class CommSemigroup₃ (α : Type) extends Semigroup₃ α where + mul_comm : ∀ a b : α, a * b = b * a + +class AddCommMonoid₃ (α : Type) extends AddMonoid₃ α, AddCommSemigroup₃ α + +@[to_additive AddCommMonoid₃] +class CommMonoid₃ (α : Type) extends Monoid₃ α, CommSemigroup₃ α + +class AddGroup₃ (G : Type) extends AddMonoid₃ G, Neg G where + neg_add : ∀ a : G, -a + a = 0 + +@[to_additive AddGroup₃] +class Group₃ (G : Type) extends Monoid₃ G, Inv G where + inv_mul : ∀ a : G, a⁻¹ * a = 1 + + +attribute [simp] Group₃.inv_mul AddGroup₃.neg_add + + + +@[to_additive] +lemma inv_eq_of_mul [Group₃ G] {a b : G} (h : a * b = 1) : a⁻¹ = b := + sorry + + +@[to_additive (attr := simp)] +lemma Group₃.mul_inv {G : Type} [Group₃ G] (a : G) : a * a⁻¹ = 1 := by + sorry + +@[to_additive] +lemma mul_left_cancel₃ {G : Type} [Group₃ G] {a b c : G} (h : a * b = a * c) : b = c := by + sorry + +@[to_additive] +lemma mul_right_cancel₃ {G : Type} [Group₃ G] {a b c : G} (h : b*a = c*a) : b = c := by + sorry + +class AddCommGroup₃ (G : Type) extends AddGroup₃ G, AddCommMonoid₃ G + +@[to_additive AddCommGroup₃] +class CommGroup₃ (G : Type) extends Group₃ G, CommMonoid₃ G + + + +class Ring₃ (R : Type) extends AddGroup₃ R, Monoid₃ R, MulZeroClass R where + /-- Multiplication is left distributive over addition -/ + left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c + /-- Multiplication is right distributive over addition -/ + right_distrib : ∀ a b c : R, (a + b) * c = a * c + b * c + +instance {R : Type} [Ring₃ R] : AddCommGroup₃ R := +{ add_comm := by + sorry } + +instance : Ring₃ ℤ where + add := (· + ·) + add_assoc₃ := add_assoc + zero := 0 + zero_add := by simp + add_zero := by simp + neg := (- ·) + neg_add := by simp + mul := (· * ·) + mul_assoc₃ := mul_assoc + one := 1 + one_mul := by simp + mul_one := by simp + zero_mul := by simp + mul_zero := by simp + left_distrib := Int.mul_add + right_distrib := Int.add_mul + +class LE₁ (α : Type) where + /-- The Less-or-Equal relation. -/ + le : α → α → Prop + +@[inherit_doc] infix:50 " ≤₁ " => LE₁.le + +class Preorder₁ (α : Type) + +class PartialOrder₁ (α : Type) + +class OrderedCommMonoid₁ (α : Type) + +instance : OrderedCommMonoid₁ ℕ where + +class SMul₃ (α : Type) (β : Type) where + /-- Scalar multiplication -/ + smul : α → β → β + +infixr:73 " • " => SMul₃.smul + + +class Module₁ (R : Type) [Ring₃ R] (M : Type) [AddCommGroup₃ M] extends SMul₃ R M where + zero_smul : ∀ m : M, (0 : R) • m = 0 + one_smul : ∀ m : M, (1 : R) • m = m + mul_smul : ∀ (a b : R) (m : M), (a * b) • m = a • b • m + add_smul : ∀ (a b : R) (m : M), (a + b) • m = a • m + b • m + smul_add : ∀ (a : R) (m n : M), a • (m + n) = a • m + a • n + +instance selfModule (R : Type) [Ring₃ R] : Module₁ R R where + smul := fun r s ↦ r*s + zero_smul := zero_mul + one_smul := one_mul + mul_smul := mul_assoc₃ + add_smul := Ring₃.right_distrib + smul_add := Ring₃.left_distrib + +def nsmul₁ {M : Type*} [Zero M] [Add M] : ℕ → M → M + | 0, _ => 0 + | n + 1, a => a + nsmul₁ n a + +def zsmul₁ {M : Type*} [Zero M] [Add M] [Neg M] : ℤ → M → M + | Int.ofNat n, a => nsmul₁ n a + | Int.negSucc n, a => -nsmul₁ n.succ a + +instance abGrpModule (A : Type) [AddCommGroup₃ A] : Module₁ ℤ A where + smul := zsmul₁ + zero_smul := sorry + one_smul := sorry + mul_smul := sorry + add_smul := sorry + smul_add := sorry + +#synth Module₁ ℤ ℤ -- abGrpModule ℤ + + +class AddMonoid₄ (M : Type) extends AddSemigroup₃ M, AddZeroClass M where + /-- Multiplication by a natural number. -/ + nsmul : ℕ → M → M := nsmul₁ + /-- Multiplication by `(0 : ℕ)` gives `0`. -/ + nsmul_zero : ∀ x, nsmul 0 x = 0 := by intros; rfl + /-- Multiplication by `(n + 1 : ℕ)` behaves as expected. -/ + nsmul_succ : ∀ (n : ℕ) (x), nsmul (n + 1) x = x + nsmul n x := by intros; rfl + +instance mySMul {M : Type} [AddMonoid₄ M] : SMul ℕ M := ⟨AddMonoid₄.nsmul⟩ + +instance (M N : Type) [AddMonoid₄ M] [AddMonoid₄ N] : AddMonoid₄ (M × N) where + add := fun p q ↦ (p.1 + q.1, p.2 + q.2) + add_assoc₃ := fun a b c ↦ by ext <;> apply add_assoc₃ + zero := (0, 0) + zero_add := fun a ↦ by ext <;> apply zero_add + add_zero := fun a ↦ by ext <;> apply add_zero + +instance : AddMonoid₄ ℤ where + add := (· + ·) + add_assoc₃ := Int.add_assoc + zero := 0 + zero_add := Int.zero_add + add_zero := Int.add_zero + nsmul := fun n m ↦ (n : ℤ) * m + nsmul_zero := Int.zero_mul + nsmul_succ := fun n m ↦ show (n + 1 : ℤ) * m = m + n * m + by rw [Int.add_mul, Int.add_comm, Int.one_mul] + +example (n : ℕ) (m : ℤ) : SMul.smul (self := mySMul) n m = n * m := rfl + diff --git a/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S02_Morphisms.lean b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S02_Morphisms.lean new file mode 100644 index 0000000..4d5d214 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S02_Morphisms.lean @@ -0,0 +1,118 @@ +module +public import MIL.Common +public import Mathlib.Topology.Instances.Real.Lemmas + +set_option autoImplicit true + + +def isMonoidHom₁ [Monoid G] [Monoid H] (f : G → H) : Prop := + f 1 = 1 ∧ ∀ g g', f (g * g') = f g * f g' +structure isMonoidHom₂ [Monoid G] [Monoid H] (f : G → H) : Prop where + map_one : f 1 = 1 + map_mul : ∀ g g', f (g * g') = f g * f g' +example : Continuous (id : ℝ → ℝ) := continuous_id +@[ext] +structure MonoidHom₁ (G H : Type) [Monoid G] [Monoid H] where + toFun : G → H + map_one : toFun 1 = 1 + map_mul : ∀ g g', toFun (g * g') = toFun g * toFun g' + +instance [Monoid G] [Monoid H] : CoeFun (MonoidHom₁ G H) (fun _ ↦ G → H) where + coe := MonoidHom₁.toFun + +attribute [coe] MonoidHom₁.toFun + + +example [Monoid G] [Monoid H] (f : MonoidHom₁ G H) : f 1 = 1 := f.map_one + +@[ext] +structure AddMonoidHom₁ (G H : Type) [AddMonoid G] [AddMonoid H] where + toFun : G → H + map_zero : toFun 0 = 0 + map_add : ∀ g g', toFun (g + g') = toFun g + toFun g' + +instance [AddMonoid G] [AddMonoid H] : CoeFun (AddMonoidHom₁ G H) (fun _ ↦ G → H) where + coe := AddMonoidHom₁.toFun + +attribute [coe] AddMonoidHom₁.toFun + +@[ext] +structure RingHom₁ (R S : Type) [Ring R] [Ring S] extends MonoidHom₁ R S, AddMonoidHom₁ R S + + + +class MonoidHomClass₁ (F : Type) (M N : Type) [Monoid M] [Monoid N] where + toFun : F → M → N + map_one : ∀ f : F, toFun f 1 = 1 + map_mul : ∀ f g g', toFun f (g * g') = toFun f g * toFun f g' + + +def badInst [Monoid M] [Monoid N] [MonoidHomClass₁ F M N] : CoeFun F (fun _ ↦ M → N) where + coe := MonoidHomClass₁.toFun + + +class MonoidHomClass₂ (F : Type) (M N : outParam Type) [Monoid M] [Monoid N] where + toFun : F → M → N + map_one : ∀ f : F, toFun f 1 = 1 + map_mul : ∀ f g g', toFun f (g * g') = toFun f g * toFun f g' + +instance [Monoid M] [Monoid N] [MonoidHomClass₂ F M N] : CoeFun F (fun _ ↦ M → N) where + coe := MonoidHomClass₂.toFun + +attribute [coe] MonoidHomClass₂.toFun + + +instance (M N : Type) [Monoid M] [Monoid N] : MonoidHomClass₂ (MonoidHom₁ M N) M N where + toFun := MonoidHom₁.toFun + map_one := fun f ↦ f.map_one + map_mul := fun f ↦ f.map_mul + +instance (R S : Type) [Ring R] [Ring S] : MonoidHomClass₂ (RingHom₁ R S) R S where + toFun := fun f ↦ f.toMonoidHom₁.toFun + map_one := fun f ↦ f.toMonoidHom₁.map_one + map_mul := fun f ↦ f.toMonoidHom₁.map_mul + + +lemma map_inv_of_inv [Monoid M] [Monoid N] [MonoidHomClass₂ F M N] (f : F) {m m' : M} (h : m*m' = 1) : + f m * f m' = 1 := by + rw [← MonoidHomClass₂.map_mul, h, MonoidHomClass₂.map_one] + +example [Monoid M] [Monoid N] (f : MonoidHom₁ M N) {m m' : M} (h : m*m' = 1) : f m * f m' = 1 := +map_inv_of_inv f h + +example [Ring R] [Ring S] (f : RingHom₁ R S) {r r' : R} (h : r*r' = 1) : f r * f r' = 1 := +map_inv_of_inv f h + + + +class MonoidHomClass₃ (F : Type) (M N : outParam Type) [Monoid M] [Monoid N] extends + DFunLike F M (fun _ ↦ N) where + map_one : ∀ f : F, f 1 = 1 + map_mul : ∀ (f : F) g g', f (g * g') = f g * f g' + +instance (M N : Type) [Monoid M] [Monoid N] : MonoidHomClass₃ (MonoidHom₁ M N) M N where + coe := MonoidHom₁.toFun + coe_injective _ _ := MonoidHom₁.ext + map_one := MonoidHom₁.map_one + map_mul := MonoidHom₁.map_mul + + +@[ext] +structure OrderPresHom (α β : Type) [LE α] [LE β] where + toFun : α → β + le_of_le : ∀ a a', a ≤ a' → toFun a ≤ toFun a' + +@[ext] +structure OrderPresMonoidHom (M N : Type) [Monoid M] [LE M] [Monoid N] [LE N] extends +MonoidHom₁ M N, OrderPresHom M N + +class OrderPresHomClass (F : Type) (α β : outParam Type) [LE α] [LE β] + +instance (α β : Type) [LE α] [LE β] : OrderPresHomClass (OrderPresHom α β) α β where + +instance (α β : Type) [LE α] [Monoid α] [LE β] [Monoid β] : + OrderPresHomClass (OrderPresMonoidHom α β) α β where + +instance (α β : Type) [LE α] [Monoid α] [LE β] [Monoid β] : + MonoidHomClass₃ (OrderPresMonoidHom α β) α β + := sorry diff --git a/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S03_Subobjects.lean b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S03_Subobjects.lean new file mode 100644 index 0000000..40bd018 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S03_Subobjects.lean @@ -0,0 +1,96 @@ +module +public import MIL.Common +public import Mathlib.GroupTheory.QuotientGroup.Basic + +set_option autoImplicit true + + +@[ext] +structure Submonoid₁ (M : Type) [Monoid M] where + /-- The carrier of a submonoid. -/ + carrier : Set M + /-- The product of two elements of a submonoid belongs to the submonoid. -/ + mul_mem {a b} : a ∈ carrier → b ∈ carrier → a * b ∈ carrier + /-- The unit element belongs to the submonoid. -/ + one_mem : 1 ∈ carrier + +/-- Submonoids in `M` can be seen as sets in `M`. -/ +instance [Monoid M] : SetLike (Submonoid₁ M) M where + coe := Submonoid₁.carrier + coe_injective _ _ := Submonoid₁.ext + + + +example [Monoid M] (N : Submonoid₁ M) : 1 ∈ N := N.one_mem + +example [Monoid M] (N : Submonoid₁ M) (α : Type) (f : M → α) := f '' N + + +example [Monoid M] (N : Submonoid₁ M) (x : N) : (x : M) ∈ N := x.property + + +instance [Monoid M] : PartialOrder (Submonoid₁ M) := .ofSetLike (Submonoid₁ M) M + +example [Monoid M] (N P : Submonoid₁ M) : N ≤ P ↔ ∀ x, x ∈ N → x ∈ P := SetLike.le_def + + +instance SubMonoid₁Monoid [Monoid M] (N : Submonoid₁ M) : Monoid N where + mul := fun x y ↦ ⟨x*y, N.mul_mem x.property y.property⟩ + mul_assoc := fun x y z ↦ SetCoe.ext (mul_assoc (x : M) y z) + one := ⟨1, N.one_mem⟩ + one_mul := fun x ↦ SetCoe.ext (one_mul (x : M)) + mul_one := fun x ↦ SetCoe.ext (mul_one (x : M)) + + +example [Monoid M] (N : Submonoid₁ M) : Monoid N where + mul := fun ⟨x, hx⟩ ⟨y, hy⟩ ↦ ⟨x*y, N.mul_mem hx hy⟩ + mul_assoc := fun ⟨x, _⟩ ⟨y, _⟩ ⟨z, _⟩ ↦ SetCoe.ext (mul_assoc x y z) + one := ⟨1, N.one_mem⟩ + one_mul := fun ⟨x, _⟩ ↦ SetCoe.ext (one_mul x) + mul_one := fun ⟨x, _⟩ ↦ SetCoe.ext (mul_one x) + + +class SubmonoidClass₁ (S : Type) (M : Type) [Monoid M] [SetLike S M] : Prop where + mul_mem : ∀ (s : S) {a b : M}, a ∈ s → b ∈ s → a * b ∈ s + one_mem : ∀ s : S, 1 ∈ s + +instance [Monoid M] : SubmonoidClass₁ (Submonoid₁ M) M where + mul_mem := Submonoid₁.mul_mem + one_mem := Submonoid₁.one_mem + + +instance [Monoid M] : Min (Submonoid₁ M) := + ⟨fun S₁ S₂ ↦ + { carrier := S₁ ∩ S₂ + one_mem := ⟨S₁.one_mem, S₂.one_mem⟩ + mul_mem := fun ⟨hx, hx'⟩ ⟨hy, hy'⟩ ↦ ⟨S₁.mul_mem hx hy, S₂.mul_mem hx' hy'⟩ }⟩ + + +example [Monoid M] (N P : Submonoid₁ M) : Submonoid₁ M := N ⊓ P + + +def Submonoid.Setoid [CommMonoid M] (N : Submonoid M) : Setoid M where + r := fun x y ↦ ∃ w ∈ N, ∃ z ∈ N, x*w = y*z + iseqv := { + refl := fun x ↦ ⟨1, N.one_mem, 1, N.one_mem, rfl⟩ + symm := fun ⟨w, hw, z, hz, h⟩ ↦ ⟨z, hz, w, hw, h.symm⟩ + trans := by + sorry + } + +instance [CommMonoid M] : HasQuotient M (Submonoid M) where + Quotient := fun N ↦ Quotient N.Setoid + +def QuotientMonoid.mk [CommMonoid M] (N : Submonoid M) : M → M ⧸ N := Quotient.mk N.Setoid + +instance [CommMonoid M] (N : Submonoid M) : Monoid (M ⧸ N) where + mul := Quotient.map₂ (· * ·) (by + sorry + ) + mul_assoc := by + sorry + one := QuotientMonoid.mk N 1 + one_mul := by + sorry + mul_one := by + sorry diff --git a/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S01_Basics.lean b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S01_Basics.lean new file mode 100644 index 0000000..22879ab --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S01_Basics.lean @@ -0,0 +1,354 @@ +module +public import MIL.Common +public import Mathlib.Algebra.BigOperators.Ring.List +public import Mathlib.Basic.Real.Basic + +public section +set_option autoImplicit true + + +class One₁ (α : Type) where + /-- The element one -/ + one : α + + +#check One₁.one -- One₁.one {α : Type} [self : One₁ α] : α + +@[class] structure One₂ (α : Type) where + /-- The element one -/ + one : α + +#check One₂.one + + +example (α : Type) [One₁ α] : α := One₁.one + +example (α : Type) [One₁ α] := (One₁.one : α) + +@[inherit_doc] +notation "𝟙" => One₁.one + +example {α : Type} [One₁ α] : α := 𝟙 + +example {α : Type} [One₁ α] : (𝟙 : α) = 𝟙 := rfl + + +class Dia₁ (α : Type) where + dia : α → α → α + +infixl:70 " ⋄ " => Dia₁.dia + + +class Semigroup₀ (α : Type) where + toDia₁ : Dia₁ α + /-- Diamond is associative -/ + dia_assoc : ∀ a b c : α, a ⋄ b ⋄ c = a ⋄ (b ⋄ c) + + +attribute [reducible, instance] Semigroup₀.toDia₁ + +example {α : Type} [Semigroup₀ α] (a b : α) : α := a ⋄ b + + +class Semigroup₁ (α : Type) extends toDia₁ : Dia₁ α where + /-- Diamond is associative -/ + dia_assoc : ∀ a b c : α, a ⋄ b ⋄ c = a ⋄ (b ⋄ c) + +example {α : Type} [Semigroup₁ α] (a b : α) : α := a ⋄ b + + +class Semigroup₂ (α : Type) extends Dia₁ α where + /-- Diamond is associative -/ + dia_assoc : ∀ a b c : α, a ⋄ b ⋄ c = a ⋄ (b ⋄ c) + +class DiaOneClass₁ (α : Type) extends One₁ α, Dia₁ α where + /-- One is a left neutral element for diamond. -/ + one_dia : ∀ a : α, 𝟙 ⋄ a = a + /-- One is a right neutral element for diamond -/ + dia_one : ∀ a : α, a ⋄ 𝟙 = a + + + +set_option trace.Meta.synthInstance true in +example {α : Type} [DiaOneClass₁ α] (a b : α) : Prop := a ⋄ b = 𝟙 + + +class Monoid₁ (α : Type) extends Semigroup₁ α, DiaOneClass₁ α + + +class Monoid₂ (α : Type) where + toSemigroup₁ : Semigroup₁ α + toDiaOneClass₁ : DiaOneClass₁ α + + +example {α : Type} [Monoid₁ α] : + (Monoid₁.toSemigroup₁.toDia₁.dia : α → α → α) = Monoid₁.toDiaOneClass₁.toDia₁.dia := rfl + + +/- Monoid₂.mk {α : Type} (toSemigroup₁ : Semigroup₁ α) (toDiaOneClass₁ : DiaOneClass₁ α) : Monoid₂ α -/ +#check Monoid₂.mk + +/- Monoid₁.mk {α : Type} [toSemigroup₁ : Semigroup₁ α] [toOne₁ : One₁ α] (one_dia : ∀ (a : α), 𝟙 ⋄ a = a) (dia_one : ∀ (a : α), a ⋄ 𝟙 = a) : Monoid₁ α -/ +#check Monoid₁.mk + + +#check Monoid₁.toSemigroup₁ +#check Monoid₁.toDiaOneClass₁ + + +class Inv₁ (α : Type) where + /-- The inversion function -/ + inv : α → α + +@[inherit_doc] +postfix:max "⁻¹" => Inv₁.inv + +class Group₁ (G : Type) extends Monoid₁ G, Inv₁ G where + inv_dia : ∀ a : G, a⁻¹ ⋄ a = 𝟙 + + +lemma left_inv_eq_right_inv₁ {M : Type} [Monoid₁ M] {a b c : M} (hba : b ⋄ a = 𝟙) (hac : a ⋄ c = 𝟙) : b = c := by + rw [← DiaOneClass₁.one_dia c, ← hba, Semigroup₁.dia_assoc, hac, DiaOneClass₁.dia_one b] + + +export DiaOneClass₁ (one_dia dia_one) +export Semigroup₁ (dia_assoc) +export Group₁ (inv_dia) + + +example {M : Type} [Monoid₁ M] {a b c : M} (hba : b ⋄ a = 𝟙) (hac : a ⋄ c = 𝟙) : b = c := by + rw [← one_dia c, ← hba, dia_assoc, hac, dia_one b] + + +lemma inv_eq_of_dia [Group₁ G] {a b : G} (h : a ⋄ b = 𝟙) : a⁻¹ = b := + left_inv_eq_right_inv₁ (inv_dia a) h + +lemma dia_inv [Group₁ G] (a : G) : a ⋄ a⁻¹ = 𝟙 := + by rw [← inv_dia a⁻¹, inv_eq_of_dia (inv_dia a)] + + + + + +class AddSemigroup₃ (α : Type) extends Add α where + /-- Addition is associative -/ + add_assoc₃ : ∀ a b c : α, a + b + c = a + (b + c) + +@[to_additive AddSemigroup₃] +class Semigroup₃ (α : Type) extends Mul α where + /-- Multiplication is associative -/ + mul_assoc₃ : ∀ a b c : α, a * b * c = a * (b * c) + +class AddMonoid₃ (α : Type) extends AddSemigroup₃ α, AddZeroClass α + +@[to_additive AddMonoid₃] +class Monoid₃ (α : Type) extends Semigroup₃ α, MulOneClass α + +export Semigroup₃ (mul_assoc₃) +export AddSemigroup₃ (add_assoc₃) + +#whats_new in +@[to_additive] +lemma left_inv_eq_right_inv' {M : Type} [Monoid₃ M] {a b c : M} (hba : b * a = 1) (hac : a * c = 1) : b = c := by + rw [← one_mul c, ← hba, mul_assoc₃, hac, mul_one b] + +#check left_neg_eq_right_neg' + +class AddCommSemigroup₃ (α : Type) extends AddSemigroup₃ α where + add_comm : ∀ a b : α, a + b = b + a + +@[to_additive AddCommSemigroup₃] +class CommSemigroup₃ (α : Type) extends Semigroup₃ α where + mul_comm : ∀ a b : α, a * b = b * a + +class AddCommMonoid₃ (α : Type) extends AddMonoid₃ α, AddCommSemigroup₃ α + +@[to_additive AddCommMonoid₃] +class CommMonoid₃ (α : Type) extends Monoid₃ α, CommSemigroup₃ α + +class AddGroup₃ (G : Type) extends AddMonoid₃ G, Neg G where + neg_add : ∀ a : G, -a + a = 0 + +@[to_additive AddGroup₃] +class Group₃ (G : Type) extends Monoid₃ G, Inv G where + inv_mul : ∀ a : G, a⁻¹ * a = 1 + + +attribute [simp] Group₃.inv_mul AddGroup₃.neg_add + + + +@[to_additive] +lemma inv_eq_of_mul [Group₃ G] {a b : G} (h : a * b = 1) : a⁻¹ = b := + left_inv_eq_right_inv' (Group₃.inv_mul a) h + + +@[to_additive (attr := simp)] +lemma Group₃.mul_inv {G : Type} [Group₃ G] (a : G) : a * a⁻¹ = 1 := by + rw [← inv_mul a⁻¹, inv_eq_of_mul (inv_mul a)] + +@[to_additive] +lemma mul_left_cancel₃ {G : Type} [Group₃ G] {a b c : G} (h : a * b = a * c) : b = c := by + simpa [← mul_assoc₃] using congr_arg (a⁻¹ * ·) h + +@[to_additive] +lemma mul_right_cancel₃ {G : Type} [Group₃ G] {a b c : G} (h : b*a = c*a) : b = c := by + simpa [mul_assoc₃] using congr_arg (· * a⁻¹) h + +class AddCommGroup₃ (G : Type) extends AddGroup₃ G, AddCommMonoid₃ G + +@[to_additive AddCommGroup₃] +class CommGroup₃ (G : Type) extends Group₃ G, CommMonoid₃ G + + + +class Ring₃ (R : Type) extends AddGroup₃ R, Monoid₃ R, MulZeroClass R where + /-- Multiplication is left distributive over addition -/ + left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c + /-- Multiplication is right distributive over addition -/ + right_distrib : ∀ a b c : R, (a + b) * c = a * c + b * c + +instance {R : Type} [Ring₃ R] : AddCommGroup₃ R := +{ add_comm := by + intro a b + have : a + (a + b + b) = a + (b + a + b) := calc + a + (a + b + b) = (a + a) + (b + b) := by simp [add_assoc₃, add_assoc₃] + _ = (1 * a + 1 * a) + (1 * b + 1 * b) := by simp + _ = (1 + 1) * a + (1 + 1) * b := by simp [Ring₃.right_distrib] + _ = (1 + 1) * (a + b) := by simp [Ring₃.left_distrib] + _ = 1 * (a + b) + 1 * (a + b) := by simp [Ring₃.right_distrib] + _ = (a + b) + (a + b) := by simp + _ = a + (b + a + b) := by simp [add_assoc₃] + exact add_right_cancel₃ (add_left_cancel₃ this) } + +instance : Ring₃ ℤ where + add := (· + ·) + add_assoc₃ := add_assoc + zero := 0 + zero_add := by simp + add_zero := by simp + neg := (- ·) + neg_add := by simp + mul := (· * ·) + mul_assoc₃ := mul_assoc + one := 1 + one_mul := by simp + mul_one := by simp + zero_mul := by simp + mul_zero := by simp + left_distrib := Int.mul_add + right_distrib := Int.add_mul + +class LE₁ (α : Type) where + /-- The Less-or-Equal relation. -/ + le : α → α → Prop + +@[inherit_doc] infix:50 " ≤₁ " => LE₁.le + +class Preorder₁ (α : Type) + extends LE₁ α where + le_refl : ∀ a : α, a ≤₁ a + le_trans : ∀ a b c : α, a ≤₁ b → b ≤₁ c → a ≤₁ c + +class PartialOrder₁ (α : Type) + extends Preorder₁ α where + le_antisymm : ∀ a b : α, a ≤₁ b → b ≤₁ a → a = b + +class OrderedCommMonoid₁ (α : Type) + extends PartialOrder₁ α, CommMonoid₃ α where + mul_of_le : ∀ a b : α, a ≤₁ b → ∀ c : α, c * a ≤₁ c * b + +instance : OrderedCommMonoid₁ ℕ where + le := (· ≤ ·) + le_refl := fun _ ↦ le_rfl + le_trans := fun _ _ _ ↦ le_trans + le_antisymm := fun _ _ ↦ le_antisymm + mul := (· * ·) + mul_assoc₃ := mul_assoc + one := 1 + one_mul := one_mul + mul_one := mul_one + mul_comm := mul_comm + mul_of_le := fun _ _ h c ↦ Nat.mul_le_mul_left c h + +class SMul₃ (α : Type) (β : Type) where + /-- Scalar multiplication -/ + smul : α → β → β + +infixr:73 " • " => SMul₃.smul + + +class Module₁ (R : Type) [Ring₃ R] (M : Type) [AddCommGroup₃ M] extends SMul₃ R M where + zero_smul : ∀ m : M, (0 : R) • m = 0 + one_smul : ∀ m : M, (1 : R) • m = m + mul_smul : ∀ (a b : R) (m : M), (a * b) • m = a • b • m + add_smul : ∀ (a b : R) (m : M), (a + b) • m = a • m + b • m + smul_add : ∀ (a : R) (m n : M), a • (m + n) = a • m + a • n + +instance selfModule (R : Type) [Ring₃ R] : Module₁ R R where + smul := fun r s ↦ r*s + zero_smul := zero_mul + one_smul := one_mul + mul_smul := mul_assoc₃ + add_smul := Ring₃.right_distrib + smul_add := Ring₃.left_distrib + +def nsmul₁ {M : Type*} [Zero M] [Add M] : ℕ → M → M + | 0, _ => 0 + | n + 1, a => a + nsmul₁ n a + +def zsmul₁ {M : Type*} [Zero M] [Add M] [Neg M] : ℤ → M → M + | Int.ofNat n, a => nsmul₁ n a + | Int.negSucc n, a => -nsmul₁ n.succ a + +instance abGrpModule (A : Type) [AddCommGroup₃ A] : Module₁ ℤ A where + smul := zsmul₁ + zero_smul := sorry + one_smul := sorry + mul_smul := sorry + add_smul := sorry + smul_add := sorry + +#synth Module₁ ℤ ℤ -- abGrpModule ℤ + + +class AddMonoid₄ (M : Type) extends AddSemigroup₃ M, AddZeroClass M where + /-- Multiplication by a natural number. -/ + nsmul : ℕ → M → M := nsmul₁ + /-- Multiplication by `(0 : ℕ)` gives `0`. -/ + nsmul_zero : ∀ x, nsmul 0 x = 0 := by intros; rfl + /-- Multiplication by `(n + 1 : ℕ)` behaves as expected. -/ + nsmul_succ : ∀ (n : ℕ) (x), nsmul (n + 1) x = x + nsmul n x := by intros; rfl + +instance mySMul {M : Type} [AddMonoid₄ M] : SMul ℕ M := ⟨AddMonoid₄.nsmul⟩ + +instance (M N : Type) [AddMonoid₄ M] [AddMonoid₄ N] : AddMonoid₄ (M × N) where + add := fun p q ↦ (p.1 + q.1, p.2 + q.2) + add_assoc₃ := fun a b c ↦ by ext <;> apply add_assoc₃ + zero := (0, 0) + zero_add := fun a ↦ by ext <;> apply zero_add + add_zero := fun a ↦ by ext <;> apply add_zero + +instance : AddMonoid₄ ℤ where + add := (· + ·) + add_assoc₃ := Int.add_assoc + zero := 0 + zero_add := Int.zero_add + add_zero := Int.add_zero + nsmul := fun n m ↦ (n : ℤ) * m + nsmul_zero := Int.zero_mul + nsmul_succ := fun n m ↦ show (n + 1 : ℤ) * m = m + n * m + by rw [Int.add_mul, Int.add_comm, Int.one_mul] + +example (n : ℕ) (m : ℤ) : SMul.smul (self := mySMul) n m = n * m := rfl +class LT₁ (α : Type) where + /-- The Less-Than relation -/ + lt : α → α → Prop + +@[inherit_doc] infix:50 " <₁ " => LT₁.lt + +class PreOrder₂ (α : Type) extends LE₁ α, LT₁ α where + le_refl : ∀ a : α, a ≤₁ a + le_trans : ∀ a b c : α, a ≤₁ b → b ≤₁ c → a ≤₁ c + lt := fun a b ↦ a ≤₁ b ∧ ¬b ≤₁ a + lt_iff_le_not_le : ∀ a b : α, a <₁ b ↔ a ≤₁ b ∧ ¬b ≤₁ a := by intros; rfl diff --git a/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S02_Morphisms.lean b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S02_Morphisms.lean new file mode 100644 index 0000000..96d7aed --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S02_Morphisms.lean @@ -0,0 +1,130 @@ +module +public import MIL.Common +public import Mathlib.Topology.Instances.Real.Lemmas + +set_option autoImplicit true + + +def isMonoidHom₁ [Monoid G] [Monoid H] (f : G → H) : Prop := + f 1 = 1 ∧ ∀ g g', f (g * g') = f g * f g' +structure isMonoidHom₂ [Monoid G] [Monoid H] (f : G → H) : Prop where + map_one : f 1 = 1 + map_mul : ∀ g g', f (g * g') = f g * f g' +example : Continuous (id : ℝ → ℝ) := continuous_id +@[ext] +structure MonoidHom₁ (G H : Type) [Monoid G] [Monoid H] where + toFun : G → H + map_one : toFun 1 = 1 + map_mul : ∀ g g', toFun (g * g') = toFun g * toFun g' + +instance [Monoid G] [Monoid H] : CoeFun (MonoidHom₁ G H) (fun _ ↦ G → H) where + coe := MonoidHom₁.toFun + +attribute [coe] MonoidHom₁.toFun + + +example [Monoid G] [Monoid H] (f : MonoidHom₁ G H) : f 1 = 1 := f.map_one + +@[ext] +structure AddMonoidHom₁ (G H : Type) [AddMonoid G] [AddMonoid H] where + toFun : G → H + map_zero : toFun 0 = 0 + map_add : ∀ g g', toFun (g + g') = toFun g + toFun g' + +instance [AddMonoid G] [AddMonoid H] : CoeFun (AddMonoidHom₁ G H) (fun _ ↦ G → H) where + coe := AddMonoidHom₁.toFun + +attribute [coe] AddMonoidHom₁.toFun + +@[ext] +structure RingHom₁ (R S : Type) [Ring R] [Ring S] extends MonoidHom₁ R S, AddMonoidHom₁ R S + + + +class MonoidHomClass₁ (F : Type) (M N : Type) [Monoid M] [Monoid N] where + toFun : F → M → N + map_one : ∀ f : F, toFun f 1 = 1 + map_mul : ∀ f g g', toFun f (g * g') = toFun f g * toFun f g' + + +def badInst [Monoid M] [Monoid N] [MonoidHomClass₁ F M N] : CoeFun F (fun _ ↦ M → N) where + coe := MonoidHomClass₁.toFun + + +class MonoidHomClass₂ (F : Type) (M N : outParam Type) [Monoid M] [Monoid N] where + toFun : F → M → N + map_one : ∀ f : F, toFun f 1 = 1 + map_mul : ∀ f g g', toFun f (g * g') = toFun f g * toFun f g' + +instance [Monoid M] [Monoid N] [MonoidHomClass₂ F M N] : CoeFun F (fun _ ↦ M → N) where + coe := MonoidHomClass₂.toFun + +attribute [coe] MonoidHomClass₂.toFun + + +instance (M N : Type) [Monoid M] [Monoid N] : MonoidHomClass₂ (MonoidHom₁ M N) M N where + toFun := MonoidHom₁.toFun + map_one := fun f ↦ f.map_one + map_mul := fun f ↦ f.map_mul + +instance (R S : Type) [Ring R] [Ring S] : MonoidHomClass₂ (RingHom₁ R S) R S where + toFun := fun f ↦ f.toMonoidHom₁.toFun + map_one := fun f ↦ f.toMonoidHom₁.map_one + map_mul := fun f ↦ f.toMonoidHom₁.map_mul + + +lemma map_inv_of_inv [Monoid M] [Monoid N] [MonoidHomClass₂ F M N] (f : F) {m m' : M} (h : m*m' = 1) : + f m * f m' = 1 := by + rw [← MonoidHomClass₂.map_mul, h, MonoidHomClass₂.map_one] + +example [Monoid M] [Monoid N] (f : MonoidHom₁ M N) {m m' : M} (h : m*m' = 1) : f m * f m' = 1 := +map_inv_of_inv f h + +example [Ring R] [Ring S] (f : RingHom₁ R S) {r r' : R} (h : r*r' = 1) : f r * f r' = 1 := +map_inv_of_inv f h + + + +class MonoidHomClass₃ (F : Type) (M N : outParam Type) [Monoid M] [Monoid N] extends + DFunLike F M (fun _ ↦ N) where + map_one : ∀ f : F, f 1 = 1 + map_mul : ∀ (f : F) g g', f (g * g') = f g * f g' + +instance (M N : Type) [Monoid M] [Monoid N] : MonoidHomClass₃ (MonoidHom₁ M N) M N where + coe := MonoidHom₁.toFun + coe_injective _ _ := MonoidHom₁.ext + map_one := MonoidHom₁.map_one + map_mul := MonoidHom₁.map_mul + + +@[ext] +structure OrderPresHom (α β : Type) [LE α] [LE β] where + toFun : α → β + le_of_le : ∀ a a', a ≤ a' → toFun a ≤ toFun a' + +@[ext] +structure OrderPresMonoidHom (M N : Type) [Monoid M] [LE M] [Monoid N] [LE N] extends +MonoidHom₁ M N, OrderPresHom M N + +class OrderPresHomClass (F : Type) (α β : outParam Type) [LE α] [LE β] +extends DFunLike F α (fun _ ↦ β) where + le_of_le : ∀ (f : F) a a', a ≤ a' → f a ≤ f a' + +instance (α β : Type) [LE α] [LE β] : OrderPresHomClass (OrderPresHom α β) α β where + coe := OrderPresHom.toFun + coe_injective _ _ := OrderPresHom.ext + le_of_le := OrderPresHom.le_of_le + +instance (α β : Type) [LE α] [Monoid α] [LE β] [Monoid β] : + OrderPresHomClass (OrderPresMonoidHom α β) α β where + coe := fun f ↦ f.toOrderPresHom.toFun + coe_injective _ _ := OrderPresMonoidHom.ext + le_of_le := fun f ↦ f.toOrderPresHom.le_of_le + +instance (α β : Type) [LE α] [Monoid α] [LE β] [Monoid β] : + MonoidHomClass₃ (OrderPresMonoidHom α β) α β +where + coe := fun f ↦ f.toOrderPresHom.toFun + coe_injective _ _ := OrderPresMonoidHom.ext + map_one := fun f ↦ f.toMonoidHom₁.map_one + map_mul := fun f ↦ f.toMonoidHom₁.map_mul diff --git a/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S03_Subobjects.lean b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S03_Subobjects.lean new file mode 100644 index 0000000..2ddb42e --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S03_Subobjects.lean @@ -0,0 +1,132 @@ +module +public import MIL.Common +public import Mathlib.GroupTheory.QuotientGroup.Basic + +set_option autoImplicit true + + +@[ext] +structure Submonoid₁ (M : Type) [Monoid M] where + /-- The carrier of a submonoid. -/ + carrier : Set M + /-- The product of two elements of a submonoid belongs to the submonoid. -/ + mul_mem {a b} : a ∈ carrier → b ∈ carrier → a * b ∈ carrier + /-- The unit element belongs to the submonoid. -/ + one_mem : 1 ∈ carrier + +/-- Submonoids in `M` can be seen as sets in `M`. -/ +instance [Monoid M] : SetLike (Submonoid₁ M) M where + coe := Submonoid₁.carrier + coe_injective _ _ := Submonoid₁.ext + + + +example [Monoid M] (N : Submonoid₁ M) : 1 ∈ N := N.one_mem + +example [Monoid M] (N : Submonoid₁ M) (α : Type) (f : M → α) := f '' N + + +example [Monoid M] (N : Submonoid₁ M) (x : N) : (x : M) ∈ N := x.property + + +instance [Monoid M] : PartialOrder (Submonoid₁ M) := .ofSetLike (Submonoid₁ M) M + +example [Monoid M] (N P : Submonoid₁ M) : N ≤ P ↔ ∀ x, x ∈ N → x ∈ P := SetLike.le_def + + +instance SubMonoid₁Monoid [Monoid M] (N : Submonoid₁ M) : Monoid N where + mul := fun x y ↦ ⟨x*y, N.mul_mem x.property y.property⟩ + mul_assoc := fun x y z ↦ SetCoe.ext (mul_assoc (x : M) y z) + one := ⟨1, N.one_mem⟩ + one_mul := fun x ↦ SetCoe.ext (one_mul (x : M)) + mul_one := fun x ↦ SetCoe.ext (mul_one (x : M)) + + +example [Monoid M] (N : Submonoid₁ M) : Monoid N where + mul := fun ⟨x, hx⟩ ⟨y, hy⟩ ↦ ⟨x*y, N.mul_mem hx hy⟩ + mul_assoc := fun ⟨x, _⟩ ⟨y, _⟩ ⟨z, _⟩ ↦ SetCoe.ext (mul_assoc x y z) + one := ⟨1, N.one_mem⟩ + one_mul := fun ⟨x, _⟩ ↦ SetCoe.ext (one_mul x) + mul_one := fun ⟨x, _⟩ ↦ SetCoe.ext (mul_one x) + + +class SubmonoidClass₁ (S : Type) (M : Type) [Monoid M] [SetLike S M] : Prop where + mul_mem : ∀ (s : S) {a b : M}, a ∈ s → b ∈ s → a * b ∈ s + one_mem : ∀ s : S, 1 ∈ s + +instance [Monoid M] : SubmonoidClass₁ (Submonoid₁ M) M where + mul_mem := Submonoid₁.mul_mem + one_mem := Submonoid₁.one_mem + +@[ext] +structure Subgroup₁ (G : Type) [Group G] extends Submonoid₁ G where + /-- The inverse of an element of a subgroup belongs to the subgroup. -/ + inv_mem {a} : a ∈ carrier → a⁻¹ ∈ carrier + + +/-- Subgroups in `M` can be seen as sets in `M`. -/ +instance [Group G] : SetLike (Subgroup₁ G) G where + coe := fun H ↦ H.toSubmonoid₁.carrier + coe_injective _ _ := Subgroup₁.ext + +instance [Group G] (H : Subgroup₁ G) : Group H := +{ SubMonoid₁Monoid H.toSubmonoid₁ with + inv := fun x ↦ ⟨x⁻¹, H.inv_mem x.property⟩ + inv_mul_cancel := fun x ↦ SetCoe.ext (inv_mul_cancel (x : G)) } + +class SubgroupClass₁ (S : Type) (G : Type) [Group G] [SetLike S G] : Prop + extends SubmonoidClass₁ S G where + inv_mem : ∀ (s : S) {a : G}, a ∈ s → a⁻¹ ∈ s + +instance [Group G] : SubmonoidClass₁ (Subgroup₁ G) G where + mul_mem := fun H ↦ H.toSubmonoid₁.mul_mem + one_mem := fun H ↦ H.toSubmonoid₁.one_mem + +instance [Group G] : SubgroupClass₁ (Subgroup₁ G) G := +{ (inferInstance : SubmonoidClass₁ (Subgroup₁ G) G) with + inv_mem := Subgroup₁.inv_mem } + + +instance [Monoid M] : Min (Submonoid₁ M) := + ⟨fun S₁ S₂ ↦ + { carrier := S₁ ∩ S₂ + one_mem := ⟨S₁.one_mem, S₂.one_mem⟩ + mul_mem := fun ⟨hx, hx'⟩ ⟨hy, hy'⟩ ↦ ⟨S₁.mul_mem hx hy, S₂.mul_mem hx' hy'⟩ }⟩ + + +example [Monoid M] (N P : Submonoid₁ M) : Submonoid₁ M := N ⊓ P + + +def Submonoid.Setoid [CommMonoid M] (N : Submonoid M) : Setoid M where + r := fun x y ↦ ∃ w ∈ N, ∃ z ∈ N, x*w = y*z + iseqv := { + refl := fun x ↦ ⟨1, N.one_mem, 1, N.one_mem, rfl⟩ + symm := fun ⟨w, hw, z, hz, h⟩ ↦ ⟨z, hz, w, hw, h.symm⟩ + trans := by + rintro a b c ⟨w, hw, z, hz, h⟩ ⟨w', hw', z', hz', h'⟩ + refine ⟨w*w', N.mul_mem hw hw', z*z', N.mul_mem hz hz', ?_⟩ + rw [← mul_assoc, h, mul_comm b, mul_assoc, h', ← mul_assoc, mul_comm z, mul_assoc] + } + +instance [CommMonoid M] : HasQuotient M (Submonoid M) where + Quotient := fun N ↦ Quotient N.Setoid + +def QuotientMonoid.mk [CommMonoid M] (N : Submonoid M) : M → M ⧸ N := Quotient.mk N.Setoid + +instance [CommMonoid M] (N : Submonoid M) : Monoid (M ⧸ N) where + mul := Quotient.map₂ (· * ·) (by + rintro a₁ b₁ ⟨w, hw, z, hz, ha⟩ a₂ b₂ ⟨w', hw', z', hz', hb⟩ + refine ⟨w*w', N.mul_mem hw hw', z*z', N.mul_mem hz hz', ?_⟩ + rw [mul_comm w, ← mul_assoc, mul_assoc a₁, hb, mul_comm, ← mul_assoc, mul_comm w, ha, + mul_assoc, mul_comm z, mul_assoc b₂, mul_comm z', mul_assoc] + ) + mul_assoc := by + rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ + apply Quotient.sound + dsimp only + rw [mul_assoc] + one := QuotientMonoid.mk N 1 + one_mul := by + rintro ⟨a⟩ ; apply Quotient.sound ; dsimp only ; rw [one_mul] + mul_one := by + rintro ⟨a⟩ ; apply Quotient.sound ; dsimp only ; rw [mul_one] diff --git a/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/S01_Groups.lean b/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/S01_Groups.lean new file mode 100644 index 0000000..60c643b --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/S01_Groups.lean @@ -0,0 +1,296 @@ +module +public import Mathlib.GroupTheory.Sylow +public import Mathlib.GroupTheory.Perm.Cycle.Concrete +public import Mathlib.GroupTheory.Perm.Subgroup +public import Mathlib.GroupTheory.PresentedGroup + +public import MIL.Common + +public section + +example {M : Type*} [Monoid M] (x : M) : x * 1 = x := mul_one x + +example {M : Type*} [AddCommMonoid M] (x y : M) : x + y = y + x := add_comm x y + +example {M N : Type*} [Monoid M] [Monoid N] (x y : M) (f : M →* N) : f (x * y) = f x * f y := + f.map_mul x y + +example {M N : Type*} [AddMonoid M] [AddMonoid N] (f : M →+ N) : f 0 = 0 := + f.map_zero + +example {M N P : Type*} [AddMonoid M] [AddMonoid N] [AddMonoid P] + (f : M →+ N) (g : N →+ P) : M →+ P := g.comp f + +example {G : Type*} [Group G] (x : G) : x * x⁻¹ = 1 := mul_inv_cancel x + +example {G : Type*} [Group G] (x y z : G) : x * (y * z) * (x * z)⁻¹ * (x * y * x⁻¹)⁻¹ = 1 := by + group + +example {G : Type*} [AddCommGroup G] (x y z : G) : z + x + (y - z - x) = y := by + abel + +example {G H : Type*} [Group G] [Group H] (x y : G) (f : G →* H) : f (x * y) = f x * f y := + f.map_mul x y + +example {G H : Type*} [Group G] [Group H] (x : G) (f : G →* H) : f (x⁻¹) = (f x)⁻¹ := + f.map_inv x + +example {G H : Type*} [Group G] [Group H] (f : G → H) (h : ∀ x y, f (x * y) = f x * f y) : + G →* H := + MonoidHom.mk' f h + +example {G H : Type*} [Group G] [Group H] (f : G ≃* H) : + f.trans f.symm = MulEquiv.refl G := + f.self_trans_symm + +noncomputable example {G H : Type*} [Group G] [Group H] + (f : G →* H) (h : Function.Bijective f) : + G ≃* H := + MulEquiv.ofBijective f h + +example {G : Type*} [Group G] (H : Subgroup G) {x y : G} (hx : x ∈ H) (hy : y ∈ H) : + x * y ∈ H := + H.mul_mem hx hy + +example {G : Type*} [Group G] (H : Subgroup G) {x : G} (hx : x ∈ H) : + x⁻¹ ∈ H := + H.inv_mem hx + +example : AddSubgroup ℚ where + carrier := Set.range ((↑) : ℤ → ℚ) + add_mem' := by + rintro _ _ ⟨n, rfl⟩ ⟨m, rfl⟩ + use n + m + simp + zero_mem' := by + use 0 + simp + neg_mem' := by + rintro _ ⟨n, rfl⟩ + use -n + simp + +example {G : Type*} [Group G] (H : Subgroup G) : Group H := inferInstance + +example {G : Type*} [Group G] (H : Subgroup G) : Group {x : G // x ∈ H} := inferInstance + +example {G : Type*} [Group G] (H H' : Subgroup G) : + ((H ⊓ H' : Subgroup G) : Set G) = (H : Set G) ∩ (H' : Set G) := rfl + +example {G : Type*} [Group G] (H H' : Subgroup G) : + ((H ⊔ H' : Subgroup G) : Set G) = Subgroup.closure ((H : Set G) ∪ (H' : Set G)) := by + rw [Subgroup.sup_eq_closure] + +example {G : Type*} [Group G] (x : G) : x ∈ (⊤ : Subgroup G) := trivial + +example {G : Type*} [Group G] (x : G) : x ∈ (⊥ : Subgroup G) ↔ x = 1 := Subgroup.mem_bot + +def conjugate {G : Type*} [Group G] (x : G) (H : Subgroup G) : Subgroup G where + carrier := {a : G | ∃ h, h ∈ H ∧ a = x * h * x⁻¹} + one_mem' := by + dsimp + sorry + inv_mem' := by + dsimp + sorry + mul_mem' := by + dsimp + sorry + +example {G H : Type*} [Group G] [Group H] (G' : Subgroup G) (f : G →* H) : Subgroup H := + Subgroup.map f G' + +example {G H : Type*} [Group G] [Group H] (H' : Subgroup H) (f : G →* H) : Subgroup G := + Subgroup.comap f H' + +#check Subgroup.mem_map +#check Subgroup.mem_comap + +example {G H : Type*} [Group G] [Group H] (f : G →* H) (g : G) : + g ∈ MonoidHom.ker f ↔ f g = 1 := + f.mem_ker + +example {G H : Type*} [Group G] [Group H] (f : G →* H) (h : H) : + h ∈ MonoidHom.range f ↔ ∃ g : G, f g = h := + f.mem_range + +section exercises +variable {G H : Type*} [Group G] [Group H] + +open Subgroup + +example (φ : G →* H) (S T : Subgroup H) (hST : S ≤ T) : comap φ S ≤ comap φ T := by + sorry + +example (φ : G →* H) (S T : Subgroup G) (hST : S ≤ T) : map φ S ≤ map φ T := by + sorry + +variable {K : Type*} [Group K] + +-- Remember you can use the `ext` tactic to prove an equality of subgroups. +example (φ : G →* H) (ψ : H →* K) (U : Subgroup K) : + comap (ψ.comp φ) U = comap φ (comap ψ U) := by + sorry + +-- Pushing a subgroup along one homomorphism and then another is equal to +-- pushing it forward along the composite of the homomorphisms. +example (φ : G →* H) (ψ : H →* K) (S : Subgroup G) : + map (ψ.comp φ) S = map ψ (S.map φ) := by + sorry + +end exercises + +open scoped Classical + + +example {G : Type*} [Group G] (G' : Subgroup G) : Nat.card G' ∣ Nat.card G := + ⟨G'.index, mul_comm G'.index _ ▸ G'.index_mul_card.symm⟩ + +open Subgroup + +example {G : Type*} [Group G] [Finite G] (p : ℕ) {n : ℕ} [Fact p.Prime] + (hdvd : p ^ n ∣ Nat.card G) : ∃ K : Subgroup G, Nat.card K = p ^ n := + Sylow.exists_subgroup_card_pow_prime p hdvd + +lemma eq_bot_iff_card {G : Type*} [Group G] {H : Subgroup G} : + H = ⊥ ↔ Nat.card H = 1 := by + suffices (∀ x ∈ H, x = 1) ↔ ∃ x ∈ H, ∀ a ∈ H, a = x by + simpa [eq_bot_iff_forall, Nat.card_eq_one_iff_exists] + sorry + +#check card_dvd_of_le + +lemma inf_bot_of_coprime {G : Type*} [Group G] (H K : Subgroup G) + (h : (Nat.card H).Coprime (Nat.card K)) : H ⊓ K = ⊥ := by + sorry +open Equiv + +example {X : Type*} [Finite X] : Subgroup.closure {σ : Perm X | Perm.IsCycle σ} = ⊤ := + Perm.closure_isCycle + +#simp [mul_assoc] c[1, 2, 3] * c[2, 3, 4] + +section FreeGroup + +inductive S | a | b | c + +open S + +def myElement : FreeGroup S := (.of a) * (.of b)⁻¹ + +def myMorphism : FreeGroup S →* Perm (Fin 5) := + FreeGroup.lift fun | .a => c[1, 2, 3] + | .b => c[2, 3, 1] + | .c => c[2, 3] + + +def myGroup := PresentedGroup {.of () ^ 3} deriving Group + +def myMap : Unit → Perm (Fin 5) +| () => c[1, 2, 3] + +lemma compat_myMap : + ∀ r ∈ ({.of () ^ 3} : Set (FreeGroup Unit)), FreeGroup.lift myMap r = 1 := by + rintro _ rfl + simp + decide + +def myNewMorphism : myGroup →* Perm (Fin 5) := PresentedGroup.toGroup compat_myMap + +end FreeGroup + +noncomputable section GroupActions + +example {G X : Type*} [Group G] [MulAction G X] (g g': G) (x : X) : + g • (g' • x) = (g * g') • x := + (mul_smul g g' x).symm + +example {G X : Type*} [AddGroup G] [AddAction G X] (g g' : G) (x : X) : + g +ᵥ (g' +ᵥ x) = (g + g') +ᵥ x := + (add_vadd g g' x).symm + +open MulAction + +example {G X : Type*} [Group G] [MulAction G X] : G →* Equiv.Perm X := + toPermHom G X + +def CayleyIsoMorphism (G : Type*) [Group G] : G ≃* (toPermHom G G).range := + Equiv.Perm.subgroupOfMulAction G G + +example {G X : Type*} [Group G] [MulAction G X] : + X ≃ (ω : orbitRel.Quotient G X) × (orbit G (Quotient.out ω)) := + MulAction.selfEquivSigmaOrbits G X + +example {G X : Type*} [Group G] [MulAction G X] (x : X) : + orbit G x ≃ G ⧸ stabilizer G x := + MulAction.orbitEquivQuotientStabilizer G x + +example {G : Type*} [Group G] (H : Subgroup G) : G ≃ (G ⧸ H) × H := + groupEquivQuotientProdSubgroup + +variable {G : Type*} [Group G] + +lemma conjugate_one (H : Subgroup G) : conjugate 1 H = H := by + sorry + +instance : MulAction G (Subgroup G) where + smul := conjugate + one_smul := by + sorry + mul_smul := by + sorry + +end GroupActions + +noncomputable section QuotientGroup + +example {G : Type*} [Group G] (H : Subgroup G) [H.Normal] : Group (G ⧸ H) := inferInstance + +example {G : Type*} [Group G] (H : Subgroup G) [H.Normal] : G →* G ⧸ H := + QuotientGroup.mk' H + +example {G : Type*} [Group G] (N : Subgroup G) [N.Normal] {M : Type*} + [Group M] (φ : G →* M) (h : N ≤ MonoidHom.ker φ) : G ⧸ N →* M := + QuotientGroup.lift N φ h + +example {G : Type*} [Group G] {M : Type*} [Group M] (φ : G →* M) : + G ⧸ MonoidHom.ker φ →* MonoidHom.range φ := + QuotientGroup.quotientKerEquivRange φ + +example {G G': Type*} [Group G] [Group G'] + {N : Subgroup G} [N.Normal] {N' : Subgroup G'} [N'.Normal] + {φ : G →* G'} (h : N ≤ Subgroup.comap φ N') : G ⧸ N →* G' ⧸ N':= + QuotientGroup.map N N' φ h + +example {G : Type*} [Group G] {M N : Subgroup G} [M.Normal] + [N.Normal] (h : M = N) : G ⧸ M ≃* G ⧸ N := QuotientGroup.quotientMulEquivOfEq h + +section +variable {G : Type*} [Group G] {H K : Subgroup G} + +open MonoidHom + +#check Nat.card_pos -- The nonempty argument will be automatically inferred for subgroups +#check Subgroup.index_eq_card +#check Subgroup.index_mul_card +#check Nat.eq_of_mul_eq_mul_right + +lemma aux_card_eq [Finite G] (h' : Nat.card G = Nat.card H * Nat.card K) : + Nat.card (G ⧸ H) = Nat.card K := by + sorry +variable [H.Normal] [K.Normal] [Fintype G] (h : Disjoint H K) + (h' : Nat.card G = Nat.card H * Nat.card K) + +#check Nat.bijective_iff_injective_and_card +#check ker_eq_bot_iff +#check domRestrict +#check ker_domRestrict + +def iso₁ : K ≃* G ⧸ H := by + sorry +def iso₂ : G ≃* (G ⧸ K) × (G ⧸ H) := by + sorry +#check MulEquiv.prodCongr + +def finalIso : G ≃* H × K := + sorry diff --git a/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/S02_Rings.lean b/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/S02_Rings.lean new file mode 100644 index 0000000..c411909 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/S02_Rings.lean @@ -0,0 +1,224 @@ +module +public import Mathlib.RingTheory.Ideal.Quotient.Operations +public import Mathlib.RingTheory.Localization.Basic +public import Mathlib.Analysis.Complex.Polynomial.Basic +public import Mathlib.Data.ZMod.QuotientRing +public import MIL.Common + +noncomputable section + +example {R : Type*} [CommRing R] (x y : R) : (x + y) ^ 2 = x ^ 2 + y ^ 2 + 2 * x * y := by ring + +example (x y : ℕ) : (x + y) ^ 2 = x ^ 2 + y ^ 2 + 2 * x * y := by ring + +example (x : ℤˣ) : x = 1 ∨ x = -1 := Int.units_eq_one_or x + +example {M : Type*} [Monoid M] (x : Mˣ) : (x : M) * x⁻¹ = 1 := Units.mul_inv x + +example {M : Type*} [Monoid M] : Group Mˣ := inferInstance + +example {R S : Type*} [Ring R] [Ring S] (f : R →+* S) (x y : R) : + f (x + y) = f x + f y := f.map_add x y + +example {R S : Type*} [Ring R] [Ring S] (f : R →+* S) : Rˣ →* Sˣ := + Units.map f + +example {R : Type*} [Ring R] (S : Subring R) : Ring S := inferInstance + +example {R : Type*} [CommRing R] (I : Ideal R) : R →+* R ⧸ I := + Ideal.Quotient.mk I + +example {R : Type*} [CommRing R] {a : R} {I : Ideal R} : + Ideal.Quotient.mk I a = 0 ↔ a ∈ I := + Ideal.Quotient.eq_zero_iff_mem + +example {R S : Type*} [CommRing R] [CommRing S] (I : Ideal R) (f : R →+* S) + (H : I ≤ RingHom.ker f) : R ⧸ I →+* S := + Ideal.Quotient.lift I f H + +example {R S : Type*} [CommRing R] [CommRing S](f : R →+* S) : + R ⧸ RingHom.ker f ≃+* f.range := + RingHom.quotientKerEquivRange f + +section +variable {R : Type*} [CommRing R] {I J : Ideal R} + +example : I + J = I ⊔ J := rfl + +example {x : R} : x ∈ I + J ↔ ∃ a ∈ I, ∃ b ∈ J, a + b = x := by + simp [Submodule.mem_sup] + +example : I * J ≤ J := Ideal.mul_le_right + +example : I * J ≤ I := Ideal.mul_le_left + +example : I * J ≤ I ⊓ J := Ideal.mul_le_inf + +end + +example {R S : Type*} [CommRing R] [CommRing S] (I : Ideal R) (J : Ideal S) (f : R →+* S) + (H : I ≤ Ideal.comap f J) : R ⧸ I →+* S ⧸ J := + Ideal.quotientMap J f H + +example {R : Type*} [CommRing R] {I J : Ideal R} (h : I = J) : R ⧸ I ≃+* R ⧸ J := + Ideal.quotEquivOfEq h + +example {R : Type*} [CommRing R] {ι : Type*} [Fintype ι] (f : ι → Ideal R) + (hf : ∀ i j, i ≠ j → IsCoprime (f i) (f j)) : (R ⧸ ⨅ i, f i) ≃+* Π i, R ⧸ f i := + Ideal.quotientInfRingEquivPiQuotient f hf + +open BigOperators PiNotation + +example {ι : Type*} [Fintype ι] (a : ι → ℕ) (coprime : ∀ i j, i ≠ j → (a i).Coprime (a j)) : + ZMod (∏ i, a i) ≃+* Π i, ZMod (a i) := + ZMod.prodEquivPi a coprime + +section +variable {ι R : Type*} [CommRing R] +open Ideal Quotient Function + +#check RingHom.pi +#check ker_Pi_Quotient_mk + +/-- The homomorphism from ``R ⧸ ⨅ i, I i`` to ``Π i, R ⧸ I i`` featured in the Chinese + Remainder Theorem. -/ +def chineseMap (I : ι → Ideal R) : (R ⧸ ⨅ i, I i) →+* Π i, R ⧸ I i := + sorry + +lemma chineseMap_mk (I : ι → Ideal R) (x : R) : + chineseMap I (Quotient.mk _ x) = fun i : ι ↦ Ideal.Quotient.mk (I i) x := + sorry + +lemma chineseMap_mk' (I : ι → Ideal R) (x : R) (i : ι) : + chineseMap I (mk _ x) i = mk (I i) x := + sorry + +#check injective_lift_iff + +lemma chineseMap_inj (I : ι → Ideal R) : Injective (chineseMap I) := by + sorry + +#check IsCoprime +#check isCoprime_iff_add +#check isCoprime_iff_exists +#check isCoprime_iff_sup_eq +#check isCoprime_iff_codisjoint + +#check Finset.mem_insert_of_mem +#check Finset.mem_insert_self + +theorem isCoprime_Inf {I : Ideal R} {J : ι → Ideal R} {s : Finset ι} + (hf : ∀ j ∈ s, IsCoprime I (J j)) : IsCoprime I (⨅ j ∈ s, J j) := by + classical + simp_rw [isCoprime_iff_add] at * + induction s using Finset.induction with + | empty => + simp + | @insert i s _ hs => + rw [Finset.iInf_insert, inf_comm, one_eq_top, eq_top_iff, ← one_eq_top] + set K := ⨅ j ∈ s, J j + calc + 1 = I + K := sorry + _ = I + K * (I + J i) := sorry + _ = (1 + K) * I + K * J i := sorry + _ ≤ I + K ⊓ J i := sorry +lemma chineseMap_surj [Fintype ι] {I : ι → Ideal R} + (hI : ∀ i j, i ≠ j → IsCoprime (I i) (I j)) : Surjective (chineseMap I) := by + classical + intro g + choose f hf using fun i ↦ Ideal.Quotient.mk_surjective (g i) + have key : ∀ i, ∃ e : R, mk (I i) e = 1 ∧ ∀ j, j ≠ i → mk (I j) e = 0 := by + intro i + have hI' : ∀ j ∈ ({i} : Finset ι)ᶜ, IsCoprime (I i) (I j) := by + sorry + sorry + choose e he using key + use mk _ (∑ i, f i * e i) + sorry + +noncomputable def chineseIso [Fintype ι] (f : ι → Ideal R) + (hf : ∀ i j, i ≠ j → IsCoprime (f i) (f j)) : (R ⧸ ⨅ i, f i) ≃+* Π i, R ⧸ f i := + { Equiv.ofBijective _ ⟨chineseMap_inj f, chineseMap_surj hf⟩, + chineseMap f with } + +end + +example {R A : Type*} [CommRing R] [Ring A] [Algebra R A] (r r' : R) (a : A) : + (r + r') • a = r • a + r' • a := + add_smul r r' a + +example {R A : Type*} [CommRing R] [Ring A] [Algebra R A] (r r' : R) (a : A) : + (r * r') • a = r • r' • a := + mul_smul r r' a + +section Polynomials +open Polynomial + +example {R : Type*} [CommRing R] : R[X] := X + +example {R : Type*} [CommRing R] (r : R) := X - C r + +example {R : Type*} [CommRing R] (r : R) : (X + C r) * (X - C r) = X ^ 2 - C (r ^ 2) := by + rw [C.map_pow] + ring + +example {R : Type*} [CommRing R] (r:R) : (C r).coeff 0 = r := by simp + +example {R : Type*} [CommRing R] : (X ^ 2 + 2 * X + C 3 : R[X]).coeff 1 = 2 := by simp + +example {R : Type*} [Semiring R] [NoZeroDivisors R] {p q : R[X]} : + degree (p * q) = degree p + degree q := + Polynomial.degree_mul + +example {R : Type*} [Semiring R] [NoZeroDivisors R] {p q : R[X]} (hp : p ≠ 0) (hq : q ≠ 0) : + natDegree (p * q) = natDegree p + natDegree q := + Polynomial.natDegree_mul hp hq + +example {R : Type*} [Semiring R] [NoZeroDivisors R] {p q : R[X]} : + natDegree (comp p q) = natDegree p * natDegree q := + Polynomial.natDegree_comp + +example {R : Type*} [CommRing R] (P: R[X]) (x : R) := P.eval x + +example {R : Type*} [CommRing R] (r : R) : (X - C r).eval r = 0 := by simp + +example {R : Type*} [CommRing R] (P : R[X]) (r : R) : IsRoot P r ↔ P.eval r = 0 := Iff.rfl + +example {R : Type*} [CommRing R] [IsDomain R] (r : R) : (X - C r).roots = {r} := + roots_X_sub_C r + +example {R : Type*} [CommRing R] [IsDomain R] (r : R) (n : ℕ): + ((X - C r) ^ n).roots = n • {r} := + by simp + +example : aeval Complex.I (X ^ 2 + 1 : ℝ[X]) = 0 := by simp + +open Complex Polynomial + +example : aroots (X ^ 2 + 1 : ℝ[X]) ℂ = {Complex.I, -I} := by + suffices roots (X ^ 2 + 1 : ℂ[X]) = {I, -I} by simpa [aroots_def] + have factored : (X ^ 2 + 1 : ℂ[X]) = (X - C I) * (X - C (-I)) := by + have key : (C I * C I : ℂ[X]) = -1 := by simp [← C_mul] + rw [C_neg] + linear_combination key + have p_ne_zero : (X - C I) * (X - C (-I)) ≠ 0 := by + intro H + apply_fun eval 0 at H + simp [eval] at H + simp only [factored, roots_mul p_ne_zero, roots_X_sub_C] + rfl + +-- Mathlib knows about D'Alembert-Gauss theorem: ``ℂ`` is algebraically closed. +example : IsAlgClosed ℂ := inferInstance + +#check (Complex.ofRealHom : ℝ →+* ℂ) + +example : (X ^ 2 + 1 : ℝ[X]).eval₂ Complex.ofRealHom Complex.I = 0 := by simp + +open MvPolynomial + +def circleEquation : MvPolynomial (Fin 2) ℝ := X 0 ^ 2 + X 1 ^ 2 - 1 + +example : MvPolynomial.eval ![1, 0] circleEquation = 0 := by simp [circleEquation] + +end Polynomials diff --git a/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S01_Groups.lean b/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S01_Groups.lean new file mode 100644 index 0000000..8806445 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S01_Groups.lean @@ -0,0 +1,171 @@ +module +public import Mathlib.GroupTheory.Sylow +public import Mathlib.GroupTheory.Perm.Cycle.Concrete +public import Mathlib.GroupTheory.Perm.Subgroup +public import Mathlib.GroupTheory.PresentedGroup + +public import MIL.Common + +public section + +def conjugate {G : Type*} [Group G] (x : G) (H : Subgroup G) : Subgroup G where + carrier := {a : G | ∃ h, h ∈ H ∧ a = x * h * x⁻¹} + one_mem' := by + dsimp + use 1 + constructor + exact H.one_mem + group + inv_mem' := by + dsimp + rintro - ⟨h, h_in, rfl⟩ + use h⁻¹, H.inv_mem h_in + group + mul_mem' := by + dsimp + rintro - - ⟨h, h_in, rfl⟩ ⟨k, k_in, rfl⟩ + use h*k, H.mul_mem h_in k_in + group + +section exercises +variable {G H : Type*} [Group G] [Group H] + +open Subgroup + +example (φ : G →* H) (S T : Subgroup H) (hST : S ≤ T) : comap φ S ≤ comap φ T := by + intro x hx + rw [mem_comap] at * -- Lean does not need this line + exact hST hx + +example (φ : G →* H) (S T : Subgroup G) (hST : S ≤ T) : map φ S ≤ map φ T := by + intro x hx + rw [mem_map] at * -- Lean does not need this line + rcases hx with ⟨y, hy, rfl⟩ + use y, hST hy + +variable {K : Type*} [Group K] + +-- Remember you can use the `ext` tactic to prove an equality of subgroups. +example (φ : G →* H) (ψ : H →* K) (U : Subgroup K) : + comap (ψ.comp φ) U = comap φ (comap ψ U) := by + -- The whole proof could be ``rfl``, but let's decompose it a bit. + ext x + simp only [mem_comap] + rfl + +-- Pushing a subgroup along one homomorphism and then another is equal to +-- pushing it forward along the composite of the homomorphisms. +example (φ : G →* H) (ψ : H →* K) (S : Subgroup G) : + map (ψ.comp φ) S = map ψ (S.map φ) := by + ext x + simp only [mem_map] + constructor + · rintro ⟨y, y_in, hy⟩ + exact ⟨φ y, ⟨y, y_in, rfl⟩, hy⟩ + · rintro ⟨y, ⟨z, z_in, hz⟩, hy⟩ + use z, z_in + calc ψ.comp φ z = ψ (φ z) := rfl + _ = ψ y := by congr + _ = x := hy + +end exercises + +open scoped Classical + +open Subgroup + +lemma eq_bot_iff_card {G : Type*} [Group G] {H : Subgroup G} : + H = ⊥ ↔ Nat.card H = 1 := by + suffices (∀ x ∈ H, x = 1) ↔ ∃ x ∈ H, ∀ a ∈ H, a = x by + simpa [eq_bot_iff_forall, Nat.card_eq_one_iff_exists] + constructor + · intro h + use 1, H.one_mem + · rintro ⟨y, -, hy'⟩ x hx + calc x = y := hy' x hx + _ = 1 := (hy' 1 H.one_mem).symm + +lemma inf_bot_of_coprime {G : Type*} [Group G] (H K : Subgroup G) + (h : (Nat.card H).Coprime (Nat.card K)) : H ⊓ K = ⊥ := by + have D₁ : Nat.card (H ⊓ K : Subgroup G) ∣ Nat.card H := card_dvd_of_le inf_le_left + have D₂ : Nat.card (H ⊓ K : Subgroup G) ∣ Nat.card K := card_dvd_of_le inf_le_right + exact eq_bot_iff_card.2 (Nat.eq_one_of_dvd_coprimes h D₁ D₂) + +noncomputable section GroupActions + +variable {G : Type*} [Group G] + +lemma conjugate_one (H : Subgroup G) : conjugate 1 H = H := by + ext x + simp [conjugate] + +instance : MulAction G (Subgroup G) where + smul := conjugate + one_smul := by + exact conjugate_one + mul_smul := by + intro x y H + ext z + constructor + · rintro ⟨h, h_in, rfl⟩ + use y*h*y⁻¹ + constructor + · use h + · group + · rintro ⟨-, ⟨h, h_in, rfl⟩, rfl⟩ + use h, h_in + group + +end GroupActions + +noncomputable section QuotientGroup + +section +variable {G : Type*} [Group G] {H K : Subgroup G} + +open MonoidHom + +#check Nat.card_pos -- The nonempty argument will be automatically inferred for subgroups +#check Subgroup.index_eq_card +#check Subgroup.index_mul_card +#check Nat.eq_of_mul_eq_mul_right + +lemma aux_card_eq [Finite G] (h' : Nat.card G = Nat.card H * Nat.card K) : + Nat.card (G ⧸ H) = Nat.card K := by + have := calc + Nat.card (G ⧸ H) * Nat.card H = Nat.card G := by rw [← H.index_eq_card, H.index_mul_card] + _ = Nat.card K * Nat.card H := by rw [h', mul_comm] + + exact Nat.eq_of_mul_eq_mul_right Nat.card_pos this + +variable [H.Normal] [K.Normal] [Fintype G] (h : Disjoint H K) + (h' : Nat.card G = Nat.card H * Nat.card K) + +#check Nat.bijective_iff_injective_and_card +#check ker_eq_bot_iff +#check domRestrict +#check ker_domRestrict + +def iso₁ : K ≃* G ⧸ H := by + apply MulEquiv.ofBijective ((QuotientGroup.mk' H).domRestrict K) + rw [Nat.bijective_iff_injective_and_card] + constructor + · rw [← ker_eq_bot_iff, (QuotientGroup.mk' H).ker_domRestrict K] + simp [h] + · symm + exact aux_card_eq h' + +def iso₂ : G ≃* (G ⧸ K) × (G ⧸ H) := by + apply MulEquiv.ofBijective <| (QuotientGroup.mk' K).prod (QuotientGroup.mk' H) + rw [Nat.bijective_iff_injective_and_card] + constructor + · rw [← ker_eq_bot_iff, ker_prod] + simp [h.symm.eq_bot] + · rw [Nat.card_prod] + rw [aux_card_eq h', aux_card_eq (mul_comm (Nat.card H) _▸ h'), h'] + +def finalIso : G ≃* H × K := + (iso₂ h h').trans ((iso₁ h.symm (mul_comm (Nat.card H) _ ▸ h')).prodCongr (iso₁ h h')).symm + +end +end QuotientGroup diff --git a/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S02_Rings.lean b/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S02_Rings.lean new file mode 100644 index 0000000..647dd33 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S02_Rings.lean @@ -0,0 +1,82 @@ +module +public import Mathlib.RingTheory.Ideal.Quotient.Operations +public import Mathlib.RingTheory.Localization.Basic +public import Mathlib.Analysis.Complex.Polynomial.Basic +public import Mathlib.Data.ZMod.QuotientRing +public import MIL.Common + +noncomputable section + +open BigOperators PiNotation + +section +variable {ι R : Type*} [CommRing R] +open Ideal Quotient Function + +#check RingHom.pi +#check ker_Pi_Quotient_mk + +/-- The homomorphism from ``R ⧸ ⨅ i, I i`` to ``Π i, R ⧸ I i`` featured in the Chinese + Remainder Theorem. -/ +def chineseMap (I : ι → Ideal R) : (R ⧸ ⨅ i, I i) →+* Π i, R ⧸ I i := + Ideal.Quotient.lift (⨅ i, I i) (RingHom.pi fun i : ι ↦ Ideal.Quotient.mk (I i)) + (by simp [← RingHom.mem_ker, ker_Pi_Quotient_mk]) + +lemma chineseMap_mk (I : ι → Ideal R) (x : R) : + chineseMap I (Quotient.mk _ x) = fun i : ι ↦ Ideal.Quotient.mk (I i) x := + rfl + +lemma chineseMap_mk' (I : ι → Ideal R) (x : R) (i : ι) : + chineseMap I (mk _ x) i = mk (I i) x := + rfl + +lemma chineseMap_inj (I : ι → Ideal R) : Injective (chineseMap I) := by + rw [chineseMap, injective_lift_iff, ker_Pi_Quotient_mk] + +theorem isCoprime_Inf {I : Ideal R} {J : ι → Ideal R} {s : Finset ι} + (hf : ∀ j ∈ s, IsCoprime I (J j)) : IsCoprime I (⨅ j ∈ s, J j) := by + classical + simp_rw [isCoprime_iff_add] at * + induction s using Finset.induction with + | empty => + simp + | @insert i s _ hs => + rw [Finset.iInf_insert, inf_comm, one_eq_top, eq_top_iff, ← one_eq_top] + set K := ⨅ j ∈ s, J j + calc + 1 = I + K := (hs fun j hj ↦ hf j (Finset.mem_insert_of_mem hj)).symm + _ = I + K * (I + J i) := by rw [hf i (Finset.mem_insert_self i s), mul_one] + _ = (1 + K) * I + K * J i := by ring + _ ≤ I + K ⊓ J i := by gcongr ; apply mul_le_right ; apply mul_le_inf + + +lemma chineseMap_surj [Fintype ι] {I : ι → Ideal R} + (hI : ∀ i j, i ≠ j → IsCoprime (I i) (I j)) : Surjective (chineseMap I) := by + classical + intro g + choose f hf using fun i ↦ Ideal.Quotient.mk_surjective (g i) + have key : ∀ i, ∃ e : R, mk (I i) e = 1 ∧ ∀ j, j ≠ i → mk (I j) e = 0 := by + intro i + have hI' : ∀ j ∈ ({i} : Finset ι)ᶜ, IsCoprime (I i) (I j) := by + intros j hj + exact hI _ _ (by simpa [ne_comm, isCoprime_iff_add] using hj) + rcases isCoprime_iff_exists.mp (isCoprime_Inf hI') with ⟨u, hu, e, he, hue⟩ + replace he : ∀ j, j ≠ i → e ∈ I j := by simpa using he + refine ⟨e, ?_, ?_⟩ + · simp [eq_sub_of_add_eq' hue, map_sub, eq_zero_iff_mem.mpr hu] + · exact fun j hj ↦ eq_zero_iff_mem.mpr (he j hj) + choose e he using key + use mk _ (∑ i, f i * e i) + ext i + rw [chineseMap_mk', map_sum, Fintype.sum_eq_single i] + · simp [(he i).1, hf] + · intros j hj + simp [(he j).2 i hj.symm] + +noncomputable def chineseIso [Fintype ι] (f : ι → Ideal R) + (hf : ∀ i j, i ≠ j → IsCoprime (f i) (f j)) : (R ⧸ ⨅ i, f i) ≃+* Π i, R ⧸ f i := + { Equiv.ofBijective _ ⟨chineseMap_inj f, chineseMap_surj hf⟩, + chineseMap f with } + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S01_Vector_Spaces.lean b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S01_Vector_Spaces.lean new file mode 100644 index 0000000..62c6629 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S01_Vector_Spaces.lean @@ -0,0 +1,175 @@ +module +public import Mathlib.LinearAlgebra.Matrix.Determinant.Basic +public import Mathlib.LinearAlgebra.Eigenspace.Minpoly +public import Mathlib.LinearAlgebra.Charpoly.Basic + +public import MIL.Common + + + +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + + +example (a : K) (u v : V) : a • (u + v) = a • u + a • v := + smul_add a u v + +example (a b : K) (u : V) : (a + b) • u = a • u + b • u := + add_smul a b u + +example (a b : K) (u : V) : a • b • u = b • a • u := + smul_comm a b u + +example {R M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] : + Module (Ideal R) (Submodule R M) := + inferInstance + +section +variable {R : Type*} [Ring R] {M : Type*} [AddCommGroup M] [Module R M] +end + + + +section +variable {R : Type*} [Semiring R] {M : Type*} [AddCommMonoid M] [Module R M] +end + + + +example {R : Type*} [Ring R] {M : Type*} [AddCommMonoid M] [Module R M] : M → M := + -- Make sure to use `letI` (instead of `haveI` or `let`) to make it easier to + -- identify the existing additive structure from the `AddCommMonoid M` hypothesis + -- with the new one introduced in the line below. + letI : AddCommGroup M := Module.addCommMonoidToAddCommGroup R + fun x => - x + + + +variable {W : Type*} [AddCommGroup W] [Module K W] + +variable (φ : V →ₗ[K] W) + +example (a : K) (v : V) : φ (a • v) = a • φ v := + map_smul φ a v + +example (v w : V) : φ (v + w) = φ v + φ w := + map_add φ v w + + +variable (ψ : V →ₗ[K] W) + +#check (2 • φ + ψ : V →ₗ[K] W) + + +variable (θ : W →ₗ[K] V) + +#check (φ.comp θ : W →ₗ[K] W) +#check (φ ∘ₗ θ : W →ₗ[K] W) + + +example : V →ₗ[K] V where + toFun v := 3 • v + map_add' _ _ := smul_add .. + map_smul' _ _ := smul_comm .. + + + +#check (φ.map_add' : ∀ x y : V, φ.toFun (x + y) = φ.toFun x + φ.toFun y) +#check (φ.map_add : ∀ x y : V, φ (x + y) = φ x + φ y) +#check (map_add φ : ∀ x y : V, φ (x + y) = φ x + φ y) + + + +#check (LinearMap.lsmul K V 3 : V →ₗ[K] V) +#check (LinearMap.lsmul K V : K →ₗ[K] V →ₗ[K] V) + + +example (f : V ≃ₗ[K] W) : f ≪≫ₗ f.symm = LinearEquiv.refl K V := + f.self_trans_symm + +noncomputable example (f : V →ₗ[K] W) (h : Function.Bijective f) : V ≃ₗ[K] W := + .ofBijective f h + + +section binary_product + +variable {W : Type*} [AddCommGroup W] [Module K W] +variable {U : Type*} [AddCommGroup U] [Module K U] +variable {T : Type*} [AddCommGroup T] [Module K T] + +-- First projection map +example : V × W →ₗ[K] V := LinearMap.fst K V W + +-- Second projection map +example : V × W →ₗ[K] W := LinearMap.snd K V W + +-- Universal property of the product +example (φ : U →ₗ[K] V) (ψ : U →ₗ[K] W) : U →ₗ[K] V × W := LinearMap.prod φ ψ + +-- The product map does the expected thing, first component +example (φ : U →ₗ[K] V) (ψ : U →ₗ[K] W) : LinearMap.fst K V W ∘ₗ LinearMap.prod φ ψ = φ := rfl + +-- The product map does the expected thing, second component +example (φ : U →ₗ[K] V) (ψ : U →ₗ[K] W) : LinearMap.snd K V W ∘ₗ LinearMap.prod φ ψ = ψ := rfl + +-- We can also combine maps in parallel +example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] T) : (V × W) →ₗ[K] (U × T) := φ.prodMap ψ + +-- This is simply done by combining the projections with the universal property +example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] T) : + φ.prodMap ψ = (φ ∘ₗ .fst K V W).prod (ψ ∘ₗ .snd K V W) := rfl + +-- First inclusion map +example : V →ₗ[K] V × W := LinearMap.inl K V W + +-- Second inclusion map +example : W →ₗ[K] V × W := LinearMap.inr K V W + +-- Universal property of the sum (aka coproduct) +example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] U) : V × W →ₗ[K] U := φ.coprod ψ + +-- The coproduct map does the expected thing, first component +example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] U) : φ.coprod ψ ∘ₗ LinearMap.inl K V W = φ := + LinearMap.coprod_inl φ ψ + +-- The coproduct map does the expected thing, second component +example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] U) : φ.coprod ψ ∘ₗ LinearMap.inr K V W = ψ := + LinearMap.coprod_inr φ ψ + +-- The coproduct map is defined in the expected way +example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] U) (v : V) (w : W) : + φ.coprod ψ (v, w) = φ v + ψ w := + rfl + +end binary_product + + +section families +open DirectSum + +variable {ι : Type*} [DecidableEq ι] + (V : ι → Type*) [∀ i, AddCommGroup (V i)] [∀ i, Module K (V i)] + +-- The universal property of the direct sum assembles maps from the summands to build +-- a map from the direct sum +example (φ : Π i, (V i →ₗ[K] W)) : (⨁ i, V i) →ₗ[K] W := + DirectSum.toModule K ι W φ + +-- The universal property of the direct product assembles maps into the factors +-- to build a map into the direct product +example (φ : Π i, (W →ₗ[K] V i)) : W →ₗ[K] (Π i, V i) := + LinearMap.pi φ + +-- The projection maps from the product +example (i : ι) : (Π j, V j) →ₗ[K] V i := LinearMap.proj i + +-- The inclusion maps into the sum +example (i : ι) : V i →ₗ[K] (⨁ i, V i) := DirectSum.lof K ι V i + +-- The inclusion maps into the product +example (i : ι) : V i →ₗ[K] (Π i, V i) := LinearMap.single K V i + +-- In case `ι` is a finite type, there is an isomorphism between the sum and product. +example [Fintype ι] : (⨁ i, V i) ≃ₗ[K] (Π i, V i) := + linearEquivFunOnFintype K ι V + +end families diff --git a/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S02_Subspaces.lean b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S02_Subspaces.lean new file mode 100644 index 0000000..7b433fe --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S02_Subspaces.lean @@ -0,0 +1,170 @@ +module +public import Mathlib.LinearAlgebra.Matrix.Determinant.Basic +public import Mathlib.LinearAlgebra.Eigenspace.Minpoly +public import Mathlib.LinearAlgebra.Charpoly.Basic + +public import MIL.Common + +section +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + +example (U : Submodule K V) {x y : V} (hx : x ∈ U) (hy : y ∈ U) : + x + y ∈ U := + U.add_mem hx hy + +example (U : Submodule K V) {x : V} (hx : x ∈ U) (a : K) : + a • x ∈ U := + U.smul_mem a hx +end + +noncomputable example : Submodule ℝ ℂ where + carrier := Set.range ((↑) : ℝ → ℂ) + add_mem' := by + rintro _ _ ⟨n, rfl⟩ ⟨m, rfl⟩ + use n + m + simp + zero_mem' := by + use 0 + simp + smul_mem' := by + rintro c - ⟨a, rfl⟩ + use c*a + simp + + +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + +def preimage {W : Type*} [AddCommGroup W] [Module K W] (φ : V →ₗ[K] W) (H : Submodule K W) : + Submodule K V where + carrier := φ ⁻¹' H + zero_mem' := by + sorry + add_mem' := by + sorry + smul_mem' := by + sorry + +example (U : Submodule K V) : Module K U := inferInstance + +example (U : Submodule K V) : Module K {x : V // x ∈ U} := inferInstance + +example (H H' : Submodule K V) : + ((H ⊓ H' : Submodule K V) : Set V) = (H : Set V) ∩ (H' : Set V) := rfl + +example (H H' : Submodule K V) : + ((H ⊔ H' : Submodule K V) : Set V) = Submodule.span K ((H : Set V) ∪ (H' : Set V)) := by + simp [Submodule.span_union] + +example (x : V) : x ∈ (⊤ : Submodule K V) := trivial + +example (x : V) : x ∈ (⊥ : Submodule K V) ↔ x = 0 := Submodule.mem_bot K + + +-- If two subspaces are in direct sum then they span the whole space. +example (U V : Submodule K V) (h : IsCompl U V) : + U ⊔ V = ⊤ := h.sup_eq_top + +-- If two subspaces are in direct sum then they intersect only at zero. +example (U V : Submodule K V) (h : IsCompl U V) : + U ⊓ V = ⊥ := h.inf_eq_bot + +section +open DirectSum +variable {ι : Type*} [DecidableEq ι] + +-- If subspaces are in direct sum then they span the whole space. +example (U : ι → Submodule K V) (h : DirectSum.IsInternal U) : + ⨆ i, U i = ⊤ := h.submodule_iSup_eq_top + +-- If subspaces are in direct sum then they pairwise intersect only at zero. +example {ι : Type*} [DecidableEq ι] (U : ι → Submodule K V) (h : DirectSum.IsInternal U) + {i j : ι} (hij : i ≠ j) : U i ⊓ U j = ⊥ := + (h.submodule_iSupIndep.pairwiseDisjoint hij).eq_bot + +-- Those conditions characterize direct sums. +#check DirectSum.isInternal_submodule_iff_iSupIndep_and_iSup_eq_top + +-- The relation with external direct sums: if a family of subspaces is +-- in internal direct sum then the map from their external direct sum into `V` +-- is a linear isomorphism. +noncomputable example {ι : Type*} [DecidableEq ι] (U : ι → Submodule K V) + (h : DirectSum.IsInternal U) : (⨁ i, U i) ≃ₗ[K] V := + LinearEquiv.ofBijective (coeLinearMap U) h +end + +example {s : Set V} (E : Submodule K V) : Submodule.span K s ≤ E ↔ s ⊆ E := + Submodule.span_le + +example : GaloisInsertion (Submodule.span K) ((↑) : Submodule K V → Set V) := + Submodule.gi K V + +example {S T : Submodule K V} {x : V} (h : x ∈ S ⊔ T) : + ∃ s ∈ S, ∃ t ∈ T, x = s + t := by + rw [← S.span_eq, ← T.span_eq, ← Submodule.span_union] at h + induction h using Submodule.span_induction with + | mem y h => + sorry + | zero => + sorry + | add x y hx hy hx' hy' => + sorry + | smul a x hx hx' => + sorry + +section + +variable {W : Type*} [AddCommGroup W] [Module K W] (φ : V →ₗ[K] W) + +variable (E : Submodule K V) in +#check (Submodule.map φ E : Submodule K W) + +variable (F : Submodule K W) in +#check (Submodule.comap φ F : Submodule K V) + +example : LinearMap.range φ = .map φ ⊤ := LinearMap.range_eq_map φ + +example : LinearMap.ker φ = .comap φ ⊥ := Submodule.comap_bot φ -- or `rfl` + + + +open Function LinearMap + +example : Injective φ ↔ ker φ = ⊥ := ker_eq_bot.symm + +example : Surjective φ ↔ range φ = ⊤ := range_eq_top.symm + +#check Submodule.mem_map_of_mem +#check Submodule.mem_map +#check Submodule.mem_comap + +example (E : Submodule K V) (F : Submodule K W) : + Submodule.map φ E ≤ F ↔ E ≤ Submodule.comap φ F := by + sorry + +variable (E : Submodule K V) + +example : Module K (V ⧸ E) := inferInstance + +example : V →ₗ[K] V ⧸ E := E.mkQ + +example : ker E.mkQ = E := E.ker_mkQ + +example : range E.mkQ = ⊤ := E.range_mkQ + +example (hφ : E ≤ ker φ) : V ⧸ E →ₗ[K] W := E.liftQ φ hφ + +example (F : Submodule K W) (hφ : E ≤ .comap φ F) : V ⧸ E →ₗ[K] W ⧸ F := E.mapQ F φ hφ + +noncomputable example : (V ⧸ LinearMap.ker φ) ≃ₗ[K] range φ := φ.quotKerEquivRange + + +open Submodule + +#check Submodule.map_comap_eq +#check Submodule.comap_map_eq + +example : Submodule K (V ⧸ E) ≃ { F : Submodule K V // E ≤ F } where + toFun := sorry + invFun := sorry + left_inv := sorry + right_inv := sorry diff --git a/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S03_Endomorphisms.lean b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S03_Endomorphisms.lean new file mode 100644 index 0000000..f4a90ee --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S03_Endomorphisms.lean @@ -0,0 +1,73 @@ +module +public import Mathlib.LinearAlgebra.Matrix.Determinant.Basic +public import Mathlib.LinearAlgebra.Eigenspace.Minpoly +public import Mathlib.LinearAlgebra.Charpoly.Basic + +public import MIL.Common + +noncomputable section + + + +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + +variable {W : Type*} [AddCommGroup W] [Module K W] + + +open Polynomial Module LinearMap End + +example (φ ψ : End K V) : φ * ψ = φ ∘ₗ ψ := + End.mul_eq_comp φ ψ -- `rfl` would also work + +-- evaluating `P` on `φ` +example (P : K[X]) (φ : End K V) : V →ₗ[K] V := + aeval φ P + +-- evaluating `X` on `φ` gives back `φ` +example (φ : End K V) : aeval φ (X : K[X]) = φ := + aeval_X φ + + + +#check Submodule.eq_bot_iff +#check Submodule.mem_inf +#check LinearMap.mem_ker + +example (P Q : K[X]) (h : IsCoprime P Q) (φ : End K V) : ker (aeval φ P) ⊓ ker (aeval φ Q) = ⊥ := by + sorry + +#check Submodule.add_mem_sup +#check map_mul +#check End.mul_apply +#check LinearMap.ker_le_ker_comp + +example (P Q : K[X]) (h : IsCoprime P Q) (φ : End K V) : + ker (aeval φ P) ⊔ ker (aeval φ Q) = ker (aeval φ (P*Q)) := by + sorry +example (φ : End K V) (a : K) : φ.eigenspace a = LinearMap.ker (φ - a • 1) := + End.eigenspace_def + + + +example (φ : End K V) (a : K) : φ.HasEigenvalue a ↔ φ.eigenspace a ≠ ⊥ := + Iff.rfl + +example (φ : End K V) (a : K) : φ.HasEigenvalue a ↔ ∃ v, φ.HasEigenvector a v := + ⟨End.HasEigenvalue.exists_hasEigenvector, fun ⟨_, hv⟩ ↦ φ.hasEigenvalue_of_hasEigenvector hv⟩ + +example (φ : End K V) : φ.Eigenvalues = {a // φ.HasEigenvalue a} := + rfl + +-- Eigenvalue are roots of the minimal polynomial +example (φ : End K V) (a : K) : φ.HasEigenvalue a → (minpoly K φ).IsRoot a := + φ.isRoot_of_hasEigenvalue + +-- In finite dimension, the converse is also true (we will discuss dimension below) +example [FiniteDimensional K V] (φ : End K V) (a : K) : + φ.HasEigenvalue a ↔ (minpoly K φ).IsRoot a := + φ.hasEigenvalue_iff_isRoot + +-- Cayley-Hamilton +example [FiniteDimensional K V] (φ : End K V) : aeval φ φ.charpoly = 0 := + φ.aeval_self_charpoly + diff --git a/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S04_Bases.lean b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S04_Bases.lean new file mode 100644 index 0000000..25b6b0c --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S04_Bases.lean @@ -0,0 +1,269 @@ +module +public import Mathlib.LinearAlgebra.Matrix.Determinant.Basic +public import Mathlib.LinearAlgebra.Eigenspace.Minpoly +public import Mathlib.LinearAlgebra.Charpoly.Basic +public import Mathlib.LinearAlgebra.Complex.FiniteDimensional + +public import MIL.Common + + +section matrices + +-- Adding vectors +#eval ![1, 2] + ![3, 4] -- ![4, 6] + +-- Adding matrices +#eval !![1, 2; 3, 4] + !![3, 4; 5, 6] -- !![4, 6; 8, 10] + +-- Multiplying matrices +#eval !![1, 2; 3, 4] * !![3, 4; 5, 6] -- !![13, 16; 29, 36] + +open Matrix + +-- matrices acting on vectors on the left +#eval !![1, 2; 3, 4] *ᵥ ![1, 1] -- ![3, 7] + +-- matrices acting on vectors on the left, resulting in a size one matrix +#eval !![1, 2] *ᵥ ![1, 1] -- ![3] + +-- matrices acting on vectors on the right +#eval ![1, 1, 1] ᵥ* !![1, 2; 3, 4; 5, 6] -- ![9, 12] +#eval replicateRow (Fin 1) ![1, 2] -- !![1, 2] + +#eval replicateCol (Fin 1) ![1, 2] -- !![1; 2] + +-- vector dot product +#eval ![1, 2] ⬝ᵥ ![3, 4] -- `11` + +-- matrix transpose +#eval !![1, 2; 3, 4]ᵀ -- `!![1, 3; 2, 4]` + +-- determinant +#eval !![(1 : ℤ), 2; 3, 4].det -- `-2` + +-- trace +#eval !![(1 : ℤ), 2; 3, 4].trace -- `5` + + + +#simp !![(1 : ℝ), 2; 3, 4].det -- `4 - 2*3` + +#norm_num !![(1 : ℝ), 2; 3, 4].det -- `-2` + +#norm_num !![(1 : ℝ), 2; 3, 4].trace -- `5` + +variable (a b c d : ℝ) in +#simp !![a, b; c, d].det -- `a * d – b * c` + + +#norm_num [Matrix.inv_def] !![(1 : ℝ), 2; 3, 4]⁻¹ -- !![-2, 1; 3 / 2, -(1 / 2)] + + +example : !![(1 : ℝ), 2; 3, 4]⁻¹ * !![(1 : ℝ), 2; 3, 4] = 1 := by + have : Invertible !![(1 : ℝ), 2; 3, 4] := by + apply Matrix.invertibleOfIsUnitDet + norm_num + simp + +example : !![(1 : ℝ), 2; 3, 4]⁻¹ * !![(1 : ℝ), 2; 3, 4] = 1 := by + norm_num [Matrix.inv_def] + exact one_fin_two.symm + +section + +example : (fun _ ↦ 1 : Fin 2 → Fin 2 → ℤ) = !![1, 1; 1, 1] := by + ext i j + fin_cases i <;> fin_cases j <;> rfl + +example : (fun _ ↦ 1 : Fin 2 → Fin 2 → ℤ) * (fun _ ↦ 1 : Fin 2 → Fin 2 → ℤ) = !![1, 1; 1, 1] := by + ext i j + fin_cases i <;> fin_cases j <;> rfl + +example : !![1, 1; 1, 1] * !![1, 1; 1, 1] = !![2, 2; 2, 2] := by + norm_num + +example {n : ℕ} (v : Fin n → ℝ) : + Matrix.vandermonde v = Matrix.of (fun i j : Fin n ↦ v i ^ (j : ℕ)) := + rfl +end +end matrices +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + +section + +open Module + +variable {ι : Type*} (B : Basis ι K V) (v : V) (i : ι) + +-- The basis vector with index ``i`` +#check (B i : V) + +-- the linear isomorphism with the model space given by ``B`` +#check (B.repr : V ≃ₗ[K] ι →₀ K) + +-- the component function of ``v`` +#check (B.repr v : ι →₀ K) + +-- the component of ``v`` with index ``i`` +#check (B.repr v i : K) + +noncomputable example (b : ι → V) (b_indep : LinearIndependent K b) + (b_spans : ∀ v, v ∈ Submodule.span K (Set.range b)) : Basis ι K V := + Basis.mk b_indep (fun v _ ↦ b_spans v) + +-- The family of vectors underlying the above basis is indeed ``b``. +example (b : ι → V) (b_indep : LinearIndependent K b) + (b_spans : ∀ v, v ∈ Submodule.span K (Set.range b)) (i : ι) : + Basis.mk b_indep (fun v _ ↦ b_spans v) i = b i := + Basis.mk_apply b_indep (fun v _ ↦ b_spans v) i + +variable [DecidableEq ι] + +example : Finsupp.basisSingleOne.repr = LinearEquiv.refl K (ι →₀ K) := + rfl + +example (i : ι) : Finsupp.basisSingleOne i = Finsupp.single i 1 := + rfl + + +example [Finite ι] (x : ι → K) (i : ι) : (Pi.basisFun K ι).repr x i = x i := by + simp + + +example [Fintype ι] : ∑ i : ι, B.repr v i • (B i) = v := + B.sum_repr v + + + + +example (c : ι →₀ K) (f : ι → V) (s : Finset ι) (h : c.support ⊆ s) : + Finsupp.linearCombination K f c = ∑ i ∈ s, c i • f i := + Finsupp.linearCombination_apply_of_mem_supported K h + +example : Finsupp.linearCombination K B (B.repr v) = v := + B.linearCombination_repr v +variable (f : ι → V) in +#check (Finsupp.linearCombination K f : (ι →₀ K) →ₗ[K] V) + +section + +variable {W : Type*} [AddCommGroup W] [Module K W] + (φ : V →ₗ[K] W) (u : ι → W) + +#check (B.constr K : (ι → W) ≃ₗ[K] (V →ₗ[K] W)) + +#check (B.constr K u : V →ₗ[K] W) + +example (i : ι) : B.constr K u (B i) = u i := + B.constr_basis K u i + +example (φ ψ : V →ₗ[K] W) (h : ∀ i, φ (B i) = ψ (B i)) : φ = ψ := + B.ext h + + + + +variable {ι' : Type*} (B' : Basis ι' K W) [Fintype ι] [Fintype ι'] [DecidableEq ι'] + +open LinearMap + +#check (toMatrix B B' : (V →ₗ[K] W) ≃ₗ[K] Matrix ι' ι K) + +open Matrix -- get access to the ``*ᵥ`` notation for multiplication between matrices and vectors. + +example (φ : V →ₗ[K] W) (v : V) : (toMatrix B B' φ) *ᵥ (B.repr v) = B'.repr (φ v) := + toMatrix_mulVec_repr B B' φ v + + +variable {ι'' : Type*} (B'' : Basis ι'' K W) [Fintype ι''] [DecidableEq ι''] + +example (φ : V →ₗ[K] W) : (toMatrix B B'' φ) = (toMatrix B' B'' .id) * (toMatrix B B' φ) := by + simp + +end + + +open Module LinearMap Matrix + +-- Some lemmas coming from the fact that `LinearMap.toMatrix` is an algebra morphism. +#check toMatrix_comp +#check id_comp +#check comp_id +#check toMatrix_id + +-- Some lemmas coming from the fact that ``Matrix.det`` is a multiplicative monoid morphism. +#check Matrix.det_mul +#check Matrix.det_one + +example [Fintype ι] (B' : Basis ι K V) (φ : End K V) : + (toMatrix B B φ).det = (toMatrix B' B' φ).det := by + set M := toMatrix B B φ + set M' := toMatrix B' B' φ + set P := (toMatrix B B') LinearMap.id + set P' := (toMatrix B' B) LinearMap.id + sorry +end + +section + +#check (Module.finrank K V : ℕ) + +-- `Fin n → K` is the archetypical space with dimension `n` over `K`. +example (n : ℕ) : Module.finrank K (Fin n → K) = n := + Module.finrank_fin_fun K + +-- Seen as a vector space over itself, `ℂ` has dimension one. +example : Module.finrank ℂ ℂ = 1 := + Module.finrank_self ℂ + +-- But as a real vector space it has dimension two. +example : Module.finrank ℝ ℂ = 2 := + Complex.finrank_real_complex + + +example [FiniteDimensional K V] : 0 < Module.finrank K V ↔ Nontrivial V := + Module.finrank_pos_iff + + +example [FiniteDimensional K V] (h : 0 < Module.finrank K V) : Nontrivial V := by + apply (Module.finrank_pos_iff (R := K)).1 + exact h + +variable {ι : Type*} (B : Module.Basis ι K V) + +example [Finite ι] : FiniteDimensional K V := Module.Basis.finiteDimensional_of_finite B + +example [FiniteDimensional K V] : Finite ι := + (FiniteDimensional.fintypeBasisIndex B).finite +end + +section +variable (E F : Submodule K V) [FiniteDimensional K V] + +open Module + +example : finrank K (E ⊔ F : Submodule K V) + finrank K (E ⊓ F : Submodule K V) = + finrank K E + finrank K F := + Submodule.finrank_sup_add_finrank_inf_eq E F + +example : finrank K E ≤ finrank K V := Submodule.finrank_le E +example (h : finrank K V < finrank K E + finrank K F) : + Nontrivial (E ⊓ F : Submodule K V) := by + sorry +end + +#check V -- Type u_2 +#check Module.rank K V -- Cardinal.{u_2} + + +universe u v -- `u` and `v` will denote universe levels + +variable {ι : Type u} (B : Module.Basis ι K V) + {ι' : Type v} (B' : Module.Basis ι' K V) + +example : Cardinal.lift.{v, u} (.mk ι) = Cardinal.lift.{u, v} (.mk ι') := + mk_eq_mk_of_basis B B' + +example [FiniteDimensional K V] : + (Module.finrank K V : Cardinal) = Module.rank K V := + Module.finrank_eq_rank K V diff --git a/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S01_Vector_Spaces.lean b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S01_Vector_Spaces.lean new file mode 100644 index 0000000..fa07fbb --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S01_Vector_Spaces.lean @@ -0,0 +1,7 @@ +module +public import Mathlib.LinearAlgebra.Matrix.Determinant.Basic +public import Mathlib.LinearAlgebra.Eigenspace.Minpoly +public import Mathlib.LinearAlgebra.Charpoly.Basic + +public import MIL.Common + diff --git a/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S02_Subspaces.lean b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S02_Subspaces.lean new file mode 100644 index 0000000..6d2b398 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S02_Subspaces.lean @@ -0,0 +1,129 @@ +module +public import Mathlib.LinearAlgebra.Matrix.Determinant.Basic +public import Mathlib.LinearAlgebra.Eigenspace.Minpoly +public import Mathlib.LinearAlgebra.Charpoly.Basic + +public import MIL.Common + +section +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + +example (U : Submodule K V) {x y : V} (hx : x ∈ U) (hy : y ∈ U) : + x + y ∈ U := + U.add_mem hx hy + +example (U : Submodule K V) {x : V} (hx : x ∈ U) (a : K) : + a • x ∈ U := + U.smul_mem a hx +end + +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + +def preimage {W : Type*} [AddCommGroup W] [Module K W] (φ : V →ₗ[K] W) (H : Submodule K W) : + Submodule K V where + carrier := φ ⁻¹' H + zero_mem' := by + rw [Set.mem_preimage, map_zero] + exact H.zero_mem + add_mem' := by + rintro a b ha hb + rw [Set.mem_preimage, map_add] + apply H.add_mem <;> assumption + smul_mem' := by + rintro a v hv + rw [Set.mem_preimage, map_smul] + exact H.smul_mem a hv + + +example {S T : Submodule K V} {x : V} (h : x ∈ S ⊔ T) : + ∃ s ∈ S, ∃ t ∈ T, x = s + t := by + rw [← S.span_eq, ← T.span_eq, ← Submodule.span_union] at h + induction h using Submodule.span_induction with + | mem x h => + rcases h with (hx|hx) + · use x, hx, 0, T.zero_mem + module + · use 0, S.zero_mem, x, hx + module + | zero => + use 0, S.zero_mem, 0, T.zero_mem + module + | add x y hx hy hx' hy' => + rcases hx' with ⟨s, hs, t, ht, rfl⟩ + rcases hy' with ⟨s', hs', t', ht', rfl⟩ + use s + s', S.add_mem hs hs', t + t', T.add_mem ht ht' + module + | smul a x hx hx' => + rcases hx' with ⟨s, hs, t, ht, rfl⟩ + use a • s, S.smul_mem a hs, a • t, T.smul_mem a ht + module + + +section + +variable {W : Type*} [AddCommGroup W] [Module K W] (φ : V →ₗ[K] W) + +variable (E : Submodule K V) in +#check (Submodule.map φ E : Submodule K W) + +variable (F : Submodule K W) in +#check (Submodule.comap φ F : Submodule K V) + + +open Function LinearMap + +example : Injective φ ↔ ker φ = ⊥ := ker_eq_bot.symm + +example : Surjective φ ↔ range φ = ⊤ := range_eq_top.symm + +#check Submodule.mem_map_of_mem +#check Submodule.mem_map +#check Submodule.mem_comap + +example (E : Submodule K V) (F : Submodule K W) : + Submodule.map φ E ≤ F ↔ E ≤ Submodule.comap φ F := by + constructor + · intro h x hx + exact h ⟨x, hx, rfl⟩ + · rintro h - ⟨x, hx, rfl⟩ + exact h hx + + +variable (E : Submodule K V) + +example : Module K (V ⧸ E) := inferInstance + +example : V →ₗ[K] V ⧸ E := E.mkQ + +example : ker E.mkQ = E := E.ker_mkQ + +example : range E.mkQ = ⊤ := E.range_mkQ + +example (hφ : E ≤ ker φ) : V ⧸ E →ₗ[K] W := E.liftQ φ hφ + +example (F : Submodule K W) (hφ : E ≤ .comap φ F) : V ⧸ E →ₗ[K] W ⧸ F := E.mapQ F φ hφ + +noncomputable example : (V ⧸ LinearMap.ker φ) ≃ₗ[K] range φ := φ.quotKerEquivRange + + +open Submodule + +#check Submodule.map_comap_eq +#check Submodule.comap_map_eq + +example : Submodule K (V ⧸ E) ≃ { F : Submodule K V // E ≤ F } where + toFun F := ⟨comap E.mkQ F, by + conv_lhs => rw [← E.ker_mkQ, ← comap_bot] + gcongr + apply bot_le⟩ + invFun P := map E.mkQ P + left_inv P := by + dsimp + rw [Submodule.map_comap_eq, E.range_mkQ] + exact top_inf_eq P + right_inv := by + intro P + ext x + dsimp only + rw [Submodule.comap_map_eq, E.ker_mkQ, sup_of_le_left] + exact P.2 diff --git a/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S03_Endomorphisms.lean b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S03_Endomorphisms.lean new file mode 100644 index 0000000..6cd39e7 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S03_Endomorphisms.lean @@ -0,0 +1,69 @@ +module +public import Mathlib.LinearAlgebra.Matrix.Determinant.Basic +public import Mathlib.LinearAlgebra.Eigenspace.Minpoly +public import Mathlib.LinearAlgebra.Charpoly.Basic + +public import MIL.Common + +noncomputable section + + + +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + +variable {W : Type*} [AddCommGroup W] [Module K W] + + +open Polynomial Module LinearMap End + +example (φ ψ : End K V) : φ * ψ = φ ∘ₗ ψ := + End.mul_eq_comp φ ψ -- `rfl` would also work + +-- evaluating `P` on `φ` +example (P : K[X]) (φ : End K V) : V →ₗ[K] V := + aeval φ P + +-- evaluating `X` on `φ` gives back `φ` +example (φ : End K V) : aeval φ (X : K[X]) = φ := + aeval_X φ + + + +#check Submodule.eq_bot_iff +#check Submodule.mem_inf +#check LinearMap.mem_ker + +example (P Q : K[X]) (h : IsCoprime P Q) (φ : End K V) : ker (aeval φ P) ⊓ ker (aeval φ Q) = ⊥ := by + rw [Submodule.eq_bot_iff] + rintro x hx + rw [Submodule.mem_inf, mem_ker, mem_ker] at hx + rcases h with ⟨U, V, hUV⟩ + have := congr((aeval φ) $hUV.symm x) + simpa [hx] + +#check Submodule.add_mem_sup +#check map_mul +#check End.mul_apply +#check LinearMap.ker_le_ker_comp + +example (P Q : K[X]) (h : IsCoprime P Q) (φ : End K V) : + ker (aeval φ P) ⊔ ker (aeval φ Q) = ker (aeval φ (P*Q)) := by + apply le_antisymm + · apply sup_le + · rw [mul_comm, map_mul] + apply ker_le_ker_comp -- or alternative below: + -- intro x hx + -- rw [mul_comm, mem_ker] at * + -- simp [hx] + · rw [map_mul] + apply ker_le_ker_comp -- or alternative as above + · intro x hx + rcases h with ⟨U, V, hUV⟩ + have key : x = aeval φ (U*P) x + aeval φ (V*Q) x := by simpa using congr((aeval φ) $hUV.symm x) + rw [key, add_comm] + apply Submodule.add_mem_sup <;> rw [mem_ker] at * + · rw [← mul_apply, ← map_mul, show P*(V*Q) = V*(P*Q) by ring, map_mul, mul_apply, hx, + map_zero] + · rw [← mul_apply, ← map_mul, show Q*(U*P) = U*(P*Q) by ring, map_mul, mul_apply, hx, + map_zero] + diff --git a/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S04_Bases.lean b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S04_Bases.lean new file mode 100644 index 0000000..57855eb --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S04_Bases.lean @@ -0,0 +1,112 @@ +module +public import Mathlib.LinearAlgebra.Matrix.Determinant.Basic +public import Mathlib.LinearAlgebra.Eigenspace.Minpoly +public import Mathlib.LinearAlgebra.Charpoly.Basic +public import Mathlib.LinearAlgebra.Complex.FiniteDimensional + +public import MIL.Common + +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + +section + +open Module + +variable {ι : Type*} (B : Basis ι K V) (v : V) (i : ι) + +-- The basis vector with index ``i`` +#check (B i : V) + +-- the linear isomorphism with the model space given by ``B`` +#check (B.repr : V ≃ₗ[K] ι →₀ K) + +-- the component function of ``v`` +#check (B.repr v : ι →₀ K) + +-- the component of ``v`` with index ``i`` +#check (B.repr v i : K) + +variable [DecidableEq ι] + +section + +variable {W : Type*} [AddCommGroup W] [Module K W] + (φ : V →ₗ[K] W) (u : ι → W) + +#check (B.constr K : (ι → W) ≃ₗ[K] (V →ₗ[K] W)) + +#check (B.constr K u : V →ₗ[K] W) + +example (i : ι) : B.constr K u (B i) = u i := + B.constr_basis K u i + + + +variable {ι' : Type*} (B' : Basis ι' K W) [Fintype ι] [Fintype ι'] [DecidableEq ι'] + +open LinearMap + +#check (toMatrix B B' : (V →ₗ[K] W) ≃ₗ[K] Matrix ι' ι K) + +open Matrix -- get access to the ``*ᵥ`` notation for multiplication between matrices and vectors. + +example (φ : V →ₗ[K] W) (v : V) : (toMatrix B B' φ) *ᵥ (B.repr v) = B'.repr (φ v) := + toMatrix_mulVec_repr B B' φ v + + +variable {ι'' : Type*} (B'' : Basis ι'' K W) [Fintype ι''] [DecidableEq ι''] + +example (φ : V →ₗ[K] W) : (toMatrix B B'' φ) = (toMatrix B' B'' .id) * (toMatrix B B' φ) := by + simp + +end + + +open Module LinearMap Matrix + +-- Some lemmas coming from the fact that `LinearMap.toMatrix` is an algebra morphism. +#check toMatrix_comp +#check id_comp +#check comp_id +#check toMatrix_id + +-- Some lemmas coming from the fact that ``Matrix.det`` is a multiplicative monoid morphism. +#check Matrix.det_mul +#check Matrix.det_one + +example [Fintype ι] (B' : Basis ι K V) (φ : End K V) : + (toMatrix B B φ).det = (toMatrix B' B' φ).det := by + set M := toMatrix B B φ + set M' := toMatrix B' B' φ + set P := (toMatrix B B') LinearMap.id + set P' := (toMatrix B' B) LinearMap.id + have F : M = P' * M' * P := by + rw [← toMatrix_comp, ← toMatrix_comp, id_comp, comp_id] + have F' : P' * P = 1 := by + rw [← toMatrix_comp, id_comp, toMatrix_id] + rw [F, Matrix.det_mul, Matrix.det_mul, + show P'.det * M'.det * P.det = P'.det * P.det * M'.det by ring, ← Matrix.det_mul, F', + Matrix.det_one, one_mul] +end + + +section +variable (E F : Submodule K V) [FiniteDimensional K V] + +open Module + +example : finrank K (E ⊔ F : Submodule K V) + finrank K (E ⊓ F : Submodule K V) = + finrank K E + finrank K F := + Submodule.finrank_sup_add_finrank_inf_eq E F + +example : finrank K E ≤ finrank K V := Submodule.finrank_le E +example (h : finrank K V < finrank K E + finrank K F) : + Nontrivial (E ⊓ F : Submodule K V) := by + rw [← finrank_pos_iff (R := K)] + have := Submodule.finrank_sup_add_finrank_inf_eq E F + have := Submodule.finrank_le E + have := Submodule.finrank_le F + have := Submodule.finrank_le (E ⊔ F) + linarith +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C11_Topology/S01_Filters.lean b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/S01_Filters.lean new file mode 100644 index 0000000..e07e7d6 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/S01_Filters.lean @@ -0,0 +1,106 @@ +module +public import MIL.Common +public import Mathlib.Topology.Instances.Real.Lemmas + +open Set Filter Topology + +def principal {α : Type*} (s : Set α) : Filter α + where + sets := { t | s ⊆ t } + univ_sets := sorry + sets_of_superset := sorry + inter_sets := sorry + +example : Filter ℕ := + { sets := { s | ∃ a, ∀ b, a ≤ b → b ∈ s } + univ_sets := sorry + sets_of_superset := sorry + inter_sets := sorry } + +def Tendsto₁ {X Y : Type*} (f : X → Y) (F : Filter X) (G : Filter Y) := + ∀ V ∈ G, f ⁻¹' V ∈ F + +def Tendsto₂ {X Y : Type*} (f : X → Y) (F : Filter X) (G : Filter Y) := + map f F ≤ G + +example {X Y : Type*} (f : X → Y) (F : Filter X) (G : Filter Y) : + Tendsto₂ f F G ↔ Tendsto₁ f F G := + Iff.rfl + +#check (@Filter.map_mono : ∀ {α β} {m : α → β}, Monotone (map m)) + +#check + (@Filter.map_map : + ∀ {α β γ} {f : Filter α} {m : α → β} {m' : β → γ}, map m' (map m f) = map (m' ∘ m) f) + +example {X Y Z : Type*} {F : Filter X} {G : Filter Y} {H : Filter Z} {f : X → Y} {g : Y → Z} + (hf : Tendsto₁ f F G) (hg : Tendsto₁ g G H) : Tendsto₁ (g ∘ f) F H := + sorry + +variable (f : ℝ → ℝ) (x₀ y₀ : ℝ) + +#check comap ((↑) : ℚ → ℝ) (𝓝 x₀) + +#check Tendsto (f ∘ (↑)) (comap ((↑) : ℚ → ℝ) (𝓝 x₀)) (𝓝 y₀) + +section +variable {α β γ : Type*} (F : Filter α) {m : γ → β} {n : β → α} + +#check (comap_comap : comap m (comap n F) = comap (n ∘ m) F) + +end + +example : 𝓝 (x₀, y₀) = 𝓝 x₀ ×ˢ 𝓝 y₀ := + nhds_prod_eq + +#check le_inf_iff + +example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : + Tendsto f atTop (𝓝 (x₀, y₀)) ↔ + Tendsto (Prod.fst ∘ f) atTop (𝓝 x₀) ∧ Tendsto (Prod.snd ∘ f) atTop (𝓝 y₀) := + sorry + +example (x₀ : ℝ) : HasBasis (𝓝 x₀) (fun ε : ℝ ↦ 0 < ε) fun ε ↦ Ioo (x₀ - ε) (x₀ + ε) := + nhds_basis_Ioo_pos x₀ + +example (u : ℕ → ℝ) (x₀ : ℝ) : + Tendsto u atTop (𝓝 x₀) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, u n ∈ Ioo (x₀ - ε) (x₀ + ε) := by + have : atTop.HasBasis (fun _ : ℕ ↦ True) Ici := atTop_basis + rw [this.tendsto_iff (nhds_basis_Ioo_pos x₀)] + simp + +example (P Q : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n) : + ∀ᶠ n in atTop, P n ∧ Q n := + hP.and hQ + +example (u v : ℕ → ℝ) (h : ∀ᶠ n in atTop, u n = v n) (x₀ : ℝ) : + Tendsto u atTop (𝓝 x₀) ↔ Tendsto v atTop (𝓝 x₀) := + tendsto_congr' h + +example (u v : ℕ → ℝ) (h : u =ᶠ[atTop] v) (x₀ : ℝ) : + Tendsto u atTop (𝓝 x₀) ↔ Tendsto v atTop (𝓝 x₀) := + tendsto_congr' h + +#check Eventually.of_forall +#check Eventually.mono +#check Eventually.and + +example (P Q R : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n) + (hR : ∀ᶠ n in atTop, P n ∧ Q n → R n) : ∀ᶠ n in atTop, R n := by + apply (hP.and (hQ.and hR)).mono + rintro n ⟨h, h', h''⟩ + exact h'' ⟨h, h'⟩ + +example (P Q R : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n) + (hR : ∀ᶠ n in atTop, P n ∧ Q n → R n) : ∀ᶠ n in atTop, R n := by + filter_upwards [hP, hQ, hR] with n h h' h'' + exact h'' ⟨h, h'⟩ + +#check mem_closure_iff_clusterPt +#check le_principal_iff +#check neBot_of_le + +example (u : ℕ → ℝ) (M : Set ℝ) (x : ℝ) (hux : Tendsto u atTop (𝓝 x)) + (huM : ∀ᶠ n in atTop, u n ∈ M) : x ∈ closure M := + sorry + diff --git a/dev/vendor/mathematics_in_lean/MIL/C11_Topology/S02_Metric_Spaces.lean b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/S02_Metric_Spaces.lean new file mode 100644 index 0000000..5f6c465 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/S02_Metric_Spaces.lean @@ -0,0 +1,205 @@ +module +public import MIL.Common +public import Mathlib.Topology.Instances.Real.Lemmas +public import Mathlib.Analysis.Normed.Operator.BanachSteinhaus + +open Set Filter +open Topology Filter + +variable {X : Type*} [MetricSpace X] (a b c : X) + +#check (dist a b : ℝ) +#check (dist_nonneg : 0 ≤ dist a b) +#check (dist_eq_zero : dist a b = 0 ↔ a = b) +#check (dist_comm a b : dist a b = dist b a) +#check (dist_triangle a b c : dist a c ≤ dist a b + dist b c) + +-- Note the next three lines are not quoted, their purpose is to make sure those things don't get renamed while we're looking elsewhere. +#check EMetricSpace +#check PseudoMetricSpace +#check PseudoEMetricSpace + +example {u : ℕ → X} {a : X} : + Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) a < ε := + Metric.tendsto_atTop + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} : + Continuous f ↔ + ∀ x : X, ∀ ε > 0, ∃ δ > 0, ∀ x', dist x' x < δ → dist (f x') (f x) < ε := + Metric.continuous_iff + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : + Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := by continuity + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : + Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := + continuous_dist.comp ((hf.comp continuous_fst).prodMk (hf.comp continuous_snd)) + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : + Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := by + apply Continuous.dist + exact hf.comp continuous_fst + exact hf.comp continuous_snd + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : + Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := + (hf.comp continuous_fst).dist (hf.comp continuous_snd) + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : + Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := + hf.fst'.dist hf.snd' + +example {f : ℝ → X} (hf : Continuous f) : Continuous fun x : ℝ ↦ f (x ^ 2 + x) := + sorry +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] (f : X → Y) (a : X) : + ContinuousAt f a ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x}, dist x a < δ → dist (f x) (f a) < ε := + Metric.continuousAt_iff + +variable (r : ℝ) + +example : Metric.ball a r = { b | dist b a < r } := + rfl + +example : Metric.closedBall a r = { b | dist b a ≤ r } := + rfl + +example (hr : 0 < r) : a ∈ Metric.ball a r := + Metric.mem_ball_self hr + +example (hr : 0 ≤ r) : a ∈ Metric.closedBall a r := + Metric.mem_closedBall_self hr + +example (s : Set X) : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, Metric.ball x ε ⊆ s := + Metric.isOpen_iff + +example {s : Set X} : IsClosed s ↔ IsOpen (sᶜ) := + isOpen_compl_iff.symm + +example {s : Set X} (hs : IsClosed s) {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) + (hus : ∀ n, u n ∈ s) : a ∈ s := + hs.mem_of_tendsto hu (Eventually.of_forall hus) + +example {s : Set X} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, a ∈ Metric.ball b ε := + Metric.mem_closure_iff + +example {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) {s : Set X} (hs : ∀ n, u n ∈ s) : + a ∈ closure s := by + sorry +example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.ball x ε ⊆ s := + Metric.nhds_basis_ball.mem_iff + +example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.closedBall x ε ⊆ s := + Metric.nhds_basis_closedBall.mem_iff + +example : IsCompact (Set.Icc 0 1 : Set ℝ) := + isCompact_Icc + +example {s : Set X} (hs : IsCompact s) {u : ℕ → X} (hu : ∀ n, u n ∈ s) : + ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := + hs.tendsto_subseq hu + +example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} + (hfs : ContinuousOn f s) : + ∃ x ∈ s, ∀ y ∈ s, f x ≤ f y := + hs.exists_isMinOn hs' hfs + +example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} + (hfs : ContinuousOn f s) : + ∃ x ∈ s, ∀ y ∈ s, f y ≤ f x := + hs.exists_isMaxOn hs' hfs + +example {s : Set X} (hs : IsCompact s) : IsClosed s := + hs.isClosed + +example {X : Type*} [MetricSpace X] [CompactSpace X] : IsCompact (univ : Set X) := + isCompact_univ + +#check IsCompact.isClosed + +example {X : Type*} [MetricSpace X] {Y : Type*} [MetricSpace Y] {f : X → Y} : + UniformContinuous f ↔ + ∀ ε > 0, ∃ δ > 0, ∀ {a b : X}, dist a b < δ → dist (f a) (f b) < ε := + Metric.uniformContinuous_iff + +example {X : Type*} [MetricSpace X] [CompactSpace X] + {Y : Type*} [MetricSpace Y] {f : X → Y} + (hf : Continuous f) : UniformContinuous f := by + sorry +example (u : ℕ → X) : + CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ m ≥ N, ∀ n ≥ N, dist (u m) (u n) < ε := + Metric.cauchySeq_iff + +example (u : ℕ → X) : + CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, dist (u n) (u N) < ε := + Metric.cauchySeq_iff' + +example [CompleteSpace X] (u : ℕ → X) (hu : CauchySeq u) : + ∃ x, Tendsto u atTop (𝓝 x) := + cauchySeq_tendsto_of_complete hu + +open BigOperators + +open Finset + +theorem cauchySeq_of_le_geometric_two' {u : ℕ → X} + (hu : ∀ n : ℕ, dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : CauchySeq u := by + rw [Metric.cauchySeq_iff'] + intro ε ε_pos + obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε := by sorry + use N + intro n hn + obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn + calc + dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := sorry + _ ≤ ∑ i ∈ range k, dist (u (N + i)) (u (N + (i + 1))) := sorry + _ ≤ ∑ i ∈ range k, (1 / 2 : ℝ) ^ (N + i) := sorry + _ = 1 / 2 ^ N * ∑ i ∈ range k, (1 / 2 : ℝ) ^ i := sorry + _ ≤ 1 / 2 ^ N * 2 := sorry + _ < ε := sorry + + +open Metric + +example [CompleteSpace X] (f : ℕ → Set X) (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) : + Dense (⋂ n, f n) := by + let B : ℕ → ℝ := fun n ↦ (1 / 2) ^ n + have Bpos : ∀ n, 0 < B n + sorry + /- Translate the density assumption into two functions `center` and `radius` associating + to any n, x, δ, δpos a center and a positive radius such that + `closedBall center radius` is included both in `f n` and in `closedBall x δ`. + We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ + have : + ∀ (n : ℕ) (x : X), + ∀ δ > 0, ∃ y : X, ∃ r > 0, r ≤ B (n + 1) ∧ closedBall y r ⊆ closedBall x δ ∩ f n := + by sorry + choose! center radius Hpos HB Hball using this + intro x + rw [mem_closure_iff_nhds_basis nhds_basis_closedBall] + intro ε εpos + /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` + belonging to all `f n`. For this, we construct inductively a sequence + `F n = (c n, r n)` such that the closed ball `closedBall (c n) (r n)` is included + in the previous ball and in `f n`, and such that `r n` is small enough to ensure + that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs + to all the `f n`. -/ + let F : ℕ → X × ℝ := fun n ↦ + Nat.recOn n (Prod.mk x (min ε (B 0))) + fun n p ↦ Prod.mk (center n p.1 p.2) (radius n p.1 p.2) + let c : ℕ → X := fun n ↦ (F n).1 + let r : ℕ → ℝ := fun n ↦ (F n).2 + have rpos : ∀ n, 0 < r n := by sorry + have rB : ∀ n, r n ≤ B n := by sorry + have incl : ∀ n, closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) ∩ f n := by + sorry + have cdist : ∀ n, dist (c n) (c (n + 1)) ≤ B n := by sorry + have : CauchySeq c := cauchySeq_of_le_geometric_two' cdist + -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. + rcases cauchySeq_tendsto_of_complete this with ⟨y, ylim⟩ + -- this point `y` will be the desired point. We will check that it belongs to all + -- `f n` and to `ball x ε`. + use y + have I : ∀ n, ∀ m ≥ n, closedBall (c m) (r m) ⊆ closedBall (c n) (r n) := by sorry + have yball : ∀ n, y ∈ closedBall (c n) (r n) := by sorry + sorry + diff --git a/dev/vendor/mathematics_in_lean/MIL/C11_Topology/S03_Topological_Spaces.lean b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/S03_Topological_Spaces.lean new file mode 100644 index 0000000..eeccc80 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/S03_Topological_Spaces.lean @@ -0,0 +1,152 @@ +module +public import MIL.Common +public import Mathlib.Topology.Instances.Real.Lemmas +public import Mathlib.Analysis.Normed.Operator.BanachSteinhaus + +open Set Filter Topology + +section +variable {X : Type*} [TopologicalSpace X] + +example : IsOpen (univ : Set X) := + isOpen_univ + +example : IsOpen (∅ : Set X) := + isOpen_empty + +example {ι : Type*} {s : ι → Set X} (hs : ∀ i, IsOpen (s i)) : IsOpen (⋃ i, s i) := + isOpen_iUnion hs + +example {ι : Type*} [Fintype ι] {s : ι → Set X} (hs : ∀ i, IsOpen (s i)) : + IsOpen (⋂ i, s i) := + isOpen_iInter_of_finite hs + +variable {Y : Type*} [TopologicalSpace Y] + +example {f : X → Y} : Continuous f ↔ ∀ s, IsOpen s → IsOpen (f ⁻¹' s) := + continuous_def + +example {f : X → Y} {x : X} : ContinuousAt f x ↔ map f (𝓝 x) ≤ 𝓝 (f x) := + Iff.rfl + +example {f : X → Y} {x : X} : ContinuousAt f x ↔ ∀ U ∈ 𝓝 (f x), ∀ᶠ x in 𝓝 x, f x ∈ U := + Iff.rfl + +example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t := + mem_nhds_iff + +example (x : X) : pure x ≤ 𝓝 x := + pure_le_nhds x + +example (x : X) (P : X → Prop) (h : ∀ᶠ y in 𝓝 x, P y) : P x := + h.self_of_nhds + +example {P : X → Prop} {x : X} (h : ∀ᶠ y in 𝓝 x, P y) : ∀ᶠ y in 𝓝 x, ∀ᶠ z in 𝓝 y, P z := + eventually_eventually_nhds.mpr h + +#check TopologicalSpace.mkOfNhds + +#check TopologicalSpace.nhds_mkOfNhds + +example {α : Type*} (n : α → Filter α) (H₀ : ∀ a, pure a ≤ n a) + (H : ∀ a : α, ∀ p : α → Prop, (∀ᶠ x in n a, p x) → ∀ᶠ y in n a, ∀ᶠ x in n y, p x) : + ∀ a, ∀ s ∈ n a, ∃ t ∈ n a, t ⊆ s ∧ ∀ a' ∈ t, s ∈ n a' := by + sorry +end + +variable {X Y : Type*} + +example (f : X → Y) : TopologicalSpace X → TopologicalSpace Y := + TopologicalSpace.coinduced f + +example (f : X → Y) : TopologicalSpace Y → TopologicalSpace X := + TopologicalSpace.induced f + +example (f : X → Y) (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) : + TopologicalSpace.coinduced f T_X ≤ T_Y ↔ T_X ≤ TopologicalSpace.induced f T_Y := + coinduced_le_iff_le_induced + +#check coinduced_compose + +#check induced_compose + +example {T T' : TopologicalSpace X} : T ≤ T' ↔ ∀ s, T'.IsOpen s → T.IsOpen s := + Iff.rfl + +example (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) (f : X → Y) : + Continuous f ↔ TopologicalSpace.coinduced f T_X ≤ T_Y := + continuous_iff_coinduced_le + +example {Z : Type*} (f : X → Y) (T_X : TopologicalSpace X) (T_Z : TopologicalSpace Z) + (g : Y → Z) : + @Continuous Y Z (TopologicalSpace.coinduced f T_X) T_Z g ↔ + @Continuous X Z T_X T_Z (g ∘ f) := by + rw [continuous_iff_coinduced_le, coinduced_compose, continuous_iff_coinduced_le] + +example (ι : Type*) (X : ι → Type*) (T_X : ∀ i, TopologicalSpace (X i)) : + (Pi.topologicalSpace : TopologicalSpace (∀ i, X i)) = + ⨅ i, TopologicalSpace.induced (fun x ↦ x i) (T_X i) := + rfl + +example [TopologicalSpace X] [T2Space X] {u : ℕ → X} {a b : X} (ha : Tendsto u atTop (𝓝 a)) + (hb : Tendsto u atTop (𝓝 b)) : a = b := + tendsto_nhds_unique ha hb + +example [TopologicalSpace X] [RegularSpace X] (a : X) : + (𝓝 a).HasBasis (fun s : Set X ↦ s ∈ 𝓝 a ∧ IsClosed s) id := + closed_nhds_basis a + +example [TopologicalSpace X] {x : X} : + (𝓝 x).HasBasis (fun t : Set X ↦ t ∈ 𝓝 x ∧ IsOpen t) id := + nhds_basis_opens' x + +theorem aux {X Y A : Type*} [TopologicalSpace X] {c : A → X} + {f : A → Y} {x : X} {F : Filter Y} + (h : Tendsto f (comap c (𝓝 x)) F) {V' : Set Y} (V'_in : V' ∈ F) : + ∃ V ∈ 𝓝 x, IsOpen V ∧ c ⁻¹' V ⊆ f ⁻¹' V' := by + sorry + +example [TopologicalSpace X] [TopologicalSpace Y] [T3Space Y] {A : Set X} + (hA : ∀ x, x ∈ closure A) {f : A → Y} (f_cont : Continuous f) + (hf : ∀ x : X, ∃ c : Y, Tendsto f (comap (↑) (𝓝 x)) (𝓝 c)) : + ∃ φ : X → Y, Continuous φ ∧ ∀ a : A, φ a = f a := by + sorry + +#check HasBasis.tendsto_right_iff + +example [TopologicalSpace X] [FirstCountableTopology X] + {s : Set X} {a : X} : + a ∈ closure s ↔ ∃ u : ℕ → X, (∀ n, u n ∈ s) ∧ Tendsto u atTop (𝓝 a) := + mem_closure_iff_seq_limit + +variable [TopologicalSpace X] + +example {F : Filter X} {x : X} : ClusterPt x F ↔ NeBot (𝓝 x ⊓ F) := + Iff.rfl + +example {s : Set X} : + IsCompact s ↔ ∀ (F : Filter X) [NeBot F], F ≤ 𝓟 s → ∃ a ∈ s, ClusterPt a F := + Iff.rfl + +example [FirstCountableTopology X] {s : Set X} {u : ℕ → X} (hs : IsCompact s) + (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := + hs.tendsto_subseq hu + +variable [TopologicalSpace Y] + +example {x : X} {F : Filter X} {G : Filter Y} (H : ClusterPt x F) {f : X → Y} + (hfx : ContinuousAt f x) (hf : Tendsto f F G) : ClusterPt (f x) G := + ClusterPt.map H hfx hf + +example {f : X → Y} (hf : Continuous f) {s : Set X} (hs : IsCompact s) : + IsCompact (f '' s) := by + intro F F_ne F_le + have map_eq : map f (𝓟 s ⊓ comap f F) = 𝓟 (f '' s) ⊓ F := by + sorry + have Hne : (𝓟 s ⊓ comap f F).NeBot := by + sorry + have Hle : 𝓟 s ⊓ comap f F ≤ 𝓟 s := inf_le_left + sorry +example {ι : Type*} {s : Set X} (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) + (hsU : s ⊆ ⋃ i, U i) : ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := + hs.elim_finite_subcover U hUo hsU diff --git a/dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S01_Filters.lean b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S01_Filters.lean new file mode 100644 index 0000000..cfdd518 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S01_Filters.lean @@ -0,0 +1,73 @@ +module +public import MIL.Common +public import Mathlib.Topology.Instances.Real.Lemmas + +open Set Filter Topology + +-- In the next example we could use `tauto` in each proof instead of knowing the lemmas +example {α : Type*} (s : Set α) : Filter α := + { sets := { t | s ⊆ t } + univ_sets := subset_univ s + sets_of_superset := fun hU hUV ↦ Subset.trans hU hUV + inter_sets := fun hU hV ↦ subset_inter hU hV } + +example : Filter ℕ := + { sets := { s | ∃ a, ∀ b, a ≤ b → b ∈ s } + univ_sets := by + use 42 + simp + sets_of_superset := by + rintro U V ⟨N, hN⟩ hUV + use N + tauto + inter_sets := by + rintro U V ⟨N, hN⟩ ⟨N', hN'⟩ + use max N N' + intro b hb + rw [max_le_iff] at hb + constructor <;> tauto } + +def Tendsto₁ {X Y : Type*} (f : X → Y) (F : Filter X) (G : Filter Y) := + ∀ V ∈ G, f ⁻¹' V ∈ F + +example {X Y Z : Type*} {F : Filter X} {G : Filter Y} {H : Filter Z} {f : X → Y} {g : Y → Z} + (hf : Tendsto₁ f F G) (hg : Tendsto₁ g G H) : Tendsto₁ (g ∘ f) F H := + calc + map (g ∘ f) F = map g (map f F) := by rw [map_map] + _ ≤ map g G := (map_mono hf) + _ ≤ H := hg + + +example {X Y Z : Type*} {F : Filter X} {G : Filter Y} {H : Filter Z} {f : X → Y} {g : Y → Z} + (hf : Tendsto₁ f F G) (hg : Tendsto₁ g G H) : Tendsto₁ (g ∘ f) F H := by + intro V hV + rw [preimage_comp] + apply hf + apply hg + exact hV + +example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : + Tendsto f atTop (𝓝 (x₀, y₀)) ↔ + Tendsto (Prod.fst ∘ f) atTop (𝓝 x₀) ∧ Tendsto (Prod.snd ∘ f) atTop (𝓝 y₀) := + calc + Tendsto f atTop (𝓝 (x₀, y₀)) ↔ map f atTop ≤ 𝓝 (x₀, y₀) := Iff.rfl + _ ↔ map f atTop ≤ 𝓝 x₀ ×ˢ 𝓝 y₀ := by rw [nhds_prod_eq] + _ ↔ map f atTop ≤ comap Prod.fst (𝓝 x₀) ⊓ comap Prod.snd (𝓝 y₀) := Iff.rfl + _ ↔ map f atTop ≤ comap Prod.fst (𝓝 x₀) ∧ map f atTop ≤ comap Prod.snd (𝓝 y₀) := le_inf_iff + _ ↔ map Prod.fst (map f atTop) ≤ 𝓝 x₀ ∧ map Prod.snd (map f atTop) ≤ 𝓝 y₀ := by + rw [← map_le_iff_le_comap, ← map_le_iff_le_comap] + _ ↔ map (Prod.fst ∘ f) atTop ≤ 𝓝 x₀ ∧ map (Prod.snd ∘ f) atTop ≤ 𝓝 y₀ := by + rw [map_map, map_map] + + +-- an alternative solution +example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : + Tendsto f atTop (𝓝 (x₀, y₀)) ↔ + Tendsto (Prod.fst ∘ f) atTop (𝓝 x₀) ∧ Tendsto (Prod.snd ∘ f) atTop (𝓝 y₀) := by + rw [nhds_prod_eq] + unfold Tendsto SProd.sprod Filter.instSProd + rw [le_inf_iff, ← map_le_iff_le_comap, map_map, ← map_le_iff_le_comap, map_map] + +example (u : ℕ → ℝ) (M : Set ℝ) (x : ℝ) (hux : Tendsto u atTop (𝓝 x)) + (huM : ∀ᶠ n in atTop, u n ∈ M) : x ∈ closure M := + mem_closure_iff_clusterPt.mpr (neBot_of_le <| le_inf hux <| le_principal_iff.mpr huM) diff --git a/dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S02_Metric_Spaces.lean b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S02_Metric_Spaces.lean new file mode 100644 index 0000000..0837a99 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S02_Metric_Spaces.lean @@ -0,0 +1,305 @@ +module +public import MIL.Common +public import Mathlib.Topology.Instances.Real.Lemmas +public import Mathlib.Analysis.Normed.Operator.BanachSteinhaus + +open Set Filter +open Topology Filter + +variable {X : Type*} [MetricSpace X] (a b c : X) + +#check (dist a b : ℝ) +#check (dist_nonneg : 0 ≤ dist a b) +#check (dist_eq_zero : dist a b = 0 ↔ a = b) +#check (dist_comm a b : dist a b = dist b a) +#check (dist_triangle a b c : dist a c ≤ dist a b + dist b c) + +-- Note the next three lines are not quoted, their purpose is to make sure those things don't get renamed while we're looking elsewhere. +#check EMetricSpace +#check PseudoMetricSpace +#check PseudoEMetricSpace + +example {u : ℕ → X} {a : X} : + Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) a < ε := + Metric.tendsto_atTop + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} : + Continuous f ↔ + ∀ x : X, ∀ ε > 0, ∃ δ > 0, ∀ x', dist x' x < δ → dist (f x') (f x) < ε := + Metric.continuous_iff + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : + Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := by continuity + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : + Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := + continuous_dist.comp ((hf.comp continuous_fst).prodMk (hf.comp continuous_snd)) + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : + Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := by + apply Continuous.dist + exact hf.comp continuous_fst + exact hf.comp continuous_snd + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : + Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := + (hf.comp continuous_fst).dist (hf.comp continuous_snd) + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : + Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := + hf.fst'.dist hf.snd' + +example {f : ℝ → X} (hf : Continuous f) : Continuous fun x : ℝ ↦ f (x ^ 2 + x) := + hf.comp <| (continuous_pow 2).add continuous_id + + +example {X Y : Type*} [MetricSpace X] [MetricSpace Y] (f : X → Y) (a : X) : + ContinuousAt f a ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x}, dist x a < δ → dist (f x) (f a) < ε := + Metric.continuousAt_iff + +variable (r : ℝ) + +example : Metric.ball a r = { b | dist b a < r } := + rfl + +example : Metric.closedBall a r = { b | dist b a ≤ r } := + rfl + +example (hr : 0 < r) : a ∈ Metric.ball a r := + Metric.mem_ball_self hr + +example (hr : 0 ≤ r) : a ∈ Metric.closedBall a r := + Metric.mem_closedBall_self hr + +example (s : Set X) : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, Metric.ball x ε ⊆ s := + Metric.isOpen_iff + +example {s : Set X} : IsClosed s ↔ IsOpen (sᶜ) := + isOpen_compl_iff.symm + +example {s : Set X} (hs : IsClosed s) {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) + (hus : ∀ n, u n ∈ s) : a ∈ s := + hs.mem_of_tendsto hu (Eventually.of_forall hus) + +example {s : Set X} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, a ∈ Metric.ball b ε := + Metric.mem_closure_iff + +example {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) {s : Set X} (hs : ∀ n, u n ∈ s) : + a ∈ closure s := by + rw [Metric.tendsto_atTop] at hu + rw [Metric.mem_closure_iff] + intro ε ε_pos + rcases hu ε ε_pos with ⟨N, hN⟩ + refine ⟨u N, hs _, ?_⟩ + rw [dist_comm] + exact hN N le_rfl + + +example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.ball x ε ⊆ s := + Metric.nhds_basis_ball.mem_iff + +example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.closedBall x ε ⊆ s := + Metric.nhds_basis_closedBall.mem_iff + +example : IsCompact (Set.Icc 0 1 : Set ℝ) := + isCompact_Icc + +example {s : Set X} (hs : IsCompact s) {u : ℕ → X} (hu : ∀ n, u n ∈ s) : + ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := + hs.tendsto_subseq hu + +example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} + (hfs : ContinuousOn f s) : + ∃ x ∈ s, ∀ y ∈ s, f x ≤ f y := + hs.exists_isMinOn hs' hfs + +example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} + (hfs : ContinuousOn f s) : + ∃ x ∈ s, ∀ y ∈ s, f y ≤ f x := + hs.exists_isMaxOn hs' hfs + +example {s : Set X} (hs : IsCompact s) : IsClosed s := + hs.isClosed + +example {X : Type*} [MetricSpace X] [CompactSpace X] : IsCompact (univ : Set X) := + isCompact_univ + +#check IsCompact.isClosed + +example {X : Type*} [MetricSpace X] {Y : Type*} [MetricSpace Y] {f : X → Y} : + UniformContinuous f ↔ + ∀ ε > 0, ∃ δ > 0, ∀ {a b : X}, dist a b < δ → dist (f a) (f b) < ε := + Metric.uniformContinuous_iff + +example {X : Type*} [MetricSpace X] [CompactSpace X] + {Y : Type*} [MetricSpace Y] {f : X → Y} + (hf : Continuous f) : UniformContinuous f := by + rw [Metric.uniformContinuous_iff] + intro ε ε_pos + let φ : X × X → ℝ := fun p ↦ dist (f p.1) (f p.2) + have φ_cont : Continuous φ := hf.fst'.dist hf.snd' + let K := { p : X × X | ε ≤ φ p } + have K_closed : IsClosed K := isClosed_le continuous_const φ_cont + have K_cpct : IsCompact K := K_closed.isCompact + rcases eq_empty_or_nonempty K with hK | hK + · use 1, by norm_num + intro x y _ + have : (x, y) ∉ K := by simp [hK] + simpa [K] using this + · rcases K_cpct.exists_isMinOn hK continuous_dist.continuousOn with ⟨⟨x₀, x₁⟩, xx_in, H⟩ + use dist x₀ x₁ + constructor + · change _ < _ + rw [dist_pos] + intro h + have : ε ≤ 0 := by simpa [K, φ, *] using xx_in + linarith + · intro x x' + contrapose! + intro (hxx' : (x, x') ∈ K) + exact H hxx' + + +example (u : ℕ → X) : + CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ m ≥ N, ∀ n ≥ N, dist (u m) (u n) < ε := + Metric.cauchySeq_iff + +example (u : ℕ → X) : + CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, dist (u n) (u N) < ε := + Metric.cauchySeq_iff' + +example [CompleteSpace X] (u : ℕ → X) (hu : CauchySeq u) : + ∃ x, Tendsto u atTop (𝓝 x) := + cauchySeq_tendsto_of_complete hu + +open BigOperators + +open Finset + +theorem cauchySeq_of_le_geometric_two' {u : ℕ → X} + (hu : ∀ n : ℕ, dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : CauchySeq u := by + rw [Metric.cauchySeq_iff'] + intro ε ε_pos + obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε := by + have : Tendsto (fun N : ℕ ↦ (1 / 2 ^ N * 2 : ℝ)) atTop (𝓝 0) := by + rw [← zero_mul (2 : ℝ)] + apply Tendsto.mul + simp_rw [← one_div_pow (2 : ℝ)] + apply tendsto_pow_atTop_nhds_zero_of_lt_one <;> linarith + exact tendsto_const_nhds + rcases(atTop_basis.tendsto_iff (nhds_basis_Ioo_pos (0 : ℝ))).mp this ε ε_pos with ⟨N, _, hN⟩ + exact ⟨N, by simpa using (hN N self_mem_Ici).2⟩ + use N + intro n hn + obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn + calc + dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := by rw [dist_comm, add_zero] + _ ≤ ∑ i ∈ range k, dist (u (N + i)) (u (N + (i + 1))) := + (dist_le_range_sum_dist (fun i ↦ u (N + i)) k) + _ ≤ ∑ i ∈ range k, (1 / 2 : ℝ) ^ (N + i) := (sum_le_sum fun i _ ↦ hu <| N + i) + _ = 1 / 2 ^ N * ∑ i ∈ range k, (1 / 2 : ℝ) ^ i := by simp_rw [← one_div_pow, pow_add, ← mul_sum] + _ ≤ 1 / 2 ^ N * 2 := + (mul_le_mul_of_nonneg_left (sum_geometric_two_le _) + (one_div_nonneg.mpr (pow_nonneg (zero_le_two : (0 : ℝ) ≤ 2) _))) + _ < ε := hN + + +open Metric + +example [CompleteSpace X] (f : ℕ → Set X) (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) : + Dense (⋂ n, f n) := by + let B : ℕ → ℝ := fun n ↦ (1 / 2) ^ n + have Bpos : ∀ n, 0 < B n := fun n ↦ pow_pos (by linarith) n + /- Translate the density assumption into two functions `center` and `radius` associating + to any n, x, δ, δpos a center and a positive radius such that + `closedBall center radius` is included both in `f n` and in `closedBall x δ`. + We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ + have : + ∀ (n : ℕ) (x : X), + ∀ δ > 0, ∃ y : X, ∃ r > 0, r ≤ B (n + 1) ∧ closedBall y r ⊆ closedBall x δ ∩ f n := by + intro n x δ δpos + have : x ∈ closure (f n) := hd n x + rcases Metric.mem_closure_iff.1 this (δ / 2) (half_pos δpos) with ⟨y, ys, xy⟩ + rw [dist_comm] at xy + obtain ⟨r, rpos, hr⟩ : ∃ r > 0, closedBall y r ⊆ f n := + nhds_basis_closedBall.mem_iff.1 (isOpen_iff_mem_nhds.1 (ho n) y ys) + refine ⟨y, min (min (δ / 2) r) (B (n + 1)), ?_, ?_, fun z hz ↦ ⟨?_, ?_⟩⟩ + show 0 < min (min (δ / 2) r) (B (n + 1)) + exact lt_min (lt_min (half_pos δpos) rpos) (Bpos (n + 1)) + show min (min (δ / 2) r) (B (n + 1)) ≤ B (n + 1) + exact min_le_right _ _ + show z ∈ closedBall x δ + exact + calc + dist z x ≤ dist z y + dist y x := dist_triangle _ _ _ + _ ≤ min (min (δ / 2) r) (B (n + 1)) + δ / 2 := (add_le_add hz xy.le) + _ ≤ δ / 2 + δ / 2 := (add_le_add_left ((min_le_left _ _).trans (min_le_left _ _)) _) + _ = δ := add_halves δ + + show z ∈ f n + exact + hr + (calc + dist z y ≤ min (min (δ / 2) r) (B (n + 1)) := hz + _ ≤ r := (min_le_left _ _).trans (min_le_right _ _) + ) + choose! center radius Hpos HB Hball using this + refine fun x ↦ (mem_closure_iff_nhds_basis nhds_basis_closedBall).2 fun ε εpos ↦ ?_ + /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` belonging to all + `f n`. For this, we construct inductively a sequence `F n = (c n, r n)` such that the closed ball + `closedBall (c n) (r n)` is included in the previous ball and in `f n`, and such that + `r n` is small enough to ensure that `c n` is a Cauchy sequence. Then `c n` converges to a + limit which belongs to all the `f n`. -/ + let F : ℕ → X × ℝ := fun n ↦ + Nat.recOn n (Prod.mk x (min ε (B 0))) fun n p ↦ Prod.mk (center n p.1 p.2) (radius n p.1 p.2) + let c : ℕ → X := fun n ↦ (F n).1 + let r : ℕ → ℝ := fun n ↦ (F n).2 + have rpos : ∀ n, 0 < r n := by + intro n + induction' n with n hn + exact lt_min εpos (Bpos 0) + exact Hpos n (c n) (r n) hn + have rB : ∀ n, r n ≤ B n := by + intro n + induction' n with n hn + exact min_le_right _ _ + exact HB n (c n) (r n) (rpos n) + have incl : ∀ n, closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) ∩ f n := fun n ↦ + Hball n (c n) (r n) (rpos n) + have cdist : ∀ n, dist (c n) (c (n + 1)) ≤ B n := by + intro n + rw [dist_comm] + have A : c (n + 1) ∈ closedBall (c (n + 1)) (r (n + 1)) := + mem_closedBall_self (rpos <| n + 1).le + have I := + calc + closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) := + (incl n).trans Set.inter_subset_left + _ ⊆ closedBall (c n) (B n) := closedBall_subset_closedBall (rB n) + + exact I A + have : CauchySeq c := cauchySeq_of_le_geometric_two' cdist + -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. + rcases cauchySeq_tendsto_of_complete this with ⟨y, ylim⟩ + -- this point `y` will be the desired point. We will check that it belongs to all + -- `f n` and to `ball x ε`. + use y + have I : ∀ n, ∀ m ≥ n, closedBall (c m) (r m) ⊆ closedBall (c n) (r n) := by + intro n + refine Nat.le_induction ?_ fun m hnm h ↦ ?_ + · exact Subset.rfl + · exact (incl m).trans (Set.inter_subset_left.trans h) + have yball : ∀ n, y ∈ closedBall (c n) (r n) := by + intro n + refine isClosed_closedBall.mem_of_tendsto ylim ?_ + refine (Filter.eventually_ge_atTop n).mono fun m hm ↦ ?_ + exact I n m hm (mem_closedBall_self (rpos _).le) + constructor + · suffices ∀ n, y ∈ f n by rwa [Set.mem_iInter] + intro n + have : closedBall (c (n + 1)) (r (n + 1)) ⊆ f n := + Subset.trans (incl n) Set.inter_subset_right + exact this (yball (n + 1)) + calc + dist y x ≤ r 0 := yball 0 + _ ≤ ε := min_le_left _ _ diff --git a/dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S03_Topological_Spaces.lean b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S03_Topological_Spaces.lean new file mode 100644 index 0000000..c3469d4 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S03_Topological_Spaces.lean @@ -0,0 +1,180 @@ +module +public import MIL.Common +public import Mathlib.Topology.Instances.Real.Lemmas +public import Mathlib.Analysis.Normed.Operator.BanachSteinhaus + +open Set Filter Topology + +section +variable {X : Type*} [TopologicalSpace X] + +example : IsOpen (univ : Set X) := + isOpen_univ + +example : IsOpen (∅ : Set X) := + isOpen_empty + +example {ι : Type*} {s : ι → Set X} (hs : ∀ i, IsOpen (s i)) : IsOpen (⋃ i, s i) := + isOpen_iUnion hs + +example {ι : Type*} [Fintype ι] {s : ι → Set X} (hs : ∀ i, IsOpen (s i)) : + IsOpen (⋂ i, s i) := + isOpen_iInter_of_finite hs + +variable {Y : Type*} [TopologicalSpace Y] + +example {f : X → Y} : Continuous f ↔ ∀ s, IsOpen s → IsOpen (f ⁻¹' s) := + continuous_def + +example {f : X → Y} {x : X} : ContinuousAt f x ↔ map f (𝓝 x) ≤ 𝓝 (f x) := + Iff.rfl + +example {f : X → Y} {x : X} : ContinuousAt f x ↔ ∀ U ∈ 𝓝 (f x), ∀ᶠ x in 𝓝 x, f x ∈ U := + Iff.rfl + +example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t := + mem_nhds_iff + +example (x : X) : pure x ≤ 𝓝 x := + pure_le_nhds x + +example (x : X) (P : X → Prop) (h : ∀ᶠ y in 𝓝 x, P y) : P x := + h.self_of_nhds + +example {P : X → Prop} {x : X} (h : ∀ᶠ y in 𝓝 x, P y) : ∀ᶠ y in 𝓝 x, ∀ᶠ z in 𝓝 y, P z := + eventually_eventually_nhds.mpr h + +#check TopologicalSpace.mkOfNhds + +#check TopologicalSpace.nhds_mkOfNhds + +example {α : Type*} (n : α → Filter α) (H₀ : ∀ a, pure a ≤ n a) + (H : ∀ a : α, ∀ p : α → Prop, (∀ᶠ x in n a, p x) → ∀ᶠ y in n a, ∀ᶠ x in n y, p x) : + ∀ a, ∀ s ∈ n a, ∃ t ∈ n a, t ⊆ s ∧ ∀ a' ∈ t, s ∈ n a' := by + intro a s s_in + refine ⟨{ y | s ∈ n y }, H a (fun x ↦ x ∈ s) s_in, ?_, by tauto⟩ + rintro y (hy : s ∈ n y) + exact H₀ y hy + +end + +variable {X Y : Type*} + +example (f : X → Y) : TopologicalSpace X → TopologicalSpace Y := + TopologicalSpace.coinduced f + +example (f : X → Y) : TopologicalSpace Y → TopologicalSpace X := + TopologicalSpace.induced f + +example (f : X → Y) (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) : + TopologicalSpace.coinduced f T_X ≤ T_Y ↔ T_X ≤ TopologicalSpace.induced f T_Y := + coinduced_le_iff_le_induced + +#check coinduced_compose + +#check induced_compose + +example {T T' : TopologicalSpace X} : T ≤ T' ↔ ∀ s, T'.IsOpen s → T.IsOpen s := + Iff.rfl + +example (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) (f : X → Y) : + Continuous f ↔ TopologicalSpace.coinduced f T_X ≤ T_Y := + continuous_iff_coinduced_le + +example {Z : Type*} (f : X → Y) (T_X : TopologicalSpace X) (T_Z : TopologicalSpace Z) + (g : Y → Z) : + @Continuous Y Z (TopologicalSpace.coinduced f T_X) T_Z g ↔ + @Continuous X Z T_X T_Z (g ∘ f) := by + rw [continuous_iff_coinduced_le, coinduced_compose, continuous_iff_coinduced_le] + +example (ι : Type*) (X : ι → Type*) (T_X : ∀ i, TopologicalSpace (X i)) : + (Pi.topologicalSpace : TopologicalSpace (∀ i, X i)) = + ⨅ i, TopologicalSpace.induced (fun x ↦ x i) (T_X i) := + rfl + +example [TopologicalSpace X] [T2Space X] {u : ℕ → X} {a b : X} (ha : Tendsto u atTop (𝓝 a)) + (hb : Tendsto u atTop (𝓝 b)) : a = b := + tendsto_nhds_unique ha hb + +example [TopologicalSpace X] [RegularSpace X] (a : X) : + (𝓝 a).HasBasis (fun s : Set X ↦ s ∈ 𝓝 a ∧ IsClosed s) id := + closed_nhds_basis a + +example [TopologicalSpace X] {x : X} : + (𝓝 x).HasBasis (fun t : Set X ↦ t ∈ 𝓝 x ∧ IsOpen t) id := + nhds_basis_opens' x + +theorem aux {X Y A : Type*} [TopologicalSpace X] {c : A → X} + {f : A → Y} {x : X} {F : Filter Y} + (h : Tendsto f (comap c (𝓝 x)) F) {V' : Set Y} (V'_in : V' ∈ F) : + ∃ V ∈ 𝓝 x, IsOpen V ∧ c ⁻¹' V ⊆ f ⁻¹' V' := by + obtain ⟨V, ⟨V_mem, V_op⟩, hV⟩ := ((nhds_basis_opens' x).comap c).tendsto_left_iff.mp h V' V'_in + exact ⟨V, V_mem, V_op, hV⟩ + +example [TopologicalSpace X] [TopologicalSpace Y] [T3Space Y] {A : Set X} + (hA : ∀ x, x ∈ closure A) {f : A → Y} (f_cont : Continuous f) + (hf : ∀ x : X, ∃ c : Y, Tendsto f (comap (↑) (𝓝 x)) (𝓝 c)) : + ∃ φ : X → Y, Continuous φ ∧ ∀ a : A, φ a = f a := by + choose φ hφ using hf + use φ + constructor + · rw [continuous_iff_continuousAt] + intro x + suffices ∀ V' ∈ 𝓝 (φ x), IsClosed V' → φ ⁻¹' V' ∈ 𝓝 x by + simpa [ContinuousAt, (closed_nhds_basis (φ x)).tendsto_right_iff] + intro V' V'_in V'_closed + obtain ⟨V, V_in, V_op, hV⟩ : ∃ V ∈ 𝓝 x, IsOpen V ∧ (↑) ⁻¹' V ⊆ f ⁻¹' V' := aux (hφ x) V'_in + suffices : ∀ y ∈ V, φ y ∈ V' + exact mem_of_superset V_in this + intro y y_in + have hVx : V ∈ 𝓝 y := V_op.mem_nhds y_in + have : (comap ((↑) : A → X) (𝓝 y)).NeBot := by simpa [mem_closure_iff_comap_neBot] using hA y + apply V'_closed.mem_of_tendsto (hφ y) + exact mem_of_superset (preimage_mem_comap hVx) hV + · intro a + have lim : Tendsto f (𝓝 a) (𝓝 (φ a)) := by simpa [nhds_induced] using hφ a + exact tendsto_nhds_unique lim f_cont.continuousAt + +example [TopologicalSpace X] [FirstCountableTopology X] + {s : Set X} {a : X} : + a ∈ closure s ↔ ∃ u : ℕ → X, (∀ n, u n ∈ s) ∧ Tendsto u atTop (𝓝 a) := + mem_closure_iff_seq_limit + +variable [TopologicalSpace X] + +example {F : Filter X} {x : X} : ClusterPt x F ↔ NeBot (𝓝 x ⊓ F) := + Iff.rfl + +example {s : Set X} : + IsCompact s ↔ ∀ (F : Filter X) [NeBot F], F ≤ 𝓟 s → ∃ a ∈ s, ClusterPt a F := + Iff.rfl + +example [FirstCountableTopology X] {s : Set X} {u : ℕ → X} (hs : IsCompact s) + (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := + hs.tendsto_subseq hu + +variable [TopologicalSpace Y] + +example {x : X} {F : Filter X} {G : Filter Y} (H : ClusterPt x F) {f : X → Y} + (hfx : ContinuousAt f x) (hf : Tendsto f F G) : ClusterPt (f x) G := + ClusterPt.map H hfx hf + +example {f : X → Y} (hf : Continuous f) {s : Set X} (hs : IsCompact s) : + IsCompact (f '' s) := by + intro F F_ne F_le + have map_eq : map f (𝓟 s ⊓ comap f F) = 𝓟 (f '' s) ⊓ F := by + rw [Filter.push_pull, map_principal] + have Hne : (𝓟 s ⊓ comap f F).NeBot := by + apply NeBot.of_map + rw [map_eq, inf_of_le_right F_le] + exact F_ne + have Hle : 𝓟 s ⊓ comap f F ≤ 𝓟 s := inf_le_left + rcases hs Hle with ⟨x, x_in, hx⟩ + refine ⟨f x, mem_image_of_mem f x_in, ?_⟩ + apply hx.map hf.continuousAt + rw [Tendsto, map_eq] + exact inf_le_right + +example {ι : Type*} {s : Set X} (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) + (hsU : s ⊆ ⋃ i, U i) : ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := + hs.elim_finite_subcover U hUo hsU diff --git a/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/S01_Elementary_Differential_Calculus.lean b/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/S01_Elementary_Differential_Calculus.lean new file mode 100644 index 0000000..7d7e373 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/S01_Elementary_Differential_Calculus.lean @@ -0,0 +1,47 @@ +module +public import MIL.Common +public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv +public import Mathlib.Analysis.Calculus.Deriv.Pow +public import Mathlib.Analysis.Calculus.MeanValue +public import Mathlib.Analysis.Calculus.Deriv.MeanValue + +open Set Filter +open Topology Filter Classical Real + +noncomputable section + +open Real + +/-- The sin function has derivative 1 at 0. -/ +example : HasDerivAt sin 1 0 := by simpa using hasDerivAt_sin 0 + +example (x : ℝ) : DifferentiableAt ℝ sin x := + (hasDerivAt_sin x).differentiableAt + +example {f : ℝ → ℝ} {x a : ℝ} (h : HasDerivAt f a x) : deriv f x = a := + h.deriv + +example {f : ℝ → ℝ} {x : ℝ} (h : ¬DifferentiableAt ℝ f x) : deriv f x = 0 := + deriv_zero_of_not_differentiableAt h + +example {f g : ℝ → ℝ} {x : ℝ} (hf : DifferentiableAt ℝ f x) (hg : DifferentiableAt ℝ g x) : + deriv (f + g) x = deriv f x + deriv g x := + deriv_add hf hg + +example {f : ℝ → ℝ} {a : ℝ} (h : IsLocalMin f a) : deriv f a = 0 := by + exact? + --h.deriv_eq_zero + +open Set + +example {f : ℝ → ℝ} {a b : ℝ} (hab : a < b) (hfc : ContinuousOn f (Icc a b)) (hfI : f a = f b) : + ∃ c ∈ Ioo a b, deriv f c = 0 := + exists_deriv_eq_zero hab hfc hfI + +example (f : ℝ → ℝ) {a b : ℝ} (hab : a < b) (hf : ContinuousOn f (Icc a b)) + (hf' : DifferentiableOn ℝ f (Ioo a b)) : ∃ c ∈ Ioo a b, deriv f c = (f b - f a) / (b - a) := + exists_deriv_eq_slope f hab hf hf' + +example : deriv (fun x : ℝ ↦ x ^ 5) 6 = 5 * 6 ^ 4 := by simp + +example : deriv sin π = -1 := by simp diff --git a/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/S02_Differential_Calculus_in_Normed_Spaces.lean b/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/S02_Differential_Calculus_in_Normed_Spaces.lean new file mode 100644 index 0000000..206d326 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/S02_Differential_Calculus_in_Normed_Spaces.lean @@ -0,0 +1,185 @@ +module +public import MIL.Common +public import Mathlib.Analysis.Normed.Operator.BanachSteinhaus +public import Mathlib.Analysis.Normed.Module.FiniteDimension +public import Mathlib.Analysis.Calculus.InverseFunctionTheorem.FDeriv +public import Mathlib.Analysis.Calculus.ContDiff.RCLike +public import Mathlib.Analysis.Calculus.FDeriv.Prod + + +open Set Filter + +open Topology Filter + +noncomputable section + +section + +variable {E : Type*} [NormedAddCommGroup E] + +example (x : E) : 0 ≤ ‖x‖ := + norm_nonneg x + +example {x : E} : ‖x‖ = 0 ↔ x = 0 := + norm_eq_zero + +example (x y : E) : ‖x + y‖ ≤ ‖x‖ + ‖y‖ := + norm_add_le x y + +example : MetricSpace E := by infer_instance + +example {X : Type*} [TopologicalSpace X] {f : X → E} (hf : Continuous f) : + Continuous fun x ↦ ‖f x‖ := + hf.norm + +variable [NormedSpace ℝ E] + +example (a : ℝ) (x : E) : ‖a • x‖ = |a| * ‖x‖ := + norm_smul a x + +example [FiniteDimensional ℝ E] : CompleteSpace E := by infer_instance + +example (𝕜 : Type*) [NontriviallyNormedField 𝕜] (x y : 𝕜) : ‖x * y‖ = ‖x‖ * ‖y‖ := + norm_mul x y + +example (𝕜 : Type*) [NontriviallyNormedField 𝕜] : ∃ x : 𝕜, 1 < ‖x‖ := + NormedField.exists_one_lt_norm 𝕜 + +example (𝕜 : Type*) [NontriviallyNormedField 𝕜] (E : Type*) [NormedAddCommGroup E] + [NormedSpace 𝕜 E] [CompleteSpace 𝕜] [FiniteDimensional 𝕜 E] : CompleteSpace E := + FiniteDimensional.complete 𝕜 E + +end + +section + +variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] + [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] + +example : E →L[𝕜] E := + ContinuousLinearMap.id 𝕜 E + +example (f : E →L[𝕜] F) : E → F := + f + +example (f : E →L[𝕜] F) : Continuous f := + f.cont + +example (f : E →L[𝕜] F) (x y : E) : f (x + y) = f x + f y := + f.map_add x y + +example (f : E →L[𝕜] F) (a : 𝕜) (x : E) : f (a • x) = a • f x := + f.map_smul a x + +variable (f : E →L[𝕜] F) + +example (x : E) : ‖f x‖ ≤ ‖f‖ * ‖x‖ := + f.le_opNorm x + +example {M : ℝ} (hMp : 0 ≤ M) (hM : ∀ x, ‖f x‖ ≤ M * ‖x‖) : ‖f‖ ≤ M := + f.opNorm_le_bound hMp hM + +end + +section + +variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] + [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] + +open Metric + +example {ι : Type*} [CompleteSpace E] {g : ι → E →L[𝕜] F} (h : ∀ x, ∃ C, ∀ i, ‖g i x‖ ≤ C) : + ∃ C', ∀ i, ‖g i‖ ≤ C' := by + -- sequence of subsets consisting of those `x : E` with norms `‖g i x‖` bounded by `n` + let e : ℕ → Set E := fun n ↦ ⋂ i : ι, { x : E | ‖g i x‖ ≤ n } + -- each of these sets is closed + have hc : ∀ n : ℕ, IsClosed (e n) := by + sorry + -- the union is the entire space; this is where we use `h` + have hU : (⋃ n : ℕ, e n) = univ := by + sorry + /- apply the Baire category theorem to conclude that for some `m : ℕ`, + the interior of `e m` contains some `x` -/ + obtain ⟨m, x, hx⟩ : ∃ m, ∃ x, x ∈ interior (e m) := sorry + obtain ⟨ε, ε_pos, hε⟩ : ∃ ε > 0, ball x ε ⊆ interior (e m) := sorry + obtain ⟨k, hk⟩ : ∃ k : 𝕜, 1 < ‖k‖ := sorry + -- show all elements in the ball have norm bounded by `m` after applying any `g i` + have real_norm_le : ∀ z ∈ ball x ε, ∀ (i : ι), ‖g i z‖ ≤ m + sorry + have εk_pos : 0 < ε / ‖k‖ := sorry + refine ⟨(m + m : ℕ) / (ε / ‖k‖), fun i ↦ ContinuousLinearMap.opNorm_le_of_shell ε_pos ?_ hk ?_⟩ + sorry + sorry +end + +open Asymptotics + +example {α : Type*} {E : Type*} [NormedGroup E] {F : Type*} [NormedGroup F] (c : ℝ) + (l : Filter α) (f : α → E) (g : α → F) : IsBigOWith c l f g ↔ ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := + isBigOWith_iff + +example {α : Type*} {E : Type*} [NormedGroup E] {F : Type*} [NormedGroup F] + (l : Filter α) (f : α → E) (g : α → F) : f =O[l] g ↔ ∃ C, IsBigOWith C l f g := + isBigO_iff_isBigOWith + +example {α : Type*} {E : Type*} [NormedGroup E] {F : Type*} [NormedGroup F] + (l : Filter α) (f : α → E) (g : α → F) : f =o[l] g ↔ ∀ C > 0, IsBigOWith C l f g := + isLittleO_iff_forall_isBigOWith + +example {α : Type*} {E : Type*} [NormedAddCommGroup E] (l : Filter α) (f g : α → E) : + f ~[l] g ↔ (f - g) =o[l] g := + Iff.rfl + +section + +open Topology + +variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] + [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] + +example (f : E → F) (f' : E →L[𝕜] F) (x₀ : E) : + HasFDerivAt f f' x₀ ↔ (fun x ↦ f x - f x₀ - f' (x - x₀)) =o[𝓝 x₀] fun x ↦ x - x₀ := + hasFDerivAt_iff_isLittleO + +example (f : E → F) (f' : E →L[𝕜] F) (x₀ : E) (hff' : HasFDerivAt f f' x₀) : fderiv 𝕜 f x₀ = f' := + hff'.fderiv + +example (n : ℕ) (f : E → F) : E → E[×n]→L[𝕜] F := + iteratedFDeriv 𝕜 n f + +example (n : ℕ∞) {f : E → F} : + ContDiff 𝕜 n f ↔ + (∀ m : ℕ, (m : WithTop ℕ) ≤ n → Continuous fun x ↦ iteratedFDeriv 𝕜 m f x) ∧ + ∀ m : ℕ, (m : WithTop ℕ) < n → Differentiable 𝕜 fun x ↦ iteratedFDeriv 𝕜 m f x := + contDiff_iff_continuous_differentiable + +example {𝕂 : Type*} [RCLike 𝕂] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕂 E] {F : Type*} + [NormedAddCommGroup F] [NormedSpace 𝕂 F] {f : E → F} {x : E} {n : WithTop ℕ∞} + (hf : ContDiffAt 𝕂 n f x) (hn : 1 ≤ n) : HasStrictFDerivAt f (fderiv 𝕂 f x) x := + hf.hasStrictFDerivAt (zero_lt_one.trans_le hn).ne' + +section LocalInverse +variable [CompleteSpace E] {f : E → F} {f' : E ≃L[𝕜] F} {a : E} + +example (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) : F → E := + HasStrictFDerivAt.localInverse f f' a hf + +example (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) : + ∀ᶠ x in 𝓝 a, hf.localInverse f f' a (f x) = x := + hf.eventually_left_inverse + +example (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) : + ∀ᶠ x in 𝓝 (f a), f (hf.localInverse f f' a x) = x := + hf.eventually_right_inverse + +example (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) : + HasStrictFDerivAt (HasStrictFDerivAt.localInverse f f' a hf) (f'.symm : F →L[𝕜] E) (f a) := + HasStrictFDerivAt.to_localInverse hf + +end LocalInverse + +#check HasFDerivWithinAt + +#check HasFDerivAtFilter + +end diff --git a/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/solutions/Solutions_S01_Elementary_Differential_Calculus.lean b/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/solutions/Solutions_S01_Elementary_Differential_Calculus.lean new file mode 100644 index 0000000..820e7e4 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/solutions/Solutions_S01_Elementary_Differential_Calculus.lean @@ -0,0 +1,12 @@ +module +public import MIL.Common +public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv +public import Mathlib.Analysis.Calculus.Deriv.Pow +public import Mathlib.Analysis.Calculus.MeanValue +public import Mathlib.Analysis.Calculus.Deriv.MeanValue + +open Set Filter +open Topology Filter Classical Real + +noncomputable section + diff --git a/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/solutions/Solutions_S02_Differential_Calculus_in_Normed_Spaces.lean b/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/solutions/Solutions_S02_Differential_Calculus_in_Normed_Spaces.lean new file mode 100644 index 0000000..268bb73 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C12_Differential_Calculus/solutions/Solutions_S02_Differential_Calculus_in_Normed_Spaces.lean @@ -0,0 +1,64 @@ +module +public import MIL.Common +public import Mathlib.Analysis.Normed.Operator.BanachSteinhaus +public import Mathlib.Analysis.Normed.Module.FiniteDimension +public import Mathlib.Analysis.Calculus.InverseFunctionTheorem.FDeriv +public import Mathlib.Analysis.Calculus.ContDiff.RCLike +public import Mathlib.Analysis.Calculus.FDeriv.Prod + + +open Set Filter + +open Topology Filter + +noncomputable section + +section + +variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] + [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] + +open Metric + +example {ι : Type*} [CompleteSpace E] {g : ι → E →L[𝕜] F} (h : ∀ x, ∃ C, ∀ i, ‖g i x‖ ≤ C) : + ∃ C', ∀ i, ‖g i‖ ≤ C' := by + -- sequence of subsets consisting of those `x : E` with norms `‖g i x‖` bounded by `n` + let e : ℕ → Set E := fun n ↦ ⋂ i : ι, { x : E | ‖g i x‖ ≤ n } + -- each of these sets is closed + have hc : ∀ n : ℕ, IsClosed (e n) := by + intro i + exact isClosed_iInter fun i ↦ isClosed_le (g i).cont.norm continuous_const + -- the union is the entire space; this is where we use `h` + have hU : (⋃ n : ℕ, e n) = univ := by + refine eq_univ_of_forall fun x ↦ ?_ + rcases h x with ⟨C, hC⟩ + obtain ⟨m, hm⟩ := exists_nat_ge C + exact ⟨e m, mem_range_self m, mem_iInter.mpr fun i ↦ le_trans (hC i) hm⟩ + /- apply the Baire category theorem to conclude that for some `m : ℕ`, + the interior of `e m` contains some `x` -/ + obtain ⟨m : ℕ, x : E, hx : x ∈ interior (e m)⟩ := nonempty_interior_of_iUnion_of_closed hc hU + obtain ⟨ε, ε_pos, hε : ball x ε ⊆ interior (e m)⟩ := isOpen_iff.mp isOpen_interior x hx + obtain ⟨k : 𝕜, hk : 1 < ‖k‖⟩ := NormedField.exists_one_lt_norm 𝕜 + -- show all elements in the ball have norm bounded by `m` after applying any `g i` + have real_norm_le : ∀ z ∈ ball x ε, ∀ (i : ι), ‖g i z‖ ≤ m := by + intro z hz i + replace hz := mem_iInter.mp (interior_iInter_subset _ (hε hz)) i + apply interior_subset hz + have εk_pos : 0 < ε / ‖k‖ := div_pos ε_pos (zero_lt_one.trans hk) + refine ⟨(m + m : ℕ) / (ε / ‖k‖), fun i ↦ ContinuousLinearMap.opNorm_le_of_shell ε_pos ?_ hk ?_⟩ + · exact div_nonneg (Nat.cast_nonneg _) εk_pos.le + intro y le_y y_lt + calc + ‖g i y‖ = ‖g i (y + x) - g i x‖ := by rw [(g i).map_add, add_sub_cancel_right] + _ ≤ ‖g i (y + x)‖ + ‖g i x‖ := (norm_sub_le _ _) + _ ≤ m + m := + (add_le_add (real_norm_le (y + x) (by rwa [add_comm, add_mem_ball_iff_norm]) i) + (real_norm_le x (mem_ball_self ε_pos) i)) + _ = (m + m : ℕ) := by norm_cast + _ ≤ (m + m : ℕ) * (‖y‖ / (ε / ‖k‖)) := + (le_mul_of_one_le_right (Nat.cast_nonneg _) + ((one_le_div <| div_pos ε_pos (zero_lt_one.trans hk)).2 le_y)) + _ = (m + m : ℕ) / (ε / ‖k‖) * ‖y‖ := (mul_comm_div _ _ _).symm + +end + diff --git a/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S01_Elementary_Integration.lean b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S01_Elementary_Integration.lean new file mode 100644 index 0000000..9854e47 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S01_Elementary_Integration.lean @@ -0,0 +1,34 @@ +module +public import MIL.Common +public import Mathlib.Analysis.SpecialFunctions.Integrals.Basic +public import Mathlib.Analysis.Convolution + +open Set Filter + +open Topology Filter + +noncomputable section + +open MeasureTheory intervalIntegral + +open Interval +-- this introduces the notation `[[a, b]]` for the segment from `min a b` to `max a b` + +example (a b : ℝ) : (∫ x in a..b, x) = (b ^ 2 - a ^ 2) / 2 := + integral_id + +example {a b : ℝ} (h : (0 : ℝ) ∉ [[a, b]]) : (∫ x in a..b, 1 / x) = Real.log (b / a) := + integral_one_div h + +example (f : ℝ → ℝ) (hf : Continuous f) (a b : ℝ) : deriv (fun u ↦ ∫ x in a..u, f x) b = f b := + (integral_hasStrictDerivAt_right (hf.intervalIntegrable _ _) (hf.stronglyMeasurableAtFilter _ _) + hf.continuousAt).hasDerivAt.deriv + +example {f : ℝ → ℝ} {a b : ℝ} {f' : ℝ → ℝ} (h : ∀ x ∈ [[a, b]], HasDerivAt f (f' x) x) + (h' : IntervalIntegrable f' volume a b) : (∫ y in a..b, f' y) = f b - f a := + integral_eq_sub_of_hasDerivAt h h' + +open Convolution + +example (f : ℝ → ℝ) (g : ℝ → ℝ) : f ⋆ g = fun x ↦ ∫ t, f t * g (x - t) := + rfl diff --git a/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S02_Measure_Theory.lean b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S02_Measure_Theory.lean new file mode 100644 index 0000000..e8bb41e --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S02_Measure_Theory.lean @@ -0,0 +1,50 @@ +module +public import MIL.Common +public import Mathlib.Analysis.Normed.Module.FiniteDimension +public import Mathlib.Analysis.Convolution +public import Mathlib.MeasureTheory.Function.Jacobian +public import Mathlib.MeasureTheory.Integral.Bochner.Basic +public import Mathlib.MeasureTheory.Measure.Lebesgue.Basic + +open Set Filter + +noncomputable section + +variable {α : Type*} [MeasurableSpace α] + +example : MeasurableSet (∅ : Set α) := + MeasurableSet.empty + +example : MeasurableSet (univ : Set α) := + MeasurableSet.univ + +example {s : Set α} (hs : MeasurableSet s) : MeasurableSet (sᶜ) := + hs.compl + +example : Encodable ℕ := by infer_instance + +example (n : ℕ) : Encodable (Fin n) := by infer_instance + +variable {ι : Type*} [Encodable ι] + +example {f : ι → Set α} (h : ∀ b, MeasurableSet (f b)) : MeasurableSet (⋃ b, f b) := + MeasurableSet.iUnion h + +example {f : ι → Set α} (h : ∀ b, MeasurableSet (f b)) : MeasurableSet (⋂ b, f b) := + MeasurableSet.iInter h + +open MeasureTheory Function +variable {μ : Measure α} + +example (s : Set α) : μ s = ⨅ (t : Set α) (_ : s ⊆ t) (_ : MeasurableSet t), μ t := + measure_eq_iInf s + +example (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑' i, μ (s i) := + measure_iUnion_le s + +example {f : ℕ → Set α} (hmeas : ∀ i, MeasurableSet (f i)) (hdis : Pairwise (Disjoint on f)) : + μ (⋃ i, f i) = ∑' i, μ (f i) := + μ.m_iUnion hmeas hdis + +example {P : α → Prop} : (∀ᵐ x ∂μ, P x) ↔ ∀ᶠ x in ae μ, P x := + Iff.rfl diff --git a/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S03_Integration.lean b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S03_Integration.lean new file mode 100644 index 0000000..100f1dd --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S03_Integration.lean @@ -0,0 +1,66 @@ +module +public import MIL.Common +public import Mathlib.Analysis.Normed.Module.FiniteDimension +public import Mathlib.Analysis.Convolution +public import Mathlib.MeasureTheory.Function.Jacobian +public import Mathlib.MeasureTheory.Integral.Bochner.Basic +public import Mathlib.MeasureTheory.Integral.DominatedConvergence +public import Mathlib.MeasureTheory.Measure.Lebesgue.Basic + +open Set Filter + +open Topology Filter ENNReal + +open MeasureTheory + +noncomputable section +variable {α : Type*} [MeasurableSpace α] +variable {μ : Measure α} + +section +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {f : α → E} + +example {f g : α → E} (hf : Integrable f μ) (hg : Integrable g μ) : + ∫ a, f a + g a ∂μ = ∫ a, f a ∂μ + ∫ a, g a ∂μ := + integral_add hf hg + +example {s : Set α} (c : E) : ∫ _ in s, c ∂μ = (μ s).toReal • c := + setIntegral_const c + +open Filter + +example {F : ℕ → α → E} {f : α → E} (bound : α → ℝ) (hmeas : ∀ n, AEStronglyMeasurable (F n) μ) + (hint : Integrable bound μ) (hbound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) + (hlim : ∀ᵐ a ∂μ, Tendsto (fun n : ℕ ↦ F n a) atTop (𝓝 (f a))) : + Tendsto (fun n ↦ ∫ a, F n a ∂μ) atTop (𝓝 (∫ a, f a ∂μ)) := + tendsto_integral_of_dominated_convergence bound hmeas hint hbound hlim + +example {α : Type*} [MeasurableSpace α] {μ : Measure α} [SigmaFinite μ] {β : Type*} + [MeasurableSpace β] {ν : Measure β} [SigmaFinite ν] (f : α × β → E) + (hf : Integrable f (μ.prod ν)) : ∫ z, f z ∂ μ.prod ν = ∫ x, ∫ y, f (x, y) ∂ν ∂μ := + integral_prod f hf + +end + +section + +open Convolution + +variable {𝕜 : Type*} {G : Type*} {E : Type*} {E' : Type*} {F : Type*} [NormedAddCommGroup E] + [NormedAddCommGroup E'] [NormedAddCommGroup F] [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] + [NormedSpace 𝕜 E'] [NormedSpace 𝕜 F] [MeasurableSpace G] [NormedSpace ℝ F] [CompleteSpace F] + [Sub G] + +example (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F) (μ : Measure G) : + f ⋆[L, μ] g = fun x ↦ ∫ t, L (f t) (g (x - t)) ∂μ := + rfl + +end + +example {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [μ.IsAddHaarMeasure] {F : Type*} + [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {s : Set E} {f : E → E} + {f' : E → E →L[ℝ] E} (hs : MeasurableSet s) + (hf : ∀ x : E, x ∈ s → HasFDerivWithinAt f (f' x) s x) (h_inj : InjOn f s) (g : E → F) : + ∫ x in f '' s, g x ∂μ = ∫ x in s, |(f' x).det| • g (f x) ∂μ := + integral_image_eq_integral_abs_det_fderiv_smul μ hs hf h_inj g diff --git a/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S01_Elementary_Integration.lean b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S01_Elementary_Integration.lean new file mode 100644 index 0000000..3516dbd --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S01_Elementary_Integration.lean @@ -0,0 +1,11 @@ +module +public import MIL.Common +public import Mathlib.Analysis.SpecialFunctions.Integrals.Basic +public import Mathlib.Analysis.Convolution + +open Set Filter + +open Topology Filter + +noncomputable section + diff --git a/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S02_Measure_Theory.lean b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S02_Measure_Theory.lean new file mode 100644 index 0000000..ea0c121 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S02_Measure_Theory.lean @@ -0,0 +1,19 @@ +module +public import MIL.Common +public import Mathlib.Analysis.Normed.Module.FiniteDimension +public import Mathlib.Analysis.Convolution +public import Mathlib.MeasureTheory.Function.Jacobian +public import Mathlib.MeasureTheory.Integral.Bochner.Basic +public import Mathlib.MeasureTheory.Measure.Lebesgue.Basic + +open Set Filter + +noncomputable section + +variable {α : Type*} [MeasurableSpace α] + +variable {ι : Type*} [Encodable ι] + +open MeasureTheory Function +variable {μ : Measure α} + diff --git a/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S03_Integration.lean b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S03_Integration.lean new file mode 100644 index 0000000..f1927ba --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/solutions/Solutions_S03_Integration.lean @@ -0,0 +1,19 @@ +module +public import MIL.Common +public import Mathlib.Analysis.Normed.Module.FiniteDimension +public import Mathlib.Analysis.Convolution +public import Mathlib.MeasureTheory.Function.Jacobian +public import Mathlib.MeasureTheory.Integral.Bochner.Basic +public import Mathlib.MeasureTheory.Integral.DominatedConvergence +public import Mathlib.MeasureTheory.Measure.Lebesgue.Basic + +open Set Filter + +open Topology Filter ENNReal + +open MeasureTheory + +noncomputable section +variable {α : Type*} [MeasurableSpace α] +variable {μ : Measure α} + diff --git a/dev/vendor/mathematics_in_lean/MIL/Common.lean b/dev/vendor/mathematics_in_lean/MIL/Common.lean new file mode 100644 index 0000000..95ccc84 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL/Common.lean @@ -0,0 +1,5 @@ +module +public import Mathlib.Tactic +public import Mathlib.Util.Delaborators + +set_option warningAsError false diff --git a/dev/vendor/mathematics_in_lean/MIL_solutions.lean b/dev/vendor/mathematics_in_lean/MIL_solutions.lean new file mode 100644 index 0000000..a5ae45f --- /dev/null +++ b/dev/vendor/mathematics_in_lean/MIL_solutions.lean @@ -0,0 +1,44 @@ +import MIL.C01_Introduction.solutions.Solutions_S01_Getting_Started +import MIL.C01_Introduction.solutions.Solutions_S02_Overview +import MIL.C02_Basics.solutions.Solutions_S01_Calculating +import MIL.C02_Basics.solutions.Solutions_S02_Proving_Identities_in_Algebraic_Structures +import MIL.C02_Basics.solutions.Solutions_S03_Using_Theorems_and_Lemmas +import MIL.C02_Basics.solutions.Solutions_S04_More_on_Order_and_Divisibility +import MIL.C02_Basics.solutions.Solutions_S05_Proving_Facts_about_Algebraic_Structures +import MIL.C03_Logic.solutions.Solutions_S01_Implication_and_the_Universal_Quantifier +import MIL.C03_Logic.solutions.Solutions_S02_The_Existential_Quantifier +import MIL.C03_Logic.solutions.Solutions_S03_Negation +import MIL.C03_Logic.solutions.Solutions_S04_Conjunction_and_Iff +import MIL.C03_Logic.solutions.Solutions_S05_Disjunction +import MIL.C03_Logic.solutions.Solutions_S06_Sequences_and_Convergence +import MIL.C04_Sets_and_Functions.solutions.Solutions_S01_Sets +import MIL.C04_Sets_and_Functions.solutions.Solutions_S02_Functions +import MIL.C04_Sets_and_Functions.solutions.Solutions_S03_The_Schroeder_Bernstein_Theorem +import MIL.C05_Elementary_Number_Theory.solutions.Solutions_S01_Irrational_Roots +import MIL.C05_Elementary_Number_Theory.solutions.Solutions_S02_Induction_and_Recursion +import MIL.C05_Elementary_Number_Theory.solutions.Solutions_S03_Infinitely_Many_Primes +import MIL.C05_Elementary_Number_Theory.solutions.Solutions_S04_More_Induction +import MIL.C06_Discrete_Mathematics.solutions.Solutions_S01_Finsets_and_Fintypes +import MIL.C06_Discrete_Mathematics.solutions.Solutions_S02_Counting_Arguments +import MIL.C06_Discrete_Mathematics.solutions.Solutions_S03_Inductive_Structures +import MIL.C07_Structures.solutions.Solutions_S01_Structures +import MIL.C07_Structures.solutions.Solutions_S02_Algebraic_Structures +import MIL.C07_Structures.solutions.Solutions_S03_Building_the_Gaussian_Integers +import MIL.C08_Hierarchies.solutions.Solutions_S01_Basics +import MIL.C08_Hierarchies.solutions.Solutions_S02_Morphisms +import MIL.C08_Hierarchies.solutions.Solutions_S03_Subobjects +import MIL.C09_Groups_and_Rings.solutions.Solutions_S01_Groups +import MIL.C09_Groups_and_Rings.solutions.Solutions_S02_Rings +import MIL.C10_Linear_Algebra.solutions.Solutions_S01_Vector_Spaces +import MIL.C10_Linear_Algebra.solutions.Solutions_S02_Subspaces +import MIL.C10_Linear_Algebra.solutions.Solutions_S03_Endomorphisms +import MIL.C10_Linear_Algebra.solutions.Solutions_S04_Bases +import MIL.C11_Topology.solutions.Solutions_S01_Filters +import MIL.C11_Topology.solutions.Solutions_S02_Metric_Spaces +import MIL.C11_Topology.solutions.Solutions_S03_Topological_Spaces +import MIL.C12_Differential_Calculus.solutions.Solutions_S01_Elementary_Differential_Calculus +import MIL.C12_Differential_Calculus.solutions.Solutions_S02_Differential_Calculus_in_Normed_Spaces +import MIL.C13_Integration_and_Measure_Theory.solutions.Solutions_S01_Elementary_Integration +import MIL.C13_Integration_and_Measure_Theory.solutions.Solutions_S02_Measure_Theory +import MIL.C13_Integration_and_Measure_Theory.solutions.Solutions_S03_Integration +import MIL.Common diff --git a/dev/vendor/mathematics_in_lean/README.md b/dev/vendor/mathematics_in_lean/README.md new file mode 100644 index 0000000..8e1808a --- /dev/null +++ b/dev/vendor/mathematics_in_lean/README.md @@ -0,0 +1,80 @@ +# Mathematics in Lean + +This tutorial depends on Lean 4, VS Code, and Mathlib. +You can find the textbook both online and in this repository +in +[html format](https://leanprover-community.github.io/mathematics_in_lean/) +or as a +[pdf document](https://leanprover-community.github.io/mathematics_in_lean/mathematics_in_lean.pdf). +The book is designed to be read as you +work through examples and exercises, +using a copy of this repository on your computer. +Alternatively, you can use Github Codespaces or Gitpod to run Lean and VS Code in the cloud. + +This version of *Mathematics in Lean* is designed for [Lean 4](https://lean-lang.org/) and +[Mathlib](https://github.com/leanprover-community/mathlib4). +For the Lean 3 version, see [https://github.com/leanprover-community/mathematics_in_lean3](https://github.com/leanprover-community/mathematics_in_lean3). + + +## To use this repository on your computer + +Do the following: + +1. Install Lean 4 and VS Code following + these [instructions](https://lean-lang.org/install/). + +2. Fetch the repository by clicking on the forall symbol in the upper right corner of VS Code, + and choose `Open Project`, `Download Project`, and `Mathematics in Lean`. + +3. Each section in the textbook has an associated Lean file with examples and exercises. + You can find them in the folder `MIL`, organized by chapter. + We strongly recommend making a copy of that folder and experimenting and doing the + exercises in that copy. + This leaves the originals intact, and it also makes it easier to update the repository as it changes (see below). + You can call the copy `my_files` or whatever you want and use it to create + your own Lean files as well. + +At that point, you can open the textbook in a web browser +at [https://leanprover-community.github.io/mathematics_in_lean/](https://leanprover-community.github.io/mathematics_in_lean/) +and start reading and doing the exercises in VS Code. + +The textbook and this repository are still a work in progress. +You can update the repository by typing `git pull` +followed by `lake exe cache get` inside the `mathematics_in_lean` folder. +(This assumes that you have not changed the contents of the `MIL` folder, +which is why we suggested making a copy.) + + +## To use this repository with Github Codespaces + +If you have trouble installing Lean, you can use Lean directly in your browser using Github +Codespaces. +This requires a Github account. If you are signed in to Github, click here: + +Open in GitHub Codespaces + +Make sure the Machine type is `4-core`, and then press `Create codespace` +(this might take a few minutes). +This creates a virtual machine in the cloud, +and installs Lean and Mathlib. + +Opening any `.lean` file in the MIL folder will start Lean, +though this may also take a little while. +We suggest making a copy of the `MIL` directory, as described +in the instructions above for using MIL on your computer. +You can update the repository by opening a terminal in the browser +and typing `git pull` followed by `lake exe cache get` as above. + +Codespaces offers a certain number of free hours per month. When you are done working, +press `Ctrl/Cmd+Shift+P` on your keyboard, start typing `stop current codespace`, and then +select `Codespaces: Stop Current Codespace` from the list of options. +If you forget, don't worry: the virtual machine will stop itself after a certain +amount of time of inactivity. + +To restart a previous workspace, visit . + + +## Contributing + +PRs and issues should be opened at the upstream +[source repository](https://github.com/avigad/mathematics_in_lean_source). diff --git a/dev/vendor/mathematics_in_lean/html/.buildinfo b/dev/vendor/mathematics_in_lean/html/.buildinfo new file mode 100644 index 0000000..d83cd57 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/.buildinfo @@ -0,0 +1,4 @@ +# Sphinx build info version 1 +# This file records the configuration used when building these files. When it is not found, a full rebuild will be done. +config: 0f8940dd4ae29242f36813bf88872c4e +tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/dev/vendor/mathematics_in_lean/html/C01_Introduction.html b/dev/vendor/mathematics_in_lean/html/C01_Introduction.html new file mode 100644 index 0000000..e37ddd5 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C01_Introduction.html @@ -0,0 +1,403 @@ + + + + + + + + + 1. Introduction — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

1. Introduction

+
+

1.1. Getting Started

+

The goal of this book is to teach you to formalize mathematics using the +Lean 4 interactive proof assistant. +It assumes that you know some mathematics, but it does not require much. +Although we will cover examples ranging from number theory +to measure theory and analysis, +we will focus on elementary aspects of those fields, +in the hopes that if they are not familiar to you, +you can pick them up as you go. +We also don’t presuppose any background with formal methods. +Formalization can be seen as a kind of computer programming: +we will write mathematical definitions, theorems, and proofs in +a regimented language, like a programming language, +that Lean can understand. +In return, Lean provides feedback and information, +interprets expressions and guarantees that they are well-formed, +and ultimately certifies the correctness of our proofs.

+

You can learn more about Lean from the +Lean project page +and the +Lean community web pages. +This tutorial is based on Lean’s large and ever-growing library, Mathlib. +We also strongly recommend joining the +Lean Zulip online chat group +if you haven’t already. +You’ll find a lively and welcoming community of Lean enthusiasts there, +happy to answer questions and offer moral support.

+

Although you can read a pdf or html version of this book online, +it is designed to be read interactively, +running Lean from inside the VS Code editor. +To get started:

+
    +
  1. Install Lean 4 and VS Code following +these installation instructions.

  2. +
  3. Fetch the repository by clicking on the forall symbol in the upper right corner of VS Code, +and choose Open Project, Download Project, and Mathematics in Lean.

  4. +
  5. Each section in this book has an associated Lean file with examples and exercises. +You can find them in the folder MIL, organized by chapter. +We strongly recommend making a copy of that folder and experimenting and doing the +exercises in that copy. +This leaves the originals intact, and it also makes it easier to update the repository as it changes (see below). +You can call the copy my_files or whatever you want and use it to create +your own Lean files as well.

  6. +
+

At that point, you can open the textbook in a side panel in VS Code as follows:

+
    +
  1. Type ctrl-shift-P (command-shift-P in macOS).

  2. +
  3. Type Lean 4: Docs: Show Documentation Resources in the bar that appears, and then +press return. (You can press return to select it as soon as it is highlighted +in the menu.)

  4. +
  5. In the window that opens, click on Mathematics in Lean.

  6. +
+

Alternatively, you can run Lean and VS Code in the cloud, +using Codespaces. +You can find instructions as to how to do that on the Mathematics in Lean +project page +on Github. We still recommend working in a copy of the MIL folder, +as described above.

+

This textbook and the associated repository are still a work in progress. +You can update the repository by typing git pull +followed by lake exe cache get inside the mathematics_in_lean folder. +(This assumes that you have not changed the contents of the MIL folder, +which is why we suggested making a copy.)

+

We intend for you to work on the exercises in the MIL folder while reading the +textbook, which contains explanations, instructions, and hints. +The text will often include examples, like this one:

+
#eval "Hello, World!"
+
+
+

You should be able to find the corresponding example in the associated +Lean file. +If you click on the line, VS Code will show you Lean’s feedback in +the Lean InfoView window, and if you hover +your cursor over the #eval command VS Code will show you Lean’s response +to this command in a pop-up window. +You are encouraged to edit the file and try examples of your own.

+

This book moreover provides lots of challenging exercises for you to try. +Don’t rush past these! +Lean is about doing mathematics interactively, not just reading about it. +Working through the exercises is central to the experience. +You don’t have to do all of them; when you feel comfortable that you have mastered +the relevant skills, feel free to move on. +You can always compare your solutions to the ones in the solutions +folder associated with each section.

+
+
+

1.2. Overview

+

Put simply, Lean is a tool for building complex expressions in a formal language +known as dependent type theory.

+

Every expression has a type, and you can use the #check command to +print it. +Some expressions have types like ℕ or ℕ → ℕ. +These are mathematical objects.

+
#check 2 + 2
+
+def f (x : ℕ) :=
+  x + 3
+
+#check f
+
+
+

Some expressions have type Prop. +These are mathematical statements.

+
#check 2 + 2 = 4
+
+def FermatLastTheorem :=
+  ∀ x y z n : ℕ, n > 2 ∧ x * y * z ≠ 0 → x ^ n + y ^ n ≠ z ^ n
+
+#check FermatLastTheorem
+
+
+

Some expressions have a type, P, where P itself has type Prop. +Such an expression is a proof of the proposition P.

+
theorem easy : 2 + 2 = 4 :=
+  rfl
+
+#check easy
+
+theorem hard : FermatLastTheorem :=
+  sorry
+
+#check hard
+
+
+

If you manage to construct an expression of type FermatLastTheorem and +Lean accepts it as a term of that type, +you have done something very impressive. +(Using sorry is cheating, and Lean knows it.) +So now you know the game. +All that is left to learn is the rules.

+

This book is complementary to a companion tutorial, +Theorem Proving in Lean, +which provides a more thorough introduction to the underlying logical framework +and core syntax of Lean. +Theorem Proving in Lean is for people who prefer to read a user manual cover to cover before +using a new dishwasher. +If you are the kind of person who prefers to hit the start button and +figure out how to activate the potscrubber feature later, +it makes more sense to start here and refer back to +Theorem Proving in Lean as necessary.

+

Another thing that distinguishes Mathematics in Lean from +Theorem Proving in Lean is that here we place a much greater +emphasis on the use of tactics. +Given that we are trying to build complex expressions, +Lean offers two ways of going about it: +we can write down the expressions themselves +(that is, suitable text descriptions thereof), +or we can provide Lean with instructions as to how to construct them. +For example, the following expression represents a proof of the fact that +if n is even then so is m * n:

+
example : ∀ m n : Nat, Even n → Even (m * n) := fun m n ⟨k, (hk : n = k + k)⟩ ↦
+  have hmn : m * n = m * k + m * k := by rw [hk, mul_add]
+  show ∃ l, m * n = l + l from ⟨_, hmn⟩
+
+
+

The proof term can be compressed to a single line:

+
example : ∀ m n : Nat, Even n → Even (m * n) :=
+fun m n ⟨k, hk⟩ ↦ ⟨m * k, by rw [hk, mul_add]⟩
+
+
+

The following is, instead, a tactic-style proof of the same theorem, where lines +starting with -- are comments, hence ignored by Lean:

+
example : ∀ m n : Nat, Even n → Even (m * n) := by
+  -- Say `m` and `n` are natural numbers, and assume `n = 2 * k`.
+  rintro m n ⟨k, hk⟩
+  -- We need to prove `m * n` is twice a natural number. Let's show it's twice `m * k`.
+  use m * k
+  -- Substitute for `n`,
+  rw [hk]
+  -- and now it's obvious.
+  ring
+
+
+

As you enter each line of such a proof in VS Code, +Lean displays the proof state in a separate window, +telling you what facts you have already established and what +tasks remain to prove your theorem. +You can replay the proof by stepping through the lines, +since Lean will continue to show you the state of the proof +at the point where the cursor is. +In this example, you will then see that +the first line of the proof introduces m and n +(we could have renamed them at that point, if we wanted to), +and also decomposes the hypothesis Even n to +a k and the assumption that n = 2 * k. +The second line, use m * k, +declares that we are going to show that m * n is even by +showing m * n = 2 * (m * k). +The next line uses the rw tactic +to replace n by 2 * k in the goal (rw stands for “rewrite”), +and the ring tactic solves the resulting goal m * (2 * k) = 2 * (m * k).

+

The ability to build a proof in small steps with incremental feedback +is extremely powerful. For that reason, +tactic proofs are often easier and quicker to write than +proof terms. +There isn’t a sharp distinction between the two: +tactic proofs can be inserted in proof terms, +as we did with the phrase by rw [hk, mul_add] in the example above. +We will also see that, conversely, +it is often useful to insert a short proof term in the middle of a tactic proof. +That said, in this book, our emphasis will be on the use of tactics.

+

In our example, the tactic proof can also be reduced to a one-liner:

+
example : ∀ m n : Nat, Even n → Even (m * n) := by
+  rintro m n ⟨k, hk⟩; use m * k; rw [hk]; ring
+
+
+

Here we have used tactics to carry out small proof steps. +But they can also provide substantial automation, +and justify longer calculations and bigger inferential steps. +For example, we can invoke Lean’s simplifier with +specific rules for simplifying statements about parity to +prove our theorem automatically.

+
example : ∀ m n : Nat, Even n → Even (m * n) := by
+  intros; simp [*, parity_simps]
+
+
+

Another big difference between the two introductions is that +Theorem Proving in Lean depends only on core Lean and its built-in +tactics, whereas Mathematics in Lean is built on top of Lean’s +powerful and ever-growing library, Mathlib. +As a result, we can show you how to use some of the mathematical +objects and theorems in the library, +and some of the very useful tactics. +This book is not meant to be used as an complete overview of the library; +the community +web pages contain extensive documentation. +Rather, our goal is to introduce you to the style of thinking that +underlies that formalization, and point out basic entry points +so that you are comfortable browsing the library and +finding things on your own.

+

Interactive theorem proving can be frustrating, +and the learning curve is steep. +But the Lean community is very welcoming to newcomers, +and people are available on the +Lean Zulip chat group round the clock +to answer questions. +We hope to see you there, and have no doubt that +soon enough you, too, will be able to answer such questions +and contribute to the development of Mathlib.

+

So here is your mission, should you choose to accept it: +dive in, try the exercises, come to Zulip with questions, and have fun. +But be forewarned: +interactive theorem proving will challenge you to think about +mathematics and mathematical reasoning in fundamentally new ways. +Your life may never be the same.

+

Acknowledgments. We are grateful to Gabriel Ebner for setting up the +infrastructure for running this tutorial in VS Code, +and to Kim Morrison and Mario Carneiro for help porting it from Lean 4. +We are also grateful for help and corrections from +Takeshi Abe, +Julian Berman, Alex Best, Axel Boldt, Thomas Browning, +Bulwi Cha, Hanson Char, Bryan Gin-ge Chen, Steven Clontz, Mauricio Collaris, Johan Commelin, +Mark Czubin, +Alexandru Duca, +Pierpaolo Frasa, +Denis Gorbachev, Winston de Greef, Darij Grinberg, Mathieu Guay-Paquet, +Rik Heurter, Marc Huisinga, +Benjamin Jones, +Julian Külshammer, +Victor Liu, Jimmy Lu, +Martin C. Martin, Giovanni Mascellani, John McDowell, Joseph McKinsey, Bhavik Mehta, Sebastian Miele, Isaiah Mindich, +Kabelo Moiloa, Hunter Monroe, Pietro Monticone, +Oliver Nash, Emanuelle Natale, Filippo A. E. Nuccio, +Pim Otte, +Nicolas Rolland, Keith Rush, +Yannick Seurin, Guilherme Silva, Bernardo Subercaseaux, +Pedro Sánchez Terraf, Matthew Toohey, Alistair Tucker, +Floris van Doorn, Veniamin Viflyantsev, +Eric Wieser, +and others. +Our work has been partially supported by the Hoskinson Center for +Formal Mathematics.

+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C02_Basics.html b/dev/vendor/mathematics_in_lean/html/C02_Basics.html new file mode 100644 index 0000000..9bb00b4 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C02_Basics.html @@ -0,0 +1,1455 @@ + + + + + + + + + 2. Basics — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

2. Basics

+

This chapter is designed to introduce you to the nuts and +bolts of mathematical reasoning in Lean: calculating, +applying lemmas and theorems, +and reasoning about generic structures.

+
+

2.1. Calculating

+

We generally learn to carry out mathematical calculations +without thinking of them as proofs. +But when we justify each step in a calculation, +as Lean requires us to do, +the net result is a proof that the left-hand side of the calculation +is equal to the right-hand side.

+

In Lean, stating a theorem is tantamount to stating a goal, +namely, the goal of proving the theorem. +Lean provides the rewriting tactic rw, +to replace the left-hand side of an identity by the right-hand side +in the goal. If a, b, and c are real numbers, +mul_assoc a b c is the identity a * b * c = a * (b * c) +and mul_comm a b is the identity a * b = b * a. +Lean provides automation that generally eliminates the need +to refer the facts like these explicitly, +but they are useful for the purposes of illustration. +In Lean, multiplication associates to the left, +so the left-hand side of mul_assoc could also be written (a * b) * c. +However, it is generally good style to be mindful of Lean’s +notational conventions and leave out parentheses when Lean does as well.

+

Let’s try out rw.

+
example (a b c : ℝ) : a * b * c = b * (a * c) := by
+  rw [mul_comm a b]
+  rw [mul_assoc b a c]
+
+
+

The module and public import lines at the beginning of the associated examples file +import the theory of the real numbers from Mathlib, as well as useful automation. +More precisely, the module line tells Lean to import from Mathlib only those definitions and +theorems that are marked as public, and the keyword public tells Lean to keep them public in any +file that imports this one. You can ignore these details for now; the most important thing to know +is that the “import” commands tell Lean what parts of Mathlib you want to use. +For the sake of brevity, we generally suppress information like this in the textbook.

+

You are welcome to make changes to see what happens. +You can type the ℝ character as \R or \real +in VS Code. +The symbol doesn’t appear until you hit space or the tab key. +If you hover over a symbol when reading a Lean file, +VS Code will show you the syntax that can be used to enter it. +If you are curious to see all available abbreviations, you can hit Ctrl-Shift-P +and then type abbreviations to get access to the Lean 4: Show Unicode Input Abbreviations command. +If your keyboard does not have an easily accessible backslash, +you can change the leading character by changing the +lean4.input.leader setting.

+

When a cursor is in the middle of a tactic proof, +Lean reports on the current proof state in the +Lean Infoview window. +As you move your cursor past each step of the proof, +you can see the state change. +A typical proof state in Lean might look as follows:

+
1 goal
+x y : ℕ,
+h₁ : Prime x,
+h₂ : ¬Even x,
+h₃ : y > x
+⊢ y ≥ 4
+
+
+

The lines before the one that begins with ⊢ denote the context: +they are the objects and assumptions currently at play. +In this example, these include two objects, x and y, +each a natural number. +They also include three assumptions, +labelled h₁, h₂, and h₃. +In Lean, everything in a context is labelled with an identifier. +You can type these subscripted labels as h\1, h\2, and h\3, +but any legal identifiers would do: +you can use h1, h2, h3 instead, +or foo, bar, and baz. +The last line represents the goal, +that is, the fact to be proved. +Sometimes people use target for the fact to be proved, +and goal for the combination of the context and the target. +In practice, the intended meaning is usually clear.

+

Try proving these identities, +in each case replacing sorry by a tactic proof. +With the rw tactic, you can use a left arrow (\l) +to reverse an identity. +For example, rw [← mul_assoc a b c] +replaces a * (b * c) by a * b * c in the current goal. Note that +the left-pointing arrow refers to going from right to left in the identity provided +by mul_assoc, it has nothing to do with the left or right side of the goal.

+
example (a b c : ℝ) : c * b * a = b * (a * c) := by
+  sorry
+
+example (a b c : ℝ) : a * (b * c) = b * (a * c) := by
+  sorry
+
+
+

You can also use identities like mul_assoc and mul_comm without arguments. +In this case, the rewrite tactic tries to match the left-hand side with +an expression in the goal, +using the first pattern it finds.

+
example (a b c : ℝ) : a * b * c = b * c * a := by
+  rw [mul_assoc]
+  rw [mul_comm]
+
+
+

You can also provide partial information. +For example, mul_comm a matches any pattern of the form +a * ? and rewrites it to ? * a. +Try doing the first of these examples without +providing any arguments at all, +and the second with only one argument.

+
example (a b c : ℝ) : a * (b * c) = b * (c * a) := by
+  sorry
+
+example (a b c : ℝ) : a * (b * c) = b * (a * c) := by
+  sorry
+
+
+

You can also use rw with facts from the local context.

+
example (a b c d e f : ℝ) (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by
+  rw [h']
+  rw [← mul_assoc]
+  rw [h]
+  rw [mul_assoc]
+
+
+

Try these, using the theorem sub_self for the second one:

+
example (a b c d e f : ℝ) (h : b * c = e * f) : a * b * c * d = a * e * f * d := by
+  sorry
+
+example (a b c d : ℝ) (hyp : c = b * a - d) (hyp' : d = a * b) : c = 0 := by
+  sorry
+
+
+

Multiple rewrite commands can be carried out with a single command, +by listing the relevant identities separated by commas inside the square brackets.

+
example (a b c d e f : ℝ) (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by
+  rw [h', ← mul_assoc, h, mul_assoc]
+
+
+

You still see the incremental progress by placing the cursor after +a comma in any list of rewrites.

+

Another trick is that we can declare variables once and for all outside +an example or theorem. Lean then includes them automatically.

+
variable (a b c d e f : ℝ)
+
+example (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by
+  rw [h', ← mul_assoc, h, mul_assoc]
+
+
+

Inspection of the tactic state at the beginning of the above proof +reveals that Lean indeed included all variables. +We can delimit the scope of the declaration by putting it +in a section ... end block. +Finally, recall from the introduction that Lean provides us with a +command to determine the type of an expression:

+
section
+variable (a b c : ℝ)
+
+#check a
+#check a + b
+#check (a : ℝ)
+#check mul_comm a b
+#check (mul_comm a b : a * b = b * a)
+#check mul_assoc c a b
+#check mul_comm a
+#check mul_comm
+
+end
+
+
+

The #check command works for both objects and facts. +In response to the command #check a, Lean reports that a has type ℝ. +In response to the command #check mul_comm a b, +Lean reports that mul_comm a b is a proof of the fact a * b = b * a. +The command #check (a : ℝ) states our expectation that the +type of a is ℝ, +and Lean will raise an error if that is not the case. +We will explain the output of the last three #check commands later, +but in the meanwhile, you can take a look at them, +and experiment with some #check commands of your own.

+

Let’s try some more examples. The theorem two_mul a says +that 2 * a = a + a. The theorems add_mul and mul_add +express the distributivity of multiplication over addition, +and the theorem add_assoc expresses the associativity of addition. +Use the #check command to see the precise statements.

+
example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by
+  rw [mul_add, add_mul, add_mul]
+  rw [← add_assoc, add_assoc (a * a)]
+  rw [mul_comm b a, ← two_mul]
+
+
+

Whereas it is possible to figure out what is going on in this proof +by stepping through it in the editor, +it is hard to read on its own. +Lean provides a more structured way of writing proofs like this +using the calc keyword.

+
example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b :=
+  calc
+    (a + b) * (a + b) = a * a + b * a + (a * b + b * b) := by
+      rw [mul_add, add_mul, add_mul]
+    _ = a * a + (b * a + a * b) + b * b := by
+      rw [← add_assoc, add_assoc (a * a)]
+    _ = a * a + 2 * (a * b) + b * b := by
+      rw [mul_comm b a, ← two_mul]
+
+
+

Notice that the proof does not begin with by: +an expression that begins with calc is a proof term. +A calc expression can also be used inside a tactic proof, +but Lean interprets it as the instruction to use the resulting +proof term to solve the goal. +The calc syntax is finicky: the underscores and justification +have to be in the format indicated above. +Lean uses indentation to determine things like where a block +of tactics or a calc block begins and ends; +try changing the indentation in the proof above to see what happens.

+

One way to write a calc proof is to outline it first +using the sorry tactic for justification, +make sure Lean accepts the expression modulo these, +and then justify the individual steps using tactics.

+
example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b :=
+  calc
+    (a + b) * (a + b) = a * a + b * a + (a * b + b * b) := by
+      sorry
+    _ = a * a + (b * a + a * b) + b * b := by
+      sorry
+    _ = a * a + 2 * (a * b) + b * b := by
+      sorry
+
+
+

Try proving the following identity using both a pure rw proof +and a more structured calc proof: +The following exercise is a little more challenging. +You can use the theorems listed underneath (you won’t need all of them).

+
example (a b : ℝ) : (a + b) * (a - b) = a ^ 2 - b ^ 2 := by
+  sorry
+
+#check pow_two a
+#check mul_sub a b c
+#check add_mul a b c
+#check add_sub a b c
+#check sub_sub a b c
+#check sub_add a b c
+#check add_zero a
+#check sub_zero a
+#check sub_self a
+
+
+

We can also perform rewriting in an assumption in the context. +For example, rw [mul_comm a b] at hyp replaces a * b by b * a +in the assumption hyp.

+
variable (a b c d : ℝ)
+
+example (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := by
+  rw [hyp'] at hyp
+  rw [mul_comm d a] at hyp
+  rw [← two_mul (a * d)] at hyp
+  rw [← mul_assoc 2 a d] at hyp
+  exact hyp
+
+
+

In the last step, the exact tactic can use hyp to solve the goal +because at that point hyp matches the goal exactly.

+

We close this section by noting that Mathlib provides a +useful bit of automation with a ring tactic, +which is designed to prove identities in any commutative ring as long as they follow +purely from the ring axioms, without using any local assumption.

+
example : c * b * a = b * (a * c) := by
+  ring
+
+example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by
+  ring
+
+example : (a + b) * (a - b) = a ^ 2 - b ^ 2 := by
+  ring
+
+example (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := by
+  rw [hyp, hyp']
+  ring
+
+
+

The ring tactic is imported indirectly when we +public import Mathlib.Basic.Real.Basic, +but we will see in the next section that it can be used +for calculations on structures other than the real numbers. +It can be imported explicitly with the command +import Mathlib.Tactic. +We will see there are similar tactics for other common kind of algebraic +structures.

+

There is a variation of rw called nth_rw that allows you to replace only particular instances of an expression in the goal. +Possible matches are enumerated starting with 1, +so in the following example, nth_rw 2 [h] replaces the second +occurrence of a + b with c.

+
example (a b c : ℕ) (h : a + b = c) : (a + b) * (a + b) = a * c + b * c := by
+  nth_rw 2 [h]
+  rw [add_mul]
+
+
+
+
+

2.2. Proving Identities in Algebraic Structures

+

Mathematically, a ring consists of a collection of objects, +\(R\), operations \(+\) \(\times\), and constants \(0\) +and \(1\), and an operation \(x \mapsto -x\) such that:

+
    +
  • \(R\) with \(+\) is an abelian group, with \(0\) +as the additive identity and negation as inverse.

  • +
  • Multiplication is associative with identity \(1\), +and multiplication distributes over addition.

  • +
+

In Lean, the collection of objects is represented as a type, R. +The ring axioms are as follows:

+
variable (R : Type*) [Ring R]
+
+#check (add_assoc : ∀ a b c : R, a + b + c = a + (b + c))
+#check (add_comm : ∀ a b : R, a + b = b + a)
+#check (zero_add : ∀ a : R, 0 + a = a)
+#check (neg_add_cancel : ∀ a : R, -a + a = 0)
+#check (mul_assoc : ∀ a b c : R, a * b * c = a * (b * c))
+#check (mul_one : ∀ a : R, a * 1 = a)
+#check (one_mul : ∀ a : R, 1 * a = a)
+#check (mul_add : ∀ a b c : R, a * (b + c) = a * b + a * c)
+#check (add_mul : ∀ a b c : R, (a + b) * c = a * c + b * c)
+
+
+

You will learn more about the square brackets in the first line later, +but for the time being, +suffice it to say that the declaration gives us a type, R, +and a ring structure on R. +Lean then allows us to use generic ring notation with elements of R, +and to make use of a library of theorems about rings.

+

The names of some of the theorems should look familiar: +they are exactly the ones we used to calculate with the real numbers +in the last section. +Lean is good not only for proving things about concrete mathematical +structures like the natural numbers and the integers, +but also for proving things about abstract structures, +characterized axiomatically, like rings. +Moreover, Lean supports generic reasoning about +both abstract and concrete structures, +and can be trained to recognize appropriate instances. +So any theorem about rings can be applied to concrete rings +like the integers, ℤ, the rational numbers, ℚ, +and the complex numbers ℂ. +It can also be applied to any instance of an abstract +structure that extends rings, +such as any ordered ring or any field.

+

Not all important properties of the real numbers hold in an +arbitrary ring, however. +For example, multiplication on the real numbers +is commutative, +but that does not hold in general. +If you have taken a course in linear algebra, +you will recognize that, for every \(n\), +the \(n\) by \(n\) matrices of real numbers +form a ring in which commutativity usually fails. If we declare R to be a +commutative ring, in fact, all the theorems +in the last section continue to hold when we replace +ℝ by R.

+
variable (R : Type*) [CommRing R]
+variable (a b c d : R)
+
+example : c * b * a = b * (a * c) := by ring
+
+example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by ring
+
+example : (a + b) * (a - b) = a ^ 2 - b ^ 2 := by ring
+
+example (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := by
+  rw [hyp, hyp']
+  ring
+
+
+

We leave it to you to check that all the other proofs go through unchanged. +Notice that when a proof is short, like by ring or by linarith +or by sorry, +it is common (and permissible) to put it on the same line as +the by. +Good proof-writing style should strike a balance between concision and readability.

+

The goal of this section is to strengthen the skills +you have developed in the last section +and apply them to reasoning axiomatically about rings. +We will start with the axioms listed above, +and use them to derive other facts. +Most of the facts we prove are already in Mathlib. +We will give the versions we prove the same names +to help you learn the contents of the library +as well as the naming conventions.

+

Lean provides an organizational mechanism similar +to those used in programming languages: +when a definition or theorem foo is introduced in a namespace +bar, its full name is bar.foo. +The command open bar later opens the namespace, +which allows us to use the shorter name foo. +To avoid errors due to name clashes, +in the next example we put our versions of the library +theorems in a new namespace called MyRing.

+

The next example shows that we do not need add_zero or add_neg_cancel +as ring axioms, because they follow from the other axioms.

+
namespace MyRing
+variable {R : Type*} [Ring R]
+
+theorem add_zero (a : R) : a + 0 = a := by rw [add_comm, zero_add]
+
+theorem add_neg_cancel (a : R) : a + -a = 0 := by rw [add_comm, neg_add_cancel]
+
+#check MyRing.add_zero
+#check add_zero
+
+end MyRing
+
+
+

The net effect is that we can temporarily reprove a theorem in the library, +and then go on using the library version after that. +But don’t cheat! +In the exercises that follow, take care to use only the +general facts about rings that we have proved earlier in this section.

+

(If you are paying careful attention, you may have noticed that we +changed the round brackets in (R : Type*) for +curly brackets in {R : Type*}. +This declares R to be an implicit argument. +We will explain what this means in a moment, +but don’t worry about it in the meanwhile.)

+

Here is a useful theorem:

+
theorem neg_add_cancel_left (a b : R) : -a + (a + b) = b := by
+  rw [← add_assoc, neg_add_cancel, zero_add]
+
+
+

Prove the companion version:

+
theorem add_neg_cancel_right (a b : R) : a + b + -b = a := by
+  sorry
+
+
+

Use these to prove the following:

+
theorem add_left_cancel {a b c : R} (h : a + b = a + c) : b = c := by
+  sorry
+
+theorem add_right_cancel {a b c : R} (h : a + b = c + b) : a = c := by
+  sorry
+
+
+

With enough planning, you can do each of them with three rewrites.

+

We will now explain the use of the curly braces. +Imagine you are in a situation where you have a, b, and c +in your context, +as well as a hypothesis h : a + b = a + c, +and you would like to draw the conclusion b = c. +In Lean, you can apply a theorem to hypotheses and facts just +the same way that you can apply them to objects, +so you might think that add_left_cancel a b c h is a +proof of the fact b = c. +But notice that explicitly writing a, b, and c +is redundant, because the hypothesis h makes it clear that +those are the objects we have in mind. +In this case, typing a few extra characters is not onerous, +but if we wanted to apply add_left_cancel to more complicated expressions, +writing them would be tedious. +In cases like these, +Lean allows us to mark arguments as implicit, +meaning that they are supposed to be left out and inferred by other means, +such as later arguments and hypotheses. +The curly brackets in {a b c : R} do exactly that. +So, given the statement of the theorem above, +the correct expression is simply add_left_cancel h.

+

To illustrate, let us show that a * 0 = 0 +follows from the ring axioms.

+
theorem mul_zero (a : R) : a * 0 = 0 := by
+  have h : a * 0 + a * 0 = a * 0 + 0 := by
+    rw [← mul_add, add_zero, add_zero]
+  rw [add_left_cancel h]
+
+
+

We have used a new trick! +If you step through the proof, +you can see what is going on. +The have tactic introduces a new goal, +a * 0 + a * 0 = a * 0 + 0, +with the same context as the original goal. +The fact that the next line is indented indicates that Lean +is expecting a block of tactics that serves to prove this +new goal. +The indentation therefore promotes a modular style of proof: +the indented subproof establishes the goal +that was introduced by the have. +After that, we are back to proving the original goal, +except a new hypothesis h has been added: +having proved it, we are now free to use it. +At this point, the goal is exactly the result of add_left_cancel h.

+

We could equally well have closed the proof with +apply add_left_cancel h or exact add_left_cancel h. +The exact tactic takes as argument a proof term which completely proves the +current goal, without creating any new goal. The apply tactic is a variant +whose argument is not necessarily a complete proof. The missing pieces are either +inferred automatically by Lean or become new goals to prove. +While the exact tactic is technically redundant since it is strictly less powerful +than apply, it makes proof scripts slightly clearer to +human readers and easier to maintain when the library evolves.

+

Remember that multiplication is not assumed to be commutative, +so the following theorem also requires some work.

+
theorem zero_mul (a : R) : 0 * a = 0 := by
+  sorry
+
+
+

By now, you should also be able to replace each sorry in the next +exercise with a proof, +still using only facts about rings that we have +established in this section along with the lemma Eq.symm stating that +a = b implies b = a.

+
theorem neg_eq_of_add_eq_zero {a b : R} (h : a + b = 0) : -a = b := by
+  sorry
+
+theorem eq_neg_of_add_eq_zero {a b : R} (h : a + b = 0) : a = -b := by
+  sorry
+
+theorem neg_zero : (-0 : R) = 0 := by
+  apply neg_eq_of_add_eq_zero
+  rw [add_zero]
+
+theorem neg_neg (a : R) : - -a = a := by
+  sorry
+
+
+

We had to use the annotation (-0 : R) instead of 0 in the third theorem +because without specifying R +it is impossible for Lean to infer which 0 we have in mind, +and by default it would be interpreted as a natural number.

+

In Lean, subtraction in a ring is provably equal to +addition of the additive inverse.

+
example (a b : R) : a - b = a + -b :=
+  sub_eq_add_neg a b
+
+
+

On the real numbers, it is defined that way:

+
example (a b : ℝ) : a - b = a + -b :=
+  rfl
+
+example (a b : ℝ) : a - b = a + -b := by
+  rfl
+
+
+

The proof term rfl is short for “reflexivity”. +Presenting it as a proof of a - b = a + -b forces Lean +to unfold the definition and recognize both sides as being the same. +The rfl tactic does the same. +This is an instance of what is known as a definitional equality +in Lean’s underlying logic. +This means that not only can one rewrite with sub_eq_add_neg +to replace a - b = a + -b, +but in some contexts, when dealing with the real numbers, +you can use the two sides of the equation interchangeably. +For example, you now have enough information to prove the theorem +self_sub from the last section:

+
theorem self_sub (a : R) : a - a = 0 := by
+  sorry
+
+
+

Show that you can prove this using rw, +but if you replace the arbitrary ring R by +the real numbers, you can also prove it +using either apply or exact.

+

Lean knows that 1 + 1 = 2 holds in any ring. +With a bit of effort, +you can use that to prove the theorem two_mul from +the last section:

+
theorem one_add_one_eq_two : 1 + 1 = (2 : R) := by
+  norm_num
+
+theorem two_mul (a : R) : 2 * a = a + a := by
+  sorry
+
+
+

We close this section by noting that some of the facts about +addition and negation that we established above do not +need the full strength of the ring axioms, or even +commutativity of addition. The weaker notion of a group +can be axiomatized as follows:

+
variable (A : Type*) [AddGroup A]
+
+#check (add_assoc : ∀ a b c : A, a + b + c = a + (b + c))
+#check (zero_add : ∀ a : A, 0 + a = a)
+#check (neg_add_cancel : ∀ a : A, -a + a = 0)
+
+
+

It is conventional to use additive notation when +the group operation is commutative, +and multiplicative notation otherwise. +So Lean defines a multiplicative version as well as the +additive version (and also their abelian variants, +AddCommGroup and CommGroup).

+
variable {G : Type*} [Group G]
+
+#check (mul_assoc : ∀ a b c : G, a * b * c = a * (b * c))
+#check (one_mul : ∀ a : G, 1 * a = a)
+#check (inv_mul_cancel : ∀ a : G, a⁻¹ * a = 1)
+
+
+

If you are feeling cocky, try proving the following facts about +groups, using only these axioms. +You will need to prove a number of helper lemmas along the way. +The proofs we have carried out in this section provide some hints.

+
theorem mul_inv_cancel (a : G) : a * a⁻¹ = 1 := by
+  sorry
+
+theorem mul_one (a : G) : a * 1 = a := by
+  sorry
+
+theorem mul_inv_rev (a b : G) : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by
+  sorry
+
+
+

Explicitly invoking those lemmas is tedious, so Mathlib provides +tactics similar to ring in order to cover most uses: group +is for non-commutative multiplicative groups, abel for abelian +additive groups, and noncomm_ring for non-commutative rings. +It may seem odd that the algebraic structures are called +Ring and CommRing while the tactics are named +noncomm_ring and ring. This is partly for historical reasons, +but also for the convenience of using a shorter name for the +tactic that deals with commutative rings, since it is used more often.

+
+
+

2.3. Using Theorems and Lemmas

+

Rewriting is great for proving equations, +but what about other sorts of theorems? +For example, how can we prove an inequality, +like the fact that \(a + e^b \le a + e^c\) holds whenever \(b \le c\)? +We have already seen that theorems can be applied to arguments and hypotheses, +and that the apply and exact tactics can be used to solve goals. +In this section, we will make good use of these tools.

+

Consider the library theorems le_refl and le_trans:

+
#check (le_refl : ∀ a : ℝ, a ≤ a)
+#check (le_trans : a ≤ b → b ≤ c → a ≤ c)
+
+
+

As we explain in more detail in Section 3.1, +the implicit parentheses in the statement of le_trans +associate to the right, so it should be interpreted as a ≤ b → (b ≤ c → a ≤ c). +The library designers have set the arguments a, b and c to le_trans implicit, +so that Lean will not let you provide them explicitly (unless you +really insist, as we will discuss later). +Rather, it expects to infer them from the context in which they are used. +For example, when hypotheses h : a ≤ b and h' : b ≤ c +are in the context, +all the following work:

+
variable (h : a ≤ b) (h' : b ≤ c)
+
+#check (le_refl : ∀ a : Real, a ≤ a)
+#check (le_refl a : a ≤ a)
+#check (le_trans : a ≤ b → b ≤ c → a ≤ c)
+#check (le_trans h : b ≤ c → a ≤ c)
+#check (le_trans h h' : a ≤ c)
+
+
+

The apply tactic takes a proof of a general statement or implication, +tries to match the conclusion with the current goal, +and leaves the hypotheses, if any, as new goals. +If the given proof matches the goal exactly +(modulo definitional equality), +you can use the exact tactic instead of apply. +So, all of these work:

+
example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := by
+  apply le_trans
+  · apply h₀
+  · apply h₁
+
+example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := by
+  apply le_trans h₀
+  apply h₁
+
+example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z :=
+  le_trans h₀ h₁
+
+example (x : ℝ) : x ≤ x := by
+  apply le_refl
+
+example (x : ℝ) : x ≤ x :=
+  le_refl x
+
+
+

In the first example, applying le_trans +creates two goals, +and we use the dots to indicate where the proof of each begins. +The dots are optional, but they serve to focus the goal: +within the block introduced by the dot, only one goal is visible, +and it must be completed before the end of the block. +Here we end the first block by starting a new one with another dot. +We could just as well have decreased the indentation. +In the third example and in the last example, +we avoid going into tactic mode entirely: +le_trans h₀ h₁ and le_refl x are the proof terms we need.

+

Here are a few more library theorems:

+
#check (le_refl : ∀ a, a ≤ a)
+#check (le_trans : a ≤ b → b ≤ c → a ≤ c)
+#check (lt_of_le_of_lt : a ≤ b → b < c → a < c)
+#check (lt_of_lt_of_le : a < b → b ≤ c → a < c)
+#check (lt_trans : a < b → b < c → a < c)
+
+
+

Use them together with apply and exact to prove the following:

+
example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := by
+  sorry
+
+
+

In fact, Lean has a tactic that does this sort of thing automatically:

+
example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := by
+  linarith
+
+
+

The linarith tactic is designed to handle linear arithmetic.

+
example (h : 2 * a ≤ 3 * b) (h' : 1 ≤ a) (h'' : d = 2) : d + a ≤ 5 * b := by
+  linarith
+
+
+

In addition to equations and inequalities in the context, +linarith will use additional inequalities that you pass as arguments. +In the next example, exp_le_exp.mpr h' is a proof of +exp b ≤ exp c, as we will explain in a moment. +Notice that, in Lean, we write f x to denote the application +of a function f to the argument x, +exactly the same way we write h x to denote the result of +applying a fact or theorem h to the argument x. +Parentheses are only needed for compound arguments, +as in f (x + y). Without the parentheses, f x + y +would be parsed as (f x) + y.

+
example (h : 1 ≤ a) (h' : b ≤ c) : 2 + a + exp b ≤ 3 * a + exp c := by
+  linarith [exp_le_exp.mpr h']
+
+
+

Here are some more theorems in the library that can be used to establish +inequalities on the real numbers.

+
#check (exp_le_exp : exp a ≤ exp b ↔ a ≤ b)
+#check (exp_lt_exp : exp a < exp b ↔ a < b)
+#check (log_le_log : 0 < a → a ≤ b → log a ≤ log b)
+#check (log_lt_log : 0 < a → a < b → log a < log b)
+#check (add_le_add : a ≤ b → c ≤ d → a + c ≤ b + d)
+#check (add_le_add_right : a ≤ b → ∀ c, c + a ≤ c + b)
+#check (add_le_add_left : a ≤ b → ∀ c, a + c ≤ b + c)
+#check (add_lt_add_of_le_of_lt : a ≤ b → c < d → a + c < b + d)
+#check (add_lt_add_of_lt_of_le : a < b → c ≤ d → a + c < b + d)
+#check (add_lt_add_right : a < b → ∀ c, c + a < c + b)
+#check (add_lt_add_left : a < b → ∀ c, a + c < b + c)
+#check (add_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a + b)
+#check (add_pos : 0 < a → 0 < b → 0 < a + b)
+#check (add_pos_of_pos_of_nonneg : 0 < a → 0 ≤ b → 0 < a + b)
+#check (exp_pos : ∀ a, 0 < exp a)
+
+
+

Some of the theorems, exp_le_exp, exp_lt_exp +use a bi-implication, which represents the +phrase “if and only if.” +(You can type it in VS Code with \lr or \iff). +We will discuss this connective in greater detail in the next chapter. +Such a theorem can be used with rw to rewrite a goal to +an equivalent one:

+
example (h : a ≤ b) : exp a ≤ exp b := by
+  rw [exp_le_exp]
+  exact h
+
+
+

In this section, however, we will use the fact that if h : A ↔ B +is such an equivalence, +then h.mp establishes the forward direction, A → B, +and h.mpr establishes the reverse direction, B → A. +Here, mp stands for “modus ponens” and +mpr stands for “modus ponens reverse.” +You can also use h.1 and h.2 for h.mp and h.mpr, +respectively, if you prefer. +Thus the following proof works:

+
example (h₀ : a ≤ b) (h₁ : c < d) : a + exp c + e < b + exp d + e := by
+  apply add_lt_add_of_lt_of_le
+  · apply add_lt_add_of_le_of_lt h₀
+    apply exp_lt_exp.mpr h₁
+  apply le_refl
+
+
+

The first line, apply add_lt_add_of_lt_of_le, +creates two goals, +and once again we use a dot to separate the +proof of the first from the proof of the second.

+

Try the following examples on your own. +The example in the middle shows you that the norm_num +tactic can be used to solve concrete numeric goals.

+
example (h₀ : d ≤ e) : c + exp (a + d) ≤ c + exp (a + e) := by sorry
+
+example : (0 : ℝ) < 1 := by norm_num
+
+example (h : a ≤ b) : log (1 + exp a) ≤ log (1 + exp b) := by
+  have h₀ : 0 < 1 + exp a := by sorry
+  apply log_le_log h₀
+  sorry
+
+
+

From these examples, it should be clear that being able to +find the library theorems you need constitutes an important +part of formalization. +There are a number of strategies you can use:

+
    +
  • You can browse Mathlib in its +GitHub repository.

  • +
  • You can use the API documentation on the Mathlib +web pages.

  • +
  • You can use Loogle +to search Lean and Mathlib definitions and theorems by patterns.

  • +
  • You can rely on Mathlib naming conventions and Ctrl-space completion in +the editor to guess a theorem name. +In Lean, a theorem named A_of_B_of_C establishes +something of the form A from hypotheses of the form B and C, +where A, B, and C +approximate the way we might read the goals out loud. +So a theorem establishing something like x + y ≤ ... will probably +start with add_le. +Typing add_le and hitting Ctrl-space will give you some helpful choices. +Note that hitting Ctrl-space twice displays more information about the available +completions.

  • +
  • If you right-click on an existing theorem name in VS Code, +the editor will show a menu with the option to +jump to the file where the theorem is defined, +and you can find similar theorems nearby.

  • +
  • You can use the apply? tactic, +which tries to find the relevant theorem in the library.

  • +
+
example : 0 ≤ a ^ 2 := by
+  -- apply?
+  exact sq_nonneg a
+
+
+

To try out apply? in this example, +delete the exact command and uncomment the previous line. +Using these tricks, +see if you can find what you need to do the +next example:

+
example (h : a ≤ b) : c - exp b ≤ c - exp a := by
+  sorry
+
+
+

Using the same tricks, confirm that linarith instead of apply? +can also finish the job.

+

Here is another example of an inequality:

+
example : 2*a*b ≤ a^2 + b^2 := by
+  have h : 0 ≤ a^2 - 2*a*b + b^2
+  calc
+    a^2 - 2*a*b + b^2 = (a - b)^2 := by ring
+    _ ≥ 0 := by apply pow_two_nonneg
+
+  calc
+    2*a*b = 2*a*b + 0 := by ring
+    _ ≤ 2*a*b + (a^2 - 2*a*b + b^2) := add_le_add (le_refl _) h
+    _ = a^2 + b^2 := by ring
+
+
+

Mathlib tends to put spaces around binary operations like * and ^, +but in this example, the more compressed format increases readability. +There are a number of things worth noticing. +First, an expression s ≥ t is definitionally equivalent to t ≤ s. +In principle, this means one should be able to use them interchangeably. +But some of Lean’s automation does not recognize the equivalence, +so Mathlib tends to favor ≤ over ≥. +Second, we have used the ring tactic extensively. +It is a real timesaver! +Finally, notice that in the second line of the +second calc proof, +instead of writing by exact add_le_add (le_refl _) h, +we can simply write the proof term add_le_add (le_refl _) h.

+

In fact, the only cleverness in the proof above is figuring +out the hypothesis h. +Once we have it, the second calculation involves only +linear arithmetic, and linarith can handle it:

+
example : 2*a*b ≤ a^2 + b^2 := by
+  have h : 0 ≤ a^2 - 2*a*b + b^2
+  calc
+    a^2 - 2*a*b + b^2 = (a - b)^2 := by ring
+    _ ≥ 0 := by apply pow_two_nonneg
+  linarith
+
+
+

How nice! We challenge you to use these ideas to prove the +following theorem. You can use the theorem abs_le'.mpr. +You will also need the constructor tactic to split a conjunction +into two goals; see Section 3.4.

+
example : |a*b| ≤ (a^2 + b^2)/2 := by
+  sorry
+
+#check abs_le'.mpr
+
+
+

If you managed to solve this, congratulations! +You are well on your way to becoming a master formalizer.

+
+
+

2.4. More examples using apply and rw

+

The min function on the real numbers is uniquely characterized +by the following three facts:

+
#check (min_le_left a b : min a b ≤ a)
+#check (min_le_right a b : min a b ≤ b)
+#check (le_min : c ≤ a → c ≤ b → c ≤ min a b)
+
+
+

Can you guess the names of the theorems that characterize +max in a similar way?

+

Notice that we have to apply min to a pair of arguments a and b +by writing min a b rather than min (a, b). +Formally, min is a function of type ℝ → ℝ → ℝ. +When we write a type like this with multiple arrows, +the convention is that the implicit parentheses associate +to the right, so the type is interpreted as ℝ → (ℝ → ℝ). +The net effect is that if a and b have type ℝ +then min a has type ℝ → ℝ and +min a b has type ℝ, so min acts like a function +of two arguments, as we expect. Handling multiple +arguments in this way is known as currying, +after the logician Haskell Curry.

+

The order of operations in Lean can also take some getting used to. +Function application binds tighter than infix operations, so the +expression min a b + c is interpreted as (min a b) + c. +With time, these conventions will become second nature.

+

Using the theorem le_antisymm, we can show that two +real numbers are equal if each is less than or equal to the other. +Using this and the facts above, +we can show that min is commutative:

+
example : min a b = min b a := by
+  apply le_antisymm
+  · show min a b ≤ min b a
+    apply le_min
+    · apply min_le_right
+    apply min_le_left
+  · show min b a ≤ min a b
+    apply le_min
+    · apply min_le_right
+    apply min_le_left
+
+
+

Here we have used dots to separate proofs of +different goals. +Our usage is inconsistent: +at the outer level, +we use dots and indentation for both goals, +whereas for the nested proofs, +we use dots only until a single goal remains. +Both conventions are reasonable and useful. +We also use the show tactic to structure +the proof +and indicate what is being proved in each block. +The proof still works without the show commands, +but using them makes the proof easier to read and maintain.

+

It may bother you that the proof is repetitive. +To foreshadow skills you will learn later on, +we note that one way to avoid the repetition +is to state a local lemma and then use it:

+
example : min a b = min b a := by
+  have h : ∀ x y : ℝ, min x y ≤ min y x := by
+    intro x y
+    apply le_min
+    apply min_le_right
+    apply min_le_left
+  apply le_antisymm
+  apply h
+  apply h
+
+
+

We will say more about the universal quantifier in +Section 3.1, +but suffice it to say here that the hypothesis +h says that the desired inequality holds for +any x and y, +and the intro tactic introduces an arbitrary +x and y to establish the conclusion. +The first apply after le_antisymm implicitly +uses h a b, whereas the second one uses h b a.

+

Another solution is to use the repeat tactic, +which applies a tactic (or a block) as many times +as it can.

+
example : min a b = min b a := by
+  apply le_antisymm
+  repeat
+    apply le_min
+    apply min_le_right
+    apply min_le_left
+
+
+

We encourage you to prove the following as exercises. +You can use either of the tricks just described to shorten the first.

+
example : max a b = max b a := by
+  sorry
+example : min (min a b) c = min a (min b c) := by
+  sorry
+
+
+

Of course, you are welcome to prove the associativity of max as well.

+

It is an interesting fact that min distributes over max +the way that multiplication distributes over addition, +and vice-versa. +In other words, on the real numbers, we have the identity +min a (max b c) = max (min a b) (min a c) +as well as the corresponding version with max and min +switched. +But in the next section we will see that this does not follow +from the transitivity and reflexivity of ≤ and +the characterizing properties of min and max enumerated above. +We need to use the fact that ≤ on the real numbers is a total order, +which is to say, +it satisfies ∀ x y, x ≤ y ∨ y ≤ x. +Here the disjunction symbol, ∨, represents “or”. +In the first case, we have min x y = x, +and in the second case, we have min x y = y. +We will learn how to reason by cases in Section 3.5, +but for now we will stick to examples that don’t require the case split.

+

Here is one such example:

+
theorem aux : min a b + c ≤ min (a + c) (b + c) := by
+  sorry
+example : min a b + c = min (a + c) (b + c) := by
+  sorry
+
+
+

It is clear that aux provides one of the two inequalities +needed to prove the equality, +but applying it to suitable values yields the other direction +as well. +As a hint, you can use the theorem add_neg_cancel_right +and the linarith tactic.

+

Lean’s naming convention is made manifest +in the library’s name for the triangle inequality:

+
#check (abs_add_le : ∀ a b : ℝ, |a + b| ≤ |a| + |b|)
+
+
+

Use it to prove the following variant, using also add_sub_cancel_right:

+
example : |a| - |b| ≤ |a - b| :=
+  sorry
+end
+
+
+

See if you can do this in three lines or less. +You can use the theorem sub_add_cancel.

+

Another important relation that we will make use of +in the sections to come is the divisibility relation +on the natural numbers, x ∣ y. +Be careful: the divisibility symbol is not the +ordinary bar on your keyboard. +Rather, it is a unicode character obtained by +typing \| in VS Code. +By convention, Mathlib uses dvd +to refer to it in theorem names.

+
example (h₀ : x ∣ y) (h₁ : y ∣ z) : x ∣ z :=
+  dvd_trans h₀ h₁
+
+example : x ∣ y * x * z := by
+  apply dvd_mul_of_dvd_left
+  apply dvd_mul_left
+
+example : x ∣ x ^ 2 := by
+  apply dvd_mul_left
+
+
+

In the last example, the exponent is a natural +number, and applying dvd_mul_left +forces Lean to expand the definition of x^2 to +x^1 * x. +See if you can guess the names of the theorems +you need to prove the following:

+
example (h : x ∣ w) : x ∣ y * (x * z) + x ^ 2 + w ^ 2 := by
+  sorry
+end
+
+
+

With respect to divisibility, the greatest common divisor, +gcd, and least common multiple, lcm, +are analogous to min and max. +Since every number divides 0, +0 is really the greatest element with respect to divisibility:

+
variable (m n : ℕ)
+
+#check (Nat.gcd_zero_right n : Nat.gcd n 0 = n)
+#check (Nat.gcd_zero_left n : Nat.gcd 0 n = n)
+#check (Nat.lcm_zero_right n : Nat.lcm n 0 = 0)
+#check (Nat.lcm_zero_left n : Nat.lcm 0 n = 0)
+
+
+

See if you can guess the names of the theorems you will need to +prove the following:

+
example : Nat.gcd m n = Nat.gcd n m := by
+  sorry
+
+
+

Hint: you can use dvd_antisymm, but if you do, Lean will +complain that the expression is ambiguous between the generic +theorem and the version Nat.dvd_antisymm, +the one specifically for the natural numbers. +You can use _root_.dvd_antisymm to specify the generic one; +either one will work.

+
+
+

2.5. Proving Facts about Algebraic Structures

+

In Section 2.2, +we saw that many common identities governing the real numbers hold +in more general classes of algebraic structures, +such as commutative rings. +We can use any axioms we want to describe an algebraic structure, +not just equations. +For example, a partial order consists of a set with a +binary relation that is reflexive, transitive, and antisymmetric. +like ≤ on the real numbers. +Lean knows about partial orders:

+
variable {α : Type*} [PartialOrder α]
+variable (x y z : α)
+
+#check x ≤ y
+#check (le_refl x : x ≤ x)
+#check (le_trans : x ≤ y → y ≤ z → x ≤ z)
+#check (le_antisymm : x ≤ y → y ≤ x → x = y)
+
+
+

Here we are adopting the Mathlib convention of using +letters like α, β, and γ +(entered as \a, \b, and \g) +for arbitrary types. +The library often uses letters like R and G +for the carriers of algebraic structures like rings and groups, +respectively, +but in general Greek letters are used for types, +especially when there is little or no structure +associated with them.

+

Associated to any partial order, ≤, +there is also a strict partial order, <, +which acts somewhat like < on the real numbers. +Saying that x is less than y in this order +is equivalent to saying that it is less-than-or-equal to y +and not equal to y.

+
#check x < y
+#check (lt_irrefl x : ¬ (x < x))
+#check (lt_trans : x < y → y < z → x < z)
+#check (lt_of_le_of_lt : x ≤ y → y < z → x < z)
+#check (lt_of_lt_of_le : x < y → y ≤ z → x < z)
+
+example : x < y ↔ x ≤ y ∧ x ≠ y :=
+  lt_iff_le_and_ne
+
+
+

In this example, the symbol ∧ stands for “and,” +the symbol ¬ stands for “not,” and +x ≠ y abbreviates ¬ (x = y). +In Chapter 3, you will learn how to use +these logical connectives to prove that < +has the properties indicated.

+

A lattice is a structure that extends a partial +order with operations ⊓ and ⊔ that are +analogous to min and max on the real numbers:

+
variable {α : Type*} [Lattice α]
+variable (x y z : α)
+
+#check x ⊓ y
+#check (inf_le_left : x ⊓ y ≤ x)
+#check (inf_le_right : x ⊓ y ≤ y)
+#check (le_inf : z ≤ x → z ≤ y → z ≤ x ⊓ y)
+#check x ⊔ y
+#check (le_sup_left : x ≤ x ⊔ y)
+#check (le_sup_right : y ≤ x ⊔ y)
+#check (sup_le : x ≤ z → y ≤ z → x ⊔ y ≤ z)
+
+
+

The characterizations of ⊓ and ⊔ justify calling them +the greatest lower bound and least upper bound, respectively. +You can type them in VS code using \glb and \lub. +The symbols are also often called then infimum and +the supremum, +and Mathlib refers to them as inf and sup in +theorem names. +To further complicate matters, +they are also often called meet and join. +Therefore, if you work with lattices, +you have to keep the following dictionary in mind:

+
    +
  • ⊓ is the greatest lower bound, infimum, or meet.

  • +
  • ⊔ is the least upper bound, supremum, or join.

  • +
+

Some instances of lattices include:

+
    +
  • min and max on any total order, such as the integers or real numbers with ≤

  • +
  • ∩ and ∪ on the collection of subsets of some domain, with the ordering ⊆

  • +
  • ∧ and ∨ on boolean truth values, with ordering x ≤ y if either x is false or y is true

  • +
  • gcd and lcm on the natural numbers (or positive natural numbers), with the divisibility ordering, ∣

  • +
  • the collection of linear subspaces of a vector space, +where the greatest lower bound is given by the intersection, +the least upper bound is given by the sum of the two spaces, +and the ordering is inclusion

  • +
  • the collection of topologies on a set (or, in Lean, a type), +where the greatest lower bound of two topologies consists of +the topology that is generated by their union, +the least upper bound is their intersection, +and the ordering is reverse inclusion

  • +
+

You can check that, as with min / max and gcd / lcm, +you can prove the commutativity and associativity of the infimum and supremum +using only their characterizing axioms, +together with le_refl and le_trans.

+

Using apply le_trans when seeing a goal x ≤ z is not a great idea. +Indeed Lean has no way to guess which intermediate element y we +want to use. +So apply le_trans produces three goals that look like x ≤ ?a, ?a ≤ z +and α where ?a (probably with a more complicated auto-generated name) stands +for the mysterious y. +The last goal, with type α, is to provide the value of y. +It comes last because Lean hopes to automatically infer it from the proof of +the first goal x ≤ ?a. +In order to avoid this unappealing situation, you can use the calc tactic +to explicitly provide y. +Alternatively, you can use the trans tactic +which takes y as an argument and produces the expected goals x ≤ y and +y ≤ z. +Of course you can also avoid this issue by providing directly a full proof such as +exact le_trans inf_le_left inf_le_right, but this requires a lot more +planning.

+
example : x ⊓ y = y ⊓ x := by
+  sorry
+
+example : x ⊓ y ⊓ z = x ⊓ (y ⊓ z) := by
+  sorry
+
+example : x ⊔ y = y ⊔ x := by
+  sorry
+
+example : x ⊔ y ⊔ z = x ⊔ (y ⊔ z) := by
+  sorry
+
+
+

You can find these theorems in the Mathlib as inf_comm, inf_assoc, +sup_comm, and sup_assoc, respectively.

+

Another good exercise is to prove the absorption laws +using only those axioms:

+
theorem absorb1 : x ⊓ (x ⊔ y) = x := by
+  sorry
+
+theorem absorb2 : x ⊔ x ⊓ y = x := by
+  sorry
+
+
+

These can be found in Mathlib with the names inf_sup_self and sup_inf_self.

+

A lattice that satisfies the additional identities +x ⊓ (y ⊔ z) = (x ⊓ y) ⊔ (x ⊓ z) and +x ⊔ (y ⊓ z) = (x ⊔ y) ⊓ (x ⊔ z) +is called a distributive lattice. Lean knows about these too:

+
variable {α : Type*} [DistribLattice α]
+variable (x y z : α)
+
+#check (inf_sup_left x y z : x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z)
+#check (inf_sup_right x y z : (x ⊔ y) ⊓ z = x ⊓ z ⊔ y ⊓ z)
+#check (sup_inf_left x y z : x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z))
+#check (sup_inf_right x y z : x ⊓ y ⊔ z = (x ⊔ z) ⊓ (y ⊔ z))
+
+
+

The left and right versions are easily shown to be +equivalent, given the commutativity of ⊓ and ⊔. +It is a good exercise to show that not every lattice +is distributive +by providing an explicit description of a +nondistributive lattice with finitely many elements. +It is also a good exercise to show that in any lattice, +either distributivity law implies the other:

+
variable {α : Type*} [Lattice α]
+variable (a b c : α)
+
+example (h : ∀ x y z : α, x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z) : a ⊔ b ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) := by
+  sorry
+
+example (h : ∀ x y z : α, x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z)) : a ⊓ (b ⊔ c) = a ⊓ b ⊔ a ⊓ c := by
+  sorry
+
+
+

It is possible to combine axiomatic structures into larger ones. +For example, a strict ordered ring consists of a ring together +with a partial order on the carrier +satisfying additional axioms that say that the ring operations +are compatible with the order:

+
variable {R : Type*} [Ring R] [PartialOrder R] [IsStrictOrderedRing R]
+variable (a b c : R)
+
+#check (add_le_add_right : a ≤ b → ∀ c, c + a ≤ c + b)
+#check (mul_pos : 0 < a → 0 < b → 0 < a * b)
+
+
+

Chapter 3 will provide the means to derive the following from mul_pos +and the definition of <:

+
#check (mul_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a * b)
+
+
+

It is then an extended exercise to show that many common facts +used to reason about arithmetic and the ordering on the real +numbers hold generically for any ordered ring. +Here are a couple of examples you can try, +using only properties of rings, partial orders, and the facts +enumerated in the last two examples (beware that those rings are +not assumed to be commutative, so the ring tactic is not available):

+
example (h : a ≤ b) : 0 ≤ b - a := by
+  sorry
+
+example (h: 0 ≤ b - a) : a ≤ b := by
+  sorry
+
+example (h : a ≤ b) (h' : 0 ≤ c) : a * c ≤ b * c := by
+  sorry
+
+
+

Finally, here is one last example. +A metric space consists of a set equipped with a notion of +distance, dist x y, +mapping any pair of elements to a real number. +The distance function is assumed to satisfy the following axioms:

+
variable {X : Type*} [MetricSpace X]
+variable (x y z : X)
+
+#check (dist_self x : dist x x = 0)
+#check (dist_comm x y : dist x y = dist y x)
+#check (dist_triangle x y z : dist x z ≤ dist x y + dist y z)
+
+
+

Having mastered this section, +you can show that it follows from these axioms that distances are +always nonnegative:

+
example (x y : X) : 0 ≤ dist x y := by
+  sorry
+
+
+

As you may have guessed, this theorem is called dist_nonneg in Mathlib.

+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C03_Logic.html b/dev/vendor/mathematics_in_lean/html/C03_Logic.html new file mode 100644 index 0000000..676f74b --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C03_Logic.html @@ -0,0 +1,1876 @@ + + + + + + + + + 3. Logic — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

3. Logic

+

In the last chapter, we dealt with equations, inequalities, +and basic mathematical statements like +“\(x\) divides \(y\).” +Complex mathematical statements are built up from +simple ones like these +using logical terms like “and,” “or,” “not,” and +“if … then,” “every,” and “some.” +In this chapter, we show you how to work with statements +that are built up in this way.

+
+

3.1. Implication and the Universal Quantifier

+

Consider the statement after the #check:

+
#check ∀ x : ℝ, 0 ≤ x → |x| = x
+
+
+

In words, we would say “for every real number x, if 0 ≤ x then +the absolute value of x equals x”. +We can also have more complicated statements like:

+
#check ∀ x y ε : ℝ, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε
+
+
+

In words, we would say “for every x, y, and ε, +if 0 < ε ≤ 1, the absolute value of x is less than ε, +and the absolute value of y is less than ε, +then the absolute value of x * y is less than ε.” +In Lean, in a sequence of implications there are +implicit parentheses grouped to the right. +So the expression above means +“if 0 < ε then if ε ≤ 1 then if |x| < ε …” +As a result, the expression says that all the +assumptions together imply the conclusion.

+

You have already seen that even though the universal quantifier +in this statement +ranges over objects and the implication arrows introduce hypotheses, +Lean treats the two in very similar ways. +In particular, if you have proved a theorem of that form, +you can apply it to objects and hypotheses in the same way. +We will use as an example the following statement that we will help you to prove a +bit later:

+
theorem my_lemma : ∀ x y ε : ℝ, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε :=
+  sorry
+
+section
+variable (a b δ : ℝ)
+variable (h₀ : 0 < δ) (h₁ : δ ≤ 1)
+variable (ha : |a| < δ) (hb : |b| < δ)
+
+#check my_lemma a b δ
+#check my_lemma a b δ h₀ h₁
+#check my_lemma a b δ h₀ h₁ ha hb
+
+end
+
+
+

You have also already seen that it is common in Lean +to use curly brackets to make quantified variables implicit +when they can be inferred from subsequent hypotheses. +When we do that, we can just apply a lemma to the hypotheses without +mentioning the objects.

+
theorem my_lemma2 : ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε :=
+  sorry
+
+section
+variable (a b δ : ℝ)
+variable (h₀ : 0 < δ) (h₁ : δ ≤ 1)
+variable (ha : |a| < δ) (hb : |b| < δ)
+
+#check my_lemma2 h₀ h₁ ha hb
+
+end
+
+
+

At this stage, you also know that if you use +the apply tactic to apply my_lemma +to a goal of the form |a * b| < δ, +you are left with new goals that require you to prove +each of the hypotheses.

+

To prove a statement like this, use the intro tactic. +Take a look at what it does in this example:

+
theorem my_lemma3 :
+    ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε := by
+  intro x y ε epos ele1 xlt ylt
+  sorry
+
+
+

We can use any names we want for the universally quantified variables; +they do not have to be x, y, and ε. +Notice that we have to introduce the variables +even though they are marked implicit: +making them implicit means that we leave them out when +we write an expression using my_lemma, +but they are still an essential part of the statement +that we are proving. +After the intro command, +the goal is what it would have been at the start if we +listed all the variables and hypotheses before the colon, +as we did in the last section. +In a moment, we will see why it is sometimes necessary to +introduce variables and hypotheses after the proof begins.

+

To help you prove the lemma, we will start you off:

+
theorem my_lemma4 :
+    ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → |x| < ε → |y| < ε → |x * y| < ε := by
+  intro x y ε epos ele1 xlt ylt
+  calc
+    |x * y| = |x| * |y| := sorry
+    _ ≤ |x| * ε := sorry
+    _ < 1 * ε := sorry
+    _ = ε := sorry
+
+
+

Finish the proof using the theorems +abs_mul, mul_le_mul, abs_nonneg, +mul_lt_mul_of_pos_right, and one_mul. +Remember that you can find theorems like these using +Ctrl-space completion. +Remember also that you can use .mp and .mpr +or .1 and .2 to extract the two directions +of an if-and-only-if statement.

+

Universal quantifiers are often hidden in definitions, +and Lean will unfold definitions to expose them when necessary. +For example, let’s define two predicates, +FnUb f a and FnLb f a, +where f is a function from the real numbers to the real +numbers and a is a real number. +The first says that a is an upper bound on the +values of f, +and the second says that a is a lower bound +on the values of f.

+
def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop :=
+  ∀ x, f x ≤ a
+
+def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop :=
+  ∀ x, a ≤ f x
+
+
+

In the next example, fun x ↦ f x + g x is the +function that maps x to f x + g x. Going from the expression f x + g x +to this function is called a lambda abstraction in type theory.

+
example (hfa : FnUb f a) (hgb : FnUb g b) : FnUb (fun x ↦ f x + g x) (a + b) := by
+  intro x
+  dsimp
+  apply add_le_add
+  apply hfa
+  apply hgb
+
+
+

Applying intro to the goal FnUb (fun x ↦ f x + g x) (a + b) +forces Lean to unfold the definition of FnUb +and introduce x for the universal quantifier. +The goal is then (fun (x : ℝ) ↦ f x + g x) x ≤ a + b. +But applying (fun x ↦ f x + g x) to x should result in f x + g x, +and the dsimp command performs that simplification. +(The “d” stands for “definitional.”) +You can delete that command and the proof still works; +Lean would have to perform that contraction anyhow to make +sense of the next apply. +The dsimp command simply makes the goal more readable +and helps us figure out what to do next. +Another option is to use the change tactic +by writing change f x + g x ≤ a + b. +This helps make the proof more readable, +and gives you more control over how the goal is transformed.

+

The rest of the proof is routine. +The last two apply commands force Lean to unfold the definitions +of FnUb in the hypotheses. +Try carrying out similar proofs of these:

+
example (hfa : FnLb f a) (hgb : FnLb g b) : FnLb (fun x ↦ f x + g x) (a + b) :=
+  sorry
+
+example (nnf : FnLb f 0) (nng : FnLb g 0) : FnLb (fun x ↦ f x * g x) 0 :=
+  sorry
+
+example (hfa : FnUb f a) (hgb : FnUb g b) (nng : FnLb g 0) (nna : 0 ≤ a) :
+    FnUb (fun x ↦ f x * g x) (a * b) :=
+  sorry
+
+
+

Even though we have defined FnUb and FnLb for functions +from the reals to the reals, +you should recognize that the definitions and proofs are much +more general. +The definitions make sense for functions between any two types +for which there is a notion of order on the codomain. +Checking the type of the theorem add_le_add shows that it holds +of any monoid structure that respects the relevant order; +the details of what that means don’t matter now, +but it is worth knowing that the natural numbers, integers, rationals, +and real numbers are all instances. +So if we prove the theorem fnUb_add at that level of generality, +it will apply in all these instances.

+
variable {α : Type*} {R : Type*} [AddCommMonoid R] [PartialOrder R] [IsOrderedCancelAddMonoid R]
+
+#check add_le_add
+
+def FnUb' (f : α → R) (a : R) : Prop :=
+  ∀ x, f x ≤ a
+
+theorem fnUb_add {f g : α → R} {a b : R} (hfa : FnUb' f a) (hgb : FnUb' g b) :
+    FnUb' (fun x ↦ f x + g x) (a + b) := fun x ↦ add_le_add (hfa x) (hgb x)
+
+
+

You have already seen square brackets like these in +Section Section 2.2, +though we still haven’t explained what they mean. +For concreteness, we will stick to the real numbers +for most of our examples, +but it is worth knowing that Mathlib contains definitions and theorems +that work at a high level of generality.

+

For another example of a hidden universal quantifier, +Mathlib defines a predicate Monotone, +which says that a function is nondecreasing in its arguments:

+
example (f : ℝ → ℝ) (h : Monotone f) : ∀ {a b}, a ≤ b → f a ≤ f b :=
+  @h
+
+
+

The property Monotone f is defined to be exactly the expression +after the colon. We need to put the @ symbol before h because +if we don’t, +Lean expands the implicit arguments to h and inserts placeholders.

+

Proving statements about monotonicity +involves using intro to introduce two variables, +say, a and b, and the hypothesis a ≤ b. +To use a monotonicity hypothesis, +you can apply it to suitable arguments and hypotheses, +and then apply the resulting expression to the goal. +Or you can apply it to the goal and let Lean help you +work backwards by displaying the remaining hypotheses +as new subgoals.

+
example (mf : Monotone f) (mg : Monotone g) : Monotone fun x ↦ f x + g x := by
+  intro a b aleb
+  apply add_le_add
+  apply mf aleb
+  apply mg aleb
+
+
+

When a proof is this short, it is often convenient +to give a proof term instead. +To describe a proof that temporarily introduces objects +a and b and a hypothesis aleb, +Lean uses the notation fun a b aleb ↦ .... +This is analogous to the way that an expression +like fun x ↦ x^2 describes a function +by temporarily naming an object, x, +and then using it to describe a value. +So the intro command in the previous proof +corresponds to the lambda abstraction in the next proof term. +The apply commands then correspond to building +the application of the theorem to its arguments.

+
example (mf : Monotone f) (mg : Monotone g) : Monotone fun x ↦ f x + g x :=
+  fun _a _b aleb ↦ add_le_add (mf aleb) (mg aleb)
+
+
+

Here is a useful trick: if you start writing +the proof term fun a b aleb ↦ _ using +an underscore where the rest of the +expression should go, +Lean will flag an error, +indicating that it can’t guess the value of that expression. +If you check the Lean InfoView window in VS Code or +hover over the squiggly error marker, +Lean will show you the goal that the remaining +expression has to solve.

+

You’ll notice Lean prints warnings about the above proof, saying +that a and b are not used in the body of the function. +This is a general mechanism that is useful for instance to avoid having +unnecessary assumptions in a theorem. Here it is not really telling us +anything useful. We can either disable this warning until the end of the +current section by writing +set_option linter.unusedVariables false +or only in the example by writing +set_option linter.unusedVariables false in +above the example.

+

We can also replace a and b by underscores to tell Lean we don’t +want to name them. Lean will then use auto-generated inaccessible names +such as x✝. Alternatively we can prefix our names with underscores to +tell Lean we do not intend to use them.

+

Try proving the following examples, with either tactics or proof terms:

+
example {c : ℝ} (mf : Monotone f) (nnc : 0 ≤ c) : Monotone fun x ↦ c * f x :=
+  sorry
+
+example (mf : Monotone f) (mg : Monotone g) : Monotone fun x ↦ f (g x) :=
+  sorry
+
+
+

Here are some more examples. +A function \(f\) from \(\Bbb R\) to +\(\Bbb R\) is said to be even if +\(f(-x) = f(x)\) for every \(x\), +and odd if \(f(-x) = -f(x)\) for every \(x\). +The following example defines these two notions formally +and establishes one fact about them. +You can complete the proofs of the others.

+
def FnEven (f : ℝ → ℝ) : Prop :=
+  ∀ x, f x = f (-x)
+
+def FnOdd (f : ℝ → ℝ) : Prop :=
+  ∀ x, f x = -f (-x)
+
+example (ef : FnEven f) (eg : FnEven g) : FnEven fun x ↦ f x + g x := by
+  intro x
+  calc
+    (fun x ↦ f x + g x) x = f x + g x := rfl
+    _ = f (-x) + g (-x) := by rw [ef, eg]
+
+
+example (of : FnOdd f) (og : FnOdd g) : FnEven fun x ↦ f x * g x := by
+  sorry
+
+example (ef : FnEven f) (og : FnOdd g) : FnOdd fun x ↦ f x * g x := by
+  sorry
+
+example (ef : FnEven f) (og : FnOdd g) : FnEven fun x ↦ f (g x) := by
+  sorry
+
+
+

The first proof can be shortened using dsimp or change +to get rid of the lambda abstraction. +But you can check that the subsequent rw won’t work +unless we get rid of the lambda abstraction explicitly, +because otherwise it cannot find the patterns f x and g x +in the expression. +Contrary to some other tactics, rw operates on the syntactic level, +it won’t unfold definitions or apply reductions for you +(it has a variant called erw that tries a little harder in this +direction, but not much harder).

+

You can find implicit universal quantifiers all over the place, +once you know how to spot them.

+

Mathlib includes a good library for manipulating sets. Recall that Lean does not +use foundations based on set theory, so here the word set has its mundane meaning +of a collection of mathematical objects of some given type α. +If x has type α and s has type Set α, then x ∈ s is a proposition +that asserts that x is an element of s. If y has some different type β then the +expression y ∈ s makes no sense. Here “makes no sense” means “has no type hence Lean does not +accept it as a well-formed statement”. This contrasts with Zermelo-Fraenkel set theory for instance +where a ∈ b is a well-formed statement for both mathematical objects a and b. +For instance sin ∈ cos is a well-formed statement in ZF. This defect of set theoretic +foundations is an important motivation for not using it in a proof assistant which is meant to assist +us by detecting meaningless expressions. In Lean sin has type ℝ → ℝ and cos has type +ℝ → ℝ which is not equal to Set (ℝ → ℝ), even after unfolding definitions, so the statement +sin ∈ cos makes no sense. +One can also use Lean to work on set theory itself. For instance the independence of the continuum +hypothesis from the axioms of Zermelo-Fraenkel has been formalized in Lean. But such a meta-theory +of set theory is completely beyond the scope of this book.

+

If s and t are of type Set α, +then the subset relation s ⊆ t is defined to mean +∀ {x : α}, x ∈ s → x ∈ t. +The variable in the quantifier is marked implicit so that +given h : s ⊆ t and h' : x ∈ s, +we can write h h' as justification for x ∈ t. +The following example provides a tactic proof and a proof term +justifying the reflexivity of the subset relation, +and asks you to do the same for transitivity.

+
variable {α : Type*} (r s t : Set α)
+
+example : s ⊆ s := by
+  intro x xs
+  exact xs
+
+theorem Subset.refl : s ⊆ s := fun _x xs ↦ xs
+
+theorem Subset.trans : r ⊆ s → s ⊆ t → r ⊆ t := by
+  sorry
+
+
+

Just as we defined FnUb for functions, +we can define SetUb s a to mean that a +is an upper bound on the set s, +assuming s is a set of elements of some type that +has an order associated with it. +In the next example, we ask you to prove that +if a is a bound on s and a ≤ b, +then b is a bound on s as well.

+
variable {α : Type*} [PartialOrder α]
+variable (s : Set α) (a b : α)
+
+def SetUb (s : Set α) (a : α) :=
+  ∀ x, x ∈ s → x ≤ a
+
+example (h : SetUb s a) (h' : a ≤ b) : SetUb s b :=
+  sorry
+
+
+

We close this section with one last important example. +A function \(f\) is said to be injective if for +every \(x_1\) and \(x_2\), +if \(f(x_1) = f(x_2)\) then \(x_1 = x_2\). +Mathlib defines Function.Injective f with +x₁ and x₂ implicit. +The next example shows that, on the real numbers, +any function that adds a constant is injective. +We then ask you to show that multiplication by a nonzero +constant is also injective, using the lemma name in the example as a source +of inspiration. Recall you should use Ctrl-space completion after guessing the beginning of +a lemma name.

+
open Function
+
+example (c : ℝ) : Injective fun x ↦ x + c := by
+  intro x₁ x₂ h'
+  exact (add_left_inj c).mp h'
+
+example {c : ℝ} (h : c ≠ 0) : Injective fun x ↦ c * x := by
+  sorry
+
+
+

Finally, show that the composition of two injective functions is injective:

+
variable {α : Type*} {β : Type*} {γ : Type*}
+variable {g : β → γ} {f : α → β}
+
+example (injg : Injective g) (injf : Injective f) : Injective fun x ↦ g (f x) := by
+  sorry
+
+
+
+
+

3.2. The Existential Quantifier

+

The existential quantifier, which can be entered as \ex in VS Code, +is used to represent the phrase “there exists.” +The formal expression ∃ x : ℝ, 2 < x ∧ x < 3 in Lean says +that there is a real number between 2 and 3. +(We will discuss the conjunction symbol, ∧, in Section 3.4.) +The canonical way to prove such a statement is to exhibit a real number +and show that it has the stated property. +The number 2.5, which we can enter as 5 / 2 +or (5 : ℝ) / 2 when Lean cannot infer from context that we have +the real numbers in mind, has the required property, +and the norm_num tactic can prove that it meets the description.

+

There are a few ways we can put the information together. +Given a goal that begins with an existential quantifier, +the use tactic is used to provide the object, +leaving the goal of proving the property.

+
example : ∃ x : ℝ, 2 < x ∧ x < 3 := by
+  use 5 / 2
+  norm_num
+
+
+

You can give the use tactic proofs as well as data:

+
example : ∃ x : ℝ, 2 < x ∧ x < 3 := by
+  have h1 : 2 < (5 : ℝ) / 2 := by norm_num
+  have h2 : (5 : ℝ) / 2 < 3 := by norm_num
+  use 5 / 2, h1, h2
+
+
+

In fact, the use tactic automatically tries to use available assumptions as well.

+
example : ∃ x : ℝ, 2 < x ∧ x < 3 := by
+  have h : 2 < (5 : ℝ) / 2 ∧ (5 : ℝ) / 2 < 3 := by norm_num
+  use 5 / 2
+
+
+

Alternatively, we can use Lean’s anonymous constructor notation +to construct a proof of an existential quantifier.

+
example : ∃ x : ℝ, 2 < x ∧ x < 3 :=
+  have h : 2 < (5 : ℝ) / 2 ∧ (5 : ℝ) / 2 < 3 := by norm_num
+  ⟨5 / 2, h⟩
+
+
+

Notice that there is no by; here we are giving an explicit proof term. +The left and right angle brackets, +which can be entered as \< and \> respectively, +tell Lean to put together the given data using +whatever construction is appropriate +for the current goal. +We can use the notation without going first into tactic mode:

+
example : ∃ x : ℝ, 2 < x ∧ x < 3 :=
+  ⟨5 / 2, by norm_num⟩
+
+
+

So now we know how to prove an exists statement. +But how do we use one? +If we know that there exists an object with a certain property, +we should be able to give a name to an arbitrary one +and reason about it. +For example, remember the predicates FnUb f a and FnLb f a +from the last section, +which say that a is an upper bound or lower bound on f, +respectively. +We can use the existential quantifier to say that “f is bounded” +without specifying the bound:

+
def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop :=
+  ∀ x, f x ≤ a
+
+def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop :=
+  ∀ x, a ≤ f x
+
+def FnHasUb (f : ℝ → ℝ) :=
+  ∃ a, FnUb f a
+
+def FnHasLb (f : ℝ → ℝ) :=
+  ∃ a, FnLb f a
+
+
+

We can use the theorem FnUb_add from the last section +to prove that if f and g have upper bounds, +then so does fun x ↦ f x + g x.

+
variable {f g : ℝ → ℝ}
+
+example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := by
+  rcases ubf with ⟨a, ubfa⟩
+  rcases ubg with ⟨b, ubgb⟩
+  use a + b
+  apply fnUb_add ubfa ubgb
+
+
+

The rcases tactic unpacks the information +in the existential quantifier. +The annotations like ⟨a, ubfa⟩, written with the +same angle brackets as the anonymous constructors, +are known as patterns, and they describe the information +that we expect to find when we unpack the main argument. +Given the hypothesis ubf that there is an upper bound +for f, +rcases ubf with ⟨a, ubfa⟩ adds a new variable a +for an upper bound to the context, +together with the hypothesis ubfa that it has the given property. +The goal is left unchanged; +what has changed is that we can now use +the new object and the new hypothesis +to prove the goal. +This is a common method of reasoning in mathematics: +we unpack objects whose existence is asserted or implied +by some hypothesis, and then use it to establish the existence +of something else.

+

Try using this method to establish the following. +You might find it useful to turn some of the examples +from the last section into named theorems, +as we did with fn_ub_add, +or you can insert the arguments directly +into the proofs.

+
example (lbf : FnHasLb f) (lbg : FnHasLb g) : FnHasLb fun x ↦ f x + g x := by
+  sorry
+
+example {c : ℝ} (ubf : FnHasUb f) (h : c ≥ 0) : FnHasUb fun x ↦ c * f x := by
+  sorry
+
+
+

The “r” in rcases stands for “recursive,” because it allows +us to use arbitrarily complex patterns to unpack nested data. +The rintro tactic +is a combination of intro and rcases:

+
example : FnHasUb f → FnHasUb g → FnHasUb fun x ↦ f x + g x := by
+  rintro ⟨a, ubfa⟩ ⟨b, ubgb⟩
+  exact ⟨a + b, fnUb_add ubfa ubgb⟩
+
+
+

In fact, Lean also supports a pattern-matching fun +in expressions and proof terms:

+
example : FnHasUb f → FnHasUb g → FnHasUb fun x ↦ f x + g x :=
+  fun ⟨a, ubfa⟩ ⟨b, ubgb⟩ ↦ ⟨a + b, fnUb_add ubfa ubgb⟩
+
+
+

The task of unpacking information in a hypothesis is +so important that Lean and Mathlib provide a number of +ways to do it. For example, the obtain tactic provides suggestive syntax:

+
example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := by
+  obtain ⟨a, ubfa⟩ := ubf
+  obtain ⟨b, ubgb⟩ := ubg
+  exact ⟨a + b, fnUb_add ubfa ubgb⟩
+
+
+

Think of the first obtain instruction as matching the “contents” of ubf +with the given pattern and assigning the components to the named variables. +rcases and obtain are said to destruct their arguments.

+

Lean also supports syntax that is similar to that used in other functional programming +languages:

+
example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := by
+  cases ubf
+  case intro a ubfa =>
+    cases ubg
+    case intro b ubgb =>
+      exact ⟨a + b, fnUb_add ubfa ubgb⟩
+
+example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := by
+  cases ubf
+  next a ubfa =>
+    cases ubg
+    next b ubgb =>
+      exact ⟨a + b, fnUb_add ubfa ubgb⟩
+
+example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x := by
+  match ubf, ubg with
+    | ⟨a, ubfa⟩, ⟨b, ubgb⟩ =>
+      exact ⟨a + b, fnUb_add ubfa ubgb⟩
+
+example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x ↦ f x + g x :=
+  match ubf, ubg with
+    | ⟨a, ubfa⟩, ⟨b, ubgb⟩ =>
+      ⟨a + b, fnUb_add ubfa ubgb⟩
+
+
+

In the first example, if you put your cursor after cases ubf, +you will see that the tactic produces a single goal, which Lean has tagged +intro. (The particular name chosen comes from the internal name for +the axiomatic primitive that builds a proof of an existential statement.) +The case tactic then names the components. The second example is similar, +except using next instead of case means that you can avoid mentioning +intro. The word match in the last two examples highlights that +what we are doing here is what computer scientists call “pattern matching.” +Notice that the third proof begins by by, after which the tactic version +of match expects a tactic proof on the right side of the arrow. +The last example is a proof term: there are no tactics in sight.

+

For the rest of this book, we will stick to rcases, rintro, and obtain, +as the preferred ways of using an existential quantifier. +But it can’t hurt to see the alternative syntax, especially if there is +a chance you will find yourself in the company of computer scientists.

+

To illustrate one way that rcases can be used, +we prove an old mathematical chestnut: +if two integers x and y can each be written as +a sum of two squares, +then so can their product, x * y. +In fact, the statement is true for any commutative +ring, not just the integers. +In the next example, rcases unpacks two existential +quantifiers at once. +We then provide the magic values needed to express x * y +as a sum of squares as a list to the use statement, +and we use ring to verify that they work.

+
variable {α : Type*} [CommRing α]
+
+def SumOfSquares (x : α) :=
+  ∃ a b, x = a ^ 2 + b ^ 2
+
+theorem sumOfSquares_mul {x y : α} (sosx : SumOfSquares x) (sosy : SumOfSquares y) :
+    SumOfSquares (x * y) := by
+  rcases sosx with ⟨a, b, xeq⟩
+  rcases sosy with ⟨c, d, yeq⟩
+  rw [xeq, yeq]
+  use a * c - b * d, a * d + b * c
+  ring
+
+
+

This proof doesn’t provide much insight, +but here is one way to motivate it. +A Gaussian integer is a number of the form \(a + bi\) +where \(a\) and \(b\) are integers and \(i = \sqrt{-1}\). +The norm of the Gaussian integer \(a + bi\) is, by definition, +\(a^2 + b^2\). +So the norm of a Gaussian integer is a sum of squares, +and any sum of squares can be expressed in this way. +The theorem above reflects the fact that norm of a product of +Gaussian integers is the product of their norms: +if \(x\) is the norm of \(a + bi\) and +\(y\) is the norm of \(c + di\), +then \(xy\) is the norm of \((a + bi) (c + di)\). +Our cryptic proof illustrates the fact that +the proof that is easiest to formalize isn’t always +the most perspicuous one. +In Section 7.3, +we will provide you with the means to define the Gaussian +integers and use them to provide an alternative proof.

+

The pattern of unpacking an equation inside an existential quantifier +and then using it to rewrite an expression in the goal +comes up often, +so much so that the rcases tactic provides +an abbreviation: +if you use the keyword rfl in place of a new identifier, +rcases does the rewriting automatically (this trick doesn’t work +with pattern-matching lambdas).

+
theorem sumOfSquares_mul' {x y : α} (sosx : SumOfSquares x) (sosy : SumOfSquares y) :
+    SumOfSquares (x * y) := by
+  rcases sosx with ⟨a, b, rfl⟩
+  rcases sosy with ⟨c, d, rfl⟩
+  use a * c - b * d, a * d + b * c
+  ring
+
+
+

As with the universal quantifier, +you can find existential quantifiers hidden all over +if you know how to spot them. +For example, divisibility is implicitly an “exists” statement.

+
example (divab : a ∣ b) (divbc : b ∣ c) : a ∣ c := by
+  rcases divab with ⟨d, beq⟩
+  rcases divbc with ⟨e, ceq⟩
+  rw [ceq, beq]
+  use d * e; ring
+
+
+

And once again, this provides a nice setting for using +rcases with rfl. +Try it out in the proof above. +It feels pretty good!

+

Then try proving the following:

+
example (divab : a ∣ b) (divac : a ∣ c) : a ∣ b + c := by
+  sorry
+
+
+

For another important example, a function \(f : \alpha \to \beta\) +is said to be surjective if for every \(y\) in the +codomain, \(\beta\), +there is an \(x\) in the domain, \(\alpha\), +such that \(f(x) = y\). +Notice that this statement includes both a universal +and an existential quantifier, which explains +why the next example makes use of both intro and use.

+
example {c : ℝ} : Surjective fun x ↦ x + c := by
+  intro y
+  use y - c
+  dsimp; ring
+
+
+

Try this example yourself using the theorem mul_div_cancel₀.:

+
example {c : ℝ} (h : c ≠ 0) : Surjective fun x ↦ c * x := by
+  sorry
+
+
+

At this point, it is worth mentioning that there is a tactic, field_simp, +that will often clear denominators in a useful way. +It can be used in conjunction with the ring tactic.

+
example (x y : ℝ) (h : x - y ≠ 0) : (x ^ 2 - y ^ 2) / (x - y) = x + y := by
+  field_simp [h]
+  ring
+
+
+

The next example uses a surjectivity hypothesis +by applying it to a suitable value. +Note that you can use rcases with any expression, +not just a hypothesis.

+
example {f : ℝ → ℝ} (h : Surjective f) : ∃ x, f x ^ 2 = 4 := by
+  rcases h 2 with ⟨x, hx⟩
+  use x
+  rw [hx]
+  norm_num
+
+
+

See if you can use these methods to show that +the composition of surjective functions is surjective.

+
variable {α : Type*} {β : Type*} {γ : Type*}
+variable {g : β → γ} {f : α → β}
+
+example (surjg : Surjective g) (surjf : Surjective f) : Surjective fun x ↦ g (f x) := by
+  sorry
+
+
+
+
+

3.3. Negation

+

The symbol ¬ is meant to express negation, +so ¬ x < y says that x is not less than y, +¬ x = y (or, equivalently, x ≠ y) says that +x is not equal to y, +and ¬ ∃ z, x < z ∧ z < y says that there does not exist a z +strictly between x and y. +In Lean, the notation ¬ A abbreviates A → False, +which you can think of as saying that A implies a contradiction. +Practically speaking, this means that you already know something +about how to work with negations: +you can prove ¬ A by introducing a hypothesis h : A +and proving False, +and if you have h : ¬ A and h' : A, +then applying h to h' yields False.

+

To illustrate, consider the irreflexivity principle lt_irrefl +for a strict order, +which says that we have ¬ a < a for every a. +The asymmetry principle lt_asymm says that we have +a < b → ¬ b < a. Let’s show that lt_asymm follows +from lt_irrefl.

+
example (h : a < b) : ¬b < a := by
+  intro h'
+  have : a < a := lt_trans h h'
+  apply lt_irrefl a this
+
+
+

This example introduces a couple of new tricks. +First, when you use have without providing +a label, +Lean uses the name this, +providing a convenient way to refer back to it. +Because the proof is so short, we provide an explicit proof term. +But what you should really be paying attention to in this +proof is the result of the intro tactic, +which leaves a goal of False, +and the fact that we eventually prove False +by applying lt_irrefl to a proof of a < a.

+

Here is another example, which uses the +predicate FnHasUb defined in the last section, +which says that a function has an upper bound.

+
example (h : ∀ a, ∃ x, f x > a) : ¬FnHasUb f := by
+  intro fnub
+  rcases fnub with ⟨a, fnuba⟩
+  rcases h a with ⟨x, hx⟩
+  have : f x ≤ a := fnuba x
+  linarith
+
+
+

Remember that it is often convenient to use linarith +when a goal follows from linear equations and +inequalities that are in the context.

+

See if you can prove these in a similar way:

+
example (h : ∀ a, ∃ x, f x < a) : ¬FnHasLb f :=
+  sorry
+
+example : ¬FnHasUb fun x ↦ x :=
+  sorry
+
+
+

Mathlib offers a number of useful theorems for relating orders +and negations:

+
#check (not_le_of_gt : a > b → ¬a ≤ b)
+#check (not_lt_of_ge : a ≥ b → ¬a < b)
+#check (lt_of_not_ge : ¬a ≥ b → a < b)
+#check (le_of_not_gt : ¬a > b → a ≤ b)
+
+
+

Recall the predicate Monotone f, +which says that f is nondecreasing. +Use some of the theorems just enumerated to prove the following:

+
example (h : Monotone f) (h' : f a < f b) : a < b := by
+  sorry
+
+example (h : a ≤ b) (h' : f b < f a) : ¬Monotone f := by
+  sorry
+
+
+

We can show that the first example in the last snippet +cannot be proved if we replace < by ≤. +Notice that we can prove the negation of a universally +quantified statement by giving a counterexample. +Complete the proof.

+
example : ¬∀ {f : ℝ → ℝ}, Monotone f → ∀ {a b}, f a ≤ f b → a ≤ b := by
+  intro h
+  let f := fun x : ℝ ↦ (0 : ℝ)
+  have monof : Monotone f := by sorry
+  have h' : f 1 ≤ f 0 := le_refl _
+  sorry
+
+
+

This example introduces the let tactic, +which adds a local definition to the context. +If you put the cursor after the let command, +in the goal window you will see that the definition +f : ℝ → ℝ := fun x ↦ 0 has been added to the context. +Lean will unfold the definition of f when it has to. +In particular, when we prove f 1 ≤ f 0 with le_refl, +Lean reduces f 1 and f 0 to 0.

+

Use le_of_not_gt to prove the following:

+
example (x : ℝ) (h : ∀ ε > 0, x < ε) : x ≤ 0 := by
+  sorry
+
+
+

Implicit in many of the proofs we have just done +is the fact that if P is any property, +saying that there is nothing with property P +is the same as saying that everything fails to have +property P, +and saying that not everything has property P +is equivalent to saying that something fails to have property P. +In other words, all four of the following implications +are valid (but one of them cannot be proved with what we explained so +far):

+
variable {α : Type*} (P : α → Prop) (Q : Prop)
+
+example (h : ¬∃ x, P x) : ∀ x, ¬P x := by
+  sorry
+
+example (h : ∀ x, ¬P x) : ¬∃ x, P x := by
+  sorry
+
+example (h : ¬∀ x, P x) : ∃ x, ¬P x := by
+  sorry
+
+example (h : ∃ x, ¬P x) : ¬∀ x, P x := by
+  sorry
+
+
+

The first, second, and fourth are straightforward to +prove using the methods you have already seen. +We encourage you to try it. +The third is more difficult, however, +because it concludes that an object exists +from the fact that its nonexistence is contradictory. +This is an instance of classical mathematical reasoning. +We can use proof by contradiction +to prove the third implication as follows.

+
example (h : ¬∀ x, P x) : ∃ x, ¬P x := by
+  by_contra h'
+  apply h
+  intro x
+  show P x
+  by_contra h''
+  exact h' ⟨x, h''⟩
+
+
+

Make sure you understand how this works. +The by_contra tactic +allows us to prove a goal Q by assuming ¬ Q +and deriving a contradiction. +In fact, it is equivalent to using the +equivalence not_not : ¬ ¬ Q ↔ Q. +Confirm that you can prove the forward direction +of this equivalence using by_contra, +while the reverse direction follows from the +ordinary rules for negation.

+
example (h : ¬¬Q) : Q := by
+  sorry
+
+example (h : Q) : ¬¬Q := by
+  sorry
+
+
+

Use proof by contradiction to establish the following, +which is the converse of one of the implications we proved above. +(Hint: use intro first.)

+
example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by
+  sorry
+
+
+

It is often tedious to work with compound statements with +a negation in front, +and it is a common mathematical pattern to replace such +statements with equivalent forms in which the negation +has been pushed inward. +To facilitate this, Mathlib offers a push tactic +that can push an application using registered lemmas. +In our case we will use push Not to restate negations +(this includes simplifying ¬ ¬A to A). +The command push Not at h restates the hypothesis h.

+
example (h : ¬∀ a, ∃ x, f x > a) : FnHasUb f := by
+  push Not at h
+  exact h
+
+example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by
+  dsimp only [FnHasUb, FnUb] at h
+  push Not at h
+  exact h
+
+
+

In the second example, we use dsimp to +expand the definitions of FnHasUb and FnUb. +(We need to use dsimp rather than rw +to expand FnUb, +because it appears in the scope of a quantifier.) +You can verify that in the examples above +with ¬∃ x, P x and ¬∀ x, P x, +the push tactic does the expected thing. +Without even knowing how to use the conjunction +symbol, +you should be able to use push Not +to prove the following:

+
example (h : ¬Monotone f) : ∃ x y, x ≤ y ∧ f y < f x := by
+  sorry
+
+
+

Mathlib also has a tactic, contrapose, +which transforms a goal A → B to ¬B → ¬A. +Similarly, given a goal of proving B from +hypothesis h : A, +contrapose h leaves you with a goal of proving +¬A from hypothesis ¬B. +Using contrapose! instead of contrapose +applies push Not to the goal and the relevant +hypothesis as well.

+
example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by
+  contrapose! h
+  exact h
+
+example (x : ℝ) (h : ∀ ε > 0, x ≤ ε) : x ≤ 0 := by
+  contrapose! h
+  use x / 2
+  constructor <;> linarith
+
+
+

We have not yet explained the constructor command +or the use of the semicolon after it, +but we will do that in the next section.

+

We close this section with +the principle of ex falso, +which says that anything follows from a contradiction. +In Lean, this is represented by False.elim, +which establishes False → P for any proposition P. +This may seem like a strange principle, +but it comes up fairly often. +We often prove a theorem by splitting on cases, +and sometimes we can show that one of +the cases is contradictory. +In that case, we need to assert that the contradiction +establishes the goal so we can move on to the next one. +(We will see instances of reasoning by cases in +Section 3.5.)

+

Lean provides a number of ways of closing +a goal once a contradiction has been reached.

+
example (h : 0 < 0) : a > 37 := by
+  exfalso
+  apply lt_irrefl 0 h
+
+example (h : 0 < 0) : a > 37 :=
+  absurd h (lt_irrefl 0)
+
+example (h : 0 < 0) : a > 37 := by
+  have h' : ¬0 < 0 := lt_irrefl 0
+  contradiction
+
+
+

The exfalso tactic replaces the current goal with +the goal of proving False. +Given h : P and h' : ¬ P, +the term absurd h h' establishes any proposition. +Finally, the contradiction tactic tries to close a goal +by finding a contradiction in the hypotheses, +such as a pair of the form h : P and h' : ¬ P. +Of course, in this example, linarith also works.

+
+
+

3.4. Conjunction and Iff

+

You have already seen that the conjunction symbol, ∧, +is used to express “and.” +The constructor tactic allows you to prove a statement of +the form A ∧ B +by proving A and then proving B.

+
example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬y ≤ x) : x ≤ y ∧ x ≠ y := by
+  constructor
+  · assumption
+  intro h
+  apply h₁
+  rw [h]
+
+
+

In this example, the assumption tactic +tells Lean to find an assumption that will solve the goal. +Notice that the final rw finishes the goal by +applying the reflexivity of ≤. +The following are alternative ways of carrying out +the previous examples using the anonymous constructor +angle brackets. +The first is a slick proof-term version of the +previous proof, +which drops into tactic mode at the keyword by.

+
example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬y ≤ x) : x ≤ y ∧ x ≠ y :=
+  ⟨h₀, fun h ↦ h₁ (by rw [h])⟩
+
+example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬y ≤ x) : x ≤ y ∧ x ≠ y :=
+  have h : x ≠ y := by
+    contrapose! h₁
+    rw [h₁]
+  ⟨h₀, h⟩
+
+
+

Using a conjunction instead of proving one involves unpacking the proofs of the +two parts. +You can use the rcases tactic for that, +as well as rintro or a pattern-matching fun, +all in a manner similar to the way they are used with +the existential quantifier.

+
example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by
+  rcases h with ⟨h₀, h₁⟩
+  contrapose! h₁
+  exact le_antisymm h₀ h₁
+
+example {x y : ℝ} : x ≤ y ∧ x ≠ y → ¬y ≤ x := by
+  rintro ⟨h₀, h₁⟩ h'
+  exact h₁ (le_antisymm h₀ h')
+
+example {x y : ℝ} : x ≤ y ∧ x ≠ y → ¬y ≤ x :=
+  fun ⟨h₀, h₁⟩ h' ↦ h₁ (le_antisymm h₀ h')
+
+
+

In analogy to the obtain tactic, there is also a pattern-matching have:

+
example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by
+  have ⟨h₀, h₁⟩ := h
+  contrapose! h₁
+  exact le_antisymm h₀ h₁
+
+
+

In contrast to rcases, here the have tactic leaves h in the context. +And even though we won’t use them, once again we have the computer scientists’ +pattern-matching syntax:

+
example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by
+  cases h
+  case intro h₀ h₁ =>
+    contrapose! h₁
+    exact le_antisymm h₀ h₁
+
+example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by
+  cases h
+  next h₀ h₁ =>
+    contrapose! h₁
+    exact le_antisymm h₀ h₁
+
+example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by
+  match h with
+    | ⟨h₀, h₁⟩ =>
+        contrapose! h₁
+        exact le_antisymm h₀ h₁
+
+
+

In contrast to using an existential quantifier, +you can also extract proofs of the two components +of a hypothesis h : A ∧ B +by writing h.left and h.right, +or, equivalently, h.1 and h.2.

+
example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by
+  intro h'
+  apply h.right
+  exact le_antisymm h.left h'
+
+example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x :=
+  fun h' ↦ h.right (le_antisymm h.left h')
+
+
+

Try using these techniques to come up with various ways of proving of the following:

+
example {m n : ℕ} (h : m ∣ n ∧ m ≠ n) : m ∣ n ∧ ¬n ∣ m :=
+  sorry
+
+
+

You can nest uses of ∃ and ∧ +with anonymous constructors, rintro, and rcases.

+
example : ∃ x : ℝ, 2 < x ∧ x < 4 :=
+  ⟨5 / 2, by norm_num, by norm_num⟩
+
+example (x y : ℝ) : (∃ z : ℝ, x < z ∧ z < y) → x < y := by
+  rintro ⟨z, xltz, zlty⟩
+  exact lt_trans xltz zlty
+
+example (x y : ℝ) : (∃ z : ℝ, x < z ∧ z < y) → x < y :=
+  fun ⟨_z, xltz, zlty⟩ ↦ lt_trans xltz zlty
+
+
+

Recall that prefixing z with underscore tells Lean we don’t intend to use z. +Otherwise Lean would output a warning saying z is unused.

+

You can also use the use tactic:

+
example : ∃ x : ℝ, 2 < x ∧ x < 4 := by
+  use 5 / 2
+  constructor <;> norm_num
+
+example : ∃ m n : ℕ, 4 < m ∧ m < n ∧ n < 10 ∧ Nat.Prime m ∧ Nat.Prime n := by
+  use 5
+  use 7
+  norm_num
+
+example {x y : ℝ} : x ≤ y ∧ x ≠ y → x ≤ y ∧ ¬y ≤ x := by
+  rintro ⟨h₀, h₁⟩
+  use h₀
+  exact fun h' ↦ h₁ (le_antisymm h₀ h')
+
+
+

In the first example, the <;> after the constructor command tells Lean to use +the norm_num tactic on both of the goals that result.

+

In Lean, A ↔ B is not defined to be (A → B) ∧ (B → A), +but it could have been, +and it behaves roughly the same way. +You have already seen that you can write h.mp and h.mpr +or h.1 and h.2 for the two directions of h : A ↔ B. +You can also use cases and friends. +To prove an if-and-only-if statement, +you can use constructor or angle brackets, +just as you would if you were proving a conjunction.

+
example {x y : ℝ} (h : x ≤ y) : ¬y ≤ x ↔ x ≠ y := by
+  constructor
+  · contrapose!
+    rintro rfl
+    rfl
+  contrapose!
+  exact le_antisymm h
+
+example {x y : ℝ} (h : x ≤ y) : ¬y ≤ x ↔ x ≠ y :=
+  ⟨fun h₀ h₁ ↦ h₀ (by rw [h₁]), fun h₀ h₁ ↦ h₀ (le_antisymm h h₁)⟩
+
+
+

The last proof term is inscrutable. Remember that you can +use underscores while writing an expression like that to +see what Lean expects.

+

Try out the various techniques and gadgets you have just seen +in order to prove the following:

+
example {x y : ℝ} : x ≤ y ∧ ¬y ≤ x ↔ x ≤ y ∧ x ≠ y :=
+  sorry
+
+
+

For a more interesting exercise, show that for any +two real numbers x and y, +x^2 + y^2 = 0 if and only if x = 0 and y = 0. +We suggest proving an auxiliary lemma using +linarith, pow_two_nonneg, and eq_zero_of_pow_eq_zero.

+
theorem aux {x y : ℝ} (h : x ^ 2 + y ^ 2 = 0) : x = 0 :=
+  have h' : x ^ 2 = 0 := by sorry
+  eq_zero_of_pow_eq_zero h'
+
+example (x y : ℝ) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 :=
+  sorry
+
+
+

In Lean, bi-implication leads a double-life. +You can treat it like a conjunction and use its two +parts separately. +But Lean also knows that it is a reflexive, symmetric, +and transitive relation between propositions, +and you can also use it with calc and rw. +It is often convenient to rewrite a statement to +an equivalent one. +In the next example, we use abs_lt to +replace an expression of the form |x| < y +by the equivalent expression - y < x ∧ x < y, +and in the one after that we use Nat.dvd_gcd_iff +to replace an expression of the form m ∣ Nat.gcd n k by the equivalent expression m ∣ n ∧ m ∣ k.

+
example (x : ℝ) : |x + 3| < 5 → -8 < x ∧ x < 2 := by
+  rw [abs_lt]
+  intro h
+  constructor <;> linarith
+
+example : 3 ∣ Nat.gcd 6 15 := by
+  rw [Nat.dvd_gcd_iff]
+  constructor <;> norm_num
+
+
+

See if you can use rw with the theorem below +to provide a short proof that negation is not a +nondecreasing function. (Note that push Not won’t +unfold definitions for you, so the rw [Monotone] in +the proof of the theorem is needed.)

+
theorem not_monotone_iff {f : ℝ → ℝ} : ¬Monotone f ↔ ∃ x y, x ≤ y ∧ f x > f y := by
+  rw [Monotone]
+  push Not
+  rfl
+
+example : ¬Monotone fun x : ℝ ↦ -x := by
+  sorry
+
+
+

The remaining exercises in this section are designed +to give you some more practice with conjunction and +bi-implication. Remember that a partial order is a +binary relation that is transitive, reflexive, and +antisymmetric. +An even weaker notion sometimes arises: +a preorder is just a reflexive, transitive relation. +For any pre-order ≤, +Lean axiomatizes the associated strict pre-order by +a < b ↔ a ≤ b ∧ ¬ b ≤ a. +Show that if ≤ is a partial order, +then a < b is equivalent to a ≤ b ∧ a ≠ b:

+
variable {α : Type*} [PartialOrder α]
+variable (a b : α)
+
+example : a < b ↔ a ≤ b ∧ a ≠ b := by
+  rw [lt_iff_le_not_ge]
+  sorry
+
+
+

Beyond logical operations, you do not need +anything more than le_refl, le_trans, +and le_antisymm. +Show that even in the case where ≤ +is only assumed to be a preorder, +we can prove that the strict order is irreflexive +and transitive. +In the second example, +for convenience, we use the simplifier rather than rw +to express < in terms of ≤ and ¬. +We will come back to the simplifier later, +but here we are only relying on the fact that it will +use the indicated lemma repeatedly, even if it needs +to be instantiated to different values.

+
variable {α : Type*} [Preorder α]
+variable (a b c : α)
+
+example : ¬a < a := by
+  rw [lt_iff_le_not_ge]
+  sorry
+
+example : a < b → b < c → a < c := by
+  simp only [lt_iff_le_not_ge]
+  sorry
+
+
+
+
+

3.5. Disjunction

+

The canonical way to prove a disjunction A ∨ B is to prove +A or to prove B. +The left tactic chooses A, +and the right tactic chooses B.

+
variable {x y : ℝ}
+
+example (h : y > x ^ 2) : y > 0 ∨ y < -1 := by
+  left
+  linarith [pow_two_nonneg x]
+
+example (h : -y > x ^ 2 + 1) : y > 0 ∨ y < -1 := by
+  right
+  linarith [pow_two_nonneg x]
+
+
+

We cannot use an anonymous constructor to construct a proof +of an “or” because Lean would have to guess +which disjunct we are trying to prove. +When we write proof terms we can use +Or.inl and Or.inr instead +to make the choice explicitly. +Here, inl is short for “introduction left” and +inr is short for “introduction right.”

+
example (h : y > 0) : y > 0 ∨ y < -1 :=
+  Or.inl h
+
+example (h : y < -1) : y > 0 ∨ y < -1 :=
+  Or.inr h
+
+
+

It may seem strange to prove a disjunction by proving one side +or the other. +In practice, which case holds usually depends on a case distinction +that is implicit or explicit in the assumptions and the data. +The rcases tactic allows us to make use of a hypothesis +of the form A ∨ B. +In contrast to the use of rcases with conjunction or an +existential quantifier, +here the rcases tactic produces two goals. +Both have the same conclusion, but in the first case, +A is assumed to be true, +and in the second case, +B is assumed to be true. +In other words, as the name suggests, +the rcases tactic carries out a proof by cases. +As usual, we can tell Lean what names to use for the hypotheses. +In the next example, we tell Lean +to use the name h on each branch.

+
example : x < |y| → x < y ∨ x < -y := by
+  rcases le_or_gt 0 y with h | h
+  · rw [abs_of_nonneg h]
+    intro h; left; exact h
+  · rw [abs_of_neg h]
+    intro h; right; exact h
+
+
+

Notice that the pattern changes from ⟨h₀, h₁⟩ in the case of +a conjunction to h₀ | h₁ in the case of a disjunction. +Think of the first pattern as matching against data that contains +both an h₀ and a h₁, whereas the second pattern, with the bar, +matches against data that contains either an h₀ or an h₁. +In this case, because the two goals are separate, we have chosen +to use the same name, h, in each case.

+

The absolute value function is defined in such a way +that we can immediately prove that +x ≥ 0 implies |x| = x +(this is the theorem abs_of_nonneg) +and x < 0 implies |x| = -x (this is abs_of_neg). +The expression le_or_gt 0 x establishes 0 ≤ x ∨ x < 0, +allowing us to split on those two cases.

+

Lean also supports the computer scientists’ pattern-matching +syntax for disjunction. Now the cases tactic is more attractive, +because it allows us to name each case, and name the hypothesis +that is introduced closer to where it is used.

+
example : x < |y| → x < y ∨ x < -y := by
+  cases le_or_gt 0 y
+  case inl h =>
+    rw [abs_of_nonneg h]
+    intro h; left; exact h
+  case inr h =>
+    rw [abs_of_neg h]
+    intro h; right; exact h
+
+
+

The names inl and inr are short for “intro left” and “intro right,” +respectively. Using case has the advantage that you can prove the +cases in either order; Lean uses the tag to find the relevant goal. +If you don’t care about that, you can use next, or match, +or even a pattern-matching have.

+
example : x < |y| → x < y ∨ x < -y := by
+  cases le_or_gt 0 y
+  next h =>
+    rw [abs_of_nonneg h]
+    intro h; left; exact h
+  next h =>
+    rw [abs_of_neg h]
+    intro h; right; exact h
+
+example : x < |y| → x < y ∨ x < -y := by
+  match le_or_gt 0 y with
+    | Or.inl h =>
+      rw [abs_of_nonneg h]
+      intro h; left; exact h
+    | Or.inr h =>
+      rw [abs_of_neg h]
+      intro h; right; exact h
+
+
+

In the case of match, we need to use the full names +Or.inl and Or.inr of the canonical ways to prove a disjunction. +In this textbook, we will generally use rcases to split on the +cases of a disjunction.

+

Try proving the triangle inequality using the +first two theorems in the next snippet. +They are given the same names they have in Mathlib.

+
namespace MyAbs
+
+theorem le_abs_self (x : ℝ) : x ≤ |x| := by
+  sorry
+
+theorem neg_le_abs (x : ℝ) : -x ≤ |x| := by
+  sorry
+
+theorem abs_add_le (x y : ℝ) : |x + y| ≤ |x| + |y| := by
+  sorry
+
+
+

In case you enjoyed these (pun intended) and +you want more practice with disjunction, +try these.

+
theorem lt_abs : x < |y| ↔ x < y ∨ x < -y := by
+  sorry
+
+theorem abs_lt : |x| < y ↔ -y < x ∧ x < y := by
+  sorry
+
+
+

You can also use rcases and rintro with nested disjunctions. +When these result in a genuine case split with multiple goals, +the patterns for each new goal are separated by a vertical bar.

+
example {x : ℝ} (h : x ≠ 0) : x < 0 ∨ x > 0 := by
+  rcases lt_trichotomy x 0 with xlt | xeq | xgt
+  · left
+    exact xlt
+  · contradiction
+  · right; exact xgt
+
+
+

You can still nest patterns and use the rfl keyword +to substitute equations:

+
example {m n k : ℕ} (h : m ∣ n ∨ m ∣ k) : m ∣ n * k := by
+  rcases h with ⟨a, rfl⟩ | ⟨b, rfl⟩
+  · rw [mul_assoc]
+    apply dvd_mul_right
+  · rw [mul_comm, mul_assoc]
+    apply dvd_mul_right
+
+
+

See if you can prove the following with a single (long) line. +Use rcases to unpack the hypotheses and split on cases, +and use <;> linarith to solve each branch.

+
example {z : ℝ} (h : ∃ x y, z = x ^ 2 + y ^ 2 ∨ z = x ^ 2 + y ^ 2 + 1) : z ≥ 0 := by
+  sorry
+
+
+

On the real numbers, an equation x * y = 0 +tells us that x = 0 or y = 0. +In Mathlib, this fact is known as eq_zero_or_eq_zero_of_mul_eq_zero, +and it is another nice example of how a disjunction can arise. +See if you can use it to prove the following:

+
example {x : ℝ} (h : x ^ 2 = 1) : x = 1 ∨ x = -1 := by
+  sorry
+
+example {x y : ℝ} (h : x ^ 2 = y ^ 2) : x = y ∨ x = -y := by
+  sorry
+
+
+

Remember that you can use the ring tactic to help +with calculations.

+

In an arbitrary ring \(R\), an element \(x\) such +that \(x y = 0\) for some nonzero \(y\) is called +a left zero divisor, +an element \(x\) such +that \(y x = 0\) for some nonzero \(y\) is called +a right zero divisor, +and an element that is either a left or right zero divisor +is called simply a zero divisor. +The theorem eq_zero_or_eq_zero_of_mul_eq_zero +says that the real numbers have no nontrivial zero divisors. +A commutative ring with this property is called an integral domain. +Your proofs of the two theorems above should work equally well +in any integral domain:

+
variable {R : Type*} [CommRing R] [IsDomain R]
+variable (x y : R)
+
+example (h : x ^ 2 = 1) : x = 1 ∨ x = -1 := by
+  sorry
+
+example (h : x ^ 2 = y ^ 2) : x = y ∨ x = -y := by
+  sorry
+
+
+

In fact, if you are careful, you can prove the first +theorem without using commutativity of multiplication. +In that case, it suffices to assume that R is +a Ring instead of an CommRing.

+

Sometimes in a proof we want to split on cases +depending on whether some statement is true or not. +For any proposition P, we can use +em P : P ∨ ¬ P. +The name em is short for “excluded middle.”

+
example (P : Prop) : ¬¬P → P := by
+  intro h
+  cases em P
+  · assumption
+  · contradiction
+
+
+

Alternatively, you can use the by_cases tactic.

+
example (P : Prop) : ¬¬P → P := by
+  intro h
+  by_cases h' : P
+  · assumption
+  contradiction
+
+
+

Notice that the by_cases tactic lets you +specify a label for the hypothesis that is +introduced in each branch, +in this case, h' : P in one and h' : ¬ P +in the other. +If you leave out the label, +Lean uses h by default. +Try proving the following equivalence, +using by_cases to establish one direction.

+
example (P Q : Prop) : P → Q ↔ ¬P ∨ Q := by
+  sorry
+
+
+
+
+

3.6. Sequences and Convergence

+

We now have enough skills at our disposal to do some real mathematics. +In Lean, we can represent a sequence \(s_0, s_1, s_2, \ldots\) of +real numbers as a function s : ℕ → ℝ. +Such a sequence is said to converge to a number \(a\) if for every +\(\varepsilon > 0\) there is a point beyond which the sequence +remains within \(\varepsilon\) of \(a\), +that is, there is a number \(N\) such that for every +\(n \ge N\), \(| s_n - a | < \varepsilon\). +In Lean, we can render this as follows:

+
def ConvergesTo (s : ℕ → ℝ) (a : ℝ) :=
+  ∀ ε > 0, ∃ N, ∀ n ≥ N, |s n - a| < ε
+
+
+

The notation ∀ ε > 0, ... is a convenient abbreviation +for ∀ ε, ε > 0 → ..., and, similarly, +∀ n ≥ N, ... abbreviates ∀ n, n ≥ N →  .... +And remember that ε > 0, in turn, is defined as 0 < ε, +and n ≥ N is defined as N ≤ n.

+

In this section, we’ll establish some properties of convergence. +But first, we will discuss three tactics for working with equality +that will prove useful. +The first, the ext tactic, +gives us a way of proving that two functions are equal. +Let \(f(x) = x + 1\) and \(g(x) = 1 + x\) +be functions from reals to reals. +Then, of course, \(f = g\), because they return the same +value for every \(x\). +The ext tactic enables us to prove an equation between functions +by proving that their values are the same +at all the values of their arguments.

+
example : (fun x y : ℝ ↦ (x + y) ^ 2) = fun x y : ℝ ↦ x ^ 2 + 2 * x * y + y ^ 2 := by
+  ext
+  ring
+
+
+

We’ll see later that ext is actually more general, and also one can +specify the name of the variables that appear. +For instance you can try to replace ext with ext u v in the +above proof. +The second tactic, the congr tactic, +allows us to prove an equation between two expressions +by reconciling the parts that are different:

+
example (a b : ℝ) : |a| = |a - b + b| := by
+  congr
+  ring
+
+
+

Here the congr tactic peels off the abs on each side, +leaving us to prove a = a - b + b.

+

Finally, the convert tactic is used to apply a theorem +to a goal when the conclusion of the theorem doesn’t quite match. +For example, suppose we want to prove a < a * a from 1 < a. +A theorem in the library, mul_lt_mul_iff_left₀, +will let us prove 1 * a < a * a. +One possibility is to work backwards and rewrite the goal +so that it has that form. +Instead, the convert tactic lets us apply the theorem +as it is, +and leaves us with the task of proving the equations that +are needed to make the goal match. +The convert! variant more aggressively unfold definitions when +trying to solve the resulting goals.

+
example {a : ℝ} (h : 1 < a) : a < a * a := by
+  convert! (mul_lt_mul_iff_left₀ _).2 h
+  · rw [one_mul]
+  exact lt_trans zero_lt_one h
+
+
+

This example illustrates another useful trick: when we apply an +expression with an underscore +and Lean can’t fill it in for us automatically, +it simply leaves it for us as another goal.

+

The following shows that any constant sequence \(a, a, a, \ldots\) +converges.

+
theorem convergesTo_const (a : ℝ) : ConvergesTo (fun _x : ℕ ↦ a) a := by
+  intro ε εpos
+  use 0
+  intro n nge
+  rw [sub_self, abs_zero]
+  apply εpos
+
+
+

Lean has a tactic, simp, which can often save you the +trouble of carrying out steps like rw [sub_self, abs_zero] +by hand. +We will tell you more about it soon.

+

For a more interesting theorem, let’s show that if s +converges to a and t converges to b, then +fun n ↦ s n + t n converges to a + b. +It is helpful to have a clear pen-and-paper +proof in mind before you start writing a formal one. +Given ε greater than 0, +the idea is to use the hypotheses to obtain an Ns +such that beyond that point, s is within ε / 2 +of a, +and an Nt such that beyond that point, t is within +ε / 2 of b. +Then, whenever n is greater than or equal to the +maximum of Ns and Nt, +the sequence fun n ↦ s n + t n should be within ε +of a + b. +The following example begins to implement this strategy. +See if you can finish it off.

+
theorem convergesTo_add {s t : ℕ → ℝ} {a b : ℝ}
+      (cs : ConvergesTo s a) (ct : ConvergesTo t b) :
+    ConvergesTo (fun n ↦ s n + t n) (a + b) := by
+  intro ε εpos
+  dsimp -- this line is not needed but cleans up the goal a bit.
+  have ε2pos : 0 < ε / 2 := by linarith
+  rcases cs (ε / 2) ε2pos with ⟨Ns, hs⟩
+  rcases ct (ε / 2) ε2pos with ⟨Nt, ht⟩
+  use max Ns Nt
+  sorry
+
+
+

As hints, you can use le_of_max_le_left and le_of_max_le_right, +and norm_num can prove ε / 2 + ε / 2 = ε. +Also, it is helpful to use the congr tactic to +show that |s n + t n - (a + b)| is equal to +|(s n - a) + (t n - b)|, +since then you can use the triangle inequality. +Notice that we marked all the variables s, t, a, and b +implicit because they can be inferred from the hypotheses.

+

Proving the same theorem with multiplication in place +of addition is tricky. +We will get there by proving some auxiliary statements first. +See if you can also finish off the next proof, +which shows that if s converges to a, +then fun n ↦ c * s n converges to c * a. +It is helpful to split into cases depending on whether c +is equal to zero or not. +We have taken care of the zero case, +and we have left you to prove the result with +the extra assumption that c is nonzero.

+
theorem convergesTo_mul_const {s : ℕ → ℝ} {a : ℝ} (c : ℝ) (cs : ConvergesTo s a) :
+    ConvergesTo (fun n ↦ c * s n) (c * a) := by
+  by_cases h : c = 0
+  · convert convergesTo_const 0
+    · rw [h]
+      ring
+    rw [h]
+    ring
+  have acpos : 0 < |c| := abs_pos.mpr h
+  sorry
+
+
+

The next theorem is also independently interesting: +it shows that a convergent sequence is eventually bounded +in absolute value. +We have started you off; see if you can finish it.

+
theorem exists_abs_le_of_convergesTo {s : ℕ → ℝ} {a : ℝ} (cs : ConvergesTo s a) :
+    ∃ N b, ∀ n, N ≤ n → |s n| < b := by
+  rcases cs 1 zero_lt_one with ⟨N, h⟩
+  use N, |a| + 1
+  sorry
+
+
+

In fact, the theorem could be strengthened to assert +that there is a bound b that holds for all values of n. +But this version is strong enough for our purposes, +and we will see at the end of this section that it +holds more generally.

+

The next lemma is auxiliary: we prove that if +s converges to a and t converges to 0, +then fun n ↦ s n * t n converges to 0. +To do so, we use the previous theorem to find a B +that bounds s beyond some point N₀. +See if you can understand the strategy we have outlined +and finish the proof.

+
theorem aux {s t : ℕ → ℝ} {a : ℝ} (cs : ConvergesTo s a) (ct : ConvergesTo t 0) :
+    ConvergesTo (fun n ↦ s n * t n) 0 := by
+  intro ε εpos
+  dsimp
+  rcases exists_abs_le_of_convergesTo cs with ⟨N₀, B, h₀⟩
+  have Bpos : 0 < B := lt_of_le_of_lt (abs_nonneg _) (h₀ N₀ (le_refl _))
+  have pos₀ : ε / B > 0 := div_pos εpos Bpos
+  rcases ct _ pos₀ with ⟨N₁, h₁⟩
+  sorry
+
+
+

If you have made it this far, congratulations! +We are now within striking distance of our theorem. +The following proof finishes it off.

+
theorem convergesTo_mul {s t : ℕ → ℝ} {a b : ℝ}
+      (cs : ConvergesTo s a) (ct : ConvergesTo t b) :
+    ConvergesTo (fun n ↦ s n * t n) (a * b) := by
+  have h₁ : ConvergesTo (fun n ↦ s n * (t n + -b)) 0 := by
+    apply aux cs
+    convert convergesTo_add ct (convergesTo_const (-b))
+    ring
+  have := convergesTo_add h₁ (convergesTo_mul_const b cs)
+  convert convergesTo_add h₁ (convergesTo_mul_const b cs) using 1
+  · ext; ring
+  ring
+
+
+

For another challenging exercise, +try filling out the following sketch of a proof that limits +are unique. +(If you are feeling bold, +you can delete the proof sketch and try proving it from scratch.)

+
theorem convergesTo_unique {s : ℕ → ℝ} {a b : ℝ}
+      (sa : ConvergesTo s a) (sb : ConvergesTo s b) :
+    a = b := by
+  by_contra abne
+  have : |a - b| > 0 := by sorry
+  let ε := |a - b| / 2
+  have εpos : ε > 0 := by
+    change |a - b| / 2 > 0
+    linarith
+  rcases sa ε εpos with ⟨Na, hNa⟩
+  rcases sb ε εpos with ⟨Nb, hNb⟩
+  let N := max Na Nb
+  have absa : |s N - a| < ε := by sorry
+  have absb : |s N - b| < ε := by sorry
+  have : |a - b| < |a - b| := by sorry
+  exact lt_irrefl _ this
+
+
+

We close the section with the observation that our proofs can be generalized. +For example, the only properties that we have used of the +natural numbers is that their structure carries a partial order +with min and max. +You can check that everything still works if you replace ℕ +everywhere by any linear order α:

+
variable {α : Type*} [LinearOrder α]
+
+def ConvergesTo' (s : α → ℝ) (a : ℝ) :=
+  ∀ ε > 0, ∃ N, ∀ n ≥ N, |s n - a| < ε
+
+
+

In Section 11.1, we will see that Mathlib has mechanisms +for dealing with convergence in vastly more general terms, +not only abstracting away particular features of the domain +and codomain, +but also abstracting over different types of convergence.

+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C04_Sets_and_Functions.html b/dev/vendor/mathematics_in_lean/html/C04_Sets_and_Functions.html new file mode 100644 index 0000000..5c877da --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C04_Sets_and_Functions.html @@ -0,0 +1,1164 @@ + + + + + + + + + 4. Sets and Functions — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

4. Sets and Functions

+

The vocabulary of sets, relations, and functions provides a uniform +language for carrying out constructions in all the branches of +mathematics. +Since functions and relations can be defined in terms of sets, +axiomatic set theory can be used as a foundation for mathematics.

+

Lean’s foundation is based instead on the primitive notion of a type, +and it includes ways of defining functions between types. +Every expression in Lean has a type: +there are natural numbers, real numbers, functions from reals to reals, +groups, vector spaces, and so on. +Some expressions are types, +which is to say, +their type is Type. +Lean and Mathlib provide ways of defining new types, +and ways of defining objects of those types.

+

Conceptually, you can think of a type as just a set of objects. +Requiring every object to have a type has some advantages. +For example, it makes it possible to overload notation like +, +and it sometimes makes input less verbose +because Lean can infer a lot of information from +an object’s type. +The type system also enables Lean to flag errors when you +apply a function to the wrong number of arguments, +or apply a function to arguments of the wrong type.

+

Lean’s library does define elementary set-theoretic notions. +In contrast to set theory, +in Lean a set is always a set of objects of some type, +such as a set of natural numbers or a set of functions +from real numbers to real numbers. +The distinction between types and sets takes some getting used to, +but this chapter will take you through the essentials.

+
+

4.1. Sets

+

If α is any type, the type Set α consists of sets +of elements of α. +This type supports the usual set-theoretic operations and relations. +For example, s ⊆ t says that s is a subset of t, +s ∩ t denotes the intersection of s and t, +and s ∪ t denotes their union. +The subset relation can be typed with \ss or \sub, +intersection can be typed with \i or \cap, +and union can be typed with \un or \cup. +The library also defines the set univ, +which consists of all the elements of type α, +and the empty set, ∅, which can be typed as \empty. +Given x : α and s : Set α, +the expression x ∈ s says that x is a member of s. +Theorems that mention set membership often include mem +in their name. +The expression x ∉ s abbreviates ¬ x ∈ s. +You can type ∈ as \in or \mem and ∉ as \notin.

+

One way to prove things about sets is to use rw +or the simplifier to expand the definitions. +In the second example below, we use simp only +to tell the simplifier to use only the list +of identities we give it, +and not its full database of identities. +Unlike rw, simp can perform simplifications +inside a universal or existential quantifier. +If you step through the proof, +you can see the effects of these commands.

+
variable {α : Type*}
+variable (s t u : Set α)
+open Set
+
+example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by
+  rw [subset_def, inter_def, inter_def]
+  rw [subset_def] at h
+  simp only [mem_ofPred]
+  rintro x ⟨xs, xu⟩
+  exact ⟨h _ xs, xu⟩
+
+example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by
+  simp only [subset_def, mem_inter_iff] at *
+  rintro x ⟨xs, xu⟩
+  exact ⟨h _ xs, xu⟩
+
+
+

In this example, we open the Set namespace to have +access to the shorter names for the theorems. +But, in fact, we can delete the calls to rw and simp +entirely:

+
example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by
+  intro x xsu
+  exact ⟨h xsu.1, xsu.2⟩
+
+
+

What is going on here is known as definitional reduction: +to make sense of the intro command and the anonymous constructors +Lean is forced to expand the definitions. +The following example also illustrate the phenomenon:

+
example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u :=
+  fun _x ⟨xs, xu⟩ ↦ ⟨h xs, xu⟩
+
+
+

To deal with unions, we can use Set.union_def and Set.mem_union. +Since x ∈ s ∪ t unfolds to x ∈ s ∨ x ∈ t, +we can also use the cases tactic to force a definitional reduction.

+
example : s ∩ (t ∪ u) ⊆ s ∩ t ∪ s ∩ u := by
+  intro x hx
+  have xs : x ∈ s := hx.1
+  have xtu : x ∈ t ∪ u := hx.2
+  rcases xtu with xt | xu
+  · left
+    show x ∈ s ∩ t
+    exact ⟨xs, xt⟩
+  · right
+    show x ∈ s ∩ u
+    exact ⟨xs, xu⟩
+
+
+

Since intersection binds tighter than union, +the use of parentheses in the expression (s ∩ t) ∪ (s ∩ u) +is unnecessary, but they make the meaning of the expression clearer. +The following is a shorter proof of the same fact:

+
example : s ∩ (t ∪ u) ⊆ s ∩ t ∪ s ∩ u := by
+  rintro x ⟨xs, xt | xu⟩
+  · left; exact ⟨xs, xt⟩
+  · right; exact ⟨xs, xu⟩
+
+
+

As an exercise, try proving the other inclusion:

+
example : s ∩ t ∪ s ∩ u ⊆ s ∩ (t ∪ u) := by
+  sorry
+
+
+

It might help to know that when using rintro, +sometimes we need to use parentheses around a disjunctive pattern +h1 | h2 to get Lean to parse it correctly.

+

The library also defines set difference, s \ t, +where the backslash is a special unicode character +entered as \\. +The expression x ∈ s \ t expands to x ∈ s ∧ x ∉ t. +(The ∉ can be entered as \notin.) +It can be rewritten manually using Set.diff_eq and dsimp +or Set.mem_diff, +but the following two proofs of the same inclusion +show how to avoid using them.

+
example : (s \ t) \ u ⊆ s \ (t ∪ u) := by
+  intro x xstu
+  have xs : x ∈ s := xstu.1.1
+  have xnt : x ∉ t := xstu.1.2
+  have xnu : x ∉ u := xstu.2
+  constructor
+  · exact xs
+  intro xtu
+  -- x ∈ t ∨ x ∈ u
+  rcases xtu with xt | xu
+  · show False; exact xnt xt
+  · show False; exact xnu xu
+
+example : (s \ t) \ u ⊆ s \ (t ∪ u) := by
+  rintro x ⟨⟨xs, xnt⟩, xnu⟩
+  use xs
+  rintro (xt | xu) <;> contradiction
+
+
+

As an exercise, prove the reverse inclusion:

+
example : s \ (t ∪ u) ⊆ (s \ t) \ u := by
+  sorry
+
+
+

To prove that two sets are equal, +it suffices to show that every element of one is an element +of the other. +This principle is known as “extensionality,” +and, unsurprisingly, +the ext tactic is equipped to handle it.

+
example : s ∩ t = t ∩ s := by
+  ext x
+  simp only [mem_inter_iff]
+  constructor
+  · rintro ⟨xs, xt⟩; exact ⟨xt, xs⟩
+  · rintro ⟨xt, xs⟩; exact ⟨xs, xt⟩
+
+
+

Once again, deleting the line simp only [mem_inter_iff] +does not harm the proof. +In fact, if you like inscrutable proof terms, +the following one-line proof is for you:

+
example : s ∩ t = t ∩ s :=
+  Set.ext fun _x ↦ ⟨fun ⟨xs, xt⟩ ↦ ⟨xt, xs⟩, fun ⟨xt, xs⟩ ↦ ⟨xs, xt⟩⟩
+
+
+

Here is an even shorter proof, +using the simplifier:

+
example : s ∩ t = t ∩ s := by ext x; simp [and_comm]
+
+
+

An alternative to using ext is to use +the theorem Subset.antisymm +which allows us to prove an equation s = t +between sets by proving s ⊆ t and t ⊆ s.

+
example : s ∩ t = t ∩ s := by
+  apply Subset.antisymm
+  · rintro x ⟨xs, xt⟩; exact ⟨xt, xs⟩
+  · rintro x ⟨xt, xs⟩; exact ⟨xs, xt⟩
+
+
+

Try finishing this proof term:

+
example : s ∩ t = t ∩ s :=
+    Subset.antisymm sorry sorry
+
+
+

Remember that you can replace sorry by an underscore, +and when you hover over it, +Lean will show you what it expects at that point.

+

Here are some set-theoretic identities you might enjoy proving:

+
example : s ∩ (s ∪ t) = s := by
+  sorry
+
+example : s ∪ s ∩ t = s := by
+  sorry
+
+example : s \ t ∪ t = s ∪ t := by
+  sorry
+
+example : s \ t ∪ t \ s = (s ∪ t) \ (s ∩ t) := by
+  sorry
+
+
+

When it comes to representing sets, +here is what is going on underneath the hood. +In type theory, a property or predicate on a type α +is just a function P : α → Prop. +This makes sense: +given a : α, P a is just the proposition +that P holds for a. +In the library, Set α is defined to be α → Prop and x ∈ s is defined to be s x. +In other words, sets are really properties, treated as objects.

+

The library also defines set-builder notation. +The expression { y | P y } unfolds to (fun y ↦ P y), +so x ∈ { y | P y } reduces to P x. +So we can turn the property of being even into the set of even numbers:

+
def evens : Set ℕ :=
+  { n | Even n }
+
+def odds : Set ℕ :=
+  { n | ¬Even n }
+
+example : evens ∪ odds = univ := by
+  rw [evens, odds]
+  ext n
+  simp [-Nat.not_even_iff_odd]
+  apply Classical.em
+
+
+

You should step through this proof and make sure +you understand what is going on. +Note we tell the simplifier to not use the lemma +Nat.not_even_iff because we want to keep +¬ Even n in our goal. +Try deleting the line rw [evens, odds] +and confirm that the proof still works.

+

In fact, set-builder notation is used to define

+
    +
  • s ∩ t as {x | x ∈ s ∧ x ∈ t},

  • +
  • s ∪ t as {x | x ∈ s ∨ x ∈ t},

  • +
  • ∅ as {x | False}, and

  • +
  • univ as {x | True}.

  • +
+

We often need to indicate the type of ∅ and univ +explicitly, +because Lean has trouble guessing which ones we mean. +The following examples show how Lean unfolds the last +two definitions when needed. In the second one, +trivial is the canonical proof of True in the library.

+
example (x : ℕ) (h : x ∈ (∅ : Set ℕ)) : False :=
+  h
+
+example (x : ℕ) : x ∈ (univ : Set ℕ) :=
+  trivial
+
+
+

As an exercise, prove the following inclusion. +Use intro n to unfold the definition of subset, +and use the simplifier to reduce the +set-theoretic constructions to logic. +We also recommend using the theorems +Nat.Prime.eq_two_or_odd and Nat.odd_iff.

+
example : { n | Nat.Prime n } ∩ { n | n > 2 } ⊆ { n | ¬Even n } := by
+  sorry
+
+
+

Be careful: it is somewhat confusing that the library has multiple versions +of the predicate Prime. +The most general one makes sense in any commutative monoid with a zero element. +The predicate Nat.Prime is specific to the natural numbers. +Fortunately, there is a theorem that says that in the specific case, +the two notions agree, so you can always rewrite one to the other.

+
#print Prime
+
+#print Nat.Prime
+
+example (n : ℕ) : Prime n ↔ Nat.Prime n :=
+  Nat.prime_iff.symm
+
+example (n : ℕ) (h : Prime n) : Nat.Prime n := by
+  rw [Nat.prime_iff]
+  exact h
+
+
+

The rwa tactic follows a rewrite with the assumption tactic.

+
example (n : ℕ) (h : Prime n) : Nat.Prime n := by
+  rwa [Nat.prime_iff]
+
+
+

Lean introduces the notation ∀ x ∈ s, ..., +“for every x in s .,” +as an abbreviation for ∀ x, x ∈ s → .... +It also introduces the notation ∃ x ∈ s, ..., +“there exists an x in s such that ..” +These are sometimes known as bounded quantifiers, +because the construction serves to restrict their significance +to the set s. +As a result, theorems in the library that make use of them +often contain ball or bex in the name. +The theorem bex_def asserts that ∃ x ∈ s, ... is equivalent +to ∃ x, x ∈ s ∧ ..., +but when they are used with rintro, use, +and anonymous constructors, +these two expressions behave roughly the same. +As a result, we usually don’t need to use bex_def +to transform them explicitly. +Here are some examples of how they are used:

+
variable (s t : Set ℕ)
+
+example (h₀ : ∀ x ∈ s, ¬Even x) (h₁ : ∀ x ∈ s, Prime x) : ∀ x ∈ s, ¬Even x ∧ Prime x := by
+  intro x xs
+  constructor
+  · apply h₀ x xs
+  apply h₁ x xs
+
+example (h : ∃ x ∈ s, ¬Even x ∧ Prime x) : ∃ x ∈ s, Prime x := by
+  rcases h with ⟨x, xs, _, prime_x⟩
+  use x, xs
+
+
+

See if you can prove these slight variations:

+
section
+variable (ssubt : s ⊆ t)
+
+example (h₀ : ∀ x ∈ t, ¬Even x) (h₁ : ∀ x ∈ t, Prime x) : ∀ x ∈ s, ¬Even x ∧ Prime x := by
+  sorry
+
+example (h : ∃ x ∈ s, ¬Even x ∧ Prime x) : ∃ x ∈ t, Prime x := by
+  sorry
+
+end
+
+
+

Indexed unions and intersections are +another important set-theoretic construction. +We can model a sequence \(A_0, A_1, A_2, \ldots\) of sets of +elements of α +as a function A : ℕ → Set α, +in which case ⋃ i, A i denotes their union, +and ⋂ i, A i denotes their intersection. +There is nothing special about the natural numbers here, +so ℕ can be replaced by any type I +used to index the sets. +The following illustrates their use.

+
variable {α I : Type*}
+variable (A B : I → Set α)
+variable (s : Set α)
+
+open Set
+
+example : (s ∩ ⋃ i, A i) = ⋃ i, A i ∩ s := by
+  ext x
+  simp only [mem_inter_iff, mem_iUnion]
+  constructor
+  · rintro ⟨xs, ⟨i, xAi⟩⟩
+    exact ⟨i, xAi, xs⟩
+  rintro ⟨i, xAi, xs⟩
+  exact ⟨xs, ⟨i, xAi⟩⟩
+
+example : (⋂ i, A i ∩ B i) = (⋂ i, A i) ∩ ⋂ i, B i := by
+  ext x
+  simp only [mem_inter_iff, mem_iInter]
+  constructor
+  · intro h
+    constructor
+    · intro i
+      exact (h i).1
+    intro i
+    exact (h i).2
+  rintro ⟨h1, h2⟩ i
+  constructor
+  · exact h1 i
+  exact h2 i
+
+
+

Parentheses are often needed with an +indexed union or intersection because, +as with the quantifiers, +the scope of the bound variable extends as far as it can.

+

Try proving the following identity. +One direction requires classical logic! +We recommend using by_cases xs : x ∈ s +at an appropriate point in the proof.

+
example : (s ∪ ⋂ i, A i) = ⋂ i, A i ∪ s := by
+  sorry
+
+
+

Mathlib also has bounded unions and intersections, +which are analogous to the bounded quantifiers. +You can unpack their meaning with mem_iUnion₂ +and mem_iInter₂. +As the following examples show, +Lean’s simplifier carries out these replacements as well.

+
def primes : Set ℕ :=
+  { x | Nat.Prime x }
+
+example : (⋃ p ∈ primes, { x | p ^ 2 ∣ x }) = { x | ∃ p ∈ primes, p ^ 2 ∣ x } :=by
+  ext
+  rw [mem_iUnion₂]
+  simp
+
+example : (⋃ p ∈ primes, { x | p ^ 2 ∣ x }) = { x | ∃ p ∈ primes, p ^ 2 ∣ x } := by
+  ext
+  simp
+
+example : (⋂ p ∈ primes, { x | ¬p ∣ x }) ⊆ { x | x = 1 } := by
+  intro x
+  contrapose!
+  simp
+  apply Nat.exists_prime_and_dvd
+
+
+

Try solving the following example, which is similar. +If you start typing eq_univ, +tab completion will tell you that apply eq_univ_of_forall +is a good way to start the proof. +We also recommend using the theorem Nat.exists_infinite_primes.

+
example : (⋃ p ∈ primes, { x | x ≤ p }) = univ := by
+  sorry
+
+
+

Give a collection of sets, s : Set (Set α), +their union, ⋃₀ s, has type Set α +and is defined as {x | ∃ t ∈ s, x ∈ t}. +Similarly, their intersection, ⋂₀ s, is defined as +{x | ∀ t ∈ s, x ∈ t}. +These operations are called sUnion and sInter, respectively. +The following examples show their relationship to bounded union +and intersection.

+
variable {α : Type*} (s : Set (Set α))
+
+example : ⋃₀ s = ⋃ t ∈ s, t := by
+  ext x
+  rw [mem_iUnion₂]
+  simp
+
+example : ⋂₀ s = ⋂ t ∈ s, t := by
+  ext x
+  rw [mem_iInter₂]
+  rfl
+
+
+

In the library, these identities are called +sUnion_eq_biUnion and sInter_eq_biInter.

+
+
+

4.2. Functions

+

If f : α → β is a function and p is a set of +elements of type β, +the library defines preimage f p, written f ⁻¹' p, +to be {x | f x ∈ p}. +The expression x ∈ f ⁻¹' p reduces to f x ∈ p. +This is often convenient, as in the following example:

+
variable {α β : Type*}
+variable (f : α → β)
+variable (s t : Set α)
+variable (u v : Set β)
+
+open Function
+open Set
+
+example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := by
+  ext
+  rfl
+
+
+

If s is a set of elements of type α, +the library also defines image f s, +written f '' s, +to be {y | ∃ x, x ∈ s ∧ f x = y}. +So a hypothesis y ∈ f '' s decomposes to a triple +⟨x, xs, xeq⟩ with x : α satisfying the hypotheses xs : x ∈ s +and xeq : f x = y. +The rfl tag in the rintro tactic (see Section 3.2) was made precisely +for this sort of situation.

+
example : f '' (s ∪ t) = f '' s ∪ f '' t := by
+  ext y; constructor
+  · rintro ⟨x, xs | xt, rfl⟩
+    · left
+      use x, xs
+    right
+    use x, xt
+  rintro (⟨x, xs, rfl⟩ | ⟨x, xt, rfl⟩)
+  · use x, Or.inl xs
+  use x, Or.inr xt
+
+
+

Notice also that the use tactic applies rfl +to close goals when it can.

+

Here is another example:

+
example : s ⊆ f ⁻¹' (f '' s) := by
+  intro x xs
+  show f x ∈ f '' s
+  use x, xs
+
+
+

We can replace the line use x, xs by +apply mem_image_of_mem f xs if we want to +use a theorem specifically designed for that purpose. +But knowing that the image is defined in terms +of an existential quantifier is often convenient.

+

The following equivalence is a good exercise:

+
example : f '' s ⊆ v ↔ s ⊆ f ⁻¹' v := by
+  sorry
+
+
+

It shows that image f and preimage f are +an instance of what is known as a Galois connection +between Set α and Set β, +each partially ordered by the subset relation. +In the library, this equivalence is named +image_subset_iff. +In practice, the right-hand side is often the +more useful representation, +because x ∈ f ⁻¹' t unfolds to f x ∈ t +whereas working with y ∈ f '' s requires +decomposing an existential quantifier.

+

Here is a long list of set-theoretic identities for +you to enjoy. +You don’t have to do all of them at once; +do a few of them, +and set the rest aside for a rainy day.

+
example (h : Injective f) : f ⁻¹' (f '' s) ⊆ s := by
+  sorry
+
+example : f '' (f ⁻¹' u) ⊆ u := by
+  sorry
+
+example (h : Surjective f) : u ⊆ f '' (f ⁻¹' u) := by
+  sorry
+
+example (h : s ⊆ t) : f '' s ⊆ f '' t := by
+  sorry
+
+example (h : u ⊆ v) : f ⁻¹' u ⊆ f ⁻¹' v := by
+  sorry
+
+example : f ⁻¹' (u ∪ v) = f ⁻¹' u ∪ f ⁻¹' v := by
+  sorry
+
+example : f '' (s ∩ t) ⊆ f '' s ∩ f '' t := by
+  sorry
+
+example (h : Injective f) : f '' s ∩ f '' t ⊆ f '' (s ∩ t) := by
+  sorry
+
+example : f '' s \ f '' t ⊆ f '' (s \ t) := by
+  sorry
+
+example : f ⁻¹' u \ f ⁻¹' v ⊆ f ⁻¹' (u \ v) := by
+  sorry
+
+example : f '' s ∩ v = f '' (s ∩ f ⁻¹' v) := by
+  sorry
+
+example : f '' (s ∩ f ⁻¹' u) ⊆ f '' s ∩ u := by
+  sorry
+
+example : s ∩ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∩ u) := by
+  sorry
+
+example : s ∪ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∪ u) := by
+  sorry
+
+
+

You can also try your hand at the next group of exercises, +which characterize the behavior of images and preimages +with respect to indexed unions and intersections. +In the third exercise, the argument i : I is needed +to guarantee that the index set is nonempty. +To prove any of these, we recommend using ext or intro +to unfold the meaning of an equation or inclusion between sets, +and then calling simp to unpack the conditions for membership.

+
variable {I : Type*} (A : I → Set α) (B : I → Set β)
+
+example : (f '' ⋃ i, A i) = ⋃ i, f '' A i := by
+  sorry
+
+example : (f '' ⋂ i, A i) ⊆ ⋂ i, f '' A i := by
+  sorry
+
+example (i : I) (injf : Injective f) : (⋂ i, f '' A i) ⊆ f '' ⋂ i, A i := by
+  sorry
+
+example : (f ⁻¹' ⋃ i, B i) = ⋃ i, f ⁻¹' B i := by
+  sorry
+
+example : (f ⁻¹' ⋂ i, B i) = ⋂ i, f ⁻¹' B i := by
+  sorry
+
+
+

The library defines a predicate InjOn f s to say that +f is injective on s. +It is defined as follows:

+
example : InjOn f s ↔ ∀ x₁ ∈ s, ∀ x₂ ∈ s, f x₁ = f x₂ → x₁ = x₂ :=
+  Iff.refl _
+
+
+

The statement Injective f is provably equivalent +to InjOn f univ. +Similarly, the library defines range f to be +{x | ∃y, f y = x}, +so range f is provably equal to f '' univ. +This is a common theme in Mathlib: +although many properties of functions are defined relative +to their full domain, +there are often relativized versions that restrict +the statements to a subset of the domain type.

+

Here are some examples of InjOn and range in use:

+
open Set Real
+
+example : InjOn log { x | x > 0 } := by
+  intro x xpos y ypos e
+  calc
+    x = exp (log x) := by rw [exp_log xpos]
+    _ = exp (log y) := by rw [e]
+    _ = y := by rw [exp_log ypos]
+
+
+example : range exp = { y | y > 0 } := by
+  ext y; constructor
+  · rintro ⟨x, rfl⟩
+    apply exp_pos
+  intro ypos
+  use log y
+  rw [exp_log ypos]
+
+
+

Try proving these:

+
example : InjOn sqrt { x | x ≥ 0 } := by
+  sorry
+
+example : InjOn (fun x ↦ x ^ 2) { x : ℝ | x ≥ 0 } := by
+  sorry
+
+example : sqrt '' { x | x ≥ 0 } = { y | y ≥ 0 } := by
+  sorry
+
+example : (range fun x ↦ x ^ 2) = { y : ℝ | y ≥ 0 } := by
+  sorry
+
+
+

To define the inverse of a function f : α → β, +we will use two new ingredients. +First, we need to deal with the fact that +an arbitrary type in Lean may be empty. +To define the inverse to f at y when there is +no x satisfying f x = y, +we want to assign a default value in α. +Adding the annotation [Inhabited α] as a variable +is tantamount to assuming that α has a +preferred element, which is denoted default. +Second, in the case where there is more than one x +such that f x = y, +the inverse function needs to choose one of them. +This requires an appeal to the axiom of choice. +Lean allows various ways of accessing it; +one convenient method is to use the classical choose +operator, illustrated below.

+
variable {α β : Type*} [Inhabited α]
+
+#check (default : α)
+
+variable (P : α → Prop) (h : ∃ x, P x)
+
+#check Classical.choose h
+
+example : P (Classical.choose h) :=
+  Classical.choose_spec h
+
+
+

Given h : ∃ x, P x, the value of Classical.choose h +is some x satisfying P x. +The theorem Classical.choose_spec h says that Classical.choose h +meets this specification.

+

With these in hand, we can define the inverse function +as follows:

+
noncomputable section
+
+open Classical
+
+def inverse (f : α → β) : β → α := fun y : β ↦
+  if h : ∃ x, f x = y then Classical.choose h else default
+
+theorem inverse_spec {f : α → β} (y : β) (h : ∃ x, f x = y) : f (inverse f y) = y := by
+  rw [inverse, dite_eq_left h]
+  exact Classical.choose_spec h
+
+
+

The lines noncomputable section and open Classical +are needed because we are using classical logic in an essential way. +On input y, the function inverse f +returns some value of x satisfying f x = y if there is one, +and a default element of α otherwise. +This is an instance of a dependent if construction, +since in the positive case, the value returned, +Classical.choose h, depends on the assumption h. +The identity dite_eq_left h rewrites if h : e then a else b +to a given h : e, +and, similarly, dite_eq_right h rewrites it to b given h : ¬ e. +There are also versions ite_eq_left and ite_eq_right that works for non-dependent +if constructions and will be used in the next section. +The theorem inverse_spec says that inverse f +meets the first part of this specification.

+

Don’t worry if you do not fully understand how these work. +The theorem inverse_spec alone should be enough to show +that inverse f is a left inverse if and only if f is injective +and a right inverse if and only if f is surjective. +Look up the definition of LeftInverse and RightInverse +by double-clicking or right-clicking on them in VS Code, +or using the commands #print LeftInverse and #print RightInverse. +Then try to prove the two theorems. +They are tricky! +It helps to do the proofs on paper before +you start hacking through the details. +You should be able to prove each of them with about a half-dozen +short lines. +If you are looking for an extra challenge, +try to condense each proof to a single-line proof term.

+
variable (f : α → β)
+
+open Function
+
+example : Injective f ↔ LeftInverse (inverse f) f :=
+  sorry
+
+example : Surjective f ↔ RightInverse (inverse f) f :=
+  sorry
+
+
+

We close this section with a type-theoretic statement of Cantor’s +famous theorem that there is no surjective function from a set +to its power set. +See if you can understand the proof, +and then fill in the two lines that are missing.

+
theorem Cantor : ∀ f : α → Set α, ¬Surjective f := by
+  intro f surjf
+  let S := { i | i ∉ f i }
+  rcases surjf S with ⟨j, h⟩
+  have h₁ : j ∉ f j := by
+    intro h'
+    have : j ∉ f j := by rwa [h] at h'
+    contradiction
+  have h₂ : j ∈ S
+  sorry
+  have h₃ : j ∉ S
+  sorry
+  contradiction
+
+
+
+
+

4.3. The Schröder-Bernstein Theorem

+

We close this chapter with an elementary but nontrivial theorem of set theory. +Let \(\alpha\) and \(\beta\) be sets. +(In our formalization, they will actually be types.) +Suppose \(f : \alpha → \beta\) and \(g : \beta → \alpha\) +are both injective. +Intuitively, this means that \(\alpha\) is no bigger than \(\beta\) and vice-versa. +If \(\alpha\) and \(\beta\) are finite, this implies that +they have the same cardinality, which is equivalent to saying that there +is a bijection between them. +In the nineteenth century, Cantor stated that same result holds even in the +case where \(\alpha\) and \(\beta\) are infinite. +This was eventually established by Dedekind, Schröder, and Bernstein +independently.

+

Our formalization will introduce some new methods that we will explain +in greater detail in chapters to come. +Don’t worry if they go by too quickly here. +Our goal is to show you that you already have the skills to contribute +to the formal proof of a real mathematical result.

+

To understand the idea behind the proof, consider the image of the map +\(g\) in \(\alpha\). +On that image, the inverse of \(g\) is defined and is a bijection +with \(\beta\).

+the Schröder Bernstein theorem + +

The problem is that the bijection does not include the shaded region +in the diagram, which is nonempty if \(g\) is not surjective. +Alternatively, we can use \(f\) to map all of +\(\alpha\) to \(\beta\), +but in that case the problem is that if \(f\) is not surjective, +it will miss some elements of \(\beta\).

+the Schröder Bernstein theorem + +

But now consider the composition \(g \circ f\) from \(\alpha\) to +itself. Because the composition is injective, it forms a bijection between +\(\alpha\) and its image, yielding a scaled-down copy of \(\alpha\) +inside itself.

+the Schröder Bernstein theorem + +

This composition maps the inner shaded ring to yet another such +set, which we can think of as an even smaller concentric shaded ring, +and so on. +This yields a +concentric sequence of shaded rings, each of which is in +bijective correspondence with the next. +If we map each ring to the next and leave the unshaded +parts of \(\alpha\) alone, +we have a bijection of \(\alpha\) with the image of \(g\). +Composing with \(g^{-1}\), this yields the desired +bijection between \(\alpha\) and \(\beta\).

+

We can describe this bijection more simply. +Let \(A\) be the union of the sequence of shaded regions, and +define \(h : \alpha \to \beta\) as follows:

+
+\[\begin{split}h(x) = \begin{cases} + f(x) & \text{if $x \in A$} \\ + g^{-1}(x) & \text{otherwise.} +\end{cases}\end{split}\]
+

In other words, we use \(f\) on the shaded parts, +and we use the inverse of \(g\) everywhere else. +The resulting map \(h\) is injective +because each component is injective +and the images of the two components are disjoint. +To see that it is surjective, +suppose we are given a \(y\) in \(\beta\), and +consider \(g(y)\). +If \(g(y)\) is in one of the shaded regions, +it cannot be in the first ring, so we have \(g(y) = g(f(x))\) +for some \(x\) is in the previous ring. +By the injectivity of \(g\), we have \(h(x) = f(x) = y\). +If \(g(y)\) is not in the shaded region, +then by the definition of \(h\), we have \(h(g(y))= y\). +Either way, \(y\) is in the image of \(h\).

+

This argument should sound plausible, but the details are delicate. +Formalizing the proof will not only improve our confidence in the +result, but also help us understand it better. +Because the proof uses classical logic, we tell Lean that our definitions +will generally not be computable.

+
noncomputable section
+open Classical
+variable {α β : Type*} [Nonempty β]
+
+
+

The annotation [Nonempty β] specifies that β is nonempty. +We use it because the Mathlib primitive that we will use to +construct \(g^{-1}\) requires it. +The case of the theorem where \(\beta\) is empty is trivial, +and even though it would not be hard to generalize the formalization to cover +that case as well, we will not bother. +Specifically, we need the hypothesis [Nonempty β] for the operation +invFun that is defined in Mathlib. +Given x : α, invFun g x chooses a preimage of x +in β if there is one, +and returns an arbitrary element of β otherwise. +The function invFun g is always a left inverse if g is injective +and a right inverse if g is surjective.

+
#check (invFun g : α → β)
+#check (leftInverse_invFun : Injective g → LeftInverse (invFun g) g)
+#check (leftInverse_invFun : Injective g → ∀ y, invFun g (g y) = y)
+#check (invFun_eq : (∃ y, g y = x) → g (invFun g x) = x)
+
+
+

We define the set corresponding to the union of the shaded regions as follows.

+
variable (f : α → β) (g : β → α)
+
+def sbAux : ℕ → Set α
+  | 0 => univ \ g '' univ
+  | n + 1 => g '' (f '' sbAux n)
+
+def sbSet :=
+  ⋃ n, sbAux f g n
+
+
+

The definition sbAux is an example of a recursive definition, +which we will explain in the next chapter. +It defines a sequence of sets

+
+\[\begin{split}S_0 &= \alpha ∖ g(\beta) \\ +S_{n+1} &= g(f(S_n)).\end{split}\]
+

The definition sbSet corresponds to the set +\(A = \bigcup_{n \in \mathbb{N}} S_n\) in our proof sketch. +The function \(h\) described above is now defined as follows:

+
def sbFun (x : α) : β :=
+  if x ∈ sbSet f g then f x else invFun g x
+
+
+

We will need the fact that our definition of \(g^{-1}\) is a +right inverse on the complement of \(A\), +which is to say, on the non-shaded regions of \(\alpha\). +This is so because the outermost ring, \(S_0\), is equal to +\(\alpha \setminus g(\beta)\), so the complement of \(A\) is +contained in \(g(\beta)\). +As a result, for every \(x\) in the complement of \(A\), +there is a \(y\) such that \(g(y) = x\). +(By the injectivity of \(g\), this \(y\) is unique, +but next theorem says only that invFun g x returns some y +such that g y = x.)

+

Step through the proof below, make sure you understand what is going on, +and fill in the remaining parts. +You will need to use invFun_eq at the end. +Notice that rewriting with sbAux here replaces sbAux f g 0 +with the right-hand side of the corresponding defining equation.

+
theorem sb_right_inv {x : α} (hx : x ∉ sbSet f g) : g (invFun g x) = x := by
+  have : x ∈ g '' univ := by
+    contrapose! hx
+    rw [sbSet, mem_iUnion]
+    use 0
+    rw [sbAux, mem_sdiff]
+    sorry
+  have : ∃ y, g y = x := by
+    sorry
+  sorry
+
+
+

We now turn to the proof that \(h\) is injective. +Informally, the proof goes as follows. +First, suppose \(h(x_1) = h(x_2)\). +If \(x_1\) is in \(A\), then \(h(x_1) = f(x_1)\), +and we can show that \(x_2\) is in \(A\) as follows. +If it isn’t, then we have \(h(x_2) = g^{-1}(x_2)\). +From \(f(x_1) = h(x_1) = h(x_2)\) we have \(g(f(x_1)) = x_2\). +From the definition of \(A\), since \(x_1\) is in \(A\), +\(x_2\) is in \(A\) as well, a contradiction. +Hence, if \(x_1\) is in \(A\), so is \(x_2\), +in which case we have \(f(x_1) = h(x_1) = h(x_2) = f(x_2)\). +The injectivity of \(f\) then implies \(x_1 = x_2\). +The symmetric argument shows that if \(x_2\) is in \(A\), +then so is \(x_1\), which again implies \(x_1 = x_2\).

+

The only remaining possibility is that neither \(x_1\) nor \(x_2\) +is in \(A\). In that case, we have +\(g^{-1}(x_1) = h(x_1) = h(x_2) = g^{-1}(x_2)\). +Applying \(g\) to both sides yields \(x_1 = x_2\).

+

Once again, we encourage you to step through the following proof +to see how the argument plays out in Lean. +See if you can finish off the proof using sb_right_inv.

+
theorem sb_injective (hf : Injective f) : Injective (sbFun f g) := by
+  set A := sbSet f g with A_def
+  set h := sbFun f g with h_def
+  intro x₁ x₂ (hxeq : h x₁ = h x₂)
+  show x₁ = x₂
+  simp only [h_def, sbFun, ← A_def] at hxeq
+  by_cases xA : x₁ ∈ A ∨ x₂ ∈ A
+  · wlog x₁A : x₁ ∈ A generalizing x₁ x₂ hxeq xA
+    · symm
+      apply this hxeq.symm xA.symm (xA.resolve_left x₁A)
+    have x₂A : x₂ ∈ A := by
+      apply _root_.not_imp_self.mp
+      intro (x₂nA : x₂ ∉ A)
+      rw [ite_eq_left x₁A, ite_eq_right x₂nA] at hxeq
+      rw [A_def, sbSet, mem_iUnion] at x₁A
+      have x₂eq : x₂ = g (f x₁) := by
+        sorry
+      rcases x₁A with ⟨n, hn⟩
+      rw [A_def, sbSet, mem_iUnion]
+      use n + 1
+      simp [sbAux]
+      exact ⟨x₁, hn, x₂eq.symm⟩
+    sorry
+  push Not at xA
+  sorry
+
+
+

The proof introduces some new tactics. +To start with, notice the set tactic, which introduces abbreviations +A and h for sbSet f g and sb_fun f g respectively. +We name the corresponding defining equations A_def and h_def. +The abbreviations are definitional, which is to say, Lean will sometimes +unfold them automatically when needed. +But not always; for example, when using rw, we generally need to +use A_def and h_def explicitly. +So the definitions bring a tradeoff: they can make expressions shorter +and more readable, but they sometimes require us to do more work.

+

A more interesting tactic is the wlog tactic, which encapsulates +the symmetry argument in the informal proof above. +We will not dwell on it now, but notice that it does exactly what we want. +If you hover over the tactic you can take a look at its documentation.

+

The argument for surjectivity is even easier. +Given \(y\) in \(\beta\), +we consider two cases, depending on whether \(g(y)\) is in \(A\). +If it is, it can’t be in \(S_0\), the outermost ring, +because by definition that is disjoint from the image of \(g\). +Thus it is an element of \(S_{n+1}\) for some \(n\). +This means that it is of the form \(g(f(x))\) for some +\(x\) in \(S_n\). +By the injectivity of \(g\), we have \(f(x) = y\). +In the case where \(g(y)\) is in the complement of \(A\), +we immediately have \(h(g(y))= y\), and we are done.

+

Once again, we encourage you to step through the proof and fill in +the missing parts. +The tactic rcases n with _ | n splits on the cases g y ∈ sbAux f g 0 +and g y ∈ sbAux f g (n + 1). +In both cases, calling the simplifier with simp [sbAux] +applies the corresponding defining equation of sbAux.

+
theorem sb_surjective (hg : Injective g) : Surjective (sbFun f g) := by
+  set A := sbSet f g with A_def
+  set h := sbFun f g with h_def
+  intro y
+  by_cases gyA : g y ∈ A
+  · rw [A_def, sbSet, mem_iUnion] at gyA
+    rcases gyA with ⟨n, hn⟩
+    rcases n with _ | n
+    · simp [sbAux] at hn
+    simp [sbAux] at hn
+    rcases hn with ⟨x, xmem, hx⟩
+    use x
+    have : x ∈ A := by
+      rw [A_def, sbSet, mem_iUnion]
+      exact ⟨n, xmem⟩
+    rw [h_def, sbFun, ite_eq_left this]
+    apply hg hx
+
+  sorry
+
+
+

We can now put it all together. The final statement is short and sweet, +and the proof uses the fact that Bijective h unfolds to +Injective h ∧ Surjective h.

+
theorem schroeder_bernstein {f : α → β} {g : β → α} (hf : Injective f) (hg : Injective g) :
+    ∃ h : α → β, Bijective h :=
+  ⟨sbFun f g, sb_injective f g hf, sb_surjective f g hg⟩
+
+
+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C05_Elementary_Number_Theory.html b/dev/vendor/mathematics_in_lean/html/C05_Elementary_Number_Theory.html new file mode 100644 index 0000000..14d91f2 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C05_Elementary_Number_Theory.html @@ -0,0 +1,1403 @@ + + + + + + + + + 5. Elementary Number Theory — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

5. Elementary Number Theory

+

In this chapter, we show you how to formalize some elementary +results in number theory. +As we deal with more substantive mathematical content, +the proofs will get longer and more involved, +building on the skills you have already mastered.

+
+

5.1. Irrational Roots

+

Let’s start with a fact known to the ancient Greeks, namely, +that the square root of 2 is irrational. +If we suppose otherwise, +we can write \(\sqrt{2} = a / b\) as a fraction +in lowest terms. Squaring both sides yields \(a^2 = 2 b^2\), +which implies that \(a\) is even. +If we write \(a = 2c\), then we get \(4c^2 = 2 b^2\) +and hence \(b^2 = 2 c^2\). +This implies that \(b\) is also even, contradicting +the fact that we have assumed that \(a / b\) has been +reduced to lowest terms.

+

Saying that \(a / b\) is a fraction in lowest terms means +that \(a\) and \(b\) do not have any factors in common, +which is to say, they are coprime. +Mathlib defines the predicate Nat.Coprime m n to be Nat.gcd m n = 1. +Using Lean’s anonymous projection notation, if s and t are +expressions of type Nat, we can write s.Coprime t instead of +Nat.Coprime s t, and similarly for Nat.gcd. +As usual, Lean will often unfold the definition of Nat.Coprime automatically +when necessary, +but we can also do it manually by rewriting or simplifying with +the identifier Nat.Coprime. +The norm_num tactic is smart enough to compute concrete values.

+
#print Nat.Coprime
+
+example (m n : Nat) (h : m.Coprime n) : m.gcd n = 1 :=
+  h
+
+example (m n : Nat) (h : m.Coprime n) : m.gcd n = 1 := by
+  rw [Nat.Coprime] at h
+  exact h
+
+example : Nat.Coprime 12 7 := by norm_num
+
+example : Nat.gcd 12 8 = 4 := by norm_num
+
+
+

We have already encountered the gcd function in +Section 2.4. +There is also a version of gcd for the integers; +we will return to a discussion of the relationship between +different number systems below. +There are even a generic gcd function and generic +notions of Prime and Coprime +that make sense in general classes of algebraic structures. +We will come to understand how Lean manages this generality +in the next chapter. +In the meanwhile, in this section, we will restrict attention +to the natural numbers.

+

We also need the notion of a prime number, Nat.Prime. +The theorem Nat.prime_def_lt provides one familiar characterization, +and Nat.Prime.eq_one_or_self_of_dvd provides another.

+
#check Nat.prime_def_lt
+
+example (p : ℕ) (prime_p : Nat.Prime p) : 2 ≤ p ∧ ∀ m : ℕ, m < p → m ∣ p → m = 1 := by
+  rwa [Nat.prime_def_lt] at prime_p
+
+#check Nat.Prime.eq_one_or_self_of_dvd
+
+example (p : ℕ) (prime_p : Nat.Prime p) : ∀ m : ℕ, m ∣ p → m = 1 ∨ m = p :=
+  prime_p.eq_one_or_self_of_dvd
+
+example : Nat.Prime 17 := by norm_num
+
+-- commonly used
+example : Nat.Prime 2 :=
+  Nat.prime_two
+
+example : Nat.Prime 3 :=
+  Nat.prime_three
+
+
+

In the natural numbers, a prime number has the property that it cannot +be written as a product of nontrivial factors. +In a broader mathematical context, an element of a ring that has this property +is said to be irreducible. +An element of a ring is said to be prime if whenever it divides a product, +it divides one of the factors. +It is an important property of the natural numbers +that in that setting the two notions coincide, +giving rise to the theorem Nat.Prime.dvd_mul.

+

We can use this fact to establish a key property in the argument +above: +if the square of a number is even, then that number is even as well. +Mathlib defines the predicate Even in Algebra.Group.Even, +but for reasons that will become clear below, +we will simply use 2 ∣ m to express that m is even.

+
#check Nat.Prime.dvd_mul
+#check Nat.Prime.dvd_mul Nat.prime_two
+#check Nat.prime_two.dvd_mul
+
+theorem even_of_even_sqr {m : ℕ} (h : 2 ∣ m ^ 2) : 2 ∣ m := by
+  rw [pow_two, Nat.prime_two.dvd_mul] at h
+  cases h <;> assumption
+
+example {m : ℕ} (h : 2 ∣ m ^ 2) : 2 ∣ m :=
+  Nat.Prime.dvd_of_dvd_pow Nat.prime_two h
+
+
+

As we proceed, you will need to become proficient at finding the facts you +need. +Remember that if you can guess the prefix of the name and +you have imported the relevant library, +you can use tab completion (sometimes with ctrl-tab) to find +what you are looking for. +You can use ctrl-click on any identifier to jump to the file +where it is defined, which enables you to browse definitions and theorems +nearby. +You can also use the search engine on the +Lean community web pages, +and if all else fails, +don’t hesitate to ask on +Zulip.

+
example (a b c : Nat) (h : a * b = a * c) (h' : a ≠ 0) : b = c :=
+  -- apply? suggests the following:
+  (mul_right_inj' h').mp h
+
+
+

The heart of our proof of the irrationality of the square root of two +is contained in the following theorem. +See if you can fill out the proof sketch, using +even_of_even_sqr and the theorem Nat.dvd_gcd.

+
example {m n : ℕ} (coprime_mn : m.Coprime n) : m ^ 2 ≠ 2 * n ^ 2 := by
+  intro sqr_eq
+  have : 2 ∣ m := by
+    sorry
+  obtain ⟨k, meq⟩ := dvd_iff_exists_eq_mul_left.mp this
+  have : 2 * (2 * k ^ 2) = 2 * n ^ 2 := by
+    rw [← sqr_eq, meq]
+    ring
+  have : 2 * k ^ 2 = n ^ 2 :=
+    sorry
+  have : 2 ∣ n := by
+    sorry
+  have : 2 ∣ m.gcd n := by
+    sorry
+  have : 2 ∣ 1 := by
+    sorry
+  norm_num at this
+
+
+

In fact, with very few changes, we can replace 2 by an arbitrary prime. +Give it a try in the next example. +At the end of the proof, you’ll need to derive a contradiction from +p ∣ 1. +You can use Nat.Prime.two_le, which says that +any prime number is greater than or equal to two, +and Nat.le_of_dvd.

+
example {m n p : ℕ} (coprime_mn : m.Coprime n) (prime_p : p.Prime) : m ^ 2 ≠ p * n ^ 2 := by
+  sorry
+
+
+

Let us consider another approach. +Here is a quick proof that if \(p\) is prime, then +\(m^2 \ne p n^2\): if we assume \(m^2 = p n^2\) +and consider the factorization of \(m\) and \(n\) into primes, +then \(p\) occurs an even number of times on the left side of the equation +and an odd number of times on the right, a contradiction. +Note that this argument requires that \(n\) and hence \(m\) +are not equal to zero. +The formalization below confirms that this assumption is sufficient.

+

The unique factorization theorem says that any natural number other +than zero can be written as the product of primes in a unique way. +Mathlib contains a formal version of this, expressed in terms of a function +Nat.primeFactorsList, which returns the list of +prime factors of a number in nondecreasing order. +The library proves that all the elements of Nat.primeFactorsList n +are prime, that any n greater than zero is equal to the +product of its factors, +and that if n is equal to the product of another list of prime numbers, +then that list is a permutation of Nat.primeFactorsList n.

+
#check Nat.primeFactorsList
+#check Nat.prime_of_mem_primeFactorsList
+#check Nat.prod_primeFactorsList
+#check Nat.primeFactorsList_unique
+
+
+

You can browse these theorems and others nearby, even though we have not +talked about list membership, products, or permutations yet. +We won’t need any of that for the task at hand. +We will instead use the fact that Mathlib has a function Nat.factorization, +that represents the same data as a function. +Specifically, Nat.factorization n p, which we can also write +n.factorization p, returns the multiplicity of p in the prime +factorization of n. We will use the following three facts.

+
theorem factorization_mul' {m n : ℕ} (mnez : m ≠ 0) (nnez : n ≠ 0) (p : ℕ) :
+    (m * n).factorization p = m.factorization p + n.factorization p := by
+  rw [Nat.factorization_mul mnez nnez]
+  rfl
+
+theorem factorization_pow' (n k p : ℕ) :
+    (n ^ k).factorization p = k * n.factorization p := by
+  rw [Nat.factorization_pow]
+  rfl
+
+theorem Nat.Prime.factorization' {p : ℕ} (prime_p : p.Prime) :
+    p.factorization p = 1 := by
+  rw [prime_p.factorization]
+  simp
+
+
+

In fact, n.factorization is defined in Lean as a function of finite support, +which explains the strange notation you will see as you step through the +proofs above. Don’t worry about this now. For our purposes here, we can use +the three theorems above as a black box.

+

The next example shows that the simplifier is smart enough to replace +n^2 ≠ 0 by n ≠ 0. The tactic simpa just calls simp +followed by assumption.

+

See if you can use the identities above to fill in the missing parts +of the proof.

+
example {m n p : ℕ} (nnz : n ≠ 0) (prime_p : p.Prime) : m ^ 2 ≠ p * n ^ 2 := by
+  intro sqr_eq
+  have nsqr_nez : n ^ 2 ≠ 0 := by simpa
+  have eq1 : Nat.factorization (m ^ 2) p = 2 * m.factorization p := by
+    sorry
+  have eq2 : (p * n ^ 2).factorization p = 2 * n.factorization p + 1 := by
+    sorry
+  have : 2 * m.factorization p % 2 = (2 * n.factorization p + 1) % 2 := by
+    rw [← eq1, sqr_eq, eq2]
+  rw [add_comm, Nat.add_mul_mod_self_left, Nat.mul_mod_right] at this
+  norm_num at this
+
+
+

A nice thing about this proof is that it also generalizes. There is +nothing special about 2; with small changes, the proof shows that +whenever we write m^k = r * n^k, the multiplicity of any prime p +in r has to be a multiple of k.

+

To use Nat.count_factors_mul_of_pos with r * n^k, +we need to know that r is positive. +But when r is zero, the theorem below is trivial, and easily +proved by the simplifier. +So the proof is carried out in cases. +The line rcases r with _ | r replaces the goal with two versions: +one in which r is replaced by 0, +and the other in which r is replaced by r + 1. +In the second case, we can use the theorem r.succ_ne_zero, which +establishes r + 1 ≠ 0 (succ stands for successor).

+

Notice also that the line that begins have : npow_nz provides a +short proof-term proof of n^k ≠ 0. +To understand how it works, try replacing it with a tactic proof, +and then think about how the tactics describe the proof term.

+

See if you can fill in the missing parts of the proof below. +At the very end, you can use Nat.dvd_sub and Nat.dvd_mul_right +to finish it off.

+

Note that this example does not assume that p is prime, but the +conclusion is trivial when p is not prime since r.factorization p +is then zero by definition, and the proof works in all cases anyway.

+
example {m n k r : ℕ} (nnz : n ≠ 0) (pow_eq : m ^ k = r * n ^ k) {p : ℕ} :
+    k ∣ r.factorization p := by
+  rcases r with _ | r
+  · simp
+  have npow_nz : n ^ k ≠ 0 := fun npowz ↦ nnz (eq_zero_of_pow_eq_zero npowz)
+  have eq1 : (m ^ k).factorization p = k * m.factorization p := by
+    sorry
+  have eq2 : ((r + 1) * n ^ k).factorization p =
+      k * n.factorization p + (r + 1).factorization p := by
+    sorry
+  have : r.succ.factorization p = k * m.factorization p - k * n.factorization p := by
+    rw [← eq1, pow_eq, eq2, add_comm, Nat.add_sub_cancel]
+  rw [this]
+  sorry
+
+
+

There are a number of ways in which we might want to improve on these results. +To start with, a proof that the square root of two is irrational +should say something about the square root of two, +which can be understood as an element of the +real or complex numbers. +And stating that it is irrational should say something about the +rational numbers, namely, that no rational number is equal to it. +Moreover, we should extend the theorems in this section to the integers. +Although it is mathematically obvious that if we could write the square root of +two as a quotient of two integers then we could write it as a quotient +of two natural numbers, +proving this formally requires some effort.

+

In Mathlib, the natural numbers, the integers, the rationals, the reals, +and the complex numbers are represented by separate data types. +Restricting attention to the separate domains is often helpful: +we will see that it is easy to do induction on the natural numbers, +and it is easiest to reason about divisibility of integers when the +real numbers are not part of the picture. +But having to mediate between the different domains is a headache, +one we will have to contend with. +We will return to this issue later in this chapter.

+

We should also expect to be able to strengthen the conclusion of the +last theorem to say that the number r is a k-th power, +since its k-th root is just the product of each prime dividing r +raised to its multiplicity in r divided by k. +To be able to do that we will need better means for reasoning about +products and sums over a finite set, +which is also a topic we will return to.

+

In fact, the results in this section are all established in much +greater generality in Mathlib, +in Data.Real.Irrational. +The notion of multiplicity is defined for an +arbitrary commutative monoid, +and that it takes values in the extended natural numbers enat, +which adds the value infinity to the natural numbers. +In the next chapter, we will begin to develop the means to +appreciate the way that Lean supports this sort of generality.

+
+
+

5.2. Induction and Recursion

+

The set of natural numbers \(\mathbb{N} = \{ 0, 1, 2, \ldots \}\) +is not only fundamentally important in its own right, +but also plays a central role in the construction of new mathematical objects. +Lean’s foundation allows us to declare inductive types, +which are types generated inductively by a given list of +constructors. +In Lean, the natural numbers are declared as follows.

+
inductive Nat where
+  | zero : Nat
+  | succ (n : Nat) : Nat
+
+
+

You can find this in the library by writing #check Nat and +then using ctrl-click on the identifier Nat. +The command specifies that Nat is the datatype generated +freely and inductively by the two constructors zero : Nat and +succ : Nat → Nat. +Of course, the library introduces notation ℕ and 0 for +Nat and zero respectively. (Numerals are translated to binary +representations, but we don’t have to worry about the details of that now.)

+

What “freely” means for the working mathematician is that the type +Nat has an element zero and an injective successor function +succ whose image does not include zero.

+
example (n : Nat) : n.succ ≠ Nat.zero :=
+  Nat.succ_ne_zero n
+
+example (m n : Nat) (h : m.succ = n.succ) : m = n :=
+  Nat.succ.inj h
+
+
+

What the word “inductively” means for the working mathematician is that +the natural numbers comes with a principle of proof by induction +and a principle of definition by recursion. +This section will show you how to use these.

+

Here is an example of a recursive definition of the factorial +function.

+
def fac : ℕ → ℕ
+  | 0 => 1
+  | n + 1 => (n + 1) * fac n
+
+
+

The syntax takes some getting used to. +Notice that there is no := on the first line. +The next two lines provide the base case and inductive step +for a recursive definition. +These equations hold definitionally, but they can also +be used manually by giving the name fac to simp or rw.

+
example : fac 0 = 1 :=
+  rfl
+
+example : fac 0 = 1 := by
+  rw [fac]
+
+example : fac 0 = 1 := by
+  simp [fac]
+
+example (n : ℕ) : fac (n + 1) = (n + 1) * fac n :=
+  rfl
+
+example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := by
+  rw [fac]
+
+example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := by
+  simp [fac]
+
+
+

The factorial function is actually already defined in Mathlib as +Nat.factorial. Once again, you can jump to it by typing +#check Nat.factorial and using ctrl-click. +For illustrative purposes, we will continue using fac in the examples. +The annotation @[simp] before the definition +of Nat.factorial specifies that +the defining equation should be added to the database of identities +that the simplifier uses by default.

+

The principle of induction says that we can prove a general statement +about the natural numbers by proving that the statement holds of 0 +and that whenever it holds of a natural number \(n\), +it also holds of \(n + 1\). +The line induction' n with n ih in the proof +below therefore results in two goals: +in the first we need to prove 0 < fac 0, +and in the second we have the added assumption ih : 0 < fac n +and are required to prove 0 < fac (n + 1). +The phrase with n ih serves to name the variable and +the assumption for the inductive hypothesis, +and you can choose whatever names you want for them.

+
theorem fac_pos (n : ℕ) : 0 < fac n := by
+  induction' n with n ih
+  · rw [fac]
+    exact zero_lt_one
+  rw [fac]
+  exact mul_pos n.succ_pos ih
+
+
+

The induction' tactic is smart enough to include hypotheses +that depend on the induction variable as part of the +induction hypothesis. +Step through the next example to see what is going on.

+
theorem dvd_fac {i n : ℕ} (ipos : 0 < i) (ile : i ≤ n) : i ∣ fac n := by
+  induction' n with n ih
+  · exact absurd ipos (not_lt_of_ge ile)
+  rw [fac]
+  rcases Nat.of_le_succ ile with h | h
+  · apply dvd_mul_of_dvd_right (ih h)
+  rw [h]
+  apply dvd_mul_right
+
+
+

The following example provides a crude lower bound for the factorial +function. +It turns out to be easier to start with a proof by cases, +so that the remainder of the proof starts with the case +\(n = 1\). +See if you can complete the argument with a proof by induction using pow_succ +or pow_succ'.

+
theorem pow_two_le_fac (n : ℕ) : 2 ^ (n - 1) ≤ fac n := by
+  rcases n with _ | n
+  · simp [fac]
+  sorry
+
+
+

Induction is often used to prove identities involving finite sums and +products. +Mathlib defines the expressions Finset.sum s f where +s : Finset α is a finite set of elements of the type α and +f is a function defined on α. +The codomain of f can be any type that supports a commutative, +associative addition operation with a zero element. +If you import Algebra.BigOperators.Ring and issue the command +open BigOperators, you can use the more suggestive notation +∑ x ∈ s, f x. Of course, there is an analogous operation and +notation for finite products.

+

We will talk about the Finset type and the operations +it supports in the next section, and again in a later chapter. +For now, we will only make use +of Finset.range n, which is the finite set of natural numbers +less than n.

+
variable {α : Type*} (s : Finset ℕ) (f : ℕ → ℕ) (n : ℕ)
+
+#check Finset.sum s f
+#check Finset.prod s f
+
+open BigOperators
+open Finset
+
+example : s.sum f = ∑ x ∈ s, f x :=
+  rfl
+
+example : s.prod f = ∏ x ∈ s, f x :=
+  rfl
+
+example : (range n).sum f = ∑ x ∈ range n, f x :=
+  rfl
+
+example : (range n).prod f = ∏ x ∈ range n, f x :=
+  rfl
+
+
+

The facts Finset.sum_range_zero and Finset.sum_range_succ +provide a recursive description of summation up to \(n\), +and similarly for products.

+
example (f : ℕ → ℕ) : ∑ x ∈ range 0, f x = 0 :=
+  Finset.sum_range_zero f
+
+example (f : ℕ → ℕ) (n : ℕ) : ∑ x ∈ range n.succ, f x = ∑ x ∈ range n, f x + f n :=
+  Finset.sum_range_succ f n
+
+example (f : ℕ → ℕ) : ∏ x ∈ range 0, f x = 1 :=
+  Finset.prod_range_zero f
+
+example (f : ℕ → ℕ) (n : ℕ) : ∏ x ∈ range n.succ, f x = (∏ x ∈ range n, f x) * f n :=
+  Finset.prod_range_succ f n
+
+
+

The first identity in each pair holds definitionally, which is to say, +you can replace the proofs by rfl.

+

The following expresses the factorial function that we defined as a product.

+
example (n : ℕ) : fac n = ∏ i ∈ range n, (i + 1) := by
+  induction' n with n ih
+  · simp [fac]
+  simp [fac, ih, prod_range_succ, mul_comm]
+
+
+

The fact that we include mul_comm as a simplification rule deserves +comment. +It should seem dangerous to simplify with the identity x * y = y * x, +which would ordinarily loop indefinitely. +Lean’s simplifier is smart enough to recognize that, and applies the rule +only in the case where the resulting term has a smaller value in some +fixed but arbitrary ordering of the terms. +The following example shows that simplifying using the three rules +mul_assoc, mul_comm, and mul_left_comm +manages to identify products that are the same up to the +placement of parentheses and ordering of variables.

+
example (a b c d e f : ℕ) : a * (b * c * f * (d * e)) = d * (a * f * e) * (c * b) := by
+  simp [mul_comm, mul_left_comm]
+
+
+

Roughly, the rules work by pushing parentheses to the right +and then re-ordering the expressions on both sides until they +both follow the same canonical order. Simplifying with these +rules, and the corresponding rules for addition, is a handy trick.

+

Returning to summation identities, we suggest stepping through the following proof +that the sum of the natural numbers up to and including \(n\) is +\(n (n + 1) / 2\). +The first step of the proof clears the denominator. +This is generally useful when formalizing identities, +because calculations with division generally have side conditions. +(It is similarly useful to avoid using subtraction on the natural numbers when possible.)

+
theorem sum_id (n : ℕ) : ∑ i ∈ range (n + 1), i = n * (n + 1) / 2 := by
+  symm; apply Nat.div_eq_of_eq_mul_right (by norm_num : 0 < 2)
+  induction' n with n ih
+  · simp
+  rw [Finset.sum_range_succ, mul_add 2, ← ih]
+  ring
+
+
+

We encourage you to prove the analogous identity for sums of squares, +and other identities you can find on the web.

+
theorem sum_sqr (n : ℕ) : ∑ i ∈ range (n + 1), i ^ 2 = n * (n + 1) * (2 * n + 1) / 6 := by
+  sorry
+
+
+

In Lean’s core library, addition and multiplication are themselves defined +using recursive definitions, +and their fundamental properties are established using induction. +If you like thinking about foundational topics like that, +you might enjoy working through proofs +of the commutativity and associativity of multiplication and addition +and the distributivity of multiplication over addition. +You can do this on a copy of the natural numbers +following the outline below. +Notice that we can use the induction tactic with MyNat; +Lean is smart enough to know to +use the relevant induction principle (which is, of course, +the same as that for Nat).

+

We start you off with the commutativity of addition. +A good rule of thumb is that because addition and multiplication +are defined by recursion on the second argument, +it is generally advantageous to do proofs by induction on a variable +that occurs in that position. +It is a bit tricky to decide which variable to use in the proof +of associativity.

+

It can be confusing to write things without the usual notation +for zero, one, addition, and multiplication. +We will learn how to define such notation later. +Working in the namespace MyNat means that we can write +zero and succ rather than MyNat.zero and MyNat.succ, +and that these interpretations of the names take precedence over +others. +Outside the namespace, the full name of the add defined below, +for example, is MyNat.add.

+

If you find that you really enjoy this sort of thing, try defining +truncated subtraction and exponentiation and proving some of their +properties as well. +Remember that truncated subtraction cuts off at zero. +To define that, it is useful to define a predecessor function, pred, +that subtracts one from any nonzero number and fixes zero. +The function pred can be defined by a simple instance of recursion.

+
inductive MyNat where
+  | zero : MyNat
+  | succ : MyNat → MyNat
+
+namespace MyNat
+
+def add : MyNat → MyNat → MyNat
+  | x, zero => x
+  | x, succ y => succ (add x y)
+
+def mul : MyNat → MyNat → MyNat
+  | _, zero => zero
+  | x, succ y => add (mul x y) x
+
+theorem zero_add (n : MyNat) : add zero n = n := by
+  induction' n with n ih
+  · rfl
+  rw [add, ih]
+
+theorem succ_add (m n : MyNat) : add (succ m) n = succ (add m n) := by
+  induction' n with n ih
+  · rfl
+  rw [add, ih]
+  rfl
+
+theorem add_comm (m n : MyNat) : add m n = add n m := by
+  induction' n with n ih
+  · rw [zero_add]
+    rfl
+  rw [add, succ_add, ih]
+
+theorem add_assoc (m n k : MyNat) : add (add m n) k = add m (add n k) := by
+  sorry
+theorem mul_add (m n k : MyNat) : mul m (add n k) = add (mul m n) (mul m k) := by
+  sorry
+theorem zero_mul (n : MyNat) : mul zero n = zero := by
+  sorry
+theorem succ_mul (m n : MyNat) : mul (succ m) n = add (mul m n) n := by
+  sorry
+theorem mul_comm (m n : MyNat) : mul m n = mul n m := by
+  sorry
+end MyNat
+
+
+
+
+

5.3. Infinitely Many Primes

+

Let us continue our exploration of induction and recursion with another +mathematical standard: a proof that there are infinitely many primes. +One way to formulate this is as the statement that +for every natural number +\(n\), there is a prime number greater than \(n\). +To prove this, let \(p\) be any prime factor of \(n! + 1\). +If \(p\) is less than or equal to \(n\), it divides \(n!\). +Since it also divides \(n! + 1\), it divides 1, a contradiction. +Hence \(p\) is greater than \(n\).

+

To formalize that proof, we need to show that any number greater than or equal +to 2 has a prime factor. +To do that, we will need to show that any natural number that is +not equal to 0 or 1 is greater-than or equal to 2. +And this brings us to a quirky feature of formalization: +it is often trivial statements like this that are among the most +annoying to formalize. +Here we consider a few ways to do it.

+

To start with, we can use the cases tactic and the fact that the +successor function respects the ordering on the natural numbers.

+
theorem two_le {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by
+  cases m; contradiction
+  case succ m =>
+    cases m; contradiction
+    repeat apply Nat.succ_le_succ
+    apply zero_le
+
+
+

Another strategy is to use the tactic interval_cases, +which automatically splits the goal into cases when +the variable in question is contained in an interval +of natural numbers or integers. +Remember that you can hover over it to see its documentation.

+
example {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by
+  by_contra h
+  push Not at h
+  interval_cases m <;> contradiction
+
+
+

Recall that the semicolon after interval_cases m means +that the next tactic is applied to each of the cases that it generates. +Yet another option is to use the tactic decide, which tries +to find a decision procedure to solve the problem. +Lean knows that you can decide the truth value of a statement that +begins with a bounded quantifier ∀ x, x < n → ... or ∃ x, x < n ∧ ... +by deciding each of the finitely many instances.

+
example {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by
+  by_contra h
+  push Not at h
+  revert h0 h1
+  revert h m
+  decide
+
+
+

With the theorem two_le in hand, let’s start by showing that every +natural number greater than two has a prime divisor. +Mathlib contains a function Nat.minFac that +returns the smallest prime divisor, +but for the sake of learning new parts of the library, +we’ll avoid using it and prove the theorem directly.

+

Here, ordinary induction isn’t enough. +We want to use strong induction, which allows us to prove +that every natural number \(n\) has a property \(P\) +by showing that for every number \(n\), if \(P\) holds +of all values less than \(n\), it holds at \(n\) as well. +In Lean, this principle is called Nat.strong_induction_on, +and we can use the using keyword to tell the induction tactic +to use it. +Notice that when we do that, there is no base case; it is subsumed +by the general induction step.

+

The argument is simply as follows. Assuming \(n ≥ 2\), +if \(n\) is prime, we’re done. If it isn’t, +then by one of the characterizations of what it means to be a prime number, +it has a nontrivial factor, \(m\), +and we can apply the inductive hypothesis to that. +Step through the next proof to see how that plays out.

+
theorem exists_prime_factor {n : Nat} (h : 2 ≤ n) : ∃ p : Nat, p.Prime ∧ p ∣ n := by
+  by_cases np : n.Prime
+  · use n, np
+  induction' n using Nat.strong_induction_on with n ih
+  rw [Nat.prime_def_lt] at np
+  push Not at np
+  rcases np h with ⟨m, mltn, mdvdn, mne1⟩
+  have : m ≠ 0 := by
+    intro mz
+    rw [mz, zero_dvd_iff] at mdvdn
+    linarith
+  have mgt2 : 2 ≤ m := two_le this mne1
+  by_cases mp : m.Prime
+  · use m, mp
+  · rcases ih m mltn mgt2 mp with ⟨p, pp, pdvd⟩
+    use p, pp
+    apply pdvd.trans mdvdn
+
+
+

We can now prove the following formulation of our theorem. +See if you can fill out the sketch. +You can use Nat.factorial_pos, Nat.dvd_factorial, +and Nat.dvd_sub'.

+
theorem primes_infinite : ∀ n, ∃ p > n, Nat.Prime p := by
+  intro n
+  have : 2 ≤ Nat.factorial n + 1 := by
+    sorry
+  rcases exists_prime_factor this with ⟨p, pp, pdvd⟩
+  refine ⟨p, ?_, pp⟩
+  show p > n
+  by_contra ple
+  push Not at ple
+  have : p ∣ Nat.factorial n := by
+    sorry
+  have : p ∣ 1 := by
+    sorry
+  show False
+  sorry
+
+
+

Let’s consider a variation of the proof above, where instead +of using the factorial function, +we suppose that we are given a finite set +\(\{ p_1, \ldots, p_n \}\) and we consider a prime factor of +\(\prod_{i = 1}^n p_i + 1\). +That prime factor has to be distinct from each +\(p_i\), showing that there is no finite set that contains +all the prime numbers.

+

Formalizing this argument requires us to reason about finite +sets. In Lean, for any type α, the type Finset α +represents finite sets of elements of type α. +Reasoning about finite sets computationally requires having +a procedure to test equality on α, which is why the snippet +below includes the assumption [DecidableEq α]. +For concrete data types like ℕ, ℤ, and ℚ, +the assumption is satisfied automatically. When reasoning about +the real numbers, it can be satisfied using classical logic +and abandoning the computational interpretation.

+

We use the command open Finset to avail ourselves of shorter names +for the relevant theorems. Unlike the case with sets, +most equivalences involving finsets do not hold definitionally, +so they need to be expanded manually using equivalences like +Finset.subset_iff, Finset.mem_union, Finset.mem_inter, +and Finset.mem_sdiff. The ext tactic can still be used +to show that two finite sets are equal by showing +that every element of one is an element of the other.

+
open Finset
+
+section
+variable {α : Type*} [DecidableEq α] (r s t : Finset α)
+
+example : r ∩ (s ∪ t) ⊆ r ∩ s ∪ r ∩ t := by
+  rw [subset_iff]
+  intro x
+  rw [mem_inter, mem_union, mem_union, mem_inter, mem_inter]
+  tauto
+
+example : r ∩ (s ∪ t) ⊆ r ∩ s ∪ r ∩ t := by
+  simp [subset_iff]
+  intro x
+  tauto
+
+example : r ∩ s ∪ r ∩ t ⊆ r ∩ (s ∪ t) := by
+  simp [subset_iff]
+  intro x
+  tauto
+
+example : r ∩ s ∪ r ∩ t = r ∩ (s ∪ t) := by
+  ext x
+  simp
+  tauto
+
+end
+
+
+

We have used a new trick: the tauto tactic (and a strengthened +version, tauto!, which uses classical logic) can be used to +dispense with propositional tautologies. See if you can use +these methods to prove the two examples below.

+
example : (r ∪ s) ∩ (r ∪ t) = r ∪ s ∩ t := by
+  sorry
+example : (r \ s) \ t = r \ (s ∪ t) := by
+  sorry
+
+
+

The theorem Finset.dvd_prod_of_mem tells us that if an +n is an element of a finite set s, then n divides +∏ i ∈ s, i.

+
example (s : Finset ℕ) (n : ℕ) (h : n ∈ s) : n ∣ ∏ i ∈ s, i :=
+  Finset.dvd_prod_of_mem _ h
+
+
+

We also need to know that the converse holds in the case where +n is prime and s is a set of primes. +To show that, we need the following lemma, which you should +be able to prove using the theorem Nat.Prime.eq_one_or_self_of_dvd.

+
theorem _root_.Nat.Prime.eq_of_dvd_of_prime {p q : ℕ}
+      (prime_p : Nat.Prime p) (prime_q : Nat.Prime q) (h : p ∣ q) :
+    p = q := by
+  sorry
+
+
+

We can use this lemma to show that if a prime p divides a product of a finite +set of primes, then it is equal to one of them. +Mathlib provides a useful principle of induction on finite sets: +to show that a property holds of an arbitrary finite set s, +show that it holds of the empty set, and show that it is preserved +when we add a single new element a ∉ s. +The principle is known as Finset.induction_on. +When we tell the induction tactic to use it, we can also specify the names +a and s, the name for the assumption a ∉ s in the inductive step, +and the name of the inductive hypothesis. +The expression Finset.insert a s denotes the union of s with the singleton a. +The identities Finset.prod_empty and Finset.prod_insert then provide +the relevant rewrite rules for the product. +In the proof below, the first simp applies Finset.prod_empty. +Step through the beginning of the proof to see the induction unfold, +and then finish it off.

+
theorem mem_of_dvd_prod_primes {s : Finset ℕ} {p : ℕ} (prime_p : p.Prime) :
+    (∀ n ∈ s, Nat.Prime n) → (p ∣ ∏ n ∈ s, n) → p ∈ s := by
+  intro h₀ h₁
+  induction' s using Finset.induction_on with a s ans ih
+  · simp at h₁
+    linarith [prime_p.two_le]
+  simp [Finset.prod_insert ans, prime_p.dvd_mul] at h₀ h₁
+  rw [mem_insert]
+  sorry
+
+
+

We need one last property of finite sets. +Given an element s : Set α and a predicate +P on α, in Chapter 4 +we wrote { x ∈ s | P x } for the set of +elements of s that satisfy P. +Given s : Finset α, +the analogous notion is written s.filter P.

+
example (s : Finset ℕ) (x : ℕ) : x ∈ s.filter Nat.Prime ↔ x ∈ s ∧ x.Prime :=
+  mem_filter
+
+
+

We now prove an alternative formulation of the statement that there are infinitely many +primes, namely, that given any s : Finset ℕ, there is a prime p that is not +an element of s. +Aiming for a contradiction, we assume that all the primes are in s, and then +cut down to a set s' that contains all and only the primes. +Taking the product of that set, adding one, and finding a prime factor +of the result +leads to the contradiction we are looking for. +See if you can complete the sketch below. +You can use Finset.prod_pos in the proof of the first have.

+
theorem primes_infinite' : ∀ s : Finset Nat, ∃ p, Nat.Prime p ∧ p ∉ s := by
+  intro s
+  by_contra h
+  push Not at h
+  set s' := s.filter Nat.Prime with s'_def
+  have mem_s' : ∀ {n : ℕ}, n ∈ s' ↔ n.Prime := by
+    intro n
+    simp [s'_def]
+    apply h
+  have : 2 ≤ (∏ i ∈ s', i) + 1 := by
+    sorry
+  rcases exists_prime_factor this with ⟨p, pp, pdvd⟩
+  have : p ∣ ∏ i ∈ s', i := by
+    sorry
+  have : p ∣ 1 := by
+    convert Nat.dvd_sub pdvd this
+    simp
+  show False
+  sorry
+
+
+

We have thus seen two ways of saying that there are infinitely many primes: +saying that they are not bounded by any n, and saying that they are +not contained in any finite set s. +The two proofs below show that these formulations are equivalent. +In the second, in order to form s.filter Q, we have to assume that there +is a procedure for deciding whether or not Q holds. Lean knows that there +is a procedure for Nat.Prime. In general, if we use classical logic +by writing open Classical, +we can dispense with the assumption.

+

In Mathlib, Finset.sup s f denotes the supremum of the values of f x as x +ranges over s, returning 0 in the case where s is empty and +the codomain of f is ℕ. In the first proof, we use s.sup id, +where id is the identity function, to refer to the maximum value in s.

+
theorem bounded_of_ex_finset (Q : ℕ → Prop) :
+    (∃ s : Finset ℕ, ∀ k, Q k → k ∈ s) → ∃ n, ∀ k, Q k → k < n := by
+  rintro ⟨s, hs⟩
+  use s.sup id + 1
+  intro k Qk
+  apply Nat.lt_succ_of_le
+  show id k ≤ s.sup id
+  apply le_sup (hs k Qk)
+
+theorem ex_finset_of_bounded (Q : ℕ → Prop) [DecidablePred Q] :
+    (∃ n, ∀ k, Q k → k ≤ n) → ∃ s : Finset ℕ, ∀ k, Q k ↔ k ∈ s := by
+  rintro ⟨n, hn⟩
+  use (range (n + 1)).filter Q
+  intro k
+  simpa using hn k
+
+
+

A small variation on our second proof that there are infinitely many primes +shows that there are infinitely many primes congruent to 3 modulo 4. +The argument goes as follows. +First, notice that if the product of two numbers \(m\) and \(n\) +is equal to 3 modulo 4, then one of the two numbers is congruent to 3 modulo 4. +After all, both have to be odd, and if they are both congruent to 1 modulo 4, +so is their product. +We can use this observation to show that if some number +greater than 2 is congruent to 3 modulo 4, +then that number has a prime divisor that is also congruent to 3 modulo 4.

+

Now suppose there are only finitely many prime numbers congruent to 3 +modulo 4, say, \(p_1, \ldots, p_k\). +Without loss of generality, we can assume that \(p_1 = 3\). +Consider the product \(4 \prod_{i = 2}^k p_i + 3\). +It is easy to see that this is congruent to 3 modulo 4, so it has +a prime factor \(p\) congruent to 3 modulo 4. +It can’t be the case that \(p = 3\); since \(p\) +divides \(4 \prod_{i = 2}^k p_i + 3\), if \(p\) +were equal to 3 then it would also divide \(\prod_{i = 2}^k p_i\), +which implies that \(p\) is equal to +one of the \(p_i\) for \(i = 2, \ldots, k\); +and we have excluded 3 from this list. +So \(p\) has to be one of the other elements \(p_i\). +But in that case, \(p\) divides \(4 \prod_{i = 2}^k p_i\) +and hence 3, which contradicts the fact that it is not 3.

+

In Lean, the notation n % m, read “n modulo m,” +denotes the remainder of the division of n by m.

+
example : 27 % 4 = 3 := by norm_num
+
+
+

We can then render the statement “n is congruent to 3 modulo 4” +as n % 4 = 3. The following example and theorems sum up +the facts about this function that we will need to use below. +The first named theorem is another illustration of reasoning by +a small number of cases. +In the second named theorem, remember that the semicolon means that +the subsequent tactic block is applied to all the goals created by the +preceding tactic.

+
example (n : ℕ) : (4 * n + 3) % 4 = 3 := by
+  rw [add_comm, Nat.add_mul_mod_self_left]
+
+theorem mod_4_eq_3_or_mod_4_eq_3 {m n : ℕ} (h : m * n % 4 = 3) : m % 4 = 3 ∨ n % 4 = 3 := by
+  revert h
+  rw [Nat.mul_mod]
+  have : m % 4 < 4 := Nat.mod_lt m (by norm_num)
+  interval_cases m % 4 <;> simp [-Nat.mul_mod_mod]
+  have : n % 4 < 4 := Nat.mod_lt n (by norm_num)
+  interval_cases n % 4 <;> simp
+
+theorem two_le_of_mod_4_eq_3 {n : ℕ} (h : n % 4 = 3) : 2 ≤ n := by
+  apply two_le <;>
+    · intro neq
+      rw [neq] at h
+      norm_num at h
+
+
+

We will also need the following fact, which says that if +m is a nontrivial divisor of n, then so is n / m. +See if you can complete the proof using Nat.div_dvd_of_dvd +and Nat.div_lt_self.

+
theorem aux {m n : ℕ} (h₀ : m ∣ n) (h₁ : 2 ≤ m) (h₂ : m < n) : n / m ∣ n ∧ n / m < n := by
+  sorry
+
+
+

Now put all the pieces together to prove that any +number congruent to 3 modulo 4 has a prime divisor with that +same property.

+
theorem exists_prime_factor_mod_4_eq_3 {n : Nat} (h : n % 4 = 3) :
+    ∃ p : Nat, p.Prime ∧ p ∣ n ∧ p % 4 = 3 := by
+  by_cases np : n.Prime
+  · use n
+  induction' n using Nat.strong_induction_on with n ih
+  rw [Nat.prime_def_lt] at np
+  push Not at np
+  rcases np (two_le_of_mod_4_eq_3 h) with ⟨m, mltn, mdvdn, mne1⟩
+  have mge2 : 2 ≤ m := by
+    apply two_le _ mne1
+    intro mz
+    rw [mz, zero_dvd_iff] at mdvdn
+    linarith
+  have neq : m * (n / m) = n := Nat.mul_div_cancel' mdvdn
+  have : m % 4 = 3 ∨ n / m % 4 = 3 := by
+    apply mod_4_eq_3_or_mod_4_eq_3
+    rw [neq, h]
+  rcases this with h1 | h1
+  . sorry
+  . sorry
+
+
+

We are in the home stretch. Given a set s of prime +numbers, we need to talk about the result of removing 3 from that +set, if it is present. The function Finset.erase handles that.

+
example (m n : ℕ) (s : Finset ℕ) (h : m ∈ erase s n) : m ≠ n ∧ m ∈ s := by
+  rwa [mem_erase] at h
+
+example (m n : ℕ) (s : Finset ℕ) (h : m ∈ erase s n) : m ≠ n ∧ m ∈ s := by
+  simp at h
+  assumption
+
+
+

We are now ready to prove that there are infinitely many primes +congruent to 3 modulo 4. +Fill in the missing parts below. +Our solution uses Nat.dvd_add_iff_left and Nat.dvd_sub' +along the way.

+
theorem primes_mod_4_eq_3_infinite : ∀ n, ∃ p > n, Nat.Prime p ∧ p % 4 = 3 := by
+  by_contra h
+  push Not at h
+  rcases h with ⟨n, hn⟩
+  have : ∃ s : Finset Nat, ∀ p : ℕ, p.Prime ∧ p % 4 = 3 ↔ p ∈ s := by
+    apply ex_finset_of_bounded
+    use n
+    contrapose! hn
+    rcases hn with ⟨p, ⟨pp, p4⟩, pltn⟩
+    exact ⟨p, pltn, pp, p4⟩
+  rcases this with ⟨s, hs⟩
+  have h₁ : ((4 * ∏ i ∈ erase s 3, i) + 3) % 4 = 3 := by
+    sorry
+  rcases exists_prime_factor_mod_4_eq_3 h₁ with ⟨p, pp, pdvd, p4eq⟩
+  have ps : p ∈ s := by
+    sorry
+  have pne3 : p ≠ 3 := by
+    sorry
+  have : p ∣ 4 * ∏ i ∈ erase s 3, i := by
+    sorry
+  have : p ∣ 3 := by
+    sorry
+  have : p = 3 := by
+    sorry
+  contradiction
+
+
+

If you managed to complete the proof, congratulations! This has been a serious +feat of formalization.

+
+
+

5.4. More Induction

+

In Section 5.2, we saw how to define the factorial function by +recursion on the natural numbers.

+
def fac : ℕ → ℕ
+  | 0 => 1
+  | n + 1 => (n + 1) * fac n
+
+
+

We also saw how to prove theorems using the induction' tactic.

+
theorem fac_pos (n : ℕ) : 0 < fac n := by
+  induction' n with n ih
+  · rw [fac]
+    exact zero_lt_one
+  rw [fac]
+  exact mul_pos n.succ_pos ih
+
+
+

The induction tactic (without the prime tick mark) allows for more structured syntax.

+
example (n : ℕ) : 0 < fac n := by
+  induction n
+  case zero =>
+    rw [fac]
+    exact zero_lt_one
+  case succ n ih =>
+    rw [fac]
+    exact mul_pos n.succ_pos ih
+
+example (n : ℕ) : 0 < fac n := by
+  induction n with
+  | zero =>
+    rw [fac]
+    exact zero_lt_one
+  | succ n ih =>
+    rw [fac]
+    exact mul_pos n.succ_pos ih
+
+
+

As usual, you can hover over the induction keyword to read the documentation. +The names of the cases, zero and succ, are taken from the definition of the type ℕ. +Notice that the succ case allows you to choose whatever names you want for the +induction variable and the inductive hypothesis, here n and ih. +You can even prove a theorem with the same notation used to define a recursive function.

+
theorem fac_pos' : ∀ n, 0 < fac n
+  | 0 => by
+    rw [fac]
+    exact zero_lt_one
+  | n + 1 => by
+    rw [fac]
+    exact mul_pos n.succ_pos (fac_pos' n)
+
+
+

Notice also the absence of the :=, the ∀ n after the colon, the by keyword in each case, +and the inductive appeal to fac_pos' n. +It is as though the theorem is a recursive function of n and in the inductive step we make +a recursive call.

+

This style of definition is remarkably flexible. +Lean’s designers have built in elaborate means of defining recursive functions, and these +extend to doing proofs by induction. +For example, we can define the Fibonacci function with multiple base cases.

+
@[simp] def fib : ℕ → ℕ
+  | 0 => 0
+  | 1 => 1
+  | n + 2 => fib n + fib (n + 1)
+
+
+

The @[simp] annotation means that the simplifier will use the defining equations. +You can also apply them by writing rw [fib]. +Below it will be helpful to give a name to the n + 2 case.

+
theorem fib_add_two (n : ℕ) : fib (n + 2) = fib n + fib (n + 1) := rfl
+
+example (n : ℕ) : fib (n + 2) = fib n + fib (n + 1) := by rw [fib]
+
+
+

Using Lean’s notation for recursive functions, you can carry out proofs by induction on the +natural numbers that mirror the recursive definition of fib. +The following example provides an explicit formula for the nth Fibonacci number in terms of +the golden mean, φ, and its conjugate, φ'. +We have to tell Lean that we don’t expect our definitions to generate code because the +arithmetic operations on the real numbers are not computable.

+

We will use the grind tactic to do computations, telling it to use the definitions +of phi and phi’ and the inductively assumed fib_eq n and fib_eq (n+1).

+
noncomputable section
+
+def phi  : ℝ := (1 + √5) / 2
+def phi' : ℝ := (1 - √5) / 2
+
+theorem fib_eq : ∀ n, fib n = (phi^n - phi'^n) / √5
+  | 0   => by simp
+  | 1   => by unfold fib; grind [phi, phi']
+  | n+2 => by unfold fib; simp [fib_eq n, fib_eq (n+1), phi, phi']; grind
+
+end
+
+
+

Induction proofs involving the Fibonacci function do not have to be of that form. +Below we reproduce the Mathlib proof that consecutive Fibonacci numbers are coprime.

+
theorem fib_coprime_fib_succ (n : ℕ) : Nat.Coprime (fib n) (fib (n + 1)) := by
+  induction n with
+  | zero => simp
+  | succ n ih =>
+    simp only [fib, Nat.coprime_add_self_right]
+    exact ih.symm
+
+
+

Using Lean’s computational interpretation, we can evaluate the Fibonacci numbers.

+
#eval fib 6
+#eval List.range 20 |>.map fib
+
+
+

The straightforward implementation of fib is computationally inefficient. In fact, it runs +in time exponential in its argument. (You should think about why.) +In Lean, we can implement the following tail-recursive version, whose running time is linear +in n, and prove that it computes the same function.

+
def fib' (n : Nat) : Nat :=
+  aux n 0 1
+where aux
+  | 0,   x, _ => x
+  | n+1, x, y => aux n y (x + y)
+
+theorem fib'.aux_eq (m n : ℕ) : fib'.aux n (fib m) (fib (m + 1)) = fib (n + m) := by
+  induction n generalizing m with
+  | zero => simp [fib'.aux]
+  | succ n ih => rw [fib'.aux, ←fib_add_two, ih, add_assoc, add_comm 1]
+
+theorem fib'_eq_fib : fib' = fib := by
+  ext n
+  erw [fib', fib'.aux_eq 0 n]; rfl
+
+#eval fib' 10000
+
+
+

Notice the generalizing keyword in the proof of fib'.aux_eq. +It serves to insert a ∀ m in front of the inductive hypothesis, so that in the induction +step, m can take a different value. +You can step through the proof and check that in this case, the quantifier needs to be +instantiated to m + 1 in the inductive step.

+

Notice also the use of erw (for “extended rewrite”) instead of rw. +This is used because to rewrite the goal fib'.aux_eq, fib 0 and fib 1 +have to be reduced to 0 and 1, respectively. +The tactic erw is more aggressive than rw in unfolding definitions to +match parameters. +This isn’t always a good idea; it can waste a lot of time in some cases, so use erw +sparingly.

+

Here is another example of the generalizing keyword in use, in the proof of another +identity that is found in Mathlib. +An informal proof of the identity can be found here. +We provide two variants of the formal proof.

+
theorem fib_add (m n : ℕ) : fib (m + n + 1) = fib m * fib n + fib (m + 1) * fib (n + 1) := by
+  induction n generalizing m with
+  | zero => simp
+  | succ n ih =>
+    specialize ih (m + 1)
+    rw [add_assoc m 1 n, add_comm 1 n] at ih
+    simp only [fib_add_two, ih]
+    ring
+
+theorem fib_add' : ∀ m n, fib (m + n + 1) = fib m * fib n + fib (m + 1) * fib (n + 1)
+  | _, 0     => by simp
+  | m, n + 1 => by
+    have := fib_add' (m + 1) n
+    rw [add_assoc m 1 n, add_comm 1 n] at this
+    simp only [fib_add_two, this]
+    ring
+
+
+

As an exercise, use fib_add to prove the following.

+
example (n : ℕ): (fib n) ^ 2 + (fib (n + 1)) ^ 2 = fib (2 * n + 1) := by
+  sorry
+
+
+

Lean’s mechanisms for defining recursive functions are flexible enough to allow arbitrary +recursive calls, as long as the complexity of the arguments decrease according to some +well-founded measure. +In the next example, we show that every natural number n ≠ 1 has a prime divisor, +using the fact that if n is nonzero and not prime, it has a smaller divisor. +(You can check that Mathlib has a theorem of the same name in the Nat namespace, +though it has a different proof than the one we give here.)

+
#check (@Nat.not_prime_iff_exists_dvd_lt :
+  ∀ {n : ℕ}, 2 ≤ n → (¬Nat.Prime n ↔ ∃ m, m ∣ n ∧ 2 ≤ m ∧ m < n))
+
+theorem ne_one_iff_exists_prime_dvd : ∀ {n}, n ≠ 1 ↔ ∃ p : ℕ, p.Prime ∧ p ∣ n
+  | 0 => by simpa using Exists.intro 2 Nat.prime_two
+  | 1 => by simp [Nat.not_prime_one]
+  | n + 2 => by
+    have hn : n + 2 ≠ 1 := by omega
+    simp only [Ne, not_false_iff, true_iff, hn]
+    by_cases h : Nat.Prime (n + 2)
+    · use n + 2, h
+    · have : 2 ≤ n + 2 := by omega
+      rw [Nat.not_prime_iff_exists_dvd_lt this] at h
+      rcases h with ⟨m, mdvdn, mge2, -⟩
+      have : m ≠ 1 := by omega
+      rw [ne_one_iff_exists_prime_dvd] at this
+      rcases this with ⟨p, primep, pdvdm⟩
+      use p, primep
+      exact pdvdm.trans mdvdn
+
+
+

The line rw [ne_one_iff_exists_prime_dvd] at this is like a magic trick: we are using +the very theorem we are proving in its own proof. +What makes it work is that the inductive call is instantiated at m, +the current case is n + 2, and the context has m < n + 2. +Lean can find the hypothesis and use it to show that the induction is well-founded. +Lean is pretty good at figuring out what is decreasing; in this case, the choice of +n in the statement of the theorem and the less-than relation is obvious. +In more complicated cases, Lean provides mechanisms to provide this information +explicitly. See the section on well-founded recursion in the Lean Reference Manual.

+

Sometimes, in a proof, you need to split on cases depending on whether a natural number n +is zero or a successor, without requiring an inductive hypothesis in the successor case. +For that, you can use the cases and rcases tactics.

+
theorem zero_lt_of_mul_eq_one (m n : ℕ) : n * m = 1 → 0 < n ∧ 0 < m := by
+  cases n <;> cases m <;> simp
+
+example (m n : ℕ) : n*m = 1 → 0 < n ∧ 0 < m := by
+  rcases m with (_ | m); simp
+  rcases n with (_ | n) <;> simp
+
+
+

This is a useful trick. +Often you have a theorem about a natural number n for which the zero case is easy. +If you case on n and take care of the zero case quickly, you are left with the original +goal with n replaced by n + 1.

+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C06_Discrete_Mathematics.html b/dev/vendor/mathematics_in_lean/html/C06_Discrete_Mathematics.html new file mode 100644 index 0000000..3325eb9 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C06_Discrete_Mathematics.html @@ -0,0 +1,839 @@ + + + + + + + + + 6. Discrete Mathematics — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

6. Discrete Mathematics

+

Discrete Mathematics is the study of finite sets, objects, and structures. +We can count the elements of a finite set, and we can compute finite sums or products over its +elements, we can compute maximums and minimums, and so on. +We can also study objects that are generated by finitely many applications of +certain generating functions, we can define functions by structural recursion, +and prove theorems by structural induction. +This chapter describes parts of Mathlib that support these activities.

+
+

6.1. Finsets and Fintypes

+

Dealing with finite sets and types in Mathlib can be confusing, because the library offers +multiple ways of handling them. In this section we will discuss the most common ones.

+

We have already come across the type Finset in Section 5.2 +and Section 5.3. +As the name suggests, an element of type Finset α is a finite set of elements of type α. +We will call these “finsets.” +The Finset data type is designed to have a computational interpretation, +and many basic operations on Finset α assume that α has decidable equality, +which guarantees that there is an algorithm for testing whether a : α is an element +of a finset s.

+
section
+variable {α : Type*} [DecidableEq α] (a : α) (s t : Finset α)
+
+#check a ∈ s
+#check s ∩ t
+
+end
+
+
+

If you remove the declaration [DecidableEq α], Lean will complain on the line +#check s ∩ t because it cannot compute the intersection. +All of the data types that you should expect to be able to compute with +have decidable equality, however, +and if you work classically by opening the Classical namespace and +declaring noncomputable section, you can reason about finsets of elements of any type +at all.

+

Finsets support most of the set-theoretic operations that sets do:

+
open Finset
+
+variable (a b c : Finset ℕ)
+variable (n : ℕ)
+
+#check a ∩ b
+#check a ∪ b
+#check a \ b
+#check (∅ : Finset ℕ)
+
+example : a ∩ (b ∪ c) = (a ∩ b) ∪ (a ∩ c) := by
+  ext x; simp only [mem_inter, mem_union]; tauto
+
+example : a ∩ (b ∪ c) = (a ∩ b) ∪ (a ∩ c) := by rw [inter_union_distrib_left]
+
+
+

Note that we have opened the Finset namespace, +where theorems specific to finsets are found. +If you step through the last example below, you will see applying ext +followed by simp reduces the identity to a problem +in propositional logic. +As an exercise, you can try proving some of set identities from +Chapter 4, transported to finsets.

+

You have already seen the notation Finset.range n for the +finite set of natural numbers \(\{ 0, 1, \ldots, n-1 \}\). +Finset also allows you to define finite sets by enumerating +the elements:

+
#check ({0, 2, 5} : Finset Nat)
+
+def example1 : Finset ℕ := {0, 1, 2}
+
+
+

There are various ways to get Lean to recognize that order of elements and +duplicates do not matter in a set presented in this way.

+
example : ({0, 1, 2} : Finset ℕ) = {1, 2, 0} := by decide
+
+example : ({0, 1, 2} : Finset ℕ) = {0, 1, 1, 2} := by decide
+
+example : ({0, 1} : Finset ℕ) = {1, 0} := by rw [Finset.pair_comm]
+
+example (x : Nat) : ({x, x} : Finset ℕ) = {x} := by simp
+
+example (x y z : Nat) : ({x, y, z, y, z, x} : Finset ℕ) = {x, y, z} := by
+  ext i; simp [or_comm, or_left_comm]
+
+example (x y z : Nat) : ({x, y, z, y, z, x} : Finset ℕ) = {x, y, z} := by
+  ext i; simp; tauto
+
+
+

You can use insert to add a single element to a Finset, and Finset.erase +to delete a single element. +Note that erase is in the Finset namespace, but insert is in the root +namespace.

+
example (s : Finset ℕ) (a : ℕ) (h : a ∉ s) : (insert a s |>.erase a) = s :=
+  Finset.erase_insert h
+
+example (s : Finset ℕ) (a : ℕ) (h : a ∈ s) : insert a (s.erase a) = s :=
+  Finset.insert_erase h
+
+
+

In fact, {0, 1, 2} is just notation for insert 0 (insert 1 (singleton 2)).

+
set_option pp.notation false in
+#check ({0, 1, 2} : Finset ℕ)
+
+
+

Given a finset s and a predicate P, we can use set-builder notation {x ∈ s | P x} to +define the set of elements of s that satisfy P. +This is notation for Finset.filter P s, which can also be written s.filter P.

+
example : {m ∈ range n | Even m} = (range n).filter Even := rfl
+example : {m ∈ range n | Even m ∧ m ≠ 3} = (range n).filter (fun m ↦ Even m ∧ m ≠ 3) := rfl
+
+example : {m ∈ range 10 | Even m} = {0, 2, 4, 6, 8} := by decide
+
+
+

Mathlib knows that the image of a finset under a function is a finset.

+
#check (range 5).image (fun x ↦ x * 2)
+
+example : (range 5).image (fun x ↦ x * 2) = {x ∈ range 10 | Even x} := by decide
+
+
+

Lean also knows that the cartesian product s ×ˢ t of two finsets is a finset, +and that the powerset of a finset is a finset. (Note that the notation s ×ˢ t +also works for sets.)

+
#check s ×ˢ t
+#check s.powerset
+
+
+

Defining operations on finsets in terms of their elements is tricky, because any such definition +has to be independent of the order in which the elements are presented. +Of course, you can always define functions by composing existing operations. +Another thing you can do is use Finset.fold to fold a binary operation over the +elements, provided that the operation is associative and commutative, +since these properties guarantee that the result is independent of the order that +the operation is applied. Finite sums, products, and unions are defined in that way. +In the last example below, biUnion stands for “bounded indexed union.” +With conventional mathematical notation, the expression would be written +\(\bigcup_{i ∈ s} g(i)\).

+
#check Finset.fold
+
+def f (n : ℕ) : Int := (↑n)^2
+
+#check (range 5).fold (fun x y : Int ↦ x + y) 0 f
+#eval (range 5).fold (fun x y : Int ↦ x + y) 0 f
+
+#check ∑ i ∈ range 5, i^2
+#check ∏ i ∈ range 5, i + 1
+
+variable (g : Nat → Finset Int)
+
+#check (range 5).biUnion g
+
+
+

There is a natural principle of induction on finsets: to prove that every finset +has a property, show that the empty set has the property and that the property is +preserved when we add one new element to a finset. (The @ symbol in +@insert is needed in the induction step of the next example to give names to the +parameters a and s because they have been marked implicit. )

+
#check Finset.induction
+
+example {α : Type*} [DecidableEq α] (f : α → ℕ)  (s : Finset α) (h : ∀ x ∈ s, f x ≠ 0) :
+    ∏ x ∈ s, f x ≠ 0 := by
+  induction s using Finset.induction_on with
+  | empty => simp
+  | @insert a s anins ih =>
+    rw [prod_insert anins]
+    apply mul_ne_zero
+    · apply h; apply mem_insert_self
+    apply ih
+    intros x xs
+    exact h x (mem_insert_of_mem xs)
+
+
+

If s is a finset, Finset.Nonempty s is defined to be ∃ x, x ∈ s. +You can use classical choice to pick an element of a nonempty finset. Similarly, +the library defines Finset.toList s which uses choice to pick the elements of +s in some order.

+
noncomputable example (s : Finset ℕ) (h : s.Nonempty) : ℕ := Classical.choose h
+
+example (s : Finset ℕ) (h : s.Nonempty) : Classical.choose h ∈ s := Classical.choose_spec h
+
+noncomputable example (s : Finset ℕ) : List ℕ := s.toList
+
+example (s : Finset ℕ) (a : ℕ) : a ∈ s.toList ↔ a ∈ s := mem_toList
+
+
+

You can use Finset.min and Finset.max to choose the minimum or maximum element +of a finset of elements of a linear order, and similarly you can use Finset.inf +and Finset.sup with finsets of elements of a lattice, but there is a catch. +What should the minimum element of an empty finset be? +You can check that the primed versions of the functions below add a precondition +that the finset is nonempty. +The non-primed versions Finset.min and Finset.max +add a top or bottom element, respectively, to the output type, to handle the case where the +finset is empty. +The non-primed versions Finset.inf and Finset.sup assume that +the lattice comes equipped with a top or bottom element, respectively.

+
#check Finset.min
+#check Finset.min'
+#check Finset.max
+#check Finset.max'
+#check Finset.inf
+#check Finset.inf'
+#check Finset.sup
+#check Finset.sup'
+
+example : Finset.Nonempty {2, 6, 7} := ⟨6, by trivial⟩
+example : Finset.min' {2, 6, 7} ⟨6, by trivial⟩ = 2 := by trivial
+
+
+

Every finset s has a finite cardinality, Finset.card s, which can be written #s +when the Finset namespace is open.

+
#check Finset.card
+
+#eval (range 5).card
+
+example (s : Finset ℕ) : s.card = #s := by rfl
+
+example (s : Finset ℕ) : s.card = ∑ _i ∈ s, 1 := by rw [card_eq_sum_ones]
+
+example (s : Finset ℕ) : s.card = ∑ _i ∈ s, 1 := by simp
+
+
+

The next section is all about reasoning about cardinality.

+

When formalizing mathematics, one often has to make a decision as to whether to express +one’s definitions and theorems in terms of sets or types. +Using types often simplifies notation and proofs, but working +with subsets of a type can be more flexible. +The type-based analogue of a finset is a fintype, that is, a type Fintype α for some +α. +By definition, a fintype is just a data type that comes equipped with a finset univ that +contains all its elements.

+
variable {α : Type*} [Fintype α]
+
+example : ∀ x : α, x ∈ Finset.univ := by
+  intro x; exact mem_univ x
+
+
+

Fintype.card α is equal to the cardinality of the corresponding finset.

+
example : Fintype.card α = (Finset.univ : Finset α).card := rfl
+
+
+

We have already seen a prototypical example of a fintype, namely, the types Fin n for +each n. +Lean recognizes that the fintypes are closed under operations like the product operation.

+
example : Fintype.card (Fin 5) = 5 := by simp
+example : Fintype.card ((Fin 5) × (Fin 3)) = 15 := by simp
+
+
+

Any element s of Finset α can be coerced to a type (↑s : Type α), namely, +the subtype of elements of α that are contained in s. Moreover, Lean knows that ↑s +is a fintype.

+
variable (s : Finset ℕ)
+
+example : (↑s : Type) = {x : ℕ // x ∈ s} := rfl
+example : Fintype.card ↑s = s.card := by simp
+
+
+

Lean and Mathlib use type class inference to track the additional structure on fintypes, +namely, the universal finset that contains all the elements. +In other words, you can think of a fintype as an algebraic structure equipped with that +extra data. +Chapter 7 explains how this works.

+
+
+

6.2. Counting Arguments

+

The art of counting things is a central part of combinatorics. +Mathlib contains several basic identities for counting elements of finsets:

+
open Finset
+
+variable {α β : Type*} [DecidableEq α] [DecidableEq β] (s t : Finset α) (f : α → β)
+
+example : #(s ×ˢ t) = #s * #t := by rw [card_product]
+example : #(s ×ˢ t) = #s * #t := by simp
+
+example : #(s ∪ t) = #s + #t - #(s ∩ t) := by rw [card_union]
+
+example (h : Disjoint s t) : #(s ∪ t) = #s + #t := by rw [card_union_of_disjoint h]
+example (h : Disjoint s t) : #(s ∪ t) = #s + #t := by simp [h]
+
+example (h : Function.Injective f) : #(s.image f) = #s := by rw [card_image_of_injective _ h]
+
+example (h : Set.InjOn f s) : #(s.image f) = #s := by rw [card_image_of_injOn h]
+
+
+

Opening the Finset namespace allows us to use the notation #s for s.card, as well as +to use the shortened names card_union and so on.

+

Mathlib can also count elements of fintypes:

+
open Fintype
+
+variable {α β : Type*} [Fintype α] [Fintype β]
+
+example : card (α × β) = card α * card β := by simp
+
+example : card (α ⊕ β) = card α + card β := by simp
+
+example (n : ℕ) : card (Fin n → α) = (card α)^n := by simp
+
+variable {n : ℕ} {γ : Fin n → Type*} [∀ i, Fintype (γ i)]
+
+example : card ((i : Fin n) → γ i) = ∏ i, card (γ i) := by simp
+
+example : card (Σ i, γ i) = ∑ i, card (γ i) := by simp
+
+
+

When the Fintype namespace is not open, we have to use Fintype.card instead of card.

+

The following is an example of calculating the cardinality of a finset, namely, the union of +range n with a copy of range n that has been shifted by more than n. +The calculation requires showing the the two sets in the union are disjoint; +the first line of the proof yields the side condition +Disjoint (range n) (image (fun i ↦ m + i) (range n)), which is established at the end of the +proof. +The Disjoint predicate is too general to be directly useful to us, but the theorem +disjoint_iff_ne puts it in a form we can use.

+
#check Disjoint
+
+example (m n : ℕ) (h : m ≥ n) :
+    card (range n ∪ (range n).image (fun i ↦ m + i)) = 2 * n := by
+  rw [card_union_of_disjoint, card_range, card_image_of_injective, card_range]; omega
+  . apply add_right_injective
+  . simp [disjoint_iff_ne]; omega
+
+
+

Throughout this section, omega will be a workhorse for us, for dealing with arithmetic +calculations and inequalities.

+

Here is a more interesting example. Consider the subset of +\(\{0, \ldots, n\} \times \{0, \ldots, n\}\) consisting +of pairs \((i, j)\) such that \(i < j\). If you think of these as lattice points in the coordinate +plane, they constitute an upper triangle of the square with corners \((0, 0)\) and +\((n, n)\), not +including the diagonal. The cardinality of the full square is \((n + 1)^2\), and removing the size of +the diagonal and halving the result shows us that the cardinality of the triangle is +\(n (n + 1) / 2\).

+

Alternatively, we note that the rows of the triangle have sizes \(0, 1, \ldots, n\), so the +cardinality is the sum of the first \(n\) positive integers. The first have of the proof +below describes the triangle as the union of the rows, where row \(j\) consists of +the numbers \(0, 1, ..., j - 1\) paired with \(j\). +In the proof below, the notation (., j) abbreviates the function +fun i ↦ (i, j). The rest of the proof is just a calculation with finset cardinalities.

+
def triangle (n : ℕ) : Finset (ℕ × ℕ) := {p ∈ range (n+1) ×ˢ range (n+1) | p.1 < p.2}
+
+example (n : ℕ) : #(triangle n) = (n + 1) * n / 2 := by
+  have : triangle n = (range (n+1)).biUnion (fun j ↦ (range j).image (., j)) := by
+    ext p
+    simp only [triangle, mem_filter, mem_product, mem_range, mem_biUnion, mem_image]
+    constructor
+    . rintro ⟨⟨hp1, hp2⟩, hp3⟩
+      use p.2, hp2, p.1, hp3
+    . rintro ⟨p1, hp1, p2, hp2, rfl⟩
+      omega
+  rw [this, card_biUnion]; swap
+  · -- take care of disjointness first
+    intro x _ y _ xney
+    simp [disjoint_iff_ne, xney]
+  -- continue the calculation
+  transitivity (∑ i ∈ range (n + 1), i)
+  · congr; ext i
+    rw [card_image_of_injective, card_range]
+    intros i1 i2; simp
+  rw [sum_range_id]; rfl
+
+
+

The following variation on the proof does the calculation with fintypes instead of finsets. +The type α ≃ β is the type of equivalences between α and β, consisting of a map +in the forward direction, the map in the backward direction, and proofs that these two are +inverse to one another. The first have in the proof shows that triangle n is equivalent to +the disjoint union of Fin i as i ranges over Fin (n + 1). Interestingly, the forward +function and the reverse function are constructed with tactics, rather than written explicitly. +Since they do nothing more than move data and information around, rfl establishes that they +are inverses.

+

After that, rw [←Fintype.card_coe] rewrites #(triangle n) as the cardinality of the subtype +{ x // x ∈ triangle n }, and the rest of the proof is a calculation.

+
example (n : ℕ) : #(triangle n) = (n + 1) * n / 2 := by
+  have : triangle n ≃ Σ i : Fin (n + 1), Fin i.val :=
+    { toFun := by
+        rintro ⟨⟨i, j⟩, hp⟩
+        have : (i ≤ n ∧ j ≤ n) ∧ i < j := by simpa [triangle] using hp
+        exact ⟨⟨j, by linarith⟩, ⟨i, by linarith⟩⟩
+      invFun := by
+        rintro ⟨i, j⟩
+        use ⟨j, i⟩
+        suffices j ≤ n ∧ i ≤ n by simpa [triangle]
+        constructor <;> linarith [i.2, j.2]
+      left_inv := by intro i; rfl
+      right_inv := by intro i; rfl }
+  rw [←Fintype.card_coe]
+  trans; apply (Fintype.card_congr this)
+  rw [Fintype.card_sigma, sum_fin_eq_sum_range]
+  convert! Finset.sum_range_id (n + 1)
+  simp_all
+
+
+

Here is yet another approach. The first line of the proof below reduces the problem to showing +2 * #(triangle n) = (n + 1) * n. We can do that by showing that two copies of the triangle +exactly fill the rectangle range n ×ˢ range (n + 1). +As an exercise, see if you can fill in the steps of the calculation. +In the solutions, we rely on omega +extensively in the second-to-last step, but we unfortunately have to do a fair amount of +work by hand.

+
example (n : ℕ) : #(triangle n) = (n + 1) * n / 2 := by
+  apply Nat.eq_div_of_mul_eq_right (by norm_num)
+  let turn (p : ℕ × ℕ) : ℕ × ℕ := (n - 1 - p.1, n - p.2)
+  calc 2 * #(triangle n)
+      = #(triangle n) + #(triangle n) := by
+          sorry
+    _ = #(triangle n) + #(triangle n |>.image turn) := by
+          sorry
+    _ = #(range n ×ˢ range (n + 1)) := by
+          sorry
+    _ = (n + 1) * n := by
+          sorry
+
+
+

You can convince yourself that we get the same triangle, shifted down, if we replace n by +n + 1 +and replace < by ≤ in the definition of triangle. +The exercise below asks you to use this fact to show that the two triangles have the same size.

+
def triangle' (n : ℕ) : Finset (ℕ × ℕ) := {p ∈ range n ×ˢ range n | p.1 ≤ p.2}
+
+example (n : ℕ) : #(triangle' n) = #(triangle n) := by sorry
+
+
+

Let us close this section with an example and an exercise from a tutorial +on combinatorics given by Bhavik Mehta at Lean for the Curious Mathematician in 2023. +Suppose we have a bipartite graph with vertex sets s and t, such that for every a in +s, there are at least three edges leaving a, and for every b in t, there is at most +one edge entering b. Then the total number of edges in the graph is at least three times the +cardinality of s and at most the cardinality of t, from which is follows that three times the cardinality of s is at most the cardinality of t. +The following theorem implements this argument, where we use the relation r to represent +the edges of the graph. The proof is an elegant calculation.

+
open Classical
+variable (s t : Finset ℕ) (a b : ℕ)
+
+theorem doubleCounting {α β : Type*} (s : Finset α) (t : Finset β)
+    (r : α → β → Prop)
+    (h_left : ∀ a ∈ s, 3 ≤ #{b ∈ t | r a b})
+    (h_right : ∀ b ∈ t, #{a ∈ s | r a b} ≤ 1) :
+    3 * #(s) ≤ #(t) := by
+  calc 3 * #(s)
+      = ∑ a ∈ s, 3                               := by simp [mul_comm]
+    _ ≤ ∑ a ∈ s, #({b ∈ t | r a b})              := sum_le_sum h_left
+    _ = ∑ a ∈ s, ∑ b ∈ t, if r a b then 1 else 0 := by simp
+    _ = ∑ b ∈ t, ∑ a ∈ s, if r a b then 1 else 0 := sum_comm
+    _ = ∑ b ∈ t, #({a ∈ s | r a b})              := by simp
+    _ ≤ ∑ b ∈ t, 1                               := sum_le_sum h_right
+    _ ≤ #(t)                                     := by simp
+
+
+

The following exercise is also taken from Mehta’s tutorial. Suppose A is a subset of +range (2 * n) with n + 1 elements. +It’s easy to see that A must contain two +consecutive integers, and hence two elements that are coprime. +If you watch the tutorial, you will see that a good deal of effort was spent in +establishing the following fact, which is now proved automatically by omega.

+
example (m k : ℕ) (h : m ≠ k) (h' : m / 2 = k / 2) : m = k + 1 ∨ k = m + 1 := by omega
+
+
+

The solution to Mehta’s exercise uses the pigeonhole principle, in the form +exists_lt_card_fiber_of_mul_lt_card_of_maps_to, to show that there are two distinct elements +m and k in A such that m / 2 = k / 2. +See if you can complete the justification of that fact and then use it to finish the proof.

+
example {n : ℕ} (A : Finset ℕ)
+    (hA : #(A) = n + 1)
+    (hA' : A ⊆ range (2 * n)) :
+    ∃ m ∈ A, ∃ k ∈ A, Nat.Coprime m k := by
+  have : ∃ t ∈ range n, 1 < #({u ∈ A | u / 2 = t}) := by
+    apply exists_lt_card_fiber_of_mul_lt_card_of_maps_to
+    · sorry
+    · sorry
+  rcases this with ⟨t, ht, ht'⟩
+  simp only [one_lt_card, mem_filter] at ht'
+  sorry
+
+
+
+
+

6.3. Inductively Defined Types

+

Lean’s foundation allows us to define inductive types, that is, data types whose instances +are generated from the bottom up. +For example, the data type List α of lists of elements of α is generated by starting +with the empty list, nil, and successively adding elements to the front the list. +Below we will define a type of binary trees, BinTree, whose elements are generated by +starting with the empty tree and building new trees by attaching a new node to two existing trees.

+

In Lean, one can define inductive types whose objects are infinite, like countably branching +well-founded trees. +Finite inductive definitions are commonly used in discrete mathematics, however, +especially in those branches of discrete mathematics that are relevant to computer science. +Lean provides not only the means to define such types, but also principles of induction and +definition by recursion. For example, the data type List α is defined inductively:

+
namespace MyListSpace
+
+inductive List (α : Type*) where
+  | nil  : List α
+  | cons : α → List α → List α
+
+end MyListSpace
+
+
+

The inductive definition says that every element of List α is either nil, the empty list, +or cons a as, where a is an element of α and as is a list of elements of α. +The constructors are properly named List.nil and List.cons, but you can use the shorter +notation when the List namespace is open. +When the List namespace is not open, you can write .nil and .cons a as anywhere +that Lean expects a list, and Lean will automatically insert the List qualifier. +Throughout this section, we will put temporary definitions in separate namespaces like +MyListSpace to avoid conflicts with the standard library. Outside the temporary namespace, +we revert to using the standard library definitions.

+

Lean defines the notation [] for nil and :: for cons, and you can write +[a, b, c] for a :: b :: c :: []. The append and map functions are defined +recursively as follows:

+
def append {α : Type*} : List α → List α → List α
+  | [],      bs => bs
+  | a :: as, bs => a :: append as bs
+
+def map {α β : Type*} (f : α → β) : List α → List β
+  | []      => []
+  | a :: as => f a :: map f as
+
+#eval append [1, 2, 3] [4, 5, 6]
+#eval map (fun n => n^2) [1, 2, 3, 4, 5]
+
+
+

Notice that there is a base case and a recursive case. +In each case, the two defining clauses hold definitionally:

+
theorem nil_append {α : Type*} (as : List α) : append [] as = as := rfl
+
+theorem cons_append {α : Type*} (a : α) (as : List α) (bs : List α) :
+    append (a :: as) bs = a :: append as bs := rfl
+
+theorem map_nil {α β : Type*} (f : α → β) : map f [] = [] := rfl
+
+theorem map_cons {α β : Type*} (f : α → β) (a : α) (as : List α) :
+    map f (a :: as) = f a :: map f as := rfl
+
+
+

The functions append and map are defined in the standard library, and append as bs +can be written as as ++ bs.

+

Lean allows you to write proofs by induction following the structure of the definition.

+
variable {α β γ : Type*}
+variable (as bs cs : List α)
+variable (a b c : α)
+
+open List
+
+theorem append_nil : ∀ as : List α, as ++ [] = as
+  | [] => rfl
+  | a :: as => by rw [cons_append, append_nil as]
+
+theorem map_map (f : α → β) (g : β → γ) :
+    ∀ as : List α, map g (map f as) = map (g ∘ f) as
+  | [] => rfl
+  | a :: as => by rw [map_cons, map_cons, map_cons, map_map f g as]; rfl
+
+
+

You can also use the induction' tactic.

+

Of course, these theorems are already in the standard library. As an exercise, +try defining a function reverse in the MyListSpace3 namespace (to avoid +conflicting with the standard List.reverse) that reverses a list. +You can use #eval reverse [1, 2, 3, 4, 5] to test it out. +The most straightforward definition of +reverse requires quadratic time, but don’t worry about that. +You can jump to the definition of List.reverse in the standard library to see a +linear-time implementation. +Try proving reverse (as ++ bs) = reverse bs ++ reverse as and +reverse (reverse as) = as. +You can use cons_append and append_assoc, but you +may need to come up with auxiliary lemmas and prove them.

+
def reverse : List α → List α := sorry
+
+theorem reverse_append (as bs : List α) : reverse (as ++ bs) = reverse bs ++ reverse as := by
+  sorry
+
+theorem reverse_reverse (as : List α) : reverse (reverse as) = as := by sorry
+
+
+

For another example, consider the following inductive definition of binary trees together with +functions to compute the size and depth of a binary tree.

+
inductive BinTree where
+  | empty : BinTree
+  | node  : BinTree → BinTree → BinTree
+
+namespace BinTree
+
+def size : BinTree → ℕ
+  | empty    => 0
+  | node l r => size l + size r + 1
+
+def depth : BinTree → ℕ
+  | empty    => 0
+  | node l r => max (depth l) (depth r) + 1
+
+
+

It is convenient to count the empty binary tree as a binary tree of size 0 and depth 0. +In the literature, this data type is sometimes called the extended binary trees. +Including the empty tree means, for example, that we can define the tree +node empty (node empty empty) consisting of a root node, an empty left subtree, +and a right subtree consisting of a single node.

+

Here is an important inequality relating the size and the depth:

+
theorem size_le : ∀ t : BinTree, size t ≤ 2^depth t - 1
+  | empty    => Nat.zero_le _
+  | node l r => by
+    simp only [depth, size]
+    calc l.size + r.size + 1
+      ≤ (2^l.depth - 1) + (2^r.depth - 1) + 1 := by
+          gcongr <;> apply size_le
+    _ ≤ (2 ^ max l.depth r.depth - 1) + (2 ^ max l.depth r.depth - 1) + 1 := by
+          gcongr <;> simp
+    _ ≤ 2 ^ (max l.depth r.depth + 1) - 1 := by
+          have : 0 < 2 ^ max l.depth r.depth := by simp
+          omega
+
+
+

Try proving the following inequality, which is somewhat easier. +Remember, if you do a proof by induction as in the previous theorem, +you have to delete the := by.

+
theorem depth_le_size : ∀ t : BinTree, depth t ≤ size t := by sorry
+
+
+

Also define the flip operation on binary trees, which recursively swaps the +left and right subtrees.

+
def flip : BinTree → BinTree := sorry
+
+
+

If you did it right, the proof of the following should be rfl.

+
example: flip  (node (node empty (node empty empty)) (node empty empty)) =
+    node (node empty empty) (node (node empty empty) empty) := sorry
+
+
+

Prove the following:

+
theorem size_flip : ∀ t, size (flip t) = size t := by sorry
+
+
+

We close this section with some formal logic. +The following is an inductive definition of propositional formulas.

+
inductive PropForm : Type where
+  | var (n : ℕ)           : PropForm
+  | fls                   : PropForm
+  | conj (A B : PropForm) : PropForm
+  | disj (A B : PropForm) : PropForm
+  | impl (A B : PropForm) : PropForm
+
+
+

Every propositional formula is either a variable var n, the constant false +fls, or a compound formula of the form conj A B, disj A B, or impl A B. +With ordinary mathematical notation, these are commonly written \(p_n\), \(\bot\), \(A \wedge B\), +\(A \vee B\), and \(A \to B\), respectively. +The other propositional connectives can be defined in terms of these; for example, we can +define \(\neg A\) as \(A \to \bot\) and \(A \leftrightarrow B\) as +\((A \to B) \wedge (B \to A)\).

+

Having defined the data type of propositional formulas, we define what it means to evaluate a +propositional formula with respect to an +assignment v of Boolean truth values to the variables.

+
def eval : PropForm → (ℕ → Bool) → Bool
+  | var n,    v => v n
+  | fls,      _ => false
+  | conj A B, v => A.eval v && B.eval v
+  | disj A B, v => A.eval v || B.eval v
+  | impl A B, v => ! A.eval v || B.eval v
+
+
+

The next definition specifies the set of variables occurring in a formula, and the subsequent +theorem shows that evaluating a formula on two truth assignments that agree on its variables +yields the same value.

+
def vars : PropForm → Finset ℕ
+  | var n    => {n}
+  | fls      => ∅
+  | conj A B => A.vars ∪ B.vars
+  | disj A B => A.vars ∪ B.vars
+  | impl A B => A.vars ∪ B.vars
+
+theorem eval_eq_eval : ∀ (A : PropForm) (v1 v2 : ℕ → Bool),
+    (∀ n ∈ A.vars, v1 n = v2 n) → A.eval v1 = A.eval v2
+  | var n, v1, v2, h    => by simp_all [vars, eval]
+  | fls, v1, v2, h      => by simp_all [eval]
+  | conj A B, v1, v2, h => by
+      simp_all [vars, eval, eval_eq_eval A v1 v2, eval_eq_eval B v1 v2]
+  | disj A B, v1, v2, h => by
+      simp_all [vars, eval, eval_eq_eval A v1 v2, eval_eq_eval B v1 v2]
+  | impl A B, v1, v2, h => by
+      simp_all [vars, eval, eval_eq_eval A v1 v2, eval_eq_eval B v1 v2]
+
+
+

Noticing the repetition, we can be clever about the use of automation.

+
theorem eval_eq_eval' (A : PropForm) (v1 v2 : ℕ → Bool) (h : ∀ n ∈ A.vars, v1 n = v2 n) :
+    A.eval v1 = A.eval v2 := by
+  cases A <;> simp_all [eval, vars, fun A => eval_eq_eval' A v1 v2]
+
+
+

The function subst A m C describes the result of substituting the formula C for every +occurrence of the variable var m in the formula A.

+
def subst : PropForm → ℕ → PropForm → PropForm
+  | var n,    m, C => if n = m then C else var n
+  | fls,      _, _ => fls
+  | conj A B, m, C => conj (A.subst m C) (B.subst m C)
+  | disj A B, m, C => disj (A.subst m C) (B.subst m C)
+  | impl A B, m, C => impl (A.subst m C) (B.subst m C)
+
+
+

As an example, show that substituting for a variable that does not occur in a formula +has no effect:

+
theorem subst_eq_of_not_mem_vars :
+    ∀ (A : PropForm) (n : ℕ) (C : PropForm), n ∉ A.vars → A.subst n C = A := sorry
+
+
+

The following theorem says something more subtle and interesting: evaluating +A.subst n C on a truth assignment v is the same as evaluating +A on a truth assignment that assigns the value of C to var n. +See if you can prove it.

+
theorem subst_eval_eq : ∀ (A : PropForm) (n : ℕ) (C : PropForm) (v : ℕ → Bool),
+  (A.subst n C).eval v = A.eval (fun m => if m = n then C.eval v else v m) := sorry
+
+
+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C07_Structures.html b/dev/vendor/mathematics_in_lean/html/C07_Structures.html new file mode 100644 index 0000000..43542d6 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C07_Structures.html @@ -0,0 +1,1564 @@ + + + + + + + + + 7. Structures — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

7. Structures

+

Modern mathematics makes essential use of algebraic +structures, +which encapsulate patterns that can be instantiated in +multiple settings. +The subject provides various ways of defining such structures and +constructing particular instances.

+

Lean therefore provides corresponding ways of +defining structures formally and working with them. +You have already seen examples of algebraic structures in Lean, +such as rings and lattices, which were discussed in +Chapter 2. +This chapter will explain the mysterious square bracket annotations +that you saw there, +[Ring α] and [Lattice α]. +It will also show you how to define and use +algebraic structures on your own.

+

For more technical detail, you can consult Theorem Proving in Lean, +and a paper by Anne Baanen, Use and abuse of instance parameters in the Lean mathematical library.

+
+

7.1. Defining structures

+

In the broadest sense of the term, a structure is a specification +of a collection of data, possibly with constraints that the +data is required to satisfy. +An instance of the structure is a particular bundle of data satisfying +the constraints. For example, we can specify that a point is +a tuple of three real numbers:

+
@[ext]
+structure Point where
+  x : ℝ
+  y : ℝ
+  z : ℝ
+
+
+

The @[ext] annotation tells Lean to automatically generate theorems +that can be used to prove that two instances of a structure are equal +when their components are equal, a property known as extensionality.

+
#check Point.ext
+
+example (a b : Point) (hx : a.x = b.x) (hy : a.y = b.y) (hz : a.z = b.z) : a = b := by
+  ext
+  repeat assumption
+
+
+

We can then define particular instances of the Point structure. +Lean provides multiple ways of doing that.

+
def myPoint1 : Point where
+  x := 2
+  y := -1
+  z := 4
+
+def myPoint2 : Point :=
+  { x := 2, y := -1, z := 4 }
+
+def myPoint3 : Point :=
+  ⟨2, -1, 4⟩
+
+def myPoint4 :=
+  Point.mk 2 (-1) 4
+
+
+

In the first example, the fields of the structure are named +explicitly. +The function Point.mk referred to in the definition of myPoint4 +is known as the constructor for the Point structure, because +it serves to construct elements. +You can specify a different name if you want, like build.

+
structure Point' where build ::
+  x : ℝ
+  y : ℝ
+  z : ℝ
+
+#check Point'.build 2 (-1) 4
+
+
+

The next two examples show how to define functions on structures. +Whereas the second example makes the Point.mk +constructor explicit, the first example uses an anonymous constructor +for brevity. +Lean can infer the relevant constructor from the indicated type of +add. +It is conventional to put definitions and theorems associated +with a structure like Point in a namespace with the same name. +In the example below, because we have opened the Point +namespace, the full name of add is Point.add. +When the namespace is not open, we have to use the full name. +But remember that it is often convenient to use +anonymous projection notation, +which allows us to write a.add b instead of Point.add a b. +Lean interprets the former as the latter because a has type Point.

+
namespace Point
+
+def add (a b : Point) : Point :=
+  ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩
+
+def add' (a b : Point) : Point where
+  x := a.x + b.x
+  y := a.y + b.y
+  z := a.z + b.z
+
+#check add myPoint1 myPoint2
+#check myPoint1.add myPoint2
+
+end Point
+
+#check Point.add myPoint1 myPoint2
+#check myPoint1.add myPoint2
+
+
+

Below we will continue to put definitions in the relevant +namespace, but we will leave the namespacing commands out of the quoted +snippets. To prove properties of the addition function, +we can use rw to expand the definition and ext to +reduce an equation between two elements of the structure to equations +between the components. +Below we use the protected keyword so that the name of the +theorem is Point.add_comm, even when the namespace is open. +This is helpful when we want to avoid ambiguity with a generic +theorem like add_comm.

+
protected theorem add_comm (a b : Point) : add a b = add b a := by
+  rw [add, add]
+  ext <;> dsimp
+  repeat apply add_comm
+
+example (a b : Point) : add a b = add b a := by simp [add, add_comm]
+
+
+

Because Lean can unfold definitions and simplify projections +internally, sometimes the equations we want hold definitionally.

+
theorem add_x (a b : Point) : (a.add b).x = a.x + b.x :=
+  rfl
+
+
+

It is also possible to define functions on structures using +pattern matching, +in a manner similar to the way we defined recursive functions in +Section 5.2. +The definitions addAlt and addAlt' below are essentially the +same; the only difference is that we use anonymous constructor notation +in the second.

+
def addAlt : Point → Point → Point
+  | Point.mk x₁ y₁ z₁, Point.mk x₂ y₂ z₂ => ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩
+
+def addAlt' : Point → Point → Point
+  | ⟨x₁, y₁, z₁⟩, ⟨x₂, y₂, z₂⟩ => ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩
+
+theorem addAlt_x (a b : Point) : (a.addAlt b).x = a.x + b.x := by
+  rfl
+
+theorem addAlt_comm (a b : Point) : addAlt a b = addAlt b a := by
+  rw [addAlt, addAlt]
+  -- the same proof still works
+  ext <;> dsimp
+  repeat apply add_comm
+
+
+

Mathematical constructions often involve taking apart bundled information and +putting it together again in different ways. +It therefore makes sense that Lean and Mathlib offer so many ways +of doing this efficiently. +As an exercise, try proving that Point.add is associative. +Then define scalar multiplication for a point and show that it +distributes over addition.

+
protected theorem add_assoc (a b c : Point) : (a.add b).add c = a.add (b.add c) := by
+  sorry
+
+def smul (r : ℝ) (a : Point) : Point :=
+  sorry
+
+theorem smul_distrib (r : ℝ) (a b : Point) :
+    (smul r a).add (smul r b) = smul r (a.add b) := by
+  sorry
+
+
+

Using structures is only the first step on the road to +algebraic abstraction. +We don’t yet have a way to link Point.add to the generic + symbol, +or to connect Point.add_comm and Point.add_assoc to +the generic add_comm and add_assoc theorems. +These tasks belong to the algebraic aspect of using structures, +and we will explain how to carry them out in the next section. +For now, just think of a structure as a way of bundling together objects +and information.

+

It is especially useful that a structure can specify not only +data types but also constraints that the data must satisfy. +In Lean, the latter are represented as fields of type Prop. +For example, the standard 2-simplex is defined to be the set of +points \((x, y, z)\) satisfying \(x ≥ 0\), \(y ≥ 0\), \(z ≥ 0\), +and \(x + y + z = 1\). +If you are not familiar with the notion, you should draw a picture, +and convince yourself that this set is +the equilateral triangle in three-space with vertices +\((1, 0, 0)\), \((0, 1, 0)\), and \((0, 0, 1)\), +together with its interior. +We can represent it in Lean as follows:

+
structure StandardTwoSimplex where
+  x : ℝ
+  y : ℝ
+  z : ℝ
+  x_nonneg : 0 ≤ x
+  y_nonneg : 0 ≤ y
+  z_nonneg : 0 ≤ z
+  sum_eq : x + y + z = 1
+
+
+

Notice that the last four fields refer to x, y, and z, +that is, the first three fields. +We can define a map from the two-simplex to itself that swaps x and y:

+
def swapXy (a : StandardTwoSimplex) : StandardTwoSimplex
+    where
+  x := a.y
+  y := a.x
+  z := a.z
+  x_nonneg := a.y_nonneg
+  y_nonneg := a.x_nonneg
+  z_nonneg := a.z_nonneg
+  sum_eq := by rw [add_comm a.y a.x, a.sum_eq]
+
+
+

More interestingly, we can compute the midpoint of two points on +the simplex. We have added the phrase noncomputable section +at the beginning of this file in order to use division on the real numbers.

+
noncomputable section
+
+def midpoint (a b : StandardTwoSimplex) : StandardTwoSimplex
+    where
+  x := (a.x + b.x) / 2
+  y := (a.y + b.y) / 2
+  z := (a.z + b.z) / 2
+  x_nonneg := div_nonneg (add_nonneg a.x_nonneg b.x_nonneg) (by norm_num)
+  y_nonneg := div_nonneg (add_nonneg a.y_nonneg b.y_nonneg) (by norm_num)
+  z_nonneg := div_nonneg (add_nonneg a.z_nonneg b.z_nonneg) (by norm_num)
+  sum_eq := by field_simp; linarith [a.sum_eq, b.sum_eq]
+
+
+

Here we have established x_nonneg, y_nonneg, and z_nonneg +with concise proof terms, but establish sum_eq in tactic mode, +using by.

+

Given a parameter \(\lambda\) satisfying \(0 \le \lambda \le 1\), +we can take the weighted average \(\lambda a + (1 - \lambda) b\) +of two points \(a\) and \(b\) in the standard 2-simplex. +We challenge you to define that function, in analogy to the midpoint +function above.

+
def weightedAverage (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1)
+    (a b : StandardTwoSimplex) : StandardTwoSimplex :=
+  sorry
+
+
+

Structures can depend on parameters. +For example, we can generalize the standard 2-simplex to the standard +\(n\)-simplex for any \(n\). +At this stage, you don’t have to know anything about the type Fin n +except that it has \(n\) elements, and that Lean knows +how to sum over it.

+
open BigOperators
+
+structure StandardSimplex (n : ℕ) where
+  V : Fin n → ℝ
+  NonNeg : ∀ i : Fin n, 0 ≤ V i
+  sum_eq_one : (∑ i, V i) = 1
+
+namespace StandardSimplex
+
+def midpoint (n : ℕ) (a b : StandardSimplex n) : StandardSimplex n
+    where
+  V i := (a.V i + b.V i) / 2
+  NonNeg := by
+    intro i
+    apply div_nonneg
+    · linarith [a.NonNeg i, b.NonNeg i]
+    norm_num
+  sum_eq_one := by
+    simp [div_eq_mul_inv, ← Finset.sum_mul, Finset.sum_add_distrib,
+      a.sum_eq_one, b.sum_eq_one]
+    norm_num
+
+end StandardSimplex
+
+
+

As an exercise, see if you can define the weighted average of +two points in the standard \(n\)-simplex. +You can use Finset.sum_add_distrib +and Finset.mul_sum to manipulate the relevant sums.

+

We have seen that structures can be used to bundle together data +and properties. +Interestingly, they can also be used to bundle together properties +without the data. +For example, the next structure, IsLinear, bundles together +the two components of linearity.

+
structure IsLinear (f : ℝ → ℝ) where
+  is_additive : ∀ x y, f (x + y) = f x + f y
+  preserves_mul : ∀ x c, f (c * x) = c * f x
+
+section
+variable (f : ℝ → ℝ) (linf : IsLinear f)
+
+#check linf.is_additive
+#check linf.preserves_mul
+
+end
+
+
+

It is worth pointing out that structures are not the only way to bundle +together data. +The Point data structure can be defined using the generic type product, +and IsLinear can be defined with a simple and.

+
def Point'' :=
+  ℝ × ℝ × ℝ
+
+def IsLinear' (f : ℝ → ℝ) :=
+  (∀ x y, f (x + y) = f x + f y) ∧ ∀ x c, f (c * x) = c * f x
+
+
+

Generic type constructions can even be used in place of structures +with dependencies between their components. +For example, the subtype construction combines a piece of data with +a property. +You can think of the type PReal in the next example as being +the type of positive real numbers. +Any x : PReal has two components: the value, and the property of being +positive. +You can access these components as x.val, which has type ℝ, +and x.property, which represents the fact 0 < x.val.

+
def PReal :=
+  { y : ℝ // 0 < y }
+
+section
+variable (x : PReal)
+
+#check x.val
+#check x.property
+#check x.1
+#check x.2
+
+end
+
+
+

We could have used subtypes to define the standard 2-simplex, +as well as the standard \(n\)-simplex for an arbitrary \(n\).

+
def StandardTwoSimplex' :=
+  { p : ℝ × ℝ × ℝ // 0 ≤ p.1 ∧ 0 ≤ p.2.1 ∧ 0 ≤ p.2.2 ∧ p.1 + p.2.1 + p.2.2 = 1 }
+
+def StandardSimplex' (n : ℕ) :=
+  { v : Fin n → ℝ // (∀ i : Fin n, 0 ≤ v i) ∧ (∑ i, v i) = 1 }
+
+
+

Similarly, Sigma types are generalizations of ordered pairs, +whereby the type of the second component depends on the type of +the first.

+
def StdSimplex := Σ n : ℕ, StandardSimplex n
+
+section
+variable (s : StdSimplex)
+
+#check s.fst
+#check s.snd
+
+#check s.1
+#check s.2
+
+end
+
+
+

Given s : StdSimplex, the first component s.fst is a natural +number, and the second component is an element of the corresponding +simplex StandardSimplex s.fst. +The difference between a Sigma type and a subtype is that +the second component of a Sigma type is data rather than a proposition.

+

But even though we can use products, subtypes, and Sigma types +instead of structures, using structures has a number of advantages. +Defining a structure abstracts away the underlying representation +and provides custom names for the functions that access the components. +This makes proofs more robust: +proofs that rely only on the interface to a structure +will generally continue to work when we change the definition, +as long as we redefine the old accessors in terms of the new definition. +Moreover, as we are about to see, Lean provides support for +weaving structures together into a rich, interconnected hierarchy, +and for managing the interactions between them.

+
+
+

7.2. Algebraic Structures

+

To clarify what we mean by the phrase algebraic structure, +it will help to consider some examples.

+
    +
  1. A partially ordered set consists of a set \(P\) and +a binary relation \(\le\) on \(P\) that is transitive, +reflexive and antisymmetric.

  2. +
  3. A group consists of a set \(G\) with an associative +binary operation, an identity element +\(1\), and a function \(g \mapsto g^{-1}\) that returns +an inverse for each \(g\) in \(G\). +A group is abelian or commutative if the operation is commutative.

  4. +
  5. A lattice is a partially ordered set with meets and joins.

  6. +
  7. A ring consists of an (additively written) abelian group +\((R, +, 0, x \mapsto -x)\) +together with an associative multiplication operation +\(\cdot\) and an identity \(1\), +such that multiplication distributes over addition. +A ring is commutative if the multiplication is commutative.

  8. +
  9. An ordered ring \((R, +, 0, -, \cdot, 1, \le)\) consists of a ring +together with a partial order on its elements, such that \(a \le b\) implies +\(a + c \le b + c\) for every \(a\), \(b\), and \(c\) in \(R\), +and \(0 \le a\) and \(0 \le b\) implies \(0 \le a b\) for +every \(a\) and \(b\) in \(R\).

  10. +
  11. A metric space consists of a set \(X\) and a function +\(d : X \times X \to \mathbb{R}\) such that the following hold:

    +
      +
    • \(d(x, y) \ge 0\) for every \(x\) and \(y\) in \(X\).

    • +
    • \(d(x, y) = 0\) if and only if \(x = y\).

    • +
    • \(d(x, y) = d(y, x)\) for every \(x\) and \(y\) in \(X\).

    • +
    • \(d(x, z) \le d(x, y) + d(y, z)\) for every \(x\), \(y\), and +\(z\) in \(X\).

    • +
    +
  12. +
  13. A topological space consists of a set \(X\) and a collection \(\mathcal T\) +of subsets of \(X\), called the open subsets of \(X\), such that +the following hold:

    +
      +
    • The empty set and \(X\) are open.

    • +
    • The intersection of two open sets is open.

    • +
    • An arbitrary union of open sets is open.

    • +
    +
  14. +
+

In each of these examples, the elements of the structure belong to a +set, the carrier set, +that sometimes stands proxy for the entire structure. +For example, when we say “let \(G\) be a group” and then +“let \(g \in G\),” we are using \(G\) to stand for both +the structure and its carrier. +Not every algebraic structure is associated with a single carrier set in this way. +For example, a bipartite graph involves a relation between two sets, +as does a Galois connection. +A category also involves two sets of interest, commonly called the objects +and the morphisms.

+

The examples indicate some of the things that a proof assistant has to do +in order to support algebraic reasoning. +First, it needs to recognize concrete instances of structures. +The number systems \(\mathbb{Z}\), \(\mathbb{Q}\), +and \(\mathbb{R}\) are all ordered rings, +and we should be able to apply a generic theorem about ordered rings +in any of these instances. +Sometimes a concrete set may be an instance of a structure in more than one way. +For example, in addition to the usual topology on \(\mathbb{R}\), +which forms the basis for real analysis, +we can also consider the discrete topology on \(\mathbb{R}\), +in which every set is open.

+

Second, a proof assistant needs to support generic notation on structures. +In Lean, the notation * +is used for multiplication in all the usual number systems, +as well as for multiplication in generic groups and rings. +When we use an expression like f x * y, +Lean has to use information about the types of f, x, and y +to determine which multiplication we have in mind.

+

Third, it needs to deal with the fact that structures can inherit +definitions, theorems, and notation from other structures in various ways. +Some structures extend others by adding more axioms. +A commutative ring is still a ring, so any definition +that makes sense in a ring also makes sense in a commutative ring, +and any theorem that holds in a ring also holds in a commutative ring. +Some structures extend others by adding more data. +For example, the additive part of any ring is an additive group. +The ring structure adds a multiplication and an identity, +as well as axioms that govern them and relate them to the additive part. +Sometimes we can define one structure in terms of another. +Any metric space has a canonical topology associated with it, +the metric space topology, and there are various topologies that can be +associated with any linear ordering.

+

Finally, it is important to keep in mind that mathematics allows us to +use functions and operations to define structures in the same way we +use functions and operations to define numbers. +Products and powers of groups are again groups. +For every \(n\), the integers modulo \(n\) form a ring, +and for every \(k > 0\), the \(k \times k\) matrices of polynomials +with coefficients in that ring again form a ring. +Thus we can calculate with structures just as easily as we can calculate +with their elements. +This means that algebraic structures lead dual lives in mathematics, +as containers for collections of objects and as objects in their own right. +A proof assistant has to accommodate this dual role.

+

When dealing with elements of a type that has an algebraic structure +associated with it, +a proof assistant needs to recognize the structure and find the relevant +definitions, theorems, and notation. +All this should sound like a lot of work, and it is. +But Lean uses a small collection of fundamental mechanisms to +carry out these tasks. +The goal of this section is to explain these mechanisms and show you +how to use them.

+

The first ingredient is almost too obvious to mention: +formally speaking, algebraic structures are structures in the sense +of Section 7.1. +An algebraic structure is a specification of a bundle of data satisfying +some axiomatic hypotheses, and we saw in Section 7.1 that +this is exactly what the structure command is designed to accommodate. +It’s a marriage made in heaven!

+

Given a data type α, we can define a group structure on α +as follows.

+
structure Group₁ (α : Type*) where
+  mul : α → α → α
+  one : α
+  inv : α → α
+  mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z)
+  mul_one : ∀ x : α, mul x one = x
+  one_mul : ∀ x : α, mul one x = x
+  inv_mul_cancel : ∀ x : α, mul (inv x) x = one
+
+
+

Notice that the type α is a parameter in the definition of Group₁. +So you should think of an object struc : Group₁ α as being +a group structure on α. +We saw in Section 2.2 +that the counterpart mul_inv_cancel to inv_mul_cancel +follows from the other group axioms, so there is no need +to add it to the definition.

+

This definition of a group is similar to the definition of Group in +Mathlib, +and we have chosen the name Group₁ to distinguish our version. +If you write #check Group and ctrl-click on the definition, +you will see that the Mathlib version of Group is defined to +extend another structure; we will explain how to do that later. +If you type #print Group you will also see that the Mathlib +version of Group has a number of extra fields. +For reasons we will explain later, sometimes it is useful to add +redundant information to a structure, +so that there are additional fields for objects and functions +that can be defined from the core +data. Don’t worry about that for now. +Rest assured that our simplified version Group₁ is +morally the same as the definition of a group that Mathlib uses.

+

It is sometimes useful to bundle +the type together with the structure, and Mathlib also +contains a definition of a Grp structure that is equivalent to +the following:

+
structure Grp₁ where
+  α : Type*
+  str : Group₁ α
+
+
+

The Mathlib version is found in Mathlib.Algebra.Category.Grp.Basic, +and you can #check it if you add this to the imports at the +beginning of the examples file.

+

For reasons that will become clearer below, it is more often +useful to keep the type α separate from the structure Group α. +We refer to the two objects together as a partially bundled structure, +since the representation combines most, but not all, of the components +into one structure. It is common in Mathlib +to use capital roman letters like G for a type +when it is used as the carrier type for a group.

+

Let’s construct a group by defining an element of the Group₁ type. +For any pair of types α and β, Mathlib defines the type Equiv α β +of equivalences between α and β. +Mathlib also defines the suggestive notation α ≃ β for this type. +An element f : α ≃ β is a bijection between α and β +represented by four components: +a function f.toFun from α to β, +the inverse function f.invFun from β to α, +and two properties that specify these functions are indeed inverse +to one another.

+
variable (α β γ : Type*)
+variable (f : α ≃ β) (g : β ≃ γ)
+
+#check Equiv α β
+#check (f.toFun : α → β)
+#check (f.invFun : β → α)
+#check (f.right_inv : ∀ x : β, f (f.invFun x) = x)
+#check (f.left_inv : ∀ x : α, f.invFun (f x) = x)
+#check (Equiv.refl α : α ≃ α)
+#check (f.symm : β ≃ α)
+#check (f.trans g : α ≃ γ)
+
+
+

Notice the creative naming of the last three constructions. We think of the +identity function Equiv.refl, the inverse operation Equiv.symm, +and the composition operation Equiv.trans as explicit evidence +that the property of being in bijective correspondence is an equivalence relation.

+

Notice also that f.trans g requires composing the forward functions +in reverse order. Mathlib has declared a coercion from Equiv α β +to the function type α → β, so we can omit writing .toFun +and have Lean insert it for us.

+
example (x : α) : (f.trans g).toFun x = g.toFun (f.toFun x) :=
+  rfl
+
+example (x : α) : (f.trans g) x = g (f x) :=
+  rfl
+
+example : (f.trans g : α → γ) = g ∘ f :=
+  rfl
+
+
+

Mathlib also defines the type Perm α of equivalences between +α and itself.

+
example (α : Type*) : Equiv.Perm α = (α ≃ α) :=
+  rfl
+
+
+

It should be clear that Equiv.Perm α forms a group under composition +of equivalences. We orient things so that mul f g is +equal to g.trans f, whose forward function is f ∘ g. +In other words, multiplication is what we ordinarily think of as +composition of the bijections. Here we define this group:

+
def permGroup {α : Type*} : Group₁ (Equiv.Perm α)
+    where
+  mul f g := Equiv.trans g f
+  one := Equiv.refl α
+  inv := Equiv.symm
+  mul_assoc f g h := (Equiv.trans_assoc h g f).symm
+  one_mul := Equiv.trans_refl
+  mul_one := Equiv.refl_trans
+  inv_mul_cancel := Equiv.self_trans_symm
+
+
+

In fact, Mathlib defines exactly this Group structure on Equiv.Perm α +in the file Algebra.Group.End. +As always, you can hover over the theorems used in the definition of +permGroup to see their statements, +and you can jump to their definitions in the original file to learn +more about how they are implemented.

+

In ordinary mathematics, we generally think of notation as +independent of structure. +For example, we can consider groups \((G_1, \cdot, 1, \cdot^{-1})\), +\((G_2, \circ, e, i(\cdot))\), and \((G_3, +, 0, -)\). +In the first case, we write the binary operation as \(\cdot\), +the identity as \(1\), and the inverse function as \(x \mapsto x^{-1}\). +In the second and third cases, we use the notational alternatives shown. +When we formalize the notion of a group in Lean, however, +the notation is more tightly linked to the structure. +In Lean, the components of any Group are named +mul, one, and inv, +and in a moment we will see how multiplicative notation is +set up to refer to them. +If we want to use additive notation, we instead use an isomorphic structure +AddGroup (the structure underlying additive groups). Its components are named add, zero, +and neg, and the associated notation is what you would expect it to be.

+

Recall the type Point that we defined in Section 7.1, +and the addition function that we defined there. +These definitions are reproduced in the examples file that accompanies +this section. +As an exercise, define an AddGroup₁ structure that is similar +to the Group₁ structure we defined above, except that it uses the +additive naming scheme just described. +Define negation and a zero on the Point data type, +and define the AddGroup₁ structure on Point.

+
structure AddGroup₁ (α : Type*) where
+  (add : α → α → α)
+  -- fill in the rest
+@[ext]
+structure Point where
+  x : ℝ
+  y : ℝ
+  z : ℝ
+
+namespace Point
+
+def add (a b : Point) : Point :=
+  ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩
+
+def neg (a : Point) : Point := sorry
+
+def zero : Point := sorry
+
+def addGroupPoint : AddGroup₁ Point := sorry
+
+end Point
+
+
+

We are making progress. +Now we know how to define algebraic structures in Lean, +and we know how to define instances of those structures. +But we also want to associate notation with structures +so that we can use it with each instance. +Moreover, we want to arrange it so that we can define an operation +on a structure and use it with any particular instance, +and we want to arrange it so that we can prove a theorem about +a structure and use it with any instance.

+

In fact, Mathlib is already set up to use generic group notation, +definitions, and theorems for Equiv.Perm α.

+
variable {α : Type*} (f g : Equiv.Perm α) (n : ℕ)
+
+#check f * g
+#check mul_assoc f g g⁻¹
+
+-- group power, defined for any group
+#check g ^ n
+
+example : f * g * g⁻¹ = f := by rw [mul_assoc, mul_inv_cancel, mul_one]
+
+example : f * g * g⁻¹ = f :=
+  mul_inv_cancel_right f g
+
+example {α : Type*} (f g : Equiv.Perm α) : g.symm.trans (g.trans f) = f :=
+  mul_inv_cancel_right f g
+
+
+

You can check that this is not the case for the additive group structure +on Point that we asked you to define above. +Our task now is to understand that magic that goes on under the hood +in order to make the examples for Equiv.Perm α work the way they do.

+

The issue is that Lean needs to be able to find the relevant +notation and the implicit group structure, +using the information that is found in the expressions that we type. +Similarly, when we write x + y with expressions x and y +that have type ℝ, Lean needs to interpret the + +symbol as the relevant addition function on the reals. +It also has to recognize the type ℝ as an instance of a commutative ring, +so that all the definitions and theorems for a commutative ring are available. +For another example, +continuity is defined in Lean relative to any two topological spaces. +When we have f : ℝ → ℂ and we write Continuous f, Lean has to find the +relevant topologies on ℝ and ℂ.

+

The magic is achieved with a combination of three things.

+
    +
  1. Logic. A definition that should be interpreted in any group takes, as +arguments, the type of the group and the group structure as arguments. +Similarly, a theorem about the elements of an arbitrary group +begins with universal quantifiers over +the type of the group and the group structure.

  2. +
  3. Implicit arguments. The arguments for the type and the structure +are generally left implicit, so that we do not have to write them +or see them in the Lean information window. Lean fills the +information in for us silently.

  4. +
  5. Type class inference. Also known as class inference, +this is a simple but powerful mechanism +that enables us to register information for Lean to use later on. +When Lean is called on to fill in implicit arguments to a +definition, theorem, or piece of notation, +it can make use of information that has been registered.

  6. +
+

Whereas an annotation (grp : Group G) tells Lean that it should +expect to be given that argument explicitly and the annotation +{grp : Group G} tells Lean that it should try to figure it out +from contextual cues in the expression, +the annotation [grp : Group G] tells Lean that the corresponding +argument should be synthesized using type class inference. +Since the whole point to the use of such arguments is that +we generally do not need to refer to them explicitly, +Lean allows us to write [Group G] and leave the name anonymous. +You have probably already noticed that Lean chooses names like _inst_1 +automatically. +When we use the anonymous square-bracket annotation with the variable command, +then as long as the variables are still in scope, +Lean automatically adds the argument [Group G] to any definition or +theorem that mentions G.

+

How do we register the information that Lean needs to use to carry +out the search? +Returning to our group example, we need only make two changes. +First, instead of using the structure command to define the group structure, +we use the keyword class to indicate that it is a candidate +for class inference. +Second, instead of defining particular instances with def, +we use the keyword instance to register the particular instance with +Lean. As with the names of class variables, we are allowed to leave the +name of an instance definition anonymous, +since in general we intend Lean to find it and put it to use +without troubling us with the details.

+
class Group₂ (α : Type*) where
+  mul : α → α → α
+  one : α
+  inv : α → α
+  mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z)
+  mul_one : ∀ x : α, mul x one = x
+  one_mul : ∀ x : α, mul one x = x
+  inv_mul_cancel : ∀ x : α, mul (inv x) x = one
+
+instance {α : Type*} : Group₂ (Equiv.Perm α) where
+  mul f g := Equiv.trans g f
+  one := Equiv.refl α
+  inv := Equiv.symm
+  mul_assoc f g h := (Equiv.trans_assoc h g f).symm
+  one_mul := Equiv.trans_refl
+  mul_one := Equiv.refl_trans
+  inv_mul_cancel := Equiv.self_trans_symm
+
+
+

The following illustrates their use.

+
#check Group₂.mul
+
+def mySquare {α : Type*} [Group₂ α] (x : α) :=
+  Group₂.mul x x
+
+#check mySquare
+
+section
+variable {β : Type*} (f g : Equiv.Perm β)
+
+example : Group₂.mul f g = g.trans f :=
+  rfl
+
+example : mySquare f = f.trans f :=
+  rfl
+
+end
+
+
+

The #check command shows that Group₂.mul has an implicit argument +[Group₂ α] that we expect to be found by class inference, +where α is the type of the arguments to Group₂.mul. +In other words, {α : Type*} is the implicit argument for the type +of the group elements and [Group₂ α] is the implicit argument for the +group structure on α. +Similarly, when we define a generic squaring function my_square +for Group₂, we use an implicit argument {α : Type*} for +the type of the elements and an implicit argument [Group₂ α] for +the Group₂ structure.

+

In the first example, +when we write Group₂.mul f g, the type of f and g +tells Lean that in the argument α to Group₂.mul +has to be instantiated to Equiv.Perm β. +That means that Lean has to find an element of Group₂ (Equiv.Perm β). +The previous instance declaration tells Lean exactly how to do that. +Problem solved!

+

This simple mechanism for registering information so that Lean can find it +when it needs it is remarkably useful. +Here is one way it comes up. +In Lean’s foundation, a data type α may be empty. +In a number of applications, however, it is useful to know that a +type has at least one element. +For example, the function List.headI, which returns the first +element of a list, can return the default value when the list is empty. +To make that work, the Lean library defines a class Inhabited α, +which does nothing more than store a default value. +We can show that the Point type is an instance:

+
instance : Inhabited Point where default := ⟨0, 0, 0⟩
+
+#check (default : Point)
+
+example : ([] : List Point).headI = default :=
+  rfl
+
+
+

The class inference mechanism is also used for generic notation. +The expression x + y is an abbreviation for Add.add x y +where—you guessed it—Add α is a class that stores +a binary function on α. +Writing x + y tells Lean to find a registered instance of [Add.add α] +and use the corresponding function. +Below, we register the addition function for Point.

+
instance : Add Point where add := Point.add
+
+section
+variable (x y : Point)
+
+#check x + y
+
+example : x + y = Point.add x y :=
+  rfl
+
+end
+
+
+

In this way, we can assign the notation + to binary operations on other +types as well.

+

But we can do even better. We have seen that * can be used in any +group, + can be used in any additive group, and both can be used in +any ring. +When we define a new instance of a ring in Lean, +we don’t have to define + and * for that instance, +because Lean knows that these are defined for every ring. +We can use this method to specify notation for our Group₂ class:

+
instance {α : Type*} [Group₂ α] : Mul α :=
+  ⟨Group₂.mul⟩
+
+instance {α : Type*} [Group₂ α] : One α :=
+  ⟨Group₂.one⟩
+
+instance {α : Type*} [Group₂ α] : Inv α :=
+  ⟨Group₂.inv⟩
+
+section
+variable {α : Type*} (f g : Equiv.Perm α)
+
+#check f * 1 * g⁻¹
+
+lemma foo : f * 1 * g⁻¹ = g.symm.trans ((Equiv.refl α).trans f) :=
+  rfl
+
+end
+
+
+

What makes this approach work is that Lean carries out a recursive search. +According to the instances we have declared, Lean can find an instance of +Mul (Equiv.Perm α) by finding an +instance of Group₂ (Equiv.Perm α), and it can find an instance of +Group₂ (Equiv.Perm α) because we have provided one. +Lean is capable of finding these two facts and chaining them together.

+

The example we have just given is dangerous, because Lean’s +library also has an instance of Group (Equiv.Perm α), and +multiplication is defined on any group. +So it is ambiguous as to which instance is found. +In fact, Lean favors more recent declarations unless you explicitly +specify a different priority. +Also, there is another way to tell Lean that one structure is an +instance of another, using the extends keyword. +This is how Mathlib specifies that, for example, +every commutative ring is a ring. +You can find more information in Section 8 and in a +section on class inference in Theorem Proving in Lean.

+

In general, it is a bad idea to specify a value of +* for an instance of an algebraic structure that already has +the notation defined. +Redefining the notion of Group in Lean is an artificial example. +In this case, however, both interpretations of the group notation unfold to +Equiv.trans, Equiv.refl, and Equiv.symm, in the same way.

+

As a similarly artificial exercise, +define a class AddGroup₂ in analogy to Group₂. +Define the usual notation for addition, negation, and zero +on any AddGroup₂ +using the classes Add, Neg, and Zero. +Then show Point is an instance of AddGroup₂. +Try it out and make sure that the additive group notation works for +elements of Point.

+
class AddGroup₂ (α : Type*) where
+  add : α → α → α
+  -- fill in the rest
+
+
+

It is not a big problem that we have already declared instances +Add, Neg, and Zero for Point above. +Once again, the two ways of synthesizing the notation should come up +with the same answer.

+

Class inference is subtle, and you have to be careful when using it, +because it configures automation that invisibly governs the interpretation of +the expressions we type. +When used wisely, however, class inference is a powerful tool. +It is what makes algebraic reasoning possible in Lean.

+
+
+

7.3. Building the Gaussian Integers

+

We will now illustrate the use of the algebraic hierarchy in Lean by +building an important mathematical object, the Gaussian integers, +and showing that it is a Euclidean domain. In other words, according to +the terminology we have been using, we will define the Gaussian integers +and show that they are an instance of the Euclidean domain structure.

+

In ordinary mathematical terms, the set of Gaussian integers \(\Bbb{Z}[i]\) +is the set of complex numbers \(\{ a + b i \mid a, b \in \Bbb{Z}\}\). +But rather than define them as a subset of the complex numbers, our goal +here is to define them as a data type in their own right. We do this by +representing a Gaussian integer as a pair of integers, which we think of as the +real and imaginary parts.

+
@[ext]
+structure GaussInt where
+  re : ℤ
+  im : ℤ
+
+
+

We first show that the Gaussian integers have the structure of a ring, +with 0 defined to be ⟨0, 0⟩, 1 defined to be ⟨1, 0⟩, and +addition defined pointwise. To work out the definition of multiplication, +remember that we want the element \(i\), represented by ⟨0, 1⟩, to +be a square root of \(-1\). Thus we want

+
+\[\begin{split}(a + bi) (c + di) & = ac + bci + adi + bd i^2 \\ + & = (ac - bd) + (bc + ad)i.\end{split}\]
+

This explains the definition of Mul below.

+
instance : Zero GaussInt :=
+  ⟨⟨0, 0⟩⟩
+
+instance : One GaussInt :=
+  ⟨⟨1, 0⟩⟩
+
+instance : Add GaussInt :=
+  ⟨fun x y ↦ ⟨x.re + y.re, x.im + y.im⟩⟩
+
+instance : Neg GaussInt :=
+  ⟨fun x ↦ ⟨-x.re, -x.im⟩⟩
+
+instance : Mul GaussInt :=
+  ⟨fun x y ↦ ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩⟩
+
+
+

As noted in Section 7.1, it is a good idea to put all the definitions +related to a data type in a namespace with the same name. Thus in the Lean +files associated with this chapter, these definitions are made in the +GaussInt namespace.

+

Notice that here we are defining the interpretations of the notation 0, +1, +, -, and * directly, rather than naming them +GaussInt.zero and the like and assigning the notation to those. +It is often useful to have an explicit name for the definitions, for example, +to use with simp and rw.

+
theorem zero_def : (0 : GaussInt) = ⟨0, 0⟩ :=
+  rfl
+
+theorem one_def : (1 : GaussInt) = ⟨1, 0⟩ :=
+  rfl
+
+theorem add_def (x y : GaussInt) : x + y = ⟨x.re + y.re, x.im + y.im⟩ :=
+  rfl
+
+theorem neg_def (x : GaussInt) : -x = ⟨-x.re, -x.im⟩ :=
+  rfl
+
+theorem mul_def (x y : GaussInt) :
+    x * y = ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩ :=
+  rfl
+
+
+

It is also useful to name the rules that compute the real and imaginary +parts, and to declare them to the simplifier.

+
@[simp]
+theorem zero_re : (0 : GaussInt).re = 0 :=
+  rfl
+
+@[simp]
+theorem zero_im : (0 : GaussInt).im = 0 :=
+  rfl
+
+@[simp]
+theorem one_re : (1 : GaussInt).re = 1 :=
+  rfl
+
+@[simp]
+theorem one_im : (1 : GaussInt).im = 0 :=
+  rfl
+
+@[simp]
+theorem add_re (x y : GaussInt) : (x + y).re = x.re + y.re :=
+  rfl
+
+@[simp]
+theorem add_im (x y : GaussInt) : (x + y).im = x.im + y.im :=
+  rfl
+
+@[simp]
+theorem neg_re (x : GaussInt) : (-x).re = -x.re :=
+  rfl
+
+@[simp]
+theorem neg_im (x : GaussInt) : (-x).im = -x.im :=
+  rfl
+
+@[simp]
+theorem mul_re (x y : GaussInt) : (x * y).re = x.re * y.re - x.im * y.im :=
+  rfl
+
+@[simp]
+theorem mul_im (x y : GaussInt) : (x * y).im = x.re * y.im + x.im * y.re :=
+  rfl
+
+
+

It is now surprisingly easy to show that the Gaussian integers are an instance +of a commutative ring. We are putting the structure concept to good use. +Each particular Gaussian integer is an instance of the GaussInt structure, +whereas the type GaussInt itself, together with the relevant operations, is an +instance of the CommRing structure. The CommRing structure, in turn, +extends the notational structures Zero, One, Add, +Neg, and Mul.

+

If you type instance : CommRing GaussInt := _, click on the light bulb +that appears in VS Code, and then ask Lean to fill in a skeleton for the +structure definition, you will see a scary number of entries. +Jumping to the definition of the structure, however, shows that many of the +fields have default definitions that Lean will fill in for you automatically. +The essential ones appear in the definition below. +A special case are nsmul and zsmul which should be ignored for now +and will be explained in the next chapter. +In each case, the relevant +identity is proved by unfolding definitions, using the ext tactic +to reduce the identities to their real and imaginary components, +simplifying, and, if necessary, carrying out the relevant ring calculation in +the integers. Note that we could easily avoid repeating all this code, but +this is not the topic of the current discussion.

+
instance instCommRing : CommRing GaussInt where
+  zero := 0
+  one := 1
+  add := (· + ·)
+  neg x := -x
+  mul := (· * ·)
+  nsmul := nsmulRec
+  zsmul := zsmulRec
+  add_assoc := by
+    intros
+    ext <;> simp <;> ring
+  zero_add := by
+    intro
+    ext <;> simp
+  add_zero := by
+    intro
+    ext <;> simp
+  neg_add_cancel := by
+    intro
+    ext <;> simp
+  add_comm := by
+    intros
+    ext <;> simp <;> ring
+  mul_assoc := by
+    intros
+    ext <;> simp <;> ring
+  one_mul := by
+    intro
+    ext <;> simp
+  mul_one := by
+    intro
+    ext <;> simp
+  left_distrib := by
+    intros
+    ext <;> simp <;> ring
+  right_distrib := by
+    intros
+    ext <;> simp <;> ring
+  mul_comm := by
+    intros
+    ext <;> simp <;> ring
+  zero_mul := by
+    intros
+    ext <;> simp
+  mul_zero := by
+    intros
+    ext <;> simp
+
+
+

Lean’s library defines the class of nontrivial types to be types with at +least two distinct elements. In the context of a ring, this is equivalent +to saying that the zero is not equal to the one. Since some common theorems +depend on that fact, we may as well establish it now.

+
instance : Nontrivial GaussInt := by
+  use 0, 1
+  rw [Ne, GaussInt.ext_iff]
+  simp
+
+
+

We will now show that the Gaussian integers have an important additional +property. A Euclidean domain is a ring \(R\) equipped with a norm +function \(N : R \to \mathbb{N}\) with the following two properties:

+
    +
  • For every \(a\) and \(b \ne 0\) in \(R\), there are +\(q\) and \(r\) in \(R\) such that \(a = bq + r\) and +either \(r = 0\) or \(N(r) < N(b)\).

  • +
  • For every \(a\) and \(b \ne 0\), \(N(a) \le N(ab)\).

  • +
+

The ring of integers \(\Bbb{Z}\) with \(N(a) = |a|\) is an +archetypal example of a Euclidean domain. +In that case, we can take \(q\) to be the +result of integer division of \(a\) by \(b\) and \(r\) +to be the remainder. Note that when a and b are integers, a / b denotes +integer division in Lean, and a % b denotes the remainder. These are defined so +as to satisfly the following:

+
example (a b : ℤ) : a = b * (a / b) + a % b :=
+  Eq.symm (Int.mul_ediv_add_emod a b)
+
+example (a b : ℤ) : b ≠ 0 → 0 ≤ a % b :=
+  Int.emod_nonneg a
+
+example (a b : ℤ) : b ≠ 0 → a % b < |b| :=
+  Int.emod_lt_abs a
+
+
+

In an arbitrary ring, an element \(a\) is said to be a unit if it divides +\(1\). A nonzero element \(a\) is said to be irreducible if it cannot +be written in the form \(a = bc\) +where neither \(b\) nor \(c\) is a unit. In the integers, every +irreducible element \(a\) is prime, which is to say, whenever \(a\) +divides a product \(bc\), it divides either \(b\) or \(c\). But +in other rings this property can fail. In the ring +\(\Bbb{Z}[\sqrt{-5}]\), we have

+
+\[6 = 2 \cdot 3 = (1 + \sqrt{-5})(1 - \sqrt{-5}),\]
+

and the elements \(2\), \(3\), \(1 + \sqrt{-5}\), and +\(1 - \sqrt{-5}\) are all irreducible, but they are not prime. For example, +\(2\) divides the product \((1 + \sqrt{-5})(1 - \sqrt{-5})\), +but it does not divide either factor. In particular, we no longer have +unique factorization: the number \(6\) can be factored into irreducible +elements in more than one way.

+

In contrast, every Euclidean domain is a unique factorization domain, which +implies that every irreducible element is prime. +The axioms for a Euclidean domain imply that one can write any nonzero element +as a finite product of irreducible elements. They also imply that one can use +the Euclidean algorithm to find a greatest common divisor of any two +nonzero elements a and b, i.e. an element that is divisible by any +other common divisor. This, in turn, implies that factorization +into irreducible elements is unique up to multiplication by units.

+

We now show that the Gaussian integers are a Euclidean domain with +the norm defined by \(N(a + bi) = (a + bi)(a - bi) = a^2 + b^2\). +The Gaussian integer \(a - bi\) is called the conjugate of \(a + bi\). +It is not hard to check that for any complex numbers \(x\) and \(y\), +we have \(N(xy) = N(x)N(y)\).

+

To see that this definition of the norm makes the Gaussian integers a Euclidean +domain, only the first property is challenging. Suppose +we want to write \(a + bi = (c + di) q + r\) for suitable \(q\) +and \(r\). Treating \(a + bi\) and \(c + di\) as complex +numbers, carry out the division

+
+\[\frac{a + bi}{c + di} = \frac{(a + bi)(c - di)}{(c + di)(c-di)} = + \frac{ac + bd}{c^2 + d^2} + \frac{bc -ad}{c^2+d^2} i.\]
+

The real and imaginary parts might not be integers, but we can round +them to the nearest integers \(u\) and \(v\). We can then express the +right-hand side as \((u + vi) + (u' + v'i)\), where +\(u' + v'i\) is the part left over. Note that we have +\(|u'| \le 1/2\) and \(|v'| \le 1/2\), and hence

+
+\[N(u' + v' i) = (u')^2 + (v')^2 \le 1/4 + 1/4 \le 1/2.\]
+

Multiplying through by \(c + di\), we have

+
+\[a + bi = (c + di) (u + vi) + (c + di) (u' + v'i).\]
+

Setting \(q = u + vi\) and \(r = (c + di) (u' + v'i)\), we have +\(a + bi = (c + di) q + r\), and we only need to +bound \(N(r)\):

+
+\[N(r) = N(c + di)N(u' + v'i) \le N(c + di) \cdot 1/2 < N(c + di).\]
+

The argument we just carried out requires viewing the Gaussian integers +as a subset of the complex numbers. One option for formalizing it in Lean +is therefore to embed the Gaussian integers in the complex numbers, embed +the integers in the Gaussian integers, define the rounding function from the +real numbers to the integers, and take great care to pass back and forth +between these number systems appropriately. +In fact, this is exactly the approach that is followed in Mathlib, +where the Gaussian integers themselves are constructed as a special case +of a ring of quadratic integers. +See the file GaussianInt.lean.

+

Here we will instead carry out an argument that stays in the integers. +This illustrates a choice one commonly faces when formalizing mathematics. +Given an argument that requires concepts or machinery that is not already +in the library, one has two choices: either formalize the concepts and machinery +needed, or adapt the argument to make use of concepts and machinery you +already have. +The first choice is generally a good investment of time when the results +can be used in other contexts. +Pragmatically speaking, however, sometimes seeking a more elementary proof +is more efficient.

+

The usual quotient-remainder theorem for the integers says that for +every \(a\) and nonzero \(b\), there are \(q\) and \(r\) +such that \(a = b q + r\) and \(0 \le r < |b|\). +Here we will make use of the following variation, which says that there +are \(q'\) and \(r'\) such that +\(a = b q' + r'\) and \(|r'| \le |b|/2\). +You can check that if the value of \(r\) in the first statement +satisfies \(r \le |b|/2\), we can take \(q' = q\) and \(r' = r\), +and otherwise we can take \(q' = q + 1\) and \(r' = r - b\) +(for \(b\) positive; otherwise mutatis mutandis). +We are grateful to Heather Macbeth for suggesting the following more +elegant approach, which avoids definition by cases. +We simply add b / 2 to a before dividing and then subtract it +from the remainder.

+
def div' (a b : ℤ) :=
+  (a + b / 2) / b
+
+def mod' (a b : ℤ) :=
+  (a + b / 2) % b - b / 2
+
+theorem div'_add_mod' (a b : ℤ) : b * div' a b + mod' a b = a := by
+  rw [div', mod']
+  linarith [Int.mul_ediv_add_emod (a + b / 2) b]
+
+theorem abs_mod'_le (a b : ℤ) (h : 0 < b) : |mod' a b| ≤ b / 2 := by
+  rw [mod', abs_le]
+  constructor
+  · linarith [Int.emod_nonneg (a + b / 2) h.ne']
+  have := Int.emod_lt_of_pos (a + b / 2) h
+  have := Int.mul_ediv_add_emod b 2
+  have := Int.emod_lt_of_pos b zero_lt_two
+  linarith
+
+
+

Note the use of our old friend, linarith. We will also need to express +mod' in terms of div'.

+
theorem mod'_eq (a b : ℤ) : mod' a b = a - b * div' a b := by linarith [div'_add_mod' a b]
+
+
+

We will use the fact that \(x^2 + y^2\) is equal to zero if and only if +\(x\) and \(y\) are both zero. As an exercise, we ask you to prove +that this holds in any ordered ring.

+
theorem square_add_sq_eq_zero {α : Type*} [Ring α] [LinearOrder α] [IsStrictOrderedRing α]
+    (x y : α) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by
+  sorry
+
+
+

We will put all the remaining definitions and theorems in this section +in the GaussInt namespace. +First, we define the norm function and ask you to establish +some of its properties. +The proofs are all short.

+
def norm (x : GaussInt) :=
+  x.re ^ 2 + x.im ^ 2
+
+@[simp]
+theorem norm_nonneg (x : GaussInt) : 0 ≤ norm x := by
+  sorry
+theorem norm_eq_zero (x : GaussInt) : norm x = 0 ↔ x = 0 := by
+  sorry
+theorem norm_pos (x : GaussInt) : 0 < norm x ↔ x ≠ 0 := by
+  sorry
+theorem norm_mul (x y : GaussInt) : norm (x * y) = norm x * norm y := by
+  sorry
+
+
+

Next we define the conjugate function:

+
def conj (x : GaussInt) : GaussInt :=
+  ⟨x.re, -x.im⟩
+
+@[simp]
+theorem conj_re (x : GaussInt) : (conj x).re = x.re :=
+  rfl
+
+@[simp]
+theorem conj_im (x : GaussInt) : (conj x).im = -x.im :=
+  rfl
+
+theorem norm_conj (x : GaussInt) : norm (conj x) = norm x := by simp [norm]
+
+
+

Finally, we define division for the Gaussian integers +with the notation x / y, that rounds the complex quotient to the nearest +Gaussian integer. We use our bespoke Int.div' for that purpose. +As we calculated above, if x is \(a + bi\) and y is \(c + di\), +then the real and imaginary parts of x / y are the nearest integers to

+
+\[\frac{ac + bd}{c^2 + d^2} \quad \text{and} \quad \frac{bc -ad}{c^2+d^2},\]
+

respectively. Here the numerators are the real and imaginary parts of +\((a + bi) (c - di)\), and the denominators are both equal to the norm +of \(c + di\).

+
instance : Div GaussInt :=
+  ⟨fun x y ↦ ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩⟩
+
+
+

Having defined x / y, we define x % y to be the remainder, +x - (x / y) * y. As above, we record the definitions in the +theorems div_def and +mod_def so that we can use them with simp and rw.

+
instance : Mod GaussInt :=
+  ⟨fun x y ↦ x - y * (x / y)⟩
+
+theorem div_def (x y : GaussInt) :
+    x / y = ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩ :=
+  rfl
+
+theorem mod_def (x y : GaussInt) : x % y = x - y * (x / y) :=
+  rfl
+
+
+

These definitions immediately yield x = y * (x / y) + x % y for every +x and y, so all we need to do is show that the norm of x % y is +less than the norm of y when y is not zero.

+

We just defined the real and imaginary parts of x / y to be +div' (x * conj y).re (norm y) and div' (x * conj y).im (norm y), +respectively. +Calculating, we have

+
+

(x % y) * conj y = (x - x / y * y) * conj y = x * conj y - x / y * (y * conj y)

+
+

The real and imaginary parts of the right-hand side are exactly mod' (x * conj y).re (norm y) and mod' (x * conj y).im (norm y). +By the properties of div' and mod', +these are guaranteed to be less than or equal to norm y / 2. +So we have

+
+

norm ((x % y) * conj y) ≤ (norm y / 2)^2 + (norm y / 2)^2 ≤ (norm y / 2) * norm y.

+
+

On the other hand, we have

+
+

norm ((x % y) * conj y) = norm (x % y) * norm (conj y) = norm (x % y) * norm y.

+
+

Dividing through by norm y we have norm (x % y) ≤ (norm y) / 2 < norm y, +as required.

+

This messy calculation is carried out in the next proof. We encourage you +to step through the details and see if you can find a nicer argument.

+
theorem norm_mod_lt (x : GaussInt) {y : GaussInt} (hy : y ≠ 0) :
+    (x % y).norm < y.norm := by
+  have norm_y_pos : 0 < norm y := by rwa [norm_pos]
+  have H1 : x % y * conj y = ⟨Int.mod' (x * conj y).re (norm y), Int.mod' (x * conj y).im (norm y)⟩
+  · ext <;> simp [Int.mod'_eq, mod_def, div_def, norm] <;> ring
+  have H2 : norm (x % y) * norm y ≤ norm y / 2 * norm y
+  · calc
+      norm (x % y) * norm y = norm (x % y * conj y) := by simp only [norm_mul, norm_conj]
+      _ = |Int.mod' (x.re * y.re + x.im * y.im) (norm y)| ^ 2
+          + |Int.mod' (-(x.re * y.im) + x.im * y.re) (norm y)| ^ 2 := by simp [H1, norm, sq_abs]
+      _ ≤ (y.norm / 2) ^ 2 + (y.norm / 2) ^ 2 := by gcongr <;> apply Int.abs_mod'_le _ _ norm_y_pos
+      _ = norm y / 2 * (norm y / 2 * 2) := by ring
+      _ ≤ norm y / 2 * norm y := by gcongr; apply Int.ediv_mul_le; norm_num
+  calc norm (x % y) ≤ norm y / 2 := le_of_mul_le_mul_right H2 norm_y_pos
+    _ < norm y := by
+        apply Int.ediv_lt_of_lt_mul
+        · norm_num
+        · linarith
+
+
+

We are in the home stretch. Our norm function maps Gaussian integers to +nonnegative integers. We need a function that maps Gaussian integers to natural +numbers, and we obtain that by composing norm with the function +Int.natAbs, which maps integers to the natural numbers. +The first of the next two lemmas establishes that mapping the norm to the +natural numbers and back to the integers does not change the value. +The second one re-expresses the fact that the norm is decreasing.

+
theorem coe_natAbs_norm (x : GaussInt) : (x.norm.natAbs : ℤ) = x.norm :=
+  Int.natAbs_of_nonneg (norm_nonneg _)
+
+theorem natAbs_norm_mod_lt (x y : GaussInt) (hy : y ≠ 0) :
+    (x % y).norm.natAbs < y.norm.natAbs := by
+  apply Int.ofNat_lt.1
+  simp only [Int.natCast_natAbs, abs_of_nonneg, norm_nonneg]
+  exact norm_mod_lt x hy
+
+
+

We also need to establish the second key property of the norm function +on a Euclidean domain.

+
theorem not_norm_mul_left_lt_norm (x : GaussInt) {y : GaussInt} (hy : y ≠ 0) :
+    ¬(norm (x * y)).natAbs < (norm x).natAbs := by
+  apply not_lt_of_ge
+  rw [norm_mul, Int.natAbs_mul]
+  apply le_mul_of_one_le_right (Nat.zero_le _)
+  apply Int.ofNat_le.1
+  rw [coe_natAbs_norm]
+  exact Int.add_one_le_of_lt ((norm_pos _).mpr hy)
+
+
+

We can now put it together to show that the Gaussian integers are an +instance of a Euclidean domain. We use the quotient and remainder function we +have defined. +The Mathlib definition of a Euclidean domain is more general than the one +above in that it allows us to show that remainder decreases with respect +to any well-founded measure. +Comparing the values of a norm function that returns natural numbers is +just one instance of such a measure, +and in that case, the required properties are the theorems +natAbs_norm_mod_lt and not_norm_mul_left_lt_norm.

+
instance : EuclideanDomain GaussInt :=
+  { GaussInt.instCommRing with
+    quotient := (· / ·)
+    remainder := (· % ·)
+    quotient_mul_add_remainder_eq :=
+      fun x y ↦ by rw [mod_def, add_comm] ; ring
+    quotient_zero := fun x ↦ by
+      simp [div_def, norm, Int.div']
+      rfl
+    r := (measure (Int.natAbs ∘ norm)).1
+    r_wellFounded := (measure (Int.natAbs ∘ norm)).2
+    remainder_lt := natAbs_norm_mod_lt
+    mul_left_not_lt := not_norm_mul_left_lt_norm }
+
+
+

An immediate payoff is that we now know that, in the Gaussian integers, +the notions of being prime and being irreducible coincide.

+
example (x : GaussInt) : Irreducible x ↔ Prime x :=
+  irreducible_iff_prime
+
+
+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C08_Hierarchies.html b/dev/vendor/mathematics_in_lean/html/C08_Hierarchies.html new file mode 100644 index 0000000..52df87a --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C08_Hierarchies.html @@ -0,0 +1,1026 @@ + + + + + + + + + 8. Hierarchies — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

8. Hierarchies

+

We have seen in Chapter 7 how to define the class +of groups and build instances of this class, and then how to build an instance +of the commutative ring class. But of course there is a hierarchy here: a +commutative ring is in particular an additive group. In this chapter we +will study how to build such hierarchies. They appear in all branches +of mathematics but in this chapter the emphasis will be on algebraic examples.

+

It may seem premature to discuss how to build hierarchies before more discussions +about using existing hierarchies. But some understanding of the technology underlying +hierarchies is required to use them. So you should probably still read this chapter, +but without trying too hard to remember everything on your first read, then read +the following chapters and come back here for a second reading.

+

In this chapter, we will redefine (simpler versions of) many things that appear in Mathlib +so we will used indices to distinguish our version. For instance we will have Ring₁ +as our version of Ring. Since we will gradually explain more powerful ways of formalizing +structures, those indices will sometimes grow beyond one.

+
+

8.1. Basics

+

At the very bottom of all hierarchies in Lean, we find data-carrying +classes. The following class records that the given type α is endowed with +a distinguished element called one. At this stage, it has no property at all.

+
class One₁ (α : Type) where
+  /-- The element one -/
+  one : α
+
+
+

Since we’ll make a much heavier use of classes in this chapter, we need to understand some +more details about what the class command is doing. +First, the class command above defines a structure One₁ with parameter α : Type and +a single field one. It also mark this structure as a class so that arguments of type +One₁ α for some type α will be inferrable using the instance resolution procedure, +as long as they are marked as instance-implicit, i.e. appear between square brackets. +Those two effects could also have been achieved using the structure command with class +attribute, i.e. writing @[class] structure instance of class. But the class command also +ensures that One₁ α appears as an instance-implicit argument in its own fields. Compare:

+
#check One₁.one -- One₁.one {α : Type} [self : One₁ α] : α
+
+@[class] structure One₂ (α : Type) where
+  /-- The element one -/
+  one : α
+
+#check One₂.one
+
+
+

In the second check, we can see that self : One₂ α is an explicit argument. +Let us make sure the first version is indeed usable without any explicit argument.

+
example (α : Type) [One₁ α] : α := One₁.one
+
+
+

Remark: in the above example, the argument One₁ α is marked as instance-implicit, +which is a bit silly since this affects only uses of the declaration and declaration created by +the example command cannot be used. However it allows us to avoid giving a name to that +argument and, more importantly, it starts installing the good habit of marking One₁ α +arguments as instance-implicit.

+

Another remark is that all this will work only when Lean knows what is α. In the above +example, leaving out the type ascription : α would generate an error message like: +typeclass instance problem is stuck, it is often due to metavariables One₁ (?m.263 α) +where ?m.263 α means “some type depending on α” (and 263 is simply an auto-generated +index that would be useful to distinguish between several unknown things). Another way +to avoid this issue would be to use a type annotation, as in:

+
example (α : Type) [One₁ α] := (One₁.one : α)
+
+
+

You may have already encountered that issue when playing with limits of sequences +in Section 3.6 if you tried to state for instance that +0 < 1 without telling Lean whether you meant this inequality to be about natural numbers +or real numbers.

+

Our next task is to assign a notation to One₁.one. Since we don’t want collisions +with the builtin notation for 1, we will use 𝟙. This is achieved by the following +command where the first line tells Lean to use the documentation +of One₁.one as documentation for the symbol 𝟙.

+
@[inherit_doc]
+notation "𝟙" => One₁.one
+
+example {α : Type} [One₁ α] : α := 𝟙
+
+example {α : Type} [One₁ α] : (𝟙 : α) = 𝟙 := rfl
+
+
+

We now want a data-carrying class recording a binary operation. We don’t want to choose +between addition and multiplication for now so we’ll use diamond.

+
class Dia₁ (α : Type) where
+  dia : α → α → α
+
+infixl:70 " ⋄ "   => Dia₁.dia
+
+
+

As in the One₁ example, the operation has no property at all at this stage. Let us +now define the class of semigroup structures where the operation is denoted by ⋄. +For now, we define it by hand as a structure with two fields, a Dia₁ instance and some +Prop-valued field dia_assoc asserting associativity of ⋄.

+
class Semigroup₀ (α : Type) where
+  toDia₁ : Dia₁ α
+  /-- Diamond is associative -/
+  dia_assoc : ∀ a b c : α, a ⋄ b ⋄ c = a ⋄ (b ⋄ c)
+
+
+

Note that while stating dia_assoc, the previously defined field toDia₁ is in the local +context hence can be used when Lean searches for an instance of Dia₁ α to make sense +of a ⋄ b. However this toDia₁ field does not become part of the type class instances database. +Hence doing example {α : Type} [Semigroup₀ α] (a b : α) : α := a ⋄ b would fail with +error message failed to synthesize instance Dia₁ α.

+

We can fix this by adding the instance attribute later (do not pay attention to the reducible +attribute, it won’t be needed once we explain a better way to do this in the next paragraph).

+
attribute [reducible, instance] Semigroup₀.toDia₁
+
+example {α : Type} [Semigroup₀ α] (a b : α) : α := a ⋄ b
+
+
+

Before building up, we need to use a different syntax to add this toDia₁ field, +to tell Lean that Dia₁ α should be treated as if its fields were fields of Semigroup₁ itself. +This also conveniently adds the toDia₁ instance automatically. +The class command supports this using the extends syntax as in:

+
class Semigroup₁ (α : Type) extends toDia₁ : Dia₁ α where
+  /-- Diamond is associative -/
+  dia_assoc : ∀ a b c : α, a ⋄ b ⋄ c = a ⋄ (b ⋄ c)
+
+example {α : Type} [Semigroup₁ α] (a b : α) : α := a ⋄ b
+
+
+

Note this syntax is also available in the structure command, although in that +case it fixes only the hurdle of writing fields such as toDia₁ since there +is no instance to define in that case.

+

The field name toDia₁ is optional in the extends syntax. +By default it takes the name of the class being extended and prefixes it with “to”.

+
class Semigroup₂ (α : Type) extends Dia₁ α where
+  /-- Diamond is associative -/
+  dia_assoc : ∀ a b c : α, a ⋄ b ⋄ c = a ⋄ (b ⋄ c)
+
+
+

Let us now try to combine a diamond operation and a distinguished one element with axioms saying +this element is neutral on both sides.

+
class DiaOneClass₁ (α : Type) extends One₁ α, Dia₁ α where
+  /-- One is a left neutral element for diamond. -/
+  one_dia : ∀ a : α, 𝟙 ⋄ a = a
+  /-- One is a right neutral element for diamond -/
+  dia_one : ∀ a : α, a ⋄ 𝟙 = a
+
+
+

In the next example, we tell Lean that α has a DiaOneClass₁ structure and state a +property that uses both a Dia₁ instance and a One₁ instance. In order to see how Lean finds +those instances we set a tracing option whose result can be seen in the Infoview. This result +is rather terse by default but it can be expanded by clicking on lines ending with black arrows. +It includes failed attempts where Lean tried to find instances before having enough type +information to succeed. The successful attempts do involve the instances generated by the +extends syntax.

+
set_option trace.Meta.synthInstance true in
+example {α : Type} [DiaOneClass₁ α] (a b : α) : Prop := a ⋄ b = 𝟙
+
+
+

Note that we don’t need to include extra fields where combining existing classes. Hence we can +define monoids as:

+
class Monoid₁ (α : Type) extends Semigroup₁ α, DiaOneClass₁ α
+
+
+

While the above definition seems straightforward, it hides an important subtlety. Both +Semigroup₁ α and DiaOneClass₁ α extend Dia₁ α, so one could fear that having +a Monoid₁ α instance gives two unrelated diamond operations on α, one coming from +a field Monoid₁.toSemigroup₁ and one coming from a field Monoid₁.toDiaOneClass₁.

+

Indeed if we try to build a monoid class by hand using:

+
class Monoid₂ (α : Type) where
+  toSemigroup₁ : Semigroup₁ α
+  toDiaOneClass₁ : DiaOneClass₁ α
+
+
+

then we get two completely unrelated diamond operations +Monoid₂.toSemigroup₁.toDia₁.dia and Monoid₂.toDiaOneClass₁.toDia₁.dia.

+

The version generated using the extends syntax does not have this defect.

+
example {α : Type} [Monoid₁ α] :
+  (Monoid₁.toSemigroup₁.toDia₁.dia : α → α → α) = Monoid₁.toDiaOneClass₁.toDia₁.dia := rfl
+
+
+

So the class command did some magic for us (and the structure command would have done it +too). An easy way to see what are the fields of our classes is to check their constructor. Compare:

+
/- Monoid₂.mk {α : Type} (toSemigroup₁ : Semigroup₁ α) (toDiaOneClass₁ : DiaOneClass₁ α) : Monoid₂ α -/
+#check Monoid₂.mk
+
+/- Monoid₁.mk {α : Type} [toSemigroup₁ : Semigroup₁ α] [toOne₁ : One₁ α] (one_dia : ∀ (a : α), 𝟙 ⋄ a = a) (dia_one : ∀ (a : α), a ⋄ 𝟙 = a) : Monoid₁ α -/
+#check Monoid₁.mk
+
+
+

So we see that Monoid₁ takes Semigroup₁ α argument as expected but then it won’t +take a would-be overlapping DiaOneClass₁ α argument but instead tears it apart and includes +only the non-overlapping parts. And it also auto-generated an instance Monoid₁.toDiaOneClass₁ +which is not a field but has the expected signature which, from the end-user point of view, +restores the symmetry between the two extended classes Semigroup₁ and DiaOneClass₁.

+
#check Monoid₁.toSemigroup₁
+#check Monoid₁.toDiaOneClass₁
+
+
+

We are now very close to defining groups. We could add to the monoid structure a field asserting +the existence of an inverse for every element. But then we would need to work to access these +inverses. In practice it is more convenient to add it as data. To optimize reusability, +we define a new data-carrying class, and then give it some notation.

+
class Inv₁ (α : Type) where
+  /-- The inversion function -/
+  inv : α → α
+
+@[inherit_doc]
+postfix:max "⁻¹" => Inv₁.inv
+
+class Group₁ (G : Type) extends Monoid₁ G, Inv₁ G where
+  inv_dia : ∀ a : G, a⁻¹ ⋄ a = 𝟙
+
+
+

The above definition may seem too weak, we only ask that a⁻¹ is a left-inverse of a. +But the other side is automatic. In order to prove that, we need a preliminary lemma.

+
lemma left_inv_eq_right_inv₁ {M : Type} [Monoid₁ M] {a b c : M} (hba : b ⋄ a = 𝟙) (hac : a ⋄ c = 𝟙) : b = c := by
+  rw [← DiaOneClass₁.one_dia c, ← hba, Semigroup₁.dia_assoc, hac, DiaOneClass₁.dia_one b]
+
+
+

In this lemma, it is pretty annoying to give full names, especially since it requires knowing +which part of the hierarchy provides those facts. One way to fix this is to use the export +command to copy those facts as lemmas in the root name space.

+
export DiaOneClass₁ (one_dia dia_one)
+export Semigroup₁ (dia_assoc)
+export Group₁ (inv_dia)
+
+
+

We can then rewrite the above proof as:

+
example {M : Type} [Monoid₁ M] {a b c : M} (hba : b ⋄ a = 𝟙) (hac : a ⋄ c = 𝟙) : b = c := by
+  rw [← one_dia c, ← hba, dia_assoc, hac, dia_one b]
+
+
+

It is now your turn to prove things about our algebraic structures.

+
lemma inv_eq_of_dia [Group₁ G] {a b : G} (h : a ⋄ b = 𝟙) : a⁻¹ = b :=
+  sorry
+
+lemma dia_inv [Group₁ G] (a : G) : a ⋄ a⁻¹ = 𝟙 :=
+  sorry
+
+
+

At this stage we would like to move on to define rings, but there is a serious issue. +A ring structure on a type contains both an additive group structure and a multiplicative +monoid structure, and some properties about their interaction. But so far we hard-coded +a notation ⋄ for all our operations. More fundamentally, the type class system +assumes every type has only one instance of each type class. There are various +ways to solve this issue. Surprisingly Mathlib uses the naive idea to duplicate +everything for additive and multiplicative theories with the help of some code-generating +attribute. Structures and classes are defined in both additive and multiplicative notation +with an attribute to_additive linking them. In case of multiple inheritance like for +semi-groups, the auto-generated “symmetry-restoring” instances need also to be marked. +This is a bit technical; you don’t need to understand details. The important point is that +lemmas are then only stated in multiplicative notation and marked with the attribute to_additive +to generate the additive version as left_inv_eq_right_inv' with its auto-generated additive +version left_neg_eq_right_neg'. In order to check the name of this additive version we +used the #whats_new in command on top of left_inv_eq_right_inv'.

+
class AddSemigroup₃ (α : Type) extends Add α where
+  /-- Addition is associative -/
+  add_assoc₃ : ∀ a b c : α, a + b + c = a + (b + c)
+
+@[to_additive AddSemigroup₃]
+class Semigroup₃ (α : Type) extends Mul α where
+  /-- Multiplication is associative -/
+  mul_assoc₃ : ∀ a b c : α, a * b * c = a * (b * c)
+
+class AddMonoid₃ (α : Type) extends AddSemigroup₃ α, AddZeroClass α
+
+@[to_additive AddMonoid₃]
+class Monoid₃ (α : Type) extends Semigroup₃ α, MulOneClass α
+
+export Semigroup₃ (mul_assoc₃)
+export AddSemigroup₃ (add_assoc₃)
+
+#whats_new in
+@[to_additive]
+lemma left_inv_eq_right_inv' {M : Type} [Monoid₃ M] {a b c : M} (hba : b * a = 1) (hac : a * c = 1) : b = c := by
+  rw [← one_mul c, ← hba, mul_assoc₃, hac, mul_one b]
+
+#check left_neg_eq_right_neg'
+
+
+

Equipped with this technology, we can easily define also commutative semigroups, monoids and +groups, and then define rings.

+
class AddCommSemigroup₃ (α : Type) extends AddSemigroup₃ α where
+  add_comm : ∀ a b : α, a + b = b + a
+
+@[to_additive AddCommSemigroup₃]
+class CommSemigroup₃ (α : Type) extends Semigroup₃ α where
+  mul_comm : ∀ a b : α, a * b = b * a
+
+class AddCommMonoid₃ (α : Type) extends AddMonoid₃ α, AddCommSemigroup₃ α
+
+@[to_additive AddCommMonoid₃]
+class CommMonoid₃ (α : Type) extends Monoid₃ α, CommSemigroup₃ α
+
+class AddGroup₃ (G : Type) extends AddMonoid₃ G, Neg G where
+  neg_add : ∀ a : G, -a + a = 0
+
+@[to_additive AddGroup₃]
+class Group₃ (G : Type) extends Monoid₃ G, Inv G where
+  inv_mul : ∀ a : G, a⁻¹ * a = 1
+
+
+

We should remember to tag lemmas with simp when appropriate.

+
attribute [simp] Group₃.inv_mul AddGroup₃.neg_add
+
+
+

Then we need to repeat ourselves a bit since we switch to standard notations, but at least +to_additive does the work of translating from the multiplicative notation to the additive one.

+
@[to_additive]
+lemma inv_eq_of_mul [Group₃ G] {a b : G} (h : a * b = 1) : a⁻¹ = b :=
+  sorry
+
+
+

Note that to_additive can be asked to tag a lemma with simp and propagate that attribute +to the additive version as follows.

+
@[to_additive (attr := simp)]
+lemma Group₃.mul_inv {G : Type} [Group₃ G] (a : G) : a * a⁻¹ = 1 := by
+  sorry
+
+@[to_additive]
+lemma mul_left_cancel₃ {G : Type} [Group₃ G] {a b c : G} (h : a * b = a * c) : b = c := by
+  sorry
+
+@[to_additive]
+lemma mul_right_cancel₃ {G : Type} [Group₃ G] {a b c : G} (h : b*a = c*a) : b = c := by
+  sorry
+
+class AddCommGroup₃ (G : Type) extends AddGroup₃ G, AddCommMonoid₃ G
+
+@[to_additive AddCommGroup₃]
+class CommGroup₃ (G : Type) extends Group₃ G, CommMonoid₃ G
+
+
+

We are now ready for rings. For demonstration purposes we won’t assume that addition is +commutative, and then immediately provide an instance of AddCommGroup₃. Mathlib does not +play this game, first because in practice this does not make any ring instance easier and +also because Mathlib’s algebraic hierarchy goes through semirings which are like rings but without +opposites so that the proof below does not work for them. What we gain here, besides a nice exercise +if you have never seen it, is an example of building an instance using the syntax that allows +to provide a parent structure as an instance parameter and then supply the extra fields. +Here the Ring₃ R argument supplies anything AddCommGroup₃ R wants except for add_comm.

+
class Ring₃ (R : Type) extends AddGroup₃ R, Monoid₃ R, MulZeroClass R where
+  /-- Multiplication is left distributive over addition -/
+  left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c
+  /-- Multiplication is right distributive over addition -/
+  right_distrib : ∀ a b c : R, (a + b) * c = a * c + b * c
+
+instance {R : Type} [Ring₃ R] : AddCommGroup₃ R :=
+{ add_comm := by
+    sorry }
+
+
+

Of course we can also build concrete instances, such as a ring structure on integers (of course +the instance below uses that all the work is already done in Mathlib).

+
instance : Ring₃ ℤ where
+  add := (· + ·)
+  add_assoc₃ := add_assoc
+  zero := 0
+  zero_add := by simp
+  add_zero := by simp
+  neg := (- ·)
+  neg_add := by simp
+  mul := (· * ·)
+  mul_assoc₃ := mul_assoc
+  one := 1
+  one_mul := by simp
+  mul_one := by simp
+  zero_mul := by simp
+  mul_zero := by simp
+  left_distrib := Int.mul_add
+  right_distrib := Int.add_mul
+
+
+

As an exercise you can now set up a simple hierarchy for order relations, including a class +for ordered commutative monoids, which have both a partial order and a commutative monoid structure +such that ∀ a b : α, a ≤ b → ∀ c : α, c * a ≤ c * b. Of course you need to add fields and maybe +extends clauses to the following classes.

+
class LE₁ (α : Type) where
+  /-- The Less-or-Equal relation. -/
+  le : α → α → Prop
+
+@[inherit_doc] infix:50 " ≤₁ " => LE₁.le
+
+class Preorder₁ (α : Type)
+
+class PartialOrder₁ (α : Type)
+
+class OrderedCommMonoid₁ (α : Type)
+
+instance : OrderedCommMonoid₁ ℕ where
+
+
+

We now want to discuss algebraic structures involving several types. The prime example +is modules over rings. If you don’t know what is a module, you can pretend it means vector space +and think that all our rings are fields. Those structures are commutative additive groups +equipped with a scalar multiplication by elements of some ring.

+

We first define the data-carrying type class of scalar multiplication by some type α on some +type β, and give it a right associative notation.

+
class SMul₃ (α : Type) (β : Type) where
+  /-- Scalar multiplication -/
+  smul : α → β → β
+
+infixr:73 " • " => SMul₃.smul
+
+
+

Then we can define modules (again think about vector spaces if you don’t know what is a module).

+
class Module₁ (R : Type) [Ring₃ R] (M : Type) [AddCommGroup₃ M] extends SMul₃ R M where
+  zero_smul : ∀ m : M, (0 : R) • m = 0
+  one_smul : ∀ m : M, (1 : R) • m = m
+  mul_smul : ∀ (a b : R) (m : M), (a * b) • m = a • b • m
+  add_smul : ∀ (a b : R) (m : M), (a + b) • m = a • m + b • m
+  smul_add : ∀ (a : R) (m n : M), a • (m + n) = a • m + a • n
+
+
+

There is something interesting going on here. While it isn’t too surprising that the +ring structure on R is a parameter in this definition, you probably expected AddCommGroup₃ M +to be part of the extends clause just as SMul₃ R M is. Trying to do that would lead +to a field Module₃.toAddCommGroup₃ marked as an instance. This instance +would have the signature: +(R : Type) → [inst : Ring₃ R] → {M : Type} → [self : Module₁ R M] → AddCommGroup₃ M. +With such an instance in the type class database, each time Lean would look for a +AddCommGroup₃ M instance for some M, it would need to go hunting for a completely +unspecified type R and a Ring₃ R instance before embarking on the main quest of finding a +Module₁ R M instance. Those two side-quests are represented by the meta-variables mentioned in +the error message and denoted by ?R and ?inst✝ there. Such a Module₃.toAddCommGroup₃ +instance would then be a huge trap for the instance resolution procedure.

+

What about extends SMul₃ R M then? That one creates a field +Module₁.toSMul₃ : {R : Type} →  [inst : Ring₃ R] → {M : Type} → [inst_1 : AddCommGroup₃ M] → [self : Module₁ R M] → SMul₃ R M +whose end result SMul₃ R M mentions both R and M so this field can +safely be used as an instance. The rule is easy to remember: each class appearing in the +extends clause should mention every type appearing in the parameters.

+

Let us create our first module instance: a ring is a module over itself using its multiplication +as a scalar multiplication.

+
instance selfModule (R : Type) [Ring₃ R] : Module₁ R R where
+  smul := fun r s ↦ r*s
+  zero_smul := zero_mul
+  one_smul := one_mul
+  mul_smul := mul_assoc₃
+  add_smul := Ring₃.right_distrib
+  smul_add := Ring₃.left_distrib
+
+
+

As a second example, every abelian group is a module over ℤ (this is one of the reason to +generalize the theory of vector spaces by allowing non-invertible scalars). First one can define +scalar multiplication by a natural number for any type equipped with a zero and an addition: +n • a is defined as a + ⋯ + a where a appears n times. Then this is extended +to scalar multiplication by an integer by ensuring (-1) • a = -a.

+
def nsmul₁ {M : Type*} [Zero M] [Add M] : ℕ → M → M
+  | 0, _ => 0
+  | n + 1, a => a + nsmul₁ n a
+
+def zsmul₁ {M : Type*} [Zero M] [Add M] [Neg M] : ℤ → M → M
+  | Int.ofNat n, a => nsmul₁ n a
+  | Int.negSucc n, a => -nsmul₁ n.succ a
+
+
+

Proving this gives rise to a module structure is a bit tedious and not interesting for the +current discussion, so we will sorry all axioms. You are not asked to replace those sorries +with proofs. If you insist on doing it then you will probably want to state and prove several +intermediate lemmas about nsmul₁ and zsmul₁.

+
instance abGrpModule (A : Type) [AddCommGroup₃ A] : Module₁ ℤ A where
+  smul := zsmul₁
+  zero_smul := sorry
+  one_smul := sorry
+  mul_smul := sorry
+  add_smul := sorry
+  smul_add := sorry
+
+
+

A much more important issue is that we now have two module structures over the ring ℤ +for ℤ itself: abGrpModule ℤ since ℤ is a abelian group, and selfModule ℤ since +ℤ is a ring. Those two module structure correspond to the same abelian group structure, +but it is not obvious that they have the same scalar multiplication. They actually do, but +this isn’t true by definition, it requires a proof. This is very bad news for the type class +instance resolution procedure and will lead to very frustrating failures for users of this +hierarchy. When directly asked to find an instance, Lean will pick one, and we can see +which one using:

+
#synth Module₁ ℤ ℤ -- abGrpModule ℤ
+
+
+

But in a more indirect context it can happen that Lean infers the other one and then gets confused. +This situation is known as a bad diamond. This has nothing to do with the diamond operation +we used above, it refers to the way one can draw the paths from ℤ to its Module₁ ℤ +going through either AddCommGroup₃ ℤ or Ring₃ ℤ.

+

It is important to understand that not all diamonds are bad. In fact there are diamonds everywhere +in Mathlib, and also in this chapter. Already at the very beginning we saw one can go +from Monoid₁ α to Dia₁ α through either Semigroup₁ α or DiaOneClass₁ α and +thanks to the work done by the class command, the resulting two Dia₁ α instances +are definitionally equal. In particular a diamond having a Prop-valued class at the bottom +cannot be bad since any two proofs of the same statement are definitionally equal.

+

But the diamond we created with modules is definitely bad. The offending piece is the smul +field which is data, not a proof, and we have two constructions that are not definitionally equal. +The robust way of fixing this issue is to make sure that going from a rich structure to a +poor structure is always done by forgetting data, not by defining data. This well-known pattern +has been named “forgetful inheritance” and extensively discussed in +https://inria.hal.science/hal-02463336v2.

+

In our concrete case, we can modify the definition of AddMonoid₃ to include a nsmul data +field and some Prop-valued fields ensuring this operation is provably the one we constructed +above. Those fields are given default values using := after their type in the definition below. +Thanks to these default values, most instances would be constructed exactly as with our previous +definitions. But in the special case of ℤ we will be able to provide specific values.

+
class AddMonoid₄ (M : Type) extends AddSemigroup₃ M, AddZeroClass M where
+  /-- Multiplication by a natural number. -/
+  nsmul : ℕ → M → M := nsmul₁
+  /-- Multiplication by `(0 : ℕ)` gives `0`. -/
+  nsmul_zero : ∀ x, nsmul 0 x = 0 := by intros; rfl
+  /-- Multiplication by `(n + 1 : ℕ)` behaves as expected. -/
+  nsmul_succ : ∀ (n : ℕ) (x), nsmul (n + 1) x = x + nsmul n x := by intros; rfl
+
+instance mySMul {M : Type} [AddMonoid₄ M] : SMul ℕ M := ⟨AddMonoid₄.nsmul⟩
+
+
+

Let us check we can still construct a product monoid instance without providing the nsmul +related fields.

+
instance (M N : Type) [AddMonoid₄ M] [AddMonoid₄ N] : AddMonoid₄ (M × N) where
+  add := fun p q ↦ (p.1 + q.1, p.2 + q.2)
+  add_assoc₃ := fun a b c ↦ by ext <;> apply add_assoc₃
+  zero := (0, 0)
+  zero_add := fun a ↦ by ext <;> apply zero_add
+  add_zero := fun a ↦ by ext <;> apply add_zero
+
+
+

And now let us handle the special case of ℤ where we want to build nsmul using the coercion +of ℕ to ℤ and the multiplication on ℤ. Note in particular how the proof fields +contain more work than in the default value above.

+
instance : AddMonoid₄ ℤ where
+  add := (· + ·)
+  add_assoc₃ := Int.add_assoc
+  zero := 0
+  zero_add := Int.zero_add
+  add_zero := Int.add_zero
+  nsmul := fun n m ↦ (n : ℤ) * m
+  nsmul_zero := Int.zero_mul
+  nsmul_succ := fun n m ↦ show (n + 1 : ℤ) * m = m + n * m
+    by rw [Int.add_mul, Int.add_comm, Int.one_mul]
+
+
+

Let us check we solved our issue. Because Lean already has a definition of scalar multiplication +of a natural number and an integer, and we want to make sure our instance is used, we won’t use +the • notation but call SMul.mul and explicitly provide our instance defined above.

+
example (n : ℕ) (m : ℤ) : SMul.smul (self := mySMul) n m = n * m := rfl
+
+
+

This story then continues with incorporating a zsmul field into the definition of groups +and similar tricks. You are now ready to read the definition of monoids, groups, rings and modules +in Mathlib. They are more complicated than what we have seen here, because they are part of a huge +hierarchy, but all principles have been explained above.

+

As an exercise, you can come back to the order relation hierarchy you built above and try +to incorporate a type class LT₁ carrying the Less-Than notation <₁ and make sure +that every preorder comes with a <₁ which has a default value built from ≤₁ and a +Prop-valued field asserting the natural relation between those two comparison operators.

+
+
+

8.2. Morphisms

+

So far in this chapter, we discussed how to create a hierarchy of mathematical structures. +But defining structures is not really completed until we have morphisms. There are two +main approaches here. The most obvious one is to define a predicate on functions.

+
def isMonoidHom₁ [Monoid G] [Monoid H] (f : G → H) : Prop :=
+  f 1 = 1 ∧ ∀ g g', f (g * g') = f g * f g'
+
+
+

In this definition, it is a bit unpleasant to use a conjunction. In particular users +will need to remember the ordering we chose when they want to access the two conditions. +So we could use a structure instead.

+
structure isMonoidHom₂ [Monoid G] [Monoid H] (f : G → H) : Prop where
+  map_one : f 1 = 1
+  map_mul : ∀ g g', f (g * g') = f g * f g'
+
+
+

Once we are here, it is even tempting to make it a class and use the type class instance resolution +procedure to automatically infer isMonoidHom₂ for complicated functions out of instances for +simpler functions. For instance a composition of monoid morphisms is a monoid morphism and this +seems like a useful instance. However such an instance would be very tricky for the resolution +procedure since it would need to hunt down g ∘ f everywhere. Seeing it failing in g (f x) +would be very frustrating. More generally one must always keep in mind that recognizing which +function is applied in a given expression is a very difficult problem, called the “higher-order +unification problem”. So Mathlib does not use this class approach.

+

A more fundamental question is whether we use predicates as above (using either a def or a +structure) or use structures bundling a function and predicates. This is partly a psychological +issue. It is extremely rare to consider a function between monoids that is not a morphism. +It really feels like “monoid morphism” is not an adjective you can assign to a bare function, +it is a noun. On the other hand one can argue that a continuous function between topological spaces +is really a function that happens to be continuous. This is one reason why Mathlib has a +Continuous predicate. For instance you can write:

+
example : Continuous (id : ℝ → ℝ) := continuous_id
+
+
+

We still have bundles of continuous functions, which are convenient for instance to put a topology +on a space of continuous functions, but they are not the primary tool to work with continuity.

+

By contrast, morphisms between monoids (or other algebraic structures) are bundled as in:

+
@[ext]
+structure MonoidHom₁ (G H : Type) [Monoid G] [Monoid H]  where
+  toFun : G → H
+  map_one : toFun 1 = 1
+  map_mul : ∀ g g', toFun (g * g') = toFun g * toFun g'
+
+
+

Of course we don’t want to type toFun everywhere so we register a coercion using +the CoeFun type class. Its first argument is the type we want to coerce to a function. +The second argument describes the target function type. In our case it is always G → H +for every f : MonoidHom₁ G H. We also tag MonoidHom₁.toFun with the coe attribute to +make sure it is displayed almost invisibly in the tactic state, simply by a ↑ prefix.

+
instance [Monoid G] [Monoid H] : CoeFun (MonoidHom₁ G H) (fun _ ↦ G → H) where
+  coe := MonoidHom₁.toFun
+
+attribute [coe] MonoidHom₁.toFun
+
+
+

Let us check we can indeed apply a bundled monoid morphism to an element.

+
example [Monoid G] [Monoid H] (f : MonoidHom₁ G H) : f 1 = 1 :=  f.map_one
+
+
+

We can do the same with other kind of morphisms until we reach ring morphisms.

+
@[ext]
+structure AddMonoidHom₁ (G H : Type) [AddMonoid G] [AddMonoid H]  where
+  toFun : G → H
+  map_zero : toFun 0 = 0
+  map_add : ∀ g g', toFun (g + g') = toFun g + toFun g'
+
+instance [AddMonoid G] [AddMonoid H] : CoeFun (AddMonoidHom₁ G H) (fun _ ↦ G → H) where
+  coe := AddMonoidHom₁.toFun
+
+attribute [coe] AddMonoidHom₁.toFun
+
+@[ext]
+structure RingHom₁ (R S : Type) [Ring R] [Ring S] extends MonoidHom₁ R S, AddMonoidHom₁ R S
+
+
+

There are a couple of issues about this approach. A minor one is we don’t quite know where to put +the coe attribute since the RingHom₁.toFun does not exist, the relevant function is +MonoidHom₁.toFun ∘ RingHom₁.toMonoidHom₁ which is not a declaration that can be tagged with an +attribute (but we could still define a CoeFun  (RingHom₁ R S) (fun _ ↦ R → S) instance). +A much more important one is that lemmas about monoid morphisms won’t directly apply +to ring morphisms. This leaves the alternative of either juggling with RingHom₁.toMonoidHom₁ +each time we want to apply a monoid morphism lemma or restate every such lemmas for ring morphisms. +Neither option is appealing so Mathlib uses a new hierarchy trick here. The idea is to define +a type class for objects that are at least monoid morphisms, instantiate that class with both monoid +morphisms and ring morphisms and use it to state every lemma. In the definition below, +F could be MonoidHom₁ M N, or RingHom₁ M N if M and N have a ring structure.

+
class MonoidHomClass₁ (F : Type) (M N : Type) [Monoid M] [Monoid N] where
+  toFun : F → M → N
+  map_one : ∀ f : F, toFun f 1 = 1
+  map_mul : ∀ f g g', toFun f (g * g') = toFun f g * toFun f g'
+
+
+

However there is a problem with the above implementation. We haven’t registered a coercion to +function instance yet. Let us try to do it now (ignoring the warning from Lean telling us something +is dangerous here, since we know we are indeed doing something bad).

+
def badInst [Monoid M] [Monoid N] [MonoidHomClass₁ F M N] : CoeFun F (fun _ ↦ M → N) where
+  coe := MonoidHomClass₁.toFun
+
+
+

Making this an instance would be bad. When faced with something like f x where the type of f +is not a function type, Lean will try to find a CoeFun instance to coerce f into a function. +The above function has type: +{M N F : Type} → [Monoid M] → [Monoid N] → [MonoidHomClass₁ F M N] → CoeFun F (fun x ↦ M → N) +so, when it trying to apply it, it wouldn’t be a priori clear to Lean in which order the unknown +types M, N and F should be inferred. This is a kind of bad instance that is slightly +different from the one we saw already, but it boils down to the same issue: without knowing M, +Lean would have to search for a monoid instance on an unknown type, hence hopelessly try every +monoid instance in the database. If you are curious to see the effect of such an instance you +can type set_option synthInstance.checkSynthOrder false in on top of the above declaration, +replace def badInst with instance, and look for random failures in this file.

+

Here the solution is easy, we need to tell Lean to first search what is F and then deduce M +and N. This is done using the outParam function. This function is defined as the identity +function, but is still recognized by the type class machinery and triggers the desired behavior. +Hence we can retry defining our class, paying attention to the outParam function:

+
class MonoidHomClass₂ (F : Type) (M N : outParam Type) [Monoid M] [Monoid N] where
+  toFun : F → M → N
+  map_one : ∀ f : F, toFun f 1 = 1
+  map_mul : ∀ f g g', toFun f (g * g') = toFun f g * toFun f g'
+
+instance [Monoid M] [Monoid N] [MonoidHomClass₂ F M N] : CoeFun F (fun _ ↦ M → N) where
+  coe := MonoidHomClass₂.toFun
+
+attribute [coe] MonoidHomClass₂.toFun
+
+
+

Now we can proceed with our plan to instantiate this class.

+
instance (M N : Type) [Monoid M] [Monoid N] : MonoidHomClass₂ (MonoidHom₁ M N) M N where
+  toFun := MonoidHom₁.toFun
+  map_one := fun f ↦ f.map_one
+  map_mul := fun f ↦ f.map_mul
+
+instance (R S : Type) [Ring R] [Ring S] : MonoidHomClass₂ (RingHom₁ R S) R S where
+  toFun := fun f ↦ f.toMonoidHom₁.toFun
+  map_one := fun f ↦ f.toMonoidHom₁.map_one
+  map_mul := fun f ↦ f.toMonoidHom₁.map_mul
+
+
+

As promised every lemma we prove about f : F assuming an instance of MonoidHomClass₁ F will +apply both to monoid morphisms and ring morphisms. +Let us see an example lemma and check it applies to both situations.

+
lemma map_inv_of_inv [Monoid M] [Monoid N] [MonoidHomClass₂ F M N] (f : F) {m m' : M} (h : m*m' = 1) :
+    f m * f m' = 1 := by
+  rw [← MonoidHomClass₂.map_mul, h, MonoidHomClass₂.map_one]
+
+example [Monoid M] [Monoid N] (f : MonoidHom₁ M N) {m m' : M} (h : m*m' = 1) : f m * f m' = 1 :=
+map_inv_of_inv f h
+
+example [Ring R] [Ring S] (f : RingHom₁ R S) {r r' : R} (h : r*r' = 1) : f r * f r' = 1 :=
+map_inv_of_inv f h
+
+
+

At first sight, it may look like we got back to our old bad idea of making MonoidHom₁ a class. +But we haven’t. Everything is shifted one level of abstraction up. The type class resolution +procedure won’t be looking for functions, it will be looking for either +MonoidHom₁ or RingHom₁.

+

One remaining issue with our approach is the presence of repetitive code around the toFun +field and the corresponding CoeFun instance and coe attribute. It would also be better +to record that this pattern is used only for functions with extra properties, meaning that the +coercion to functions should be injective. So Mathlib adds one more layer of abstraction with +the base class DFunLike (where “DFun” stands for dependent function). +Let us redefine our MonoidHomClass on top of this base layer.

+
class MonoidHomClass₃ (F : Type) (M N : outParam Type) [Monoid M] [Monoid N] extends
+    DFunLike F M (fun _ ↦ N) where
+  map_one : ∀ f : F, f 1 = 1
+  map_mul : ∀ (f : F) g g', f (g * g') = f g * f g'
+
+instance (M N : Type) [Monoid M] [Monoid N] : MonoidHomClass₃ (MonoidHom₁ M N) M N where
+  coe := MonoidHom₁.toFun
+  coe_injective _ _ := MonoidHom₁.ext
+  map_one := MonoidHom₁.map_one
+  map_mul := MonoidHom₁.map_mul
+
+
+

Of course the hierarchy of morphisms does not stop here. We could go on and define a class +RingHomClass₃ extending MonoidHomClass₃ and instantiate it on RingHom and +then later on AlgebraHom (algebras are rings with some extra structure). But we’ve +covered the main formalization ideas used in Mathlib for morphisms and you should be ready +to understand how morphisms are defined in Mathlib.

+

As an exercise, you should try to define your class of bundled order-preserving function between +ordered types, and then order preserving monoid morphisms. This is for training purposes only. +Like continuous functions, order preserving functions are primarily unbundled in Mathlib where +they are defined by the Monotone predicate. Of course you need to complete the class +definitions below.

+
@[ext]
+structure OrderPresHom (α β : Type) [LE α] [LE β] where
+  toFun : α → β
+  le_of_le : ∀ a a', a ≤ a' → toFun a ≤ toFun a'
+
+@[ext]
+structure OrderPresMonoidHom (M N : Type) [Monoid M] [LE M] [Monoid N] [LE N] extends
+MonoidHom₁ M N, OrderPresHom M N
+
+class OrderPresHomClass (F : Type) (α β : outParam Type) [LE α] [LE β]
+
+instance (α β : Type) [LE α] [LE β] : OrderPresHomClass (OrderPresHom α β) α β where
+
+instance (α β : Type) [LE α] [Monoid α] [LE β] [Monoid β] :
+    OrderPresHomClass (OrderPresMonoidHom α β) α β where
+
+instance (α β : Type) [LE α] [Monoid α] [LE β] [Monoid β] :
+    MonoidHomClass₃ (OrderPresMonoidHom α β) α β
+  := sorry
+
+
+
+
+

8.3. Sub-objects

+

After defining some algebraic structure and its morphisms, the next step is to consider sets +that inherit this algebraic structure, for instance subgroups or subrings. +This largely overlaps with our previous topic. Indeed a set in X is implemented as a function from +X to Prop so sub-objects are function satisfying a certain predicate. +Hence we can reuse of lot of the ideas that led to the DFunLike class and its descendants. +We won’t reuse DFunLike itself because this would break the abstraction barrier from Set X +to X → Prop. Instead there is a SetLike class. Instead of wrapping an injection into a +function type, that class wraps an injection into a Set type and defines the corresponding +coercion and Membership instance.

+
@[ext]
+structure Submonoid₁ (M : Type) [Monoid M] where
+  /-- The carrier of a submonoid. -/
+  carrier : Set M
+  /-- The product of two elements of a submonoid belongs to the submonoid. -/
+  mul_mem {a b} : a ∈ carrier → b ∈ carrier → a * b ∈ carrier
+  /-- The unit element belongs to the submonoid. -/
+  one_mem : 1 ∈ carrier
+
+/-- Submonoids in `M` can be seen as sets in `M`. -/
+instance [Monoid M] : SetLike (Submonoid₁ M) M where
+  coe := Submonoid₁.carrier
+  coe_injective _ _ := Submonoid₁.ext
+
+
+

Equipped with the above SetLike instance, we can already state naturally that +a submonoid N contains 1 without using N.carrier. +We can also silently treat N as a set in M and take its direct image under a map.

+
example [Monoid M] (N : Submonoid₁ M) : 1 ∈ N := N.one_mem
+
+example [Monoid M] (N : Submonoid₁ M) (α : Type) (f : M → α) := f '' N
+
+
+

We also have a coercion to Type which uses Subtype so, given a submonoid N we can write +a parameter (x : N) which can be coerced to an element of M belonging to N.

+
example [Monoid M] (N : Submonoid₁ M) (x : N) : (x : M) ∈ N := x.property
+
+
+

We still need to tell Lean we want to equip Submonoid₁ M with the order relation coming +from Set M. This is done using the following instance. Then the example shows that the +partial order we defined is the expected one.

+
instance [Monoid M] : PartialOrder (Submonoid₁ M) := .ofSetLike (Submonoid₁ M) M
+
+example [Monoid M] (N P : Submonoid₁ M) : N ≤ P ↔ ∀ x, x ∈ N → x ∈ P := SetLike.le_def
+
+
+

Using this coercion to Type we can also tackle the task of equipping a submonoid with a +monoid structure. We will use the coercion from the type associated to N as above, and the +lemma SetCoe.ext asserting this coercion is injective. Both are provided by the SetLike +instance.

+
instance SubMonoid₁Monoid [Monoid M] (N : Submonoid₁ M) : Monoid N where
+  mul := fun x y ↦ ⟨x*y, N.mul_mem x.property y.property⟩
+  mul_assoc := fun x y z ↦ SetCoe.ext (mul_assoc (x : M) y z)
+  one := ⟨1, N.one_mem⟩
+  one_mul := fun x ↦ SetCoe.ext (one_mul (x : M))
+  mul_one := fun x ↦ SetCoe.ext (mul_one (x : M))
+
+
+

Note that, in the above instance, instead of using the coercion to M and calling the +property field, we could have used destructuring binders as follows.

+
example [Monoid M] (N : Submonoid₁ M) : Monoid N where
+  mul := fun ⟨x, hx⟩ ⟨y, hy⟩ ↦ ⟨x*y, N.mul_mem hx hy⟩
+  mul_assoc := fun ⟨x, _⟩ ⟨y, _⟩ ⟨z, _⟩ ↦ SetCoe.ext (mul_assoc x y z)
+  one := ⟨1, N.one_mem⟩
+  one_mul := fun ⟨x, _⟩ ↦ SetCoe.ext (one_mul x)
+  mul_one := fun ⟨x, _⟩ ↦ SetCoe.ext (mul_one x)
+
+
+

In order to apply lemmas about submonoids to subgroups or subrings, we need a class, just +like for morphisms. Note this class take a SetLike instance as a parameter so it does not need +a carrier field and can use the membership notation in its fields.

+
class SubmonoidClass₁ (S : Type) (M : Type) [Monoid M] [SetLike S M] : Prop where
+  mul_mem : ∀ (s : S) {a b : M}, a ∈ s → b ∈ s → a * b ∈ s
+  one_mem : ∀ s : S, 1 ∈ s
+
+instance [Monoid M] : SubmonoidClass₁ (Submonoid₁ M) M where
+  mul_mem := Submonoid₁.mul_mem
+  one_mem := Submonoid₁.one_mem
+
+
+

As an exercise you should define a Subgroup₁ structure, endow it with a SetLike instance +and a SubmonoidClass₁ instance, put a Group instance on the subtype associated to a +Subgroup₁ and define a SubgroupClass₁ class.

+

Another very important thing to know about subobjects of a given algebraic object in Mathlib +always form a complete lattice, and this structure is used a lot. For instance you may look for +the lemma saying that an intersection of submonoids is a submonoid. But this won’t be a lemma, +this will be an infimum construction. Let us do the case of two submonoids. Beware that the relevant +class is called Min, even in our example where the order is not total.

+
instance [Monoid M] : Min (Submonoid₁ M) :=
+  ⟨fun S₁ S₂ ↦
+    { carrier := S₁ ∩ S₂
+      one_mem := ⟨S₁.one_mem, S₂.one_mem⟩
+      mul_mem := fun ⟨hx, hx'⟩ ⟨hy, hy'⟩ ↦ ⟨S₁.mul_mem hx hy, S₂.mul_mem hx' hy'⟩ }⟩
+
+
+

This allows to get the intersections of two submonoids as a submonoid.

+
example [Monoid M] (N P : Submonoid₁ M) : Submonoid₁ M := N ⊓ P
+
+
+

You may think it’s a shame that we had to use the inf symbol ⊓ in the above example instead +of the intersection symbol ∩. But think about the supremum. The union of two submonoids is not +a submonoid. However submonoids still form a lattice (even a complete one). Actually N ⊔ P is +the submonoid generated by the union of N and P and of course it would be very confusing to +denote it by N ∪ P. So you can see the use of N ⊓ P as much more consistent. It is also +a lot more consistent across various kind of algebraic structures. It may look a bit weird at first +to see the sum of two vector subspace E and F denoted by E ⊔ F instead of E + F. +But you will get used to it. And soon you will consider the E + F notation as a distraction +emphasizing the anecdotal fact that elements of E ⊔ F can be written as a sum of an element of +E and an element of F instead of emphasizing the fundamental fact that E ⊔ F is the +smallest vector subspace containing both E and F.

+

Our last topic for this chapter is that of quotients. Again we want to explain how +convenient notation are built and code duplication is avoided in Mathlib. Here the main device +is the HasQuotient class which allows notations like M ⧸ N. Beware the quotient symbol +⧸ is a special unicode character, not a regular ASCII division symbol.

+

As an example, we will build the quotient of a commutative monoid by a submonoid, leave proofs +to you. In the last example, you can use Setoid.refl but it won’t automatically pick up +the relevant Setoid structure. You can fix this issue by providing all arguments using +the @ syntax, as in @Setoid.refl M N.Setoid.

+
def Submonoid.Setoid [CommMonoid M] (N : Submonoid M) : Setoid M  where
+  r := fun x y ↦ ∃ w ∈ N, ∃ z ∈ N, x*w = y*z
+  iseqv := {
+    refl := fun x ↦ ⟨1, N.one_mem, 1, N.one_mem, rfl⟩
+    symm := fun ⟨w, hw, z, hz, h⟩ ↦ ⟨z, hz, w, hw, h.symm⟩
+    trans := by
+      sorry
+  }
+
+instance [CommMonoid M] : HasQuotient M (Submonoid M) where
+  Quotient := fun N ↦ Quotient N.Setoid
+
+def QuotientMonoid.mk [CommMonoid M] (N : Submonoid M) : M → M ⧸ N := Quotient.mk N.Setoid
+
+instance [CommMonoid M] (N : Submonoid M) : Monoid (M ⧸ N) where
+  mul := Quotient.map₂ (· * ·) (by
+      sorry
+        )
+  mul_assoc := by
+      sorry
+  one := QuotientMonoid.mk N 1
+  one_mul := by
+      sorry
+  mul_one := by
+      sorry
+
+
+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C09_Groups_and_Rings.html b/dev/vendor/mathematics_in_lean/html/C09_Groups_and_Rings.html new file mode 100644 index 0000000..080f636 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C09_Groups_and_Rings.html @@ -0,0 +1,1150 @@ + + + + + + + + + 9. Groups and Rings — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

9. Groups and Rings

+

We saw in Section 2.2 how to reason about +operations in groups and rings. Later, in Section 7.2, we saw how +to define abstract algebraic structures, such as group structures, as well as concrete instances +such as the ring structure on the Gaussian integers. Chapter 8 explained how +hierarchies of abstract structures are handled in Mathlib.

+

In this chapter we work with groups and rings in more detail. We won’t be able to +cover every aspect of the treatment of these topics in Mathlib, especially since Mathlib is constantly growing. +But we will provide entry points to the library and show how the essential concepts are used. +There is some overlap with the discussion of +Chapter 8, but here we will focus on how to use Mathlib instead of the design +decisions behind the way the topics are treated. +So making sense of some of the examples may require reviewing the background from +Chapter 8.

+
+

9.1. Monoids and Groups

+
+

9.1.1. Monoids and their morphisms

+

Courses in abstract algebra often start with groups and +then progress to rings, fields, and vector spaces. This involves some contortions when discussing +multiplication on rings since the multiplication operation does not come from a group structure +but many of the proofs carry over verbatim from group theory to this new setting. +The most common fix, when doing mathematics with pen and paper, +is to leave those proofs as exercises. A less efficient but safer and +more formalization-friendly way of proceeding is to use monoids. A monoid structure on a type M +is an internal composition law that is associative and has a neutral element. +Monoids are used primarily to accommodate both groups and the multiplicative structure of +rings. But there are also a number of natural examples; for instance, the set of natural numbers +equipped with addition forms a monoid.

+

From a practical point of view, you can mostly ignore monoids when using Mathlib. But you need +to know they exist when you are looking for a lemma by browsing Mathlib files. Otherwise, you +might end up looking for a statement in the group theory files when it is actually found +with monoids because it does not require elements to be invertible.

+

The type of monoid structures on a type M is written Monoid M. +The function Monoid is a type class so it will almost always appear as an instance implicit +argument (in other words, in square brackets). +By default, Monoid uses multiplicative notation for the operation; for additive notation +use AddMonoid instead. +The commutative versions of these structures add the prefix Comm before Monoid.

+
example {M : Type*} [Monoid M] (x : M) : x * 1 = x := mul_one x
+
+example {M : Type*} [AddCommMonoid M] (x y : M) : x + y = y + x := add_comm x y
+
+
+

Note that although AddMonoid is found in the library, +it is generally confusing to use additive notation with a non-commutative operation.

+

The type of morphisms between monoids M and N is called MonoidHom M N and written +M →* N. Lean will automatically see such a morphism as a function from M to N when +we apply it to elements of M. The additive version is called AddMonoidHom and written +M →+ N.

+
example {M N : Type*} [Monoid M] [Monoid N] (x y : M) (f : M →* N) : f (x * y) = f x * f y :=
+  f.map_mul x y
+
+example {M N : Type*} [AddMonoid M] [AddMonoid N] (f : M →+ N) : f 0 = 0 :=
+  f.map_zero
+
+
+

These morphisms are bundled maps, i.e. they package together a map and some of its properties. +Remember that Section 8.2 explains bundled maps; +here we simply note the slightly unfortunate consequence that we cannot use ordinary function +composition to compose maps. Instead, we need to use MonoidHom.comp and AddMonoidHom.comp.

+
example {M N P : Type*} [AddMonoid M] [AddMonoid N] [AddMonoid P]
+    (f : M →+ N) (g : N →+ P) : M →+ P := g.comp f
+
+
+
+
+

9.1.2. Groups and their morphisms

+

We will have much more to say about groups, which are monoids with the extra +property that every element has an inverse.

+
example {G : Type*} [Group G] (x : G) : x * x⁻¹ = 1 := mul_inv_cancel x
+
+
+

Similar to the ring tactic that we saw earlier, there is a group tactic that proves +any identity that holds in any group. (Equivalently, it proves the identities that hold in +free groups.)

+
example {G : Type*} [Group G] (x y z : G) : x * (y * z) * (x * z)⁻¹ * (x * y * x⁻¹)⁻¹ = 1 := by
+  group
+
+
+

There is also a tactic for identities in commutative additive groups called abel.

+
example {G : Type*} [AddCommGroup G] (x y z : G) : z + x + (y - z - x) = y := by
+  abel
+
+
+

Interestingly, a group +morphism is nothing more than a monoid morphism between groups. So we can copy and paste one of our +earlier examples, replacing Monoid with Group.

+
example {G H : Type*} [Group G] [Group H] (x y : G) (f : G →* H) : f (x * y) = f x * f y :=
+  f.map_mul x y
+
+
+

Of course we do get some new properties, such as this one:

+
example {G H : Type*} [Group G] [Group H] (x : G) (f : G →* H) : f (x⁻¹) = (f x)⁻¹ :=
+  f.map_inv x
+
+
+

You may be worried that constructing group morphisms will require us to do unnecessary work since +the definition of monoid morphism enforces that neutral elements are sent to neutral elements +while this is automatic in the case of group morphisms. In practice the extra work is not hard, +but, to avoid it, there is a function building a group morphism from a function +between groups that is compatible with the composition laws.

+
example {G H : Type*} [Group G] [Group H] (f : G → H) (h : ∀ x y, f (x * y) = f x * f y) :
+    G →* H :=
+  MonoidHom.mk' f h
+
+
+

There is also a type MulEquiv of group (or monoid) isomorphisms denoted by ≃* (and +AddEquiv denoted by ≃+ in additive notation). +The inverse of f : G ≃* H is MulEquiv.symm f : H ≃* G, +composition of f and g is MulEquiv.trans f g, and +the identity isomorphism of G is M̀ulEquiv.refl G. +Using anonymous projector notation, the first two can be written f.symm and +f.trans g respectively. +Elements of this type are automatically coerced to morphisms and functions when necessary.

+
example {G H : Type*} [Group G] [Group H] (f : G ≃* H) :
+    f.trans f.symm = MulEquiv.refl G :=
+  f.self_trans_symm
+
+
+

One can use MulEquiv.ofBijective to build an isomorphism from a bijective morphism. +Doing so makes the inverse function noncomputable.

+
noncomputable example {G H : Type*} [Group G] [Group H]
+    (f : G →* H) (h : Function.Bijective f) :
+    G ≃* H :=
+  MulEquiv.ofBijective f h
+
+
+
+
+

9.1.3. Subgroups

+

Just as group morphisms are bundled, a subgroup of G is also a bundled structure consisting of +a set in G with the relevant closure properties.

+
example {G : Type*} [Group G] (H : Subgroup G) {x y : G} (hx : x ∈ H) (hy : y ∈ H) :
+    x * y ∈ H :=
+  H.mul_mem hx hy
+
+example {G : Type*} [Group G] (H : Subgroup G) {x : G} (hx : x ∈ H) :
+    x⁻¹ ∈ H :=
+  H.inv_mem hx
+
+
+

In the example above, it is important to understand that Subgroup G is the type of subgroups +of G, rather than a predicate IsSubgroup H where H is an element of Set G. +Subgroup G is endowed with a coercion to Set G and a membership predicate on G. +See Section 8.3 for an explanation of how and why this is done.

+

Of course, two subgroups are the same if and only if they have the same elements. This fact +is registered for use with the ext tactic, which can be used to prove two subgroups are +equal in the same way it is used to prove that two sets are equal.

+

To state and prove, for example, that ℤ is an additive subgroup of ℚ, +what we really want is to construct a term of type AddSubgroup ℚ whose projection to +Set ℚ is ℤ, or, more precisely, the image of ℤ in ℚ.

+
example : AddSubgroup ℚ where
+  carrier := Set.range ((↑) : ℤ → ℚ)
+  add_mem' := by
+    rintro _ _ ⟨n, rfl⟩ ⟨m, rfl⟩
+    use n + m
+    simp
+  zero_mem' := by
+    use 0
+    simp
+  neg_mem' := by
+    rintro _ ⟨n, rfl⟩
+    use -n
+    simp
+
+
+

Using type classes, Mathlib knows that a subgroup of a group inherits a group structure.

+
example {G : Type*} [Group G] (H : Subgroup G) : Group H := inferInstance
+
+
+

This example is subtle. The object H is not a type, but Lean automatically coerces it to +a type by interpreting it as a subtype of G. +So the above example can be restated more explicitly as:

+
example {G : Type*} [Group G] (H : Subgroup G) : Group {x : G // x ∈ H} := inferInstance
+
+
+

An important benefit of having a type Subgroup G instead of a predicate +IsSubgroup : Set G → Prop is that one can easily endow Subgroup G with additional structure. +Importantly, it has the structure of a complete lattice structure with respect to +inclusion. For instance, instead of having a lemma stating that an intersection of +two subgroups of G is again a subgroup, we +have used the lattice operation ⊓ to construct the intersection. We can then apply arbitrary +lemmas about lattices to the construction.

+

Let us check that the set underlying the infimum of two subgroups is indeed, by definition, +their intersection.

+
example {G : Type*} [Group G] (H H' : Subgroup G) :
+    ((H ⊓ H' : Subgroup G) : Set G) = (H : Set G) ∩ (H' : Set G) := rfl
+
+
+

It may look strange to have a different notation for what amounts to the intersection of the +underlying sets, but the correspondence does not carry over to the supremum operation and set +union, since a union of subgroups is not, in general, a subgroup. +Instead one needs to use the subgroup generated by the union, which is done +using Subgroup.closure.

+
example {G : Type*} [Group G] (H H' : Subgroup G) :
+    ((H ⊔ H' : Subgroup G) : Set G) = Subgroup.closure ((H : Set G) ∪ (H' : Set G)) := by
+  rw [Subgroup.sup_eq_closure]
+
+
+

Another subtlety is that G itself does not have type Subgroup G, +so we need a way to talk about G seen as a subgroup of G. +This is also provided by the lattice structure: the full subgroup is the top element of +this lattice.

+
example {G : Type*} [Group G] (x : G) : x ∈ (⊤ : Subgroup G) := trivial
+
+
+

Similarly the bottom element of this lattice is the subgroup whose only element is the +neutral element.

+
example {G : Type*} [Group G] (x : G) : x ∈ (⊥ : Subgroup G) ↔ x = 1 := Subgroup.mem_bot
+
+
+

As an exercise in manipulating groups and subgroups, you can define the conjugate of a subgroup +by an element of the ambient group.

+
def conjugate {G : Type*} [Group G] (x : G) (H : Subgroup G) : Subgroup G where
+  carrier := {a : G | ∃ h, h ∈ H ∧ a = x * h * x⁻¹}
+  one_mem' := by
+    dsimp
+    sorry
+  inv_mem' := by
+    dsimp
+    sorry
+  mul_mem' := by
+    dsimp
+    sorry
+
+
+

Tying the previous two topics together, one can push forward and pull back subgroups using +group morphisms. The naming convention in Mathlib is to call those operations map +and comap. +These are not the common mathematical terms, but they have the advantage of being +shorter than “pushforward” and “direct image.”

+
example {G H : Type*} [Group G] [Group H] (G' : Subgroup G) (f : G →* H) : Subgroup H :=
+  Subgroup.map f G'
+
+example {G H : Type*} [Group G] [Group H] (H' : Subgroup H) (f : G →* H) : Subgroup G :=
+  Subgroup.comap f H'
+
+#check Subgroup.mem_map
+#check Subgroup.mem_comap
+
+
+

In particular, the preimage of the bottom subgroup under a morphism f is a subgroup called +the kernel of f, and the range of f is also a subgroup.

+
example {G H : Type*} [Group G] [Group H] (f : G →* H) (g : G) :
+    g ∈ MonoidHom.ker f ↔ f g = 1 :=
+  f.mem_ker
+
+example {G H : Type*} [Group G] [Group H] (f : G →* H) (h : H) :
+    h ∈ MonoidHom.range f ↔ ∃ g : G, f g = h :=
+  f.mem_range
+
+
+

As exercises in manipulating group morphisms and subgroups, let us prove some elementary properties. +They are already proved in Mathlib, so do not use exact? too quickly if you want to benefit +from these exercises.

+
section exercises
+variable {G H : Type*} [Group G] [Group H]
+
+open Subgroup
+
+example (φ : G →* H) (S T : Subgroup H) (hST : S ≤ T) : comap φ S ≤ comap φ T := by
+  sorry
+
+example (φ : G →* H) (S T : Subgroup G) (hST : S ≤ T) : map φ S ≤ map φ T := by
+  sorry
+
+variable {K : Type*} [Group K]
+
+-- Remember you can use the `ext` tactic to prove an equality of subgroups.
+example (φ : G →* H) (ψ : H →* K) (U : Subgroup K) :
+    comap (ψ.comp φ) U = comap φ (comap ψ U) := by
+  sorry
+
+-- Pushing a subgroup along one homomorphism and then another is equal to
+-- pushing it forward along the composite of the homomorphisms.
+example (φ : G →* H) (ψ : H →* K) (S : Subgroup G) :
+    map (ψ.comp φ) S = map ψ (S.map φ) := by
+  sorry
+
+end exercises
+
+
+

Let us finish this introduction to subgroups in Mathlib with two very classical results. +Lagrange theorem states the cardinality of a subgroup of a finite group divides the cardinality of +the group. Sylow’s first theorem is a famous partial converse to Lagrange’s theorem.

+

While this corner of Mathlib is partly set up to allow computation, we can tell +Lean to use nonconstructive logic anyway using the following open scoped command.

+
open scoped Classical
+
+
+example {G : Type*} [Group G] (G' : Subgroup G) : Nat.card G' ∣ Nat.card G :=
+  ⟨G'.index, mul_comm G'.index _ ▸ G'.index_mul_card.symm⟩
+
+open Subgroup
+
+example {G : Type*} [Group G] [Finite G] (p : ℕ) {n : ℕ} [Fact p.Prime]
+    (hdvd : p ^ n ∣ Nat.card G) : ∃ K : Subgroup G, Nat.card K = p ^ n :=
+  Sylow.exists_subgroup_card_pow_prime p hdvd
+
+
+

The next two exercises derive a corollary of Lagrange’s lemma. (This is also already in Mathlib, +so do not use exact? too quickly.)

+
lemma eq_bot_iff_card {G : Type*} [Group G] {H : Subgroup G} :
+    H = ⊥ ↔ Nat.card H = 1 := by
+  suffices (∀ x ∈ H, x = 1) ↔ ∃ x ∈ H, ∀ a ∈ H, a = x by
+    simpa [eq_bot_iff_forall, Nat.card_eq_one_iff_exists]
+  sorry
+
+#check card_dvd_of_le
+
+lemma inf_bot_of_coprime {G : Type*} [Group G] (H K : Subgroup G)
+    (h : (Nat.card H).Coprime (Nat.card K)) : H ⊓ K = ⊥ := by
+  sorry
+
+
+
+
+

9.1.4. Concrete groups

+

One can also manipulate concrete groups in Mathlib, although this is typically more complicated +than working with the abstract theory. +For instance, given any type X, the group of permutations of X is Equiv.Perm X. +In particular the symmetric group \(\mathfrak{S}_n\) is Equiv.Perm (Fin n). +One can state abstract results about this group, for instance saying that Equiv.Perm X is +generated by cycles if X is finite.

+
open Equiv
+
+example {X : Type*} [Finite X] : Subgroup.closure {σ : Perm X | Perm.IsCycle σ} = ⊤ :=
+  Perm.closure_isCycle
+
+
+

One can be fully concrete and compute actual products of cycles. Below we use the #simp command, +which calls the simp tactic on a given expression. The notation c[] is used to define a +cyclic permutation. In the example, the result is a permutation of ℕ. One could use a type +ascription such as (1 : Fin 5) on the first number appearing to make it a computation in +Perm (Fin 5).

+
#simp [mul_assoc] c[1, 2, 3] * c[2, 3, 4]
+
+
+

Another way to work with concrete groups is to use free groups and group presentations. +The free group on a type α is FreeGroup α and the inclusion map is +FreeGroup.of : α → FreeGroup α. For instance let us define a type S with three elements denoted +by a, b and c, and the element ab⁻¹ of the corresponding free group.

+
section FreeGroup
+
+inductive S | a | b | c
+
+open S
+
+def myElement : FreeGroup S := (.of a) * (.of b)⁻¹
+
+
+

Note that we gave the expected type of the definition so that Lean knows that .of means +FreeGroup.of.

+

The universal property of free groups is embodied as the equivalence FreeGroup.lift. +For example, let us define the group morphism from FreeGroup S to Perm (Fin 5) that +sends a to c[1, 2, 3], b to c[2, 3, 1], and c to c[2, 3],

+
def myMorphism : FreeGroup S →* Perm (Fin 5) :=
+  FreeGroup.lift fun | .a => c[1, 2, 3]
+                     | .b => c[2, 3, 1]
+                     | .c => c[2, 3]
+
+
+

As a last concrete example, let us see how to define a group generated by a single element whose +cube is one (so that group will be isomorphic to \(\mathbb{Z}/3\)) and build a morphism +from that group to Perm (Fin 5).

+

As a type with exactly one element, we will use Unit whose +only element is denoted by (). The function PresentedGroup takes a set of relations, +i.e. a set of elements of some free group, and returns a group that is this free group quotiented +by a normal subgroup generated by relations. (We will see how to handle more general quotients +in Section 9.1.6.) Since we somehow hide this behind a definition, we use deriving Group to force creation +of a group instance on myGroup.

+
def myGroup := PresentedGroup {.of () ^ 3} deriving Group
+
+
+

The universal property of presented groups ensures that morphisms out of this group can be built +from functions that send the relations to the neutral element of the target group. +So we need such a function and a proof that the condition holds. Then we can feed this proof +to PresentedGroup.toGroup to get the desired group morphism.

+
def myMap : Unit → Perm (Fin 5)
+| () => c[1, 2, 3]
+
+lemma compat_myMap :
+    ∀ r ∈ ({.of () ^ 3} : Set (FreeGroup Unit)), FreeGroup.lift myMap r = 1 := by
+  rintro _ rfl
+  simp
+  decide
+
+def myNewMorphism : myGroup →* Perm (Fin 5) := PresentedGroup.toGroup compat_myMap
+
+end FreeGroup
+
+
+
+
+

9.1.5. Group actions

+

One important way that group theory interacts with the rest of mathematics is through +the use of group actions. +An action of a group G on some type X is nothing more than a morphism from G to +Equiv.Perm X. So in a sense group actions are already covered by the previous discussion. +But we don’t want to carry this morphism around; instead, we want it to be inferred automatically +by Lean as much as possible. So we have a type class for this, which is MulAction G X. +The downside of this setup is that having multiple actions of the same group on the same type +requires some contortions, such as defining type synonyms, each of which carries different +type class instances.

+

This allows us in particular to use g • x to denote the action of a group element g on +a point x.

+
noncomputable section GroupActions
+
+example {G X : Type*} [Group G] [MulAction G X] (g g': G) (x : X) :
+    g • (g' • x) = (g * g') • x :=
+  (mul_smul g g' x).symm
+
+
+

There is also a version for additive group called AddAction, where the action is denoted by ++ᵥ. This is used for instance in the definition of affine spaces.

+
example {G X : Type*} [AddGroup G] [AddAction G X] (g g' : G) (x : X) :
+    g +ᵥ (g' +ᵥ x) = (g + g') +ᵥ x :=
+  (add_vadd g g' x).symm
+
+
+

The underlying group morphism is called MulAction.toPermHom.

+
open MulAction
+
+example {G X : Type*} [Group G] [MulAction G X] : G →* Equiv.Perm X :=
+  toPermHom G X
+
+
+

As an illustration let us see how to define the Cayley isomorphism embedding of any group G into +a permutation group, namely Perm G. To instantiate [MulAction G G], Lean finds +the standard group action given by left multiplication, which is what we want.

+
def CayleyIsoMorphism (G : Type*) [Group G] : G ≃* (toPermHom G G).range :=
+  Equiv.Perm.subgroupOfMulAction G G
+
+
+

Note that nothing before the above definition required having a group rather than a monoid (or any +type endowed with a multiplication operation really).

+

The group condition really enters the picture when we will want to partition X into orbits. +The corresponding equivalence relation on X is called MulAction.orbitRel. +It is not declared as a global instance.

+
example {G X : Type*} [Group G] [MulAction G X] : Setoid X := orbitRel G X
+
+
+

Using this we can state that X is partitioned into orbits under the action of G. +More precisely, we get a bijection between X and the dependent product +(ω : orbitRel.Quotient G X) × (orbit G (Quotient.out' ω)) +where Quotient.out' ω simply chooses an element that projects to ω. +Recall that elements of this dependent product are pairs ⟨ω, x⟩ where the type +orbit G (Quotient.out' ω) of x depends on ω.

+
example {G X : Type*} [Group G] [MulAction G X] :
+    X ≃ (ω : orbitRel.Quotient G X) × (orbit G (Quotient.out ω)) :=
+  MulAction.selfEquivSigmaOrbits G X
+
+
+

In particular, when X is finite, this can be combined with Fintype.card_congr and +Fintype.card_sigma to deduce that the cardinality of X is the sum of the cardinalities +of the orbits. +Furthermore, the orbits are in bijection with the quotient of G under the action of the +stabilizers by left translation. +This action of a subgroup by left-translation is used to define quotients of a group by a +subgroup with notation / so we can use the following concise statement.

+
example {G X : Type*} [Group G] [MulAction G X] (x : X) :
+    orbit G x ≃ G ⧸ stabilizer G x :=
+  MulAction.orbitEquivQuotientStabilizer G x
+
+
+

An important special case of combining the above two results is when X is a group G +equipped with the action of a subgroup H by translation. +In this case all stabilizers are trivial so every orbit is in bijection with H and we get:

+
example {G : Type*} [Group G] (H : Subgroup G) : G ≃ (G ⧸ H) × H :=
+  groupEquivQuotientProdSubgroup
+
+
+

This is the conceptual variant of the version of Lagrange theorem that we saw above. +Note this version makes no finiteness assumption.

+

As an exercise for this section, let us build the action of a group on its subgroup by +conjugation, using our definition of conjugate from a previous exercise.

+
variable {G : Type*} [Group G]
+
+lemma conjugate_one (H : Subgroup G) : conjugate 1 H = H := by
+  sorry
+
+instance : MulAction G (Subgroup G) where
+  smul := conjugate
+  one_smul := by
+    sorry
+  mul_smul := by
+    sorry
+
+end GroupActions
+
+
+
+
+

9.1.6. Quotient groups

+

In the above discussion of subgroups acting on groups, we saw the quotient G ⧸ H appear. +In general this is only a type. It can be endowed with a group structure such that the quotient +map is a group morphism if and only if H is a normal subgroup (and this group structure is +then unique).

+

The normality assumption is a type class Subgroup.Normal so that type class inference can use it +to derive the group structure on the quotient.

+
noncomputable section QuotientGroup
+
+example {G : Type*} [Group G] (H : Subgroup G) [H.Normal] : Group (G ⧸ H) := inferInstance
+
+example {G : Type*} [Group G] (H : Subgroup G) [H.Normal] : G →* G ⧸ H :=
+  QuotientGroup.mk' H
+
+
+

The universal property of quotient groups is accessed through QuotientGroup.lift: +a group morphism φ descends to G ⧸ N as soon as its kernel contains N.

+
example {G : Type*} [Group G] (N : Subgroup G) [N.Normal] {M : Type*}
+    [Group M] (φ : G →* M) (h : N ≤ MonoidHom.ker φ) : G ⧸ N →* M :=
+  QuotientGroup.lift N φ h
+
+
+

The fact that the target group is called M is the above snippet is a clue that having a +monoid structure on M would be enough.

+

An important special case is when N = ker φ. In that case the descended morphism is +injective and we get a group isomorphism onto its image. This result is often called +the first isomorphism theorem.

+
example {G : Type*} [Group G] {M : Type*} [Group M] (φ : G →* M) :
+    G ⧸ MonoidHom.ker φ →* MonoidHom.range φ :=
+  QuotientGroup.quotientKerEquivRange φ
+
+
+

Applying the universal property to a composition of a morphism φ : G →* G' +with a quotient group projection Quotient.mk' N', +we can also aim for a morphism from G ⧸ N to G' ⧸ N'. +The condition required on φ is usually formulated by saying “φ should send N inside +N'.” But this is equivalent to asking that φ should pull N' back over +N, and the latter condition is nicer to work with since the definition of pullback does not +involve an existential quantifier.

+
example {G G': Type*} [Group G] [Group G']
+    {N : Subgroup G} [N.Normal] {N' : Subgroup G'} [N'.Normal]
+    {φ : G →* G'} (h : N ≤ Subgroup.comap φ N') : G ⧸ N →* G' ⧸ N':=
+  QuotientGroup.map N N' φ h
+
+
+

One subtle point to keep in mind is that the type G ⧸ N really depends on N +(up to definitional equality), so having a proof that two normal subgroups N and M are equal +is not enough to make the corresponding quotient types definitionally equal. +However, the universal properties do give an isomorphism in this case.

+
example {G : Type*} [Group G] {M N : Subgroup G} [M.Normal]
+    [N.Normal] (h : M = N) : G ⧸ M ≃* G ⧸ N := QuotientGroup.quotientMulEquivOfEq h
+
+
+

As a final series of exercises for this section, we will prove that if H and K are disjoint +normal subgroups of a finite group G such that the product of their cardinalities is equal to +the cardinality of G +then G is isomorphic to H × K. Recall that disjoint in this context means H ⊓ K = ⊥.

+

We start with playing a bit with Lagrange’s lemma, without assuming the subgroups are normal +or disjoint.

+
section
+variable {G : Type*} [Group G] {H K : Subgroup G}
+
+open MonoidHom
+
+#check Nat.card_pos -- The nonempty argument will be automatically inferred for subgroups
+#check Subgroup.index_eq_card
+#check Subgroup.index_mul_card
+#check Nat.eq_of_mul_eq_mul_right
+
+lemma aux_card_eq [Finite G] (h' : Nat.card G = Nat.card H * Nat.card K) :
+    Nat.card (G ⧸ H) = Nat.card K := by
+  sorry
+
+
+

From now on, we assume that our subgroups are normal and disjoint, and we assume the cardinality +condition. Now we construct the first building block of the desired isomorphism.

+
variable [H.Normal] [K.Normal] [Fintype G] (h : Disjoint H K)
+  (h' : Nat.card G = Nat.card H * Nat.card K)
+
+#check Nat.bijective_iff_injective_and_card
+#check ker_eq_bot_iff
+#check domRestrict
+#check ker_domRestrict
+
+def iso₁ : K ≃* G ⧸ H := by
+  sorry
+
+
+

Now we can define our second building block. +We will need MonoidHom.prod, which builds a morphism from G₀ to G₁ × G₂ out of +morphisms from G₀ to G₁ and G₂.

+
def iso₂ : G ≃* (G ⧸ K) × (G ⧸ H) := by
+  sorry
+
+
+

We are ready to put all pieces together.

+
#check MulEquiv.prodCongr
+
+def finalIso : G ≃* H × K :=
+  sorry
+
+
+
+
+
+

9.2. Rings

+
+

9.2.1. Rings, their units, morphisms and subrings

+

The type of ring structures on a type R is Ring R. The variant where multiplication is +assumed to be commutative is CommRing R. We have already seen that the ring tactic will +prove any equality that follows from the axioms of a commutative ring.

+
example {R : Type*} [CommRing R] (x y : R) : (x + y) ^ 2 = x ^ 2 + y ^ 2 + 2 * x * y := by ring
+
+
+

More exotic variants do not require that the addition on R forms a group but only an additive +monoid. The corresponding type classes are Semiring R and CommSemiring R. +The type of natural numbers is an important instance of CommSemiring R, as is any type +of functions taking values in the natural numbers. +Another important example is the type of ideals in a ring, which will be discussed below. +The name of the ring tactic is doubly misleading, since it assumes commutativity but works +in semirings as well. In other words, it applies to any CommSemiring.

+
example (x y : ℕ) : (x + y) ^ 2 = x ^ 2 + y ^ 2 + 2 * x * y := by ring
+
+
+

There are also versions of the ring and semiring classes that do not assume the existence of a +multiplicative unit or +the associativity of multiplication. We will not discuss those here.

+

Some concepts that are traditionally taught in an introduction to ring theory are actually about +the underlying multiplicative monoid. +A prominent example is the definition of the units of a ring. Every (multiplicative) monoid M +has a predicate IsUnit : M → Prop asserting existence of a two-sided inverse, a +type Units M of units with notation Mˣ, and a coercion to M. +The type Units M bundles an invertible element with its inverse as well as properties than ensure +that each is indeed the inverse of the other. +This implementation detail is relevant mainly when defining computable functions. In most +situations one can use IsUnit.unit {x : M} : IsUnit x → Mˣ to build a unit. +In the commutative case, one also has Units.mkOfMulEqOne (x y : M) : x * y = 1 → Mˣ +which builds x seen as unit.

+
example (x : ℤˣ) : x = 1 ∨ x = -1 := Int.units_eq_one_or x
+
+example {M : Type*} [Monoid M] (x : Mˣ) : (x : M) * x⁻¹ = 1 := Units.mul_inv x
+
+example {M : Type*} [Monoid M] : Group Mˣ := inferInstance
+
+
+

The type of ring morphisms between two (semi)-rings R and S is RingHom R S, +with notation R →+* S.

+
example {R S : Type*} [Ring R] [Ring S] (f : R →+* S) (x y : R) :
+    f (x + y) = f x + f y := f.map_add x y
+
+example {R S : Type*} [Ring R] [Ring S] (f : R →+* S) : Rˣ →* Sˣ :=
+  Units.map f
+
+
+

The isomorphism variant is RingEquiv, with notation ≃+*.

+

As with submonoids and subgroups, there is a Subring R type for subrings of a ring R, +but this type is a lot less useful than the type of subgroups since one cannot quotient a ring by +a subring.

+
example {R : Type*} [Ring R] (S : Subring R) : Ring S := inferInstance
+
+
+

Also notice that RingHom.range produces a subring.

+
+
+

9.2.2. Ideals and quotients

+

For historical reasons, Mathlib only has a theory of ideals for commutative rings. +(The ring library was originally developed to make quick progress toward the foundations of modern +algebraic geometry.) So in this section we will work with commutative (semi)rings. +Ideals of R are defined as submodules of R seen as R-modules. Modules will +be covered later in a chapter on linear algebra, but this implementation detail can mostly be +safely ignored since most (but not all) relevant lemmas are restated in the special context of +ideals. But anonymous projection notation won’t always work as expected. For instance, +one cannot replace Ideal.Quotient.mk I by I.Quotient.mk in the snippet below because there +are two .s and so it will parse as (Ideal.Quotient I).mk; but Ideal.Quotient by itself +doesn’t exist.

+
example {R : Type*} [CommRing R] (I : Ideal R) : R →+* R ⧸ I :=
+  Ideal.Quotient.mk I
+
+example {R : Type*} [CommRing R] {a : R} {I : Ideal R} :
+    Ideal.Quotient.mk I a = 0 ↔ a ∈ I :=
+  Ideal.Quotient.eq_zero_iff_mem
+
+
+

The universal property of quotient rings is Ideal.Quotient.lift.

+
example {R S : Type*} [CommRing R] [CommRing S] (I : Ideal R) (f : R →+* S)
+    (H : I ≤ RingHom.ker f) : R ⧸ I →+* S :=
+  Ideal.Quotient.lift I f H
+
+
+

In particular it leads to the first isomorphism theorem for rings.

+
example {R S : Type*} [CommRing R] [CommRing S](f : R →+* S) :
+    R ⧸ RingHom.ker f ≃+* f.range :=
+  RingHom.quotientKerEquivRange f
+
+
+

Ideals form a complete lattice structure with the inclusion relation, as well as a semiring +structure. These two structures interact nicely.

+
variable {R : Type*} [CommRing R] {I J : Ideal R}
+
+example : I + J = I ⊔ J := rfl
+
+example {x : R} : x ∈ I + J ↔ ∃ a ∈ I, ∃ b ∈ J, a + b = x := by
+  simp [Submodule.mem_sup]
+
+example : I * J ≤ J := Ideal.mul_le_right
+
+example : I * J ≤ I := Ideal.mul_le_left
+
+example : I * J ≤ I ⊓ J := Ideal.mul_le_inf
+
+
+

One can use ring morphisms to push ideals forward and pull them back using Ideal.map and +Ideal.comap, respectively. As usual, +the latter is more convenient to use since it does not involve an existential quantifier. +This explains why it is used to state the condition that allows us to build morphisms between +quotient rings.

+
example {R S : Type*} [CommRing R] [CommRing S] (I : Ideal R) (J : Ideal S) (f : R →+* S)
+    (H : I ≤ Ideal.comap f J) : R ⧸ I →+* S ⧸ J :=
+  Ideal.quotientMap J f H
+
+
+

One subtle point is that the type R ⧸ I really depends on I +(up to definitional equality), so having a proof that two ideals I and J are equal is not +enough to make the corresponding quotient types definitionally equal. +However, the universal properties do provide an isomorphism in this case.

+
example {R : Type*} [CommRing R] {I J : Ideal R} (h : I = J) : R ⧸ I ≃+* R ⧸ J :=
+  Ideal.quotEquivOfEq h
+
+
+

We can now present the Chinese remainder isomorphism as an example. Pay attention to the difference +between the indexed infimum symbol ⨅ and the big product of types symbol Π. Depending on +your font, those can be pretty hard to distinguish.

+
example {R : Type*} [CommRing R] {ι : Type*} [Fintype ι] (f : ι → Ideal R)
+    (hf : ∀ i j, i ≠ j → IsCoprime (f i) (f j)) : (R ⧸ ⨅ i, f i) ≃+* Π i, R ⧸ f i :=
+  Ideal.quotientInfRingEquivPiQuotient f hf
+
+
+

The elementary version of the Chinese remainder theorem, a statement about ZMod, can be easily +deduced from the previous one:

+
open BigOperators PiNotation
+
+example {ι : Type*} [Fintype ι] (a : ι → ℕ) (coprime : ∀ i j, i ≠ j → (a i).Coprime (a j)) :
+    ZMod (∏ i, a i) ≃+* Π i, ZMod (a i) :=
+  ZMod.prodEquivPi a coprime
+
+
+

As a series of exercises, we will reprove the Chinese remainder theorem in the general case.

+

We first need to define the map appearing in the theorem, as a ring morphism, using the +universal property of quotient rings.

+
variable {ι R : Type*} [CommRing R]
+open Ideal Quotient Function
+
+#check RingHom.pi
+#check ker_Pi_Quotient_mk
+
+/-- The homomorphism from ``R ⧸ ⨅ i, I i`` to ``Π i, R ⧸ I i`` featured in the Chinese
+  Remainder Theorem. -/
+def chineseMap (I : ι → Ideal R) : (R ⧸ ⨅ i, I i) →+* Π i, R ⧸ I i :=
+  sorry
+
+
+

Make sure the following next two lemmas can be proven by rfl.

+
lemma chineseMap_mk (I : ι → Ideal R) (x : R) :
+    chineseMap I (Quotient.mk _ x) = fun i : ι ↦ Ideal.Quotient.mk (I i) x :=
+  sorry
+
+lemma chineseMap_mk' (I : ι → Ideal R) (x : R) (i : ι) :
+    chineseMap I (mk _ x) i = mk (I i) x :=
+  sorry
+
+
+

The next lemma proves the easy half of the Chinese remainder theorem, without any assumption on +the family of ideals. The proof is less than one line long.

+
#check injective_lift_iff
+
+lemma chineseMap_inj (I : ι → Ideal R) : Injective (chineseMap I) := by
+  sorry
+
+
+

We are now ready for the heart of the theorem, which will show the surjectivity +of our chineseMap. First we need to know the different ways one can express the coprimality +(also called co-maximality assumption). Only the first two will be needed below.

+
#check IsCoprime
+#check isCoprime_iff_add
+#check isCoprime_iff_exists
+#check isCoprime_iff_sup_eq
+#check isCoprime_iff_codisjoint
+
+
+

We take the opportunity to use induction on Finset. Relevant lemmas on Finset are given +below. +Remember that the ring tactic works for semirings and that the ideals of a ring form a semiring.

+
#check Finset.mem_insert_of_mem
+#check Finset.mem_insert_self
+
+theorem isCoprime_Inf {I : Ideal R} {J : ι → Ideal R} {s : Finset ι}
+    (hf : ∀ j ∈ s, IsCoprime I (J j)) : IsCoprime I (⨅ j ∈ s, J j) := by
+  classical
+  simp_rw [isCoprime_iff_add] at *
+  induction s using Finset.induction with
+  | empty =>
+      simp
+  | @insert i s _ hs =>
+      rw [Finset.iInf_insert, inf_comm, one_eq_top, eq_top_iff, ← one_eq_top]
+      set K := ⨅ j ∈ s, J j
+      calc
+        1 = I + K                  := sorry
+        _ = I + K * (I + J i)      := sorry
+        _ = (1 + K) * I + K * J i  := sorry
+        _ ≤ I + K ⊓ J i            := sorry
+
+
+

We can now prove surjectivity of the map appearing in the Chinese remainder theorem.

+
lemma chineseMap_surj [Fintype ι] {I : ι → Ideal R}
+    (hI : ∀ i j, i ≠ j → IsCoprime (I i) (I j)) : Surjective (chineseMap I) := by
+  classical
+  intro g
+  choose f hf using fun i ↦ Ideal.Quotient.mk_surjective (g i)
+  have key : ∀ i, ∃ e : R, mk (I i) e = 1 ∧ ∀ j, j ≠ i → mk (I j) e = 0 := by
+    intro i
+    have hI' : ∀ j ∈ ({i} : Finset ι)ᶜ, IsCoprime (I i) (I j) := by
+      sorry
+    sorry
+  choose e he using key
+  use mk _ (∑ i, f i * e i)
+  sorry
+
+
+

Now all the pieces come together in the following:

+
noncomputable def chineseIso [Fintype ι] (f : ι → Ideal R)
+    (hf : ∀ i j, i ≠ j → IsCoprime (f i) (f j)) : (R ⧸ ⨅ i, f i) ≃+* Π i, R ⧸ f i :=
+  { Equiv.ofBijective _ ⟨chineseMap_inj f, chineseMap_surj hf⟩,
+    chineseMap f with }
+
+
+
+
+

9.2.3. Algebras and polynomials

+

Given a commutative (semi)ring R, an algebra over R is a semiring A equipped +with a ring morphism from R to A whose image commutes with every element of A. +This is encoded as a type class Algebra R A. +The morphism from R to A is called the structure map and is denoted +algebraMap R A : R →+* A in Lean. +Multiplication of a : A by algebraMap R A r for some r : R is called the scalar +multiplication of a by r and denoted by r • a. +Note that this notion of algebra is sometimes called an associative unital algebra to emphasize the +existence of more general notions of algebra.

+

The fact that algebraMap R A is ring morphism packages together a lot of properties of scalar +multiplication, such as the following:

+
example {R A : Type*} [CommRing R] [Ring A] [Algebra R A] (r r' : R) (a : A) :
+    (r + r') • a = r • a + r' • a :=
+  add_smul r r' a
+
+example {R A : Type*} [CommRing R] [Ring A] [Algebra R A] (r r' : R) (a : A) :
+    (r * r') • a = r • r' • a :=
+  mul_smul r r' a
+
+
+

The morphisms between two R-algebras A and B are ring morphisms +which commute with scalar multiplication by elements of R. They are bundled morphisms +with type AlgHom R A B, which is denoted by A →ₐ[R] B.

+

Important examples of non-commutative algebras include algebras of endomorphisms and +algebras of square matrices, both of which will be covered in the chapter on linear algebra. +In this chapter we will discuss one of the most important examples of a commutative algebra, +namely, polynomial algebras.

+

The algebra of univariate polynomials with coefficients in R is called Polynomial R, +which can be written as R[X] as soon as one opens the Polynomial namespace. +The algebra structure map from R to R[X] is denoted by C, +which stands for “constant” since the corresponding +polynomial functions are always constant. The indeterminate is denoted by X.

+
open Polynomial
+
+example {R : Type*} [CommRing R] : R[X] := X
+
+example {R : Type*} [CommRing R] (r : R) := X - C r
+
+
+

In the first example above, it is crucial that we give Lean the expected type since it cannot be +determined from the body of the definition. In the second example, the target polynomial +algebra can be inferred from our use of C r since the type of r is known.

+

Because C is a ring morphism from R to R[X], we can use all ring morphisms lemmas +such as map_zero, map_one, map_mul, and map_pow before computing in the ring +R[X]. For example:

+
example {R : Type*} [CommRing R] (r : R) : (X + C r) * (X - C r) = X ^ 2 - C (r ^ 2) := by
+  rw [C.map_pow]
+  ring
+
+
+

You can access coefficients using Polynomial.coeff

+
example {R : Type*} [CommRing R] (r:R) : (C r).coeff 0 = r := by simp
+
+example {R : Type*} [CommRing R] : (X ^ 2 + 2 * X + C 3 : R[X]).coeff 1 = 2 := by simp
+
+
+

Defining the degree of a polynomial is always tricky because of the special case of the zero +polynomial. Mathlib has two variants: Polynomial.natDegree : R[X] → ℕ assigns degree +0 to the zero polynomial, and Polynomial.degree : R[X] → WithBot ℕ assigns ⊥. +In the latter, WithBot ℕ can be seen as ℕ ∪ {-∞}, except that -∞ is denoted ⊥, +the same symbol as the bottom element in a complete lattice. This special value is used as the +degree of the zero polynomial, and it is absorbent for addition. (It is almost absorbent for +multiplication, except that ⊥ * 0 = 0.)

+

Morally speaking, the degree version is the correct one. For instance, it allows us to state +the expected formula for the degree of a product (assuming the base ring has no zero divisor).

+
example {R : Type*} [Semiring R] [NoZeroDivisors R] {p q : R[X]} :
+    degree (p * q) = degree p + degree q :=
+  Polynomial.degree_mul
+
+
+

Whereas the version for natDegree needs to assume non-zero polynomials.

+
example {R : Type*} [Semiring R] [NoZeroDivisors R] {p q : R[X]} (hp : p ≠ 0) (hq : q ≠ 0) :
+    natDegree (p * q) = natDegree p + natDegree q :=
+  Polynomial.natDegree_mul hp hq
+
+
+

However, ℕ is much nicer to use than WithBot ℕ, so Mathlib makes both versions available +and provides lemmas to convert between them. Also, natDegree is the more convenient definition +to use when computing the degree of a composition. Composition of polynomial is Polynomial.comp +and we have:

+
example {R : Type*} [Semiring R] [NoZeroDivisors R] {p q : R[X]} :
+    natDegree (comp p q) = natDegree p * natDegree q :=
+  Polynomial.natDegree_comp
+
+
+

Polynomials give rise to polynomial functions: any polynomial can be evaluated on R +using Polynomial.eval.

+
example {R : Type*} [CommRing R] (P: R[X]) (x : R) := P.eval x
+
+example {R : Type*} [CommRing R] (r : R) : (X - C r).eval r = 0 := by simp
+
+
+

In particular, there is a predicate, IsRoot, that holds for elements r in R where a +polynomial vanishes.

+
example {R : Type*} [CommRing R] (P : R[X]) (r : R) : IsRoot P r ↔ P.eval r = 0 := Iff.rfl
+
+
+

We would like to say that, assuming R has no zero divisor, a polynomial has at most as many +roots as its degree, where the roots are counted with multiplicities. +But once again the case of the zero polynomial is painful. +So Mathlib defines Polynomial.roots to send a polynomial P to a multiset, +i.e. the finite set that is defined to be empty if P is zero and the roots of P, +with multiplicities, otherwise. This is defined only when the underlying ring is a domain +since otherwise the definition does not have good properties.

+
example {R : Type*} [CommRing R] [IsDomain R] (r : R) : (X - C r).roots = {r} :=
+  roots_X_sub_C r
+
+example {R : Type*} [CommRing R] [IsDomain R] (r : R) (n : ℕ):
+    ((X - C r) ^ n).roots = n • {r} :=
+  by simp
+
+
+

Both Polynomial.eval and Polynomial.roots consider only the coefficient ring. They do not +allow us to say that X ^ 2 - 2 : ℚ[X] has a root in ℝ or that X ^ 2 + 1 : ℝ[X] has a root in +ℂ. For this, we need Polynomial.aeval, which will evaluate P : R[X] in any R-algebra. +More precisely, given a semiring A and an instance of Algebra R A, Polynomial.aeval sends +every element a : A to the R-algebra morphism R[X] → A that evaluates X at a. Since AlgHom +has a coercion to functions, one can apply it to a polynomial. +But aeval does not have a polynomial as an argument, so one cannot use dot notation like in +P.eval above.

+
example : aeval Complex.I (X ^ 2 + 1 : ℝ[X]) = 0 := by simp
+
+
+

The function corresponding to roots in this context is aroots which takes a polynomial +and then an algebra and outputs a multiset (with the same caveat about the zero polynomial as +for roots).

+
open Complex Polynomial
+
+example : aroots (X ^ 2 + 1 : ℝ[X]) ℂ = {Complex.I, -I} := by
+  suffices roots (X ^ 2 + 1 : ℂ[X]) = {I, -I} by simpa [aroots_def]
+  have factored : (X ^ 2 + 1 : ℂ[X]) = (X - C I) * (X - C (-I)) := by
+    have key : (C I * C I : ℂ[X]) = -1 := by simp [← C_mul]
+    rw [C_neg]
+    linear_combination key
+  have p_ne_zero : (X - C I) * (X - C (-I)) ≠ 0 := by
+    intro H
+    apply_fun eval 0 at H
+    simp [eval] at H
+  simp only [factored, roots_mul p_ne_zero, roots_X_sub_C]
+  rfl
+
+-- Mathlib knows about D'Alembert-Gauss theorem: ``ℂ`` is algebraically closed.
+example : IsAlgClosed ℂ := inferInstance
+
+
+

More generally, given an ring morphism f : R →+* S one can evaluate P : R[X] at a point +in S using Polynomial.eval₂. This one produces an actual function from R[X] to S +since it does not assume the existence of a Algebra R S instance, so dot notation works as +you would expect.

+
#check (Complex.ofRealHom : ℝ →+* ℂ)
+
+example : (X ^ 2 + 1 : ℝ[X]).eval₂ Complex.ofRealHom Complex.I = 0 := by simp
+
+
+

Let us end by mentioning multivariate polynomials briefly. Given a commutative semiring R, +the R-algebra of polynomials with coefficients in R and indeterminates indexed by +a type σ is MVPolynomial σ R. Given i : σ, the corresponding polynomial is +MvPolynomial.X i. (As usual, one can open the MVPolynomial namespace to shorten this +to X i.) +For instance, if we want two indeterminates we can use +Fin 2 as σ and write the polynomial defining the unit circle in \(\mathbb{R}^2`\) as:

+
open MvPolynomial
+
+def circleEquation : MvPolynomial (Fin 2) ℝ := X 0 ^ 2 + X 1 ^ 2 - 1
+
+
+

Recall that function application has a very high precedence so the expression above is read as +(X 0) ^ 2 + (X 1) ^ 2 - 1. +We can evaluate it to make sure the point with coordinates \((1, 0)\) is on the circle. +Recall the ![...] notation denotes elements of Fin n → X for some natural number n +determined by the number of arguments and some type X determined by the type of arguments.

+
example : MvPolynomial.eval ![1, 0] circleEquation = 0 := by simp [circleEquation]
+
+
+
+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C10_Linear_Algebra.html b/dev/vendor/mathematics_in_lean/html/C10_Linear_Algebra.html new file mode 100644 index 0000000..4eb3217 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C10_Linear_Algebra.html @@ -0,0 +1,1306 @@ + + + + + + + + + 10. Linear algebra — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

10. Linear algebra

+
+

10.1. Vector spaces and linear maps

+
+

10.1.1. Vector spaces

+

We will start directly abstract linear algebra, taking place in a vector space over any field. +However you can find information about matrices in +Section 10.4.1 which does not logically depend on this abstract theory. +Mathlib actually deals with a more general version of linear algebra involving the word module, +but for now we will pretend this is only an eccentric spelling habit.

+

The way to say “let \(K\) be a field and let \(V\) be a vector space over \(K\)” +(and make them implicit arguments to later results) is:

+
variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V]
+
+
+

We explained in Chapter 8 why we need two separate +typeclasses [AddCommGroup V] [Module K V]. +The short version is the following. +Mathematically we want to say that having a \(K\)-vector space structure +implies having an additive commutative group structure. +We could tell this to Lean. But then whenever Lean would need to find such a +group structure on a type \(V\), it would go hunting for vector space +structures using a completely unspecified field \(K\) that cannot be inferred +from \(V\). +This would be very bad for the type class synthesis system.

+

The multiplication of a vector v by a scalar a is denoted by +a • v. We list a couple of algebraic rules about the interaction of this +operation with addition in the following examples. Of course simp or apply? +would find those proofs. There is also a module tactic that solves goals +following from the axioms of vector spaces and fields, in the same way the +ring tactic is used in commutative rings or the group tactic is used in +groups. But it is still useful to remember that scalar +multiplication is abbreviated smul in lemma names.

+
example (a : K) (u v : V) : a • (u + v) = a • u + a • v :=
+  smul_add a u v
+
+example (a b : K) (u : V) : (a + b) • u = a • u + b • u :=
+  add_smul a b u
+
+example (a b : K) (u : V) : a • b • u = b • a • u :=
+  smul_comm a b u
+
+
+

As a quick note for more advanced readers, let us point out that, as suggested by +terminology, Mathlib’s linear algebra also covers modules over (not necessarily commutative) +rings. +In fact it even covers semi-modules over semi-rings. If you think you do not need +this level of generality, you can meditate the following example that nicely captures +a lot of algebraic rules about ideals acting on submodules:

+
example {R M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] :
+    Module (Ideal R) (Submodule R M) :=
+  inferInstance
+
+
+

To say that M is a module over the ring R, we write:

+
section
+variable {R : Type*} [Ring R] {M : Type*} [AddCommGroup M] [Module R M]
+end
+
+
+

If we compare this to declaring a vector space, we see two differences. Apart from renaming the variables, the only change is to replace the Field K hypothesis with a Ring R hypothesis.

+

To say that M is a semi-module over the semi-ring R, we replace the Ring R hypothesis with a Semiring R hypothesis, and also replace AddCommGroup M with AddCommMonoid M, reflecting the fact that semi-modules do not have negation:

+
section
+variable {R : Type*} [Semiring R] {M : Type*} [AddCommMonoid M] [Module R M]
+end
+
+
+

Lean cannot automatically infer that M has negation if R has, +because a priori it cannot guess the correct R given an arbitrary M. +So if we declare R to be a ring and M to be a module over R, +then we have to either declare M to be an AddCommGroup, or add the instance to the context +manually:

+
example {R : Type*} [Ring R] {M : Type*} [AddCommMonoid M] [Module R M] : M → M :=
+  -- Make sure to use `letI` (instead of `haveI` or `let`) to make it easier to
+  -- identify the existing additive structure from the `AddCommMonoid M` hypothesis
+  -- with the new one introduced in the line below.
+  letI : AddCommGroup M := Module.addCommMonoidToAddCommGroup R
+  fun x => - x
+
+
+
+
+

10.1.2. Linear maps

+

Next we need linear maps. Like group morphisms, linear maps in Mathlib are bundled maps, i.e. packages +made of a map and proofs of its linearity properties. +Those bundled maps are converted to ordinary functions when applied. +See Chapter 8 for more information about this design.

+

The type of linear maps between two K-vector spaces +V and W is denoted by V →ₗ[K] W. The subscript l stands for linear. +At first it may feel odd to specify K in this notation. +But this is crucial when several fields come into play. +For instance real-linear maps from \(ℂ\) to \(ℂ\) are every map \(z ↦ az + b\bar{z}\) +while only the maps \(z ↦ az\) are complex linear, and this difference is crucial in +complex analysis.

+
variable {W : Type*} [AddCommGroup W] [Module K W]
+
+variable (φ : V →ₗ[K] W)
+
+example (a : K) (v : V) : φ (a • v) = a • φ v :=
+  map_smul φ a v
+
+example (v w : V) : φ (v + w) = φ v + φ w :=
+  map_add φ v w
+
+
+

Note that V →ₗ[K] W itself carries interesting algebraic structures (this +is part of the motivation for bundling those maps). +It is a K-vector space so we can add linear maps and multiply them by scalars.

+
variable (ψ : V →ₗ[K] W)
+
+#check (2 • φ + ψ : V →ₗ[K] W)
+
+
+

One downside of using bundled maps is that we cannot use ordinary function composition. +We need to use LinearMap.comp or the notation ∘ₗ.

+
variable (θ : W →ₗ[K] V)
+
+#check (φ.comp θ : W →ₗ[K] W)
+#check (φ ∘ₗ θ : W →ₗ[K] W)
+
+
+

There are two main ways to construct linear maps. +First we can build the structure by providing the function and the linearity proof. +As usual, this is facilitated by the structure code action: you can type +example : V →ₗ[K] V := _ and use the code action “Generate a skeleton” attached to the +underscore.

+
example : V →ₗ[K] V where
+  toFun v := 3 • v
+  map_add' _ _ := smul_add ..
+  map_smul' _ _ := smul_comm ..
+
+
+

You may wonder why the proof fields of LinearMap have names ending with a prime. +This is because they are defined before the coercion to functions is defined, hence they are +phrased in terms of LinearMap.toFun. Then they are restated as LinearMap.map_add +and LinearMap.map_smul in terms of the coercion to function. +This is not yet the end of the story. One also wants a version of map_add that applies to +any (bundled) map preserving addition, such as additive group morphisms, linear maps, continuous +linear maps, K-algebra maps etc… This one is map_add (in the root namespace). +The intermediate version, LinearMap.map_add is a bit redundant but allows to use dot notation, which +can be nice sometimes. A similar story exists for map_smul, and the general framework +is explained in Chapter 8.

+
#check (φ.map_add' : ∀ x y : V, φ.toFun (x + y) = φ.toFun x + φ.toFun y)
+#check (φ.map_add : ∀ x y : V, φ (x + y) = φ x + φ y)
+#check (map_add φ : ∀ x y : V, φ (x + y) = φ x + φ y)
+
+
+

One can also build linear maps from the ones that are already defined in Mathlib +using various combinators. +For instance the above example is already known as LinearMap.lsmul K V 3. +There are several reason why K and V are explicit arguments here. +The most pressing one is that from a bare LinearMap.lsmul 3 there would be no way +for Lean to infer V or even K. +But also LinearMap.lsmul K V is an interesting object by itself: it has type +K →ₗ[K] V →ₗ[K] V, meaning it is a K-linear map from K +—seen as a vector space over itself— to the space of K-linear maps from V to V.

+
#check (LinearMap.lsmul K V 3 : V →ₗ[K] V)
+#check (LinearMap.lsmul K V : K →ₗ[K] V →ₗ[K] V)
+
+
+

There is also a type LinearEquiv of linear isomorphisms denoted by V ≃ₗ[K] W. +The inverse of f : V ≃ₗ[K] W is f.symm : W ≃ₗ[K] V, +composition of f and g is f.trans g also denoted by f ≪≫ₗ g, and +the identity isomorphism of V is LinearEquiv.refl K V. +Elements of this type are automatically coerced to morphisms and functions when necessary.

+
example (f : V ≃ₗ[K] W) : f ≪≫ₗ f.symm = LinearEquiv.refl K V :=
+  f.self_trans_symm
+
+
+

One can use LinearEquiv.ofBijective to build an isomorphism from a bijective morphism. +Doing so makes the inverse function noncomputable.

+
noncomputable example (f : V →ₗ[K] W) (h : Function.Bijective f) : V ≃ₗ[K] W :=
+  .ofBijective f h
+
+
+

Note that in the above example, Lean uses the announced type to understand that .ofBijective +refers to LinearEquiv.ofBijective (without needing to open any namespace).

+
+
+

10.1.3. Sums and products of vector spaces

+

We can build new vector spaces out of old ones using direct sums and direct +products. +Let us start with two vectors spaces. In this case there is no difference between sum and product, +and we can simply use the product type. +In the following snippet of code we simply show how to get all the structure maps (inclusions +and projections) as linear maps, as well as the universal properties constructing linear maps +into products and out of sums (if you are not familiar with the category-theoretic distinction +between sums and products, you can simply ignore the universal property vocabulary and focus +on the types of the following examples).

+
section binary_product
+
+variable {W : Type*} [AddCommGroup W] [Module K W]
+variable {U : Type*} [AddCommGroup U] [Module K U]
+variable {T : Type*} [AddCommGroup T] [Module K T]
+
+-- First projection map
+example : V × W →ₗ[K] V := LinearMap.fst K V W
+
+-- Second projection map
+example : V × W →ₗ[K] W := LinearMap.snd K V W
+
+-- Universal property of the product
+example (φ : U →ₗ[K] V) (ψ : U →ₗ[K] W) : U →ₗ[K]  V × W := LinearMap.prod φ ψ
+
+-- The product map does the expected thing, first component
+example (φ : U →ₗ[K] V) (ψ : U →ₗ[K] W) : LinearMap.fst K V W ∘ₗ LinearMap.prod φ ψ = φ := rfl
+
+-- The product map does the expected thing, second component
+example (φ : U →ₗ[K] V) (ψ : U →ₗ[K] W) : LinearMap.snd K V W ∘ₗ LinearMap.prod φ ψ = ψ := rfl
+
+-- We can also combine maps in parallel
+example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] T) : (V × W) →ₗ[K] (U × T) := φ.prodMap ψ
+
+-- This is simply done by combining the projections with the universal property
+example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] T) :
+  φ.prodMap ψ = (φ ∘ₗ .fst K V W).prod (ψ ∘ₗ .snd K V W) := rfl
+
+-- First inclusion map
+example : V →ₗ[K] V × W := LinearMap.inl K V W
+
+-- Second inclusion map
+example : W →ₗ[K] V × W := LinearMap.inr K V W
+
+-- Universal property of the sum (aka coproduct)
+example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] U) : V × W →ₗ[K] U := φ.coprod ψ
+
+-- The coproduct map does the expected thing, first component
+example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] U) : φ.coprod ψ ∘ₗ LinearMap.inl K V W = φ :=
+  LinearMap.coprod_inl φ ψ
+
+-- The coproduct map does the expected thing, second component
+example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] U) : φ.coprod ψ ∘ₗ LinearMap.inr K V W = ψ :=
+  LinearMap.coprod_inr φ ψ
+
+-- The coproduct map is defined in the expected way
+example (φ : V →ₗ[K] U) (ψ : W →ₗ[K] U) (v : V) (w : W) :
+    φ.coprod ψ (v, w) = φ v + ψ w :=
+  rfl
+
+end binary_product
+
+
+

Let us now turn to sums and products of arbitrary families of vector spaces. +Here we will simply see how to define a family of vector spaces and access the universal +properties of sums and products. +Note that the direct sum notation is scoped to the DirectSum namespace, and +that the universal property of direct sums requires decidable equality on the +indexing type (this is somehow an implementation accident).

+
section families
+open DirectSum
+
+variable {ι : Type*} [DecidableEq ι]
+         (V : ι → Type*) [∀ i, AddCommGroup (V i)] [∀ i, Module K (V i)]
+
+-- The universal property of the direct sum assembles maps from the summands to build
+-- a map from the direct sum
+example (φ : Π i, (V i →ₗ[K] W)) : (⨁ i, V i) →ₗ[K] W :=
+  DirectSum.toModule K ι W φ
+
+-- The universal property of the direct product assembles maps into the factors
+-- to build a map into the direct product
+example (φ : Π i, (W →ₗ[K] V i)) : W →ₗ[K] (Π i, V i) :=
+  LinearMap.pi φ
+
+-- The projection maps from the product
+example (i : ι) : (Π j, V j) →ₗ[K] V i := LinearMap.proj i
+
+-- The inclusion maps into the sum
+example (i : ι) : V i →ₗ[K] (⨁ i, V i) := DirectSum.lof K ι V i
+
+-- The inclusion maps into the product
+example (i : ι) : V i →ₗ[K] (Π i, V i) := LinearMap.single K V i
+
+-- In case `ι` is a finite type, there is an isomorphism between the sum and product.
+example [Fintype ι] : (⨁ i, V i) ≃ₗ[K] (Π i, V i) :=
+  linearEquivFunOnFintype K ι V
+
+end families
+
+
+
+
+
+

10.2. Subspaces and quotients

+
+

10.2.1. Subspaces

+

Just as linear maps are bundled, a linear subspace of V is also a bundled structure consisting of +a set in V, called the carrier of the subspace, with the relevant closure properties. +Again the word module appears instead of vector space because of the more general context that +Mathlib actually uses for linear algebra.

+
section
+variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V]
+
+example (U : Submodule K V) {x y : V} (hx : x ∈ U) (hy : y ∈ U) :
+    x + y ∈ U :=
+  U.add_mem hx hy
+
+example (U : Submodule K V) {x : V} (hx : x ∈ U) (a : K) :
+    a • x ∈ U :=
+  U.smul_mem a hx
+end
+
+
+

In the example above, it is important to understand that Submodule K V is the type of K-linear +subspaces of V, rather than a predicate IsSubmodule U where U is an element of Set V. +Submodule K V is endowed with a coercion to Set V and a membership predicate on V. +See Section 8.3 for an explanation of how and why this is done.

+

Of course, two subspaces are the same if and only if they have the same elements. This fact +is registered for use with the ext tactic, which can be used to prove two subspaces are +equal in the same way it is used to prove that two sets are equal.

+

To state and prove, for example, that ℝ is a ℝ-linear subspace of ℂ, +what we really want is to construct a term of type Submodule ℝ ℂ whose projection to +Set ℂ is ℝ, or, more precisely, the image of ℝ in ℂ.

+
noncomputable example : Submodule ℝ ℂ where
+  carrier := Set.range ((↑) : ℝ → ℂ)
+  add_mem' := by
+    rintro _ _ ⟨n, rfl⟩ ⟨m, rfl⟩
+    use n + m
+    simp
+  zero_mem' := by
+    use 0
+    simp
+  smul_mem' := by
+    rintro c - ⟨a, rfl⟩
+    use c*a
+    simp
+
+
+

The prime at the end of proof fields in Submodule are analogous to the one in LinearMap. +Those fields are stated in terms of the carrier field because they are defined before the +MemberShip instance. They are then superseded by Submodule.add_mem, Submodule.zero_mem +and Submodule.smul_mem that we saw above.

+

As an exercise in manipulating subspaces and linear maps, you will define the pre-image of +a subspace by a linear map (of course we will see below that Mathlib already knows about this). +Remember that Set.mem_preimage can be used to rewrite a statement involving +membership and preimage. This is the only lemma you will need in addition to the lemmas +discussed above about LinearMap and Submodule.

+
variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V]
+
+def preimage {W : Type*} [AddCommGroup W] [Module K W] (φ : V →ₗ[K] W) (H : Submodule K W) :
+    Submodule K V where
+  carrier := φ ⁻¹' H
+  zero_mem' := by
+    sorry
+  add_mem' := by
+    sorry
+  smul_mem' := by
+    sorry
+
+
+

Using type classes, Mathlib knows that a subspace of a vector space inherits a vector space structure.

+
example (U : Submodule K V) : Module K U := inferInstance
+
+
+

This example is subtle. The object U is not a type, but Lean automatically coerces it to +a type by interpreting it as a subtype of V. +So the above example can be restated more explicitly as:

+
example (U : Submodule K V) : Module K {x : V // x ∈ U} := inferInstance
+
+
+
+
+

10.2.2. Complete lattice structure and internal direct sums

+

An important benefit of having a type Submodule K V instead of a predicate +IsSubmodule : Set V → Prop is that one can easily endow Submodule K V with additional structure. +Importantly, it has the structure of a complete lattice structure with respect to +inclusion. For instance, instead of having a lemma stating that an intersection of +two subspaces of V is again a subspace, we +use the lattice operation ⊓ to construct the intersection. We can then apply arbitrary +lemmas about lattices to the construction.

+

Let us check that the set underlying the infimum of two subspaces is indeed, by definition, +their intersection.

+
example (H H' : Submodule K V) :
+    ((H ⊓ H' : Submodule K V) : Set V) = (H : Set V) ∩ (H' : Set V) := rfl
+
+
+

It may look strange to have a different notation for what amounts to the intersection of the +underlying sets, but the correspondence does not carry over to the supremum operation and set +union, since a union of subspaces is not, in general, a subspace. +Instead one needs to use the subspace generated by the union, which is done +using Submodule.span.

+
example (H H' : Submodule K V) :
+    ((H ⊔ H' : Submodule K V) : Set V) = Submodule.span K ((H : Set V) ∪ (H' : Set V)) := by
+  simp [Submodule.span_union]
+
+
+

Another subtlety is that V itself does not have type Submodule K V, +so we need a way to talk about V seen as a subspace of V. +This is also provided by the lattice structure: the full subspace is the top element of +this lattice.

+
example (x : V) : x ∈ (⊤ : Submodule K V) := trivial
+
+
+

Similarly the bottom element of this lattice is the subspace whose only element is the +zero element.

+
example (x : V) : x ∈ (⊥ : Submodule K V) ↔ x = 0 := Submodule.mem_bot K
+
+
+

In particular we can discuss the case of subspaces that are in (internal) direct sum. +In the case of two subspaces, we use the general purpose predicate IsCompl +which makes sense for any bounded partially ordered type. +In the case of general families of subspaces we use DirectSum.IsInternal.

+
-- If two subspaces are in direct sum then they span the whole space.
+example (U V : Submodule K V) (h : IsCompl U V) :
+  U ⊔ V = ⊤ := h.sup_eq_top
+
+-- If two subspaces are in direct sum then they intersect only at zero.
+example (U V : Submodule K V) (h : IsCompl U V) :
+  U ⊓ V = ⊥ := h.inf_eq_bot
+
+section
+open DirectSum
+variable {ι : Type*} [DecidableEq ι]
+
+-- If subspaces are in direct sum then they span the whole space.
+example (U : ι → Submodule K V) (h : DirectSum.IsInternal U) :
+  ⨆ i, U i = ⊤ := h.submodule_iSup_eq_top
+
+-- If subspaces are in direct sum then they pairwise intersect only at zero.
+example {ι : Type*} [DecidableEq ι] (U : ι → Submodule K V) (h : DirectSum.IsInternal U)
+    {i j : ι} (hij : i ≠ j) : U i ⊓ U j = ⊥ :=
+  (h.submodule_iSupIndep.pairwiseDisjoint hij).eq_bot
+
+-- Those conditions characterize direct sums.
+#check DirectSum.isInternal_submodule_iff_iSupIndep_and_iSup_eq_top
+
+-- The relation with external direct sums: if a family of subspaces is
+-- in internal direct sum then the map from their external direct sum into `V`
+-- is a linear isomorphism.
+noncomputable example {ι : Type*} [DecidableEq ι] (U : ι → Submodule K V)
+    (h : DirectSum.IsInternal U) : (⨁ i, U i) ≃ₗ[K] V :=
+  LinearEquiv.ofBijective (coeLinearMap U) h
+end
+
+
+
+
+

10.2.3. Subspace spanned by a set

+

In addition to building subspaces out of existing subspaces, we can build them out +of any set s using Submodule.span K s which builds the smallest subspace +containing s. +On paper it is common to use that this space is made of all linear combinations of elements of +s. +But it is often more efficient to use its universal property expressed by Submodule.span_le, +and the whole theory of Galois connections.

+
example {s : Set V} (E : Submodule K V) : Submodule.span K s ≤ E ↔ s ⊆ E :=
+  Submodule.span_le
+
+example : GaloisInsertion (Submodule.span K) ((↑) : Submodule K V → Set V) :=
+  Submodule.gi K V
+
+
+

When those are not enough, one can use the relevant induction principle +Submodule.span_induction which ensures a property holds for every element of the +span of s as long as it holds on zero and elements of s and is stable under +sum and scalar multiplication.

+

As an exercise, let us reprove one implication of Submodule.mem_sup. +Remember that you can use the module tactic to close goals that follow from +the axioms relating the various algebraic operations on V.

+
example {S T : Submodule K V} {x : V} (h : x ∈ S ⊔ T) :
+    ∃ s ∈ S, ∃ t ∈ T, x = s + t  := by
+  rw [← S.span_eq, ← T.span_eq, ← Submodule.span_union] at h
+  induction h using Submodule.span_induction with
+  | mem y h =>
+      sorry
+  | zero =>
+      sorry
+  | add x y hx hy hx' hy' =>
+      sorry
+  | smul a x hx hx' =>
+      sorry
+
+
+
+
+

10.2.4. Pushing and pulling subspaces

+

As promised earlier, we now describe how to push and pull subspaces by linear maps. +As usual in Mathlib, the first operation is called map and the second one is called +comap.

+
section
+
+variable {W : Type*} [AddCommGroup W] [Module K W] (φ : V →ₗ[K] W)
+
+variable (E : Submodule K V) in
+#check (Submodule.map φ E : Submodule K W)
+
+variable (F : Submodule K W) in
+#check (Submodule.comap φ F : Submodule K V)
+
+
+

Note those live in the Submodule namespace so one can use dot notation and write +E.map φ instead of Submodule.map φ E, but this is pretty awkward to read (although some +Mathlib contributors use this spelling).

+

In particular the range and kernel of a linear map are subspaces. Those special cases are important +enough to get declarations.

+
example : LinearMap.range φ = .map φ ⊤ := LinearMap.range_eq_map φ
+
+example : LinearMap.ker φ = .comap φ ⊥ := Submodule.comap_bot φ -- or `rfl`
+
+
+

Note that we cannot write φ.ker instead of LinearMap.ker φ because LinearMap.ker also +applies to classes of maps preserving more structure, hence it does not expect an argument +whose type starts with LinearMap, hence dot notation doesn’t work here. +However we were able to use the other flavor of dot notation in the right-hand side. Because +Lean expects a term with type Submodule K V after elaborating the left-hand side, it interprets +.comap as Submodule.comap.

+

The following lemmas give the key relations between those submodule and the properties of φ.

+
open Function LinearMap
+
+example : Injective φ ↔ ker φ = ⊥ := ker_eq_bot.symm
+
+example : Surjective φ ↔ range φ = ⊤ := range_eq_top.symm
+
+
+

As an exercise, let us prove the Galois connection property for map and comap. +One can use the following lemmas but this is not required since they are true by definition.

+
#check Submodule.mem_map_of_mem
+#check Submodule.mem_map
+#check Submodule.mem_comap
+
+example (E : Submodule K V) (F : Submodule K W) :
+    Submodule.map φ E ≤ F ↔ E ≤ Submodule.comap φ F := by
+  sorry
+
+
+
+
+

10.2.5. Quotient spaces

+

Quotient vector spaces use the general quotient notation (typed with \quot, not the ordinary +/). +The projection onto a quotient space is Submodule.mkQ and the universal property is +Submodule.liftQ.

+
variable (E : Submodule K V)
+
+example : Module K (V ⧸ E) := inferInstance
+
+example : V →ₗ[K] V ⧸ E := E.mkQ
+
+example : ker E.mkQ = E := E.ker_mkQ
+
+example : range E.mkQ = ⊤ := E.range_mkQ
+
+example (hφ : E ≤ ker φ) : V ⧸ E →ₗ[K] W := E.liftQ φ hφ
+
+example (F : Submodule K W) (hφ : E ≤ .comap φ F) : V ⧸ E →ₗ[K] W ⧸ F := E.mapQ F φ hφ
+
+noncomputable example : (V ⧸ LinearMap.ker φ) ≃ₗ[K] range φ := φ.quotKerEquivRange
+
+
+

As an exercise, let us prove the correspondence theorem for subspaces of quotient spaces. +Mathlib knows a slightly more precise version as Submodule.comapMkQRelIso.

+
open Submodule
+
+#check Submodule.map_comap_eq
+#check Submodule.comap_map_eq
+
+example : Submodule K (V ⧸ E) ≃ { F : Submodule K V // E ≤ F } where
+  toFun := sorry
+  invFun := sorry
+  left_inv := sorry
+  right_inv := sorry
+
+
+
+
+
+

10.3. Endomorphisms

+

An important special case of linear maps are endomorphisms: linear maps from a vector space to itself. +They are interesting because they form a K-algebra. In particular we can evaluate polynomials +with coefficients in K on them, and they can have eigenvalues and eigenvectors.

+

Mathlib uses the abbreviation Module.End K V := V →ₗ[K] V which is convenient when +using a lot of these (especially after opening the Module namespace).

+
variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V]
+
+variable {W : Type*} [AddCommGroup W] [Module K W]
+
+
+open Polynomial Module LinearMap End
+
+example (φ ψ : End K V) : φ * ψ = φ ∘ₗ ψ :=
+  End.mul_eq_comp φ ψ -- `rfl` would also work
+
+-- evaluating `P` on `φ`
+example (P : K[X]) (φ : End K V) : V →ₗ[K] V :=
+  aeval φ P
+
+-- evaluating `X` on `φ` gives back `φ`
+example (φ : End K V) : aeval φ (X : K[X]) = φ :=
+  aeval_X φ
+
+
+

As an exercise manipulating endomorphisms, subspaces and polynomials, let us prove the +(binary) kernels lemma: for any endomorphism \(φ\) and any two relatively +prime polynomials \(P\) and \(Q\), we have \(\ker P(φ) ⊕ \ker Q(φ) = \ker \big(PQ(φ)\big)\).

+

Note that IsCoprime x y is defined as ∃ a b, a * x + b * y = 1.

+
#check Submodule.eq_bot_iff
+#check Submodule.mem_inf
+#check LinearMap.mem_ker
+
+example (P Q : K[X]) (h : IsCoprime P Q) (φ : End K V) : ker (aeval φ P) ⊓ ker (aeval φ Q) = ⊥ := by
+  sorry
+
+#check Submodule.add_mem_sup
+#check map_mul
+#check End.mul_apply
+#check LinearMap.ker_le_ker_comp
+
+example (P Q : K[X]) (h : IsCoprime P Q) (φ : End K V) :
+    ker (aeval φ P) ⊔ ker (aeval φ Q) = ker (aeval φ (P*Q)) := by
+  sorry
+
+
+

We now move to the discussions of eigenspaces and eigenvalues. The eigenspace +associated to an endomorphism \(φ\) and a scalar \(a\) is the kernel of \(φ - aId\). +Eigenspaces are defined for all values of a, although +they are interesting only when they are non-zero. +However an eigenvector is, by definition, a non-zero element of an eigenspace. The corresponding +predicate is End.HasEigenvector.

+
example (φ : End K V) (a : K) : φ.eigenspace a = LinearMap.ker (φ - a • 1) :=
+  End.eigenspace_def
+
+
+

Then there is a predicate End.HasEigenvalue and the corresponding subtype End.Eigenvalues.

+
example (φ : End K V) (a : K) : φ.HasEigenvalue a ↔ φ.eigenspace a ≠ ⊥ :=
+  Iff.rfl
+
+example (φ : End K V) (a : K) : φ.HasEigenvalue a ↔ ∃ v, φ.HasEigenvector a v  :=
+  ⟨End.HasEigenvalue.exists_hasEigenvector, fun ⟨_, hv⟩ ↦ φ.hasEigenvalue_of_hasEigenvector hv⟩
+
+example (φ : End K V) : φ.Eigenvalues = {a // φ.HasEigenvalue a} :=
+  rfl
+
+-- Eigenvalue are roots of the minimal polynomial
+example (φ : End K V) (a : K) : φ.HasEigenvalue a → (minpoly K φ).IsRoot a :=
+  φ.isRoot_of_hasEigenvalue
+
+-- In finite dimension, the converse is also true (we will discuss dimension below)
+example [FiniteDimensional K V] (φ : End K V) (a : K) :
+    φ.HasEigenvalue a ↔ (minpoly K φ).IsRoot a :=
+  φ.hasEigenvalue_iff_isRoot
+
+-- Cayley-Hamilton
+example [FiniteDimensional K V] (φ : End K V) : aeval φ φ.charpoly = 0 :=
+  φ.aeval_self_charpoly
+
+
+
+
+

10.4. Matrices, bases and dimension

+
+

10.4.1. Matrices

+

Before introducing bases for abstract vector spaces, we go back to the much more elementary setup +of linear algebra in \(K^n\) for some field \(K\). +Here the main objects are vectors and matrices. +For concrete vectors, one can use the ![…] notation, where components are separated by commas. +For concrete matrices we can use the !![…] notation, rows are separated by semicolons +and elements of the rows are separated by commas. +When entries have a computable type such as ℕ or ℚ, we can use +the eval command to play with basic operations.

+
section matrices
+
+-- Adding vectors
+#eval ![1, 2] + ![3, 4]  -- ![4, 6]
+
+-- Adding matrices
+#eval !![1, 2; 3, 4] + !![3, 4; 5, 6]  -- !![4, 6; 8, 10]
+
+-- Multiplying matrices
+#eval !![1, 2; 3, 4] * !![3, 4; 5, 6]  -- !![13, 16; 29, 36]
+
+
+

It is important to understand that this use of #eval is interesting only for +exploration, it is not meant to replace a computer algebra system such as Sage. +The data representation used here for matrices is not computationally +efficient in any way. It uses functions instead of arrays and is optimized for +proving, not computing. +The virtual machine used by #eval is also not optimized for this use.

+

Beware the matrix notation list rows but the vector notation +is neither a row vector nor a column vector. Multiplication of a matrix with a vector +from the left (resp. right) interprets the vector as a row (resp. column) vector. +This corresponds to operations +Matrix.vecMul, with notation ᵥ* and Matrix.mulVec, with notation ` *ᵥ`. +Those notations are scoped in the Matrix namespace that we therefore need to open.

+
open Matrix
+
+-- matrices acting on vectors on the left
+#eval !![1, 2; 3, 4] *ᵥ ![1, 1] -- ![3, 7]
+
+-- matrices acting on vectors on the left, resulting in a size one matrix
+#eval !![1, 2] *ᵥ ![1, 1]  -- ![3]
+
+-- matrices acting on vectors on the right
+#eval  ![1, 1, 1] ᵥ* !![1, 2; 3, 4; 5, 6] -- ![9, 12]
+
+
+

In order to generate matrices with identical rows or columns specified by a vector, we +use Matrix.replicateRow and Matrix.replicateCol, with arguments the type indexing the +rows or columns and the vector. +For instance one can get single row or single column matrixes (more precisely matrices whose rows +or columns are indexed by Fin 1).

+
#eval replicateRow (Fin 1) ![1, 2] -- !![1, 2]
+
+#eval replicateCol (Fin 1) ![1, 2] -- !![1; 2]
+
+
+

Other familiar operations include the vector dot product, matrix transpose, and, +for square matrices, determinant and trace.

+
-- vector dot product
+#eval ![1, 2] ⬝ᵥ ![3, 4] -- `11`
+
+-- matrix transpose
+#eval !![1, 2; 3, 4]ᵀ -- `!![1, 3; 2, 4]`
+
+-- determinant
+#eval !![(1 : ℤ), 2; 3, 4].det -- `-2`
+
+-- trace
+#eval !![(1 : ℤ), 2; 3, 4].trace -- `5`
+
+
+

When entries do not have a computable type, for instance if they are real numbers, we cannot +hope that #eval can help. Also this kind of evaluation cannot be used in proofs without +considerably expanding the trusted code base (i.e. the part of Lean that you need to trust when +checking proofs).

+

So it is good to also use the simp and norm_num tactics in proofs, or +their command counter-part for quick exploration.

+
#simp !![(1 : ℝ), 2; 3, 4].det -- `4 - 2*3`
+
+#norm_num !![(1 : ℝ), 2; 3, 4].det -- `-2`
+
+#norm_num !![(1 : ℝ), 2; 3, 4].trace -- `5`
+
+variable (a b c d : ℝ) in
+#simp !![a, b; c, d].det -- `a * d – b * c`
+
+
+

The next important operation on square matrices is inversion. +In the same way as division of numbers is always defined and returns the artificial value +zero for division by zero, the inversion operation is defined on all matrices and returns +the zero matrix for non-invertible matrices.

+

More precisely, there is general function Ring.inverse that does this in any ring, +and, for any matrix A, A⁻¹ is defined as Ring.inverse A.det • A.adjugate. +According to Cramer’s rule, this is indeed the inverse of A when the determinant of A is +not zero.

+
#norm_num [Matrix.inv_def] !![(1 : ℝ), 2; 3, 4]⁻¹ -- !![-2, 1; 3 / 2, -(1 / 2)]
+
+
+

Of course this definition is really useful only for invertible matrices. +There is a general type class Invertible that helps recording this. +For instance, the simp call in the next example will use the inv_mul_of_invertible +lemma which has an Invertible type-class assumption, so it will trigger +only if this can be found by the type-class synthesis system. +Here we make this fact available using a have statement.

+
example : !![(1 : ℝ), 2; 3, 4]⁻¹ * !![(1 : ℝ), 2; 3, 4] = 1 := by
+  have : Invertible !![(1 : ℝ), 2; 3, 4] := by
+    apply Matrix.invertibleOfIsUnitDet
+    norm_num
+  simp
+
+
+

In this fully concrete case, we could also use the norm_num machinery, +and apply? to find the final line:

+
example : !![(1 : ℝ), 2; 3, 4]⁻¹ * !![(1 : ℝ), 2; 3, 4] = 1 := by
+  norm_num [Matrix.inv_def]
+  exact one_fin_two.symm
+
+
+

All the concrete matrices above have their rows and columns indexed by Fin n for +some n (not necessarily the same for rows and columns). +But sometimes it is more convenient to index matrices using arbitrary finite types. +For instance the adjacency matrix of a finite graph has rows and columns naturally indexed by +the vertices of the graph.

+

In fact, when one simply wants to define matrices without defining any operation on them, +finiteness of the indexing types are not even needed, and coefficients can have any type, +without any algebraic structure. +So Mathlib simply defines Matrix m n α to be m → n → α for any types m, n and α, +and the matrices we have been using so far had types such as Matrix (Fin 2) (Fin 2) ℝ. +Of course algebraic operations require more assumptions on m, n and α.

+

Note the main reason why we do not use m → n → α directly is to allow the type class +system to understand what we want. For instance, for a ring R, the type n → R is +endowed with the point-wise multiplication operation, and similarly m → n → R +has this operation which is not the multiplication we want on matrices.

+

In the first example below, we force Lean to see through the definition of Matrix +and accept the statement as meaningful, and then prove it by checking all entries.

+

But then the next two examples reveal that Lean uses the point-wise multiplication +on Fin 2 → Fin 2 → ℤ but the matrix multiplication on Matrix (Fin 2) (Fin 2) ℤ.

+
section
+
+example : (fun _ ↦ 1 : Fin 2 → Fin 2 → ℤ) = !![1, 1; 1, 1] := by
+  ext i j
+  fin_cases i <;> fin_cases j <;> rfl
+
+example : (fun _ ↦ 1 : Fin 2 → Fin 2 → ℤ) * (fun _ ↦ 1 : Fin 2 → Fin 2 → ℤ) = !![1, 1; 1, 1] := by
+  ext i j
+  fin_cases i <;> fin_cases j <;> rfl
+
+example : !![1, 1; 1, 1] * !![1, 1; 1, 1] = !![2, 2; 2, 2] := by
+  norm_num
+
+
+

In order to define matrices as functions without losing the benefits of Matrix +for type class synthesis, we can use the equivalence Matrix.of between functions +and matrices. This equivalence is secretly defined using Equiv.refl.

+

For instance we can define Vandermonde matrices corresponding to a vector v.

+
example {n : ℕ} (v : Fin n → ℝ) :
+    Matrix.vandermonde v = Matrix.of (fun i j : Fin n ↦ v i ^ (j : ℕ)) :=
+  rfl
+end
+end matrices
+
+
+
+
+

10.4.2. Bases

+

We now want to discuss bases of vector spaces. Informally there are many ways to define this notion. +One can use a universal property. +One can say a basis is a family of vectors that is linearly independent and spanning. +Or one can combine those properties and directly say that a basis is a family of vectors +such that every vectors can be written uniquely as a linear combination of bases vectors. +Yet another way to say it is that a basis provides a linear isomorphism with a power of +the base field K, seen as a vector space over K.

+

This isomorphism version is actually the one that Mathlib uses as a definition under the hood, and +other characterizations are proven from it. +One must be slightly careful with the “power of K” idea in the case of infinite bases. +Indeed, only finite linear combinations make sense in this algebraic context. So what we need +as a reference vector space is not a direct product of copies of K but a direct sum. +We could use ⨁ i : ι, K for some type ι indexing the basis, +but instead we use the more specialized spelling ι →₀ K, which means +“functions from ι to K with finite support”, i.e. functions which vanish outside a finite set +in ι (this finite set is not fixed, it depends on the function). +Evaluating such a function coming from a basis B at a vector v and +i : ι returns the component (or coordinate) of v on the i-th basis vector.

+

The type of bases indexed by a type ι of V as a K vector space is Basis ι K V. +The isomorphism is called Basis.repr.

+
variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V]
+
+section
+
+open Module
+
+variable {ι : Type*} (B : Basis ι K V) (v : V) (i : ι)
+
+-- The basis vector with index ``i``
+#check (B i : V)
+
+-- the linear isomorphism with the model space given by ``B``
+#check (B.repr : V ≃ₗ[K] ι →₀ K)
+
+-- the component function of ``v``
+#check (B.repr v : ι →₀ K)
+
+-- the component of ``v`` with index ``i``
+#check (B.repr v i : K)
+
+
+

Instead of starting with such an isomorphism, one can start with a family b of vectors that is +linearly independent and spanning, this is Basis.mk.

+

The assumption that the family is spanning is spelled out as ⊤ ≤ Submodule.span K (Set.range b). +Here ⊤ is the top submodule of V, i.e. V seen as submodule of itself. +This spelling looks a bit tortuous, but we will see below that it is almost equivalent by definition +to the more readable ∀ v, v ∈ Submodule.span K (Set.range b) (the underscores in the snippet +below refers to the useless information v ∈ ⊤).

+
noncomputable example (b : ι → V) (b_indep : LinearIndependent K b)
+    (b_spans : ∀ v, v ∈ Submodule.span K (Set.range b)) : Basis ι K V :=
+  Basis.mk b_indep (fun v _ ↦ b_spans v)
+
+-- The family of vectors underlying the above basis is indeed ``b``.
+example (b : ι → V) (b_indep : LinearIndependent K b)
+    (b_spans : ∀ v, v ∈ Submodule.span K (Set.range b)) (i : ι) :
+    Basis.mk b_indep (fun v _ ↦ b_spans v) i = b i :=
+  Basis.mk_apply b_indep (fun v _ ↦ b_spans v) i
+
+
+

In particular the model vector space ι →₀ K has a so-called canonical basis whose repr +function evaluated on any vector is the identity isomorphism. It is called +Finsupp.basisSingleOne where Finsupp means function with finite support and +basisSingleOne refers to the fact that basis vectors are functions which +vanish except for a single input value. More precisely the basis vector indexed by i : ι +is Finsupp.single i 1 which is the finitely supported function taking value 1 at i +and 0 everywhere else.

+
variable [DecidableEq ι]
+
+
+
example : Finsupp.basisSingleOne.repr = LinearEquiv.refl K (ι →₀ K) :=
+  rfl
+
+example (i : ι) : Finsupp.basisSingleOne i = Finsupp.single i 1 :=
+  rfl
+
+
+

The story of finitely supported functions is unneeded when the indexing type is finite. +In this case we can use the simpler Pi.basisFun which gives a basis of the whole +ι → K.

+
example [Finite ι] (x : ι → K) (i : ι) : (Pi.basisFun K ι).repr x i = x i := by
+  simp
+
+
+

Going back to the general case of bases of abstract vector spaces, we can express +any vector as a linear combination of basis vectors. +Let us first see the easy case of finite bases.

+
example [Fintype ι] : ∑ i : ι, B.repr v i • (B i) = v :=
+  B.sum_repr v
+
+
+

When ι is not finite, the above statement makes no sense a priori: we cannot take a sum over ι. +However the support of the function being summed is finite (it is the support of B.repr v). +But we need to apply a construction that takes this into account. +Here Mathlib uses a special purpose function that requires some time to get used to: +Finsupp.linearCombination (which is built on top of the more general Finsupp.sum). +Given a finitely supported function c from a type ι to the base field K and any +function f from ι to V, Finsupp.linearCombination K f c is the +sum over the support of c of the scalar multiplication c • f. In +particular, we can replace it by a sum over any finite set containing the +support of c.

+
example (c : ι →₀ K) (f : ι → V) (s : Finset ι) (h : c.support ⊆ s) :
+    Finsupp.linearCombination K f c = ∑ i ∈ s, c i • f i :=
+  Finsupp.linearCombination_apply_of_mem_supported K h
+
+
+

One could also assume that f is finitely supported and still get a well defined sum. +But the choice made by Finsupp.linearCombination is the one relevant to our basis discussion since it allows +to state the generalization of Basis.sum_repr.

+
example : Finsupp.linearCombination K B (B.repr v) = v :=
+  B.linearCombination_repr v
+
+
+

One could wonder why K is an explicit argument here, despite the fact it can be inferred from +the type of c. The point is that the partially applied Finsupp.linearCombination K f +is interesting in itself. It is not a bare function from ι →₀ K to V but a +K-linear map.

+
variable (f : ι → V) in
+#check (Finsupp.linearCombination K f : (ι →₀ K) →ₗ[K] V)
+
+
+

Returning to the mathematical discussion, it is important to understand that the +representation of vectors in a basis is less useful in formalized +mathematics than you may think. +Indeed it is very often more efficient to directly use more abstract properties of bases. +In particular the universal property of bases connecting them to other free objects in algebra +allows to construct linear maps by specifying the images of basis vectors. +This is Basis.constr. For any K-vector space W, our basis B +gives a linear isomorphism Basis.constr B K from ι → W to V →ₗ[K] W. +This isomorphism is characterized by the fact that it sends any function u : ι → W +to a linear map sending the basis vector B i to u i, for every i : ι.

+
section
+
+variable {W : Type*} [AddCommGroup W] [Module K W]
+         (φ : V →ₗ[K] W) (u : ι → W)
+
+#check (B.constr K : (ι → W) ≃ₗ[K] (V →ₗ[K] W))
+
+#check (B.constr K u : V →ₗ[K] W)
+
+example (i : ι) : B.constr K u (B i) = u i :=
+  B.constr_basis K u i
+
+
+

This property is indeed characteristic because linear maps are determined by their values +on bases:

+
example (φ ψ : V →ₗ[K] W) (h : ∀ i, φ (B i) = ψ (B i)) : φ = ψ :=
+  B.ext h
+
+
+

If we also have a basis B' on the target space then we can identify linear maps +with matrices. This identification is a K-linear isomorphism.

+
variable {ι' : Type*} (B' : Basis ι' K W) [Fintype ι] [Fintype ι'] [DecidableEq ι']
+
+open LinearMap
+
+#check (toMatrix B B' : (V →ₗ[K] W) ≃ₗ[K] Matrix ι' ι K)
+
+open Matrix -- get access to the ``*ᵥ`` notation for multiplication between matrices and vectors.
+
+example (φ : V →ₗ[K] W) (v : V) : (toMatrix B B' φ) *ᵥ (B.repr v) = B'.repr (φ v) :=
+  toMatrix_mulVec_repr B B' φ v
+
+
+variable {ι'' : Type*} (B'' : Basis ι'' K W) [Fintype ι''] [DecidableEq ι'']
+
+example (φ : V →ₗ[K] W) : (toMatrix B B'' φ) = (toMatrix B' B'' .id) * (toMatrix B B' φ) := by
+  simp
+
+end
+
+
+

As an exercise on this topic, we will prove part of the theorem which guarantees that +endomorphisms have a well-defined determinant. +Namely we want to prove that when two bases are indexed by the same type, the matrices +they attach to any endomorphism have the same determinant. +This would then need to be complemented using that bases all have isomorphic indexing types to +get the full result.

+

Of course Mathlib already knows this, and simp can close the goal immediately, so you +shouldn’t use it too soon, but rather use the provided lemmas.

+
open Module LinearMap Matrix
+
+-- Some lemmas coming from the fact that `LinearMap.toMatrix` is an algebra morphism.
+#check toMatrix_comp
+#check id_comp
+#check comp_id
+#check toMatrix_id
+
+-- Some lemmas coming from the fact that ``Matrix.det`` is a multiplicative monoid morphism.
+#check Matrix.det_mul
+#check Matrix.det_one
+
+example [Fintype ι] (B' : Basis ι K V) (φ : End K V) :
+    (toMatrix B B φ).det = (toMatrix B' B' φ).det := by
+  set M := toMatrix B B φ
+  set M' := toMatrix B' B' φ
+  set P := (toMatrix B B') LinearMap.id
+  set P' := (toMatrix B' B) LinearMap.id
+  sorry
+end
+
+
+
+
+

10.4.3. Dimension

+

Returning to the case of a single vector space, bases are also useful to define the concept of +dimension. +Here again, there is the elementary case of finite-dimensional vector spaces. +For such spaces we expect a dimension which is a natural number. +This is Module.finrank. It takes the base field as an explicit argument +since a given abelian group can be a vector space over different fields.

+
section
+
+#check (Module.finrank K V : ℕ)
+
+-- `Fin n → K` is the archetypical space with dimension `n` over `K`.
+example (n : ℕ) : Module.finrank K (Fin n → K) = n :=
+  Module.finrank_fin_fun K
+
+-- Seen as a vector space over itself, `ℂ` has dimension one.
+example : Module.finrank ℂ ℂ = 1 :=
+  Module.finrank_self ℂ
+
+-- But as a real vector space it has dimension two.
+example : Module.finrank ℝ ℂ = 2 :=
+  Complex.finrank_real_complex
+
+
+

Note that Module.finrank is defined for any vector space. It returns +zero for infinite dimensional vector spaces, just as division by zero returns zero.

+

Of course many lemmas require a finite dimension assumption. This is the role of +the FiniteDimensional typeclass. For instance, think about how the next +example fails without this assumption.

+
example [FiniteDimensional K V] : 0 < Module.finrank K V ↔ Nontrivial V  :=
+  Module.finrank_pos_iff
+
+
+

In the above statement, Nontrivial V means V has at least two different elements. +Note that Module.finrank_pos_iff has no explicit argument. +This is fine when using it from left to right, but not when using it from right to left +because Lean has no way to guess K from the statement Nontrivial V. +In that case it is useful to use the name argument syntax, after checking that the lemma +is stated over a ring named R. So we can write:

+
example [FiniteDimensional K V] (h : 0 < Module.finrank K V) : Nontrivial V := by
+  apply (Module.finrank_pos_iff (R := K)).1
+  exact h
+
+
+

The above spelling is strange because we already have h as an assumption, so we could +just as well give the full proof Module.finrank_pos_iff.1 h but it +is good to know for more complicated cases.

+

By definition, FiniteDimensional K V can be read from any basis.

+
variable {ι : Type*} (B : Module.Basis ι K V)
+
+example [Finite ι] : FiniteDimensional K V := Module.Basis.finiteDimensional_of_finite B
+
+example [FiniteDimensional K V] : Finite ι :=
+  (FiniteDimensional.fintypeBasisIndex B).finite
+end
+
+
+

Using that the subtype corresponding to a linear subspace has a vector space structure, +we can talk about the dimension of a subspace.

+
section
+variable (E F : Submodule K V) [FiniteDimensional K V]
+
+open Module
+
+example : finrank K (E ⊔ F : Submodule K V) + finrank K (E ⊓ F : Submodule K V) =
+    finrank K E + finrank K F :=
+  Submodule.finrank_sup_add_finrank_inf_eq E F
+
+example : finrank K E ≤ finrank K V := Submodule.finrank_le E
+
+
+

In the first statement above, the purpose of the type ascriptions is to make sure that +coercion to Type* does not trigger too early.

+

We are now ready for an exercise about finrank and subspaces.

+
example (h : finrank K V < finrank K E + finrank K F) :
+    Nontrivial (E ⊓ F : Submodule K V) := by
+  sorry
+end
+
+
+

Let us now move to the general case of dimension theory. In this case +finrank is useless, but we still have that, for any two bases of the same +vector space, there is a bijection between the types indexing those bases. So we +can still hope to define the rank as a cardinal, i.e. an element of the “quotient of +the collection of types under the existence of a bijection equivalence +relation”.

+

When discussing cardinal, it gets harder to ignore foundational issues around Russel’s paradox +like we do everywhere else in this book. +There is no type of all types because it would lead to logical inconsistencies. +This issue is solved by the hierarchy of universes that +we usually try to ignore.

+

Each type has a universe level, and those levels behave similarly to natural +numbers. In particular there is zeroth level, and the corresponding universe +Type 0 is simply denoted by Type. This universe is enough to hold +almost all of classical mathematics. For instance ℕ and ℝ have type Type. +Each level u has a successor denoted +by u + 1, and Type u has type Type (u+1).

+

But universe levels are not natural numbers, they have a really different nature and don’t +have a type. In particular you cannot state in Lean something like u ≠ u + 1. +There is simply no type where this would take place. Even stating +Type u ≠ Type (u+1) does not make any sense since Type u and Type (u+1) +have different types.

+

Whenever we write Type*, Lean inserts a universe level variable named u_n where n is a +number. This allows definitions and statements to live in all universes.

+

Given a universe level u, we can define an equivalence relation on Type u saying +two types α and β are equivalent if there is a bijection between them. +The quotient type Cardinal.{u} lives in Type (u+1). The curly braces +denote a universe variable. The image of α : Type u in this quotient is +Cardinal.mk α : Cardinal.{u}.

+

But we cannot directly compare cardinals in different universes. So technically we +cannot define the rank of a vector space V as the cardinal of all types indexing +a basis of V. +So instead it is defined as the supremum Module.rank K V of cardinals of +all linearly independent sets in V. If V has universe level u then +its rank has type Cardinal.{u}.

+
#check V -- Type u_2
+#check Module.rank K V -- Cardinal.{u_2}
+
+
+

One can still relate this definition to bases. Indeed there is also a commutative max +operation on universe levels, and given two universe levels u and v +there is an operation Cardinal.lift.{u, v} : Cardinal.{v} → Cardinal.{max v u} +that allows to put cardinals in a common universe and state the dimension theorem.

+
universe u v -- `u` and `v` will denote universe levels
+
+variable {ι : Type u} (B : Module.Basis ι K V)
+         {ι' : Type v} (B' : Module.Basis ι' K V)
+
+example : Cardinal.lift.{v, u} (.mk ι) = Cardinal.lift.{u, v} (.mk ι') :=
+  mk_eq_mk_of_basis B B'
+
+
+

We can relate the finite dimensional case to this discussion using the coercion +from natural numbers to finite cardinals (or more precisely the finite cardinals which live in Cardinal.{v} where v is the universe level of V).

+
example [FiniteDimensional K V] :
+    (Module.finrank K V : Cardinal) = Module.rank K V :=
+  Module.finrank_eq_rank K V
+
+
+
+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C11_Topology.html b/dev/vendor/mathematics_in_lean/html/C11_Topology.html new file mode 100644 index 0000000..0776e4a --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C11_Topology.html @@ -0,0 +1,1238 @@ + + + + + + + + + 11. Topology — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

11. Topology

+

Calculus is based on the concept of a function, which is used to model +quantities that depend on one another. +For example, it is common to study quantities that change over time. +The notion of a limit is also fundamental. +We may say that the limit of a function \(f(x)\) is a value \(b\) +as \(x\) approaches a value \(a\), +or that \(f(x)\) converges to \(b\) as \(x\) approaches \(a\). +Equivalently, we may say that \(f(x)\) approaches \(b\) as \(x\) +approaches a value \(a\), or that it tends to \(b\) +as \(x\) tends to \(a\). +We have already begun to consider such notions in Section 3.6.

+

Topology is the abstract study of limits and continuity. +Having covered the essentials of formalization in Chapters 2 +to 7, +in this chapter, we will explain how topological notions are formalized in Mathlib. +Not only do topological abstractions apply in much greater generality, +but they also, somewhat paradoxically, make it easier to reason about limits +and continuity in concrete instances.

+

Topological notions build on quite a few layers of mathematical structure. +The first layer is naive set theory, +as described in Chapter 4. +The next layer is the theory of filters, which we will describe in Section 11.1. +On top of that, we layer +the theories of topological spaces, metric spaces, and a slightly more exotic +intermediate notion called a uniform space.

+

Whereas previous chapters relied on mathematical notions that were likely +familiar to you, +the notion of a filter is less well known, +even to many working mathematicians. +The notion is essential, however, for formalizing mathematics effectively. +Let us explain why. +Let f : ℝ → ℝ be any function. We can consider +the limit of f x as x approaches some value x₀, +but we can also consider the limit of f x as x approaches infinity +or negative infinity. +We can moreover consider the limit of f x as x approaches x₀ from +the right, conventionally written x₀⁺, or from the left, +written x₀⁻. There are variations where x approaches x₀ or x₀⁺ +or x₀⁻ but +is not allowed to take on the value x₀ itself. +This results in at least eight ways that x can approach something. +We can also restrict to rational values of x +or place other constraints on the domain, but let’s stick to those 8 cases.

+

We have a similar variety of options on the codomain: +we can specify that f x approaches a value from the left or right, +or that it approaches positive or negative infinity, and so on. +For example, we may wish to say that f x tends to +∞ +when x tends to x₀ from the right without +being equal to x₀. +This results in 64 different kinds of limit statements, +and we haven’t even begun to deal with limits of sequences, +as we did in Section 3.6.

+

The problem is compounded even further when it comes to the supporting lemmas. +For instance, limits compose: if +f x tends to y₀ when x tends to x₀ and +g y tends to z₀ when y tends to y₀ then +g ∘ f x tends to z₀ when x tends to x₀. +There are three notions of “tends to” at play here, +each of which can be instantiated in any of the eight ways described +in the previous paragraph. +This results in 512 lemmas, a lot to have to add to a library! +Informally, mathematicians generally prove two or three of these +and simply note that the rest can be proved “in the same way.” +Formalizing mathematics requires making the relevant notion of “sameness” +fully explicit, and that is exactly what Bourbaki’s theory of filters +manages to do.

+
+

11.1. Filters

+

A filter on a type X is a collection of sets of X that satisfies three +conditions that we will spell out below. The notion +supports two related ideas:

+
    +
  • limits, including all the kinds of limits discussed above: finite and infinite limits of sequences, finite and infinite limits of functions at a point or at infinity, and so on.

  • +
  • things happening eventually, including things happening for large enough n : ℕ, or sufficiently near a point x, or for sufficiently close pairs of points, or almost everywhere in the sense of measure theory. Dually, filters can also express the idea of things happening often: for arbitrarily large n, at a point in any neighborhood of a given point, etc.

  • +
+

The filters that correspond to these descriptions will be defined later in this section, but we can already name them:

+
    +
  • (atTop : Filter ℕ), made of sets of ℕ containing {n | n ≥ N} for some N

  • +
  • 𝓝 x, made of neighborhoods of x in a topological space

  • +
  • 𝓤 X, made of entourages of a uniform space (uniform spaces generalize metric spaces and topological groups)

  • +
  • μ.ae , made of sets whose complement has zero measure with respect to a measure μ.

  • +
+

The general definition is as follows: a filter F : Filter X is a +collection of sets F.sets : Set (Set X) satisfying the following:

+
    +
  • F.univ_sets : univ ∈ F.sets

  • +
  • F.sets_of_superset : ∀ {U V}, U ∈ F.sets → U ⊆ V → V ∈ F.sets

  • +
  • F.inter_sets : ∀ {U V}, U ∈ F.sets → V ∈ F.sets → U ∩ V ∈ F.sets.

  • +
+

The first condition says that the set of all elements of X belongs to F.sets. +The second condition says that if U belongs to F.sets then anything +containing U also belongs to F.sets. +The third condition says that F.sets is closed under finite intersections. +In Mathlib, a filter F is defined to be a structure bundling F.sets and its +three properties, but the properties carry no additional data, +and it is convenient to blur the distinction between F and F.sets. We +therefore define U ∈ F to mean U ∈ F.sets. +This explains why the word sets appears in the names of some lemmas that +that mention U ∈ F.

+

It may help to think of a filter as defining a notion of a “sufficiently large” set. The first +condition then says that univ is sufficiently large, the second one says that a set containing a sufficiently +large set is sufficiently large and the third one says that the intersection of two sufficiently large sets +is sufficiently large.

+

It may be even more useful to think of a filter on a type X +as a generalized element of Set X. For instance, atTop is the +“set of very large numbers” and 𝓝 x₀ is the “set of points very close to x₀.” +One manifestation of this view is that we can associate to any s : Set X the so-called principal filter +consisting of all sets that contain s. +This definition is already in Mathlib and has a notation 𝓟 (localized in the Filter namespace). +For the purpose of demonstration, we ask you to take this opportunity to work out the definition here.

+
def principal {α : Type*} (s : Set α) : Filter α
+    where
+  sets := { t | s ⊆ t }
+  univ_sets := sorry
+  sets_of_superset := sorry
+  inter_sets := sorry
+
+
+

For our second example, we ask you to define the filter atTop : Filter ℕ. +(We could use any type with a preorder instead of ℕ.)

+
example : Filter ℕ :=
+  { sets := { s | ∃ a, ∀ b, a ≤ b → b ∈ s }
+    univ_sets := sorry
+    sets_of_superset := sorry
+    inter_sets := sorry }
+
+
+

We can also directly define the filter 𝓝 x of neighborhoods of any x : ℝ. +In the real numbers, a neighborhood of x is a set containing an open interval +\((x_0 - \varepsilon, x_0 + \varepsilon)\), +defined in Mathlib as Ioo (x₀ - ε) (x₀ + ε). +(This notion of a neighborhood is only a special case of a more general construction in Mathlib.)

+

With these examples, we can already define what it means for a function f : X → Y +to converge to some G : Filter Y along some F : Filter X, +as follows:

+
def Tendsto₁ {X Y : Type*} (f : X → Y) (F : Filter X) (G : Filter Y) :=
+  ∀ V ∈ G, f ⁻¹' V ∈ F
+
+
+

When X is ℕ and Y is ℝ, Tendsto₁ u atTop (𝓝 x) is equivalent to saying that the sequence u : ℕ → ℝ +converges to the real number x. When both X and Y are ℝ, Tendsto f (𝓝 x₀) (𝓝 y₀) +is equivalent to the familiar notion \(\lim_{x \to x₀} f(x) = y₀\). +All of the other kinds of limits mentioned in the introduction are +also equivalent to instances of Tendsto₁ for suitable choices of filters on the source and target.

+

The notion Tendsto₁ above is definitionally equivalent to the notion Tendsto that is defined in Mathlib, +but the latter is defined more abstractly. +The problem with the definition of Tendsto₁ is that it exposes a quantifier and elements of G, +and it hides the intuition that we get by viewing filters as generalized sets. We can +hide the quantifier ∀ V and make the intuition more salient by using more algebraic and set-theoretic machinery. +The first ingredient is the pushforward operation \(f_*\) associated to any map f : X → Y, +denoted Filter.map f in Mathlib. Given a filter F on X, Filter.map f F : Filter Y is defined so that +V ∈ Filter.map f F ↔ f ⁻¹' V ∈ F holds definitionally. +In the example file we’ve opened the Filter namespace so that +Filter.map can be written as map. This means that we can rewrite the definition of Tendsto using +the order relation on Filter Y, which is reversed inclusion of the set of members. +In other words, given G H : Filter Y, we have G ≤ H ↔ ∀ V : Set Y, V ∈ H → V ∈ G.

+
def Tendsto₂ {X Y : Type*} (f : X → Y) (F : Filter X) (G : Filter Y) :=
+  map f F ≤ G
+
+example {X Y : Type*} (f : X → Y) (F : Filter X) (G : Filter Y) :
+    Tendsto₂ f F G ↔ Tendsto₁ f F G :=
+  Iff.rfl
+
+
+

It may seem that the order relation on filters is backward. But recall that we can view filters on X as +generalized elements of Set X, via the inclusion of 𝓟 : Set X → Filter X which maps any set s to the corresponding principal filter. +This inclusion is order preserving, so the order relation on Filter can indeed be seen as the natural inclusion relation +between generalized sets. In this analogy, pushforward is analogous to the direct image. +And, indeed, map f (𝓟 s) = 𝓟 (f '' s).

+

We can now understand intuitively why a sequence u : ℕ → ℝ converges to +a point x₀ if and only if we have map u atTop ≤ 𝓝 x₀. +The inequality means the “direct image under u” of +“the set of very big natural numbers” is “included” in “the set of points very close to x₀.”

+

As promised, the definition of Tendsto₂ does not exhibit any quantifiers or sets. +It also leverages the algebraic properties of the pushforward operation. +First, each Filter.map f is monotone. And, second, Filter.map is compatible with +composition.

+
#check (@Filter.map_mono : ∀ {α β} {m : α → β}, Monotone (map m))
+
+#check
+  (@Filter.map_map :
+    ∀ {α β γ} {f : Filter α} {m : α → β} {m' : β → γ}, map m' (map m f) = map (m' ∘ m) f)
+
+
+

Together these two properties allow us to prove that limits compose, yielding in one shot all 512 variants +of the composition lemma described in the introduction, and lots more. +You can practice proving the following statement using either the definition +of Tendsto₁ in terms of the +universal quantifier or the algebraic definition, +together with the two lemmas above.

+
example {X Y Z : Type*} {F : Filter X} {G : Filter Y} {H : Filter Z} {f : X → Y} {g : Y → Z}
+    (hf : Tendsto₁ f F G) (hg : Tendsto₁ g G H) : Tendsto₁ (g ∘ f) F H :=
+  sorry
+
+
+

The pushforward construction uses a map to push filters from the map source to the map target. +There also a pullback operation, Filter.comap, going in the other direction. +This generalizes the +preimage operation on sets. For any map f, +Filter.map f and Filter.comap f form what is known as a Galois connection, +which is to say, they satisfy

+
+

Filter.map_le_iff_le_comap : Filter.map f F ≤ G ↔ F ≤ Filter.comap f G

+
+

for every F and G. +This operation could be used to provided another formulation of Tendsto that would be provably +(but not definitionally) equivalent to the one in Mathlib.

+

The comap operation can be used to restrict filters to a subtype. For instance, suppose we have f : ℝ → ℝ, +x₀ : ℝ and y₀ : ℝ, and suppose we want to state that f x approaches y₀ when x approaches x₀ within the rational numbers. +We can pull the filter 𝓝 x₀ back to ℚ using the coercion map +(↑) : ℚ → ℝ and state Tendsto (f ∘ (↑) : ℚ → ℝ) (comap (↑) (𝓝 x₀)) (𝓝 y₀).

+
variable (f : ℝ → ℝ) (x₀ y₀ : ℝ)
+
+#check comap ((↑) : ℚ → ℝ) (𝓝 x₀)
+
+#check Tendsto (f ∘ (↑)) (comap ((↑) : ℚ → ℝ) (𝓝 x₀)) (𝓝 y₀)
+
+
+

The pullback operation is also compatible with composition, but it is contravariant, +which is to say, it reverses the order of the arguments.

+
section
+variable {α β γ : Type*} (F : Filter α) {m : γ → β} {n : β → α}
+
+#check (comap_comap : comap m (comap n F) = comap (n ∘ m) F)
+
+end
+
+
+

Let’s now shift attention to the plane ℝ × ℝ and try to understand how the neighborhoods of a point +(x₀, y₀) are related to 𝓝 x₀ and 𝓝 y₀. There is a product operation +Filter.prod : Filter X → Filter Y → Filter (X × Y), denoted by ×ˢ, which answers this question:

+
example : 𝓝 (x₀, y₀) = 𝓝 x₀ ×ˢ 𝓝 y₀ :=
+  nhds_prod_eq
+
+
+

The product operation is defined in terms of the pullback operation and the inf operation:

+
+

F ×ˢ G = (comap Prod.fst F) ⊓ (comap Prod.snd G).

+
+

Here the inf operation refers to the lattice structure on Filter X for any type X, whereby +F ⊓ G is the greatest filter that is smaller than both F and G. +Thus the inf operation generalizes the notion of the intersection of sets.

+

A lot of proofs in Mathlib use all of the aforementioned structure (map, comap, inf, sup, and prod) +to give algebraic proofs about convergence without ever referring to members of filters. +You can practice doing this in a proof of the following lemma, unfolding the definition of Tendsto +and Filter.prod if needed.

+
#check le_inf_iff
+
+example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) :
+    Tendsto f atTop (𝓝 (x₀, y₀)) ↔
+      Tendsto (Prod.fst ∘ f) atTop (𝓝 x₀) ∧ Tendsto (Prod.snd ∘ f) atTop (𝓝 y₀) :=
+  sorry
+
+
+

The ordered type Filter X is actually a complete lattice, +which is to say, there is a bottom element, there is a top element, and +every set of filters on X has an Inf and a Sup.

+

Note that given the second property in the definition of a filter +(if U belongs to F then anything larger than U also belongs to F), +the first property +(the set of all inhabitants of X belongs to F) is +equivalent to the property that F is not the empty collection of sets. +This shouldn’t be confused with the more subtle question as to whether +the empty set is an element of F. The +definition of a filter does not prohibit ∅ ∈ F, +but if the empty set is in F then +every set is in F, which is to say, ∀ U : Set X, U ∈ F. +In this case, F is a rather trivial filter, which is precisely the +bottom element of the complete lattice Filter X. +This contrasts with the definition of filters in +Bourbaki, which doesn’t allow filters containing the empty set.

+

Because we include the trivial filter in our definition, we sometimes need to explicitly assume +nontriviality in some lemmas. +In return, however, the theory has nicer global properties. +We have already seen that including the trivial filter gives us a +bottom element. It also allows us to define principal : Set X → Filter X, +which maps ∅ to ⊥, without adding a precondition to rule out the empty set. +And it allows us to define the pullback operation without a precondition as well. +Indeed, it can happen that comap f F = ⊥ although F ≠ ⊥. For instance, +given x₀ : ℝ and s : Set ℝ, the pullback of 𝓝 x₀ under the coercion +from the subtype corresponding to s is nontrivial if and only if x₀ belongs to the +closure of s.

+

In order to manage lemmas that do need to assume some filter is nontrivial, Mathlib has +a type class Filter.NeBot, and the library has lemmas that assume +(F : Filter X) [F.NeBot]. The instance database knows, for example, that (atTop : Filter ℕ).NeBot, +and it knows that pushing forward a nontrivial filter gives a nontrivial filter. +As a result, a lemma assuming [F.NeBot] will automatically apply to map u atTop for any sequence u.

+

Our tour of the algebraic properties of filters and their relation to limits is essentially done, +but we have not yet justified our claim to have recaptured the usual limit notions. +Superficially, it may seem that Tendsto u atTop (𝓝 x₀) +is stronger than the notion of convergence defined in Section 3.6 because we ask that every neighborhood of x₀ +has a preimage belonging to atTop, whereas the usual definition only requires +this for the standard neighborhoods Ioo (x₀ - ε) (x₀ + ε). +The key is that, by definition, every neighborhood contains such a standard one. +This observation leads to the notion of a filter basis.

+

Given F : Filter X, +a family of sets s : ι → Set X is a basis for F if for every set U, +we have U ∈ F if and only if it contains some s i. In other words, formally speaking, +s is a basis if it satisfies +∀ U : Set X, U ∈ F ↔ ∃ i, s i ⊆ U. It is even more flexible to consider +a predicate on ι that selects only some of the values i in the indexing type. +In the case of 𝓝 x₀, we want ι to be ℝ, we write ε for i, and the predicate should select the positive values of ε. +So the fact that the sets Ioo  (x₀ - ε) (x₀ + ε) form a basis for the +neighborhood topology on ℝ is stated as follows:

+
example (x₀ : ℝ) : HasBasis (𝓝 x₀) (fun ε : ℝ ↦ 0 < ε) fun ε ↦ Ioo (x₀ - ε) (x₀ + ε) :=
+  nhds_basis_Ioo_pos x₀
+
+
+

There is also a nice basis for the filter atTop. The lemma +Filter.HasBasis.tendsto_iff allows +us to reformulate a statement of the form Tendsto f F G +given bases for F and G. +Putting these pieces together gives us essentially the notion of convergence +that we used in Section 3.6.

+
example (u : ℕ → ℝ) (x₀ : ℝ) :
+    Tendsto u atTop (𝓝 x₀) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, u n ∈ Ioo (x₀ - ε) (x₀ + ε) := by
+  have : atTop.HasBasis (fun _ : ℕ ↦ True) Ici := atTop_basis
+  rw [this.tendsto_iff (nhds_basis_Ioo_pos x₀)]
+  simp
+
+
+

We now show how filters facilitate working with properties that hold for sufficiently large numbers +or for points that are sufficiently close to a given point. In Section 3.6, we were often faced with the situation where +we knew that some property P n holds for sufficiently large n and that some +other property Q n holds for sufficiently large n. +Using cases twice gave us N_P and N_Q satisfying +∀ n ≥ N_P, P n and ∀ n ≥ N_Q, Q n. Using set N := max N_P N_Q, we could +eventually prove ∀ n ≥ N, P n ∧ Q n. +Doing this repeatedly becomes tiresome.

+

We can do better by noting that the statement “P n and Q n hold for large enough n” means +that we have {n | P n} ∈ atTop and {n | Q n} ∈ atTop. +The fact that atTop is a filter implies that the intersection of two elements of atTop +is again in atTop, so we have {n | P n ∧ Q n} ∈ atTop. +Writing {n | P n} ∈ atTop is unpleasant, +but we can use the more suggestive notation ∀ᶠ n in atTop, P n. +Here the superscripted f stands for “Filter.” +You can think of the notation as saying that for all n in the “set of very large numbers,” P n holds. The ∀ᶠ +notation stands for Filter.Eventually, and the lemma Filter.Eventually.and uses the intersection property of filters to do what we just described:

+
example (P Q : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n) :
+    ∀ᶠ n in atTop, P n ∧ Q n :=
+  hP.and hQ
+
+
+

This notation is so convenient and intuitive that we also have specializations +when P is an equality or inequality statement. For example, let u and v be +two sequences of real numbers, and let us show that if +u n and v n coincide for sufficiently large n then +u tends to x₀ if and only if v tends to x₀. +First we’ll use the generic Eventually and then the one +specialized for the equality predicate, EventuallyEq. The two statements are +definitionally equivalent so the same proof work in both cases.

+
example (u v : ℕ → ℝ) (h : ∀ᶠ n in atTop, u n = v n) (x₀ : ℝ) :
+    Tendsto u atTop (𝓝 x₀) ↔ Tendsto v atTop (𝓝 x₀) :=
+  tendsto_congr' h
+
+example (u v : ℕ → ℝ) (h : u =ᶠ[atTop] v) (x₀ : ℝ) :
+    Tendsto u atTop (𝓝 x₀) ↔ Tendsto v atTop (𝓝 x₀) :=
+  tendsto_congr' h
+
+
+

It is instructive to review the definition of filters in terms of Eventually. +Given F : Filter X, for any predicates P and Q on X,

+
    +
  • the condition univ ∈ F ensures (∀ x, P x) → ∀ᶠ x in F, P x,

  • +
  • the condition U ∈ F → U ⊆ V → V ∈ F ensures (∀ᶠ x in F, P x) → (∀ x, P x → Q x) → ∀ᶠ x in F, Q x, and

  • +
  • the condition U ∈ F → V ∈ F → U ∩ V ∈ F ensures (∀ᶠ x in F, P x) → (∀ᶠ x in F, Q x) → ∀ᶠ x in F, P x ∧ Q x.

  • +
+
#check Eventually.of_forall
+#check Eventually.mono
+#check Eventually.and
+
+
+

The second item, corresponding to Eventually.mono, supports nice ways +of using filters, especially when combined +with Eventually.and. The filter_upwards tactic allows us to combine them. +Compare:

+
example (P Q R : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n)
+    (hR : ∀ᶠ n in atTop, P n ∧ Q n → R n) : ∀ᶠ n in atTop, R n := by
+  apply (hP.and (hQ.and hR)).mono
+  rintro n ⟨h, h', h''⟩
+  exact h'' ⟨h, h'⟩
+
+example (P Q R : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n)
+    (hR : ∀ᶠ n in atTop, P n ∧ Q n → R n) : ∀ᶠ n in atTop, R n := by
+  filter_upwards [hP, hQ, hR] with n h h' h''
+  exact h'' ⟨h, h'⟩
+
+
+

Readers who know about measure theory will note that the filter μ.ae of sets whose complement has measure zero +(aka “the set consisting of almost every point”) is not very useful as the source or target of Tendsto, but it can be conveniently +used with Eventually to say that a property holds for almost every point.

+

There is a dual version of ∀ᶠ x in F, P x, which is occasionally useful: +∃ᶠ x in F, P x means +{x | ¬P x} ∉ F. For example, ∃ᶠ n in atTop, P n means there are arbitrarily large n such that P n holds. +The ∃ᶠ notation stands for Filter.Frequently.

+

For a more sophisticated example, consider the following statement about a sequence +u, a set M, and a value x:

+
+

If u converges to x and u n belongs to M for +sufficiently large n then x is in the closure of M.

+
+

This can be formalized as follows:

+
+

Tendsto u atTop (𝓝 x) → (∀ᶠ n in atTop, u n ∈ M) → x ∈ closure M.

+
+

This is a special case of the theorem mem_closure_of_tendsto from the +topology library. +See if you can prove it using the quoted lemmas, +using the fact that ClusterPt x F means (𝓝 x ⊓ F).NeBot and that, +by definition, the assumption ∀ᶠ n in atTop, u n ∈ M means M ∈ map u atTop.

+
#check mem_closure_iff_clusterPt
+#check le_principal_iff
+#check neBot_of_le
+
+example (u : ℕ → ℝ) (M : Set ℝ) (x : ℝ) (hux : Tendsto u atTop (𝓝 x))
+    (huM : ∀ᶠ n in atTop, u n ∈ M) : x ∈ closure M :=
+  sorry
+
+
+
+
+

11.2. Metric spaces

+

Examples in the previous section focus on sequences of real numbers. In this section we will go up a bit in generality and focus on +metric spaces. A metric space is a type X equipped with a distance function dist : X → X → ℝ which is a generalization of +the function fun x y ↦ |x - y| from the case where X = ℝ.

+

Introducing such a space is easy and we will check all properties required from the distance function.

+
variable {X : Type*} [MetricSpace X] (a b c : X)
+
+#check (dist a b : ℝ)
+#check (dist_nonneg : 0 ≤ dist a b)
+#check (dist_eq_zero : dist a b = 0 ↔ a = b)
+#check (dist_comm a b : dist a b = dist b a)
+#check (dist_triangle a b c : dist a c ≤ dist a b + dist b c)
+
+
+

Note we also have variants where the distance can be infinite or where dist a b can be zero without having a = b or both. +They are called EMetricSpace, PseudoMetricSpace and PseudoEMetricSpace respectively (here “e” stands for “extended”).

+

Note that our journey from ℝ to metric spaces jumped over the special case of normed spaces that also require linear algebra and +will be explained as part of the calculus chapter.

+
+

11.2.1. Convergence and continuity

+

Using distance functions, we can already define convergent sequences and continuous functions between metric spaces. +They are actually defined in a more general setting covered in the next section, +but we have lemmas recasting the definition in terms of distances.

+
example {u : ℕ → X} {a : X} :
+    Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) a < ε :=
+  Metric.tendsto_atTop
+
+example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} :
+    Continuous f ↔
+      ∀ x : X, ∀ ε > 0, ∃ δ > 0, ∀ x', dist x' x < δ → dist (f x') (f x) < ε :=
+  Metric.continuous_iff
+
+
+

A lot of lemmas have some continuity assumptions, so we end up proving a lot of continuity results and there +is a continuity tactic devoted to this task. Let’s prove a continuity statement that will be needed +in an exercise below. Notice that Lean knows how to treat a product of two metric spaces as a metric space; +it chooses the sup norm, so dist (x₁, y₁) (x₂, y₂) = max (dist x₁ x₂) (dist y₁ y₂) holds by +reflexivity. As a result, it makes sense to consider continuous functions from X × X to ℝ. +In particular the (uncurried version of the) distance function is such a function.

+
example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) :
+    Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := by continuity
+
+
+

This tactic is a bit slow, so it is also useful to know +how to do it by hand. We first need to use that fun p : X × X ↦ f p.1 is continuous because it +is the composition of f, which is continuous by assumption hf, and the projection prod.fst whose continuity +is the content of the lemma continuous_fst. The composition property is Continuous.comp which is +in the Continuous namespace so we can use dot notation to compress +Continuous.comp hf continuous_fst into hf.comp continuous_fst which is actually more readable +since it really reads as composing our assumption and our lemma. +We can do the same for the second component to get continuity of fun p : X × X ↦ f p.2. We then assemble +those two continuities using Continuous.prod_mk to get +(hf.comp continuous_fst).prod_mk (hf.comp continuous_snd) : Continuous (fun p : X × X ↦ (f p.1, f p.2)) +and compose once more to get our full proof.

+
example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) :
+    Continuous fun p : X × X ↦ dist (f p.1) (f p.2) :=
+  continuous_dist.comp ((hf.comp continuous_fst).prodMk (hf.comp continuous_snd))
+
+
+

The combination of Continuous.prod_mk and continuous_dist via Continuous.comp feels clunky, +even when heavily using dot notation as above. A more serious issue is that this nice proof requires a lot of +planning. Lean accepts the above proof term because it is a full term proving a statement which is +definitionally equivalent to our goal, the crucial definition to unfold being that of a composition of functions. +Indeed our target function fun p : X × X ↦ dist (f p.1) (f p.2) is not presented as a composition. +The proof term we provided proves continuity of dist ∘ (fun p : X × X ↦ (f p.1, f p.2)) which happens +to be definitionally equal to our target function. But if we try to build this proof gradually using +tactics starting with apply continuous_dist.comp then Lean’s elaborator will fail to recognize a +composition and refuse to apply this lemma. It is especially bad at this when products of types are involved.

+

A better lemma to apply here is +Continuous.dist {f g : X → Y} : Continuous f → Continuous g → Continuous (fun x ↦ dist (f x) (g x)) +which is nicer to Lean’s elaborator and also provides a shorter proof when directly providing a full +proof term, as can be seen from the following two new proofs of the above statement:

+
example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) :
+    Continuous fun p : X × X ↦ dist (f p.1) (f p.2) := by
+  apply Continuous.dist
+  exact hf.comp continuous_fst
+  exact hf.comp continuous_snd
+
+example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) :
+    Continuous fun p : X × X ↦ dist (f p.1) (f p.2) :=
+  (hf.comp continuous_fst).dist (hf.comp continuous_snd)
+
+
+

Note that, without the elaboration issue coming from composition, another way to compress +our proof would be to use Continuous.prod_map which is sometimes useful and gives

+

Since it is sad to decide between a version which is better for elaboration and a version which is shorter +to type, let us wrap this discussion with a last bit of compression offered +by Continuous.fst' which allows to compress hf.comp continuous_fst to hf.fst' (and the same with snd) +and get our final proof, now bordering obfuscation.

+
example {X Y : Type*} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) :
+    Continuous fun p : X × X ↦ dist (f p.1) (f p.2) :=
+  hf.fst'.dist hf.snd'
+
+
+

It’s your turn now to prove some continuity lemma. After trying the continuity tactic, you will need +Continuous.add, continuous_pow and continuous_id to do it by hand.

+
example {f : ℝ → X} (hf : Continuous f) : Continuous fun x : ℝ ↦ f (x ^ 2 + x) :=
+  sorry
+
+
+

So far we saw continuity as a global notion, but one can also define continuity at a point.

+
example {X Y : Type*} [MetricSpace X] [MetricSpace Y] (f : X → Y) (a : X) :
+    ContinuousAt f a ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x}, dist x a < δ → dist (f x) (f a) < ε :=
+  Metric.continuousAt_iff
+
+
+
+
+

11.2.2. Balls, open sets and closed sets

+

Once we have a distance function, the most important geometric definitions are (open) balls and closed balls.

+
variable (r : ℝ)
+
+example : Metric.ball a r = { b | dist b a < r } :=
+  rfl
+
+example : Metric.closedBall a r = { b | dist b a ≤ r } :=
+  rfl
+
+
+

Note that r is any real number here, there is no sign restriction. Of course some statements do require a radius condition.

+
example (hr : 0 < r) : a ∈ Metric.ball a r :=
+  Metric.mem_ball_self hr
+
+example (hr : 0 ≤ r) : a ∈ Metric.closedBall a r :=
+  Metric.mem_closedBall_self hr
+
+
+

Once we have balls, we can define open sets. They are actually defined in a more general setting covered in the next section, +but we have lemmas recasting the definition in terms of balls.

+
example (s : Set X) : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, Metric.ball x ε ⊆ s :=
+  Metric.isOpen_iff
+
+
+

Then closed sets are sets whose complement is open. Their important property is they are closed under limits. The closure of a set is the smallest closed set containing it.

+
example {s : Set X} : IsClosed s ↔ IsOpen (sᶜ) :=
+  isOpen_compl_iff.symm
+
+example {s : Set X} (hs : IsClosed s) {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a))
+    (hus : ∀ n, u n ∈ s) : a ∈ s :=
+  hs.mem_of_tendsto hu (Eventually.of_forall hus)
+
+example {s : Set X} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, a ∈ Metric.ball b ε :=
+  Metric.mem_closure_iff
+
+
+

Do the next exercise without using mem_closure_iff_seq_limit

+
example {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) {s : Set X} (hs : ∀ n, u n ∈ s) :
+    a ∈ closure s := by
+  sorry
+
+
+

Remember from the filters sections that neighborhood filters play a big role in Mathlib. +In the metric space context, the crucial point is that balls provide bases for those filters. +The main lemmas here are Metric.nhds_basis_ball and Metric.nhds_basis_closedBall +that claim this for open and closed balls with positive radius. The center point is an implicit +argument so we can invoke Filter.HasBasis.mem_iff as in the following example.

+
example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.ball x ε ⊆ s :=
+  Metric.nhds_basis_ball.mem_iff
+
+example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.closedBall x ε ⊆ s :=
+  Metric.nhds_basis_closedBall.mem_iff
+
+
+
+
+

11.2.3. Compactness

+

Compactness is an important topological notion. It distinguishes subsets of a metric space +that enjoy the same kind of properties as segments in the reals compared to other intervals:

+
    +
  • Any sequence with values in a compact set has a subsequence that converges in this set.

  • +
  • Any continuous function on a nonempty compact set with values in real numbers is bounded and +attains its bounds somewhere (this is called the extreme value theorem).

  • +
  • Compact sets are closed sets.

  • +
+

Let us first check that the unit interval in the reals is indeed a compact set, and then check the above +claims for compact sets in general metric spaces. In the second statement we only +need continuity on the given set so we will use ContinuousOn instead of Continuous, and +we will give separate statements for the minimum and the maximum. Of course all these results +are deduced from more general versions, some of which will be discussed in later sections.

+
example : IsCompact (Set.Icc 0 1 : Set ℝ) :=
+  isCompact_Icc
+
+example {s : Set X} (hs : IsCompact s) {u : ℕ → X} (hu : ∀ n, u n ∈ s) :
+    ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) :=
+  hs.tendsto_subseq hu
+
+example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ}
+      (hfs : ContinuousOn f s) :
+    ∃ x ∈ s, ∀ y ∈ s, f x ≤ f y :=
+  hs.exists_isMinOn hs' hfs
+
+example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ}
+      (hfs : ContinuousOn f s) :
+    ∃ x ∈ s, ∀ y ∈ s, f y ≤ f x :=
+  hs.exists_isMaxOn hs' hfs
+
+example {s : Set X} (hs : IsCompact s) : IsClosed s :=
+  hs.isClosed
+
+
+

We can also specify that a metric spaces is globally compact, using an extra Prop-valued type class:

+
example {X : Type*} [MetricSpace X] [CompactSpace X] : IsCompact (univ : Set X) :=
+  isCompact_univ
+
+
+

In a compact metric space any closed set is compact, this is IsClosed.isCompact.

+
+
+

11.2.4. Uniformly continuous functions

+

We now turn to uniformity notions on metric spaces : uniformly continuous functions, Cauchy sequences and completeness. +Again those are defined in a more general context but we have lemmas in the metric name space to access their elementary definitions. +We start with uniform continuity.

+
example {X : Type*} [MetricSpace X] {Y : Type*} [MetricSpace Y] {f : X → Y} :
+    UniformContinuous f ↔
+      ∀ ε > 0, ∃ δ > 0, ∀ {a b : X}, dist a b < δ → dist (f a) (f b) < ε :=
+  Metric.uniformContinuous_iff
+
+
+

In order to practice manipulating all those definitions, we will prove that continuous +functions from a compact metric space to a metric space are uniformly continuous +(we will see a more general version in a later section).

+

We will first give an informal sketch. Let f : X → Y be a continuous function from +a compact metric space to a metric space. +We fix ε > 0 and start looking for some δ.

+

Let φ : X × X → ℝ := fun p ↦ dist (f p.1) (f p.2) and let K := { p : X × X | ε ≤ φ p }. +Observe φ is continuous since f and distance are continuous. +And K is clearly closed (use isClosed_le) hence compact since X is compact and +Lean knows that the product of compact spaces is compact.

+

Then we discuss two possibilities using eq_empty_or_nonempty. +If K is empty then we are clearly done (we can set δ = 1 for instance). +So let’s assume K is not empty, and use the extreme value theorem to choose (x₀, x₁) attaining the infimum +of the distance function on K. We can then set δ = dist x₀ x₁ and check everything works.

+
example {X : Type*} [MetricSpace X] [CompactSpace X]
+      {Y : Type*} [MetricSpace Y] {f : X → Y}
+    (hf : Continuous f) : UniformContinuous f := by
+  sorry
+
+
+
+
+

11.2.5. Completeness

+

A Cauchy sequence in a metric space is a sequence whose terms get closer and closer to each other. +There are a couple of equivalent ways to state that idea. +In particular converging sequences are Cauchy. The converse is true only in so-called complete +spaces.

+
example (u : ℕ → X) :
+    CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ m ≥ N, ∀ n ≥ N, dist (u m) (u n) < ε :=
+  Metric.cauchySeq_iff
+
+example (u : ℕ → X) :
+    CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, dist (u n) (u N) < ε :=
+  Metric.cauchySeq_iff'
+
+example [CompleteSpace X] (u : ℕ → X) (hu : CauchySeq u) :
+    ∃ x, Tendsto u atTop (𝓝 x) :=
+  cauchySeq_tendsto_of_complete hu
+
+
+

We’ll practice using this definition by proving a convenient criterion which is a special case of a +criterion appearing in Mathlib. This is also a good opportunity to practice using big sums in +a geometric context. In addition to the explanations from the filters section, you will probably need +tendsto_pow_atTop_nhds_zero_of_lt_one, Tendsto.mul and dist_le_range_sum_dist.

+
theorem cauchySeq_of_le_geometric_two' {u : ℕ → X}
+    (hu : ∀ n : ℕ, dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : CauchySeq u := by
+  rw [Metric.cauchySeq_iff']
+  intro ε ε_pos
+  obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε := by sorry
+  use N
+  intro n hn
+  obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn
+  calc
+    dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := sorry
+    _ ≤ ∑ i  ∈ range k, dist (u (N + i)) (u (N + (i + 1))) := sorry
+    _ ≤ ∑ i  ∈ range k, (1 / 2 : ℝ) ^ (N + i) := sorry
+    _ = 1 / 2 ^ N * ∑ i  ∈ range k, (1 / 2 : ℝ) ^ i := sorry
+    _ ≤ 1 / 2 ^ N * 2 := sorry
+    _ < ε := sorry
+
+
+

We are ready for the final boss of this section: Baire’s theorem for complete metric spaces! +The proof skeleton below shows interesting techniques. It uses the choose tactic in its exclamation +mark variant (you should experiment with removing this exclamation mark) and it shows how to +define something inductively in the middle of a proof using Nat.rec_on.

+
open Metric
+
+example [CompleteSpace X] (f : ℕ → Set X) (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) :
+    Dense (⋂ n, f n) := by
+  let B : ℕ → ℝ := fun n ↦ (1 / 2) ^ n
+  have Bpos : ∀ n, 0 < B n
+  sorry
+  /- Translate the density assumption into two functions `center` and `radius` associating
+    to any n, x, δ, δpos a center and a positive radius such that
+    `closedBall center radius` is included both in `f n` and in `closedBall x δ`.
+    We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/
+  have :
+    ∀ (n : ℕ) (x : X),
+      ∀ δ > 0, ∃ y : X, ∃ r > 0, r ≤ B (n + 1) ∧ closedBall y r ⊆ closedBall x δ ∩ f n :=
+    by sorry
+  choose! center radius Hpos HB Hball using this
+  intro x
+  rw [mem_closure_iff_nhds_basis nhds_basis_closedBall]
+  intro ε εpos
+  /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x`
+    belonging to all `f n`. For this, we construct inductively a sequence
+    `F n = (c n, r n)` such that the closed ball `closedBall (c n) (r n)` is included
+    in the previous ball and in `f n`, and such that `r n` is small enough to ensure
+    that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs
+    to all the `f n`. -/
+  let F : ℕ → X × ℝ := fun n ↦
+    Nat.recOn n (Prod.mk x (min ε (B 0)))
+      fun n p ↦ Prod.mk (center n p.1 p.2) (radius n p.1 p.2)
+  let c : ℕ → X := fun n ↦ (F n).1
+  let r : ℕ → ℝ := fun n ↦ (F n).2
+  have rpos : ∀ n, 0 < r n := by sorry
+  have rB : ∀ n, r n ≤ B n := by sorry
+  have incl : ∀ n, closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) ∩ f n := by
+    sorry
+  have cdist : ∀ n, dist (c n) (c (n + 1)) ≤ B n := by sorry
+  have : CauchySeq c := cauchySeq_of_le_geometric_two' cdist
+  -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`.
+  rcases cauchySeq_tendsto_of_complete this with ⟨y, ylim⟩
+  -- this point `y` will be the desired point. We will check that it belongs to all
+  -- `f n` and to `ball x ε`.
+  use y
+  have I : ∀ n, ∀ m ≥ n, closedBall (c m) (r m) ⊆ closedBall (c n) (r n) := by sorry
+  have yball : ∀ n, y ∈ closedBall (c n) (r n) := by sorry
+  sorry
+
+
+
+
+
+

11.3. Topological spaces

+
+

11.3.1. Fundamentals

+

We now go up in generality and introduce topological spaces. We will review the two main ways to define +topological spaces and then explain how the category of topological spaces is much better behaved than +the category of metric spaces. Note that we won’t be using Mathlib category theory here, only having +a somewhat categorical point of view.

+

The first way to think about the transition from metric spaces to topological spaces is that we only +remember the notion of open sets (or equivalently the notion of closed sets). From this point of view, +a topological space is a type equipped with a collection of sets that are called open sets. This collection +has to satisfy a number of axioms presented below (this collection is slightly redundant but we will ignore that).

+
section
+variable {X : Type*} [TopologicalSpace X]
+
+example : IsOpen (univ : Set X) :=
+  isOpen_univ
+
+example : IsOpen (∅ : Set X) :=
+  isOpen_empty
+
+example {ι : Type*} {s : ι → Set X} (hs : ∀ i, IsOpen (s i)) : IsOpen (⋃ i, s i) :=
+  isOpen_iUnion hs
+
+example {ι : Type*} [Fintype ι] {s : ι → Set X} (hs : ∀ i, IsOpen (s i)) :
+    IsOpen (⋂ i, s i) :=
+  isOpen_iInter_of_finite hs
+
+
+

Closed sets are then defined as sets whose complement is open. A function between topological spaces +is (globally) continuous if all preimages of open sets are open.

+
variable {Y : Type*} [TopologicalSpace Y]
+
+example {f : X → Y} : Continuous f ↔ ∀ s, IsOpen s → IsOpen (f ⁻¹' s) :=
+  continuous_def
+
+
+

With this definition we already see that, compared to metric spaces, topological spaces only remember +enough information to talk about continuous functions: two topological structures on a type are +the same if and only if they have the same continuous functions (indeed the identity function will +be continuous in both direction if and only if the two structures have the same open sets).

+

However as soon as we move on to continuity at a point we see the limitations of the approach based +on open sets. In Mathlib we frequently think of topological spaces as types equipped +with a neighborhood filter 𝓝 x attached to each point x (the corresponding function +X → Filter X satisfies certain conditions explained further down). Remember from the filters section that +these gadgets play two related roles. First 𝓝 x is seen as the generalized set of points of X +that are close to x. And then it is seen as giving a way to say, for any predicate P : X → Prop, +that this predicate holds for points that are close enough to x. Let us state +that f : X → Y is continuous at x. The purely filtery way is to say that the direct image under +f of the generalized set of points that are close to x is contained in the generalized set of +points that are close to f x. Recall this is spelled either map f (𝓝 x) ≤ 𝓝 (f x) +or Tendsto f (𝓝 x) (𝓝 (f x)).

+
example {f : X → Y} {x : X} : ContinuousAt f x ↔ map f (𝓝 x) ≤ 𝓝 (f x) :=
+  Iff.rfl
+
+
+

One can also spell it using both neighborhoods seen as ordinary sets and a neighborhood filter +seen as a generalized set: “for any neighborhood U of f x, all points close to x +are sent to U”. Note that the proof is again Iff.rfl, this point of view is definitionally +equivalent to the previous one.

+
example {f : X → Y} {x : X} : ContinuousAt f x ↔ ∀ U ∈ 𝓝 (f x), ∀ᶠ x in 𝓝 x, f x ∈ U :=
+  Iff.rfl
+
+
+

We now explain how to go from one point of view to the other. In terms of open sets, we can +simply define members of 𝓝 x as sets that contain an open set containing x.

+
example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t :=
+  mem_nhds_iff
+
+
+

To go in the other direction we need to discuss the condition that 𝓝 : X → Filter X must satisfy +in order to be the neighborhood function of a topology.

+

The first constraint is that 𝓝 x, seen as a generalized set, contains the set {x} seen as the generalized set +pure x (explaining this weird name would be too much of a digression, so we simply accept it for now). +Another way to say it is that if a predicate holds for points close to x then it holds at x.

+
example (x : X) : pure x ≤ 𝓝 x :=
+  pure_le_nhds x
+
+example (x : X) (P : X → Prop) (h : ∀ᶠ y in 𝓝 x, P y) : P x :=
+  h.self_of_nhds
+
+
+

Then a more subtle requirement is that, for any predicate P : X → Prop and any x, if P y holds for y close +to x then for y close to x and z close to y, P z holds. More precisely we have:

+
example {P : X → Prop} {x : X} (h : ∀ᶠ y in 𝓝 x, P y) : ∀ᶠ y in 𝓝 x, ∀ᶠ z in 𝓝 y, P z :=
+  eventually_eventually_nhds.mpr h
+
+
+

Those two results characterize the functions X → Filter X that are neighborhood functions for a topological space +structure on X. There is a still a function TopologicalSpace.mkOfNhds : (X → Filter X) → TopologicalSpace X +but it will give back its input as a neighborhood function only if it satisfies the above two constraints. +More precisely we have a lemma TopologicalSpace.nhds_mkOfNhds saying that in a different way and our +next exercise deduces this different way from how we stated it above.

+
example {α : Type*} (n : α → Filter α) (H₀ : ∀ a, pure a ≤ n a)
+    (H : ∀ a : α, ∀ p : α → Prop, (∀ᶠ x in n a, p x) → ∀ᶠ y in n a, ∀ᶠ x in n y, p x) :
+    ∀ a, ∀ s ∈ n a, ∃ t ∈ n a, t ⊆ s ∧ ∀ a' ∈ t, s ∈ n a' := by
+  sorry
+end
+
+
+

Note that TopologicalSpace.mkOfNhds is not so frequently used, but it still good to know in what +precise sense the neighborhood filters is all there is in a topological space structure.

+

The next thing to know in order to efficiently use topological spaces in Mathlib is that we use a lot +of formal properties of TopologicalSpace : Type u → Type u. From a purely mathematical point of view, +those formal properties are a very clean way to explain how topological spaces solve issues that metric spaces +have. From this point of view, the issues solved by topological spaces is that metric spaces enjoy very +little functoriality, and have very bad categorical properties in general. This comes on top of the fact +already discussed that metric spaces contain a lot of geometrical information that is not topologically relevant.

+

Let us focus on functoriality first. A metric space structure can be induced on a subset or, +equivalently, it can be pulled back by an injective map. But that’s pretty much everything. +They cannot be pulled back by general map or pushed forward, even by surjective maps.

+

In particular there is no sensible distance to put on a quotient of a metric space or on an uncountable +product of metric spaces. Consider for instance the type ℝ → ℝ, seen as +a product of copies of ℝ indexed by ℝ. We would like to say that pointwise convergence of +sequences of functions is a respectable notion of convergence. But there is no distance on +ℝ → ℝ that gives this notion of convergence. Relatedly, there is no distance ensuring that +a map f : X → (ℝ → ℝ) is continuous if and only if fun x ↦ f x t is continuous for every t : ℝ.

+

We now review the data used to solve all those issues. First we can use any map f : X → Y to +push or pull topologies from one side to the other. Those two operations form a Galois connection.

+
variable {X Y : Type*}
+
+example (f : X → Y) : TopologicalSpace X → TopologicalSpace Y :=
+  TopologicalSpace.coinduced f
+
+example (f : X → Y) : TopologicalSpace Y → TopologicalSpace X :=
+  TopologicalSpace.induced f
+
+example (f : X → Y) (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) :
+    TopologicalSpace.coinduced f T_X ≤ T_Y ↔ T_X ≤ TopologicalSpace.induced f T_Y :=
+  coinduced_le_iff_le_induced
+
+
+

Those operations are compatible with composition of functions. +As usual, pushing forward is covariant and pulling back is contravariant, see coinduced_compose and induced_compose. +On paper we will use notations \(f_*T\) for TopologicalSpace.coinduced f T and +\(f^*T\) for TopologicalSpace.induced f T.

+

Then the next big piece is a complete lattice structure on TopologicalSpace X +for any given X. If you think of topologies as being primarily the data of open sets then you expect +the order relation on TopologicalSpace X to come from Set (Set X), i.e. you expect t ≤ t' +if a set u is open for t' as soon as it is open for t. However we already know that Mathlib focuses +on neighborhoods more than open sets so, for any x : X we want the map from topological spaces to neighborhoods +fun T : TopologicalSpace X ↦ @nhds X T x to be order preserving. +And we know the order relation on Filter X is designed to ensure an order +preserving principal : Set X → Filter X, allowing to see filters as generalized sets. +So the order relation we do use on TopologicalSpace X is opposite to the one coming from Set (Set X).

+
example {T T' : TopologicalSpace X} : T ≤ T' ↔ ∀ s, T'.IsOpen s → T.IsOpen s :=
+  Iff.rfl
+
+
+

Now we can recover continuity by combining the push-forward (or pull-back) operation with the order relation.

+
example (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) (f : X → Y) :
+    Continuous f ↔ TopologicalSpace.coinduced f T_X ≤ T_Y :=
+  continuous_iff_coinduced_le
+
+
+

With this definition and the compatibility of push-forward and composition, we +get for free the universal property that, for any topological space \(Z\), +a function \(g : Y → Z\) is continuous for the topology \(f_*T_X\) if and only if +\(g ∘ f\) is continuous.

+
+\[\begin{split}g \text{ continuous } &⇔ g_*(f_*T_X) ≤ T_Z \\ +&⇔ (g ∘ f)_* T_X ≤ T_Z \\ +&⇔ g ∘ f \text{ continuous}\end{split}\]
+
example {Z : Type*} (f : X → Y) (T_X : TopologicalSpace X) (T_Z : TopologicalSpace Z)
+      (g : Y → Z) :
+    @Continuous Y Z (TopologicalSpace.coinduced f T_X) T_Z g ↔
+      @Continuous X Z T_X T_Z (g ∘ f) := by
+  rw [continuous_iff_coinduced_le, coinduced_compose, continuous_iff_coinduced_le]
+
+
+

So we already get quotient topologies (using the projection map as f). This wasn’t using that +TopologicalSpace X is a complete lattice for all X. Let’s now see how all this structure +proves the existence of the product topology by abstract non-sense. +We considered the case of ℝ → ℝ above, but let’s now consider the general case of Π i, X i for +some ι : Type* and X : ι → Type*. We want, for any topological space Z and any function +f : Z → Π i, X i, that f is continuous if and only if (fun x ↦ x i) ∘ f is continuous for all i. +Let us explore that constraint “on paper” using notation \(p_i\) for the projection +(fun (x : Π i, X i) ↦ x i):

+
+\[\begin{split}(∀ i, p_i ∘ f \text{ continuous}) &⇔ ∀ i, (p_i ∘ f)_* T_Z ≤ T_{X_i} \\ +&⇔ ∀ i, (p_i)_* f_* T_Z ≤ T_{X_i}\\ +&⇔ ∀ i, f_* T_Z ≤ (p_i)^*T_{X_i}\\ +&⇔ f_* T_Z ≤ \inf \left[(p_i)^*T_{X_i}\right]\end{split}\]
+

So we see that what is the topology we want on Π i, X i:

+
example (ι : Type*) (X : ι → Type*) (T_X : ∀ i, TopologicalSpace (X i)) :
+    (Pi.topologicalSpace : TopologicalSpace (∀ i, X i)) =
+      ⨅ i, TopologicalSpace.induced (fun x ↦ x i) (T_X i) :=
+  rfl
+
+
+

This ends our tour of how Mathlib thinks that topological spaces fix defects of the theory of metric spaces +by being a more functorial theory and having a complete lattice structure for any fixed type.

+
+
+

11.3.2. Separation and countability

+

We saw that the category of topological spaces have very nice properties. The price to pay for +this is existence of rather pathological topological spaces. +There are a number of assumptions you can make on a topological space to ensure its behavior +is closer to what metric spaces do. The most important is T2Space, also called “Hausdorff”, +that will ensure that limits are unique. +A stronger separation property is T3Space that ensures in addition the RegularSpace property: +each point has a basis of closed neighborhoods.

+
example [TopologicalSpace X] [T2Space X] {u : ℕ → X} {a b : X} (ha : Tendsto u atTop (𝓝 a))
+    (hb : Tendsto u atTop (𝓝 b)) : a = b :=
+  tendsto_nhds_unique ha hb
+
+example [TopologicalSpace X] [RegularSpace X] (a : X) :
+    (𝓝 a).HasBasis (fun s : Set X ↦ s ∈ 𝓝 a ∧ IsClosed s) id :=
+  closed_nhds_basis a
+
+
+

Note that, in every topological space, each point has a basis of open neighborhood, by definition.

+
example [TopologicalSpace X] {x : X} :
+    (𝓝 x).HasBasis (fun t : Set X ↦ t ∈ 𝓝 x ∧ IsOpen t) id :=
+  nhds_basis_opens' x
+
+
+

Our main goal is now to prove the basic theorem which allows extension by continuity. +From Bourbaki’s general topology book, I.8.5, Theorem 1 (taking only the non-trivial implication):

+

Let \(X\) be a topological space, \(A\) a dense subset of \(X\), \(f : A → Y\) +a continuous mapping of \(A\) into a \(T_3\) space \(Y\). If, for each \(x\) in +\(X\), \(f(y)\) tends to a limit in \(Y\) when \(y\) tends to \(x\) +while remaining in \(A\) then there exists a continuous extension \(φ\) of \(f\) to +\(X\).

+

Actually Mathlib contains a more general version of the above lemma, IsDenseInducing.continuousAt_extend, +but we’ll stick to Bourbaki’s version here.

+

Remember that, given A : Set X, ↥A is the subtype associated to A, and Lean will automatically +insert that funny up arrow when needed. And the (inclusion) coercion map is (↑) : A → X. +The assumption “tends to \(x\) while remaining in \(A\)” corresponds to the pull-back filter +comap (↑) (𝓝 x).

+

Let’s first prove an auxiliary lemma, extracted to simplify the context +(in particular we don’t need Y to be a topological space here).

+
theorem aux {X Y A : Type*} [TopologicalSpace X] {c : A → X}
+      {f : A → Y} {x : X} {F : Filter Y}
+      (h : Tendsto f (comap c (𝓝 x)) F) {V' : Set Y} (V'_in : V' ∈ F) :
+    ∃ V ∈ 𝓝 x, IsOpen V ∧ c ⁻¹' V ⊆ f ⁻¹' V' := by
+  sorry
+
+
+

Let’s now turn to the main proof of the extension by continuity theorem.

+

When Lean needs a topology on ↥A it will automatically use the induced topology. +The only relevant lemma is +nhds_induced (↑) : ∀ a : ↥A, 𝓝 a = comap (↑) (𝓝 ↑a) +(this is actually a general lemma about induced topologies).

+

The proof outline is:

+

The main assumption and the axiom of choice give a function φ such that +∀ x, Tendsto f (comap (↑) (𝓝 x)) (𝓝 (φ x)) +(because Y is Hausdorff, φ is entirely determined, but we won’t need that until we try to +prove that φ indeed extends f).

+

Let’s first prove φ is continuous. Fix any x : X. +Since Y is regular, it suffices to check that for every closed neighborhood +V' of φ x, φ ⁻¹' V' ∈ 𝓝 x. +The limit assumption gives (through the auxiliary lemma above) +some V ∈ 𝓝 x such IsOpen V ∧ (↑) ⁻¹' V ⊆ f ⁻¹' V'. +Since V ∈ 𝓝 x, it suffices to prove V ⊆ φ ⁻¹' V', i.e. ∀ y ∈ V, φ y ∈ V'. +Let’s fix y in V. Because V is open, it is a neighborhood of y. +In particular (↑) ⁻¹' V ∈ comap (↑) (𝓝 y) and a fortiori f ⁻¹' V' ∈ comap (↑) (𝓝 y). +In addition comap (↑) (𝓝 y) ≠ ⊥ because A is dense. +Because we know Tendsto f (comap (↑) (𝓝 y)) (𝓝 (φ y)) this implies +φ y ∈ closure V' and, since V' is closed, we have proved φ y ∈ V'.

+

It remains to prove that φ extends f. This is where the continuity of f enters the +discussion, together with the fact that Y is Hausdorff.

+
example [TopologicalSpace X] [TopologicalSpace Y] [T3Space Y] {A : Set X}
+    (hA : ∀ x, x ∈ closure A) {f : A → Y} (f_cont : Continuous f)
+    (hf : ∀ x : X, ∃ c : Y, Tendsto f (comap (↑) (𝓝 x)) (𝓝 c)) :
+    ∃ φ : X → Y, Continuous φ ∧ ∀ a : A, φ a = f a := by
+  sorry
+
+#check HasBasis.tendsto_right_iff
+
+
+

In addition to separation property, the main kind of assumption you can make on a topological +space to bring it closer to metric spaces is countability assumption. The main one is first countability +asking that every point has a countable neighborhood basis. In particular this ensures that closure +of sets can be understood using sequences.

+
example [TopologicalSpace X] [FirstCountableTopology X]
+      {s : Set X} {a : X} :
+    a ∈ closure s ↔ ∃ u : ℕ → X, (∀ n, u n ∈ s) ∧ Tendsto u atTop (𝓝 a) :=
+  mem_closure_iff_seq_limit
+
+
+
+
+

11.3.3. Compactness

+

Let us now discuss how compactness is defined for topological spaces. As usual there are several ways +to think about it and Mathlib goes for the filter version.

+

We first need to define cluster points of filters. Given a filter F on a topological space X, +a point x : X is a cluster point of F if F, seen as a generalized set, has non-empty intersection +with the generalized set of points that are close to x.

+

Then we can say that a set s is compact if every nonempty generalized set F contained in s, +i.e. such that F ≤ 𝓟 s, has a cluster point in s.

+
variable [TopologicalSpace X]
+
+example {F : Filter X} {x : X} : ClusterPt x F ↔ NeBot (𝓝 x ⊓ F) :=
+  Iff.rfl
+
+example {s : Set X} :
+    IsCompact s ↔ ∀ (F : Filter X) [NeBot F], F ≤ 𝓟 s → ∃ a ∈ s, ClusterPt a F :=
+  Iff.rfl
+
+
+

For instance if F is map u atTop, the image under u : ℕ → X of atTop, the generalized set +of very large natural numbers, then the assumption F ≤ 𝓟 s means that u n belongs to s for n +large enough. Saying that x is a cluster point of map u atTop says the image of very large numbers +intersects the set of points that are close to x. In case 𝓝 x has a countable basis, we can +interpret this as saying that u has a subsequence converging to x, and we get back what compactness +looks like in metric spaces.

+
example [FirstCountableTopology X] {s : Set X} {u : ℕ → X} (hs : IsCompact s)
+    (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) :=
+  hs.tendsto_subseq hu
+
+
+

Cluster points behave nicely with continuous functions.

+
variable [TopologicalSpace Y]
+
+example {x : X} {F : Filter X} {G : Filter Y} (H : ClusterPt x F) {f : X → Y}
+    (hfx : ContinuousAt f x) (hf : Tendsto f F G) : ClusterPt (f x) G :=
+  ClusterPt.map H hfx hf
+
+
+

As an exercise, we will prove that the image of a compact set under a continuous map is +compact. In addition to what we saw already, you should use Filter.push_pull, +map_principal, inf_of_le_right and NeBot.of_map.

+
example {f : X → Y} (hf : Continuous f) {s : Set X} (hs : IsCompact s) :
+    IsCompact (f '' s) := by
+  intro F F_ne F_le
+  have map_eq : map f (𝓟 s ⊓ comap f F) = 𝓟 (f '' s) ⊓ F := by
+    sorry
+  have Hne : (𝓟 s ⊓ comap f F).NeBot := by
+    sorry
+  have Hle : 𝓟 s ⊓ comap f F ≤ 𝓟 s := inf_le_left
+  sorry
+
+
+

One can also express compactness in terms of open covers: s is compact if every family of open sets that +cover s has a finite covering sub-family.

+
example {ι : Type*} {s : Set X} (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i))
+    (hsU : s ⊆ ⋃ i, U i) : ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i :=
+  hs.elim_finite_subcover U hUo hsU
+
+
+
+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C12_Differential_Calculus.html b/dev/vendor/mathematics_in_lean/html/C12_Differential_Calculus.html new file mode 100644 index 0000000..1ae3e40 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C12_Differential_Calculus.html @@ -0,0 +1,485 @@ + + + + + + + + + 12. Differential Calculus — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

12. Differential Calculus

+

We now consider the formalization of notions from analysis, +starting with differentiation in this chapter +and turning integration and measure theory in the next. +In Section 12.1, we stick with the +setting of functions from the real numbers to the real numbers, +which is familiar from any introductory calculus class. +In Section 12.2, we then consider the notion of a derivative in +a much broader setting.

+
+

12.1. Elementary Differential Calculus

+

Let f be a function from the reals to the reals. There is a difference +between talking about the derivative of f at a single point and +talking about the derivative function. +In Mathlib, the first notion is represented as follows.

+
open Real
+
+/-- The sin function has derivative 1 at 0. -/
+example : HasDerivAt sin 1 0 := by simpa using hasDerivAt_sin 0
+
+
+

We can also express that f is differentiable at a point without +specifying its derivative there +by writing DifferentiableAt ℝ. +We specify ℝ explicitly because in a slightly more general context, +when talking about functions from ℂ to ℂ, +we want to be able to distinguish between being differentiable in the real sense +and being differentiable in the sense of the complex derivative.

+
example (x : ℝ) : DifferentiableAt ℝ sin x :=
+  (hasDerivAt_sin x).differentiableAt
+
+
+

It would be inconvenient to have to provide a proof of differentiability +every time we want to refer to a derivative. +So Mathlib provides a function deriv f : ℝ → ℝ that is defined for any +function f : ℝ → ℝ +but is defined to take the value 0 at any point where f is not differentiable.

+
example {f : ℝ → ℝ} {x a : ℝ} (h : HasDerivAt f a x) : deriv f x = a :=
+  h.deriv
+
+example {f : ℝ → ℝ} {x : ℝ} (h : ¬DifferentiableAt ℝ f x) : deriv f x = 0 :=
+  deriv_zero_of_not_differentiableAt h
+
+
+

Of course there are many lemmas about deriv that do require differentiability assumptions. +For instance, you should think about a counterexample to the next lemma without the +differentiability assumptions.

+
example {f g : ℝ → ℝ} {x : ℝ} (hf : DifferentiableAt ℝ f x) (hg : DifferentiableAt ℝ g x) :
+    deriv (f + g) x = deriv f x + deriv g x :=
+  deriv_add hf hg
+
+
+

Interestingly, however, there are statements that can avoid differentiability +assumptions by taking advantage +of the fact that the value of deriv defaults to zero when the function is +not differentiable. +So making sense of the following statement requires knowing the precise +definition of deriv.

+
example {f : ℝ → ℝ} {a : ℝ} (h : IsLocalMin f a) : deriv f a = 0 := by
+  exact?
+  --h.deriv_eq_zero
+
+
+

We can even state Rolle’s theorem without any differentiability assumptions, which +seems even weirder.

+
open Set
+
+example {f : ℝ → ℝ} {a b : ℝ} (hab : a < b) (hfc : ContinuousOn f (Icc a b)) (hfI : f a = f b) :
+    ∃ c ∈ Ioo a b, deriv f c = 0 :=
+  exists_deriv_eq_zero hab hfc hfI
+
+
+

Of course, this trick does not work for the general mean value theorem.

+
example (f : ℝ → ℝ) {a b : ℝ} (hab : a < b) (hf : ContinuousOn f (Icc a b))
+    (hf' : DifferentiableOn ℝ f (Ioo a b)) : ∃ c ∈ Ioo a b, deriv f c = (f b - f a) / (b - a) :=
+  exists_deriv_eq_slope f hab hf hf'
+
+
+

Lean can automatically compute some simple derivatives using the simp tactic.

+
example : deriv (fun x : ℝ ↦ x ^ 5) 6 = 5 * 6 ^ 4 := by simp
+
+example : deriv sin π = -1 := by simp
+
+
+
+
+

12.2. Differential Calculus in Normed Spaces

+
+

12.2.1. Normed spaces

+

Differentiation can be generalized beyond ℝ using the notion of a +normed vector space, which encapsulates both direction and distance. +We start with the notion of a normed group, which is an additive commutative +group equipped with a real-valued norm function +satisfying the following conditions.

+
variable {E : Type*} [NormedAddCommGroup E]
+
+example (x : E) : 0 ≤ ‖x‖ :=
+  norm_nonneg x
+
+example {x : E} : ‖x‖ = 0 ↔ x = 0 :=
+  norm_eq_zero
+
+example (x y : E) : ‖x + y‖ ≤ ‖x‖ + ‖y‖ :=
+  norm_add_le x y
+
+
+

Every normed space is a metric space with distance function +\(d(x, y) = \| x - y \|\), and hence it is also a topological space. +Lean and Mathlib know this.

+
example : MetricSpace E := by infer_instance
+
+example {X : Type*} [TopologicalSpace X] {f : X → E} (hf : Continuous f) :
+    Continuous fun x ↦ ‖f x‖ :=
+  hf.norm
+
+
+

In order to use the notion of a norm with concepts from linear algebra, +we add the assumption NormedSpace ℝ E on top of NormedAddGroup E. +This stipulates that E is a vector space over ℝ and that +scalar multiplication satisfies the following condition.

+
variable [NormedSpace ℝ E]
+
+example (a : ℝ) (x : E) : ‖a • x‖ = |a| * ‖x‖ :=
+  norm_smul a x
+
+
+

A complete normed space is known as a Banach space. +Every finite-dimensional vector space is complete.

+
example [FiniteDimensional ℝ E] : CompleteSpace E := by infer_instance
+
+
+

In all the previous examples, we used the real numbers as the base field. +More generally, we can make sense of calculus with a vector space over any +nontrivially normed field. These are fields that are equipped with a +real-valued norm that is multiplicative and has the property that +not every element has norm zero or one +(equivalently, there is an element whose norm is bigger than one).

+
example (𝕜 : Type*) [NontriviallyNormedField 𝕜] (x y : 𝕜) : ‖x * y‖ = ‖x‖ * ‖y‖ :=
+  norm_mul x y
+
+example (𝕜 : Type*) [NontriviallyNormedField 𝕜] : ∃ x : 𝕜, 1 < ‖x‖ :=
+  NormedField.exists_one_lt_norm 𝕜
+
+
+

A finite-dimensional vector space over a nontrivially normed field is +complete as long as the field itself is complete.

+
example (𝕜 : Type*) [NontriviallyNormedField 𝕜] (E : Type*) [NormedAddCommGroup E]
+    [NormedSpace 𝕜 E] [CompleteSpace 𝕜] [FiniteDimensional 𝕜 E] : CompleteSpace E :=
+  FiniteDimensional.complete 𝕜 E
+
+
+
+
+

12.2.2. Continuous linear maps

+

We now turn to the morphisms in the category of normed spaces, namely, +continuous linear maps. +In Mathlib, the type of 𝕜-linear continuous maps between normed spaces +E and F is written E →L[𝕜] F. +They are implemented as bundled maps, which means that an element of this type +is a structure that that includes the function itself and the properties +of being linear and continuous. +Lean will insert a coercion so that a continuous linear map can be treated +as a function.

+
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
+  [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
+
+example : E →L[𝕜] E :=
+  ContinuousLinearMap.id 𝕜 E
+
+example (f : E →L[𝕜] F) : E → F :=
+  f
+
+example (f : E →L[𝕜] F) : Continuous f :=
+  f.cont
+
+example (f : E →L[𝕜] F) (x y : E) : f (x + y) = f x + f y :=
+  f.map_add x y
+
+example (f : E →L[𝕜] F) (a : 𝕜) (x : E) : f (a • x) = a • f x :=
+  f.map_smul a x
+
+
+

Continuous linear maps have an operator norm that is characterized by the +following properties.

+
variable (f : E →L[𝕜] F)
+
+example (x : E) : ‖f x‖ ≤ ‖f‖ * ‖x‖ :=
+  f.le_opNorm x
+
+example {M : ℝ} (hMp : 0 ≤ M) (hM : ∀ x, ‖f x‖ ≤ M * ‖x‖) : ‖f‖ ≤ M :=
+  f.opNorm_le_bound hMp hM
+
+
+

There is also a notion of bundled continuous linear isomorphism. +Their type of such isomorphisms is E ≃L[𝕜] F.

+

As a challenging exercise, you can prove the Banach-Steinhaus theorem, also +known as the Uniform Boundedness Principle. +The principle states that a family of continuous linear maps from a Banach space +into a normed space is pointwise +bounded, then the norms of these linear maps are uniformly bounded. +The main ingredient is Baire’s theorem +nonempty_interior_of_iUnion_of_closed. (You proved a version of this in the topology chapter.) +Minor ingredients include continuous_linear_map.opNorm_le_of_shell, +interior_subset and interior_iInter_subset and isClosed_le.

+
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
+  [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
+
+open Metric
+
+example {ι : Type*} [CompleteSpace E] {g : ι → E →L[𝕜] F} (h : ∀ x, ∃ C, ∀ i, ‖g i x‖ ≤ C) :
+    ∃ C', ∀ i, ‖g i‖ ≤ C' := by
+  -- sequence of subsets consisting of those `x : E` with norms `‖g i x‖` bounded by `n`
+  let e : ℕ → Set E := fun n ↦ ⋂ i : ι, { x : E | ‖g i x‖ ≤ n }
+  -- each of these sets is closed
+  have hc : ∀ n : ℕ, IsClosed (e n) := by
+    sorry
+  -- the union is the entire space; this is where we use `h`
+  have hU : (⋃ n : ℕ, e n) = univ := by
+    sorry
+  /- apply the Baire category theorem to conclude that for some `m : ℕ`,
+       the interior of `e m` contains some `x` -/
+  obtain ⟨m, x, hx⟩ : ∃ m, ∃ x, x ∈ interior (e m) := sorry
+  obtain ⟨ε, ε_pos, hε⟩ : ∃ ε > 0, ball x ε ⊆ interior (e m) := sorry
+  obtain ⟨k, hk⟩ : ∃ k : 𝕜, 1 < ‖k‖ := sorry
+  -- show all elements in the ball have norm bounded by `m` after applying any `g i`
+  have real_norm_le : ∀ z ∈ ball x ε, ∀ (i : ι), ‖g i z‖ ≤ m
+  sorry
+  have εk_pos : 0 < ε / ‖k‖ := sorry
+  refine ⟨(m + m : ℕ) / (ε / ‖k‖), fun i ↦ ContinuousLinearMap.opNorm_le_of_shell ε_pos ?_ hk ?_⟩
+  sorry
+  sorry
+end
+
+
+
+
+

12.2.3. Asymptotic comparisons

+

Defining differentiability also requires asymptotic comparisons. +Mathlib has an extensive library covering the big O and little o relations, +whose definitions are shown below. +Opening the asymptotics locale allows us to use the corresponding +notation. +Here we will only use little o to define differentiability.

+
open Asymptotics
+
+example {α : Type*} {E : Type*} [NormedGroup E] {F : Type*} [NormedGroup F] (c : ℝ)
+    (l : Filter α) (f : α → E) (g : α → F) : IsBigOWith c l f g ↔ ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ :=
+  isBigOWith_iff
+
+example {α : Type*} {E : Type*} [NormedGroup E] {F : Type*} [NormedGroup F]
+    (l : Filter α) (f : α → E) (g : α → F) : f =O[l] g ↔ ∃ C, IsBigOWith C l f g :=
+  isBigO_iff_isBigOWith
+
+example {α : Type*} {E : Type*} [NormedGroup E] {F : Type*} [NormedGroup F]
+    (l : Filter α) (f : α → E) (g : α → F) : f =o[l] g ↔ ∀ C > 0, IsBigOWith C l f g :=
+  isLittleO_iff_forall_isBigOWith
+
+example {α : Type*} {E : Type*} [NormedAddCommGroup E] (l : Filter α) (f g : α → E) :
+    f ~[l] g ↔ (f - g) =o[l] g :=
+  Iff.rfl
+
+
+
+
+

12.2.4. Differentiability

+

We are now ready to discuss differentiable functions between normed spaces. +In analogy the elementary one-dimensional, +Mathlib defines a predicate HasFDerivAt and a function fderiv. +Here the letter +“f” stands for Fréchet.

+
open Topology
+
+variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
+  [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
+
+example (f : E → F) (f' : E →L[𝕜] F) (x₀ : E) :
+    HasFDerivAt f f' x₀ ↔ (fun x ↦ f x - f x₀ - f' (x - x₀)) =o[𝓝 x₀] fun x ↦ x - x₀ :=
+  hasFDerivAt_iff_isLittleO
+
+example (f : E → F) (f' : E →L[𝕜] F) (x₀ : E) (hff' : HasFDerivAt f f' x₀) : fderiv 𝕜 f x₀ = f' :=
+  hff'.fderiv
+
+
+

We also have iterated derivatives that take values in the type of multilinear maps +E [×n]→L[𝕜] F, +and we have continuously differential functions. +The type ℕ∞ is ℕ with an additional element ∞ that +is bigger than every natural number. +So \(\mathcal{C}^\infty\) functions are functions f that satisfy +ContDiff 𝕜 ⊤ f.

+
example (n : ℕ) (f : E → F) : E → E[×n]→L[𝕜] F :=
+  iteratedFDeriv 𝕜 n f
+
+example (n : ℕ∞) {f : E → F} :
+    ContDiff 𝕜 n f ↔
+      (∀ m : ℕ, (m : WithTop ℕ) ≤ n → Continuous fun x ↦ iteratedFDeriv 𝕜 m f x) ∧
+        ∀ m : ℕ, (m : WithTop ℕ) < n → Differentiable 𝕜 fun x ↦ iteratedFDeriv 𝕜 m f x :=
+  contDiff_iff_continuous_differentiable
+
+
+

The differentiability parameter in ContDiff can also take value ω : WithTop ℕ∞ +to denote analytic functions.

+

There is a stricter notion of differentiability called +HasStrictFDerivAt, which is used in the statement +of the inverse function theorem and the statement of the implicit function +theorem, both of which are in Mathlib. +Over ℝ or ℂ, continuously differentiable +functions are strictly differentiable.

+
example {𝕂 : Type*} [RCLike 𝕂] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕂 E] {F : Type*}
+    [NormedAddCommGroup F] [NormedSpace 𝕂 F] {f : E → F} {x : E} {n : WithTop ℕ∞}
+    (hf : ContDiffAt 𝕂 n f x) (hn : 1 ≤ n) : HasStrictFDerivAt f (fderiv 𝕂 f x) x :=
+  hf.hasStrictFDerivAt (zero_lt_one.trans_le hn).ne'
+
+
+

The local inverse theorem is stated using an operation that produces an +inverse function from a +function and the assumptions that the function is strictly differentiable at a +point a and that its derivative is an isomorphism.

+

The first example below gets this local inverse. +The next ones state that it is indeed a local inverse +from the left and from the right, and that it is strictly differentiable.

+
section LocalInverse
+variable [CompleteSpace E] {f : E → F} {f' : E ≃L[𝕜] F} {a : E}
+
+example (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) : F → E :=
+  HasStrictFDerivAt.localInverse f f' a hf
+
+example (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) :
+    ∀ᶠ x in 𝓝 a, hf.localInverse f f' a (f x) = x :=
+  hf.eventually_left_inverse
+
+example (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) :
+    ∀ᶠ x in 𝓝 (f a), f (hf.localInverse f f' a x) = x :=
+  hf.eventually_right_inverse
+
+example (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) :
+    HasStrictFDerivAt (HasStrictFDerivAt.localInverse f f' a hf) (f'.symm : F →L[𝕜] E) (f a) :=
+  HasStrictFDerivAt.to_localInverse hf
+
+end LocalInverse
+
+
+

This has been only a quick tour of the differential calculus in Mathlib. +The library contains many variations that we have not discussed. +For example, you may want to use one-sided derivatives in the +one-dimensional setting. The means to do so are found in Mathlib in a more +general context; +see HasFDerivWithinAt or the even more general HasFDerivAtFilter.

+
+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/C13_Integration_and_Measure_Theory.html b/dev/vendor/mathematics_in_lean/html/C13_Integration_and_Measure_Theory.html new file mode 100644 index 0000000..2368dd5 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/C13_Integration_and_Measure_Theory.html @@ -0,0 +1,324 @@ + + + + + + + + + 13. Integration and Measure Theory — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

13. Integration and Measure Theory

+
+

13.1. Elementary Integration

+

We first focus on integration of functions on finite intervals in ℝ. We can integrate +elementary functions.

+
open MeasureTheory intervalIntegral
+
+open Interval
+-- this introduces the notation `[[a, b]]` for the segment from `min a b` to `max a b`
+
+example (a b : ℝ) : (∫ x in a..b, x) = (b ^ 2 - a ^ 2) / 2 :=
+  integral_id
+
+example {a b : ℝ} (h : (0 : ℝ) ∉ [[a, b]]) : (∫ x in a..b, 1 / x) = Real.log (b / a) :=
+  integral_one_div h
+
+
+

The fundamental theorem of calculus relates integration and differentiation. +Below we give simplified statements of the two parts of this theorem. The first part +says that integration provides an inverse to differentiation and the second one +specifies how to compute integrals of derivatives. +(These two parts are very closely related, but their optimal versions, +which are not shown here, are not equivalent.)

+
example (f : ℝ → ℝ) (hf : Continuous f) (a b : ℝ) : deriv (fun u ↦ ∫ x in a..u, f x) b = f b :=
+  (integral_hasStrictDerivAt_right (hf.intervalIntegrable _ _) (hf.stronglyMeasurableAtFilter _ _)
+        hf.continuousAt).hasDerivAt.deriv
+
+example {f : ℝ → ℝ} {a b : ℝ} {f' : ℝ → ℝ} (h : ∀ x ∈ [[a, b]], HasDerivAt f (f' x) x)
+    (h' : IntervalIntegrable f' volume a b) : (∫ y in a..b, f' y) = f b - f a :=
+  integral_eq_sub_of_hasDerivAt h h'
+
+
+

Convolution is also defined in Mathlib and its basic properties are proved.

+
open Convolution
+
+example (f : ℝ → ℝ) (g : ℝ → ℝ) : f ⋆ g = fun x ↦ ∫ t, f t * g (x - t) :=
+  rfl
+
+
+
+
+

13.2. Measure Theory

+

The general context for integration in Mathlib is measure theory. Even the elementary +integrals of the previous section are in fact Bochner integrals. Bochner integration is +a generalization of Lebesgue integration where the target space can be any Banach space, +not necessarily finite dimensional.

+

The first component in the development of measure theory +is the notion of a \(\sigma\)-algebra of sets, which are called the +measurable sets. +The type class MeasurableSpace serves to equip a type with such a structure. +The sets empty and univ are measurable, +the complement of a measurable set is measurable, +and a countable union or intersection of measurable sets is measurable. +Note that these axioms are redundant; if you #print MeasurableSpace, +you will see the ones that Mathlib uses. +As the examples below show, countability assumptions can be expressed using the +Encodable type class.

+
variable {α : Type*} [MeasurableSpace α]
+
+example : MeasurableSet (∅ : Set α) :=
+  MeasurableSet.empty
+
+example : MeasurableSet (univ : Set α) :=
+  MeasurableSet.univ
+
+example {s : Set α} (hs : MeasurableSet s) : MeasurableSet (sᶜ) :=
+  hs.compl
+
+example : Encodable ℕ := by infer_instance
+
+example (n : ℕ) : Encodable (Fin n) := by infer_instance
+
+variable {ι : Type*} [Encodable ι]
+
+example {f : ι → Set α} (h : ∀ b, MeasurableSet (f b)) : MeasurableSet (⋃ b, f b) :=
+  MeasurableSet.iUnion h
+
+example {f : ι → Set α} (h : ∀ b, MeasurableSet (f b)) : MeasurableSet (⋂ b, f b) :=
+  MeasurableSet.iInter h
+
+
+

Once a type is measurable, we can measure it. On paper, a measure on a set +(or type) equipped with a +\(\sigma\)-algebra is a function from the measurable sets to +the extended non-negative reals that is +additive on countable disjoint unions. +In Mathlib, we don’t want to carry around measurability assumptions +every time we write an application of the measure to a set. +So we extend the measure to any set s +as the infimum of measures of measurable sets containing s. +Of course, many lemmas still require +measurability assumptions, but not all.

+
open MeasureTheory Function
+variable {μ : Measure α}
+
+example (s : Set α) : μ s = ⨅ (t : Set α) (_ : s ⊆ t) (_ : MeasurableSet t), μ t :=
+  measure_eq_iInf s
+
+example (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑' i, μ (s i) :=
+  measure_iUnion_le s
+
+example {f : ℕ → Set α} (hmeas : ∀ i, MeasurableSet (f i)) (hdis : Pairwise (Disjoint on f)) :
+    μ (⋃ i, f i) = ∑' i, μ (f i) :=
+  μ.m_iUnion hmeas hdis
+
+
+

Once a type has a measure associated with it, we say that a property P +holds almost everywhere if the set of elements where the property fails +has measure 0. +The collection of properties that hold almost everywhere form a filter, +but Mathlib introduces special notation for saying that a property holds +almost everywhere.

+
example {P : α → Prop} : (∀ᵐ x ∂μ, P x) ↔ ∀ᶠ x in ae μ, P x :=
+  Iff.rfl
+
+
+
+
+

13.3. Integration

+

Now that we have measurable spaces and measures we can consider integrals. +As explained above, Mathlib uses a very general notion of +integration that allows any Banach space as the target. +As usual, we don’t want our notation to +carry around assumptions, so we define integration in such a way +that an integral is equal to zero if the function in question is +not integrable. +Most lemmas having to do with integrals have integrability assumptions.

+
section
+variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {f : α → E}
+
+example {f g : α → E} (hf : Integrable f μ) (hg : Integrable g μ) :
+    ∫ a, f a + g a ∂μ = ∫ a, f a ∂μ + ∫ a, g a ∂μ :=
+  integral_add hf hg
+
+
+

As an example of the complex interactions between our various conventions, let us see how to integrate constant functions. +Recall that a measure μ takes values in ℝ≥0∞, the type of extended non-negative reals. +There is a function ENNReal.toReal : ℝ≥0∞ → ℝ which sends ⊤, +the point at infinity, to zero. +For any s : Set α, if μ s = ⊤, then nonzero constant functions are not integrable on s. +In that case, their integrals are equal to zero by definition, as is (μ s).toReal. +So in all cases we have the following lemma.

+
example {s : Set α} (c : E) : ∫ _ in s, c ∂μ = (μ s).toReal • c :=
+  setIntegral_const c
+
+
+

We now quickly explain how to access the most important theorems in integration theory, starting +with the dominated convergence theorem. There are several versions in Mathlib, +and here we only show the most basic one.

+
open Filter
+
+example {F : ℕ → α → E} {f : α → E} (bound : α → ℝ) (hmeas : ∀ n, AEStronglyMeasurable (F n) μ)
+    (hint : Integrable bound μ) (hbound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a)
+    (hlim : ∀ᵐ a ∂μ, Tendsto (fun n : ℕ ↦ F n a) atTop (𝓝 (f a))) :
+    Tendsto (fun n ↦ ∫ a, F n a ∂μ) atTop (𝓝 (∫ a, f a ∂μ)) :=
+  tendsto_integral_of_dominated_convergence bound hmeas hint hbound hlim
+
+
+

Then we have Fubini’s theorem for integrals on product type.

+
example {α : Type*} [MeasurableSpace α] {μ : Measure α} [SigmaFinite μ] {β : Type*}
+    [MeasurableSpace β] {ν : Measure β} [SigmaFinite ν] (f : α × β → E)
+    (hf : Integrable f (μ.prod ν)) : ∫ z, f z ∂ μ.prod ν = ∫ x, ∫ y, f (x, y) ∂ν ∂μ :=
+  integral_prod f hf
+
+
+

There is a very general version of convolution that applies to any +continuous bilinear form.

+
open Convolution
+
+variable {𝕜 : Type*} {G : Type*} {E : Type*} {E' : Type*} {F : Type*} [NormedAddCommGroup E]
+  [NormedAddCommGroup E'] [NormedAddCommGroup F] [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E]
+  [NormedSpace 𝕜 E'] [NormedSpace 𝕜 F] [MeasurableSpace G] [NormedSpace ℝ F] [CompleteSpace F]
+  [Sub G]
+
+example (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F) (μ : Measure G) :
+    f ⋆[L, μ] g = fun x ↦ ∫ t, L (f t) (g (x - t)) ∂μ :=
+  rfl
+
+
+

Finally, Mathlib has a very general version of the change-of-variables formula. +In the statement below, BorelSpace E means the +\(\sigma\)-algebra on E is generated by the open sets of E, +and IsAddHaarMeasure μ means that the measure μ is left-invariant, +gives finite mass to compact sets, and give positive mass to open sets.

+
example {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E]
+    [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [μ.IsAddHaarMeasure] {F : Type*}
+    [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {s : Set E} {f : E → E}
+    {f' : E → E →L[ℝ] E} (hs : MeasurableSet s)
+    (hf : ∀ x : E, x ∈ s → HasFDerivWithinAt f (f' x) s x) (h_inj : InjOn f s) (g : E → F) :
+    ∫ x in f '' s, g x ∂μ = ∫ x in s, |(f' x).det| • g (f x) ∂μ :=
+  integral_image_eq_integral_abs_det_fderiv_smul μ hs hf h_inj g
+
+
+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/_images/schroeder_bernstein1.png b/dev/vendor/mathematics_in_lean/html/_images/schroeder_bernstein1.png new file mode 100644 index 0000000..247fa76 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_images/schroeder_bernstein1.png differ diff --git a/dev/vendor/mathematics_in_lean/html/_images/schroeder_bernstein2.png b/dev/vendor/mathematics_in_lean/html/_images/schroeder_bernstein2.png new file mode 100644 index 0000000..0ebe270 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_images/schroeder_bernstein2.png differ diff --git a/dev/vendor/mathematics_in_lean/html/_images/schroeder_bernstein3.png b/dev/vendor/mathematics_in_lean/html/_images/schroeder_bernstein3.png new file mode 100644 index 0000000..74e3c93 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_images/schroeder_bernstein3.png differ diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C01_Introduction.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C01_Introduction.rst.txt new file mode 100644 index 0000000..791550b --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C01_Introduction.rst.txt @@ -0,0 +1,7 @@ +.. _introduction: + +Introduction +============ + +.. include:: C01_Introduction/S01_Getting_Started.inc +.. include:: C01_Introduction/S02_Overview.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C02_Basics.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C02_Basics.rst.txt new file mode 100644 index 0000000..aeb1c90 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C02_Basics.rst.txt @@ -0,0 +1,15 @@ +.. _basics: + +Basics +====== + +This chapter is designed to introduce you to the nuts and +bolts of mathematical reasoning in Lean: calculating, +applying lemmas and theorems, +and reasoning about generic structures. + +.. include:: C02_Basics/S01_Calculating.inc +.. include:: C02_Basics/S02_Proving_Identities_in_Algebraic_Structures.inc +.. include:: C02_Basics/S03_Using_Theorems_and_Lemmas.inc +.. include:: C02_Basics/S04_More_on_Order_and_Divisibility.inc +.. include:: C02_Basics/S05_Proving_Facts_about_Algebraic_Structures.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C03_Logic.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C03_Logic.rst.txt new file mode 100644 index 0000000..f936a7f --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C03_Logic.rst.txt @@ -0,0 +1,21 @@ +.. _logic: + +Logic +===== + +In the last chapter, we dealt with equations, inequalities, +and basic mathematical statements like +":math:`x` divides :math:`y`." +Complex mathematical statements are built up from +simple ones like these +using logical terms like "and," "or," "not," and +"if ... then," "every," and "some." +In this chapter, we show you how to work with statements +that are built up in this way. + +.. include:: C03_Logic/S01_Implication_and_the_Universal_Quantifier.inc +.. include:: C03_Logic/S02_The_Existential_Quantifier.inc +.. include:: C03_Logic/S03_Negation.inc +.. include:: C03_Logic/S04_Conjunction_and_Iff.inc +.. include:: C03_Logic/S05_Disjunction.inc +.. include:: C03_Logic/S06_Sequences_and_Convergence.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C04_Sets_and_Functions.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C04_Sets_and_Functions.rst.txt new file mode 100644 index 0000000..99ce514 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C04_Sets_and_Functions.rst.txt @@ -0,0 +1,43 @@ +.. _sets_and_functions: + +Sets and Functions +================== + +The vocabulary of sets, relations, and functions provides a uniform +language for carrying out constructions in all the branches of +mathematics. +Since functions and relations can be defined in terms of sets, +axiomatic set theory can be used as a foundation for mathematics. + +Lean's foundation is based instead on the primitive notion of a *type*, +and it includes ways of defining functions between types. +Every expression in Lean has a type: +there are natural numbers, real numbers, functions from reals to reals, +groups, vector spaces, and so on. +Some expressions *are* types, +which is to say, +their type is ``Type``. +Lean and Mathlib provide ways of defining new types, +and ways of defining objects of those types. + +Conceptually, you can think of a type as just a set of objects. +Requiring every object to have a type has some advantages. +For example, it makes it possible to overload notation like ``+``, +and it sometimes makes input less verbose +because Lean can infer a lot of information from +an object's type. +The type system also enables Lean to flag errors when you +apply a function to the wrong number of arguments, +or apply a function to arguments of the wrong type. + +Lean's library does define elementary set-theoretic notions. +In contrast to set theory, +in Lean a set is always a set of objects of some type, +such as a set of natural numbers or a set of functions +from real numbers to real numbers. +The distinction between types and sets takes some getting used to, +but this chapter will take you through the essentials. + +.. include:: C04_Sets_and_Functions/S01_Sets.inc +.. include:: C04_Sets_and_Functions/S02_Functions.inc +.. include:: C04_Sets_and_Functions/S03_The_Schroeder_Bernstein_Theorem.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C05_Elementary_Number_Theory.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C05_Elementary_Number_Theory.rst.txt new file mode 100644 index 0000000..48ea131 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C05_Elementary_Number_Theory.rst.txt @@ -0,0 +1,15 @@ +.. _number_theory: + +Elementary Number Theory +======================== + +In this chapter, we show you how to formalize some elementary +results in number theory. +As we deal with more substantive mathematical content, +the proofs will get longer and more involved, +building on the skills you have already mastered. + +.. include:: C05_Elementary_Number_Theory/S01_Irrational_Roots.inc +.. include:: C05_Elementary_Number_Theory/S02_Induction_and_Recursion.inc +.. include:: C05_Elementary_Number_Theory/S03_Infinitely_Many_Primes.inc +.. include:: C05_Elementary_Number_Theory/S04_More_Induction.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C06_Discrete_Mathematics.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C06_Discrete_Mathematics.rst.txt new file mode 100644 index 0000000..d2f4460 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C06_Discrete_Mathematics.rst.txt @@ -0,0 +1,16 @@ +.. _discrete_mathematics: + +Discrete Mathematics +==================== + +*Discrete Mathematics* is the study of finite sets, objects, and structures. +We can count the elements of a finite set, and we can compute finite sums or products over its +elements, we can compute maximums and minimums, and so on. +We can also study objects that are generated by finitely many applications of +certain generating functions, we can define functions by structural recursion, +and prove theorems by structural induction. +This chapter describes parts of Mathlib that support these activities. + +.. include:: C06_Discrete_Mathematics/S01_Finsets_and_Fintypes.inc +.. include:: C06_Discrete_Mathematics/S02_Counting_Arguments.inc +.. include:: C06_Discrete_Mathematics/S03_Inductive_Structures.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C07_Structures.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C07_Structures.rst.txt new file mode 100644 index 0000000..f5cb771 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C07_Structures.rst.txt @@ -0,0 +1,29 @@ +.. _structures: + +Structures +========== + +Modern mathematics makes essential use of algebraic +structures, +which encapsulate patterns that can be instantiated in +multiple settings. +The subject provides various ways of defining such structures and +constructing particular instances. + +Lean therefore provides corresponding ways of +defining structures formally and working with them. +You have already seen examples of algebraic structures in Lean, +such as rings and lattices, which were discussed in +:numref:`Chapter %s `. +This chapter will explain the mysterious square bracket annotations +that you saw there, +``[Ring α]`` and ``[Lattice α]``. +It will also show you how to define and use +algebraic structures on your own. + +For more technical detail, you can consult `Theorem Proving in Lean `_, +and a paper by Anne Baanen, `Use and abuse of instance parameters in the Lean mathematical library `_. + +.. include:: C07_Structures/S01_Structures.inc +.. include:: C07_Structures/S02_Algebraic_Structures.inc +.. include:: C07_Structures/S03_Building_the_Gaussian_Integers.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C08_Hierarchies.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C08_Hierarchies.rst.txt new file mode 100644 index 0000000..67d94ef --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C08_Hierarchies.rst.txt @@ -0,0 +1,26 @@ +.. _hierarchies: + +Hierarchies +=========== + +We have seen in :numref:`Chapter %s ` how to define the class +of groups and build instances of this class, and then how to build an instance +of the commutative ring class. But of course there is a hierarchy here: a +commutative ring is in particular an additive group. In this chapter we +will study how to build such hierarchies. They appear in all branches +of mathematics but in this chapter the emphasis will be on algebraic examples. + +It may seem premature to discuss how to build hierarchies before more discussions +about using existing hierarchies. But some understanding of the technology underlying +hierarchies is required to use them. So you should probably still read this chapter, +but without trying too hard to remember everything on your first read, then read +the following chapters and come back here for a second reading. + +In this chapter, we will redefine (simpler versions of) many things that appear in Mathlib +so we will used indices to distinguish our version. For instance we will have ``Ring₁`` +as our version of ``Ring``. Since we will gradually explain more powerful ways of formalizing +structures, those indices will sometimes grow beyond one. + +.. include:: C08_Hierarchies/S01_Basics.inc +.. include:: C08_Hierarchies/S02_Morphisms.inc +.. include:: C08_Hierarchies/S03_Subobjects.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C09_Groups_and_Rings.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C09_Groups_and_Rings.rst.txt new file mode 100644 index 0000000..9782323 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C09_Groups_and_Rings.rst.txt @@ -0,0 +1,22 @@ +.. _groups_and_ring: + +Groups and Rings +================ + +We saw in :numref:`proving_identities_in_algebraic_structures` how to reason about +operations in groups and rings. Later, in :numref:`section_algebraic_structures`, we saw how +to define abstract algebraic structures, such as group structures, as well as concrete instances +such as the ring structure on the Gaussian integers. :numref:`Chapter %s ` explained how +hierarchies of abstract structures are handled in Mathlib. + +In this chapter we work with groups and rings in more detail. We won't be able to +cover every aspect of the treatment of these topics in Mathlib, especially since Mathlib is constantly growing. +But we will provide entry points to the library and show how the essential concepts are used. +There is some overlap with the discussion of +:numref:`Chapter %s `, but here we will focus on how to use Mathlib instead of the design +decisions behind the way the topics are treated. +So making sense of some of the examples may require reviewing the background from +:numref:`Chapter %s `. + +.. include:: C09_Groups_and_Rings/S01_Groups.inc +.. include:: C09_Groups_and_Rings/S02_Rings.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C10_Linear_Algebra.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C10_Linear_Algebra.rst.txt new file mode 100644 index 0000000..bd308ac --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C10_Linear_Algebra.rst.txt @@ -0,0 +1,10 @@ +.. _linear_algebra: + +Linear algebra +============== + + +.. include:: C10_Linear_Algebra/S01_Vector_Spaces.inc +.. include:: C10_Linear_Algebra/S02_Subspaces.inc +.. include:: C10_Linear_Algebra/S03_Endomorphisms.inc +.. include:: C10_Linear_Algebra/S04_Bases.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C11_Topology.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C11_Topology.rst.txt new file mode 100644 index 0000000..cb819cb --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C11_Topology.rst.txt @@ -0,0 +1,82 @@ +.. _topology: + +.. index:: topology + +Topology +======== + +Calculus is based on the concept of a function, which is used to model +quantities that depend on one another. +For example, it is common to study quantities that change over time. +The notion of a *limit* is also fundamental. +We may say that the limit of a function :math:`f(x)` is a value :math:`b` +as :math:`x` approaches a value :math:`a`, +or that :math:`f(x)` *converges to* :math:`b` as :math:`x` approaches :math:`a`. +Equivalently, we may say that :math:`f(x)` approaches :math:`b` as :math:`x` +approaches a value :math:`a`, or that it *tends to* :math:`b` +as :math:`x` tends to :math:`a`. +We have already begun to consider such notions in :numref:`sequences_and_convergence`. + +*Topology* is the abstract study of limits and continuity. +Having covered the essentials of formalization in Chapters :numref:`%s ` +to :numref:`%s `, +in this chapter, we will explain how topological notions are formalized in Mathlib. +Not only do topological abstractions apply in much greater generality, +but they also, somewhat paradoxically, make it easier to reason about limits +and continuity in concrete instances. + +Topological notions build on quite a few layers of mathematical structure. +The first layer is naive set theory, +as described in :numref:`Chapter %s `. +The next layer is the theory of *filters*, which we will describe in :numref:`filters`. +On top of that, we layer +the theories of *topological spaces*, *metric spaces*, and a slightly more exotic +intermediate notion called a *uniform space*. + +Whereas previous chapters relied on mathematical notions that were likely +familiar to you, +the notion of a filter is less well known, +even to many working mathematicians. +The notion is essential, however, for formalizing mathematics effectively. +Let us explain why. +Let ``f : ℝ → ℝ`` be any function. We can consider +the limit of ``f x`` as ``x`` approaches some value ``x₀``, +but we can also consider the limit of ``f x`` as ``x`` approaches infinity +or negative infinity. +We can moreover consider the limit of ``f x`` as ``x`` approaches ``x₀`` from +the right, conventionally written ``x₀⁺``, or from the left, +written ``x₀⁻``. There are variations where ``x`` approaches ``x₀`` or ``x₀⁺`` +or ``x₀⁻`` but +is not allowed to take on the value ``x₀`` itself. +This results in at least eight ways that ``x`` can approach something. +We can also restrict to rational values of ``x`` +or place other constraints on the domain, but let's stick to those 8 cases. + +We have a similar variety of options on the codomain: +we can specify that ``f x`` approaches a value from the left or right, +or that it approaches positive or negative infinity, and so on. +For example, we may wish to say that ``f x`` tends to ``+∞`` +when ``x`` tends to ``x₀`` from the right without +being equal to ``x₀``. +This results in 64 different kinds of limit statements, +and we haven't even begun to deal with limits of sequences, +as we did in :numref:`sequences_and_convergence`. + +The problem is compounded even further when it comes to the supporting lemmas. +For instance, limits compose: if +``f x`` tends to ``y₀`` when ``x`` tends to ``x₀`` and +``g y`` tends to ``z₀`` when ``y`` tends to ``y₀`` then +``g ∘ f x`` tends to ``z₀`` when ``x`` tends to ``x₀``. +There are three notions of "tends to" at play here, +each of which can be instantiated in any of the eight ways described +in the previous paragraph. +This results in 512 lemmas, a lot to have to add to a library! +Informally, mathematicians generally prove two or three of these +and simply note that the rest can be proved "in the same way." +Formalizing mathematics requires making the relevant notion of "sameness" +fully explicit, and that is exactly what Bourbaki's theory of filters +manages to do. + +.. include:: C11_Topology/S01_Filters.inc +.. include:: C11_Topology/S02_Metric_Spaces.inc +.. include:: C11_Topology/S03_Topological_Spaces.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C12_Differential_Calculus.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C12_Differential_Calculus.rst.txt new file mode 100644 index 0000000..ff3764f --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C12_Differential_Calculus.rst.txt @@ -0,0 +1,18 @@ +.. _differential_calculus: + +.. index:: differential calculus + +Differential Calculus +===================== + +We now consider the formalization of notions from *analysis*, +starting with differentiation in this chapter +and turning integration and measure theory in the next. +In :numref:`elementary_differential_calculus`, we stick with the +setting of functions from the real numbers to the real numbers, +which is familiar from any introductory calculus class. +In :numref:`normed_spaces`, we then consider the notion of a derivative in +a much broader setting. + +.. include:: C12_Differential_Calculus/S01_Elementary_Differential_Calculus.inc +.. include:: C12_Differential_Calculus/S02_Differential_Calculus_in_Normed_Spaces.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/C13_Integration_and_Measure_Theory.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/C13_Integration_and_Measure_Theory.rst.txt new file mode 100644 index 0000000..212cc7a --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/C13_Integration_and_Measure_Theory.rst.txt @@ -0,0 +1,10 @@ +.. _integration_and_measure_theory: + +.. index:: integration + +Integration and Measure Theory +============================== + +.. include:: C13_Integration_and_Measure_Theory/S01_Elementary_Integration.inc +.. include:: C13_Integration_and_Measure_Theory/S02_Measure_Theory.inc +.. include:: C13_Integration_and_Measure_Theory/S03_Integration.inc diff --git a/dev/vendor/mathematics_in_lean/html/_sources/genindex.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/genindex.rst.txt new file mode 100644 index 0000000..66a2352 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/genindex.rst.txt @@ -0,0 +1,2 @@ +Index +===== \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/_sources/index.rst.txt b/dev/vendor/mathematics_in_lean/html/_sources/index.rst.txt new file mode 100644 index 0000000..ea2949f --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_sources/index.rst.txt @@ -0,0 +1,26 @@ + +Mathematics in Lean +=================== + +.. toctree:: + :numbered: + :maxdepth: 2 + + C01_Introduction + C02_Basics + C03_Logic + C04_Sets_and_Functions + C05_Elementary_Number_Theory + C06_Discrete_Mathematics + C07_Structures + C08_Hierarchies + C09_Groups_and_Rings + C10_Linear_Algebra + C11_Topology + C12_Differential_Calculus + C13_Integration_and_Measure_Theory + +.. toctree:: + :hidden: + + genindex diff --git a/dev/vendor/mathematics_in_lean/html/_static/_sphinx_javascript_frameworks_compat.js b/dev/vendor/mathematics_in_lean/html/_static/_sphinx_javascript_frameworks_compat.js new file mode 100644 index 0000000..8141580 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/_sphinx_javascript_frameworks_compat.js @@ -0,0 +1,123 @@ +/* Compatability shim for jQuery and underscores.js. + * + * Copyright Sphinx contributors + * Released under the two clause BSD licence + */ + +/** + * small helper function to urldecode strings + * + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL + */ +jQuery.urldecode = function(x) { + if (!x) { + return x + } + return decodeURIComponent(x.replace(/\+/g, ' ')); +}; + +/** + * small helper function to urlencode strings + */ +jQuery.urlencode = encodeURIComponent; + +/** + * This function returns the parsed url parameters of the + * current request. Multiple values per key are supported, + * it will always return arrays of strings for the value parts. + */ +jQuery.getQueryParameters = function(s) { + if (typeof s === 'undefined') + s = document.location.search; + var parts = s.substr(s.indexOf('?') + 1).split('&'); + var result = {}; + for (var i = 0; i < parts.length; i++) { + var tmp = parts[i].split('=', 2); + var key = jQuery.urldecode(tmp[0]); + var value = jQuery.urldecode(tmp[1]); + if (key in result) + result[key].push(value); + else + result[key] = [value]; + } + return result; +}; + +/** + * highlight a given string on a jquery object by wrapping it in + * span elements with the given class name. + */ +jQuery.fn.highlightText = function(text, className) { + function highlight(node, addItems) { + if (node.nodeType === 3) { + var val = node.nodeValue; + var pos = val.toLowerCase().indexOf(text); + if (pos >= 0 && + !jQuery(node.parentNode).hasClass(className) && + !jQuery(node.parentNode).hasClass("nohighlight")) { + var span; + var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg"); + if (isInSVG) { + span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + } else { + span = document.createElement("span"); + span.className = className; + } + span.appendChild(document.createTextNode(val.substr(pos, text.length))); + node.parentNode.insertBefore(span, node.parentNode.insertBefore( + document.createTextNode(val.substr(pos + text.length)), + node.nextSibling)); + node.nodeValue = val.substr(0, pos); + if (isInSVG) { + var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + var bbox = node.parentElement.getBBox(); + rect.x.baseVal.value = bbox.x; + rect.y.baseVal.value = bbox.y; + rect.width.baseVal.value = bbox.width; + rect.height.baseVal.value = bbox.height; + rect.setAttribute('class', className); + addItems.push({ + "parent": node.parentNode, + "target": rect}); + } + } + } + else if (!jQuery(node).is("button, select, textarea")) { + jQuery.each(node.childNodes, function() { + highlight(this, addItems); + }); + } + } + var addItems = []; + var result = this.each(function() { + highlight(this, addItems); + }); + for (var i = 0; i < addItems.length; ++i) { + jQuery(addItems[i].parent).before(addItems[i].target); + } + return result; +}; + +/* + * backward compatibility for jQuery.browser + * This will be supported until firefox bug is fixed. + */ +if (!jQuery.browser) { + jQuery.uaMatch = function(ua) { + ua = ua.toLowerCase(); + + var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || + /(webkit)[ \/]([\w.]+)/.exec(ua) || + /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || + /(msie) ([\w.]+)/.exec(ua) || + ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || + []; + + return { + browser: match[ 1 ] || "", + version: match[ 2 ] || "0" + }; + }; + jQuery.browser = {}; + jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; +} diff --git a/dev/vendor/mathematics_in_lean/html/_static/basic.css b/dev/vendor/mathematics_in_lean/html/_static/basic.css new file mode 100644 index 0000000..4738b2e --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/basic.css @@ -0,0 +1,906 @@ +/* + * Sphinx stylesheet -- basic theme. + */ + +/* -- main layout ----------------------------------------------------------- */ + +div.clearer { + clear: both; +} + +div.section::after { + display: block; + content: ''; + clear: left; +} + +/* -- relbar ---------------------------------------------------------------- */ + +div.related { + width: 100%; + font-size: 90%; +} + +div.related h3 { + display: none; +} + +div.related ul { + margin: 0; + padding: 0 0 0 10px; + list-style: none; +} + +div.related li { + display: inline; +} + +div.related li.right { + float: right; + margin-right: 5px; +} + +/* -- sidebar --------------------------------------------------------------- */ + +div.sphinxsidebarwrapper { + padding: 10px 5px 0 10px; +} + +div.sphinxsidebar { + float: left; + width: 230px; + margin-left: -100%; + font-size: 90%; + word-wrap: break-word; + overflow-wrap : break-word; +} + +div.sphinxsidebar ul { + list-style: none; +} + +div.sphinxsidebar ul ul, +div.sphinxsidebar ul.want-points { + margin-left: 20px; + list-style: square; +} + +div.sphinxsidebar ul ul { + margin-top: 0; + margin-bottom: 0; +} + +div.sphinxsidebar form { + margin-top: 10px; +} + +div.sphinxsidebar input { + border: 1px solid #98dbcc; + font-family: sans-serif; + font-size: 1em; +} + +div.sphinxsidebar #searchbox form.search { + overflow: hidden; +} + +div.sphinxsidebar #searchbox input[type="text"] { + float: left; + width: 80%; + padding: 0.25em; + box-sizing: border-box; +} + +div.sphinxsidebar #searchbox input[type="submit"] { + float: left; + width: 20%; + border-left: none; + padding: 0.25em; + box-sizing: border-box; +} + + +img { + border: 0; + max-width: 100%; +} + +/* -- search page ----------------------------------------------------------- */ + +ul.search { + margin-top: 10px; +} + +ul.search li { + padding: 5px 0; +} + +ul.search li a { + font-weight: bold; +} + +ul.search li p.context { + color: #888; + margin: 2px 0 0 30px; + text-align: left; +} + +ul.keywordmatches li.goodmatch a { + font-weight: bold; +} + +/* -- index page ------------------------------------------------------------ */ + +table.contentstable { + width: 90%; + margin-left: auto; + margin-right: auto; +} + +table.contentstable p.biglink { + line-height: 150%; +} + +a.biglink { + font-size: 1.3em; +} + +span.linkdescr { + font-style: italic; + padding-top: 5px; + font-size: 90%; +} + +/* -- general index --------------------------------------------------------- */ + +table.indextable { + width: 100%; +} + +table.indextable td { + text-align: left; + vertical-align: top; +} + +table.indextable ul { + margin-top: 0; + margin-bottom: 0; + list-style-type: none; +} + +table.indextable > tbody > tr > td > ul { + padding-left: 0em; +} + +table.indextable tr.pcap { + height: 10px; +} + +table.indextable tr.cap { + margin-top: 10px; + background-color: #f2f2f2; +} + +img.toggler { + margin-right: 3px; + margin-top: 3px; + cursor: pointer; +} + +div.modindex-jumpbox { + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + margin: 1em 0 1em 0; + padding: 0.4em; +} + +div.genindex-jumpbox { + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + margin: 1em 0 1em 0; + padding: 0.4em; +} + +/* -- domain module index --------------------------------------------------- */ + +table.modindextable td { + padding: 2px; + border-collapse: collapse; +} + +/* -- general body styles --------------------------------------------------- */ + +div.body { + min-width: 360px; + max-width: 800px; +} + +div.body p, div.body dd, div.body li, div.body blockquote { + -moz-hyphens: auto; + -ms-hyphens: auto; + -webkit-hyphens: auto; + hyphens: auto; +} + +a.headerlink { + visibility: hidden; +} + +a:visited { + color: #551A8B; +} + +h1:hover > a.headerlink, +h2:hover > a.headerlink, +h3:hover > a.headerlink, +h4:hover > a.headerlink, +h5:hover > a.headerlink, +h6:hover > a.headerlink, +dt:hover > a.headerlink, +caption:hover > a.headerlink, +p.caption:hover > a.headerlink, +div.code-block-caption:hover > a.headerlink { + visibility: visible; +} + +div.body p.caption { + text-align: inherit; +} + +div.body td { + text-align: left; +} + +.first { + margin-top: 0 !important; +} + +p.rubric { + margin-top: 30px; + font-weight: bold; +} + +img.align-left, figure.align-left, .figure.align-left, object.align-left { + clear: left; + float: left; + margin-right: 1em; +} + +img.align-right, figure.align-right, .figure.align-right, object.align-right { + clear: right; + float: right; + margin-left: 1em; +} + +img.align-center, figure.align-center, .figure.align-center, object.align-center { + display: block; + margin-left: auto; + margin-right: auto; +} + +img.align-default, figure.align-default, .figure.align-default { + display: block; + margin-left: auto; + margin-right: auto; +} + +.align-left { + text-align: left; +} + +.align-center { + text-align: center; +} + +.align-default { + text-align: center; +} + +.align-right { + text-align: right; +} + +/* -- sidebars -------------------------------------------------------------- */ + +div.sidebar, +aside.sidebar { + margin: 0 0 0.5em 1em; + border: 1px solid #ddb; + padding: 7px; + background-color: #ffe; + width: 40%; + float: right; + clear: right; + overflow-x: auto; +} + +p.sidebar-title { + font-weight: bold; +} + +nav.contents, +aside.topic, +div.admonition, div.topic, blockquote { + clear: left; +} + +/* -- topics ---------------------------------------------------------------- */ + +nav.contents, +aside.topic, +div.topic { + border: 1px solid #ccc; + padding: 7px; + margin: 10px 0 10px 0; +} + +p.topic-title { + font-size: 1.1em; + font-weight: bold; + margin-top: 10px; +} + +/* -- admonitions ----------------------------------------------------------- */ + +div.admonition { + margin-top: 10px; + margin-bottom: 10px; + padding: 7px; +} + +div.admonition dt { + font-weight: bold; +} + +p.admonition-title { + margin: 0px 10px 5px 0px; + font-weight: bold; +} + +div.body p.centered { + text-align: center; + margin-top: 25px; +} + +/* -- content of sidebars/topics/admonitions -------------------------------- */ + +div.sidebar > :last-child, +aside.sidebar > :last-child, +nav.contents > :last-child, +aside.topic > :last-child, +div.topic > :last-child, +div.admonition > :last-child { + margin-bottom: 0; +} + +div.sidebar::after, +aside.sidebar::after, +nav.contents::after, +aside.topic::after, +div.topic::after, +div.admonition::after, +blockquote::after { + display: block; + content: ''; + clear: both; +} + +/* -- tables ---------------------------------------------------------------- */ + +table.docutils { + margin-top: 10px; + margin-bottom: 10px; + border: 0; + border-collapse: collapse; +} + +table.align-center { + margin-left: auto; + margin-right: auto; +} + +table.align-default { + margin-left: auto; + margin-right: auto; +} + +table caption span.caption-number { + font-style: italic; +} + +table caption span.caption-text { +} + +table.docutils td, table.docutils th { + padding: 1px 8px 1px 5px; + border-top: 0; + border-left: 0; + border-right: 0; + border-bottom: 1px solid #aaa; +} + +th { + text-align: left; + padding-right: 5px; +} + +table.citation { + border-left: solid 1px gray; + margin-left: 1px; +} + +table.citation td { + border-bottom: none; +} + +th > :first-child, +td > :first-child { + margin-top: 0px; +} + +th > :last-child, +td > :last-child { + margin-bottom: 0px; +} + +/* -- figures --------------------------------------------------------------- */ + +div.figure, figure { + margin: 0.5em; + padding: 0.5em; +} + +div.figure p.caption, figcaption { + padding: 0.3em; +} + +div.figure p.caption span.caption-number, +figcaption span.caption-number { + font-style: italic; +} + +div.figure p.caption span.caption-text, +figcaption span.caption-text { +} + +/* -- field list styles ----------------------------------------------------- */ + +table.field-list td, table.field-list th { + border: 0 !important; +} + +.field-list ul { + margin: 0; + padding-left: 1em; +} + +.field-list p { + margin: 0; +} + +.field-name { + -moz-hyphens: manual; + -ms-hyphens: manual; + -webkit-hyphens: manual; + hyphens: manual; +} + +/* -- hlist styles ---------------------------------------------------------- */ + +table.hlist { + margin: 1em 0; +} + +table.hlist td { + vertical-align: top; +} + +/* -- object description styles --------------------------------------------- */ + +.sig { + font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; +} + +.sig-name, code.descname { + background-color: transparent; + font-weight: bold; +} + +.sig-name { + font-size: 1.1em; +} + +code.descname { + font-size: 1.2em; +} + +.sig-prename, code.descclassname { + background-color: transparent; +} + +.optional { + font-size: 1.3em; +} + +.sig-paren { + font-size: larger; +} + +.sig-param.n { + font-style: italic; +} + +/* C++ specific styling */ + +.sig-inline.c-texpr, +.sig-inline.cpp-texpr { + font-family: unset; +} + +.sig.c .k, .sig.c .kt, +.sig.cpp .k, .sig.cpp .kt { + color: #0033B3; +} + +.sig.c .m, +.sig.cpp .m { + color: #1750EB; +} + +.sig.c .s, .sig.c .sc, +.sig.cpp .s, .sig.cpp .sc { + color: #067D17; +} + + +/* -- other body styles ----------------------------------------------------- */ + +ol.arabic { + list-style: decimal; +} + +ol.loweralpha { + list-style: lower-alpha; +} + +ol.upperalpha { + list-style: upper-alpha; +} + +ol.lowerroman { + list-style: lower-roman; +} + +ol.upperroman { + list-style: upper-roman; +} + +:not(li) > ol > li:first-child > :first-child, +:not(li) > ul > li:first-child > :first-child { + margin-top: 0px; +} + +:not(li) > ol > li:last-child > :last-child, +:not(li) > ul > li:last-child > :last-child { + margin-bottom: 0px; +} + +ol.simple ol p, +ol.simple ul p, +ul.simple ol p, +ul.simple ul p { + margin-top: 0; +} + +ol.simple > li:not(:first-child) > p, +ul.simple > li:not(:first-child) > p { + margin-top: 0; +} + +ol.simple p, +ul.simple p { + margin-bottom: 0; +} + +aside.footnote > span, +div.citation > span { + float: left; +} +aside.footnote > span:last-of-type, +div.citation > span:last-of-type { + padding-right: 0.5em; +} +aside.footnote > p { + margin-left: 2em; +} +div.citation > p { + margin-left: 4em; +} +aside.footnote > p:last-of-type, +div.citation > p:last-of-type { + margin-bottom: 0em; +} +aside.footnote > p:last-of-type:after, +div.citation > p:last-of-type:after { + content: ""; + clear: both; +} + +dl.field-list { + display: grid; + grid-template-columns: fit-content(30%) auto; +} + +dl.field-list > dt { + font-weight: bold; + word-break: break-word; + padding-left: 0.5em; + padding-right: 5px; +} + +dl.field-list > dd { + padding-left: 0.5em; + margin-top: 0em; + margin-left: 0em; + margin-bottom: 0em; +} + +dl { + margin-bottom: 15px; +} + +dd > :first-child { + margin-top: 0px; +} + +dd ul, dd table { + margin-bottom: 10px; +} + +dd { + margin-top: 3px; + margin-bottom: 10px; + margin-left: 30px; +} + +.sig dd { + margin-top: 0px; + margin-bottom: 0px; +} + +.sig dl { + margin-top: 0px; + margin-bottom: 0px; +} + +dl > dd:last-child, +dl > dd:last-child > :last-child { + margin-bottom: 0; +} + +dt:target, span.highlighted { + background-color: #fbe54e; +} + +rect.highlighted { + fill: #fbe54e; +} + +dl.glossary dt { + font-weight: bold; + font-size: 1.1em; +} + +.versionmodified { + font-style: italic; +} + +.system-message { + background-color: #fda; + padding: 5px; + border: 3px solid red; +} + +.footnote:target { + background-color: #ffa; +} + +.line-block { + display: block; + margin-top: 1em; + margin-bottom: 1em; +} + +.line-block .line-block { + margin-top: 0; + margin-bottom: 0; + margin-left: 1.5em; +} + +.guilabel, .menuselection { + font-family: sans-serif; +} + +.accelerator { + text-decoration: underline; +} + +.classifier { + font-style: oblique; +} + +.classifier:before { + font-style: normal; + margin: 0 0.5em; + content: ":"; + display: inline-block; +} + +abbr, acronym { + border-bottom: dotted 1px; + cursor: help; +} + +/* -- code displays --------------------------------------------------------- */ + +pre { + overflow: auto; + overflow-y: hidden; /* fixes display issues on Chrome browsers */ +} + +pre, div[class*="highlight-"] { + clear: both; +} + +span.pre { + -moz-hyphens: none; + -ms-hyphens: none; + -webkit-hyphens: none; + hyphens: none; + white-space: nowrap; +} + +div[class*="highlight-"] { + margin: 1em 0; +} + +td.linenos pre { + border: 0; + background-color: transparent; + color: #aaa; +} + +table.highlighttable { + display: block; +} + +table.highlighttable tbody { + display: block; +} + +table.highlighttable tr { + display: flex; +} + +table.highlighttable td { + margin: 0; + padding: 0; +} + +table.highlighttable td.linenos { + padding-right: 0.5em; +} + +table.highlighttable td.code { + flex: 1; + overflow: hidden; +} + +.highlight .hll { + display: block; +} + +div.highlight pre, +table.highlighttable pre { + margin: 0; +} + +div.code-block-caption + div { + margin-top: 0; +} + +div.code-block-caption { + margin-top: 1em; + padding: 2px 5px; + font-size: small; +} + +div.code-block-caption code { + background-color: transparent; +} + +table.highlighttable td.linenos, +span.linenos, +div.highlight span.gp { /* gp: Generic.Prompt */ + user-select: none; + -webkit-user-select: text; /* Safari fallback only */ + -webkit-user-select: none; /* Chrome/Safari */ + -moz-user-select: none; /* Firefox */ + -ms-user-select: none; /* IE10+ */ +} + +div.code-block-caption span.caption-number { + padding: 0.1em 0.3em; + font-style: italic; +} + +div.code-block-caption span.caption-text { +} + +div.literal-block-wrapper { + margin: 1em 0; +} + +code.xref, a code { + background-color: transparent; + font-weight: bold; +} + +h1 code, h2 code, h3 code, h4 code, h5 code, h6 code { + background-color: transparent; +} + +.viewcode-link { + float: right; +} + +.viewcode-back { + float: right; + font-family: sans-serif; +} + +div.viewcode-block:target { + margin: -1px -10px; + padding: 0 10px; +} + +/* -- math display ---------------------------------------------------------- */ + +img.math { + vertical-align: middle; +} + +div.body div.math p { + text-align: center; +} + +span.eqno { + float: right; +} + +span.eqno a.headerlink { + position: absolute; + z-index: 1; +} + +div.math:hover a.headerlink { + visibility: visible; +} + +/* -- printout stylesheet --------------------------------------------------- */ + +@media print { + div.document, + div.documentwrapper, + div.bodywrapper { + margin: 0 !important; + width: 100%; + } + + div.sphinxsidebar, + div.related, + div.footer, + #top-link { + display: none; + } +} \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/badge_only.css b/dev/vendor/mathematics_in_lean/html/_static/css/badge_only.css new file mode 100644 index 0000000..88ba55b --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/css/badge_only.css @@ -0,0 +1 @@ +.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions .rst-other-versions .rtd-current-item{font-weight:700}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}#flyout-search-form{padding:6px} \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/custom.css b/dev/vendor/mathematics_in_lean/html/_static/css/custom.css new file mode 100644 index 0000000..b387e78 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/css/custom.css @@ -0,0 +1,16 @@ +.rst-content .admonition .admonition-title:before { + content: none; +} + +.rst-content .admonition-theorem .admonition-title:before { + content: none; +} + +.rst-content .admonition-proof .admonition-title:before { + content: none; +} + +code.literal { + color: #404040 !important; + background-color: #fbfbfb !important; +} diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Bold.woff b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Bold.woff new file mode 100644 index 0000000..6cb6000 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Bold.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Bold.woff2 b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Bold.woff2 new file mode 100644 index 0000000..7059e23 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Bold.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Regular.woff b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Regular.woff new file mode 100644 index 0000000..f815f63 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Regular.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Regular.woff2 b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Regular.woff2 new file mode 100644 index 0000000..f2c76e5 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/Roboto-Slab-Regular.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.eot b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.eot new file mode 100644 index 0000000..e9f60ca Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.eot differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.svg b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.svg new file mode 100644 index 0000000..855c845 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.svg @@ -0,0 +1,2671 @@ + + + + +Created by FontForge 20120731 at Mon Oct 24 17:37:40 2016 + By ,,, +Copyright Dave Gandy 2016. All rights reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.ttf b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.ttf new file mode 100644 index 0000000..35acda2 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.ttf differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.woff b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.woff new file mode 100644 index 0000000..400014a Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.woff2 b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.woff2 new file mode 100644 index 0000000..4d13fc6 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/fontawesome-webfont.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold-italic.woff b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold-italic.woff new file mode 100644 index 0000000..88ad05b Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold-italic.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold-italic.woff2 b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold-italic.woff2 new file mode 100644 index 0000000..c4e3d80 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold-italic.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold.woff b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold.woff new file mode 100644 index 0000000..c6dff51 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold.woff2 b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold.woff2 new file mode 100644 index 0000000..bb19504 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-bold.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal-italic.woff b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal-italic.woff new file mode 100644 index 0000000..76114bc Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal-italic.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal-italic.woff2 b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal-italic.woff2 new file mode 100644 index 0000000..3404f37 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal-italic.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal.woff b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal.woff new file mode 100644 index 0000000..ae1307f Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal.woff2 b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal.woff2 new file mode 100644 index 0000000..3bf9843 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/css/fonts/lato-normal.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/css/theme.css b/dev/vendor/mathematics_in_lean/html/_static/css/theme.css new file mode 100644 index 0000000..0f14f10 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/css/theme.css @@ -0,0 +1,4 @@ +html{box-sizing:border-box}*,:after,:before{box-sizing:inherit}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden],audio:not([controls]){display:none}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}blockquote{margin:0}dfn{font-style:italic}ins{background:#ff9;text-decoration:none}ins,mark{color:#000}mark{background:#ff0;font-style:italic;font-weight:700}.rst-content code,.rst-content tt,code,kbd,pre,samp{font-family:monospace,serif;_font-family:courier new,monospace;font-size:1em}pre{white-space:pre}q{quotes:none}q:after,q:before{content:"";content:none}small{font-size:85%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}dl,ol,ul{margin:0;padding:0;list-style:none;list-style-image:none}li{list-style:none}dd{margin:0}img{border:0;-ms-interpolation-mode:bicubic;vertical-align:middle;max-width:100%}svg:not(:root){overflow:hidden}figure,form{margin:0}label{cursor:pointer}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal}button,input[type=button],input[type=reset],input[type=submit]{cursor:pointer;-webkit-appearance:button;*overflow:visible}button[disabled],input[disabled]{cursor:default}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}textarea{resize:vertical}table{border-collapse:collapse;border-spacing:0}td{vertical-align:top}.chromeframe{margin:.2em 0;background:#ccc;color:#000;padding:.2em 0}.ir{display:block;border:0;text-indent:-999em;overflow:hidden;background-color:transparent;background-repeat:no-repeat;text-align:left;direction:ltr;*line-height:0}.ir br{display:none}.hidden{display:none!important;visibility:hidden}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.visuallyhidden.focusable:active,.visuallyhidden.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.invisible{visibility:hidden}.relative{position:relative}big,small{font-size:100%}@media print{body,html,section{background:none!important}*{box-shadow:none!important;text-shadow:none!important;filter:none!important;-ms-filter:none!important}a,a:visited{text-decoration:underline}.ir a:after,a[href^="#"]:after,a[href^="javascript:"]:after{content:""}blockquote,pre{page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}.rst-content .toctree-wrapper>p.caption,h2,h3,p{orphans:3;widows:3}.rst-content .toctree-wrapper>p.caption,h2,h3{page-break-after:avoid}}.btn,.fa:before,.icon:before,.rst-content .admonition,.rst-content .admonition-title:before,.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .code-block-caption .headerlink:before,.rst-content .danger,.rst-content .eqno .headerlink:before,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .note,.rst-content .seealso,.rst-content .tip,.rst-content .warning,.rst-content code.download span:first-child:before,.rst-content dl dt .headerlink:before,.rst-content h1 .headerlink:before,.rst-content h2 .headerlink:before,.rst-content h3 .headerlink:before,.rst-content h4 .headerlink:before,.rst-content h5 .headerlink:before,.rst-content h6 .headerlink:before,.rst-content p.caption .headerlink:before,.rst-content p .headerlink:before,.rst-content table>caption .headerlink:before,.rst-content tt.download span:first-child:before,.wy-alert,.wy-dropdown .caret:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before,.wy-menu-vertical li.current>a button.toctree-expand:before,.wy-menu-vertical li.on a button.toctree-expand:before,.wy-menu-vertical li button.toctree-expand:before,input[type=color],input[type=date],input[type=datetime-local],input[type=datetime],input[type=email],input[type=month],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=time],input[type=url],input[type=week],select,textarea{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}/*! + * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome + * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) + */@font-face{font-family:FontAwesome;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713);src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix&v=4.7.0) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#fontawesomeregular) format("svg");font-weight:400;font-style:normal}.fa,.icon,.rst-content .admonition-title,.rst-content .code-block-caption .headerlink,.rst-content .eqno .headerlink,.rst-content code.download span:first-child,.rst-content dl dt .headerlink,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content p.caption .headerlink,.rst-content p .headerlink,.rst-content table>caption .headerlink,.rst-content tt.download span:first-child,.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand,.wy-menu-vertical li button.toctree-expand{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14286em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14286em;width:2.14286em;top:.14286em;text-align:center}.fa-li.fa-lg{left:-1.85714em}.fa-border{padding:.2em .25em .15em;border:.08em solid #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa-pull-left.icon,.fa.fa-pull-left,.rst-content .code-block-caption .fa-pull-left.headerlink,.rst-content .eqno .fa-pull-left.headerlink,.rst-content .fa-pull-left.admonition-title,.rst-content code.download span.fa-pull-left:first-child,.rst-content dl dt .fa-pull-left.headerlink,.rst-content h1 .fa-pull-left.headerlink,.rst-content h2 .fa-pull-left.headerlink,.rst-content h3 .fa-pull-left.headerlink,.rst-content h4 .fa-pull-left.headerlink,.rst-content h5 .fa-pull-left.headerlink,.rst-content h6 .fa-pull-left.headerlink,.rst-content p .fa-pull-left.headerlink,.rst-content table>caption .fa-pull-left.headerlink,.rst-content tt.download span.fa-pull-left:first-child,.wy-menu-vertical li.current>a button.fa-pull-left.toctree-expand,.wy-menu-vertical li.on a button.fa-pull-left.toctree-expand,.wy-menu-vertical li button.fa-pull-left.toctree-expand{margin-right:.3em}.fa-pull-right.icon,.fa.fa-pull-right,.rst-content .code-block-caption .fa-pull-right.headerlink,.rst-content .eqno .fa-pull-right.headerlink,.rst-content .fa-pull-right.admonition-title,.rst-content code.download span.fa-pull-right:first-child,.rst-content dl dt .fa-pull-right.headerlink,.rst-content h1 .fa-pull-right.headerlink,.rst-content h2 .fa-pull-right.headerlink,.rst-content h3 .fa-pull-right.headerlink,.rst-content h4 .fa-pull-right.headerlink,.rst-content h5 .fa-pull-right.headerlink,.rst-content h6 .fa-pull-right.headerlink,.rst-content p .fa-pull-right.headerlink,.rst-content table>caption .fa-pull-right.headerlink,.rst-content tt.download span.fa-pull-right:first-child,.wy-menu-vertical li.current>a button.fa-pull-right.toctree-expand,.wy-menu-vertical li.on a button.fa-pull-right.toctree-expand,.wy-menu-vertical li button.fa-pull-right.toctree-expand{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left,.pull-left.icon,.rst-content .code-block-caption .pull-left.headerlink,.rst-content .eqno .pull-left.headerlink,.rst-content .pull-left.admonition-title,.rst-content code.download span.pull-left:first-child,.rst-content dl dt .pull-left.headerlink,.rst-content h1 .pull-left.headerlink,.rst-content h2 .pull-left.headerlink,.rst-content h3 .pull-left.headerlink,.rst-content h4 .pull-left.headerlink,.rst-content h5 .pull-left.headerlink,.rst-content h6 .pull-left.headerlink,.rst-content p .pull-left.headerlink,.rst-content table>caption .pull-left.headerlink,.rst-content tt.download span.pull-left:first-child,.wy-menu-vertical li.current>a button.pull-left.toctree-expand,.wy-menu-vertical li.on a button.pull-left.toctree-expand,.wy-menu-vertical li button.pull-left.toctree-expand{margin-right:.3em}.fa.pull-right,.pull-right.icon,.rst-content .code-block-caption .pull-right.headerlink,.rst-content .eqno .pull-right.headerlink,.rst-content .pull-right.admonition-title,.rst-content code.download span.pull-right:first-child,.rst-content dl dt .pull-right.headerlink,.rst-content h1 .pull-right.headerlink,.rst-content h2 .pull-right.headerlink,.rst-content h3 .pull-right.headerlink,.rst-content h4 .pull-right.headerlink,.rst-content h5 .pull-right.headerlink,.rst-content h6 .pull-right.headerlink,.rst-content p .pull-right.headerlink,.rst-content table>caption .pull-right.headerlink,.rst-content tt.download span.pull-right:first-child,.wy-menu-vertical li.current>a button.pull-right.toctree-expand,.wy-menu-vertical li.on a button.pull-right.toctree-expand,.wy-menu-vertical li button.pull-right.toctree-expand{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s linear infinite;animation:fa-spin 2s linear infinite}.fa-pulse{-webkit-animation:fa-spin 1s steps(8) infinite;animation:fa-spin 1s steps(8) infinite}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scaleX(-1);-ms-transform:scaleX(-1);transform:scaleX(-1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scaleY(-1);-ms-transform:scaleY(-1);transform:scaleY(-1)}:root .fa-flip-horizontal,:root .fa-flip-vertical,:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:""}.fa-music:before{content:""}.fa-search:before,.icon-search:before{content:""}.fa-envelope-o:before{content:""}.fa-heart:before{content:""}.fa-star:before{content:""}.fa-star-o:before{content:""}.fa-user:before{content:""}.fa-film:before{content:""}.fa-th-large:before{content:""}.fa-th:before{content:""}.fa-th-list:before{content:""}.fa-check:before{content:""}.fa-close:before,.fa-remove:before,.fa-times:before{content:""}.fa-search-plus:before{content:""}.fa-search-minus:before{content:""}.fa-power-off:before{content:""}.fa-signal:before{content:""}.fa-cog:before,.fa-gear:before{content:""}.fa-trash-o:before{content:""}.fa-home:before,.icon-home:before{content:""}.fa-file-o:before{content:""}.fa-clock-o:before{content:""}.fa-road:before{content:""}.fa-download:before,.rst-content code.download span:first-child:before,.rst-content tt.download span:first-child:before{content:""}.fa-arrow-circle-o-down:before{content:""}.fa-arrow-circle-o-up:before{content:""}.fa-inbox:before{content:""}.fa-play-circle-o:before{content:""}.fa-repeat:before,.fa-rotate-right:before{content:""}.fa-refresh:before{content:""}.fa-list-alt:before{content:""}.fa-lock:before{content:""}.fa-flag:before{content:""}.fa-headphones:before{content:""}.fa-volume-off:before{content:""}.fa-volume-down:before{content:""}.fa-volume-up:before{content:""}.fa-qrcode:before{content:""}.fa-barcode:before{content:""}.fa-tag:before{content:""}.fa-tags:before{content:""}.fa-book:before,.icon-book:before{content:""}.fa-bookmark:before{content:""}.fa-print:before{content:""}.fa-camera:before{content:""}.fa-font:before{content:""}.fa-bold:before{content:""}.fa-italic:before{content:""}.fa-text-height:before{content:""}.fa-text-width:before{content:""}.fa-align-left:before{content:""}.fa-align-center:before{content:""}.fa-align-right:before{content:""}.fa-align-justify:before{content:""}.fa-list:before{content:""}.fa-dedent:before,.fa-outdent:before{content:""}.fa-indent:before{content:""}.fa-video-camera:before{content:""}.fa-image:before,.fa-photo:before,.fa-picture-o:before{content:""}.fa-pencil:before{content:""}.fa-map-marker:before{content:""}.fa-adjust:before{content:""}.fa-tint:before{content:""}.fa-edit:before,.fa-pencil-square-o:before{content:""}.fa-share-square-o:before{content:""}.fa-check-square-o:before{content:""}.fa-arrows:before{content:""}.fa-step-backward:before{content:""}.fa-fast-backward:before{content:""}.fa-backward:before{content:""}.fa-play:before{content:""}.fa-pause:before{content:""}.fa-stop:before{content:""}.fa-forward:before{content:""}.fa-fast-forward:before{content:""}.fa-step-forward:before{content:""}.fa-eject:before{content:""}.fa-chevron-left:before{content:""}.fa-chevron-right:before{content:""}.fa-plus-circle:before{content:""}.fa-minus-circle:before{content:""}.fa-times-circle:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before{content:""}.fa-check-circle:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before{content:""}.fa-question-circle:before{content:""}.fa-info-circle:before{content:""}.fa-crosshairs:before{content:""}.fa-times-circle-o:before{content:""}.fa-check-circle-o:before{content:""}.fa-ban:before{content:""}.fa-arrow-left:before{content:""}.fa-arrow-right:before{content:""}.fa-arrow-up:before{content:""}.fa-arrow-down:before{content:""}.fa-mail-forward:before,.fa-share:before{content:""}.fa-expand:before{content:""}.fa-compress:before{content:""}.fa-plus:before{content:""}.fa-minus:before{content:""}.fa-asterisk:before{content:""}.fa-exclamation-circle:before,.rst-content .admonition-title:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before{content:""}.fa-gift:before{content:""}.fa-leaf:before{content:""}.fa-fire:before,.icon-fire:before{content:""}.fa-eye:before{content:""}.fa-eye-slash:before{content:""}.fa-exclamation-triangle:before,.fa-warning:before{content:""}.fa-plane:before{content:""}.fa-calendar:before{content:""}.fa-random:before{content:""}.fa-comment:before{content:""}.fa-magnet:before{content:""}.fa-chevron-up:before{content:""}.fa-chevron-down:before{content:""}.fa-retweet:before{content:""}.fa-shopping-cart:before{content:""}.fa-folder:before{content:""}.fa-folder-open:before{content:""}.fa-arrows-v:before{content:""}.fa-arrows-h:before{content:""}.fa-bar-chart-o:before,.fa-bar-chart:before{content:""}.fa-twitter-square:before{content:""}.fa-facebook-square:before{content:""}.fa-camera-retro:before{content:""}.fa-key:before{content:""}.fa-cogs:before,.fa-gears:before{content:""}.fa-comments:before{content:""}.fa-thumbs-o-up:before{content:""}.fa-thumbs-o-down:before{content:""}.fa-star-half:before{content:""}.fa-heart-o:before{content:""}.fa-sign-out:before{content:""}.fa-linkedin-square:before{content:""}.fa-thumb-tack:before{content:""}.fa-external-link:before{content:""}.fa-sign-in:before{content:""}.fa-trophy:before{content:""}.fa-github-square:before{content:""}.fa-upload:before{content:""}.fa-lemon-o:before{content:""}.fa-phone:before{content:""}.fa-square-o:before{content:""}.fa-bookmark-o:before{content:""}.fa-phone-square:before{content:""}.fa-twitter:before{content:""}.fa-facebook-f:before,.fa-facebook:before{content:""}.fa-github:before,.icon-github:before{content:""}.fa-unlock:before{content:""}.fa-credit-card:before{content:""}.fa-feed:before,.fa-rss:before{content:""}.fa-hdd-o:before{content:""}.fa-bullhorn:before{content:""}.fa-bell:before{content:""}.fa-certificate:before{content:""}.fa-hand-o-right:before{content:""}.fa-hand-o-left:before{content:""}.fa-hand-o-up:before{content:""}.fa-hand-o-down:before{content:""}.fa-arrow-circle-left:before,.icon-circle-arrow-left:before{content:""}.fa-arrow-circle-right:before,.icon-circle-arrow-right:before{content:""}.fa-arrow-circle-up:before{content:""}.fa-arrow-circle-down:before{content:""}.fa-globe:before{content:""}.fa-wrench:before{content:""}.fa-tasks:before{content:""}.fa-filter:before{content:""}.fa-briefcase:before{content:""}.fa-arrows-alt:before{content:""}.fa-group:before,.fa-users:before{content:""}.fa-chain:before,.fa-link:before,.icon-link:before{content:""}.fa-cloud:before{content:""}.fa-flask:before{content:""}.fa-cut:before,.fa-scissors:before{content:""}.fa-copy:before,.fa-files-o:before{content:""}.fa-paperclip:before{content:""}.fa-floppy-o:before,.fa-save:before{content:""}.fa-square:before{content:""}.fa-bars:before,.fa-navicon:before,.fa-reorder:before{content:""}.fa-list-ul:before{content:""}.fa-list-ol:before{content:""}.fa-strikethrough:before{content:""}.fa-underline:before{content:""}.fa-table:before{content:""}.fa-magic:before{content:""}.fa-truck:before{content:""}.fa-pinterest:before{content:""}.fa-pinterest-square:before{content:""}.fa-google-plus-square:before{content:""}.fa-google-plus:before{content:""}.fa-money:before{content:""}.fa-caret-down:before,.icon-caret-down:before,.wy-dropdown .caret:before{content:""}.fa-caret-up:before{content:""}.fa-caret-left:before{content:""}.fa-caret-right:before{content:""}.fa-columns:before{content:""}.fa-sort:before,.fa-unsorted:before{content:""}.fa-sort-desc:before,.fa-sort-down:before{content:""}.fa-sort-asc:before,.fa-sort-up:before{content:""}.fa-envelope:before{content:""}.fa-linkedin:before{content:""}.fa-rotate-left:before,.fa-undo:before{content:""}.fa-gavel:before,.fa-legal:before{content:""}.fa-dashboard:before,.fa-tachometer:before{content:""}.fa-comment-o:before{content:""}.fa-comments-o:before{content:""}.fa-bolt:before,.fa-flash:before{content:""}.fa-sitemap:before{content:""}.fa-umbrella:before{content:""}.fa-clipboard:before,.fa-paste:before{content:""}.fa-lightbulb-o:before{content:""}.fa-exchange:before{content:""}.fa-cloud-download:before{content:""}.fa-cloud-upload:before{content:""}.fa-user-md:before{content:""}.fa-stethoscope:before{content:""}.fa-suitcase:before{content:""}.fa-bell-o:before{content:""}.fa-coffee:before{content:""}.fa-cutlery:before{content:""}.fa-file-text-o:before{content:""}.fa-building-o:before{content:""}.fa-hospital-o:before{content:""}.fa-ambulance:before{content:""}.fa-medkit:before{content:""}.fa-fighter-jet:before{content:""}.fa-beer:before{content:""}.fa-h-square:before{content:""}.fa-plus-square:before{content:""}.fa-angle-double-left:before{content:""}.fa-angle-double-right:before{content:""}.fa-angle-double-up:before{content:""}.fa-angle-double-down:before{content:""}.fa-angle-left:before{content:""}.fa-angle-right:before{content:""}.fa-angle-up:before{content:""}.fa-angle-down:before{content:""}.fa-desktop:before{content:""}.fa-laptop:before{content:""}.fa-tablet:before{content:""}.fa-mobile-phone:before,.fa-mobile:before{content:""}.fa-circle-o:before{content:""}.fa-quote-left:before{content:""}.fa-quote-right:before{content:""}.fa-spinner:before{content:""}.fa-circle:before{content:""}.fa-mail-reply:before,.fa-reply:before{content:""}.fa-github-alt:before{content:""}.fa-folder-o:before{content:""}.fa-folder-open-o:before{content:""}.fa-smile-o:before{content:""}.fa-frown-o:before{content:""}.fa-meh-o:before{content:""}.fa-gamepad:before{content:""}.fa-keyboard-o:before{content:""}.fa-flag-o:before{content:""}.fa-flag-checkered:before{content:""}.fa-terminal:before{content:""}.fa-code:before{content:""}.fa-mail-reply-all:before,.fa-reply-all:before{content:""}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:""}.fa-location-arrow:before{content:""}.fa-crop:before{content:""}.fa-code-fork:before{content:""}.fa-chain-broken:before,.fa-unlink:before{content:""}.fa-question:before{content:""}.fa-info:before{content:""}.fa-exclamation:before{content:""}.fa-superscript:before{content:""}.fa-subscript:before{content:""}.fa-eraser:before{content:""}.fa-puzzle-piece:before{content:""}.fa-microphone:before{content:""}.fa-microphone-slash:before{content:""}.fa-shield:before{content:""}.fa-calendar-o:before{content:""}.fa-fire-extinguisher:before{content:""}.fa-rocket:before{content:""}.fa-maxcdn:before{content:""}.fa-chevron-circle-left:before{content:""}.fa-chevron-circle-right:before{content:""}.fa-chevron-circle-up:before{content:""}.fa-chevron-circle-down:before{content:""}.fa-html5:before{content:""}.fa-css3:before{content:""}.fa-anchor:before{content:""}.fa-unlock-alt:before{content:""}.fa-bullseye:before{content:""}.fa-ellipsis-h:before{content:""}.fa-ellipsis-v:before{content:""}.fa-rss-square:before{content:""}.fa-play-circle:before{content:""}.fa-ticket:before{content:""}.fa-minus-square:before{content:""}.fa-minus-square-o:before,.wy-menu-vertical li.current>a button.toctree-expand:before,.wy-menu-vertical li.on a button.toctree-expand:before{content:""}.fa-level-up:before{content:""}.fa-level-down:before{content:""}.fa-check-square:before{content:""}.fa-pencil-square:before{content:""}.fa-external-link-square:before{content:""}.fa-share-square:before{content:""}.fa-compass:before{content:""}.fa-caret-square-o-down:before,.fa-toggle-down:before{content:""}.fa-caret-square-o-up:before,.fa-toggle-up:before{content:""}.fa-caret-square-o-right:before,.fa-toggle-right:before{content:""}.fa-eur:before,.fa-euro:before{content:""}.fa-gbp:before{content:""}.fa-dollar:before,.fa-usd:before{content:""}.fa-inr:before,.fa-rupee:before{content:""}.fa-cny:before,.fa-jpy:before,.fa-rmb:before,.fa-yen:before{content:""}.fa-rouble:before,.fa-rub:before,.fa-ruble:before{content:""}.fa-krw:before,.fa-won:before{content:""}.fa-bitcoin:before,.fa-btc:before{content:""}.fa-file:before{content:""}.fa-file-text:before{content:""}.fa-sort-alpha-asc:before{content:""}.fa-sort-alpha-desc:before{content:""}.fa-sort-amount-asc:before{content:""}.fa-sort-amount-desc:before{content:""}.fa-sort-numeric-asc:before{content:""}.fa-sort-numeric-desc:before{content:""}.fa-thumbs-up:before{content:""}.fa-thumbs-down:before{content:""}.fa-youtube-square:before{content:""}.fa-youtube:before{content:""}.fa-xing:before{content:""}.fa-xing-square:before{content:""}.fa-youtube-play:before{content:""}.fa-dropbox:before{content:""}.fa-stack-overflow:before{content:""}.fa-instagram:before{content:""}.fa-flickr:before{content:""}.fa-adn:before{content:""}.fa-bitbucket:before,.icon-bitbucket:before{content:""}.fa-bitbucket-square:before{content:""}.fa-tumblr:before{content:""}.fa-tumblr-square:before{content:""}.fa-long-arrow-down:before{content:""}.fa-long-arrow-up:before{content:""}.fa-long-arrow-left:before{content:""}.fa-long-arrow-right:before{content:""}.fa-apple:before{content:""}.fa-windows:before{content:""}.fa-android:before{content:""}.fa-linux:before{content:""}.fa-dribbble:before{content:""}.fa-skype:before{content:""}.fa-foursquare:before{content:""}.fa-trello:before{content:""}.fa-female:before{content:""}.fa-male:before{content:""}.fa-gittip:before,.fa-gratipay:before{content:""}.fa-sun-o:before{content:""}.fa-moon-o:before{content:""}.fa-archive:before{content:""}.fa-bug:before{content:""}.fa-vk:before{content:""}.fa-weibo:before{content:""}.fa-renren:before{content:""}.fa-pagelines:before{content:""}.fa-stack-exchange:before{content:""}.fa-arrow-circle-o-right:before{content:""}.fa-arrow-circle-o-left:before{content:""}.fa-caret-square-o-left:before,.fa-toggle-left:before{content:""}.fa-dot-circle-o:before{content:""}.fa-wheelchair:before{content:""}.fa-vimeo-square:before{content:""}.fa-try:before,.fa-turkish-lira:before{content:""}.fa-plus-square-o:before,.wy-menu-vertical li button.toctree-expand:before{content:""}.fa-space-shuttle:before{content:""}.fa-slack:before{content:""}.fa-envelope-square:before{content:""}.fa-wordpress:before{content:""}.fa-openid:before{content:""}.fa-bank:before,.fa-institution:before,.fa-university:before{content:""}.fa-graduation-cap:before,.fa-mortar-board:before{content:""}.fa-yahoo:before{content:""}.fa-google:before{content:""}.fa-reddit:before{content:""}.fa-reddit-square:before{content:""}.fa-stumbleupon-circle:before{content:""}.fa-stumbleupon:before{content:""}.fa-delicious:before{content:""}.fa-digg:before{content:""}.fa-pied-piper-pp:before{content:""}.fa-pied-piper-alt:before{content:""}.fa-drupal:before{content:""}.fa-joomla:before{content:""}.fa-language:before{content:""}.fa-fax:before{content:""}.fa-building:before{content:""}.fa-child:before{content:""}.fa-paw:before{content:""}.fa-spoon:before{content:""}.fa-cube:before{content:""}.fa-cubes:before{content:""}.fa-behance:before{content:""}.fa-behance-square:before{content:""}.fa-steam:before{content:""}.fa-steam-square:before{content:""}.fa-recycle:before{content:""}.fa-automobile:before,.fa-car:before{content:""}.fa-cab:before,.fa-taxi:before{content:""}.fa-tree:before{content:""}.fa-spotify:before{content:""}.fa-deviantart:before{content:""}.fa-soundcloud:before{content:""}.fa-database:before{content:""}.fa-file-pdf-o:before{content:""}.fa-file-word-o:before{content:""}.fa-file-excel-o:before{content:""}.fa-file-powerpoint-o:before{content:""}.fa-file-image-o:before,.fa-file-photo-o:before,.fa-file-picture-o:before{content:""}.fa-file-archive-o:before,.fa-file-zip-o:before{content:""}.fa-file-audio-o:before,.fa-file-sound-o:before{content:""}.fa-file-movie-o:before,.fa-file-video-o:before{content:""}.fa-file-code-o:before{content:""}.fa-vine:before{content:""}.fa-codepen:before{content:""}.fa-jsfiddle:before{content:""}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-ring:before,.fa-life-saver:before,.fa-support:before{content:""}.fa-circle-o-notch:before{content:""}.fa-ra:before,.fa-rebel:before,.fa-resistance:before{content:""}.fa-empire:before,.fa-ge:before{content:""}.fa-git-square:before{content:""}.fa-git:before{content:""}.fa-hacker-news:before,.fa-y-combinator-square:before,.fa-yc-square:before{content:""}.fa-tencent-weibo:before{content:""}.fa-qq:before{content:""}.fa-wechat:before,.fa-weixin:before{content:""}.fa-paper-plane:before,.fa-send:before{content:""}.fa-paper-plane-o:before,.fa-send-o:before{content:""}.fa-history:before{content:""}.fa-circle-thin:before{content:""}.fa-header:before{content:""}.fa-paragraph:before{content:""}.fa-sliders:before{content:""}.fa-share-alt:before{content:""}.fa-share-alt-square:before{content:""}.fa-bomb:before{content:""}.fa-futbol-o:before,.fa-soccer-ball-o:before{content:""}.fa-tty:before{content:""}.fa-binoculars:before{content:""}.fa-plug:before{content:""}.fa-slideshare:before{content:""}.fa-twitch:before{content:""}.fa-yelp:before{content:""}.fa-newspaper-o:before{content:""}.fa-wifi:before{content:""}.fa-calculator:before{content:""}.fa-paypal:before{content:""}.fa-google-wallet:before{content:""}.fa-cc-visa:before{content:""}.fa-cc-mastercard:before{content:""}.fa-cc-discover:before{content:""}.fa-cc-amex:before{content:""}.fa-cc-paypal:before{content:""}.fa-cc-stripe:before{content:""}.fa-bell-slash:before{content:""}.fa-bell-slash-o:before{content:""}.fa-trash:before{content:""}.fa-copyright:before{content:""}.fa-at:before{content:""}.fa-eyedropper:before{content:""}.fa-paint-brush:before{content:""}.fa-birthday-cake:before{content:""}.fa-area-chart:before{content:""}.fa-pie-chart:before{content:""}.fa-line-chart:before{content:""}.fa-lastfm:before{content:""}.fa-lastfm-square:before{content:""}.fa-toggle-off:before{content:""}.fa-toggle-on:before{content:""}.fa-bicycle:before{content:""}.fa-bus:before{content:""}.fa-ioxhost:before{content:""}.fa-angellist:before{content:""}.fa-cc:before{content:""}.fa-ils:before,.fa-shekel:before,.fa-sheqel:before{content:""}.fa-meanpath:before{content:""}.fa-buysellads:before{content:""}.fa-connectdevelop:before{content:""}.fa-dashcube:before{content:""}.fa-forumbee:before{content:""}.fa-leanpub:before{content:""}.fa-sellsy:before{content:""}.fa-shirtsinbulk:before{content:""}.fa-simplybuilt:before{content:""}.fa-skyatlas:before{content:""}.fa-cart-plus:before{content:""}.fa-cart-arrow-down:before{content:""}.fa-diamond:before{content:""}.fa-ship:before{content:""}.fa-user-secret:before{content:""}.fa-motorcycle:before{content:""}.fa-street-view:before{content:""}.fa-heartbeat:before{content:""}.fa-venus:before{content:""}.fa-mars:before{content:""}.fa-mercury:before{content:""}.fa-intersex:before,.fa-transgender:before{content:""}.fa-transgender-alt:before{content:""}.fa-venus-double:before{content:""}.fa-mars-double:before{content:""}.fa-venus-mars:before{content:""}.fa-mars-stroke:before{content:""}.fa-mars-stroke-v:before{content:""}.fa-mars-stroke-h:before{content:""}.fa-neuter:before{content:""}.fa-genderless:before{content:""}.fa-facebook-official:before{content:""}.fa-pinterest-p:before{content:""}.fa-whatsapp:before{content:""}.fa-server:before{content:""}.fa-user-plus:before{content:""}.fa-user-times:before{content:""}.fa-bed:before,.fa-hotel:before{content:""}.fa-viacoin:before{content:""}.fa-train:before{content:""}.fa-subway:before{content:""}.fa-medium:before{content:""}.fa-y-combinator:before,.fa-yc:before{content:""}.fa-optin-monster:before{content:""}.fa-opencart:before{content:""}.fa-expeditedssl:before{content:""}.fa-battery-4:before,.fa-battery-full:before,.fa-battery:before{content:""}.fa-battery-3:before,.fa-battery-three-quarters:before{content:""}.fa-battery-2:before,.fa-battery-half:before{content:""}.fa-battery-1:before,.fa-battery-quarter:before{content:""}.fa-battery-0:before,.fa-battery-empty:before{content:""}.fa-mouse-pointer:before{content:""}.fa-i-cursor:before{content:""}.fa-object-group:before{content:""}.fa-object-ungroup:before{content:""}.fa-sticky-note:before{content:""}.fa-sticky-note-o:before{content:""}.fa-cc-jcb:before{content:""}.fa-cc-diners-club:before{content:""}.fa-clone:before{content:""}.fa-balance-scale:before{content:""}.fa-hourglass-o:before{content:""}.fa-hourglass-1:before,.fa-hourglass-start:before{content:""}.fa-hourglass-2:before,.fa-hourglass-half:before{content:""}.fa-hourglass-3:before,.fa-hourglass-end:before{content:""}.fa-hourglass:before{content:""}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:""}.fa-hand-paper-o:before,.fa-hand-stop-o:before{content:""}.fa-hand-scissors-o:before{content:""}.fa-hand-lizard-o:before{content:""}.fa-hand-spock-o:before{content:""}.fa-hand-pointer-o:before{content:""}.fa-hand-peace-o:before{content:""}.fa-trademark:before{content:""}.fa-registered:before{content:""}.fa-creative-commons:before{content:""}.fa-gg:before{content:""}.fa-gg-circle:before{content:""}.fa-tripadvisor:before{content:""}.fa-odnoklassniki:before{content:""}.fa-odnoklassniki-square:before{content:""}.fa-get-pocket:before{content:""}.fa-wikipedia-w:before{content:""}.fa-safari:before{content:""}.fa-chrome:before{content:""}.fa-firefox:before{content:""}.fa-opera:before{content:""}.fa-internet-explorer:before{content:""}.fa-television:before,.fa-tv:before{content:""}.fa-contao:before{content:""}.fa-500px:before{content:""}.fa-amazon:before{content:""}.fa-calendar-plus-o:before{content:""}.fa-calendar-minus-o:before{content:""}.fa-calendar-times-o:before{content:""}.fa-calendar-check-o:before{content:""}.fa-industry:before{content:""}.fa-map-pin:before{content:""}.fa-map-signs:before{content:""}.fa-map-o:before{content:""}.fa-map:before{content:""}.fa-commenting:before{content:""}.fa-commenting-o:before{content:""}.fa-houzz:before{content:""}.fa-vimeo:before{content:""}.fa-black-tie:before{content:""}.fa-fonticons:before{content:""}.fa-reddit-alien:before{content:""}.fa-edge:before{content:""}.fa-credit-card-alt:before{content:""}.fa-codiepie:before{content:""}.fa-modx:before{content:""}.fa-fort-awesome:before{content:""}.fa-usb:before{content:""}.fa-product-hunt:before{content:""}.fa-mixcloud:before{content:""}.fa-scribd:before{content:""}.fa-pause-circle:before{content:""}.fa-pause-circle-o:before{content:""}.fa-stop-circle:before{content:""}.fa-stop-circle-o:before{content:""}.fa-shopping-bag:before{content:""}.fa-shopping-basket:before{content:""}.fa-hashtag:before{content:""}.fa-bluetooth:before{content:""}.fa-bluetooth-b:before{content:""}.fa-percent:before{content:""}.fa-gitlab:before,.icon-gitlab:before{content:""}.fa-wpbeginner:before{content:""}.fa-wpforms:before{content:""}.fa-envira:before{content:""}.fa-universal-access:before{content:""}.fa-wheelchair-alt:before{content:""}.fa-question-circle-o:before{content:""}.fa-blind:before{content:""}.fa-audio-description:before{content:""}.fa-volume-control-phone:before{content:""}.fa-braille:before{content:""}.fa-assistive-listening-systems:before{content:""}.fa-american-sign-language-interpreting:before,.fa-asl-interpreting:before{content:""}.fa-deaf:before,.fa-deafness:before,.fa-hard-of-hearing:before{content:""}.fa-glide:before{content:""}.fa-glide-g:before{content:""}.fa-sign-language:before,.fa-signing:before{content:""}.fa-low-vision:before{content:""}.fa-viadeo:before{content:""}.fa-viadeo-square:before{content:""}.fa-snapchat:before{content:""}.fa-snapchat-ghost:before{content:""}.fa-snapchat-square:before{content:""}.fa-pied-piper:before{content:""}.fa-first-order:before{content:""}.fa-yoast:before{content:""}.fa-themeisle:before{content:""}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:""}.fa-fa:before,.fa-font-awesome:before{content:""}.fa-handshake-o:before{content:""}.fa-envelope-open:before{content:""}.fa-envelope-open-o:before{content:""}.fa-linode:before{content:""}.fa-address-book:before{content:""}.fa-address-book-o:before{content:""}.fa-address-card:before,.fa-vcard:before{content:""}.fa-address-card-o:before,.fa-vcard-o:before{content:""}.fa-user-circle:before{content:""}.fa-user-circle-o:before{content:""}.fa-user-o:before{content:""}.fa-id-badge:before{content:""}.fa-drivers-license:before,.fa-id-card:before{content:""}.fa-drivers-license-o:before,.fa-id-card-o:before{content:""}.fa-quora:before{content:""}.fa-free-code-camp:before{content:""}.fa-telegram:before{content:""}.fa-thermometer-4:before,.fa-thermometer-full:before,.fa-thermometer:before{content:""}.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:""}.fa-thermometer-2:before,.fa-thermometer-half:before{content:""}.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:""}.fa-thermometer-0:before,.fa-thermometer-empty:before{content:""}.fa-shower:before{content:""}.fa-bath:before,.fa-bathtub:before,.fa-s15:before{content:""}.fa-podcast:before{content:""}.fa-window-maximize:before{content:""}.fa-window-minimize:before{content:""}.fa-window-restore:before{content:""}.fa-times-rectangle:before,.fa-window-close:before{content:""}.fa-times-rectangle-o:before,.fa-window-close-o:before{content:""}.fa-bandcamp:before{content:""}.fa-grav:before{content:""}.fa-etsy:before{content:""}.fa-imdb:before{content:""}.fa-ravelry:before{content:""}.fa-eercast:before{content:""}.fa-microchip:before{content:""}.fa-snowflake-o:before{content:""}.fa-superpowers:before{content:""}.fa-wpexplorer:before{content:""}.fa-meetup:before{content:""}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.fa,.icon,.rst-content .admonition-title,.rst-content .code-block-caption .headerlink,.rst-content .eqno .headerlink,.rst-content code.download span:first-child,.rst-content dl dt .headerlink,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content p.caption .headerlink,.rst-content p .headerlink,.rst-content table>caption .headerlink,.rst-content tt.download span:first-child,.wy-dropdown .caret,.wy-inline-validate.wy-inline-validate-danger .wy-input-context,.wy-inline-validate.wy-inline-validate-info .wy-input-context,.wy-inline-validate.wy-inline-validate-success .wy-input-context,.wy-inline-validate.wy-inline-validate-warning .wy-input-context,.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand,.wy-menu-vertical li button.toctree-expand{font-family:inherit}.fa:before,.icon:before,.rst-content .admonition-title:before,.rst-content .code-block-caption .headerlink:before,.rst-content .eqno .headerlink:before,.rst-content code.download span:first-child:before,.rst-content dl dt .headerlink:before,.rst-content h1 .headerlink:before,.rst-content h2 .headerlink:before,.rst-content h3 .headerlink:before,.rst-content h4 .headerlink:before,.rst-content h5 .headerlink:before,.rst-content h6 .headerlink:before,.rst-content p.caption .headerlink:before,.rst-content p .headerlink:before,.rst-content table>caption .headerlink:before,.rst-content tt.download span:first-child:before,.wy-dropdown .caret:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before,.wy-menu-vertical li.current>a button.toctree-expand:before,.wy-menu-vertical li.on a button.toctree-expand:before,.wy-menu-vertical li button.toctree-expand:before{font-family:FontAwesome;display:inline-block;font-style:normal;font-weight:400;line-height:1;text-decoration:inherit}.rst-content .code-block-caption a .headerlink,.rst-content .eqno a .headerlink,.rst-content a .admonition-title,.rst-content code.download a span:first-child,.rst-content dl dt a .headerlink,.rst-content h1 a .headerlink,.rst-content h2 a .headerlink,.rst-content h3 a .headerlink,.rst-content h4 a .headerlink,.rst-content h5 a .headerlink,.rst-content h6 a .headerlink,.rst-content p.caption a .headerlink,.rst-content p a .headerlink,.rst-content table>caption a .headerlink,.rst-content tt.download a span:first-child,.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand,.wy-menu-vertical li a button.toctree-expand,a .fa,a .icon,a .rst-content .admonition-title,a .rst-content .code-block-caption .headerlink,a .rst-content .eqno .headerlink,a .rst-content code.download span:first-child,a .rst-content dl dt .headerlink,a .rst-content h1 .headerlink,a .rst-content h2 .headerlink,a .rst-content h3 .headerlink,a .rst-content h4 .headerlink,a .rst-content h5 .headerlink,a .rst-content h6 .headerlink,a .rst-content p.caption .headerlink,a .rst-content p .headerlink,a .rst-content table>caption .headerlink,a .rst-content tt.download span:first-child,a .wy-menu-vertical li button.toctree-expand{display:inline-block;text-decoration:inherit}.btn .fa,.btn .icon,.btn .rst-content .admonition-title,.btn .rst-content .code-block-caption .headerlink,.btn .rst-content .eqno .headerlink,.btn .rst-content code.download span:first-child,.btn .rst-content dl dt .headerlink,.btn .rst-content h1 .headerlink,.btn .rst-content h2 .headerlink,.btn .rst-content h3 .headerlink,.btn .rst-content h4 .headerlink,.btn .rst-content h5 .headerlink,.btn .rst-content h6 .headerlink,.btn .rst-content p .headerlink,.btn .rst-content table>caption .headerlink,.btn .rst-content tt.download span:first-child,.btn .wy-menu-vertical li.current>a button.toctree-expand,.btn .wy-menu-vertical li.on a button.toctree-expand,.btn .wy-menu-vertical li button.toctree-expand,.nav .fa,.nav .icon,.nav .rst-content .admonition-title,.nav .rst-content .code-block-caption .headerlink,.nav .rst-content .eqno .headerlink,.nav .rst-content code.download span:first-child,.nav .rst-content dl dt .headerlink,.nav .rst-content h1 .headerlink,.nav .rst-content h2 .headerlink,.nav .rst-content h3 .headerlink,.nav .rst-content h4 .headerlink,.nav .rst-content h5 .headerlink,.nav .rst-content h6 .headerlink,.nav .rst-content p .headerlink,.nav .rst-content table>caption .headerlink,.nav .rst-content tt.download span:first-child,.nav .wy-menu-vertical li.current>a button.toctree-expand,.nav .wy-menu-vertical li.on a button.toctree-expand,.nav .wy-menu-vertical li button.toctree-expand,.rst-content .btn .admonition-title,.rst-content .code-block-caption .btn .headerlink,.rst-content .code-block-caption .nav .headerlink,.rst-content .eqno .btn .headerlink,.rst-content .eqno .nav .headerlink,.rst-content .nav .admonition-title,.rst-content code.download .btn span:first-child,.rst-content code.download .nav span:first-child,.rst-content dl dt .btn .headerlink,.rst-content dl dt .nav .headerlink,.rst-content h1 .btn .headerlink,.rst-content h1 .nav .headerlink,.rst-content h2 .btn .headerlink,.rst-content h2 .nav .headerlink,.rst-content h3 .btn .headerlink,.rst-content h3 .nav .headerlink,.rst-content h4 .btn .headerlink,.rst-content h4 .nav .headerlink,.rst-content h5 .btn .headerlink,.rst-content h5 .nav .headerlink,.rst-content h6 .btn .headerlink,.rst-content h6 .nav .headerlink,.rst-content p .btn .headerlink,.rst-content p .nav .headerlink,.rst-content table>caption .btn .headerlink,.rst-content table>caption .nav .headerlink,.rst-content tt.download .btn span:first-child,.rst-content tt.download .nav span:first-child,.wy-menu-vertical li .btn button.toctree-expand,.wy-menu-vertical li.current>a .btn button.toctree-expand,.wy-menu-vertical li.current>a .nav button.toctree-expand,.wy-menu-vertical li .nav button.toctree-expand,.wy-menu-vertical li.on a .btn button.toctree-expand,.wy-menu-vertical li.on a .nav button.toctree-expand{display:inline}.btn .fa-large.icon,.btn .fa.fa-large,.btn .rst-content .code-block-caption .fa-large.headerlink,.btn .rst-content .eqno .fa-large.headerlink,.btn .rst-content .fa-large.admonition-title,.btn .rst-content code.download span.fa-large:first-child,.btn .rst-content dl dt .fa-large.headerlink,.btn .rst-content h1 .fa-large.headerlink,.btn .rst-content h2 .fa-large.headerlink,.btn .rst-content h3 .fa-large.headerlink,.btn .rst-content h4 .fa-large.headerlink,.btn .rst-content h5 .fa-large.headerlink,.btn .rst-content h6 .fa-large.headerlink,.btn .rst-content p .fa-large.headerlink,.btn .rst-content table>caption .fa-large.headerlink,.btn .rst-content tt.download span.fa-large:first-child,.btn .wy-menu-vertical li button.fa-large.toctree-expand,.nav .fa-large.icon,.nav .fa.fa-large,.nav .rst-content .code-block-caption .fa-large.headerlink,.nav .rst-content .eqno .fa-large.headerlink,.nav .rst-content .fa-large.admonition-title,.nav .rst-content code.download span.fa-large:first-child,.nav .rst-content dl dt .fa-large.headerlink,.nav .rst-content h1 .fa-large.headerlink,.nav .rst-content h2 .fa-large.headerlink,.nav .rst-content h3 .fa-large.headerlink,.nav .rst-content h4 .fa-large.headerlink,.nav .rst-content h5 .fa-large.headerlink,.nav .rst-content h6 .fa-large.headerlink,.nav .rst-content p .fa-large.headerlink,.nav .rst-content table>caption .fa-large.headerlink,.nav .rst-content tt.download span.fa-large:first-child,.nav .wy-menu-vertical li button.fa-large.toctree-expand,.rst-content .btn .fa-large.admonition-title,.rst-content .code-block-caption .btn .fa-large.headerlink,.rst-content .code-block-caption .nav .fa-large.headerlink,.rst-content .eqno .btn .fa-large.headerlink,.rst-content .eqno .nav .fa-large.headerlink,.rst-content .nav .fa-large.admonition-title,.rst-content code.download .btn span.fa-large:first-child,.rst-content code.download .nav span.fa-large:first-child,.rst-content dl dt .btn .fa-large.headerlink,.rst-content dl dt .nav .fa-large.headerlink,.rst-content h1 .btn .fa-large.headerlink,.rst-content h1 .nav .fa-large.headerlink,.rst-content h2 .btn .fa-large.headerlink,.rst-content h2 .nav .fa-large.headerlink,.rst-content h3 .btn .fa-large.headerlink,.rst-content h3 .nav .fa-large.headerlink,.rst-content h4 .btn .fa-large.headerlink,.rst-content h4 .nav .fa-large.headerlink,.rst-content h5 .btn .fa-large.headerlink,.rst-content h5 .nav .fa-large.headerlink,.rst-content h6 .btn .fa-large.headerlink,.rst-content h6 .nav .fa-large.headerlink,.rst-content p .btn .fa-large.headerlink,.rst-content p .nav .fa-large.headerlink,.rst-content table>caption .btn .fa-large.headerlink,.rst-content table>caption .nav .fa-large.headerlink,.rst-content tt.download .btn span.fa-large:first-child,.rst-content tt.download .nav span.fa-large:first-child,.wy-menu-vertical li .btn button.fa-large.toctree-expand,.wy-menu-vertical li .nav button.fa-large.toctree-expand{line-height:.9em}.btn .fa-spin.icon,.btn .fa.fa-spin,.btn .rst-content .code-block-caption .fa-spin.headerlink,.btn .rst-content .eqno .fa-spin.headerlink,.btn .rst-content .fa-spin.admonition-title,.btn .rst-content code.download span.fa-spin:first-child,.btn .rst-content dl dt .fa-spin.headerlink,.btn .rst-content h1 .fa-spin.headerlink,.btn .rst-content h2 .fa-spin.headerlink,.btn .rst-content h3 .fa-spin.headerlink,.btn .rst-content h4 .fa-spin.headerlink,.btn .rst-content h5 .fa-spin.headerlink,.btn .rst-content h6 .fa-spin.headerlink,.btn .rst-content p .fa-spin.headerlink,.btn .rst-content table>caption .fa-spin.headerlink,.btn .rst-content tt.download span.fa-spin:first-child,.btn .wy-menu-vertical li button.fa-spin.toctree-expand,.nav .fa-spin.icon,.nav .fa.fa-spin,.nav .rst-content .code-block-caption .fa-spin.headerlink,.nav .rst-content .eqno .fa-spin.headerlink,.nav .rst-content .fa-spin.admonition-title,.nav .rst-content code.download span.fa-spin:first-child,.nav .rst-content dl dt .fa-spin.headerlink,.nav .rst-content h1 .fa-spin.headerlink,.nav .rst-content h2 .fa-spin.headerlink,.nav .rst-content h3 .fa-spin.headerlink,.nav .rst-content h4 .fa-spin.headerlink,.nav .rst-content h5 .fa-spin.headerlink,.nav .rst-content h6 .fa-spin.headerlink,.nav .rst-content p .fa-spin.headerlink,.nav .rst-content table>caption .fa-spin.headerlink,.nav .rst-content tt.download span.fa-spin:first-child,.nav .wy-menu-vertical li button.fa-spin.toctree-expand,.rst-content .btn .fa-spin.admonition-title,.rst-content .code-block-caption .btn .fa-spin.headerlink,.rst-content .code-block-caption .nav .fa-spin.headerlink,.rst-content .eqno .btn .fa-spin.headerlink,.rst-content .eqno .nav .fa-spin.headerlink,.rst-content .nav .fa-spin.admonition-title,.rst-content code.download .btn span.fa-spin:first-child,.rst-content code.download .nav span.fa-spin:first-child,.rst-content dl dt .btn .fa-spin.headerlink,.rst-content dl dt .nav .fa-spin.headerlink,.rst-content h1 .btn .fa-spin.headerlink,.rst-content h1 .nav .fa-spin.headerlink,.rst-content h2 .btn .fa-spin.headerlink,.rst-content h2 .nav .fa-spin.headerlink,.rst-content h3 .btn .fa-spin.headerlink,.rst-content h3 .nav .fa-spin.headerlink,.rst-content h4 .btn .fa-spin.headerlink,.rst-content h4 .nav .fa-spin.headerlink,.rst-content h5 .btn .fa-spin.headerlink,.rst-content h5 .nav .fa-spin.headerlink,.rst-content h6 .btn .fa-spin.headerlink,.rst-content h6 .nav .fa-spin.headerlink,.rst-content p .btn .fa-spin.headerlink,.rst-content p .nav .fa-spin.headerlink,.rst-content table>caption .btn .fa-spin.headerlink,.rst-content table>caption .nav .fa-spin.headerlink,.rst-content tt.download .btn span.fa-spin:first-child,.rst-content tt.download .nav span.fa-spin:first-child,.wy-menu-vertical li .btn button.fa-spin.toctree-expand,.wy-menu-vertical li .nav button.fa-spin.toctree-expand{display:inline-block}.btn.fa:before,.btn.icon:before,.rst-content .btn.admonition-title:before,.rst-content .code-block-caption .btn.headerlink:before,.rst-content .eqno .btn.headerlink:before,.rst-content code.download span.btn:first-child:before,.rst-content dl dt .btn.headerlink:before,.rst-content h1 .btn.headerlink:before,.rst-content h2 .btn.headerlink:before,.rst-content h3 .btn.headerlink:before,.rst-content h4 .btn.headerlink:before,.rst-content h5 .btn.headerlink:before,.rst-content h6 .btn.headerlink:before,.rst-content p .btn.headerlink:before,.rst-content table>caption .btn.headerlink:before,.rst-content tt.download span.btn:first-child:before,.wy-menu-vertical li button.btn.toctree-expand:before{opacity:.5;-webkit-transition:opacity .05s ease-in;-moz-transition:opacity .05s ease-in;transition:opacity .05s ease-in}.btn.fa:hover:before,.btn.icon:hover:before,.rst-content .btn.admonition-title:hover:before,.rst-content .code-block-caption .btn.headerlink:hover:before,.rst-content .eqno .btn.headerlink:hover:before,.rst-content code.download span.btn:first-child:hover:before,.rst-content dl dt .btn.headerlink:hover:before,.rst-content h1 .btn.headerlink:hover:before,.rst-content h2 .btn.headerlink:hover:before,.rst-content h3 .btn.headerlink:hover:before,.rst-content h4 .btn.headerlink:hover:before,.rst-content h5 .btn.headerlink:hover:before,.rst-content h6 .btn.headerlink:hover:before,.rst-content p .btn.headerlink:hover:before,.rst-content table>caption .btn.headerlink:hover:before,.rst-content tt.download span.btn:first-child:hover:before,.wy-menu-vertical li button.btn.toctree-expand:hover:before{opacity:1}.btn-mini .fa:before,.btn-mini .icon:before,.btn-mini .rst-content .admonition-title:before,.btn-mini .rst-content .code-block-caption .headerlink:before,.btn-mini .rst-content .eqno .headerlink:before,.btn-mini .rst-content code.download span:first-child:before,.btn-mini .rst-content dl dt .headerlink:before,.btn-mini .rst-content h1 .headerlink:before,.btn-mini .rst-content h2 .headerlink:before,.btn-mini .rst-content h3 .headerlink:before,.btn-mini .rst-content h4 .headerlink:before,.btn-mini .rst-content h5 .headerlink:before,.btn-mini .rst-content h6 .headerlink:before,.btn-mini .rst-content p .headerlink:before,.btn-mini .rst-content table>caption .headerlink:before,.btn-mini .rst-content tt.download span:first-child:before,.btn-mini .wy-menu-vertical li button.toctree-expand:before,.rst-content .btn-mini .admonition-title:before,.rst-content .code-block-caption .btn-mini .headerlink:before,.rst-content .eqno .btn-mini .headerlink:before,.rst-content code.download .btn-mini span:first-child:before,.rst-content dl dt .btn-mini .headerlink:before,.rst-content h1 .btn-mini .headerlink:before,.rst-content h2 .btn-mini .headerlink:before,.rst-content h3 .btn-mini .headerlink:before,.rst-content h4 .btn-mini .headerlink:before,.rst-content h5 .btn-mini .headerlink:before,.rst-content h6 .btn-mini .headerlink:before,.rst-content p .btn-mini .headerlink:before,.rst-content table>caption .btn-mini .headerlink:before,.rst-content tt.download .btn-mini span:first-child:before,.wy-menu-vertical li .btn-mini button.toctree-expand:before{font-size:14px;vertical-align:-15%}.rst-content .admonition,.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .danger,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .note,.rst-content .seealso,.rst-content .tip,.rst-content .warning,.wy-alert{padding:12px;line-height:24px;margin-bottom:24px;background:#e7f2fa}.rst-content .admonition-title,.wy-alert-title{font-weight:700;display:block;color:#fff;background:#6ab0de;padding:6px 12px;margin:-12px -12px 12px}.rst-content .danger,.rst-content .error,.rst-content .wy-alert-danger.admonition,.rst-content .wy-alert-danger.admonition-todo,.rst-content .wy-alert-danger.attention,.rst-content .wy-alert-danger.caution,.rst-content .wy-alert-danger.hint,.rst-content .wy-alert-danger.important,.rst-content .wy-alert-danger.note,.rst-content .wy-alert-danger.seealso,.rst-content .wy-alert-danger.tip,.rst-content .wy-alert-danger.warning,.wy-alert.wy-alert-danger{background:#fdf3f2}.rst-content .danger .admonition-title,.rst-content .danger .wy-alert-title,.rst-content .error .admonition-title,.rst-content .error .wy-alert-title,.rst-content .wy-alert-danger.admonition-todo .admonition-title,.rst-content .wy-alert-danger.admonition-todo .wy-alert-title,.rst-content .wy-alert-danger.admonition .admonition-title,.rst-content .wy-alert-danger.admonition .wy-alert-title,.rst-content .wy-alert-danger.attention .admonition-title,.rst-content .wy-alert-danger.attention .wy-alert-title,.rst-content .wy-alert-danger.caution .admonition-title,.rst-content .wy-alert-danger.caution .wy-alert-title,.rst-content .wy-alert-danger.hint .admonition-title,.rst-content .wy-alert-danger.hint .wy-alert-title,.rst-content .wy-alert-danger.important .admonition-title,.rst-content .wy-alert-danger.important .wy-alert-title,.rst-content .wy-alert-danger.note .admonition-title,.rst-content .wy-alert-danger.note .wy-alert-title,.rst-content .wy-alert-danger.seealso .admonition-title,.rst-content .wy-alert-danger.seealso .wy-alert-title,.rst-content .wy-alert-danger.tip .admonition-title,.rst-content .wy-alert-danger.tip .wy-alert-title,.rst-content .wy-alert-danger.warning .admonition-title,.rst-content .wy-alert-danger.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-danger .admonition-title,.wy-alert.wy-alert-danger .rst-content .admonition-title,.wy-alert.wy-alert-danger .wy-alert-title{background:#f29f97}.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .warning,.rst-content .wy-alert-warning.admonition,.rst-content .wy-alert-warning.danger,.rst-content .wy-alert-warning.error,.rst-content .wy-alert-warning.hint,.rst-content .wy-alert-warning.important,.rst-content .wy-alert-warning.note,.rst-content .wy-alert-warning.seealso,.rst-content .wy-alert-warning.tip,.wy-alert.wy-alert-warning{background:#ffedcc}.rst-content .admonition-todo .admonition-title,.rst-content .admonition-todo .wy-alert-title,.rst-content .attention .admonition-title,.rst-content .attention .wy-alert-title,.rst-content .caution .admonition-title,.rst-content .caution .wy-alert-title,.rst-content .warning .admonition-title,.rst-content .warning .wy-alert-title,.rst-content .wy-alert-warning.admonition .admonition-title,.rst-content .wy-alert-warning.admonition .wy-alert-title,.rst-content .wy-alert-warning.danger .admonition-title,.rst-content .wy-alert-warning.danger .wy-alert-title,.rst-content .wy-alert-warning.error .admonition-title,.rst-content .wy-alert-warning.error .wy-alert-title,.rst-content .wy-alert-warning.hint .admonition-title,.rst-content .wy-alert-warning.hint .wy-alert-title,.rst-content .wy-alert-warning.important .admonition-title,.rst-content .wy-alert-warning.important .wy-alert-title,.rst-content .wy-alert-warning.note .admonition-title,.rst-content .wy-alert-warning.note .wy-alert-title,.rst-content .wy-alert-warning.seealso .admonition-title,.rst-content .wy-alert-warning.seealso .wy-alert-title,.rst-content .wy-alert-warning.tip .admonition-title,.rst-content .wy-alert-warning.tip .wy-alert-title,.rst-content .wy-alert.wy-alert-warning .admonition-title,.wy-alert.wy-alert-warning .rst-content .admonition-title,.wy-alert.wy-alert-warning .wy-alert-title{background:#f0b37e}.rst-content .note,.rst-content .seealso,.rst-content .wy-alert-info.admonition,.rst-content .wy-alert-info.admonition-todo,.rst-content .wy-alert-info.attention,.rst-content .wy-alert-info.caution,.rst-content .wy-alert-info.danger,.rst-content .wy-alert-info.error,.rst-content .wy-alert-info.hint,.rst-content .wy-alert-info.important,.rst-content .wy-alert-info.tip,.rst-content .wy-alert-info.warning,.wy-alert.wy-alert-info{background:#e7f2fa}.rst-content .note .admonition-title,.rst-content .note .wy-alert-title,.rst-content .seealso .admonition-title,.rst-content .seealso .wy-alert-title,.rst-content .wy-alert-info.admonition-todo .admonition-title,.rst-content .wy-alert-info.admonition-todo .wy-alert-title,.rst-content .wy-alert-info.admonition .admonition-title,.rst-content .wy-alert-info.admonition .wy-alert-title,.rst-content .wy-alert-info.attention .admonition-title,.rst-content .wy-alert-info.attention .wy-alert-title,.rst-content .wy-alert-info.caution .admonition-title,.rst-content .wy-alert-info.caution .wy-alert-title,.rst-content .wy-alert-info.danger .admonition-title,.rst-content .wy-alert-info.danger .wy-alert-title,.rst-content .wy-alert-info.error .admonition-title,.rst-content .wy-alert-info.error .wy-alert-title,.rst-content .wy-alert-info.hint .admonition-title,.rst-content .wy-alert-info.hint .wy-alert-title,.rst-content .wy-alert-info.important .admonition-title,.rst-content .wy-alert-info.important .wy-alert-title,.rst-content .wy-alert-info.tip .admonition-title,.rst-content .wy-alert-info.tip .wy-alert-title,.rst-content .wy-alert-info.warning .admonition-title,.rst-content .wy-alert-info.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-info .admonition-title,.wy-alert.wy-alert-info .rst-content .admonition-title,.wy-alert.wy-alert-info .wy-alert-title{background:#6ab0de}.rst-content .hint,.rst-content .important,.rst-content .tip,.rst-content .wy-alert-success.admonition,.rst-content .wy-alert-success.admonition-todo,.rst-content .wy-alert-success.attention,.rst-content .wy-alert-success.caution,.rst-content .wy-alert-success.danger,.rst-content .wy-alert-success.error,.rst-content .wy-alert-success.note,.rst-content .wy-alert-success.seealso,.rst-content .wy-alert-success.warning,.wy-alert.wy-alert-success{background:#dbfaf4}.rst-content .hint .admonition-title,.rst-content .hint .wy-alert-title,.rst-content .important .admonition-title,.rst-content .important .wy-alert-title,.rst-content .tip .admonition-title,.rst-content .tip .wy-alert-title,.rst-content .wy-alert-success.admonition-todo .admonition-title,.rst-content .wy-alert-success.admonition-todo .wy-alert-title,.rst-content .wy-alert-success.admonition .admonition-title,.rst-content .wy-alert-success.admonition .wy-alert-title,.rst-content .wy-alert-success.attention .admonition-title,.rst-content .wy-alert-success.attention .wy-alert-title,.rst-content .wy-alert-success.caution .admonition-title,.rst-content .wy-alert-success.caution .wy-alert-title,.rst-content .wy-alert-success.danger .admonition-title,.rst-content .wy-alert-success.danger .wy-alert-title,.rst-content .wy-alert-success.error .admonition-title,.rst-content .wy-alert-success.error .wy-alert-title,.rst-content .wy-alert-success.note .admonition-title,.rst-content .wy-alert-success.note .wy-alert-title,.rst-content .wy-alert-success.seealso .admonition-title,.rst-content .wy-alert-success.seealso .wy-alert-title,.rst-content .wy-alert-success.warning .admonition-title,.rst-content .wy-alert-success.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-success .admonition-title,.wy-alert.wy-alert-success .rst-content .admonition-title,.wy-alert.wy-alert-success .wy-alert-title{background:#1abc9c}.rst-content .wy-alert-neutral.admonition,.rst-content .wy-alert-neutral.admonition-todo,.rst-content .wy-alert-neutral.attention,.rst-content .wy-alert-neutral.caution,.rst-content .wy-alert-neutral.danger,.rst-content .wy-alert-neutral.error,.rst-content .wy-alert-neutral.hint,.rst-content .wy-alert-neutral.important,.rst-content .wy-alert-neutral.note,.rst-content .wy-alert-neutral.seealso,.rst-content .wy-alert-neutral.tip,.rst-content .wy-alert-neutral.warning,.wy-alert.wy-alert-neutral{background:#f3f6f6}.rst-content .wy-alert-neutral.admonition-todo .admonition-title,.rst-content .wy-alert-neutral.admonition-todo .wy-alert-title,.rst-content .wy-alert-neutral.admonition .admonition-title,.rst-content .wy-alert-neutral.admonition .wy-alert-title,.rst-content .wy-alert-neutral.attention .admonition-title,.rst-content .wy-alert-neutral.attention .wy-alert-title,.rst-content .wy-alert-neutral.caution .admonition-title,.rst-content .wy-alert-neutral.caution .wy-alert-title,.rst-content .wy-alert-neutral.danger .admonition-title,.rst-content .wy-alert-neutral.danger .wy-alert-title,.rst-content .wy-alert-neutral.error .admonition-title,.rst-content .wy-alert-neutral.error .wy-alert-title,.rst-content .wy-alert-neutral.hint .admonition-title,.rst-content .wy-alert-neutral.hint .wy-alert-title,.rst-content .wy-alert-neutral.important .admonition-title,.rst-content .wy-alert-neutral.important .wy-alert-title,.rst-content .wy-alert-neutral.note .admonition-title,.rst-content .wy-alert-neutral.note .wy-alert-title,.rst-content .wy-alert-neutral.seealso .admonition-title,.rst-content .wy-alert-neutral.seealso .wy-alert-title,.rst-content .wy-alert-neutral.tip .admonition-title,.rst-content .wy-alert-neutral.tip .wy-alert-title,.rst-content .wy-alert-neutral.warning .admonition-title,.rst-content .wy-alert-neutral.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-neutral .admonition-title,.wy-alert.wy-alert-neutral .rst-content .admonition-title,.wy-alert.wy-alert-neutral .wy-alert-title{color:#404040;background:#e1e4e5}.rst-content .wy-alert-neutral.admonition-todo a,.rst-content .wy-alert-neutral.admonition a,.rst-content .wy-alert-neutral.attention a,.rst-content .wy-alert-neutral.caution a,.rst-content .wy-alert-neutral.danger a,.rst-content .wy-alert-neutral.error a,.rst-content .wy-alert-neutral.hint a,.rst-content .wy-alert-neutral.important a,.rst-content .wy-alert-neutral.note a,.rst-content .wy-alert-neutral.seealso a,.rst-content .wy-alert-neutral.tip a,.rst-content .wy-alert-neutral.warning a,.wy-alert.wy-alert-neutral a{color:#2980b9}.rst-content .admonition-todo p:last-child,.rst-content .admonition p:last-child,.rst-content .attention p:last-child,.rst-content .caution p:last-child,.rst-content .danger p:last-child,.rst-content .error p:last-child,.rst-content .hint p:last-child,.rst-content .important p:last-child,.rst-content .note p:last-child,.rst-content .seealso p:last-child,.rst-content .tip p:last-child,.rst-content .warning p:last-child,.wy-alert p:last-child{margin-bottom:0}.wy-tray-container{position:fixed;bottom:0;left:0;z-index:600}.wy-tray-container li{display:block;width:300px;background:transparent;color:#fff;text-align:center;box-shadow:0 5px 5px 0 rgba(0,0,0,.1);padding:0 24px;min-width:20%;opacity:0;height:0;line-height:56px;overflow:hidden;-webkit-transition:all .3s ease-in;-moz-transition:all .3s ease-in;transition:all .3s ease-in}.wy-tray-container li.wy-tray-item-success{background:#27ae60}.wy-tray-container li.wy-tray-item-info{background:#2980b9}.wy-tray-container li.wy-tray-item-warning{background:#e67e22}.wy-tray-container li.wy-tray-item-danger{background:#e74c3c}.wy-tray-container li.on{opacity:1;height:56px}@media screen and (max-width:768px){.wy-tray-container{bottom:auto;top:0;width:100%}.wy-tray-container li{width:100%}}button{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle;cursor:pointer;line-height:normal;-webkit-appearance:button;*overflow:visible}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}button[disabled]{cursor:default}.btn{display:inline-block;border-radius:2px;line-height:normal;white-space:nowrap;text-align:center;cursor:pointer;font-size:100%;padding:6px 12px 8px;color:#fff;border:1px solid rgba(0,0,0,.1);background-color:#27ae60;text-decoration:none;font-weight:400;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;box-shadow:inset 0 1px 2px -1px hsla(0,0%,100%,.5),inset 0 -2px 0 0 rgba(0,0,0,.1);outline-none:false;vertical-align:middle;*display:inline;zoom:1;-webkit-user-drag:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transition:all .1s linear;-moz-transition:all .1s linear;transition:all .1s linear}.btn-hover{background:#2e8ece;color:#fff}.btn:hover{background:#2cc36b;color:#fff}.btn:focus{background:#2cc36b;outline:0}.btn:active{box-shadow:inset 0 -1px 0 0 rgba(0,0,0,.05),inset 0 2px 0 0 rgba(0,0,0,.1);padding:8px 12px 6px}.btn:visited{color:#fff}.btn-disabled,.btn-disabled:active,.btn-disabled:focus,.btn-disabled:hover,.btn:disabled{background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);filter:alpha(opacity=40);opacity:.4;cursor:not-allowed;box-shadow:none}.btn::-moz-focus-inner{padding:0;border:0}.btn-small{font-size:80%}.btn-info{background-color:#2980b9!important}.btn-info:hover{background-color:#2e8ece!important}.btn-neutral{background-color:#f3f6f6!important;color:#404040!important}.btn-neutral:hover{background-color:#e5ebeb!important;color:#404040}.btn-neutral:visited{color:#404040!important}.btn-success{background-color:#27ae60!important}.btn-success:hover{background-color:#295!important}.btn-danger{background-color:#e74c3c!important}.btn-danger:hover{background-color:#ea6153!important}.btn-warning{background-color:#e67e22!important}.btn-warning:hover{background-color:#e98b39!important}.btn-invert{background-color:#222}.btn-invert:hover{background-color:#2f2f2f!important}.btn-link{background-color:transparent!important;color:#2980b9;box-shadow:none;border-color:transparent!important}.btn-link:active,.btn-link:hover{background-color:transparent!important;color:#409ad5!important;box-shadow:none}.btn-link:visited{color:#9b59b6}.wy-btn-group .btn,.wy-control .btn{vertical-align:middle}.wy-btn-group{margin-bottom:24px;*zoom:1}.wy-btn-group:after,.wy-btn-group:before{display:table;content:""}.wy-btn-group:after{clear:both}.wy-dropdown{position:relative;display:inline-block}.wy-dropdown-active .wy-dropdown-menu{display:block}.wy-dropdown-menu{position:absolute;left:0;display:none;float:left;top:100%;min-width:100%;background:#fcfcfc;z-index:100;border:1px solid #cfd7dd;box-shadow:0 2px 2px 0 rgba(0,0,0,.1);padding:12px}.wy-dropdown-menu>dd>a{display:block;clear:both;color:#404040;white-space:nowrap;font-size:90%;padding:0 12px;cursor:pointer}.wy-dropdown-menu>dd>a:hover{background:#2980b9;color:#fff}.wy-dropdown-menu>dd.divider{border-top:1px solid #cfd7dd;margin:6px 0}.wy-dropdown-menu>dd.search{padding-bottom:12px}.wy-dropdown-menu>dd.search input[type=search]{width:100%}.wy-dropdown-menu>dd.call-to-action{background:#e3e3e3;text-transform:uppercase;font-weight:500;font-size:80%}.wy-dropdown-menu>dd.call-to-action:hover{background:#e3e3e3}.wy-dropdown-menu>dd.call-to-action .btn{color:#fff}.wy-dropdown.wy-dropdown-up .wy-dropdown-menu{bottom:100%;top:auto;left:auto;right:0}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu{background:#fcfcfc;margin-top:2px}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu a{padding:6px 12px}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu a:hover{background:#2980b9;color:#fff}.wy-dropdown.wy-dropdown-left .wy-dropdown-menu{right:0;left:auto;text-align:right}.wy-dropdown-arrow:before{content:" ";border-bottom:5px solid #f5f5f5;border-left:5px solid transparent;border-right:5px solid transparent;position:absolute;display:block;top:-4px;left:50%;margin-left:-3px}.wy-dropdown-arrow.wy-dropdown-arrow-left:before{left:11px}.wy-form-stacked select{display:block}.wy-form-aligned .wy-help-inline,.wy-form-aligned input,.wy-form-aligned label,.wy-form-aligned select,.wy-form-aligned textarea{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.wy-form-aligned .wy-control-group>label{display:inline-block;vertical-align:middle;width:10em;margin:6px 12px 0 0;float:left}.wy-form-aligned .wy-control{float:left}.wy-form-aligned .wy-control label{display:block}.wy-form-aligned .wy-control select{margin-top:6px}fieldset{margin:0}fieldset,legend{border:0;padding:0}legend{width:100%;white-space:normal;margin-bottom:24px;font-size:150%;*margin-left:-7px}label,legend{display:block}label{margin:0 0 .3125em;color:#333;font-size:90%}input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}.wy-control-group{margin-bottom:24px;max-width:1200px;margin-left:auto;margin-right:auto;*zoom:1}.wy-control-group:after,.wy-control-group:before{display:table;content:""}.wy-control-group:after{clear:both}.wy-control-group.wy-control-group-required>label:after{content:" *";color:#e74c3c}.wy-control-group .wy-form-full,.wy-control-group .wy-form-halves,.wy-control-group .wy-form-thirds{padding-bottom:12px}.wy-control-group .wy-form-full input[type=color],.wy-control-group .wy-form-full input[type=date],.wy-control-group .wy-form-full input[type=datetime-local],.wy-control-group .wy-form-full input[type=datetime],.wy-control-group .wy-form-full input[type=email],.wy-control-group .wy-form-full input[type=month],.wy-control-group .wy-form-full input[type=number],.wy-control-group .wy-form-full input[type=password],.wy-control-group .wy-form-full input[type=search],.wy-control-group .wy-form-full input[type=tel],.wy-control-group .wy-form-full input[type=text],.wy-control-group .wy-form-full input[type=time],.wy-control-group .wy-form-full input[type=url],.wy-control-group .wy-form-full input[type=week],.wy-control-group .wy-form-full select,.wy-control-group .wy-form-halves input[type=color],.wy-control-group .wy-form-halves input[type=date],.wy-control-group .wy-form-halves input[type=datetime-local],.wy-control-group .wy-form-halves input[type=datetime],.wy-control-group .wy-form-halves input[type=email],.wy-control-group .wy-form-halves input[type=month],.wy-control-group .wy-form-halves input[type=number],.wy-control-group .wy-form-halves input[type=password],.wy-control-group .wy-form-halves input[type=search],.wy-control-group .wy-form-halves input[type=tel],.wy-control-group .wy-form-halves input[type=text],.wy-control-group .wy-form-halves input[type=time],.wy-control-group .wy-form-halves input[type=url],.wy-control-group .wy-form-halves input[type=week],.wy-control-group .wy-form-halves select,.wy-control-group .wy-form-thirds input[type=color],.wy-control-group .wy-form-thirds input[type=date],.wy-control-group .wy-form-thirds input[type=datetime-local],.wy-control-group .wy-form-thirds input[type=datetime],.wy-control-group .wy-form-thirds input[type=email],.wy-control-group .wy-form-thirds input[type=month],.wy-control-group .wy-form-thirds input[type=number],.wy-control-group .wy-form-thirds input[type=password],.wy-control-group .wy-form-thirds input[type=search],.wy-control-group .wy-form-thirds input[type=tel],.wy-control-group .wy-form-thirds input[type=text],.wy-control-group .wy-form-thirds input[type=time],.wy-control-group .wy-form-thirds input[type=url],.wy-control-group .wy-form-thirds input[type=week],.wy-control-group .wy-form-thirds select{width:100%}.wy-control-group .wy-form-full{float:left;display:block;width:100%;margin-right:0}.wy-control-group .wy-form-full:last-child{margin-right:0}.wy-control-group .wy-form-halves{float:left;display:block;margin-right:2.35765%;width:48.82117%}.wy-control-group .wy-form-halves:last-child,.wy-control-group .wy-form-halves:nth-of-type(2n){margin-right:0}.wy-control-group .wy-form-halves:nth-of-type(odd){clear:left}.wy-control-group .wy-form-thirds{float:left;display:block;margin-right:2.35765%;width:31.76157%}.wy-control-group .wy-form-thirds:last-child,.wy-control-group .wy-form-thirds:nth-of-type(3n){margin-right:0}.wy-control-group .wy-form-thirds:nth-of-type(3n+1){clear:left}.wy-control-group.wy-control-group-no-input .wy-control,.wy-control-no-input{margin:6px 0 0;font-size:90%}.wy-control-no-input{display:inline-block}.wy-control-group.fluid-input input[type=color],.wy-control-group.fluid-input input[type=date],.wy-control-group.fluid-input input[type=datetime-local],.wy-control-group.fluid-input input[type=datetime],.wy-control-group.fluid-input input[type=email],.wy-control-group.fluid-input input[type=month],.wy-control-group.fluid-input input[type=number],.wy-control-group.fluid-input input[type=password],.wy-control-group.fluid-input input[type=search],.wy-control-group.fluid-input input[type=tel],.wy-control-group.fluid-input input[type=text],.wy-control-group.fluid-input input[type=time],.wy-control-group.fluid-input input[type=url],.wy-control-group.fluid-input input[type=week]{width:100%}.wy-form-message-inline{padding-left:.3em;color:#666;font-size:90%}.wy-form-message{display:block;color:#999;font-size:70%;margin-top:.3125em;font-style:italic}.wy-form-message p{font-size:inherit;font-style:italic;margin-bottom:6px}.wy-form-message p:last-child{margin-bottom:0}input{line-height:normal}input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;*overflow:visible}input[type=color],input[type=date],input[type=datetime-local],input[type=datetime],input[type=email],input[type=month],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=time],input[type=url],input[type=week]{-webkit-appearance:none;padding:6px;display:inline-block;border:1px solid #ccc;font-size:80%;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;box-shadow:inset 0 1px 3px #ddd;border-radius:0;-webkit-transition:border .3s linear;-moz-transition:border .3s linear;transition:border .3s linear}input[type=datetime-local]{padding:.34375em .625em}input[disabled]{cursor:default}input[type=checkbox],input[type=radio]{padding:0;margin-right:.3125em;*height:13px;*width:13px}input[type=checkbox],input[type=radio],input[type=search]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}input[type=color]:focus,input[type=date]:focus,input[type=datetime-local]:focus,input[type=datetime]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,input[type=password]:focus,input[type=search]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus{outline:0;outline:thin dotted\9;border-color:#333}input.no-focus:focus{border-color:#ccc!important}input[type=checkbox]:focus,input[type=file]:focus,input[type=radio]:focus{outline:thin dotted #333;outline:1px auto #129fea}input[type=color][disabled],input[type=date][disabled],input[type=datetime-local][disabled],input[type=datetime][disabled],input[type=email][disabled],input[type=month][disabled],input[type=number][disabled],input[type=password][disabled],input[type=search][disabled],input[type=tel][disabled],input[type=text][disabled],input[type=time][disabled],input[type=url][disabled],input[type=week][disabled]{cursor:not-allowed;background-color:#fafafa}input:focus:invalid,select:focus:invalid,textarea:focus:invalid{color:#e74c3c;border:1px solid #e74c3c}input:focus:invalid:focus,select:focus:invalid:focus,textarea:focus:invalid:focus{border-color:#e74c3c}input[type=checkbox]:focus:invalid:focus,input[type=file]:focus:invalid:focus,input[type=radio]:focus:invalid:focus{outline-color:#e74c3c}input.wy-input-large{padding:12px;font-size:100%}textarea{overflow:auto;vertical-align:top;width:100%;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif}select,textarea{padding:.5em .625em;display:inline-block;border:1px solid #ccc;font-size:80%;box-shadow:inset 0 1px 3px #ddd;-webkit-transition:border .3s linear;-moz-transition:border .3s linear;transition:border .3s linear}select{border:1px solid #ccc;background-color:#fff}select[multiple]{height:auto}select:focus,textarea:focus{outline:0}input[readonly],select[disabled],select[readonly],textarea[disabled],textarea[readonly]{cursor:not-allowed;background-color:#fafafa}input[type=checkbox][disabled],input[type=radio][disabled]{cursor:not-allowed}.wy-checkbox,.wy-radio{margin:6px 0;color:#404040;display:block}.wy-checkbox input,.wy-radio input{vertical-align:baseline}.wy-form-message-inline{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.wy-input-prefix,.wy-input-suffix{white-space:nowrap;padding:6px}.wy-input-prefix .wy-input-context,.wy-input-suffix .wy-input-context{line-height:27px;padding:0 8px;display:inline-block;font-size:80%;background-color:#f3f6f6;border:1px solid #ccc;color:#999}.wy-input-suffix .wy-input-context{border-left:0}.wy-input-prefix .wy-input-context{border-right:0}.wy-switch{position:relative;display:block;height:24px;margin-top:12px;cursor:pointer}.wy-switch:before{left:0;top:0;width:36px;height:12px;background:#ccc}.wy-switch:after,.wy-switch:before{position:absolute;content:"";display:block;border-radius:4px;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.wy-switch:after{width:18px;height:18px;background:#999;left:-3px;top:-3px}.wy-switch span{position:absolute;left:48px;display:block;font-size:12px;color:#ccc;line-height:1}.wy-switch.active:before{background:#1e8449}.wy-switch.active:after{left:24px;background:#27ae60}.wy-switch.disabled{cursor:not-allowed;opacity:.8}.wy-control-group.wy-control-group-error .wy-form-message,.wy-control-group.wy-control-group-error>label{color:#e74c3c}.wy-control-group.wy-control-group-error input[type=color],.wy-control-group.wy-control-group-error input[type=date],.wy-control-group.wy-control-group-error input[type=datetime-local],.wy-control-group.wy-control-group-error input[type=datetime],.wy-control-group.wy-control-group-error input[type=email],.wy-control-group.wy-control-group-error input[type=month],.wy-control-group.wy-control-group-error input[type=number],.wy-control-group.wy-control-group-error input[type=password],.wy-control-group.wy-control-group-error input[type=search],.wy-control-group.wy-control-group-error input[type=tel],.wy-control-group.wy-control-group-error input[type=text],.wy-control-group.wy-control-group-error input[type=time],.wy-control-group.wy-control-group-error input[type=url],.wy-control-group.wy-control-group-error input[type=week],.wy-control-group.wy-control-group-error textarea{border:1px solid #e74c3c}.wy-inline-validate{white-space:nowrap}.wy-inline-validate .wy-input-context{padding:.5em .625em;display:inline-block;font-size:80%}.wy-inline-validate.wy-inline-validate-success .wy-input-context{color:#27ae60}.wy-inline-validate.wy-inline-validate-danger .wy-input-context{color:#e74c3c}.wy-inline-validate.wy-inline-validate-warning .wy-input-context{color:#e67e22}.wy-inline-validate.wy-inline-validate-info .wy-input-context{color:#2980b9}.rotate-90{-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg)}.rotate-180{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);-ms-transform:rotate(180deg);-o-transform:rotate(180deg);transform:rotate(180deg)}.rotate-270{-webkit-transform:rotate(270deg);-moz-transform:rotate(270deg);-ms-transform:rotate(270deg);-o-transform:rotate(270deg);transform:rotate(270deg)}.mirror{-webkit-transform:scaleX(-1);-moz-transform:scaleX(-1);-ms-transform:scaleX(-1);-o-transform:scaleX(-1);transform:scaleX(-1)}.mirror.rotate-90{-webkit-transform:scaleX(-1) rotate(90deg);-moz-transform:scaleX(-1) rotate(90deg);-ms-transform:scaleX(-1) rotate(90deg);-o-transform:scaleX(-1) rotate(90deg);transform:scaleX(-1) rotate(90deg)}.mirror.rotate-180{-webkit-transform:scaleX(-1) rotate(180deg);-moz-transform:scaleX(-1) rotate(180deg);-ms-transform:scaleX(-1) rotate(180deg);-o-transform:scaleX(-1) rotate(180deg);transform:scaleX(-1) rotate(180deg)}.mirror.rotate-270{-webkit-transform:scaleX(-1) rotate(270deg);-moz-transform:scaleX(-1) rotate(270deg);-ms-transform:scaleX(-1) rotate(270deg);-o-transform:scaleX(-1) rotate(270deg);transform:scaleX(-1) rotate(270deg)}@media only screen and (max-width:480px){.wy-form button[type=submit]{margin:.7em 0 0}.wy-form input[type=color],.wy-form input[type=date],.wy-form input[type=datetime-local],.wy-form input[type=datetime],.wy-form input[type=email],.wy-form input[type=month],.wy-form input[type=number],.wy-form input[type=password],.wy-form input[type=search],.wy-form input[type=tel],.wy-form input[type=text],.wy-form input[type=time],.wy-form input[type=url],.wy-form input[type=week],.wy-form label{margin-bottom:.3em;display:block}.wy-form input[type=color],.wy-form input[type=date],.wy-form input[type=datetime-local],.wy-form input[type=datetime],.wy-form input[type=email],.wy-form input[type=month],.wy-form input[type=number],.wy-form input[type=password],.wy-form input[type=search],.wy-form input[type=tel],.wy-form input[type=time],.wy-form input[type=url],.wy-form input[type=week]{margin-bottom:0}.wy-form-aligned .wy-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.wy-form-aligned .wy-control{margin:1.5em 0 0}.wy-form-message,.wy-form-message-inline,.wy-form .wy-help-inline{display:block;font-size:80%;padding:6px 0}}@media screen and (max-width:768px){.tablet-hide{display:none}}@media screen and (max-width:480px){.mobile-hide{display:none}}.float-left{float:left}.float-right{float:right}.full-width{width:100%}.rst-content table.docutils,.rst-content table.field-list,.wy-table{border-collapse:collapse;border-spacing:0;empty-cells:show;margin-bottom:24px}.rst-content table.docutils caption,.rst-content table.field-list caption,.wy-table caption{color:#000;font:italic 85%/1 arial,sans-serif;padding:1em 0;text-align:center}.rst-content table.docutils td,.rst-content table.docutils th,.rst-content table.field-list td,.rst-content table.field-list th,.wy-table td,.wy-table th{font-size:90%;margin:0;overflow:visible;padding:8px 16px}.rst-content table.docutils td:first-child,.rst-content table.docutils th:first-child,.rst-content table.field-list td:first-child,.rst-content table.field-list th:first-child,.wy-table td:first-child,.wy-table th:first-child{border-left-width:0}.rst-content table.docutils thead,.rst-content table.field-list thead,.wy-table thead{color:#000;text-align:left;vertical-align:bottom;white-space:nowrap}.rst-content table.docutils thead th,.rst-content table.field-list thead th,.wy-table thead th{font-weight:700;border-bottom:2px solid #e1e4e5}.rst-content table.docutils td,.rst-content table.field-list td,.wy-table td{background-color:transparent;vertical-align:middle}.rst-content table.docutils td p,.rst-content table.field-list td p,.wy-table td p{line-height:18px}.rst-content table.docutils td p:last-child,.rst-content table.field-list td p:last-child,.wy-table td p:last-child{margin-bottom:0}.rst-content table.docutils .wy-table-cell-min,.rst-content table.field-list .wy-table-cell-min,.wy-table .wy-table-cell-min{width:1%;padding-right:0}.rst-content table.docutils .wy-table-cell-min input[type=checkbox],.rst-content table.field-list .wy-table-cell-min input[type=checkbox],.wy-table .wy-table-cell-min input[type=checkbox]{margin:0}.wy-table-secondary{color:grey;font-size:90%}.wy-table-tertiary{color:grey;font-size:80%}.rst-content table.docutils:not(.field-list) tr:nth-child(2n-1) td,.wy-table-backed,.wy-table-odd td,.wy-table-striped tr:nth-child(2n-1) td{background-color:#f3f6f6}.rst-content table.docutils,.wy-table-bordered-all{border:1px solid #e1e4e5}.rst-content table.docutils td,.wy-table-bordered-all td{border-bottom:1px solid #e1e4e5;border-left:1px solid #e1e4e5}.rst-content table.docutils tbody>tr:last-child td,.wy-table-bordered-all tbody>tr:last-child td{border-bottom-width:0}.wy-table-bordered{border:1px solid #e1e4e5}.wy-table-bordered-rows td{border-bottom:1px solid #e1e4e5}.wy-table-bordered-rows tbody>tr:last-child td{border-bottom-width:0}.wy-table-horizontal td,.wy-table-horizontal th{border-width:0 0 1px;border-bottom:1px solid #e1e4e5}.wy-table-horizontal tbody>tr:last-child td{border-bottom-width:0}.wy-table-responsive{margin-bottom:24px;max-width:100%;overflow:auto}.wy-table-responsive table{margin-bottom:0!important}.wy-table-responsive table td,.wy-table-responsive table th{white-space:nowrap}a{color:#2980b9;text-decoration:none;cursor:pointer}a:hover{color:#3091d1}a:visited{color:#9b59b6}html{height:100%}body,html{overflow-x:hidden}body{font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;font-weight:400;color:#404040;min-height:100%;background:#edf0f2}.wy-text-left{text-align:left}.wy-text-center{text-align:center}.wy-text-right{text-align:right}.wy-text-large{font-size:120%}.wy-text-normal{font-size:100%}.wy-text-small,small{font-size:80%}.wy-text-strike{text-decoration:line-through}.wy-text-warning{color:#e67e22!important}a.wy-text-warning:hover{color:#eb9950!important}.wy-text-info{color:#2980b9!important}a.wy-text-info:hover{color:#409ad5!important}.wy-text-success{color:#27ae60!important}a.wy-text-success:hover{color:#36d278!important}.wy-text-danger{color:#e74c3c!important}a.wy-text-danger:hover{color:#ed7669!important}.wy-text-neutral{color:#404040!important}a.wy-text-neutral:hover{color:#595959!important}.rst-content .toctree-wrapper>p.caption,h1,h2,h3,h4,h5,h6,legend{margin-top:0;font-weight:700;font-family:Roboto Slab,ff-tisa-web-pro,Georgia,Arial,sans-serif}p{line-height:24px;font-size:16px;margin:0 0 24px}h1{font-size:175%}.rst-content .toctree-wrapper>p.caption,h2{font-size:150%}h3{font-size:125%}h4{font-size:115%}h5{font-size:110%}h6{font-size:100%}hr{display:block;height:1px;border:0;border-top:1px solid #e1e4e5;margin:24px 0;padding:0}.rst-content code,.rst-content tt,code{white-space:nowrap;max-width:100%;background:#fff;border:1px solid #e1e4e5;font-size:75%;padding:0 5px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;color:#e74c3c;overflow-x:auto}.rst-content tt.code-large,code.code-large{font-size:90%}.rst-content .section ul,.rst-content .toctree-wrapper ul,.rst-content section ul,.wy-plain-list-disc,article ul{list-style:disc;line-height:24px;margin-bottom:24px}.rst-content .section ul li,.rst-content .toctree-wrapper ul li,.rst-content section ul li,.wy-plain-list-disc li,article ul li{list-style:disc;margin-left:24px}.rst-content .section ul li p:last-child,.rst-content .section ul li ul,.rst-content .toctree-wrapper ul li p:last-child,.rst-content .toctree-wrapper ul li ul,.rst-content section ul li p:last-child,.rst-content section ul li ul,.wy-plain-list-disc li p:last-child,.wy-plain-list-disc li ul,article ul li p:last-child,article ul li ul{margin-bottom:0}.rst-content .section ul li li,.rst-content .toctree-wrapper ul li li,.rst-content section ul li li,.wy-plain-list-disc li li,article ul li li{list-style:circle}.rst-content .section ul li li li,.rst-content .toctree-wrapper ul li li li,.rst-content section ul li li li,.wy-plain-list-disc li li li,article ul li li li{list-style:square}.rst-content .section ul li ol li,.rst-content .toctree-wrapper ul li ol li,.rst-content section ul li ol li,.wy-plain-list-disc li ol li,article ul li ol li{list-style:decimal}.rst-content .section ol,.rst-content .section ol.arabic,.rst-content .toctree-wrapper ol,.rst-content .toctree-wrapper ol.arabic,.rst-content section ol,.rst-content section ol.arabic,.wy-plain-list-decimal,article ol{list-style:decimal;line-height:24px;margin-bottom:24px}.rst-content .section ol.arabic li,.rst-content .section ol li,.rst-content .toctree-wrapper ol.arabic li,.rst-content .toctree-wrapper ol li,.rst-content section ol.arabic li,.rst-content section ol li,.wy-plain-list-decimal li,article ol li{list-style:decimal;margin-left:24px}.rst-content .section ol.arabic li ul,.rst-content .section ol li p:last-child,.rst-content .section ol li ul,.rst-content .toctree-wrapper ol.arabic li ul,.rst-content .toctree-wrapper ol li p:last-child,.rst-content .toctree-wrapper ol li ul,.rst-content section ol.arabic li ul,.rst-content section ol li p:last-child,.rst-content section ol li ul,.wy-plain-list-decimal li p:last-child,.wy-plain-list-decimal li ul,article ol li p:last-child,article ol li ul{margin-bottom:0}.rst-content .section ol.arabic li ul li,.rst-content .section ol li ul li,.rst-content .toctree-wrapper ol.arabic li ul li,.rst-content .toctree-wrapper ol li ul li,.rst-content section ol.arabic li ul li,.rst-content section ol li ul li,.wy-plain-list-decimal li ul li,article ol li ul li{list-style:disc}.wy-breadcrumbs{*zoom:1}.wy-breadcrumbs:after,.wy-breadcrumbs:before{display:table;content:""}.wy-breadcrumbs:after{clear:both}.wy-breadcrumbs>li{display:inline-block;padding-top:5px}.wy-breadcrumbs>li.wy-breadcrumbs-aside{float:right}.rst-content .wy-breadcrumbs>li code,.rst-content .wy-breadcrumbs>li tt,.wy-breadcrumbs>li .rst-content tt,.wy-breadcrumbs>li code{all:inherit;color:inherit}.breadcrumb-item:before{content:"/";color:#bbb;font-size:13px;padding:0 6px 0 3px}.wy-breadcrumbs-extra{margin-bottom:0;color:#b3b3b3;font-size:80%;display:inline-block}@media screen and (max-width:480px){.wy-breadcrumbs-extra,.wy-breadcrumbs li.wy-breadcrumbs-aside{display:none}}@media print{.wy-breadcrumbs li.wy-breadcrumbs-aside{display:none}}html{font-size:16px}.wy-affix{position:fixed;top:1.618em}.wy-menu a:hover{text-decoration:none}.wy-menu-horiz{*zoom:1}.wy-menu-horiz:after,.wy-menu-horiz:before{display:table;content:""}.wy-menu-horiz:after{clear:both}.wy-menu-horiz li,.wy-menu-horiz ul{display:inline-block}.wy-menu-horiz li:hover{background:hsla(0,0%,100%,.1)}.wy-menu-horiz li.divide-left{border-left:1px solid #404040}.wy-menu-horiz li.divide-right{border-right:1px solid #404040}.wy-menu-horiz a{height:32px;display:inline-block;line-height:32px;padding:0 16px}.wy-menu-vertical{width:300px}.wy-menu-vertical header,.wy-menu-vertical p.caption{color:#55a5d9;height:32px;line-height:32px;padding:0 1.618em;margin:12px 0 0;display:block;font-weight:700;text-transform:uppercase;font-size:85%;white-space:nowrap}.wy-menu-vertical ul{margin-bottom:0}.wy-menu-vertical li.divide-top{border-top:1px solid #404040}.wy-menu-vertical li.divide-bottom{border-bottom:1px solid #404040}.wy-menu-vertical li.current{background:#e3e3e3}.wy-menu-vertical li.current a{color:grey;border-right:1px solid #c9c9c9;padding:.4045em 2.427em}.wy-menu-vertical li.current a:hover{background:#d6d6d6}.rst-content .wy-menu-vertical li tt,.wy-menu-vertical li .rst-content tt,.wy-menu-vertical li code{border:none;background:inherit;color:inherit;padding-left:0;padding-right:0}.wy-menu-vertical li button.toctree-expand{display:block;float:left;margin-left:-1.2em;line-height:18px;color:#4d4d4d;border:none;background:none;padding:0}.wy-menu-vertical li.current>a,.wy-menu-vertical li.on a{color:#404040;font-weight:700;position:relative;background:#fcfcfc;border:none;padding:.4045em 1.618em}.wy-menu-vertical li.current>a:hover,.wy-menu-vertical li.on a:hover{background:#fcfcfc}.wy-menu-vertical li.current>a:hover button.toctree-expand,.wy-menu-vertical li.on a:hover button.toctree-expand{color:grey}.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand{display:block;line-height:18px;color:#333}.wy-menu-vertical li.toctree-l1.current>a{border-bottom:1px solid #c9c9c9;border-top:1px solid #c9c9c9}.wy-menu-vertical .toctree-l1.current .toctree-l2>ul,.wy-menu-vertical .toctree-l2.current .toctree-l3>ul,.wy-menu-vertical .toctree-l3.current .toctree-l4>ul,.wy-menu-vertical .toctree-l4.current .toctree-l5>ul,.wy-menu-vertical .toctree-l5.current .toctree-l6>ul,.wy-menu-vertical .toctree-l6.current .toctree-l7>ul,.wy-menu-vertical .toctree-l7.current .toctree-l8>ul,.wy-menu-vertical .toctree-l8.current .toctree-l9>ul,.wy-menu-vertical .toctree-l9.current .toctree-l10>ul,.wy-menu-vertical .toctree-l10.current .toctree-l11>ul{display:none}.wy-menu-vertical .toctree-l1.current .current.toctree-l2>ul,.wy-menu-vertical .toctree-l2.current .current.toctree-l3>ul,.wy-menu-vertical .toctree-l3.current .current.toctree-l4>ul,.wy-menu-vertical .toctree-l4.current .current.toctree-l5>ul,.wy-menu-vertical .toctree-l5.current .current.toctree-l6>ul,.wy-menu-vertical .toctree-l6.current .current.toctree-l7>ul,.wy-menu-vertical .toctree-l7.current .current.toctree-l8>ul,.wy-menu-vertical .toctree-l8.current .current.toctree-l9>ul,.wy-menu-vertical .toctree-l9.current .current.toctree-l10>ul,.wy-menu-vertical .toctree-l10.current .current.toctree-l11>ul{display:block}.wy-menu-vertical li.toctree-l3,.wy-menu-vertical li.toctree-l4{font-size:.9em}.wy-menu-vertical li.toctree-l2 a,.wy-menu-vertical li.toctree-l3 a,.wy-menu-vertical li.toctree-l4 a,.wy-menu-vertical li.toctree-l5 a,.wy-menu-vertical li.toctree-l6 a,.wy-menu-vertical li.toctree-l7 a,.wy-menu-vertical li.toctree-l8 a,.wy-menu-vertical li.toctree-l9 a,.wy-menu-vertical li.toctree-l10 a{color:#404040}.wy-menu-vertical li.toctree-l2 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l3 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l4 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l5 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l6 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l7 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l8 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l9 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l10 a:hover button.toctree-expand{color:grey}.wy-menu-vertical li.toctree-l2.current li.toctree-l3>a,.wy-menu-vertical li.toctree-l3.current li.toctree-l4>a,.wy-menu-vertical li.toctree-l4.current li.toctree-l5>a,.wy-menu-vertical li.toctree-l5.current li.toctree-l6>a,.wy-menu-vertical li.toctree-l6.current li.toctree-l7>a,.wy-menu-vertical li.toctree-l7.current li.toctree-l8>a,.wy-menu-vertical li.toctree-l8.current li.toctree-l9>a,.wy-menu-vertical li.toctree-l9.current li.toctree-l10>a,.wy-menu-vertical li.toctree-l10.current li.toctree-l11>a{display:block}.wy-menu-vertical li.toctree-l2.current>a{padding:.4045em 2.427em}.wy-menu-vertical li.toctree-l2.current li.toctree-l3>a{padding:.4045em 1.618em .4045em 4.045em}.wy-menu-vertical li.toctree-l3.current>a{padding:.4045em 4.045em}.wy-menu-vertical li.toctree-l3.current li.toctree-l4>a{padding:.4045em 1.618em .4045em 5.663em}.wy-menu-vertical li.toctree-l4.current>a{padding:.4045em 5.663em}.wy-menu-vertical li.toctree-l4.current li.toctree-l5>a{padding:.4045em 1.618em .4045em 7.281em}.wy-menu-vertical li.toctree-l5.current>a{padding:.4045em 7.281em}.wy-menu-vertical li.toctree-l5.current li.toctree-l6>a{padding:.4045em 1.618em .4045em 8.899em}.wy-menu-vertical li.toctree-l6.current>a{padding:.4045em 8.899em}.wy-menu-vertical li.toctree-l6.current li.toctree-l7>a{padding:.4045em 1.618em .4045em 10.517em}.wy-menu-vertical li.toctree-l7.current>a{padding:.4045em 10.517em}.wy-menu-vertical li.toctree-l7.current li.toctree-l8>a{padding:.4045em 1.618em .4045em 12.135em}.wy-menu-vertical li.toctree-l8.current>a{padding:.4045em 12.135em}.wy-menu-vertical li.toctree-l8.current li.toctree-l9>a{padding:.4045em 1.618em .4045em 13.753em}.wy-menu-vertical li.toctree-l9.current>a{padding:.4045em 13.753em}.wy-menu-vertical li.toctree-l9.current li.toctree-l10>a{padding:.4045em 1.618em .4045em 15.371em}.wy-menu-vertical li.toctree-l10.current>a{padding:.4045em 15.371em}.wy-menu-vertical li.toctree-l10.current li.toctree-l11>a{padding:.4045em 1.618em .4045em 16.989em}.wy-menu-vertical li.toctree-l2.current>a,.wy-menu-vertical li.toctree-l2.current li.toctree-l3>a{background:#c9c9c9}.wy-menu-vertical li.toctree-l2 button.toctree-expand{color:#a3a3a3}.wy-menu-vertical li.toctree-l3.current>a,.wy-menu-vertical li.toctree-l3.current li.toctree-l4>a{background:#bdbdbd}.wy-menu-vertical li.toctree-l3 button.toctree-expand{color:#969696}.wy-menu-vertical li.current ul{display:block}.wy-menu-vertical li ul{margin-bottom:0;display:none}.wy-menu-vertical li ul li a{margin-bottom:0;color:#d9d9d9;font-weight:400}.wy-menu-vertical a{line-height:18px;padding:.4045em 1.618em;display:block;position:relative;font-size:90%;color:#d9d9d9}.wy-menu-vertical a:hover{background-color:#4e4a4a;cursor:pointer}.wy-menu-vertical a:hover button.toctree-expand{color:#d9d9d9}.wy-menu-vertical a:active{background-color:#2980b9;cursor:pointer;color:#fff}.wy-menu-vertical a:active button.toctree-expand{color:#fff}.wy-side-nav-search{display:block;width:300px;padding:.809em;margin-bottom:.809em;z-index:200;background-color:#2980b9;text-align:center;color:#fcfcfc}.wy-side-nav-search input[type=text]{width:100%;border-radius:50px;padding:6px 12px;border-color:#2472a4}.wy-side-nav-search img{display:block;margin:auto auto .809em;height:45px;width:45px;background-color:#2980b9;padding:5px;border-radius:100%}.wy-side-nav-search .wy-dropdown>a,.wy-side-nav-search>a{color:#fcfcfc;font-size:100%;font-weight:700;display:inline-block;padding:4px 6px;margin-bottom:.809em;max-width:100%}.wy-side-nav-search .wy-dropdown>a:hover,.wy-side-nav-search .wy-dropdown>aactive,.wy-side-nav-search .wy-dropdown>afocus,.wy-side-nav-search>a:hover,.wy-side-nav-search>aactive,.wy-side-nav-search>afocus{background:hsla(0,0%,100%,.1)}.wy-side-nav-search .wy-dropdown>a img.logo,.wy-side-nav-search>a img.logo{display:block;margin:0 auto;height:auto;width:auto;border-radius:0;max-width:100%;background:transparent}.wy-side-nav-search .wy-dropdown>a.icon,.wy-side-nav-search>a.icon{display:block}.wy-side-nav-search .wy-dropdown>a.icon img.logo,.wy-side-nav-search>a.icon img.logo{margin-top:.85em}.wy-side-nav-search>div.switch-menus{position:relative;display:block;margin-top:-.4045em;margin-bottom:.809em;font-weight:400;color:hsla(0,0%,100%,.3)}.wy-side-nav-search>div.switch-menus>div.language-switch,.wy-side-nav-search>div.switch-menus>div.version-switch{display:inline-block;padding:.2em}.wy-side-nav-search>div.switch-menus>div.language-switch select,.wy-side-nav-search>div.switch-menus>div.version-switch select{display:inline-block;margin-right:-2rem;padding-right:2rem;max-width:240px;text-align-last:center;background:none;border:none;border-radius:0;box-shadow:none;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;font-size:1em;font-weight:400;color:hsla(0,0%,100%,.3);cursor:pointer;appearance:none;-webkit-appearance:none;-moz-appearance:none}.wy-side-nav-search>div.switch-menus>div.language-switch select:active,.wy-side-nav-search>div.switch-menus>div.language-switch select:focus,.wy-side-nav-search>div.switch-menus>div.language-switch select:hover,.wy-side-nav-search>div.switch-menus>div.version-switch select:active,.wy-side-nav-search>div.switch-menus>div.version-switch select:focus,.wy-side-nav-search>div.switch-menus>div.version-switch select:hover{background:hsla(0,0%,100%,.1);color:hsla(0,0%,100%,.5)}.wy-side-nav-search>div.switch-menus>div.language-switch select option,.wy-side-nav-search>div.switch-menus>div.version-switch select option{color:#000}.wy-side-nav-search>div.switch-menus>div.language-switch:has(>select):after,.wy-side-nav-search>div.switch-menus>div.version-switch:has(>select):after{display:inline-block;width:1.5em;height:100%;padding:.1em;content:"\f0d7";font-size:1em;line-height:1.2em;font-family:FontAwesome;text-align:center;pointer-events:none;box-sizing:border-box}.wy-nav .wy-menu-vertical header{color:#2980b9}.wy-nav .wy-menu-vertical a{color:#b3b3b3}.wy-nav .wy-menu-vertical a:hover{background-color:#2980b9;color:#fff}[data-menu-wrap]{-webkit-transition:all .2s ease-in;-moz-transition:all .2s ease-in;transition:all .2s ease-in;position:absolute;opacity:1;width:100%;opacity:0}[data-menu-wrap].move-center{left:0;right:auto;opacity:1}[data-menu-wrap].move-left{right:auto;left:-100%;opacity:0}[data-menu-wrap].move-right{right:-100%;left:auto;opacity:0}.wy-body-for-nav{background:#fcfcfc}.wy-grid-for-nav{position:absolute;width:100%;height:100%}.wy-nav-side{position:fixed;top:0;bottom:0;left:0;padding-bottom:2em;width:300px;overflow-x:hidden;overflow-y:hidden;min-height:100%;color:#9b9b9b;background:#343131;z-index:200}.wy-side-scroll{width:320px;position:relative;overflow-x:hidden;overflow-y:scroll;height:100%}.wy-nav-top{display:none;background:#2980b9;color:#fff;padding:.4045em .809em;position:relative;line-height:50px;text-align:center;font-size:100%;*zoom:1}.wy-nav-top:after,.wy-nav-top:before{display:table;content:""}.wy-nav-top:after{clear:both}.wy-nav-top a{color:#fff;font-weight:700}.wy-nav-top img{margin-right:12px;height:45px;width:45px;background-color:#2980b9;padding:5px;border-radius:100%}.wy-nav-top i{font-size:30px;float:left;cursor:pointer;padding-top:inherit}.wy-nav-content-wrap{margin-left:300px;background:#fcfcfc;min-height:100%}.wy-nav-content{padding:1.618em 3.236em;height:100%;max-width:800px;margin:auto}.wy-body-mask{position:fixed;width:100%;height:100%;background:rgba(0,0,0,.2);display:none;z-index:499}.wy-body-mask.on{display:block}footer{color:grey}footer p{margin-bottom:12px}.rst-content footer span.commit tt,footer span.commit .rst-content tt,footer span.commit code{padding:0;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;font-size:1em;background:none;border:none;color:grey}.rst-footer-buttons{*zoom:1}.rst-footer-buttons:after,.rst-footer-buttons:before{width:100%;display:table;content:""}.rst-footer-buttons:after{clear:both}.rst-breadcrumbs-buttons{margin-top:12px;*zoom:1}.rst-breadcrumbs-buttons:after,.rst-breadcrumbs-buttons:before{display:table;content:""}.rst-breadcrumbs-buttons:after{clear:both}#search-results .search li{margin-bottom:24px;border-bottom:1px solid #e1e4e5;padding-bottom:24px}#search-results .search li:first-child{border-top:1px solid #e1e4e5;padding-top:24px}#search-results .search li a{font-size:120%;margin-bottom:12px;display:inline-block}#search-results .context{color:grey;font-size:90%}.genindextable li>ul{margin-left:24px}@media screen and (max-width:768px){.wy-body-for-nav{background:#fcfcfc}.wy-nav-top{display:block}.wy-nav-side{left:-300px}.wy-nav-side.shift{width:85%;left:0}.wy-menu.wy-menu-vertical,.wy-side-nav-search,.wy-side-scroll{width:auto}.wy-nav-content-wrap{margin-left:0}.wy-nav-content-wrap .wy-nav-content{padding:1.618em}.wy-nav-content-wrap.shift{position:fixed;min-width:100%;left:85%;top:0;height:100%;overflow:hidden}}@media screen and (min-width:1100px){.wy-nav-content-wrap{background:rgba(0,0,0,.05)}.wy-nav-content{margin:0;background:#fcfcfc}}@media print{.rst-versions,.wy-nav-side,footer{display:none}.wy-nav-content-wrap{margin-left:0}}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60;*zoom:1}.rst-versions .rst-current-version:after,.rst-versions .rst-current-version:before{display:table;content:""}.rst-versions .rst-current-version:after{clear:both}.rst-content .code-block-caption .rst-versions .rst-current-version .headerlink,.rst-content .eqno .rst-versions .rst-current-version .headerlink,.rst-content .rst-versions .rst-current-version .admonition-title,.rst-content code.download .rst-versions .rst-current-version span:first-child,.rst-content dl dt .rst-versions .rst-current-version .headerlink,.rst-content h1 .rst-versions .rst-current-version .headerlink,.rst-content h2 .rst-versions .rst-current-version .headerlink,.rst-content h3 .rst-versions .rst-current-version .headerlink,.rst-content h4 .rst-versions .rst-current-version .headerlink,.rst-content h5 .rst-versions .rst-current-version .headerlink,.rst-content h6 .rst-versions .rst-current-version .headerlink,.rst-content p .rst-versions .rst-current-version .headerlink,.rst-content table>caption .rst-versions .rst-current-version .headerlink,.rst-content tt.download .rst-versions .rst-current-version span:first-child,.rst-versions .rst-current-version .fa,.rst-versions .rst-current-version .icon,.rst-versions .rst-current-version .rst-content .admonition-title,.rst-versions .rst-current-version .rst-content .code-block-caption .headerlink,.rst-versions .rst-current-version .rst-content .eqno .headerlink,.rst-versions .rst-current-version .rst-content code.download span:first-child,.rst-versions .rst-current-version .rst-content dl dt .headerlink,.rst-versions .rst-current-version .rst-content h1 .headerlink,.rst-versions .rst-current-version .rst-content h2 .headerlink,.rst-versions .rst-current-version .rst-content h3 .headerlink,.rst-versions .rst-current-version .rst-content h4 .headerlink,.rst-versions .rst-current-version .rst-content h5 .headerlink,.rst-versions .rst-current-version .rst-content h6 .headerlink,.rst-versions .rst-current-version .rst-content p .headerlink,.rst-versions .rst-current-version .rst-content table>caption .headerlink,.rst-versions .rst-current-version .rst-content tt.download span:first-child,.rst-versions .rst-current-version .wy-menu-vertical li button.toctree-expand,.wy-menu-vertical li .rst-versions .rst-current-version button.toctree-expand{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions .rst-other-versions .rtd-current-item{font-weight:700}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}#flyout-search-form{padding:6px}.rst-content .toctree-wrapper>p.caption,.rst-content h1,.rst-content h2,.rst-content h3,.rst-content h4,.rst-content h5,.rst-content h6{margin-bottom:24px}.rst-content img{max-width:100%;height:auto}.rst-content div.figure,.rst-content figure{margin-bottom:24px}.rst-content div.figure .caption-text,.rst-content figure .caption-text{font-style:italic}.rst-content div.figure p:last-child.caption,.rst-content figure p:last-child.caption{margin-bottom:0}.rst-content div.figure.align-center,.rst-content figure.align-center{text-align:center}.rst-content .section>a>img,.rst-content .section>img,.rst-content section>a>img,.rst-content section>img{margin-bottom:24px}.rst-content abbr[title]{text-decoration:none}.rst-content.style-external-links a.reference.external:after{font-family:FontAwesome;content:"\f08e";color:#b3b3b3;vertical-align:super;font-size:60%;margin:0 .2em}.rst-content blockquote{margin-left:24px;line-height:24px;margin-bottom:24px}.rst-content pre.literal-block{white-space:pre;margin:0;padding:12px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;display:block;overflow:auto}.rst-content div[class^=highlight],.rst-content pre.literal-block{border:1px solid #e1e4e5;overflow-x:auto;margin:1px 0 24px}.rst-content div[class^=highlight] div[class^=highlight],.rst-content pre.literal-block div[class^=highlight]{padding:0;border:none;margin:0}.rst-content div[class^=highlight] td.code{width:100%}.rst-content .linenodiv pre{border-right:1px solid #e6e9ea;margin:0;padding:12px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;user-select:none;pointer-events:none}.rst-content div[class^=highlight] pre{white-space:pre;margin:0;padding:12px;display:block;overflow:auto}.rst-content div[class^=highlight] pre .hll{display:block;margin:0 -12px;padding:0 12px}.rst-content .linenodiv pre,.rst-content div[class^=highlight] pre,.rst-content pre.literal-block{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;font-size:12px;line-height:1.4}.rst-content div.highlight .gp,.rst-content div.highlight span.linenos{user-select:none;pointer-events:none}.rst-content div.highlight span.linenos{display:inline-block;padding-left:0;padding-right:12px;margin-right:12px;border-right:1px solid #e6e9ea}.rst-content .code-block-caption{font-style:italic;font-size:85%;line-height:1;padding:1em 0;text-align:center}@media print{.rst-content .codeblock,.rst-content div[class^=highlight],.rst-content div[class^=highlight] pre{white-space:pre-wrap}}.rst-content .admonition,.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .danger,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .note,.rst-content .seealso,.rst-content .tip,.rst-content .warning{clear:both}.rst-content .admonition-todo .last,.rst-content .admonition-todo>:last-child,.rst-content .admonition .last,.rst-content .admonition>:last-child,.rst-content .attention .last,.rst-content .attention>:last-child,.rst-content .caution .last,.rst-content .caution>:last-child,.rst-content .danger .last,.rst-content .danger>:last-child,.rst-content .error .last,.rst-content .error>:last-child,.rst-content .hint .last,.rst-content .hint>:last-child,.rst-content .important .last,.rst-content .important>:last-child,.rst-content .note .last,.rst-content .note>:last-child,.rst-content .seealso .last,.rst-content .seealso>:last-child,.rst-content .tip .last,.rst-content .tip>:last-child,.rst-content .warning .last,.rst-content .warning>:last-child{margin-bottom:0}.rst-content .admonition-title:before{margin-right:4px}.rst-content .admonition table{border-color:rgba(0,0,0,.1)}.rst-content .admonition table td,.rst-content .admonition table th{background:transparent!important;border-color:rgba(0,0,0,.1)!important}.rst-content .section ol.loweralpha,.rst-content .section ol.loweralpha>li,.rst-content .toctree-wrapper ol.loweralpha,.rst-content .toctree-wrapper ol.loweralpha>li,.rst-content section ol.loweralpha,.rst-content section ol.loweralpha>li{list-style:lower-alpha}.rst-content .section ol.upperalpha,.rst-content .section ol.upperalpha>li,.rst-content .toctree-wrapper ol.upperalpha,.rst-content .toctree-wrapper ol.upperalpha>li,.rst-content section ol.upperalpha,.rst-content section ol.upperalpha>li{list-style:upper-alpha}.rst-content .section ol li>*,.rst-content .section ul li>*,.rst-content .toctree-wrapper ol li>*,.rst-content .toctree-wrapper ul li>*,.rst-content section ol li>*,.rst-content section ul li>*{margin-top:12px;margin-bottom:12px}.rst-content .section ol li>:first-child,.rst-content .section ul li>:first-child,.rst-content .toctree-wrapper ol li>:first-child,.rst-content .toctree-wrapper ul li>:first-child,.rst-content section ol li>:first-child,.rst-content section ul li>:first-child{margin-top:0}.rst-content .section ol li>p,.rst-content .section ol li>p:last-child,.rst-content .section ul li>p,.rst-content .section ul li>p:last-child,.rst-content .toctree-wrapper ol li>p,.rst-content .toctree-wrapper ol li>p:last-child,.rst-content .toctree-wrapper ul li>p,.rst-content .toctree-wrapper ul li>p:last-child,.rst-content section ol li>p,.rst-content section ol li>p:last-child,.rst-content section ul li>p,.rst-content section ul li>p:last-child{margin-bottom:12px}.rst-content .section ol li>p:only-child,.rst-content .section ol li>p:only-child:last-child,.rst-content .section ul li>p:only-child,.rst-content .section ul li>p:only-child:last-child,.rst-content .toctree-wrapper ol li>p:only-child,.rst-content .toctree-wrapper ol li>p:only-child:last-child,.rst-content .toctree-wrapper ul li>p:only-child,.rst-content .toctree-wrapper ul li>p:only-child:last-child,.rst-content section ol li>p:only-child,.rst-content section ol li>p:only-child:last-child,.rst-content section ul li>p:only-child,.rst-content section ul li>p:only-child:last-child{margin-bottom:0}.rst-content .section ol li>ol,.rst-content .section ol li>ul,.rst-content .section ul li>ol,.rst-content .section ul li>ul,.rst-content .toctree-wrapper ol li>ol,.rst-content .toctree-wrapper ol li>ul,.rst-content .toctree-wrapper ul li>ol,.rst-content .toctree-wrapper ul li>ul,.rst-content section ol li>ol,.rst-content section ol li>ul,.rst-content section ul li>ol,.rst-content section ul li>ul{margin-bottom:12px}.rst-content .section ol.simple li>*,.rst-content .section ol.simple li ol,.rst-content .section ol.simple li ul,.rst-content .section ul.simple li>*,.rst-content .section ul.simple li ol,.rst-content .section ul.simple li ul,.rst-content .toctree-wrapper ol.simple li>*,.rst-content .toctree-wrapper ol.simple li ol,.rst-content .toctree-wrapper ol.simple li ul,.rst-content .toctree-wrapper ul.simple li>*,.rst-content .toctree-wrapper ul.simple li ol,.rst-content .toctree-wrapper ul.simple li ul,.rst-content section ol.simple li>*,.rst-content section ol.simple li ol,.rst-content section ol.simple li ul,.rst-content section ul.simple li>*,.rst-content section ul.simple li ol,.rst-content section ul.simple li ul{margin-top:0;margin-bottom:0}.rst-content .line-block{margin-left:0;margin-bottom:24px;line-height:24px}.rst-content .line-block .line-block{margin-left:24px;margin-bottom:0}.rst-content .topic-title{font-weight:700;margin-bottom:12px}.rst-content .toc-backref{color:#404040}.rst-content .align-right{float:right;margin:0 0 24px 24px}.rst-content .align-left{float:left;margin:0 24px 24px 0}.rst-content .align-center{margin:auto}.rst-content .align-center:not(table){display:block}.rst-content .code-block-caption .headerlink,.rst-content .eqno .headerlink,.rst-content .toctree-wrapper>p.caption .headerlink,.rst-content dl dt .headerlink,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content p.caption .headerlink,.rst-content p .headerlink,.rst-content table>caption .headerlink{opacity:0;font-size:14px;font-family:FontAwesome;margin-left:.5em}.rst-content .code-block-caption .headerlink:focus,.rst-content .code-block-caption:hover .headerlink,.rst-content .eqno .headerlink:focus,.rst-content .eqno:hover .headerlink,.rst-content .toctree-wrapper>p.caption .headerlink:focus,.rst-content .toctree-wrapper>p.caption:hover .headerlink,.rst-content dl dt .headerlink:focus,.rst-content dl dt:hover .headerlink,.rst-content h1 .headerlink:focus,.rst-content h1:hover .headerlink,.rst-content h2 .headerlink:focus,.rst-content h2:hover .headerlink,.rst-content h3 .headerlink:focus,.rst-content h3:hover .headerlink,.rst-content h4 .headerlink:focus,.rst-content h4:hover .headerlink,.rst-content h5 .headerlink:focus,.rst-content h5:hover .headerlink,.rst-content h6 .headerlink:focus,.rst-content h6:hover .headerlink,.rst-content p.caption .headerlink:focus,.rst-content p.caption:hover .headerlink,.rst-content p .headerlink:focus,.rst-content p:hover .headerlink,.rst-content table>caption .headerlink:focus,.rst-content table>caption:hover .headerlink{opacity:1}.rst-content p a{overflow-wrap:anywhere}.rst-content .wy-table td p,.rst-content .wy-table td ul,.rst-content .wy-table th p,.rst-content .wy-table th ul,.rst-content table.docutils td p,.rst-content table.docutils td ul,.rst-content table.docutils th p,.rst-content table.docutils th ul,.rst-content table.field-list td p,.rst-content table.field-list td ul,.rst-content table.field-list th p,.rst-content table.field-list th ul{font-size:inherit}.rst-content .btn:focus{outline:2px solid}.rst-content table>caption .headerlink:after{font-size:12px}.rst-content .centered{text-align:center}.rst-content .sidebar{float:right;width:40%;display:block;margin:0 0 24px 24px;padding:24px;background:#f3f6f6;border:1px solid #e1e4e5}.rst-content .sidebar dl,.rst-content .sidebar p,.rst-content .sidebar ul{font-size:90%}.rst-content .sidebar .last,.rst-content .sidebar>:last-child{margin-bottom:0}.rst-content .sidebar .sidebar-title{display:block;font-family:Roboto Slab,ff-tisa-web-pro,Georgia,Arial,sans-serif;font-weight:700;background:#e1e4e5;padding:6px 12px;margin:-24px -24px 24px;font-size:100%}.rst-content .highlighted{background:#f1c40f;box-shadow:0 0 0 2px #f1c40f;display:inline;font-weight:700}.rst-content .citation-reference,.rst-content .footnote-reference{vertical-align:baseline;position:relative;top:-.4em;line-height:0;font-size:90%}.rst-content .citation-reference>span.fn-bracket,.rst-content .footnote-reference>span.fn-bracket{display:none}.rst-content .hlist{width:100%}.rst-content dl dt span.classifier:before{content:" : "}.rst-content dl dt span.classifier-delimiter{display:none!important}html.writer-html4 .rst-content table.docutils.citation,html.writer-html4 .rst-content table.docutils.footnote{background:none;border:none}html.writer-html4 .rst-content table.docutils.citation td,html.writer-html4 .rst-content table.docutils.citation tr,html.writer-html4 .rst-content table.docutils.footnote td,html.writer-html4 .rst-content table.docutils.footnote tr{border:none;background-color:transparent!important;white-space:normal}html.writer-html4 .rst-content table.docutils.citation td.label,html.writer-html4 .rst-content table.docutils.footnote td.label{padding-left:0;padding-right:0;vertical-align:top}html.writer-html5 .rst-content dl.citation,html.writer-html5 .rst-content dl.field-list,html.writer-html5 .rst-content dl.footnote{display:grid;grid-template-columns:auto minmax(80%,95%)}html.writer-html5 .rst-content dl.citation>dt,html.writer-html5 .rst-content dl.field-list>dt,html.writer-html5 .rst-content dl.footnote>dt{display:inline-grid;grid-template-columns:max-content auto}html.writer-html5 .rst-content aside.citation,html.writer-html5 .rst-content aside.footnote,html.writer-html5 .rst-content div.citation{display:grid;grid-template-columns:auto auto minmax(.65rem,auto) minmax(40%,95%)}html.writer-html5 .rst-content aside.citation>span.label,html.writer-html5 .rst-content aside.footnote>span.label,html.writer-html5 .rst-content div.citation>span.label{grid-column-start:1;grid-column-end:2}html.writer-html5 .rst-content aside.citation>span.backrefs,html.writer-html5 .rst-content aside.footnote>span.backrefs,html.writer-html5 .rst-content div.citation>span.backrefs{grid-column-start:2;grid-column-end:3;grid-row-start:1;grid-row-end:3}html.writer-html5 .rst-content aside.citation>p,html.writer-html5 .rst-content aside.footnote>p,html.writer-html5 .rst-content div.citation>p{grid-column-start:4;grid-column-end:5}html.writer-html5 .rst-content dl.citation,html.writer-html5 .rst-content dl.field-list,html.writer-html5 .rst-content dl.footnote{margin-bottom:24px}html.writer-html5 .rst-content dl.citation>dt,html.writer-html5 .rst-content dl.field-list>dt,html.writer-html5 .rst-content dl.footnote>dt{padding-left:1rem}html.writer-html5 .rst-content dl.citation>dd,html.writer-html5 .rst-content dl.citation>dt,html.writer-html5 .rst-content dl.field-list>dd,html.writer-html5 .rst-content dl.field-list>dt,html.writer-html5 .rst-content dl.footnote>dd,html.writer-html5 .rst-content dl.footnote>dt{margin-bottom:0}html.writer-html5 .rst-content dl.citation,html.writer-html5 .rst-content dl.footnote{font-size:.9rem}html.writer-html5 .rst-content dl.citation>dt,html.writer-html5 .rst-content dl.footnote>dt{margin:0 .5rem .5rem 0;line-height:1.2rem;word-break:break-all;font-weight:400}html.writer-html5 .rst-content dl.citation>dt>span.brackets:before,html.writer-html5 .rst-content dl.footnote>dt>span.brackets:before{content:"["}html.writer-html5 .rst-content dl.citation>dt>span.brackets:after,html.writer-html5 .rst-content dl.footnote>dt>span.brackets:after{content:"]"}html.writer-html5 .rst-content dl.citation>dt>span.fn-backref,html.writer-html5 .rst-content dl.footnote>dt>span.fn-backref{text-align:left;font-style:italic;margin-left:.65rem;word-break:break-word;word-spacing:-.1rem;max-width:5rem}html.writer-html5 .rst-content dl.citation>dt>span.fn-backref>a,html.writer-html5 .rst-content dl.footnote>dt>span.fn-backref>a{word-break:keep-all}html.writer-html5 .rst-content dl.citation>dt>span.fn-backref>a:not(:first-child):before,html.writer-html5 .rst-content dl.footnote>dt>span.fn-backref>a:not(:first-child):before{content:" "}html.writer-html5 .rst-content dl.citation>dd,html.writer-html5 .rst-content dl.footnote>dd{margin:0 0 .5rem;line-height:1.2rem}html.writer-html5 .rst-content dl.citation>dd p,html.writer-html5 .rst-content dl.footnote>dd p{font-size:.9rem}html.writer-html5 .rst-content aside.citation,html.writer-html5 .rst-content aside.footnote,html.writer-html5 .rst-content div.citation{padding-left:1rem;padding-right:1rem;font-size:.9rem;line-height:1.2rem}html.writer-html5 .rst-content aside.citation p,html.writer-html5 .rst-content aside.footnote p,html.writer-html5 .rst-content div.citation p{font-size:.9rem;line-height:1.2rem;margin-bottom:12px}html.writer-html5 .rst-content aside.citation span.backrefs,html.writer-html5 .rst-content aside.footnote span.backrefs,html.writer-html5 .rst-content div.citation span.backrefs{text-align:left;font-style:italic;margin-left:.65rem;word-break:break-word;word-spacing:-.1rem;max-width:5rem}html.writer-html5 .rst-content aside.citation span.backrefs>a,html.writer-html5 .rst-content aside.footnote span.backrefs>a,html.writer-html5 .rst-content div.citation span.backrefs>a{word-break:keep-all}html.writer-html5 .rst-content aside.citation span.backrefs>a:not(:first-child):before,html.writer-html5 .rst-content aside.footnote span.backrefs>a:not(:first-child):before,html.writer-html5 .rst-content div.citation span.backrefs>a:not(:first-child):before{content:" "}html.writer-html5 .rst-content aside.citation span.label,html.writer-html5 .rst-content aside.footnote span.label,html.writer-html5 .rst-content div.citation span.label{line-height:1.2rem}html.writer-html5 .rst-content aside.citation-list,html.writer-html5 .rst-content aside.footnote-list,html.writer-html5 .rst-content div.citation-list{margin-bottom:24px}html.writer-html5 .rst-content dl.option-list kbd{font-size:.9rem}.rst-content table.docutils.footnote,html.writer-html4 .rst-content table.docutils.citation,html.writer-html5 .rst-content aside.footnote,html.writer-html5 .rst-content aside.footnote-list aside.footnote,html.writer-html5 .rst-content div.citation-list>div.citation,html.writer-html5 .rst-content dl.citation,html.writer-html5 .rst-content dl.footnote{color:grey}.rst-content table.docutils.footnote code,.rst-content table.docutils.footnote tt,html.writer-html4 .rst-content table.docutils.citation code,html.writer-html4 .rst-content table.docutils.citation tt,html.writer-html5 .rst-content aside.footnote-list aside.footnote code,html.writer-html5 .rst-content aside.footnote-list aside.footnote tt,html.writer-html5 .rst-content aside.footnote code,html.writer-html5 .rst-content aside.footnote tt,html.writer-html5 .rst-content div.citation-list>div.citation code,html.writer-html5 .rst-content div.citation-list>div.citation tt,html.writer-html5 .rst-content dl.citation code,html.writer-html5 .rst-content dl.citation tt,html.writer-html5 .rst-content dl.footnote code,html.writer-html5 .rst-content dl.footnote tt{color:#555}.rst-content .wy-table-responsive.citation,.rst-content .wy-table-responsive.footnote{margin-bottom:0}.rst-content .wy-table-responsive.citation+:not(.citation),.rst-content .wy-table-responsive.footnote+:not(.footnote){margin-top:24px}.rst-content .wy-table-responsive.citation:last-child,.rst-content .wy-table-responsive.footnote:last-child{margin-bottom:24px}.rst-content table.docutils th{border-color:#e1e4e5}html.writer-html5 .rst-content table.docutils th{border:1px solid #e1e4e5}html.writer-html5 .rst-content table.docutils td>p,html.writer-html5 .rst-content table.docutils th>p{line-height:1rem;margin-bottom:0;font-size:.9rem}.rst-content table.docutils td .last,.rst-content table.docutils td .last>:last-child{margin-bottom:0}.rst-content table.field-list,.rst-content table.field-list td{border:none}.rst-content table.field-list td p{line-height:inherit}.rst-content table.field-list td>strong{display:inline-block}.rst-content table.field-list .field-name{padding-right:10px;text-align:left;white-space:nowrap}.rst-content table.field-list .field-body{text-align:left}.rst-content code,.rst-content tt{color:#000;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;padding:2px 5px}.rst-content code big,.rst-content code em,.rst-content tt big,.rst-content tt em{font-size:100%!important;line-height:normal}.rst-content code.literal,.rst-content tt.literal{color:#e74c3c;white-space:normal}.rst-content code.xref,.rst-content tt.xref,a .rst-content code,a .rst-content tt{font-weight:700;color:#404040;overflow-wrap:normal}.rst-content kbd,.rst-content pre,.rst-content samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace}.rst-content a code,.rst-content a tt{color:#2980b9}.rst-content dl{margin-bottom:24px}.rst-content dl dt{font-weight:700;margin-bottom:12px}.rst-content dl ol,.rst-content dl p,.rst-content dl table,.rst-content dl ul{margin-bottom:12px}.rst-content dl dd{margin:0 0 12px 24px;line-height:24px}.rst-content dl dd>ol:last-child,.rst-content dl dd>p:last-child,.rst-content dl dd>table:last-child,.rst-content dl dd>ul:last-child{margin-bottom:0}html.writer-html4 .rst-content dl:not(.docutils),html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple){margin-bottom:24px}html.writer-html4 .rst-content dl:not(.docutils)>dt,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt{display:table;margin:6px 0;font-size:90%;line-height:normal;background:#e7f2fa;color:#2980b9;border-top:3px solid #6ab0de;padding:6px;position:relative}html.writer-html4 .rst-content dl:not(.docutils)>dt:before,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt:before{color:#6ab0de}html.writer-html4 .rst-content dl:not(.docutils)>dt .headerlink,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt .headerlink{color:#404040;font-size:100%!important}html.writer-html4 .rst-content dl:not(.docutils) dl:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) dl:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt{margin-bottom:6px;border:none;border-left:3px solid #ccc;background:#f0f0f0;color:#555}html.writer-html4 .rst-content dl:not(.docutils) dl:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt .headerlink,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) dl:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt .headerlink{color:#404040;font-size:100%!important}html.writer-html4 .rst-content dl:not(.docutils)>dt:first-child,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)>dt:first-child{margin-top:0}html.writer-html4 .rst-content dl:not(.docutils) code.descclassname,html.writer-html4 .rst-content dl:not(.docutils) code.descname,html.writer-html4 .rst-content dl:not(.docutils) tt.descclassname,html.writer-html4 .rst-content dl:not(.docutils) tt.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) code.descclassname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) code.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) tt.descclassname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) tt.descname{background-color:transparent;border:none;padding:0;font-size:100%!important}html.writer-html4 .rst-content dl:not(.docutils) code.descname,html.writer-html4 .rst-content dl:not(.docutils) tt.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) code.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) tt.descname{font-weight:700}html.writer-html4 .rst-content dl:not(.docutils) .optional,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .optional{display:inline-block;padding:0 4px;color:#000;font-weight:700}html.writer-html4 .rst-content dl:not(.docutils) .property,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .property{display:inline-block;padding-right:8px;max-width:100%}html.writer-html4 .rst-content dl:not(.docutils) .k,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .k{font-style:italic}html.writer-html4 .rst-content dl:not(.docutils) .descclassname,html.writer-html4 .rst-content dl:not(.docutils) .descname,html.writer-html4 .rst-content dl:not(.docutils) .sig-name,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .descclassname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) .sig-name{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;color:#000}.rst-content .viewcode-back,.rst-content .viewcode-link{display:inline-block;color:#27ae60;font-size:80%;padding-left:24px}.rst-content .viewcode-back{display:block;float:right}.rst-content p.rubric{margin-bottom:12px;font-weight:700}.rst-content code.download,.rst-content tt.download{background:inherit;padding:inherit;font-weight:400;font-family:inherit;font-size:inherit;color:inherit;border:inherit;white-space:inherit}.rst-content code.download span:first-child,.rst-content tt.download span:first-child{-webkit-font-smoothing:subpixel-antialiased}.rst-content code.download span:first-child:before,.rst-content tt.download span:first-child:before{margin-right:4px}.rst-content .guilabel,.rst-content .menuselection{font-size:80%;font-weight:700;border-radius:4px;padding:2.4px 6px;margin:auto 2px}.rst-content .guilabel,.rst-content .menuselection{border:1px solid #7fbbe3;background:#e7f2fa}.rst-content :not(dl.option-list)>:not(dt):not(kbd):not(.kbd)>.kbd,.rst-content :not(dl.option-list)>:not(dt):not(kbd):not(.kbd)>kbd{color:inherit;font-size:80%;background-color:#fff;border:1px solid #a6a6a6;border-radius:4px;box-shadow:0 2px grey;padding:2.4px 6px;margin:auto 0}.rst-content .versionmodified{font-style:italic}@media screen and (max-width:480px){.rst-content .sidebar{width:100%}}span[id*=MathJax-Span]{color:#404040}.math{text-align:center}@font-face{font-family:Lato;src:url(fonts/lato-normal.woff2?bd03a2cc277bbbc338d464e679fe9942) format("woff2"),url(fonts/lato-normal.woff?27bd77b9162d388cb8d4c4217c7c5e2a) format("woff");font-weight:400;font-style:normal;font-display:block}@font-face{font-family:Lato;src:url(fonts/lato-bold.woff2?cccb897485813c7c256901dbca54ecf2) format("woff2"),url(fonts/lato-bold.woff?d878b6c29b10beca227e9eef4246111b) format("woff");font-weight:700;font-style:normal;font-display:block}@font-face{font-family:Lato;src:url(fonts/lato-bold-italic.woff2?0b6bb6725576b072c5d0b02ecdd1900d) format("woff2"),url(fonts/lato-bold-italic.woff?9c7e4e9eb485b4a121c760e61bc3707c) format("woff");font-weight:700;font-style:italic;font-display:block}@font-face{font-family:Lato;src:url(fonts/lato-normal-italic.woff2?4eb103b4d12be57cb1d040ed5e162e9d) format("woff2"),url(fonts/lato-normal-italic.woff?f28f2d6482446544ef1ea1ccc6dd5892) format("woff");font-weight:400;font-style:italic;font-display:block}@font-face{font-family:Roboto Slab;font-style:normal;font-weight:400;src:url(fonts/Roboto-Slab-Regular.woff2?7abf5b8d04d26a2cafea937019bca958) format("woff2"),url(fonts/Roboto-Slab-Regular.woff?c1be9284088d487c5e3ff0a10a92e58c) format("woff");font-display:block}@font-face{font-family:Roboto Slab;font-style:normal;font-weight:700;src:url(fonts/Roboto-Slab-Bold.woff2?9984f4a9bda09be08e83f2506954adbe) format("woff2"),url(fonts/Roboto-Slab-Bold.woff?bed5564a116b05148e3b3bea6fb1162a) format("woff");font-display:block} \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/_static/doctools.js b/dev/vendor/mathematics_in_lean/html/_static/doctools.js new file mode 100644 index 0000000..0398ebb --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/doctools.js @@ -0,0 +1,149 @@ +/* + * Base JavaScript utilities for all Sphinx HTML documentation. + */ +"use strict"; + +const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([ + "TEXTAREA", + "INPUT", + "SELECT", + "BUTTON", +]); + +const _ready = (callback) => { + if (document.readyState !== "loading") { + callback(); + } else { + document.addEventListener("DOMContentLoaded", callback); + } +}; + +/** + * Small JavaScript module for the documentation. + */ +const Documentation = { + init: () => { + Documentation.initDomainIndexTable(); + Documentation.initOnKeyListeners(); + }, + + /** + * i18n support + */ + TRANSLATIONS: {}, + PLURAL_EXPR: (n) => (n === 1 ? 0 : 1), + LOCALE: "unknown", + + // gettext and ngettext don't access this so that the functions + // can safely bound to a different name (_ = Documentation.gettext) + gettext: (string) => { + const translated = Documentation.TRANSLATIONS[string]; + switch (typeof translated) { + case "undefined": + return string; // no translation + case "string": + return translated; // translation exists + default: + return translated[0]; // (singular, plural) translation tuple exists + } + }, + + ngettext: (singular, plural, n) => { + const translated = Documentation.TRANSLATIONS[singular]; + if (typeof translated !== "undefined") + return translated[Documentation.PLURAL_EXPR(n)]; + return n === 1 ? singular : plural; + }, + + addTranslations: (catalog) => { + Object.assign(Documentation.TRANSLATIONS, catalog.messages); + Documentation.PLURAL_EXPR = new Function( + "n", + `return (${catalog.plural_expr})` + ); + Documentation.LOCALE = catalog.locale; + }, + + /** + * helper function to focus on search bar + */ + focusSearchBar: () => { + document.querySelectorAll("input[name=q]")[0]?.focus(); + }, + + /** + * Initialise the domain index toggle buttons + */ + initDomainIndexTable: () => { + const toggler = (el) => { + const idNumber = el.id.substr(7); + const toggledRows = document.querySelectorAll(`tr.cg-${idNumber}`); + if (el.src.substr(-9) === "minus.png") { + el.src = `${el.src.substr(0, el.src.length - 9)}plus.png`; + toggledRows.forEach((el) => (el.style.display = "none")); + } else { + el.src = `${el.src.substr(0, el.src.length - 8)}minus.png`; + toggledRows.forEach((el) => (el.style.display = "")); + } + }; + + const togglerElements = document.querySelectorAll("img.toggler"); + togglerElements.forEach((el) => + el.addEventListener("click", (event) => toggler(event.currentTarget)) + ); + togglerElements.forEach((el) => (el.style.display = "")); + if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler); + }, + + initOnKeyListeners: () => { + // only install a listener if it is really needed + if ( + !DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS && + !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS + ) + return; + + document.addEventListener("keydown", (event) => { + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.altKey || event.ctrlKey || event.metaKey) return; + + if (!event.shiftKey) { + switch (event.key) { + case "ArrowLeft": + if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; + + const prevLink = document.querySelector('link[rel="prev"]'); + if (prevLink && prevLink.href) { + window.location.href = prevLink.href; + event.preventDefault(); + } + break; + case "ArrowRight": + if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; + + const nextLink = document.querySelector('link[rel="next"]'); + if (nextLink && nextLink.href) { + window.location.href = nextLink.href; + event.preventDefault(); + } + break; + } + } + + // some keyboard layouts may need Shift to get / + switch (event.key) { + case "/": + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break; + Documentation.focusSearchBar(); + event.preventDefault(); + } + }); + }, +}; + +// quick alias for translations +const _ = Documentation.gettext; + +_ready(Documentation.init); diff --git a/dev/vendor/mathematics_in_lean/html/_static/documentation_options.js b/dev/vendor/mathematics_in_lean/html/_static/documentation_options.js new file mode 100644 index 0000000..8346118 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/documentation_options.js @@ -0,0 +1,13 @@ +const DOCUMENTATION_OPTIONS = { + VERSION: 'v4.34.0', + LANGUAGE: 'en', + COLLAPSE_INDEX: false, + BUILDER: 'html', + FILE_SUFFIX: '.html', + LINK_SUFFIX: '.html', + HAS_SOURCE: true, + SOURCELINK_SUFFIX: '.txt', + NAVIGATION_WITH_KEYS: false, + SHOW_SEARCH_SUMMARY: true, + ENABLE_SEARCH_SHORTCUTS: true, +}; \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/_static/favicon.ico b/dev/vendor/mathematics_in_lean/html/_static/favicon.ico new file mode 100644 index 0000000..610a7d4 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/favicon.ico differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/file.png b/dev/vendor/mathematics_in_lean/html/_static/file.png new file mode 100644 index 0000000..a858a41 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/file.png differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.eot b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.eot new file mode 100644 index 0000000..3361183 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.eot differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.ttf b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.ttf new file mode 100644 index 0000000..29f691d Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.ttf differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.woff b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.woff new file mode 100644 index 0000000..c6dff51 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.woff2 b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.woff2 new file mode 100644 index 0000000..bb19504 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bold.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.eot b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.eot new file mode 100644 index 0000000..3d41549 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.eot differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.ttf b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.ttf new file mode 100644 index 0000000..f402040 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.ttf differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.woff b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.woff new file mode 100644 index 0000000..88ad05b Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.woff2 b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.woff2 new file mode 100644 index 0000000..c4e3d80 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-bolditalic.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.eot b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.eot new file mode 100644 index 0000000..3f82642 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.eot differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.ttf b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.ttf new file mode 100644 index 0000000..b4bfc9b Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.ttf differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.woff b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.woff new file mode 100644 index 0000000..76114bc Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.woff2 b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.woff2 new file mode 100644 index 0000000..3404f37 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-italic.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.eot b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.eot new file mode 100644 index 0000000..11e3f2a Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.eot differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.ttf b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.ttf new file mode 100644 index 0000000..74decd9 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.ttf differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.woff b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.woff new file mode 100644 index 0000000..ae1307f Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.woff2 b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.woff2 new file mode 100644 index 0000000..3bf9843 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/Lato/lato-regular.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot new file mode 100644 index 0000000..79dc8ef Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf new file mode 100644 index 0000000..df5d1df Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff new file mode 100644 index 0000000..6cb6000 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2 b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2 new file mode 100644 index 0000000..7059e23 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot new file mode 100644 index 0000000..2f7ca78 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf new file mode 100644 index 0000000..eb52a79 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff new file mode 100644 index 0000000..f815f63 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2 b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2 new file mode 100644 index 0000000..f2c76e5 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2 differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/jquery.js b/dev/vendor/mathematics_in_lean/html/_static/jquery.js new file mode 100644 index 0000000..c4c6022 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/jquery.js @@ -0,0 +1,2 @@ +/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0"),n("table.docutils.footnote").wrap("
"),n("table.docutils.citation").wrap("
"),n(".wy-menu-vertical ul").not(".simple").siblings("a").each((function(){var t=n(this);expand=n(''),expand.on("click",(function(n){return e.toggleCurrent(t),n.stopPropagation(),!1})),t.prepend(expand)}))},reset:function(){var n=encodeURI(window.location.hash)||"#";try{var e=$(".wy-menu-vertical"),t=e.find('[href="'+n+'"]');if(0===t.length){var i=$('.document [id="'+n.substring(1)+'"]').closest("div.section");0===(t=e.find('[href="#'+i.attr("id")+'"]')).length&&(t=e.find('[href="#"]'))}if(t.length>0){$(".wy-menu-vertical .current").removeClass("current").attr("aria-expanded","false"),t.addClass("current").attr("aria-expanded","true"),t.closest("li.toctree-l1").parent().addClass("current").attr("aria-expanded","true");for(let n=1;n<=10;n++)t.closest("li.toctree-l"+n).addClass("current").attr("aria-expanded","true");t[0].scrollIntoView()}}catch(n){console.log("Error expanding nav for anchor",n)}},onScroll:function(){this.winScroll=!1;var n=this.win.scrollTop(),e=n+this.winHeight,t=this.navBar.scrollTop()+(n-this.winPosition);n<0||e>this.docHeight||(this.navBar.scrollTop(t),this.winPosition=n)},onResize:function(){this.winResize=!1,this.winHeight=this.win.height(),this.docHeight=$(document).height()},hashChange:function(){this.linkScroll=!0,this.win.one("hashchange",(function(){this.linkScroll=!1}))},toggleCurrent:function(n){var e=n.closest("li");e.siblings("li.current").removeClass("current").attr("aria-expanded","false"),e.siblings().find("li.current").removeClass("current").attr("aria-expanded","false");var t=e.find("> ul li");t.length&&(t.removeClass("current").attr("aria-expanded","false"),e.toggleClass("current").attr("aria-expanded",(function(n,e){return"true"==e?"false":"true"})))}},"undefined"!=typeof window&&(window.SphinxRtdTheme={Navigation:n.exports.ThemeNav,StickyNav:n.exports.ThemeNav}),function(){for(var n=0,e=["ms","moz","webkit","o"],t=0;t a.language.name.localeCompare(b.language.name)); + + const languagesHTML = ` +
+
Languages
+ ${languages + .map( + (translation) => ` +
+ ${translation.language.code} +
+ `, + ) + .join("\n")} +
+ `; + return languagesHTML; + } + + function renderVersions(config) { + if (!config.versions.active.length) { + return ""; + } + const versionsHTML = ` +
+
Versions
+ ${config.versions.active + .map( + (version) => ` +
+ ${version.slug} +
+ `, + ) + .join("\n")} +
+ `; + return versionsHTML; + } + + function renderDownloads(config) { + if (!Object.keys(config.versions.current.downloads).length) { + return ""; + } + const downloadsNameDisplay = { + pdf: "PDF", + epub: "Epub", + htmlzip: "HTML", + }; + + const downloadsHTML = ` +
+
Downloads
+ ${Object.entries(config.versions.current.downloads) + .map( + ([name, url]) => ` +
+ ${downloadsNameDisplay[name]} +
+ `, + ) + .join("\n")} +
+ `; + return downloadsHTML; + } + + document.addEventListener("readthedocs-addons-data-ready", function (event) { + const config = event.detail.data(); + + const flyout = ` +
+ + Read the Docs + v: ${config.versions.current.slug} + + +
+
+ ${renderLanguages(config)} + ${renderVersions(config)} + ${renderDownloads(config)} +
+
On Read the Docs
+
+ Project Home +
+
+ Builds +
+
+ Downloads +
+
+
+
Search
+
+
+ +
+
+
+
+ + Hosted by Read the Docs + +
+
+ `; + + // Inject the generated flyout into the body HTML element. + document.body.insertAdjacentHTML("beforeend", flyout); + + // Trigger the Read the Docs Addons Search modal when clicking on the "Search docs" input from inside the flyout. + document + .querySelector("#flyout-search-form") + .addEventListener("focusin", () => { + const event = new CustomEvent("readthedocs-search-show"); + document.dispatchEvent(event); + }); + }) +} + +if (themeLanguageSelector || themeVersionSelector) { + function onSelectorSwitch(event) { + const option = event.target.selectedIndex; + const item = event.target.options[option]; + window.location.href = item.dataset.url; + } + + document.addEventListener("readthedocs-addons-data-ready", function (event) { + const config = event.detail.data(); + + const versionSwitch = document.querySelector( + "div.switch-menus > div.version-switch", + ); + if (themeVersionSelector) { + let versions = config.versions.active; + if (config.versions.current.hidden || config.versions.current.type === "external") { + versions.unshift(config.versions.current); + } + const versionSelect = ` + + `; + + versionSwitch.innerHTML = versionSelect; + versionSwitch.firstElementChild.addEventListener("change", onSelectorSwitch); + } + + const languageSwitch = document.querySelector( + "div.switch-menus > div.language-switch", + ); + + if (themeLanguageSelector) { + if (config.projects.translations.length) { + // Add the current language to the options on the selector + let languages = config.projects.translations.concat( + config.projects.current, + ); + languages = languages.sort((a, b) => + a.language.name.localeCompare(b.language.name), + ); + + const languageSelect = ` + + `; + + languageSwitch.innerHTML = languageSelect; + languageSwitch.firstElementChild.addEventListener("change", onSelectorSwitch); + } + else { + languageSwitch.remove(); + } + } + }); +} + +document.addEventListener("readthedocs-addons-data-ready", function (event) { + // Trigger the Read the Docs Addons Search modal when clicking on "Search docs" input from the topnav. + document + .querySelector("[role='search'] input") + .addEventListener("focusin", () => { + const event = new CustomEvent("readthedocs-search-show"); + document.dispatchEvent(event); + }); +}); \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/_static/language_data.js b/dev/vendor/mathematics_in_lean/html/_static/language_data.js new file mode 100644 index 0000000..c7fe6c6 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/language_data.js @@ -0,0 +1,192 @@ +/* + * This script contains the language-specific data used by searchtools.js, + * namely the list of stopwords, stemmer, scorer and splitter. + */ + +var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"]; + + +/* Non-minified version is copied as a separate JS file, if available */ + +/** + * Porter Stemmer + */ +var Stemmer = function() { + + var step2list = { + ational: 'ate', + tional: 'tion', + enci: 'ence', + anci: 'ance', + izer: 'ize', + bli: 'ble', + alli: 'al', + entli: 'ent', + eli: 'e', + ousli: 'ous', + ization: 'ize', + ation: 'ate', + ator: 'ate', + alism: 'al', + iveness: 'ive', + fulness: 'ful', + ousness: 'ous', + aliti: 'al', + iviti: 'ive', + biliti: 'ble', + logi: 'log' + }; + + var step3list = { + icate: 'ic', + ative: '', + alize: 'al', + iciti: 'ic', + ical: 'ic', + ful: '', + ness: '' + }; + + var c = "[^aeiou]"; // consonant + var v = "[aeiouy]"; // vowel + var C = c + "[^aeiouy]*"; // consonant sequence + var V = v + "[aeiou]*"; // vowel sequence + + var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 + var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 + var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 + var s_v = "^(" + C + ")?" + v; // vowel in stem + + this.stemWord = function (w) { + var stem; + var suffix; + var firstch; + var origword = w; + + if (w.length < 3) + return w; + + var re; + var re2; + var re3; + var re4; + + firstch = w.substr(0,1); + if (firstch == "y") + w = firstch.toUpperCase() + w.substr(1); + + // Step 1a + re = /^(.+?)(ss|i)es$/; + re2 = /^(.+?)([^s])s$/; + + if (re.test(w)) + w = w.replace(re,"$1$2"); + else if (re2.test(w)) + w = w.replace(re2,"$1$2"); + + // Step 1b + re = /^(.+?)eed$/; + re2 = /^(.+?)(ed|ing)$/; + if (re.test(w)) { + var fp = re.exec(w); + re = new RegExp(mgr0); + if (re.test(fp[1])) { + re = /.$/; + w = w.replace(re,""); + } + } + else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1]; + re2 = new RegExp(s_v); + if (re2.test(stem)) { + w = stem; + re2 = /(at|bl|iz)$/; + re3 = new RegExp("([^aeiouylsz])\\1$"); + re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re2.test(w)) + w = w + "e"; + else if (re3.test(w)) { + re = /.$/; + w = w.replace(re,""); + } + else if (re4.test(w)) + w = w + "e"; + } + } + + // Step 1c + re = /^(.+?)y$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(s_v); + if (re.test(stem)) + w = stem + "i"; + } + + // Step 2 + re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) + w = stem + step2list[suffix]; + } + + // Step 3 + re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) + w = stem + step3list[suffix]; + } + + // Step 4 + re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; + re2 = /^(.+?)(s|t)(ion)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + if (re.test(stem)) + w = stem; + } + else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1] + fp[2]; + re2 = new RegExp(mgr1); + if (re2.test(stem)) + w = stem; + } + + // Step 5 + re = /^(.+?)e$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + re2 = new RegExp(meq1); + re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) + w = stem; + } + re = /ll$/; + re2 = new RegExp(mgr1); + if (re.test(w) && re2.test(w)) { + re = /.$/; + w = w.replace(re,""); + } + + // and turn initial Y back to y + if (firstch == "y") + w = firstch.toLowerCase() + w.substr(1); + return w; + } +} + diff --git a/dev/vendor/mathematics_in_lean/html/_static/minus.png b/dev/vendor/mathematics_in_lean/html/_static/minus.png new file mode 100644 index 0000000..d96755f Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/minus.png differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/plus.png b/dev/vendor/mathematics_in_lean/html/_static/plus.png new file mode 100644 index 0000000..7107cec Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/_static/plus.png differ diff --git a/dev/vendor/mathematics_in_lean/html/_static/pygments.css b/dev/vendor/mathematics_in_lean/html/_static/pygments.css new file mode 100644 index 0000000..6f8b210 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/pygments.css @@ -0,0 +1,75 @@ +pre { line-height: 125%; } +td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +.highlight .hll { background-color: #ffffcc } +.highlight { background: #f8f8f8; } +.highlight .c { color: #3D7B7B; font-style: italic } /* Comment */ +.highlight .err { border: 1px solid #F00 } /* Error */ +.highlight .k { color: #008000; font-weight: bold } /* Keyword */ +.highlight .o { color: #666 } /* Operator */ +.highlight .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */ +.highlight .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #9C6500 } /* Comment.Preproc */ +.highlight .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */ +.highlight .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #A00000 } /* Generic.Deleted */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ +.highlight .gr { color: #E40000 } /* Generic.Error */ +.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.highlight .gi { color: #008400 } /* Generic.Inserted */ +.highlight .go { color: #717171 } /* Generic.Output */ +.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.highlight .gt { color: #04D } /* Generic.Traceback */ +.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { color: #008000 } /* Keyword.Pseudo */ +.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #B00040 } /* Keyword.Type */ +.highlight .m { color: #666 } /* Literal.Number */ +.highlight .s { color: #BA2121 } /* Literal.String */ +.highlight .na { color: #687822 } /* Name.Attribute */ +.highlight .nb { color: #008000 } /* Name.Builtin */ +.highlight .nc { color: #00F; font-weight: bold } /* Name.Class */ +.highlight .no { color: #800 } /* Name.Constant */ +.highlight .nd { color: #A2F } /* Name.Decorator */ +.highlight .ni { color: #717171; font-weight: bold } /* Name.Entity */ +.highlight .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #00F } /* Name.Function */ +.highlight .nl { color: #767600 } /* Name.Label */ +.highlight .nn { color: #00F; font-weight: bold } /* Name.Namespace */ +.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ +.highlight .nv { color: #19177C } /* Name.Variable */ +.highlight .ow { color: #A2F; font-weight: bold } /* Operator.Word */ +.highlight .w { color: #BBB } /* Text.Whitespace */ +.highlight .mb { color: #666 } /* Literal.Number.Bin */ +.highlight .mf { color: #666 } /* Literal.Number.Float */ +.highlight .mh { color: #666 } /* Literal.Number.Hex */ +.highlight .mi { color: #666 } /* Literal.Number.Integer */ +.highlight .mo { color: #666 } /* Literal.Number.Oct */ +.highlight .sa { color: #BA2121 } /* Literal.String.Affix */ +.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ +.highlight .sc { color: #BA2121 } /* Literal.String.Char */ +.highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */ +.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ +.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ +.highlight .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */ +.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ +.highlight .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */ +.highlight .sx { color: #008000 } /* Literal.String.Other */ +.highlight .sr { color: #A45A77 } /* Literal.String.Regex */ +.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ +.highlight .ss { color: #19177C } /* Literal.String.Symbol */ +.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ +.highlight .fm { color: #00F } /* Name.Function.Magic */ +.highlight .vc { color: #19177C } /* Name.Variable.Class */ +.highlight .vg { color: #19177C } /* Name.Variable.Global */ +.highlight .vi { color: #19177C } /* Name.Variable.Instance */ +.highlight .vm { color: #19177C } /* Name.Variable.Magic */ +.highlight .il { color: #666 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/_static/searchtools.js b/dev/vendor/mathematics_in_lean/html/_static/searchtools.js new file mode 100644 index 0000000..91f4be5 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/searchtools.js @@ -0,0 +1,635 @@ +/* + * Sphinx JavaScript utilities for the full-text search. + */ +"use strict"; + +/** + * Simple result scoring code. + */ +if (typeof Scorer === "undefined") { + var Scorer = { + // Implement the following function to further tweak the score for each result + // The function takes a result array [docname, title, anchor, descr, score, filename] + // and returns the new score. + /* + score: result => { + const [docname, title, anchor, descr, score, filename, kind] = result + return score + }, + */ + + // query matches the full name of an object + objNameMatch: 11, + // or matches in the last dotted part of the object name + objPartialMatch: 6, + // Additive scores depending on the priority of the object + objPrio: { + 0: 15, // used to be importantResults + 1: 5, // used to be objectResults + 2: -5, // used to be unimportantResults + }, + // Used when the priority is not in the mapping. + objPrioDefault: 0, + + // query found in title + title: 15, + partialTitle: 7, + // query found in terms + term: 5, + partialTerm: 2, + }; +} + +// Global search result kind enum, used by themes to style search results. +class SearchResultKind { + static get index() { return "index"; } + static get object() { return "object"; } + static get text() { return "text"; } + static get title() { return "title"; } +} + +const _removeChildren = (element) => { + while (element && element.lastChild) element.removeChild(element.lastChild); +}; + +/** + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping + */ +const _escapeRegExp = (string) => + string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string + +const _displayItem = (item, searchTerms, highlightTerms) => { + const docBuilder = DOCUMENTATION_OPTIONS.BUILDER; + const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX; + const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX; + const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; + const contentRoot = document.documentElement.dataset.content_root; + + const [docName, title, anchor, descr, score, _filename, kind] = item; + + let listItem = document.createElement("li"); + // Add a class representing the item's type: + // can be used by a theme's CSS selector for styling + // See SearchResultKind for the class names. + listItem.classList.add(`kind-${kind}`); + let requestUrl; + let linkUrl; + if (docBuilder === "dirhtml") { + // dirhtml builder + let dirname = docName + "/"; + if (dirname.match(/\/index\/$/)) + dirname = dirname.substring(0, dirname.length - 6); + else if (dirname === "index/") dirname = ""; + requestUrl = contentRoot + dirname; + linkUrl = requestUrl; + } else { + // normal html builders + requestUrl = contentRoot + docName + docFileSuffix; + linkUrl = docName + docLinkSuffix; + } + let linkEl = listItem.appendChild(document.createElement("a")); + linkEl.href = linkUrl + anchor; + linkEl.dataset.score = score; + linkEl.innerHTML = title; + if (descr) { + listItem.appendChild(document.createElement("span")).innerHTML = + " (" + descr + ")"; + // highlight search terms in the description + if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js + highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted")); + } + else if (showSearchSummary) + fetch(requestUrl) + .then((responseData) => responseData.text()) + .then((data) => { + if (data) + listItem.appendChild( + Search.makeSearchSummary(data, searchTerms, anchor) + ); + // highlight search terms in the summary + if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js + highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted")); + }); + Search.output.appendChild(listItem); +}; +const _finishSearch = (resultCount) => { + Search.stopPulse(); + Search.title.innerText = _("Search Results"); + if (!resultCount) + Search.status.innerText = Documentation.gettext( + "Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories." + ); + else + Search.status.innerText = Documentation.ngettext( + "Search finished, found one page matching the search query.", + "Search finished, found ${resultCount} pages matching the search query.", + resultCount, + ).replace('${resultCount}', resultCount); +}; +const _displayNextItem = ( + results, + resultCount, + searchTerms, + highlightTerms, +) => { + // results left, load the summary and display it + // this is intended to be dynamic (don't sub resultsCount) + if (results.length) { + _displayItem(results.pop(), searchTerms, highlightTerms); + setTimeout( + () => _displayNextItem(results, resultCount, searchTerms, highlightTerms), + 5 + ); + } + // search finished, update title and status message + else _finishSearch(resultCount); +}; +// Helper function used by query() to order search results. +// Each input is an array of [docname, title, anchor, descr, score, filename, kind]. +// Order the results by score (in opposite order of appearance, since the +// `_displayNextItem` function uses pop() to retrieve items) and then alphabetically. +const _orderResultsByScoreThenName = (a, b) => { + const leftScore = a[4]; + const rightScore = b[4]; + if (leftScore === rightScore) { + // same score: sort alphabetically + const leftTitle = a[1].toLowerCase(); + const rightTitle = b[1].toLowerCase(); + if (leftTitle === rightTitle) return 0; + return leftTitle > rightTitle ? -1 : 1; // inverted is intentional + } + return leftScore > rightScore ? 1 : -1; +}; + +/** + * Default splitQuery function. Can be overridden in ``sphinx.search`` with a + * custom function per language. + * + * The regular expression works by splitting the string on consecutive characters + * that are not Unicode letters, numbers, underscores, or emoji characters. + * This is the same as ``\W+`` in Python, preserving the surrogate pair area. + */ +if (typeof splitQuery === "undefined") { + var splitQuery = (query) => query + .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}]+/gu) + .filter(term => term) // remove remaining empty strings +} + +/** + * Search Module + */ +const Search = { + _index: null, + _queued_query: null, + _pulse_status: -1, + + htmlToText: (htmlString, anchor) => { + const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html'); + for (const removalQuery of [".headerlink", "script", "style"]) { + htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() }); + } + if (anchor) { + const anchorContent = htmlElement.querySelector(`[role="main"] ${anchor}`); + if (anchorContent) return anchorContent.textContent; + + console.warn( + `Anchored content block not found. Sphinx search tries to obtain it via DOM query '[role=main] ${anchor}'. Check your theme or template.` + ); + } + + // if anchor not specified or not found, fall back to main content + const docContent = htmlElement.querySelector('[role="main"]'); + if (docContent) return docContent.textContent; + + console.warn( + "Content block not found. Sphinx search tries to obtain it via DOM query '[role=main]'. Check your theme or template." + ); + return ""; + }, + + init: () => { + const query = new URLSearchParams(window.location.search).get("q"); + document + .querySelectorAll('input[name="q"]') + .forEach((el) => (el.value = query)); + if (query) Search.performSearch(query); + }, + + loadIndex: (url) => + (document.body.appendChild(document.createElement("script")).src = url), + + setIndex: (index) => { + Search._index = index; + if (Search._queued_query !== null) { + const query = Search._queued_query; + Search._queued_query = null; + Search.query(query); + } + }, + + hasIndex: () => Search._index !== null, + + deferQuery: (query) => (Search._queued_query = query), + + stopPulse: () => (Search._pulse_status = -1), + + startPulse: () => { + if (Search._pulse_status >= 0) return; + + const pulse = () => { + Search._pulse_status = (Search._pulse_status + 1) % 4; + Search.dots.innerText = ".".repeat(Search._pulse_status); + if (Search._pulse_status >= 0) window.setTimeout(pulse, 500); + }; + pulse(); + }, + + /** + * perform a search for something (or wait until index is loaded) + */ + performSearch: (query) => { + // create the required interface elements + const searchText = document.createElement("h2"); + searchText.textContent = _("Searching"); + const searchSummary = document.createElement("p"); + searchSummary.classList.add("search-summary"); + searchSummary.innerText = ""; + const searchList = document.createElement("ul"); + searchList.setAttribute("role", "list"); + searchList.classList.add("search"); + + const out = document.getElementById("search-results"); + Search.title = out.appendChild(searchText); + Search.dots = Search.title.appendChild(document.createElement("span")); + Search.status = out.appendChild(searchSummary); + Search.output = out.appendChild(searchList); + + const searchProgress = document.getElementById("search-progress"); + // Some themes don't use the search progress node + if (searchProgress) { + searchProgress.innerText = _("Preparing search..."); + } + Search.startPulse(); + + // index already loaded, the browser was quick! + if (Search.hasIndex()) Search.query(query); + else Search.deferQuery(query); + }, + + _parseQuery: (query) => { + // stem the search terms and add them to the correct list + const stemmer = new Stemmer(); + const searchTerms = new Set(); + const excludedTerms = new Set(); + const highlightTerms = new Set(); + const objectTerms = new Set(splitQuery(query.toLowerCase().trim())); + splitQuery(query.trim()).forEach((queryTerm) => { + const queryTermLower = queryTerm.toLowerCase(); + + // maybe skip this "word" + // stopwords array is from language_data.js + if ( + stopwords.indexOf(queryTermLower) !== -1 || + queryTerm.match(/^\d+$/) + ) + return; + + // stem the word + let word = stemmer.stemWord(queryTermLower); + // select the correct list + if (word[0] === "-") excludedTerms.add(word.substr(1)); + else { + searchTerms.add(word); + highlightTerms.add(queryTermLower); + } + }); + + if (SPHINX_HIGHLIGHT_ENABLED) { // set in sphinx_highlight.js + localStorage.setItem("sphinx_highlight_terms", [...highlightTerms].join(" ")) + } + + // console.debug("SEARCH: searching for:"); + // console.info("required: ", [...searchTerms]); + // console.info("excluded: ", [...excludedTerms]); + + return [query, searchTerms, excludedTerms, highlightTerms, objectTerms]; + }, + + /** + * execute search (requires search index to be loaded) + */ + _performSearch: (query, searchTerms, excludedTerms, highlightTerms, objectTerms) => { + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const titles = Search._index.titles; + const allTitles = Search._index.alltitles; + const indexEntries = Search._index.indexentries; + + // Collect multiple result groups to be sorted separately and then ordered. + // Each is an array of [docname, title, anchor, descr, score, filename, kind]. + const normalResults = []; + const nonMainIndexResults = []; + + _removeChildren(document.getElementById("search-progress")); + + const queryLower = query.toLowerCase().trim(); + for (const [title, foundTitles] of Object.entries(allTitles)) { + if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) { + for (const [file, id] of foundTitles) { + const score = Math.round(Scorer.title * queryLower.length / title.length); + const boost = titles[file] === title ? 1 : 0; // add a boost for document titles + normalResults.push([ + docNames[file], + titles[file] !== title ? `${titles[file]} > ${title}` : title, + id !== null ? "#" + id : "", + null, + score + boost, + filenames[file], + SearchResultKind.title, + ]); + } + } + } + + // search for explicit entries in index directives + for (const [entry, foundEntries] of Object.entries(indexEntries)) { + if (entry.includes(queryLower) && (queryLower.length >= entry.length/2)) { + for (const [file, id, isMain] of foundEntries) { + const score = Math.round(100 * queryLower.length / entry.length); + const result = [ + docNames[file], + titles[file], + id ? "#" + id : "", + null, + score, + filenames[file], + SearchResultKind.index, + ]; + if (isMain) { + normalResults.push(result); + } else { + nonMainIndexResults.push(result); + } + } + } + } + + // lookup as object + objectTerms.forEach((term) => + normalResults.push(...Search.performObjectSearch(term, objectTerms)) + ); + + // lookup as search terms in fulltext + normalResults.push(...Search.performTermsSearch(searchTerms, excludedTerms)); + + // let the scorer override scores with a custom scoring function + if (Scorer.score) { + normalResults.forEach((item) => (item[4] = Scorer.score(item))); + nonMainIndexResults.forEach((item) => (item[4] = Scorer.score(item))); + } + + // Sort each group of results by score and then alphabetically by name. + normalResults.sort(_orderResultsByScoreThenName); + nonMainIndexResults.sort(_orderResultsByScoreThenName); + + // Combine the result groups in (reverse) order. + // Non-main index entries are typically arbitrary cross-references, + // so display them after other results. + let results = [...nonMainIndexResults, ...normalResults]; + + // remove duplicate search results + // note the reversing of results, so that in the case of duplicates, the highest-scoring entry is kept + let seen = new Set(); + results = results.reverse().reduce((acc, result) => { + let resultStr = result.slice(0, 4).concat([result[5]]).map(v => String(v)).join(','); + if (!seen.has(resultStr)) { + acc.push(result); + seen.add(resultStr); + } + return acc; + }, []); + + return results.reverse(); + }, + + query: (query) => { + const [searchQuery, searchTerms, excludedTerms, highlightTerms, objectTerms] = Search._parseQuery(query); + const results = Search._performSearch(searchQuery, searchTerms, excludedTerms, highlightTerms, objectTerms); + + // for debugging + //Search.lastresults = results.slice(); // a copy + // console.info("search results:", Search.lastresults); + + // print the results + _displayNextItem(results, results.length, searchTerms, highlightTerms); + }, + + /** + * search for object names + */ + performObjectSearch: (object, objectTerms) => { + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const objects = Search._index.objects; + const objNames = Search._index.objnames; + const titles = Search._index.titles; + + const results = []; + + const objectSearchCallback = (prefix, match) => { + const name = match[4] + const fullname = (prefix ? prefix + "." : "") + name; + const fullnameLower = fullname.toLowerCase(); + if (fullnameLower.indexOf(object) < 0) return; + + let score = 0; + const parts = fullnameLower.split("."); + + // check for different match types: exact matches of full name or + // "last name" (i.e. last dotted part) + if (fullnameLower === object || parts.slice(-1)[0] === object) + score += Scorer.objNameMatch; + else if (parts.slice(-1)[0].indexOf(object) > -1) + score += Scorer.objPartialMatch; // matches in last name + + const objName = objNames[match[1]][2]; + const title = titles[match[0]]; + + // If more than one term searched for, we require other words to be + // found in the name/title/description + const otherTerms = new Set(objectTerms); + otherTerms.delete(object); + if (otherTerms.size > 0) { + const haystack = `${prefix} ${name} ${objName} ${title}`.toLowerCase(); + if ( + [...otherTerms].some((otherTerm) => haystack.indexOf(otherTerm) < 0) + ) + return; + } + + let anchor = match[3]; + if (anchor === "") anchor = fullname; + else if (anchor === "-") anchor = objNames[match[1]][1] + "-" + fullname; + + const descr = objName + _(", in ") + title; + + // add custom score for some objects according to scorer + if (Scorer.objPrio.hasOwnProperty(match[2])) + score += Scorer.objPrio[match[2]]; + else score += Scorer.objPrioDefault; + + results.push([ + docNames[match[0]], + fullname, + "#" + anchor, + descr, + score, + filenames[match[0]], + SearchResultKind.object, + ]); + }; + Object.keys(objects).forEach((prefix) => + objects[prefix].forEach((array) => + objectSearchCallback(prefix, array) + ) + ); + return results; + }, + + /** + * search for full-text terms in the index + */ + performTermsSearch: (searchTerms, excludedTerms) => { + // prepare search + const terms = Search._index.terms; + const titleTerms = Search._index.titleterms; + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const titles = Search._index.titles; + + const scoreMap = new Map(); + const fileMap = new Map(); + + // perform the search on the required terms + searchTerms.forEach((word) => { + const files = []; + // find documents, if any, containing the query word in their text/title term indices + // use Object.hasOwnProperty to avoid mismatching against prototype properties + const arr = [ + { files: terms.hasOwnProperty(word) ? terms[word] : undefined, score: Scorer.term }, + { files: titleTerms.hasOwnProperty(word) ? titleTerms[word] : undefined, score: Scorer.title }, + ]; + // add support for partial matches + if (word.length > 2) { + const escapedWord = _escapeRegExp(word); + if (!terms.hasOwnProperty(word)) { + Object.keys(terms).forEach((term) => { + if (term.match(escapedWord)) + arr.push({ files: terms[term], score: Scorer.partialTerm }); + }); + } + if (!titleTerms.hasOwnProperty(word)) { + Object.keys(titleTerms).forEach((term) => { + if (term.match(escapedWord)) + arr.push({ files: titleTerms[term], score: Scorer.partialTitle }); + }); + } + } + + // no match but word was a required one + if (arr.every((record) => record.files === undefined)) return; + + // found search word in contents + arr.forEach((record) => { + if (record.files === undefined) return; + + let recordFiles = record.files; + if (recordFiles.length === undefined) recordFiles = [recordFiles]; + files.push(...recordFiles); + + // set score for the word in each file + recordFiles.forEach((file) => { + if (!scoreMap.has(file)) scoreMap.set(file, new Map()); + const fileScores = scoreMap.get(file); + fileScores.set(word, record.score); + }); + }); + + // create the mapping + files.forEach((file) => { + if (!fileMap.has(file)) fileMap.set(file, [word]); + else if (fileMap.get(file).indexOf(word) === -1) fileMap.get(file).push(word); + }); + }); + + // now check if the files don't contain excluded terms + const results = []; + for (const [file, wordList] of fileMap) { + // check if all requirements are matched + + // as search terms with length < 3 are discarded + const filteredTermCount = [...searchTerms].filter( + (term) => term.length > 2 + ).length; + if ( + wordList.length !== searchTerms.size && + wordList.length !== filteredTermCount + ) + continue; + + // ensure that none of the excluded terms is in the search result + if ( + [...excludedTerms].some( + (term) => + terms[term] === file || + titleTerms[term] === file || + (terms[term] || []).includes(file) || + (titleTerms[term] || []).includes(file) + ) + ) + break; + + // select one (max) score for the file. + const score = Math.max(...wordList.map((w) => scoreMap.get(file).get(w))); + // add result to the result list + results.push([ + docNames[file], + titles[file], + "", + null, + score, + filenames[file], + SearchResultKind.text, + ]); + } + return results; + }, + + /** + * helper function to return a node containing the + * search summary for a given text. keywords is a list + * of stemmed words. + */ + makeSearchSummary: (htmlText, keywords, anchor) => { + const text = Search.htmlToText(htmlText, anchor); + if (text === "") return null; + + const textLower = text.toLowerCase(); + const actualStartPosition = [...keywords] + .map((k) => textLower.indexOf(k.toLowerCase())) + .filter((i) => i > -1) + .slice(-1)[0]; + const startWithContext = Math.max(actualStartPosition - 120, 0); + + const top = startWithContext === 0 ? "" : "..."; + const tail = startWithContext + 240 < text.length ? "..." : ""; + + let summary = document.createElement("p"); + summary.classList.add("context"); + summary.textContent = top + text.substr(startWithContext, 240).trim() + tail; + + return summary; + }, +}; + +_ready(Search.init); diff --git a/dev/vendor/mathematics_in_lean/html/_static/sphinx_highlight.js b/dev/vendor/mathematics_in_lean/html/_static/sphinx_highlight.js new file mode 100644 index 0000000..8a96c69 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/_static/sphinx_highlight.js @@ -0,0 +1,154 @@ +/* Highlighting utilities for Sphinx HTML documentation. */ +"use strict"; + +const SPHINX_HIGHLIGHT_ENABLED = true + +/** + * highlight a given string on a node by wrapping it in + * span elements with the given class name. + */ +const _highlight = (node, addItems, text, className) => { + if (node.nodeType === Node.TEXT_NODE) { + const val = node.nodeValue; + const parent = node.parentNode; + const pos = val.toLowerCase().indexOf(text); + if ( + pos >= 0 && + !parent.classList.contains(className) && + !parent.classList.contains("nohighlight") + ) { + let span; + + const closestNode = parent.closest("body, svg, foreignObject"); + const isInSVG = closestNode && closestNode.matches("svg"); + if (isInSVG) { + span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + } else { + span = document.createElement("span"); + span.classList.add(className); + } + + span.appendChild(document.createTextNode(val.substr(pos, text.length))); + const rest = document.createTextNode(val.substr(pos + text.length)); + parent.insertBefore( + span, + parent.insertBefore( + rest, + node.nextSibling + ) + ); + node.nodeValue = val.substr(0, pos); + /* There may be more occurrences of search term in this node. So call this + * function recursively on the remaining fragment. + */ + _highlight(rest, addItems, text, className); + + if (isInSVG) { + const rect = document.createElementNS( + "http://www.w3.org/2000/svg", + "rect" + ); + const bbox = parent.getBBox(); + rect.x.baseVal.value = bbox.x; + rect.y.baseVal.value = bbox.y; + rect.width.baseVal.value = bbox.width; + rect.height.baseVal.value = bbox.height; + rect.setAttribute("class", className); + addItems.push({ parent: parent, target: rect }); + } + } + } else if (node.matches && !node.matches("button, select, textarea")) { + node.childNodes.forEach((el) => _highlight(el, addItems, text, className)); + } +}; +const _highlightText = (thisNode, text, className) => { + let addItems = []; + _highlight(thisNode, addItems, text, className); + addItems.forEach((obj) => + obj.parent.insertAdjacentElement("beforebegin", obj.target) + ); +}; + +/** + * Small JavaScript module for the documentation. + */ +const SphinxHighlight = { + + /** + * highlight the search words provided in localstorage in the text + */ + highlightSearchWords: () => { + if (!SPHINX_HIGHLIGHT_ENABLED) return; // bail if no highlight + + // get and clear terms from localstorage + const url = new URL(window.location); + const highlight = + localStorage.getItem("sphinx_highlight_terms") + || url.searchParams.get("highlight") + || ""; + localStorage.removeItem("sphinx_highlight_terms") + url.searchParams.delete("highlight"); + window.history.replaceState({}, "", url); + + // get individual terms from highlight string + const terms = highlight.toLowerCase().split(/\s+/).filter(x => x); + if (terms.length === 0) return; // nothing to do + + // There should never be more than one element matching "div.body" + const divBody = document.querySelectorAll("div.body"); + const body = divBody.length ? divBody[0] : document.querySelector("body"); + window.setTimeout(() => { + terms.forEach((term) => _highlightText(body, term, "highlighted")); + }, 10); + + const searchBox = document.getElementById("searchbox"); + if (searchBox === null) return; + searchBox.appendChild( + document + .createRange() + .createContextualFragment( + '" + ) + ); + }, + + /** + * helper function to hide the search marks again + */ + hideSearchWords: () => { + document + .querySelectorAll("#searchbox .highlight-link") + .forEach((el) => el.remove()); + document + .querySelectorAll("span.highlighted") + .forEach((el) => el.classList.remove("highlighted")); + localStorage.removeItem("sphinx_highlight_terms") + }, + + initEscapeListener: () => { + // only install a listener if it is really needed + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) return; + + document.addEventListener("keydown", (event) => { + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return; + if (DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS && (event.key === "Escape")) { + SphinxHighlight.hideSearchWords(); + event.preventDefault(); + } + }); + }, +}; + +_ready(() => { + /* Do not call highlightSearchWords() when we are on the search page. + * It will highlight words from the *previous* search query. + */ + if (typeof Search === "undefined") SphinxHighlight.highlightSearchWords(); + SphinxHighlight.initEscapeListener(); +}); diff --git a/dev/vendor/mathematics_in_lean/html/genindex.html b/dev/vendor/mathematics_in_lean/html/genindex.html new file mode 100644 index 0000000..7e0d120 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/genindex.html @@ -0,0 +1,583 @@ + + + + + + + + Index — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + +
  • +
  • +
+
+
+
+
+ + +

Index

+ +
+ A + | B + | C + | D + | E + | F + | G + | H + | I + | L + | M + | N + | O + | P + | R + | S + | T + | U + | V + +
+

A

+ + + +
+ +

B

+ + + +
+ +

C

+ + + +
+ +

D

+ + + +
+ +

E

+ + + +
+ +

F

+ + + +
+ +

G

+ + + +
+ +

H

+ + +
+ +

I

+ + + +
+ +

L

+ + + +
+ +

M

+ + + +
+ +

N

+ + + +
+ +

O

+ + + +
+ +

P

+ + + +
+ +

R

+ + + +
+ +

S

+ + + +
+ +

T

+ + + +
+ +

U

+ + +
+ +

V

+ + + +
+ + + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/index.html b/dev/vendor/mathematics_in_lean/html/index.html new file mode 100644 index 0000000..65cb543 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/index.html @@ -0,0 +1,211 @@ + + + + + + + + + Mathematics in Lean — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +
+

Mathematics in Lean

+ +
+
+
+ + +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/objects.inv b/dev/vendor/mathematics_in_lean/html/objects.inv new file mode 100644 index 0000000..7d30bd2 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/html/objects.inv differ diff --git a/dev/vendor/mathematics_in_lean/html/search.html b/dev/vendor/mathematics_in_lean/html/search.html new file mode 100644 index 0000000..7598f1d --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/search.html @@ -0,0 +1,136 @@ + + + + + + + + Search — Mathematics in Lean v4.34.0 documentation + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + +
  • +
  • +
+
+
+
+
+ + + + +
+ +
+ +
+
+
+ +
+ +
+

© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.

+
+ + Built with Sphinx using a + theme + provided by Read the Docs. + + +
+
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/html/searchindex.js b/dev/vendor/mathematics_in_lean/html/searchindex.js new file mode 100644 index 0000000..944db0c --- /dev/null +++ b/dev/vendor/mathematics_in_lean/html/searchindex.js @@ -0,0 +1 @@ +Search.setIndex({"alltitles":{"Algebraic Structures":[[6,"algebraic-structures"]],"Algebras and polynomials":[[8,"algebras-and-polynomials"]],"Asymptotic comparisons":[[11,"asymptotic-comparisons"]],"Balls, open sets and closed sets":[[10,"balls-open-sets-and-closed-sets"]],"Bases":[[9,"bases"]],"Basics":[[1,null],[7,"basics"]],"Building the Gaussian Integers":[[6,"building-the-gaussian-integers"]],"Calculating":[[1,"calculating"]],"Compactness":[[10,"compactness"],[10,"id5"]],"Complete lattice structure and internal direct sums":[[9,"complete-lattice-structure-and-internal-direct-sums"]],"Completeness":[[10,"completeness"]],"Concrete groups":[[8,"concrete-groups"]],"Conjunction and Iff":[[2,"conjunction-and-iff"]],"Continuous linear maps":[[11,"continuous-linear-maps"]],"Convergence and continuity":[[10,"convergence-and-continuity"]],"Counting Arguments":[[5,"counting-arguments"]],"Defining structures":[[6,"defining-structures"]],"Differentiability":[[11,"differentiability"]],"Differential Calculus":[[11,null]],"Differential Calculus in Normed Spaces":[[11,"differential-calculus-in-normed-spaces"]],"Dimension":[[9,"dimension"]],"Discrete Mathematics":[[5,null]],"Disjunction":[[2,"disjunction"]],"Elementary Differential Calculus":[[11,"elementary-differential-calculus"]],"Elementary Integration":[[12,"elementary-integration"]],"Elementary Number Theory":[[4,null]],"Endomorphisms":[[9,"endomorphisms"]],"Filters":[[10,"filters"]],"Finsets and Fintypes":[[5,"finsets-and-fintypes"]],"Functions":[[3,"functions"]],"Fundamentals":[[10,"fundamentals"]],"Getting Started":[[0,"getting-started"]],"Group actions":[[8,"group-actions"]],"Groups and Rings":[[8,null]],"Groups and their morphisms":[[8,"groups-and-their-morphisms"]],"Hierarchies":[[7,null]],"Ideals and quotients":[[8,"ideals-and-quotients"]],"Implication and the Universal Quantifier":[[2,"implication-and-the-universal-quantifier"]],"Index":[[13,null]],"Induction and Recursion":[[4,"induction-and-recursion"]],"Inductively Defined Types":[[5,"inductively-defined-types"]],"Infinitely Many Primes":[[4,"infinitely-many-primes"]],"Integration":[[12,"integration"]],"Integration and Measure Theory":[[12,null]],"Introduction":[[0,null]],"Irrational Roots":[[4,"irrational-roots"]],"Linear algebra":[[9,null]],"Linear maps":[[9,"linear-maps"]],"Logic":[[2,null]],"Mathematics in Lean":[[14,null]],"Matrices":[[9,"matrices"]],"Matrices, bases and dimension":[[9,"matrices-bases-and-dimension"]],"Measure Theory":[[12,"measure-theory"]],"Metric spaces":[[10,"metric-spaces"]],"Monoids and Groups":[[8,"monoids-and-groups"]],"Monoids and their morphisms":[[8,"monoids-and-their-morphisms"]],"More Induction":[[4,"more-induction"]],"More examples using apply and rw":[[1,"more-examples-using-apply-and-rw"]],"Morphisms":[[7,"morphisms"]],"Negation":[[2,"negation"]],"Normed spaces":[[11,"id3"]],"Overview":[[0,"overview"]],"Proving Facts about Algebraic Structures":[[1,"proving-facts-about-algebraic-structures"]],"Proving Identities in Algebraic Structures":[[1,"proving-identities-in-algebraic-structures"]],"Pushing and pulling subspaces":[[9,"pushing-and-pulling-subspaces"]],"Quotient groups":[[8,"quotient-groups"]],"Quotient spaces":[[9,"quotient-spaces"]],"Rings":[[8,"rings"]],"Rings, their units, morphisms and subrings":[[8,"rings-their-units-morphisms-and-subrings"]],"Separation and countability":[[10,"separation-and-countability"]],"Sequences and Convergence":[[2,"sequences-and-convergence"]],"Sets":[[3,"sets"]],"Sets and Functions":[[3,null]],"Structures":[[6,null]],"Sub-objects":[[7,"sub-objects"]],"Subgroups":[[8,"subgroups"]],"Subspace spanned by a set":[[9,"subspace-spanned-by-a-set"]],"Subspaces":[[9,"subspaces"]],"Subspaces and quotients":[[9,"subspaces-and-quotients"]],"Sums and products of vector spaces":[[9,"sums-and-products-of-vector-spaces"]],"The Existential Quantifier":[[2,"the-existential-quantifier"]],"The Schr\u00f6der-Bernstein Theorem":[[3,"the-schroder-bernstein-theorem"]],"Topological spaces":[[10,"topological-spaces"]],"Topology":[[10,null]],"Uniformly continuous functions":[[10,"uniformly-continuous-functions"]],"Using Theorems and Lemmas":[[1,"using-theorems-and-lemmas"]],"Vector spaces":[[9,"vector-spaces"]],"Vector spaces and linear maps":[[9,"vector-spaces-and-linear-maps"]]},"docnames":["C01_Introduction","C02_Basics","C03_Logic","C04_Sets_and_Functions","C05_Elementary_Number_Theory","C06_Discrete_Mathematics","C07_Structures","C08_Hierarchies","C09_Groups_and_Rings","C10_Linear_Algebra","C11_Topology","C12_Differential_Calculus","C13_Integration_and_Measure_Theory","genindex","index"],"envversion":{"sphinx":65,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["C01_Introduction.rst","C02_Basics.rst","C03_Logic.rst","C04_Sets_and_Functions.rst","C05_Elementary_Number_Theory.rst","C06_Discrete_Mathematics.rst","C07_Structures.rst","C08_Hierarchies.rst","C09_Groups_and_Rings.rst","C10_Linear_Algebra.rst","C11_Topology.rst","C12_Differential_Calculus.rst","C13_Integration_and_Measure_Theory.rst","genindex.rst","index.rst"],"indexentries":{"abel":[[1,"index-15",false],[8,"index-3",false]],"absolute value":[[1,"index-24",false]],"absurd":[[2,"index-17",false]],"anonymous constructor":[[2,"index-7",false]],"apply":[[1,"index-12",false],[1,"index-17",false]],"assumption":[[2,"index-19",false]],"bounded quantifiers":[[3,"index-3",false]],"by_cases":[[2,"index-23",false]],"by_contra":[[2,"index-14",false]],"by_contra and by_contradiction":[[2,"index-14",false]],"calc":[[1,"index-3",false]],"cases":[[2,"index-8",false]],"change":[[2,"index-2",false]],"check":[[0,"index-0",false]],"command":[[1,"index-9",false]],"commands":[[0,"index-0",false]],"commutative ring":[[1,"index-8",false]],"congr":[[2,"index-25",false]],"constructor":[[2,"index-18",false]],"continuity":[[10,"index-3",false]],"contradiction":[[2,"index-17",false]],"contrapose":[[2,"index-16",false]],"convert":[[2,"index-26",false]],"decide":[[4,"index-0",false]],"definitional equality":[[1,"index-13",false]],"differential calculus":[[11,"index-0",false]],"divisibility":[[1,"index-25",false]],"dsimp":[[2,"index-2",false]],"elementary calculus":[[11,"index-1",false]],"erw":[[2,"index-4",false]],"exact":[[1,"index-12",false],[1,"index-17",false],[1,"index-5",false]],"excluded middle":[[2,"index-22",false]],"exfalso":[[2,"index-17",false]],"exponential":[[1,"index-19",false]],"ext":[[2,"index-24",false]],"extensionality":[[2,"index-24",false]],"field_simp":[[2,"index-11",false]],"filter":[[10,"index-1",false]],"from":[[2,"index-12",false]],"gcd":[[1,"index-26",false]],"goal":[[1,"index-2",false]],"group":[[1,"index-15",false],[8,"index-2",false]],"group (algebraic structure)":[[1,"index-14",false],[8,"index-1",false]],"group (tactic)":[[1,"index-15",false],[8,"index-2",false]],"have":[[1,"index-11",false],[2,"index-12",false]],"implicit argument":[[1,"index-10",false]],"inequalities":[[1,"index-16",false]],"injective function":[[2,"index-5",false]],"integration":[[12,"index-0",false],[12,"index-1",false]],"intro":[[2,"index-0",false]],"lambda abstraction":[[2,"index-1",false]],"lattice":[[1,"index-28",false]],"lcm":[[1,"index-26",false]],"left":[[2,"index-21",false]],"let":[[2,"index-13",false]],"linarith":[[1,"index-18",false]],"linear map":[[9,"index-1",false]],"local context":[[1,"index-2",false]],"logarithm":[[1,"index-19",false]],"matrices":[[9,"index-3",false]],"max":[[1,"index-21",false]],"measure theory":[[12,"index-2",false]],"metric space":[[1,"index-30",false],[10,"index-2",false]],"min":[[1,"index-21",false]],"monoid":[[8,"index-0",false]],"monotone function":[[2,"index-3",false]],"namespace":[[1,"index-9",false]],"noncomm_ring":[[1,"index-15",false]],"norm_num":[[1,"index-20",false]],"normed space":[[11,"index-2",false]],"open":[[1,"index-9",false]],"order relation":[[1,"index-27",false]],"partial order":[[1,"index-27",false]],"proof state":[[1,"index-2",false]],"push":[[2,"index-15",false]],"rcases":[[2,"index-9",false]],"real numbers":[[1,"index-1",false]],"refl and reflexivity":[[1,"index-13",false]],"reflexivity":[[1,"index-13",false]],"repeat":[[1,"index-23",false]],"rewrite":[[1,"index-0",false]],"rfl":[[1,"index-13",false]],"right":[[2,"index-21",false]],"ring":[[1,"index-6",false]],"ring (algebraic structure)":[[1,"index-7",false],[8,"index-4",false]],"ring (tactic)":[[1,"index-6",false]],"rintro":[[2,"index-9",false]],"rw":[[1,"index-0",false],[1,"index-4",false]],"rw and rewrite":[[1,"index-0",false],[1,"index-4",false]],"rwa":[[3,"index-2",false]],"set operations":[[3,"index-0",false]],"show":[[1,"index-22",false]],"simp":[[2,"index-20",false],[3,"index-1",false]],"surjective function":[[2,"index-10",false]],"tactics":[[1,"index-0",false],[1,"index-11",false],[1,"index-12",false],[1,"index-13",false],[1,"index-15",false],[1,"index-17",false],[1,"index-18",false],[1,"index-20",false],[1,"index-22",false],[1,"index-23",false],[1,"index-29",false],[1,"index-3",false],[1,"index-4",false],[1,"index-5",false],[1,"index-6",false],[2,"index-0",false],[2,"index-11",false],[2,"index-12",false],[2,"index-13",false],[2,"index-14",false],[2,"index-15",false],[2,"index-16",false],[2,"index-17",false],[2,"index-18",false],[2,"index-19",false],[2,"index-2",false],[2,"index-20",false],[2,"index-21",false],[2,"index-23",false],[2,"index-24",false],[2,"index-25",false],[2,"index-26",false],[2,"index-4",false],[2,"index-6",false],[2,"index-8",false],[2,"index-9",false],[3,"index-1",false],[3,"index-2",false],[4,"index-0",false],[8,"index-2",false],[8,"index-3",false],[10,"index-3",false]],"this":[[2,"index-12",false]],"topological space":[[10,"index-4",false]],"topology":[[10,"index-0",false]],"trans":[[1,"index-29",false]],"use":[[2,"index-6",false]],"vector space":[[9,"index-0",false]],"vector subspace":[[9,"index-2",false]]},"objects":{},"objnames":{},"objtypes":{},"terms":{"":[0,1,2,3,4,5,6,7,8,9,10,11,12],"0":[0,1,2,3,4,5,6,7,8,9,10,11,12],"02463336v2":7,"1":[1,2,3,4,5,6,7,8,9,10,11,12],"10":[2,5,9],"10000":4,"11":[2,9,10],"12":[4,9,11],"13":9,"15":[2,5],"16":9,"17":4,"2":[0,1,2,3,4,5,6,7,8,9,10,11,12],"20":4,"2023":5,"263":7,"27":4,"29":9,"2c":4,"3":[0,1,2,3,4,5,6,7,8,9,10],"36":9,"37":2,"4":[0,1,2,4,5,6,8,9,10,11],"4c":4,"5":[1,2,4,5,6,8,9,10,11],"50":7,"512":10,"6":[2,4,5,6,7,8,9,10,11],"64":10,"7":[2,4,5,6,7,8,9,10],"70":7,"73":7,"8":[2,4,5,6,8,9,10],"9":[8,9],"A":[0,1,2,3,4,5,6,7,8,9,10,11],"And":[2,4,7,10],"As":[0,1,2,3,4,5,6,7,8,9,10,11,12],"At":[0,1,2,4,6,7,9],"Be":[1,3],"But":[0,1,2,3,4,6,7,8,9,10],"By":[1,3,5,6,7,8,9],"For":[0,1,2,3,4,5,6,7,8,9,10,11,12],"If":[0,1,2,3,4,5,6,7,9,10],"In":[0,1,2,3,4,5,6,7,8,9,10,11,12],"It":[0,1,2,3,4,5,6,7,8,9,10,11],"Its":[6,7],"Not":[1,2,3,4,6,10],"Of":[1,2,4,5,7,8,9,10,11,12],"On":[1,2,3,6,7,9,10,12],"One":[1,2,3,4,6,7,8,9,10],"Or":[2,3,9],"Such":[0,1,2,7],"That":[0,4,6,7],"The":[0,1,4,5,6,7,8,9,10,11,12,14],"Their":[10,11],"Then":[2,3,5,6,7,8,9,10,12],"There":[0,1,2,3,4,5,7,8,9,10,11,12],"These":[0,1,3,4,6,8,11,12],"To":[0,1,2,3,4,6,7,8,9,10],"With":[1,3,4,5,7,10],"_":[0,1,2,3,4,5,6,7,8,9,10,11,12],"_a":2,"_add_mod":6,"_b":2,"_def":4,"_eq":6,"_eq_fib":4,"_i":5,"_in":10,"_inst_1":6,"_le":6,"_n":8,"_root_":[1,3,4],"_x":[2,3],"_z":2,"a_0":3,"a_1":3,"a_2":3,"a_def":3,"a_of_b_of_c":1,"ab":[0,2,6,8],"abandon":4,"abbrevi":[1,2,3,5,6,9],"abel":[1,8],"abelian":[1,6,7,9],"abgrpmodul":7,"abil":0,"abl":[0,1,2,3,4,5,6,7,8,9,11],"abn":2,"about":[0,2,3,4,5,6,7,8,9,10,11,14],"abov":[0,1,2,3,4,6,7,8,9,10,12],"abs_add_l":[1,2],"abs_l":[1,6],"abs_lt":2,"abs_mod":6,"abs_mul":2,"abs_nonneg":2,"abs_of_neg":2,"abs_of_nonneg":[2,6],"abs_po":2,"abs_zero":2,"absa":2,"absb":2,"absenc":4,"absolut":2,"absorb":8,"absorb1":1,"absorb2":1,"absorpt":1,"abstract":[1,2,6,7,8,9,10],"abstractli":10,"absurd":[2,4],"abus":6,"ac":6,"accept":[0,1,2,9,10],"access":[1,3,6,7,8,9,10,12],"accessor":6,"accid":9,"accommod":[6,8],"accompani":6,"accord":[4,6,9],"account":9,"achiev":[6,7],"acknowledg":0,"acpo":2,"across":[5,7],"act":[1,8,9],"action":9,"activ":[0,5],"actual":[2,3,4,7,8,9,10],"ad":[1,2,3,4,5,6,7,9,10],"adapt":6,"add":[2,4,5,6,7,8,9,10,11],"add_assoc":[1,4,6,7],"add_assoc\u2083":7,"add_comm":[1,4,6,7,8],"add_def":6,"add_im":6,"add_l":1,"add_le_add":[1,2],"add_le_add_left":1,"add_le_add_right":1,"add_left_cancel":1,"add_left_inj":2,"add_lt_add_left":1,"add_lt_add_of_le_of_lt":1,"add_lt_add_of_lt_of_l":1,"add_lt_add_right":1,"add_mem":[8,9],"add_mem_sup":9,"add_mul":[1,7],"add_mul_mod_self_left":4,"add_neg_cancel":1,"add_neg_cancel_right":1,"add_nonneg":[1,6],"add_one_le_of_lt":6,"add_po":1,"add_pos_of_pos_of_nonneg":1,"add_r":6,"add_right_cancel":1,"add_right_inject":5,"add_smul":[7,8,9],"add_sub":1,"add_sub_cancel":4,"add_sub_cancel_right":1,"add_vadd":8,"add_x":6,"add_zero":[1,6,7],"addact":8,"addalt":6,"addalt_comm":6,"addalt_x":6,"addcommgroup":[1,8,9],"addcommgroup\u2083":7,"addcommmonoid":[2,8,9],"addcommmonoidtoaddcommgroup":9,"addcommmonoid\u2083":7,"addcommsemigroup\u2083":7,"addequiv":8,"addgroup":[1,6,8],"addgrouppoint":6,"addgroup\u2081":6,"addgroup\u2082":6,"addgroup\u2083":7,"addit":[1,2,4,5,6,7,8,9,10,11,12],"addmonoid":[7,8],"addmonoidhom":8,"addmonoidhom\u2081":7,"addmonoid\u2083":7,"addmonoid\u2084":7,"addsemigroup\u2083":7,"addsubgroup":8,"addzeroclass":7,"adi":6,"adjac":9,"adject":7,"adjug":9,"adopt":1,"advanc":9,"advantag":[2,3,4,6,8,11],"ae":[10,12],"aestronglymeasur":12,"aeval":[8,9],"aeval_self_charpoli":9,"aeval_x":9,"affect":7,"affin":8,"aforement":10,"after":[1,2,4,5,7,9,10,11],"again":[1,2,3,4,6,7,8,9,10],"against":2,"aggress":[2,4],"agre":[3,5],"aid":9,"aim":[4,8],"aka":[9,10],"aleb":2,"alembert":8,"alex":0,"alexandru":0,"algebra":[4,5,7,10,11,12,14],"algebrahom":7,"algebramap":8,"alghom":8,"algorithm":[5,6],"alistair":0,"all":[0,1,2,3,4,5,6,7,8,9,10,11,12],"allow":[1,2,3,4,5,6,7,8,9,10,11,12],"almost":[6,7,8,9,10,12],"alon":3,"along":[1,4,8,10],"alpha":[2,3],"alreadi":[0,1,2,3,4,5,6,7,8,9,10],"also":[0,1,2,3,4,5,6,7,8,9,10,11,12],"altern":[0,1,2,3,4,5,6,7],"although":[0,3,4,7,8,9,10],"alwai":[0,1,2,3,4,5,6,7,8,9],"ambient":8,"ambigu":[1,6],"among":4,"amount":[5,8,9],"an":[0,1,2,3,4,5,6,7,8,9,10,11,12],"analog":[1,2,3,4,9,10],"analogi":[2,6,10,11],"analogu":5,"analysi":[0,6,9,11],"analyt":11,"ancient":4,"and_comm":3,"anecdot":7,"angl":2,"ani":[0,1,2,3,4,5,6,7,8,9,10,11,12],"anin":5,"ann":6,"annoi":[4,7],"annot":[1,2,3,4,6,7],"announc":9,"anonym":[2,3,4,6,8],"anoth":[0,1,2,3,4,5,6,7,8,9,10],"answer":[0,6,10],"antisymm":3,"antisymmetr":[1,2,6],"anyhow":2,"anyth":[2,6,7,10],"anywai":[4,8],"anywher":5,"apart":[6,7,9],"api":1,"appeal":[3,4,7],"appear":[0,1,2,6,7,8,9,10],"append":5,"append_assoc":5,"append_nil":5,"appli":[2,3,4,5,6,7,8,9,10,11,12,14],"applic":[1,2,5,6,8,12],"apply_fun":8,"appreci":4,"approach":[4,5,6,7,10],"appropri":[1,2,3,6,7],"approxim":1,"ar":[0,1,2,3,4,5,6,7,8,9,10,11,12],"arbitrari":[1,2,3,4,6,8,9],"arbitrarili":[2,10],"archetyp":[6,9],"argu":7,"argument":[1,2,3,4,6,7,8,9,10,14],"aris":2,"arithmet":[1,4,5],"aroot":8,"aroots_def":8,"around":[1,3,5,7,8,9,10,12],"arrai":9,"arrang":6,"arrow":[1,2,7,10],"art":5,"artifici":[6,9],"ascii":7,"ascript":[7,8,9],"asid":3,"ask":[2,4,5,6,7,8,10],"aspect":[0,6,8],"assembl":[9,10],"assert":[2,3,7,8],"assign":[2,3,5,6,7,8],"assist":[0,2,6],"associ":[0,1,2,4,5,6,7,8,9,10,12],"assum":[0,1,2,3,4,5,7,8,9,10],"assumpt":[0,1,2,3,4,6,8,9,10,11,12],"assur":6,"asymmetri":2,"attach":[5,9,10],"attain":10,"attempt":7,"attent":[1,2,4,7,8,10],"attop":[10,12],"attop_basi":10,"attr":7,"attract":2,"attribut":7,"auto":[1,2,7],"autom":[0,1,5,6],"automat":[0,1,2,3,4,5,6,7,8,9,10,11],"aux":[1,2,4,10],"aux_card_eq":8,"aux_eq":4,"auxiliari":[2,5,10],"avail":[0,1,2,4,6,7,8,9],"averag":6,"avoid":[1,2,3,4,5,6,7,8,11],"awai":[2,6],"awkward":9,"axel":0,"axiom":[1,2,3,6,7,8,9,10,12],"axiomat":[1,2,3,6],"az":9,"b":[1,2,3,4,5,6,7,8,9,10,11,12],"b_indep":9,"b_span":9,"baanen":6,"back":[0,1,2,6,7,8,9,10],"background":[0,8],"backslash":[1,3],"backward":[2,5,10],"bad":[6,7,9,10],"badinst":7,"bair":[10,11],"balanc":1,"ball":[3,11],"banach":[11,12],"bar":[0,1,2,9],"bare":[7,9],"barrier":7,"base":[0,2,3,4,5,7,8,10,11,14],"basi":[6,9,10],"basic":[0,2,5,6,9,10,12,14],"basisfun":9,"basissingleon":9,"baz":1,"bbb":[2,6],"bc":6,"bci":6,"bd":6,"becaus":[1,2,3,4,5,6,7,8,9,10,11],"becom":[1,4,6,7,10],"been":[0,1,2,4,5,6,7,9,11],"befor":[0,1,2,3,4,6,7,8,9],"begin":[1,2,3,4,6,7],"begun":10,"behav":[2,3,7,9,10],"behavior":[3,7,10],"behind":[3,8],"being":[1,3,6,7,8,9,10,11],"belong":[6,7,10],"below":[0,2,3,4,5,6,7,8,9,10,11,12],"benefit":[8,9],"benjamin":0,"beq":2,"berman":0,"bernardo":0,"bernstein":14,"besid":7,"bespok":6,"best":0,"beta":[2,3],"better":[3,4,6,7,10],"between":[0,1,2,3,4,5,6,7,8,9,10,11,12],"bewar":[1,7,9],"bex":3,"bex_def":3,"beyond":[2,7,11],"bhavik":[0,5],"bi":[1,2,6],"big":[0,6,8,9,10,11],"bigcup_":[3,5],"bigger":[0,3,11],"bigoper":[4,6,8],"biject":[3,6,8,9],"bijective_iff_injective_and_card":8,"bilinear":12,"binari":[1,2,4,5,6,7,9],"binary_product":9,"bind":[1,3],"binder":7,"bintre":5,"bipartit":[5,6],"bit":[1,2,4,7,8,9,10],"biunion":5,"black":[4,7],"block":[1,4,8],"blur":10,"bochner":12,"bodi":[2,8],"boil":7,"bold":2,"boldt":0,"bolt":1,"book":[0,2,9,10],"bool":5,"boolean":[1,5],"border":10,"borelspac":12,"boss":10,"bot":5,"both":[1,2,3,4,6,7,8,10,11],"bother":[1,3],"bottom":[5,7,8,9,10],"bound":[1,2,3,4,5,6,9,10,11,12],"bounded":11,"bounded_of_ex_finset":4,"bourbaki":10,"box":4,"bpo":[2,10],"bq":6,"brace":[1,9],"bracket":[1,2,6,7,8],"branch":[2,3,5,7],"break":7,"breviti":[1,6],"briefli":8,"bring":[3,4,10],"broader":[4,11],"broadest":6,"brown":0,"brows":[0,1,4,8],"bryan":0,"build":[0,2,4,5,7,8,9,10,14],"builder":[3,5],"built":[0,2,4,7,8,9],"builtin":7,"bulb":6,"bulwi":0,"bundl":[6,7,8,9,10,11],"button":0,"by_cas":[2,3,4],"by_contra":[2,4],"c":[0,1,2,4,5,6,7,8,9,10,11,12],"c_mul":8,"c_neg":8,"cach":0,"calc":[1,2,3,5,6,8,10],"calcul":[0,2,4,5,6,14],"calculu":[10,12,14],"call":[0,1,2,3,4,5,6,7,8,9,10,11,12],"can":[0,1,2,3,4,5,6,7,8,9,10,11,12],"candid":6,"cannot":[2,3,4,5,6,7,8,9,10],"canon":[2,3,4,6,9],"cantor":3,"cap":3,"capabl":6,"capit":6,"captur":9,"card":[5,8],"card_biunion":5,"card_co":5,"card_congr":[5,8],"card_dvd_of_l":8,"card_eq_one_iff_exist":8,"card_eq_sum_on":5,"card_image_of_inject":5,"card_image_of_injon":5,"card_po":8,"card_product":5,"card_rang":5,"card_sigma":[5,8],"card_union":5,"card_union_of_disjoint":5,"cardin":[3,5,8,9],"care":[1,2,3,4,5,6,9],"carneiro":0,"carri":[0,1,2,3,4,6,7,8,9,10,12],"carrier":[1,6,7,8,9],"cartesian":5,"case":[1,2,3,4,5,6,7,8,9,10,12],"catch":5,"categor":10,"categori":[6,9,10,11],"cauchi":10,"cauchyseq":10,"cauchyseq_iff":10,"cauchyseq_of_le_geometric_two":10,"cauchyseq_tendsto_of_complet":10,"caveat":8,"caylei":[8,9],"cayleyisomorph":8,"cdist":10,"cdot":6,"center":[0,10],"central":[0,4,5],"centuri":3,"ceq":2,"certain":[2,5,7,10],"certifi":0,"cha":0,"chain":6,"challeng":[0,1,2,3,6,11],"chanc":2,"chang":[0,1,2,4,6,9,10,12],"chapter":[0,1,2,3,4,5,6,7,8,9,10,11],"char":0,"charact":[1,3,7],"character":[1,3,4,9,10,11],"characterist":9,"charpoli":9,"chat":0,"cheat":[0,1],"check":[0,1,2,3,4,5,6,7,8,9,10],"checksynthord":7,"chen":0,"chestnut":2,"chines":8,"chineseiso":8,"chinesemap":8,"chinesemap_inj":8,"chinesemap_mk":8,"chinesemap_surj":8,"choic":[1,2,3,4,5,6,9,10],"choos":[0,2,3,4,5,6,7,8,10],"choose_spec":[3,5],"chose":7,"chosen":[2,6],"circ":[3,6],"circl":8,"circleequ":8,"claim":10,"clarifi":6,"clash":1,"class":[1,4,5,6,7,8,9,10,11,12],"classic":[2,3,4,5,8,9],"claus":[5,7],"clean":[2,10],"clear":[1,2,4,6,7],"clearer":[1,3,6],"clearli":10,"clever":[1,5],"click":[0,1,3,4,6,7],"clock":0,"clontz":0,"close":[1,2,3,5,7,8,9,11,12],"closed_nhds_basi":10,"closedbal":10,"closer":[2,10],"closur":[8,9,10],"closure_iscycl":8,"cloud":0,"clue":8,"clunki":10,"cluster":10,"clusterpt":10,"co":[2,8],"cocki":1,"code":[0,1,2,3,4,6,7,9],"codespac":0,"codomain":[2,4,10],"coe":7,"coe_inject":7,"coe_natabs_norm":6,"coeff":8,"coeffici":[6,8,9],"coefun":7,"coelinearmap":9,"coerc":[5,7,8,9],"coercion":[6,7,8,9,10,11],"coincid":[4,6,10],"coinduc":10,"coinduced_compos":10,"coinduced_le_iff_le_induc":10,"collari":0,"collect":[1,2,3,6,9,10,12],"collis":7,"colon":[2,4],"column":9,"comap":[8,9,10],"comap_bot":9,"comap_comap":10,"comap_map_eq":9,"comapmkqreliso":9,"combin":[1,2,6,7,8,9,10],"combinator":5,"come":[0,1,2,3,4,5,6,7,8,9,10],"comfort":0,"comm":8,"comma":[1,9],"command":[0,1,2,3,4,6,7,8,9],"commelin":0,"comment":[0,4],"commgroup":1,"commgroup\u2083":7,"commmonoid":7,"commmonoid\u2083":7,"common":[1,2,3,4,5,6,8,9,10],"commonli":[4,5,6],"commr":[1,2,6,8],"commsemigroup\u2083":7,"commsemir":[8,9],"commun":[0,4],"commut":[1,2,3,4,5,6,7,8,9,11],"comp":[8,9,10],"comp_id":9,"compact":12,"compactspac":10,"compani":2,"companion":[0,1],"compar":[0,6,7,9,10],"comparison":7,"compat":[1,8,10],"compat_mymap":8,"compl":12,"complain":[1,5],"complement":[3,9,10,12],"complementari":0,"complet":[0,1,2,3,4,5,7,8,11],"completespac":[10,11,12],"complex":[0,1,2,4,6,8,9,11,12],"complic":[1,2,4,7,8,9],"compon":[2,3,6,9,10,12],"compos":[3,5,6,8,10],"composit":[2,3,6,7,8,9,10],"compound":[1,2,5,10],"compress":[0,1,10],"comput":[0,2,3,4,5,6,8,9,11,12],"computation":[4,9],"con":5,"concentr":3,"concept":[6,8,9,10,11],"conceptu":[3,8],"concis":[1,6,8],"conclud":[2,11],"conclus":[1,2,4],"concret":[1,2,4,6,7,9,10],"condens":3,"condit":[3,4,5,7,8,9,10,11],"confid":3,"configur":6,"confirm":[1,2,3,4],"conflict":5,"confus":[3,4,5,7,8,10],"congr":[2,5],"congratul":[1,2,4],"congruent":4,"conj":[5,6],"conj_im":6,"conj_r":6,"conjug":[4,6,8],"conjugate_on":8,"conjunct":[1,7,14],"connect":[1,3,5,6,9,10],"cons_append":5,"consecut":[4,5],"consequ":8,"consid":[1,2,3,4,5,6,7,8,10,11,12],"consider":9,"consist":[1,3,5,6,7,8,9,10,11],"constant":[1,2,5,8,12],"constantli":8,"constitut":[1,5],"constr":9,"constr_basi":9,"constraint":[6,10],"construct":[0,2,3,4,5,6,7,8,9,10],"constructor":[1,2,3,4,5,6,7],"consult":6,"cont":11,"contain":[0,2,3,4,5,6,7,8,9,10,11,12],"contdiff":11,"contdiff_iff_continuous_differenti":11,"contdiffat":11,"contend":4,"content":[0,1,2,4,10],"context":[1,2,4,6,7,8,9,10,11,12],"contextu":6,"continu":[0,1,4,5,6,7,9,12],"continuous_def":10,"continuous_dist":10,"continuous_fst":10,"continuous_id":[7,10],"continuous_iff":10,"continuous_iff_coinduced_l":10,"continuous_linear_map":11,"continuous_pow":10,"continuous_snd":10,"continuousat":[10,12],"continuousat_extend":10,"continuousat_iff":10,"continuouslinearmap":11,"continuouson":[10,11],"continuum":2,"contort":8,"contract":2,"contradict":[2,3,4],"contradictori":2,"contrapos":[2,3,4],"contrari":2,"contrast":[2,3,6,7,10],"contravari":10,"contribut":[0,3],"contributor":9,"control":2,"conveni":[1,2,3,5,6,7,8,9,10],"convent":[1,5,6,8,12],"convention":10,"converg":[12,14],"convergesto":2,"convergesto_add":2,"convergesto_const":2,"convergesto_mul":2,"convergesto_mul_const":2,"convergesto_uniqu":2,"convers":[0,2,4,8,9,10],"convert":[2,4,5,8,9],"convinc":[5,6],"convolut":12,"coordin":[5,8,9],"copi":[0,3,4,5,7,8,9,10],"coprim":[4,5,8],"coprime_add_self_right":4,"coprime_mn":4,"coprod":9,"coprod_inl":9,"coprod_inr":9,"coproduct":9,"core":[0,4,6],"corner":[0,5,8],"corollari":8,"correct":[0,1,8,9],"correctli":3,"correspond":[0,1,2,3,4,5,6,7,8,9,10,11],"could":[0,1,2,4,6,7,8,9,10],"count":[8,14],"count_factors_mul_of_po":4,"countabl":[5,12],"counter":9,"counterexampl":[2,11],"counterpart":6,"coupl":[1,2,7,9,10],"cours":[1,2,4,5,7,8,9,10,11,12],"covari":10,"cover":[0,1,3,7,8,9,10,11],"cramer":9,"creat":[0,1,4,7],"creation":8,"creativ":6,"criterion":10,"crucial":[8,9,10],"crude":4,"cryptic":2,"ct":2,"ctrl":[0,1,2,4,6],"cube":8,"cue":6,"cup":3,"curiou":[1,5,7],"curli":[1,2,9],"current":[1,2,4,6,7],"curri":1,"cursor":[0,1,2],"curv":0,"custom":6,"cut":4,"cycl":8,"cyclic":8,"czubin":0,"d":[1,2,4,6,8,9,11],"dai":3,"danger":[4,6,7],"darij":0,"data":[2,4,5,6,7,9,10],"databas":[3,4,7,10],"datatyp":4,"de":0,"deal":[1,2,3,4,5,6,9,10],"dealt":2,"decid":[4,5,8,9,10],"decidableeq":[4,5,9],"decidablepr":4,"decis":[4,5,8],"declar":[0,1,4,5,6,7,8,9],"decompos":[0,3],"decreas":[1,4,6],"dedekind":3,"deduc":[7,8,10],"def":[0,2,3,4,5,6,7,8,9,10],"default":[1,2,3,4,6,7,8,11],"defect":[2,7,10],"defin":[1,2,3,4,7,8,9,10,11,12,14],"definit":[0,1,2,3,4,5,6,7,8,9,10,11,12],"definition":[1,4,5,6,7,8,10],"degre":8,"degree_mul":8,"delet":[1,2,3,5],"delic":3,"delimit":1,"demonstr":[7,10],"deni":0,"denomin":[2,4,6],"denot":[1,3,4,6,7,8,9,10,11],"dens":10,"densiti":10,"depend":[0,2,3,4,6,7,8,9,10],"depth":5,"depth_le_s":5,"deriv":[1,2,4,8,11,12],"deriv_add":11,"deriv_eq_zero":11,"deriv_zero_of_not_differentiableat":11,"descend":[7,8],"describ":[0,1,2,3,4,5,6,7,9,10],"descript":[0,1,2,4,10],"deserv":4,"design":[0,1,2,3,4,5,6,8,9,10],"desir":[1,3,7,8,10],"despit":9,"destruct":2,"destructur":7,"det":[9,12],"det_mul":9,"det_on":9,"detail":[1,2,3,4,6,7,8],"detect":2,"determin":[1,6,8,9,10],"develop":[0,1,4,8,12],"devic":7,"devot":10,"dfun":7,"dfunlik":7,"di":[2,6],"dia":7,"dia_assoc":7,"dia_inv":7,"dia_on":7,"diagon":5,"diagram":3,"diamond":7,"diaoneclass\u2081":7,"dia\u2081":7,"dictionari":1,"did":[0,2,5,7,10],"diff_eq":3,"differ":[0,1,2,3,4,6,7,8,9,10,11],"differenti":[12,14],"differentiableat":11,"differentiableon":11,"difficult":[2,7],"digress":10,"dimens":14,"dimension":[9,11,12],"direct":[1,2,3,5,7,8,10,11],"directli":[1,2,4,5,6,7,9,10],"directsum":9,"disabl":2,"discret":[6,14],"discuss":[1,2,4,5,6,7,8,9,10,11],"dishwash":0,"disj":5,"disjoint":[3,5,8,12],"disjoint_iff_n":5,"disjunct":[1,3,14],"dispens":4,"displai":[0,1,2,7],"dispos":2,"dist":[1,10],"dist_comm":[1,10],"dist_eq_zero":10,"dist_le_range_sum_dist":10,"dist_nonneg":[1,10],"dist_self":1,"dist_triangl":[1,10],"distanc":[1,2,10,11],"distinct":[0,2,3,4,5,6,9,10],"distinguish":[0,6,7,8,10,11],"distract":7,"distriblattic":1,"distribut":[1,4,6,7],"dite_eq_left":3,"dite_eq_right":3,"div":6,"div_def":6,"div_dvd_of_dvd":4,"div_eq_mul_inv":6,"div_eq_of_eq_mul_right":4,"div_lt_self":4,"div_nonneg":6,"div_po":2,"divab":2,"divac":2,"divbc":2,"dive":0,"divid":[1,2,4,6,8],"divis":[1,2,4,6,7,9],"divisor":[1,2,4,6,8],"do":[0,1,2,3,4,5,6,7,8,9,10,11,12],"doc":0,"document":[0,1,3,4,7],"doe":[0,1,2,3,4,5,6,7,8,9,10,11],"doesn":[1,2,8,9,10],"domain":[1,2,3,4,6,8,10],"domin":12,"domrestrict":8,"don":[0,1,2,3,4,5,6,7,8,9,10,12],"done":[0,2,3,4,7,8,9,10],"doorn":0,"dot":[1,8,9,10],"doubl":[2,3],"doublecount":5,"doubli":8,"doubt":0,"down":[0,3,4,5,7,10],"download":0,"downsid":[8,9],"dozen":3,"draw":[1,6,7],"drop":2,"dsimp":[2,3,6,8],"dual":[6,10],"dualli":10,"duca":0,"due":[1,7],"duplic":[5,7],"dvd":1,"dvd_add_iff_left":4,"dvd_antisymm":1,"dvd_fac":4,"dvd_factori":4,"dvd_gcd":4,"dvd_gcd_iff":2,"dvd_iff_exists_eq_mul_left":4,"dvd_mul":4,"dvd_mul_left":1,"dvd_mul_of_dvd_left":1,"dvd_mul_of_dvd_right":4,"dvd_mul_right":[2,4],"dvd_of_dvd_pow":4,"dvd_prod_of_mem":4,"dvd_sub":4,"dvd_tran":1,"dwell":3,"e":[0,1,2,3,4,6,7,8,9,10,11,12],"each":[0,1,2,3,4,5,6,7,8,9,10,11],"earli":9,"earlier":[1,8,9],"easi":[0,4,5,6,7,8,9,10],"easier":[0,1,3,4,5,7,9,10],"easiest":[2,4],"easili":[1,4,6,7,8,9],"ebner":0,"eccentr":9,"edg":5,"edit":0,"editor":[0,1],"ediv_lt_of_lt_mul":6,"ediv_mul_l":6,"ef":2,"effect":[1,3,5,7,10],"effici":[6,8,9,10],"effort":[1,4,5],"eg":2,"eigenspac":9,"eigenspace_def":9,"eigenvalu":9,"eigenvector":9,"eight":10,"either":[1,2,3,5,6,7,9,10],"elabor":[4,9,10],"ele1":2,"eleg":[5,6],"element":[1,2,3,4,5,6,7,8,9,10,11,12],"elementari":[0,3,6,8,9,10,14],"elim":2,"elim_finite_subcov":10,"elimin":1,"els":[2,3,4,5,9],"em":[2,3],"emanuel":0,"emb":6,"embark":7,"embed":8,"embodi":8,"emetricspac":10,"emod_lt_ab":6,"emod_lt_of_po":6,"emod_nonneg":6,"emphas":[7,8],"emphasi":[0,7],"empti":[3,4,5,6,8,10,12],"enabl":[2,3,4,6],"enat":4,"encapsul":[3,6,11],"encod":[8,12],"encount":[4,7],"encourag":[0,1,2,3,4,6],"end":[1,2,3,4,5,6,7,8,9,10,11],"endomorph":[8,14],"endow":[7,8,9],"enforc":8,"engin":4,"enjoi":[2,3,4,10],"ennreal":12,"enough":[0,1,2,3,4,7,8,9,10],"ensur":[7,8,9,10],"enter":[0,1,2,3,5,8,10],"enthusiast":0,"entir":[1,3,6,10,11],"entourag":10,"entri":[0,6,8,9],"enumer":[1,2,5],"epo":2,"eq":[1,6],"eq1":4,"eq2":4,"eq_bot":9,"eq_bot_iff":9,"eq_bot_iff_card":8,"eq_bot_iff_foral":8,"eq_div_of_mul_eq_right":5,"eq_empty_or_nonempti":10,"eq_neg_of_add_eq_zero":1,"eq_of_dvd_of_prim":4,"eq_of_mul_eq_mul_right":8,"eq_one_or_self_of_dvd":4,"eq_top_iff":8,"eq_two_or_odd":3,"eq_univ":3,"eq_univ_of_foral":3,"eq_zero_iff_mem":8,"eq_zero_of_pow_eq_zero":[2,4],"eq_zero_or_eq_zero_of_mul_eq_zero":2,"equal":[1,2,3,4,5,6,7,8,9,10,12],"equat":[1,2,3,4,6],"equilater":6,"equip":[1,3,5,6,7,8,10,11,12],"equiv":[6,8,9],"equival":[1,2,3,4,5,6,8,9,10,11,12],"eras":[4,5],"erase_insert":5,"eric":0,"error":[1,2,3,7],"erw":[2,4],"especi":[1,2,5,6,7,8,9,10],"essenti":[2,3,6,8,10],"establish":[0,1,2,3,4,5,6],"etc":[9,10],"euclidean":6,"euclideandomain":6,"eval":[0,4,5,8,9],"eval_eq_ev":5,"evalu":[4,5,8,9],"eval\u2082":8,"even":[0,1,2,3,4,5,6,7,9,10,11,12],"even_of_even_sqr":4,"eventu":[2,3,10],"eventually_eventually_nhd":10,"eventually_left_invers":11,"eventually_right_invers":11,"eventuallyeq":10,"ever":[0,10],"everi":[0,1,2,3,4,5,6,7,8,9,10,11,12],"everyth":[1,2,7,10],"everywher":[2,3,7,9,10,12],"evid":6,"evolv":1,"ex":[0,2],"ex_finset_of_bound":4,"exact":[1,2,3,4,5,6,8,9,10,11],"exactli":[1,2,3,5,6,7,8,10],"exampl":[0,2,3,4,5,6,7,8,9,10,11,12,14],"example1":5,"except":[1,2,6,7,8,9],"exclam":10,"exclud":[2,4],"exercis":[0,1,2,3,4,5,6,7,8,9,10,11],"exfalso":2,"exhibit":[2,10],"exist":[1,2,3,4,5,7,8,9,10],"existenti":[3,8,14],"exists_abs_le_of_convergesto":2,"exists_deriv_eq_slop":11,"exists_deriv_eq_zero":11,"exists_haseigenvector":9,"exists_infinite_prim":3,"exists_ismaxon":10,"exists_isminon":10,"exists_lt_card_fiber_of_mul_lt_card_of_maps_to":5,"exists_one_lt_norm":11,"exists_prime_and_dvd":3,"exists_prime_factor":4,"exists_prime_factor_mod_4_eq_3":4,"exists_subgroup_card_pow_prim":8,"exot":[8,10],"exp":[1,3],"exp_le_exp":1,"exp_log":3,"exp_lt_exp":1,"exp_po":[1,3],"expand":[1,2,3,4,6,7,9],"expect":[1,2,3,4,5,6,7,8,9,10],"experi":[0,1,10],"explain":[1,2,3,4,5,6,7,8,9,10,12],"explan":[0,8,9,10],"explicit":[1,2,4,6,7,9,10],"explicitli":[1,2,3,4,5,6,7,8,9,10,11],"explor":[4,9,10],"expon":1,"exponenti":4,"export":7,"expos":[2,10],"express":[0,1,2,3,4,5,6,7,8,9,10,11,12],"ext":[2,3,4,5,6,7,8,9],"ext_iff":6,"extend":[1,3,4,5,6,7,10,12],"extens":[0,1,5,7,10,11],"extension":[3,6],"extern":9,"extra":[1,2,3,5,6,7,8,10],"extract":[2,10],"extrem":[0,7,10],"f":[0,1,2,3,4,5,6,7,8,9,10,11,12],"f_":10,"f_cont":10,"f_le":10,"f_ne":10,"fac":4,"fac_po":4,"face":[6,7,10],"facilit":[2,9,10],"fact":[0,2,3,4,5,6,7,8,9,10,11,12,14],"factor":[4,6,8,9],"factori":4,"factorial_po":4,"factorization_mul":4,"factorization_pow":4,"fail":[1,2,4,6,7,9,10,12],"failur":7,"fair":5,"fairli":2,"fals":[1,2,3,4,5,7],"falso":2,"famili":[8,9,10,11],"familiar":[0,1,4,6,9,10,11],"famou":[3,8],"far":[2,3,7,9,10],"favor":[1,6],"fderiv":11,"fear":7,"feat":4,"featur":[0,2,4,8],"feed":8,"feedback":0,"feel":[0,1,2,7,9,10],"fermatlasttheorem":0,"fetch":0,"few":[1,2,3,4,10],"fib":4,"fib_add":4,"fib_add_two":4,"fib_coprime_fib_succ":4,"fib_eq":4,"fibonacci":4,"field":[0,1,6,7,8,9,11],"field_simp":[2,6],"figur":[0,1,2,4,6],"file":[0,1,4,6,7,8,10],"filippo":0,"fill":[2,3,4,5,6],"filter":[4,5,11,12,14],"filter_upward":10,"filteri":10,"fin":[5,6,8,9,12],"fin_cas":9,"final":[1,2,3,6,8,9,10,12],"finaliso":8,"find":[0,1,2,4,6,7,8,9,10],"fine":9,"finicki":1,"finish":[1,2,3,4,5,8],"finit":[1,3,4,5,6,8,9,10,11,12],"finitedimension":[9,11,12],"finitedimensional_of_finit":9,"finrank":9,"finrank_eq_rank":9,"finrank_fin_fun":9,"finrank_l":9,"finrank_pos_iff":9,"finrank_real_complex":9,"finrank_self":9,"finrank_sup_add_finrank_inf_eq":9,"finset":[4,6,8,9,10,14],"finsupp":9,"fintyp":[8,9,10,14],"fintypebasisindex":9,"first":[0,1,2,3,4,5,6,7,8,9,10,11,12],"firstcountabletopologi":10,"fix":[4,7,8,9,10],"fl":5,"flag":[2,3],"flavor":9,"flexibl":[4,5,10],"flip":5,"flori":0,"fn_ub_add":2,"fneven":2,"fnhaslb":2,"fnhasub":2,"fnlb":2,"fnodd":2,"fnub":2,"fnub_add":2,"fnuba":2,"focu":[0,1,8,9,10,12],"focus":10,"fold":5,"folder":0,"follow":[0,1,2,3,4,5,6,7,8,9,10,11,12],"font":8,"foo":[1,6],"foral":0,"forc":[1,2,3,8,9],"foreshadow":1,"forewarn":0,"forget":7,"form":[0,1,2,3,4,5,6,7,8,9,10,12],"formal":[0,1,2,3,4,5,6,7,8,9,10,11],"format":1,"former":6,"formul":[4,8,10],"formula":[4,5,8,12],"forth":6,"fortiori":10,"fortun":3,"forward":[1,2,5,6,8,10],"found":[1,4,5,6,8,9,11],"foundat":[2,3,4,5,6,8,9],"four":[2,6],"fourth":2,"frac":6,"fraction":4,"fraenkel":2,"framework":[0,9],"frasa":0,"free":[0,1,8,9,10],"freegroup":8,"freeli":4,"frequent":10,"friend":[2,6],"friendli":8,"from":[0,1,2,3,4,5,6,7,8,9,10,11,12],"front":[2,4,5],"frustrat":[0,7],"fr\u00e9chet":11,"fst":[6,9,10],"fubini":12,"full":[1,2,3,4,5,6,7,8,9,10],"fulli":[3,8,9,10],"fun":[0,2,3,4,5,6,7,8,9,10,11,12],"function":[1,2,4,5,6,7,8,9,11,12,14],"functori":10,"fundament":[0,4,6,7,12],"funni":10,"further":[1,10],"furthermor":8,"g":[1,2,3,5,6,7,8,9,10,11,12],"g_":10,"g_1":6,"g_2":6,"g_3":6,"gabriel":0,"gadget":[2,10],"gain":7,"galoi":[3,6,9,10],"galoisinsert":9,"game":[0,7],"gauss":8,"gaussian":[2,8,14],"gaussianint":6,"gaussint":6,"gave":[8,10],"gcd":[1,2,4],"gcd_zero_left":1,"gcd_zero_right":1,"gcongr":[5,6],"ge":[0,2,6],"gener":[1,2,3,4,5,6,7,8,9,10,11,12],"genuin":2,"geometr":10,"geometri":8,"get":[1,2,3,4,5,7,8,9,10,11,14],"gi":9,"gin":0,"giovanni":0,"git":0,"github":[0,1],"give":[1,2,3,4,5,7,8,9,10,12],"given":[0,1,2,3,4,5,6,7,8,9,10],"glb":1,"global":[8,10],"go":[0,1,2,3,4,7,9,10],"goal":[0,1,2,3,4,6,9,10],"goe":[3,4,6,7,10],"golden":4,"good":[1,2,3,4,5,6,7,8,9,10],"gorbachev":0,"got":7,"govern":[1,6],"gradual":[7,10],"graph":[5,6,9],"grate":[0,6],"great":[1,6],"greater":[0,1,2,3,4,10],"greatest":[1,6,10],"greef":0,"greek":[1,4],"grinberg":0,"grind":4,"group":[0,1,2,3,4,6,7,9,10,11,14],"groupact":8,"groupequivquotientprodsubgroup":8,"group\u2081":[6,7],"group\u2082":6,"group\u2083":7,"grow":[0,7,8],"grp":6,"grp\u2081":6,"guai":0,"guarante":[0,3,5,6,9],"guess":[1,2,3,4,6,9],"guilherm":0,"gya":3,"g\u2080":8,"g\u2081":8,"g\u2082":8,"h":[1,2,3,4,5,6,7,8,9,10,11,12],"h0":4,"h1":[1,2,3,4,6],"h2":[1,2,3,6],"h3":1,"h_def":3,"h_inj":12,"h_left":5,"h_right":5,"ha":[0,1,2,3,4,5,6,7,8,9,10,11,12],"hab":11,"habit":[7,9],"hac":7,"hack":3,"had":[1,7,9],"hal":7,"half":[3,8],"halv":5,"hamilton":9,"hand":[1,2,3,4,5,6,7,9,10],"handi":4,"handl":[1,3,4,5,7,8],"hanson":0,"happen":[1,7,10],"happi":0,"hard":[0,1,3,6,7,8],"harder":[2,9],"harm":3,"hasbasi":10,"hasderivat":[11,12],"hasderivat_sin":11,"haseigenvalu":9,"haseigenvalue_iff_isroot":9,"haseigenvalue_of_haseigenvector":9,"haseigenvector":9,"hasfderivat":11,"hasfderivat_iff_islittleo":11,"hasfderivatfilt":11,"hasfderivwithinat":[11,12],"haskel":1,"hasquoti":7,"hasstrictfderivat":11,"hausdorff":10,"have":[0,1,2,3,4,5,6,7,8,9,10,11,12],"havei":9,"haven":[0,2,7,10],"hb":[2,10],"hba":7,"hball":10,"hbound":12,"hc":11,"hd":10,"hdi":12,"hdvd":8,"he":8,"headach":4,"headi":6,"heart":[4,8],"heather":6,"heaven":6,"heavier":7,"heavili":10,"hello":0,"help":[0,1,2,3,4,6,7,9,10],"helper":1,"henc":[0,2,3,4,5,6,7,9,10,11],"here":[0,1,2,3,4,5,6,7,8,9,10,11,12],"hesit":4,"heurter":0,"hf":[3,8,10,11,12],"hfa":2,"hfc":11,"hff":11,"hfi":11,"hfx":10,"hg":[3,10,11,12],"hgb":2,"hi":8,"hidden":2,"hide":[7,8,10],"hierarchi":[6,8,9,14],"high":[2,8],"higher":7,"highlight":[0,2],"hij":9,"hint":[0,1,2,12],"histor":[1,8],"hit":[0,1],"hk":[0,11],"hle":10,"hlim":12,"hm":11,"hmea":12,"hmn":0,"hmp":11,"hn":[3,4,10,11],"hna":2,"hnb":2,"hne":10,"ho":10,"hold":[1,2,3,4,5,6,8,9,10,12],"home":[4,6],"homomorph":8,"hood":[3,6,9],"hope":[0,1,9],"hopelessli":7,"hoskinson":0,"hover":[0,1,2,3,4,6],"how":[0,1,2,3,4,5,6,7,8,9,10,12],"howev":[1,2,5,6,7,8,9,10,11],"hp":[5,8,10],"hp1":5,"hp2":5,"hp3":5,"hpo":10,"hq":[8,10],"hr":10,"hst":8,"hsu":10,"ht":[2,5],"html":0,"http":7,"hu":[10,11],"huge":7,"huisinga":0,"hum":10,"human":1,"hunt":[7,9],"hunter":0,"huo":10,"hurdl":7,"hurt":2,"hux":10,"hv":9,"hw":7,"hx":[2,3,6,7,8,9,11],"hxeq":3,"hy":[6,7,8,9],"hyp":1,"hypothes":[1,2,3,4,6],"hypothesi":[0,1,2,3,4,9],"hz":[6,7],"h\u03b5":11,"h\u03c6":9,"h\u2080":[1,2,3,4,10],"h\u2081":[1,2,3,4],"h\u2082":[1,3,4],"h\u2083":[1,3],"i":[0,1,2,3,4,5,6,7,8,9,10,11,12],"i1":5,"i2":5,"icc":[10,11],"ici":10,"id":[4,7,9,10,11],"id_comp":9,"idea":[1,2,3,4,6,7,9,10],"ideal":9,"ident":[3,4,5,6,7,8,9,10,14],"identif":9,"identifi":[1,2,4,9],"iff":[1,3,8,9,10,11,12,14],"ignor":[0,1,6,7,8,9,10],"ih":[4,5],"iinf_insert":8,"iinter":12,"il":4,"illustr":[1,2,3,4,6,8],"im":6,"imag":[3,4,5,7,8,9,10],"image_subset_iff":3,"imagin":1,"imaginari":6,"immedi":[2,3,6,7,9],"impl":5,"implement":[2,4,5,6,7,8,9,11],"impli":[1,2,3,4,6,9,10],"implic":[1,9,10,14],"implicit":[1,2,5,6,7,8,9,10,11],"implicitli":[1,2],"import":[1,2,3,4,5,6,7,8,9,10,12],"importantli":[7,8,9],"imposs":1,"impress":0,"improv":[3,4],"inaccess":2,"incl":10,"includ":[0,1,2,3,4,5,7,8,9,10,11],"inclus":[1,3,8,9,10],"inconsist":[1,9],"inconveni":11,"incorpor":7,"increas":1,"increment":[0,1],"inde":[1,6,7,8,9,10,11],"indefinit":4,"indent":1,"independ":[2,3,5,6,9],"indetermin":8,"index":[3,5,7,8,9,10],"index_eq_card":8,"index_mul_card":8,"indic":[1,2,3,6,7],"indirect":7,"indirectli":1,"individu":1,"induc":10,"induced_compos":10,"induct":[8,9,10,14],"induction_on":[4,5],"ineffici":4,"inequ":[1,2,5,7,10],"inf":[1,5,7,10],"inf_assoc":1,"inf_bot_of_coprim":8,"inf_comm":[1,8],"inf_eq_bot":9,"inf_le_left":[1,10],"inf_le_right":1,"inf_of_le_right":10,"inf_sup_left":1,"inf_sup_right":1,"inf_sup_self":1,"infer":[1,2,3,5,6,7,8,9],"infer_inst":[11,12],"inferenti":0,"inferinst":[8,9],"inferr":7,"infimum":[1,7,8,9,10,12],"infin":[4,10,12],"infinit":[3,5,9,10,14],"infix":[1,7],"infixl":7,"infixr":7,"inform":[0,1,2,3,4,5,6,7,9,10],"infoview":[0,1,2,7],"infrastructur":0,"infti":11,"ingredi":[3,6,10,11],"inhabit":[3,6,10],"inherit":[6,7,8,9],"inherit_doc":7,"inj":4,"inject":[2,3,4,5,7,8,9,10],"injective_lift_iff":8,"injf":[2,3],"injg":2,"injon":[3,5,12],"inl":[2,3,9],"inner":3,"input":[1,3,9,10],"inr":[2,3,9],"inria":7,"inscrut":[2,3],"insert":[0,2,4,5,6,8,9,10,11],"insert_eras":5,"insid":[0,1,2,3,8],"insight":2,"insist":[1,7],"inspect":1,"inspir":2,"inst":7,"inst_1":7,"instal":[0,7],"instanc":[1,2,3,4,5,6,7,8,9,10,11],"instanti":[2,4,6,7,8,10],"instcommr":6,"instead":[0,1,2,3,4,5,6,7,8,9,10],"instruct":[0,1,2,10],"int":[5,6,7,8],"intact":0,"integ":[1,2,4,5,7,8,14],"integr":[2,11,14],"integral_add":12,"integral_eq_sub_of_hasderivat":12,"integral_hasstrictderivat_right":12,"integral_id":12,"integral_image_eq_integral_abs_det_fderiv_smul":12,"integral_one_div":12,"integral_prod":12,"intend":[0,1,2,6],"inter_def":3,"inter_set":10,"inter_union_distrib_left":5,"interact":[0,6,7,8,9,12],"interchang":1,"interconnect":6,"interest":[1,2,3,5,6,7,9,10],"interestingli":[5,6,8,11],"interfac":6,"interior":[6,11],"interior_iinter_subset":11,"interior_subset":11,"intermedi":[1,7,9,10],"intern":[2,6,8],"interpret":[0,1,4,5,6,8,9,10],"intersect":[1,3,5,6,7,8,9,10,12],"interv":[4,10,12],"interval_cas":4,"intervalintegr":12,"intro":[0,1,2,3,4,5,6,7,8,10],"introduc":[0,1,2,3,4,9,10,12],"introduct":[1,2,8,10,14],"introductori":11,"intuit":[3,10],"inv":[6,7],"inv_def":9,"inv_dia":7,"inv_eq_of_dia":7,"inv_eq_of_mul":7,"inv_mem":8,"inv_mul":7,"inv_mul_cancel":[1,6],"inv_mul_of_invert":9,"invari":12,"invers":[1,3,5,6,7,8,9,11,12],"inverse_spec":3,"invert":[7,8,9],"invertibleofisunitdet":9,"invest":6,"invfun":[3,5,6,9],"invfun_eq":3,"invisibli":[6,7],"invok":[0,1,10],"involv":[1,2,4,6,7,8,9,10],"inv\u2081":7,"inward":2,"ioo":[10,11],"ipo":4,"irrat":14,"irration":4,"irreduc":[4,6],"irreducible_iff_prim":6,"irreflex":2,"is_addit":6,"isaddhaarmeasur":12,"isaiah":0,"isalgclos":8,"isbigo_iff_isbigowith":11,"isbigowith":11,"isbigowith_iff":11,"isclos":[10,11],"isclosed_l":[10,11],"iscompact":10,"iscompact_icc":10,"iscompact_univ":10,"iscompl":9,"iscoprim":[8,9],"iscoprime_iff_add":8,"iscoprime_iff_codisjoint":8,"iscoprime_iff_exist":8,"iscoprime_iff_sup_eq":8,"iscoprime_inf":8,"iscycl":8,"isdenseinduc":10,"isdomain":[2,8],"iseqv":7,"isintern":9,"isinternal_submodule_iff_isupindep_and_isup_eq_top":9,"islinear":6,"islittleo_iff_forall_isbigowith":11,"islocalmin":11,"ismonoidhom\u2081":7,"ismonoidhom\u2082":7,"isn":[0,2,3,4,7],"isomorph":[6,8,9,11],"isopen":10,"isopen_compl_iff":10,"isopen_empti":10,"isopen_iff":10,"isopen_iinter_of_finit":10,"isopen_iunion":10,"isopen_univ":10,"isorderedcanceladdmonoid":2,"iso\u2081":8,"iso\u2082":8,"isroot":[8,9],"isroot_of_haseigenvalu":9,"isstrictorderedr":[1,6],"issu":[1,4,6,7,9,10],"issubgroup":8,"issubmodul":9,"isunit":8,"ite_eq_left":3,"ite_eq_right":3,"item":10,"iter":11,"iteratedfderiv":11,"its":[0,1,2,3,4,5,6,7,8,9,10,11,12],"itself":[0,2,3,6,7,8,9,10,11],"iunion":12,"j":[3,5,8,9],"jimmi":0,"job":1,"johan":0,"john":0,"join":[0,1,6],"jone":0,"joseph":0,"journei":10,"juggl":7,"julian":0,"jump":[1,4,5,6,10],"just":[0,1,2,3,4,5,6,7,8,9,10],"justif":[1,2,5],"justifi":[0,1,2,10],"k":[0,2,4,5,6,8,9,10,11],"kabelo":0,"keep":[1,3,6,7,8],"kei":[1,4,6,8,9,10],"keith":0,"ker":[8,9],"ker_domrestrict":8,"ker_eq_bot":9,"ker_eq_bot_iff":8,"ker_le_ker_comp":9,"ker_mkq":9,"ker_pi_quotient_mk":8,"kernel":[8,9],"keyboard":1,"keyword":[1,2,4,6],"kim":0,"kind":[0,1,7,9,10],"knew":10,"know":[0,1,2,3,4,5,6,7,8,9,10,11],"known":[0,1,2,3,4,6,7,8,9,10,11],"k\u00fclshammer":0,"l":[0,1,5,9,11,12],"label":[1,2],"lagrang":8,"lake":0,"lambda":[2,6],"lambda_l":6,"lambda_nonneg":6,"languag":[0,1,2,3],"larg":[0,7,10],"larger":[1,10],"last":[1,2,3,4,5,6,7,8,10],"later":[0,1,2,4,6,7,8,9,10],"latter":[6,8,10],"lattic":[1,5,6,7,8,10],"law":[1,8],"layer":[7,10],"lbf":2,"lbg":2,"lcm":1,"lcm_zero_left":1,"lcm_zero_right":1,"ldot":[2,3,4,5],"le":[1,6,7],"le_abs_self":2,"le_antisymm":[1,2],"le_def":7,"le_iff_exists_add":10,"le_inf":1,"le_inf_iff":10,"le_min":1,"le_mul_of_one_le_right":6,"le_of_dvd":4,"le_of_l":7,"le_of_max_le_left":2,"le_of_max_le_right":2,"le_of_mul_le_mul_right":6,"le_of_not_gt":2,"le_opnorm":11,"le_or_gt":2,"le_principal_iff":10,"le_refl":[1,2],"le_sup":4,"le_sup_left":1,"le_sup_right":1,"le_tran":[1,2],"lead":[1,2,4,6,7,8,9,10],"leader":1,"lean":[0,1,2,3,4,5,6,7,8,9,10,11],"lean4":1,"learn":[0,1,4,6],"least":[1,5,6,7,9,10],"leav":[0,1,2,3,5,6,7,8],"lebesgu":12,"led":7,"left":[0,1,2,3,4,5,6,7,8,9,10,11,12],"left_distrib":[6,7],"left_inv":[5,6,9],"left_inv_eq_right_inv":7,"left_inv_eq_right_inv\u2081":7,"left_neg_eq_right_neg":7,"leftinvers":3,"leftinverse_invfun":3,"leftrightarrow":5,"legal":1,"lemma":[2,3,4,5,6,7,8,9,10,11,12,14],"less":[1,2,3,4,6,7,8,9,10],"let":[0,1,2,3,4,5,6,7,8,9,10,11,12],"leti":9,"letter":[1,6,11],"level":[1,2,7,9],"leverag":10,"le\u2081":7,"librari":[0,1,2,3,4,5,6,8,10,11],"life":[0,2],"lift":[8,9],"liftq":9,"light":6,"like":[0,1,2,3,4,5,6,7,8,9,10],"lim_":10,"limit":[2,7,10],"linarith":[1,2,4,5,6],"line":[0,1,2,3,4,5,7,8,9],"linear":[1,2,4,5,6,8,10,14],"linear_combin":8,"linearcombin":9,"linearcombination_apply_of_mem_support":9,"linearcombination_repr":9,"linearequiv":9,"linearequivfunonfintyp":9,"linearindepend":9,"linearli":9,"linearmap":9,"linearord":[2,6],"liner":0,"linf":6,"link":[6,7],"linter":2,"list":[1,2,3,4,5,6,9],"literatur":5,"littl":[1,2,10,11],"liu":0,"live":[0,6,9],"ll":[0,2,4,7,10],"local":[1,2,7,10,11],"localinvers":11,"lof":9,"log":[1,3,12],"log_le_log":1,"log_lt_log":1,"logic":[0,1,3,4,5,6,8,9,14],"logician":1,"long":[1,2,3,4,6,7,8,9,11],"longer":[0,4,6],"loogl":1,"look":[1,2,3,4,7,8,9,10],"loop":4,"lose":9,"loss":4,"lot":[0,1,3,4,6,7,8,9,10],"loud":1,"lower":[1,2,4],"lowest":4,"lr":1,"lsmul":9,"lt_ab":2,"lt_asymm":2,"lt_iff_le_and_n":1,"lt_iff_le_not_g":2,"lt_irrefl":[1,2],"lt_of_le_of_lt":[1,2],"lt_of_lt_of_l":1,"lt_of_not_g":2,"lt_succ_of_l":4,"lt_tran":[1,2],"lt_trichotomi":2,"lt\u2081":7,"lu":0,"lub":1,"m":[0,1,2,4,5,7,8,9,10,11],"m_iunion":12,"macbeth":6,"machin":9,"machineri":[6,7,9,10],"maco":0,"made":[1,2,3,6,9,10],"magic":[2,4,6,7],"mai":[0,1,2,3,5,6,7,8,9,10,11],"main":[2,7,9,10,11],"mainli":8,"maintain":1,"make":[0,1,2,3,4,5,6,7,8,9,10,11],"manag":[0,1,4,6,10],"mani":[1,2,3,5,6,7,8,9,10,11,12,14],"manifest":[1,10],"manipul":[2,6,8,9,10],"manner":[2,6],"manual":[0,3,4,9],"map":[1,2,3,4,5,6,7,8,10,14],"map_add":[7,8,9,11],"map_comap_eq":9,"map_con":5,"map_eq":10,"map_inv":8,"map_inv_of_inv":7,"map_le_iff_le_comap":10,"map_map":[5,10],"map_mono":10,"map_mul":[7,8,9],"map_nil":5,"map_on":[7,8],"map_pow":8,"map_princip":10,"map_smul":[9,11],"map_zero":[7,8],"mapq":9,"mapsto":[1,6],"map\u2082":7,"marc":0,"mario":0,"mark":[0,1,2,4,5,7,10],"marker":2,"marriag":6,"martin":0,"mascellani":0,"mass":12,"master":[0,1,4],"match":[1,2,4,6],"mathbb":[3,4,6,8],"mathcal":[6,11],"mathemat":[0,1,2,3,4,6,7,8,9,10],"mathematician":[4,5,10],"mathematics_in_lean":0,"mathfrak":8,"mathieu":0,"mathlib":[0,1,2,3,4,5,6,7,8,9,10,11,12],"matric":[1,6,8,14],"matrix":9,"matter":[1,2,5],"matthew":0,"mauricio":0,"max":[1,2,5,7,9,10,12],"maxim":8,"maximum":[2,4,5,10],"mayb":7,"mcdowel":0,"mckinsei":0,"mdvdn":4,"mean":[1,2,3,4,5,6,7,8,9,10,11,12],"meaning":9,"meaningless":2,"meant":[0,2,7,9],"meanwhil":[1,4],"measur":[0,4,6,10,11,14],"measurableset":12,"measurablespac":12,"measure_eq_iinf":12,"measure_iunion_l":12,"measuretheori":12,"mechan":[1,2,4,6],"mediat":4,"medit":9,"meet":[1,2,3,6],"mehta":[0,5],"mem":[3,9],"mem_":4,"mem_ball_self":10,"mem_biunion":5,"mem_bot":[8,9],"mem_closedball_self":10,"mem_closure_iff":10,"mem_closure_iff_clusterpt":10,"mem_closure_iff_nhds_basi":10,"mem_closure_iff_seq_limit":10,"mem_closure_of_tendsto":10,"mem_comap":[8,9],"mem_diff":3,"mem_eras":4,"mem_filt":[4,5],"mem_iff":10,"mem_iint":3,"mem_iinter\u2082":3,"mem_imag":5,"mem_image_of_mem":3,"mem_inf":9,"mem_insert":4,"mem_insert_of_mem":[5,8],"mem_insert_self":[5,8],"mem_int":[4,5],"mem_inter_iff":3,"mem_iunion":3,"mem_iunion\u2082":3,"mem_ker":[8,9],"mem_map":[8,9],"mem_map_of_mem":9,"mem_nhds_iff":10,"mem_of_dvd_prod_prim":4,"mem_of_tendsto":10,"mem_ofpr":3,"mem_preimag":9,"mem_product":5,"mem_rang":[5,8],"mem_sdiff":[3,4],"mem_sup":[8,9],"mem_tolist":5,"mem_union":[3,4,5],"mem_univ":5,"member":[3,10],"membership":[3,4,7,8,9],"mention":[2,3,6,7,8,10],"menu":[0,1],"meq":4,"messag":7,"messi":6,"meta":[2,7],"metavari":7,"method":[0,2,3,4,6],"metric":[1,6,11,14],"metricspac":[1,10,11],"mf":2,"mg":2,"mge2":4,"mgt2":4,"mid":6,"middl":[0,1,2,10],"midpoint":6,"miel":0,"might":[1,2,3,4,6,8],"mil":0,"min":[1,2,5,7,10,12],"min_le_left":1,"min_le_right":1,"mind":[1,2,6,7,8],"mindich":0,"minfac":4,"minim":9,"minimum":[5,10],"minor":[7,11],"minpoli":9,"mirror":4,"mislead":8,"miss":[1,3,4],"mission":0,"mk":[6,7,8,9,10],"mk_appli":9,"mk_eq_mk_of_basi":9,"mk_surject":8,"mkofmuleqon":8,"mkofnhd":10,"mkq":9,"mltn":4,"mne1":4,"mnez":4,"mod":6,"mod_4_eq_3_or_mod_4_eq_3":4,"mod_def":6,"mod_lt":4,"mode":[1,2,6],"model":[3,9,10],"modern":[6,8],"modifi":7,"modu":1,"modul":[1,7,8,9],"modular":1,"module\u2081":7,"module\u2083":7,"modulo":[1,4,6],"moiloa":0,"moment":[1,2,6],"mono":10,"monof":2,"monoid":[2,3,4,7,9,14],"monoidhom":8,"monoidhomclass":7,"monoidhomclass\u2081":7,"monoidhomclass\u2082":7,"monoidhomclass\u2083":7,"monoidhom\u2081":7,"monoid\u2081":7,"monoid\u2082":7,"monoid\u2083":7,"monoton":[2,7,10],"monro":0,"monticon":0,"moral":[0,6,8],"more":[0,2,3,5,6,7,8,9,10,11,14],"moreov":[0,1,4,5,6,10],"morphism":[6,9,11,14],"morrison":0,"most":[1,2,3,4,5,6,7,8,9,10,12],"mostli":8,"motiv":[2,9],"move":[0,1,2,5,7,9,10],"mp":[1,2,3,4,10],"mpr":[1,2,6,10],"much":[0,2,4,7,8,9,10,11],"mul":[4,6,7,10],"mul_add":[0,1,4,7],"mul_appli":9,"mul_assoc":[1,2,4,6,7,8],"mul_assoc\u2083":7,"mul_comm":[1,2,4,5,6,7,8],"mul_def":6,"mul_div_cancel":4,"mul_div_cancel\u2080":2,"mul_ediv_add_emod":6,"mul_eq_comp":9,"mul_im":6,"mul_inv":[7,8],"mul_inv_cancel":[1,6,8],"mul_inv_cancel_right":6,"mul_inv_rev":1,"mul_le_inf":8,"mul_le_left":8,"mul_le_mul":2,"mul_le_right":8,"mul_left_cancel\u2083":7,"mul_left_comm":4,"mul_left_not_lt":6,"mul_lt_mul_iff_left\u2080":2,"mul_lt_mul_of_pos_right":2,"mul_mem":[7,8],"mul_mod":4,"mul_mod_mod":4,"mul_mod_right":4,"mul_ne_zero":5,"mul_nonneg":1,"mul_on":[1,6,7,8],"mul_po":[1,4],"mul_r":6,"mul_right_cancel\u2083":7,"mul_right_inj":4,"mul_smul":[7,8],"mul_sub":1,"mul_sum":6,"mul_zero":[1,6,7],"mulact":8,"mulequiv":8,"muloneclass":7,"multilinear":11,"multipl":[1,2,3,4,5,6,7,8,9,11],"multipli":[6,9],"multiset":8,"multivari":8,"mulvec":9,"mulzeroclass":7,"mundan":2,"must":[1,5,6,7,9,10],"mutandi":6,"mutati":6,"mvpolynomi":8,"my_fil":0,"my_lemma":2,"my_lemma2":2,"my_lemma3":2,"my_lemma4":2,"my_squar":6,"myab":2,"myelement":8,"mygroup":8,"mylistspac":5,"mylistspace3":5,"mymap":8,"mymorph":8,"mynat":4,"mynewmorph":8,"mypoint1":6,"mypoint2":6,"mypoint3":6,"mypoint4":6,"myre":1,"mysmul":7,"mysquar":6,"mysteri":[1,6],"mz":4,"m\u02e3":8,"n":[0,1,2,3,4,5,6,7,8,9,10,11,12],"n_p":10,"n_q":10,"na":2,"naiv":[7,10],"name":[1,2,3,4,5,6,7,8,9,10,11],"namespac":[1,2,3,4,5,6,8,9,10],"nash":0,"nat":[0,1,2,3,4,5,6,8,10],"natab":6,"natabs_mul":6,"natabs_norm_mod_lt":6,"natabs_of_nonneg":6,"natal":0,"natcast_natab":6,"natdegre":8,"natdegree_comp":8,"natdegree_mul":8,"natur":[0,1,2,3,4,5,6,7,8,9,10,11],"nb":2,"ne":[4,6,11],"ne_one_iff_exists_prime_dvd":4,"nearbi":[1,4],"nearest":6,"nebot":10,"nebot_of_l":10,"necessari":[0,2,4,6,8,9],"necessarili":[1,9,12],"need":[0,1,2,3,4,5,6,7,8,9,10],"neg":[5,6,7,10,12],"neg_add":7,"neg_add_cancel":[1,6],"neg_add_cancel_left":1,"neg_def":6,"neg_eq_of_add_eq_zero":1,"neg_im":6,"neg_le_ab":2,"neg_mem":8,"neg_neg":1,"neg_r":6,"neg_zero":1,"negat":[1,6,9,14],"negsucc":7,"neighborhood":10,"neither":[3,6,7,9],"neq":4,"nest":[1,2],"net":1,"neutral":[7,8],"never":[0,7],"new":[0,1,2,3,4,5,6,7,8,9,10],"newcom":0,"next":[0,1,2,3,4,5,6,7,8,9,10,11],"nge":2,"nhd":10,"nhds_basis_bal":10,"nhds_basis_closedbal":10,"nhds_basis_ioo_po":10,"nhds_basis_open":10,"nhds_induc":10,"nhds_mkofnhd":10,"nhds_prod_eq":10,"nice":[1,2,4,7,8,9,10],"nicer":[6,8,10],"nicola":0,"nil":5,"nil_append":5,"nineteenth":3,"nna":2,"nnc":2,"nnez":4,"nnf":2,"nng":2,"nnz":4,"node":5,"non":[1,3,5,7,8,9,10,12],"noncomm_r":1,"noncomput":[3,4,5,6,8,9],"nonconstruct":8,"nondecreas":[2,4],"nondistribut":1,"nonempti":[3,5,8,10],"nonempty_interior_of_iunion_of_clos":11,"nonexist":2,"nonneg":[1,6],"nontrivi":[2,3,4,6,9,10,11],"nontriviallynormedfield":[11,12],"nonzero":[2,4,6,12],"nor":[3,6,9],"norm":[2,6,10,14],"norm_add_l":11,"norm_conj":6,"norm_eq_zero":[6,11],"norm_mod_lt":6,"norm_mul":[6,11],"norm_nonneg":[6,11],"norm_num":[1,2,4,5,6,9],"norm_po":6,"norm_smul":11,"norm_y_po":6,"normal":8,"normedaddcommgroup":[11,12],"normedaddgroup":11,"normedfield":11,"normedgroup":11,"normedspac":[11,12],"not_even_iff":3,"not_even_iff_odd":3,"not_false_iff":4,"not_imp_self":3,"not_le_of_gt":2,"not_lt_of_g":[2,4,6],"not_monotone_iff":2,"not_norm_mul_left_lt_norm":6,"not_not":2,"not_prime_iff_exists_dvd_lt":4,"not_prime_on":4,"notat":[1,2,3,4,5,6,7,8,9,10,11,12],"note":[1,2,3,4,5,6,7,8,9,10,12],"noth":[1,2,3,4,5,6,7,8],"notic":[1,2,3,4,5,6,8,10],"notin":3,"notion":[1,2,3,4,6,8,9,10,11,12],"noun":7,"now":[0,1,2,3,4,5,6,7,8,9,10,11,12],"nozerodivisor":8,"np":4,"npow_nz":4,"npowz":4,"nsmul":[6,7],"nsmul_succ":7,"nsmul_zero":7,"nsmulrec":6,"nsmul\u2081":7,"nsqr_nez":4,"nt":2,"nth":4,"nth_rw":1,"nuccio":0,"number":[0,1,2,3,5,6,7,8,9,10,11,14],"numer":[1,4,6],"nut":1,"n\u2080":2,"n\u2081":2,"o":11,"obfusc":10,"object":[0,1,2,3,4,5,6,8,9,14],"observ":[2,4,10],"obtain":[1,2,4,6,10,11],"obviou":[0,4,6,7],"occasion":10,"occur":[4,5],"occurr":[1,5],"odd":[1,2,3,4,9],"odd_iff":3,"of_foral":10,"of_le_succ":4,"of_map":10,"ofbiject":[8,9],"off":[2,3,4],"offend":7,"offer":[0,2,5,6,10],"ofnat":7,"ofnat_l":6,"ofnat_lt":6,"ofrealhom":8,"ofsetlik":7,"often":[0,1,2,3,4,5,6,7,8,9,10],"og":2,"old":[2,6,7,9],"oliv":0,"omega":[4,5],"omit":6,"onc":[1,2,3,4,6,7,8,10,12],"one":[0,1,2,3,4,5,6,7,8,9,10,11,12],"one_add_one_eq_two":1,"one_def":6,"one_dia":7,"one_eq_top":8,"one_fin_two":9,"one_im":6,"one_lt_card":5,"one_mem":[7,8],"one_mul":[1,2,6,7],"one_r":6,"one_smul":[7,8],"oner":1,"ones":[0,1,2,3,5,6,9,11,12],"one\u2081":7,"one\u2082":7,"onli":[0,1,2,3,4,5,6,7,8,9,10,11,12],"onlin":0,"onto":[8,9],"open":[0,1,2,3,4,5,6,8,9,11,12],"oper":[1,2,3,4,5,6,7,8,9,10,11],"opnorm_le_bound":11,"opnorm_le_of_shel":11,"opportun":[8,10],"opposit":[7,10],"optim":[7,9,12],"option":[1,2,4,6,7,10],"or_comm":5,"or_left_comm":5,"orbit":8,"orbitequivquotientstabil":8,"orbitrel":8,"order":[1,2,3,4,5,6,7,9,10,11],"orderedcommmonoid\u2081":7,"orderpreshom":7,"orderpreshomclass":7,"orderpresmonoidhom":7,"ordinari":[1,2,4,5,6,8,9,10],"ordinarili":[4,6],"organ":0,"organiz":1,"orient":6,"origin":[0,1,4,6,8],"other":[0,1,2,3,4,5,6,7,8,9,10],"otherwis":[1,2,3,4,6,8],"ott":0,"our":[0,1,2,3,4,6,7,8,9,10,12],"ourselv":[4,7],"out":[0,1,2,3,4,5,6,7,8,9,10],"outer":1,"outermost":3,"outlin":[1,2,4,10],"outparam":7,"output":[1,2,5,8],"outsid":[1,4,5,9],"over":[0,1,2,3,4,5,6,7,8,9,10,11],"overlap":[7,8],"overload":3,"overview":14,"own":[0,1,4,6,7],"p":[0,1,2,3,4,5,6,7,8,9,10,12],"p1":5,"p2":5,"p4":4,"p4eq":4,"p_1":4,"p_i":[4,10],"p_k":4,"p_n":[4,5],"p_ne_zero":8,"packag":[8,9],"page":[0,1,4],"pai":[1,2,7,8,10],"pain":8,"pair":[1,2,4,5,6,8,10],"pair_comm":5,"pairwis":[9,12],"pairwisedisjoint":9,"panel":0,"paper":[2,3,6,8,9,10,12],"paquet":0,"paradox":[9,10],"paragraph":[7,10],"parallel":9,"paramet":[4,5,6,7,11],"parent":7,"parenthes":[1,2,3,4],"pariti":0,"parity_simp":0,"pars":[1,3,8],"part":[1,2,3,4,5,6,7,9,10,12],"partial":[0,1,2,3,6,7,8,9],"partialord":[1,2,7],"partialorder\u2081":7,"particular":[1,2,6,7,8,9,10],"partit":8,"partli":[1,7,8],"pass":[1,6],"past":[0,1,8],"path":7,"patholog":10,"pattern":[1,2,3,6,7],"payoff":6,"pdf":0,"pdvd":4,"pdvdm":4,"pedro":0,"peel":2,"pen":[2,8],"peopl":[0,1],"perform":[1,2,3],"perm":[6,8],"permgroup":6,"permiss":1,"permut":[4,8],"person":0,"perspicu":2,"phenomenon":3,"phi":4,"phrase":[0,1,2,4,6,9],"pi":[8,9,10],"pick":[0,5,7],"pictur":[4,6,8],"piec":[1,4,6,7,8,10],"pierpaolo":0,"pietro":0,"pigeonhol":5,"pim":0,"pinot":8,"place":[0,1,2,6,9,10],"placehold":2,"placement":4,"plai":[1,3,4,7,8,9,10],"plan":[1,7,10],"plane":[5,10],"plausibl":3,"ple":4,"pltn":4,"pne3":4,"point":[0,1,2,3,5,6,7,8,9,10,11,12],"pointwis":[6,10,11],"polynomi":[6,9],"ponen":1,"poor":7,"pop":0,"port":0,"posit":[1,3,4,5,6,10,12],"possibl":[1,2,3,4,6,8,10],"possibli":6,"postfix":7,"pos\u2080":2,"potscrubb":0,"pow_eq":4,"pow_succ":4,"pow_two":[1,4],"pow_two_le_fac":4,"pow_two_nonneg":[1,2],"power":[0,1,3,4,6,7,9],"powerset":5,"pp":[4,5],"pq":9,"practic":[1,2,3,7,8,10],"pragmat":6,"pre":[2,9],"preal":6,"preced":[4,8],"precis":[1,3,8,9,10,11],"precondit":[5,10],"pred":4,"predecessor":4,"predic":[2,3,4,5,7,8,9,10,11],"prefer":[0,1,2,3],"prefix":[2,4,7,8],"preimag":[3,8,9,10],"preliminari":7,"prematur":7,"preorder":[2,7,10],"preorder\u2081":7,"presenc":7,"present":[1,4,5,8,10],"presentedgroup":8,"preserv":[4,5,7,9,10],"preserves_mul":6,"press":[0,9],"presuppos":0,"pretend":[7,9],"pretti":[2,4,7,8,9,10],"previou":[1,2,3,5,6,7,8,10,11,12],"previous":7,"price":10,"primari":7,"primarili":[7,8,10],"prime":[1,2,3,5,6,7,8,9,14],"prime_def_lt":4,"prime_iff":3,"prime_of_mem_primefactorslist":4,"prime_p":4,"prime_q":4,"prime_thre":4,"prime_two":4,"prime_x":3,"primefactorslist":4,"primefactorslist_uniqu":4,"primep":4,"primes_infinit":4,"primes_mod_4_eq_3_infinit":4,"primit":[2,3],"princip":10,"principl":[1,2,3,4,5,7,9,11],"print":[0,2,3,4,6,12],"priori":[7,9],"prioriti":6,"probabl":[1,6,7,10],"problem":[3,4,5,6,7,10],"proce":[4,7],"procedur":[4,7],"proceed":8,"prod":[4,8,9,10,12],"prod_":4,"prod_empti":4,"prod_insert":[4,5],"prod_map":10,"prod_mk":10,"prod_po":4,"prod_primefactorslist":4,"prod_range_succ":4,"prod_range_zero":4,"prodcongr":8,"prodequivpi":8,"prodmap":9,"prodmk":10,"produc":[1,2,8,11],"product":[2,4,5,6,7,8,10,12],"profici":4,"program":[0,1,2],"progress":[0,1,6,8],"prohibit":10,"proj":9,"project":[0,4,6,8,9,10],"projector":8,"promin":8,"promis":[7,9,10],"promot":1,"proof":[0,1,2,3,4,5,6,7,8,9,10,11],"prop":[0,2,3,4,5,6,7,8,9,10,12],"propag":7,"properli":5,"properti":[1,2,3,4,5,6,7,8,9,10,11,12],"propform":5,"proposit":[0,2,3,4,5,6],"protect":6,"prototyp":5,"provabl":[1,3,7,10],"prove":[0,2,3,4,5,6,7,8,9,10,11,12,14],"proven":[8,9],"provid":[0,1,2,3,4,5,6,7,8,9,10,11,12],"proxi":6,"pseudoemetricspac":10,"pseudometricspac":10,"psycholog":7,"public":1,"pull":[0,8,10],"pullback":[8,10],"pun":2,"pure":[1,10],"pure_le_nhd":10,"purpos":[1,2,3,4,6,7,9,10],"push":[2,3,4,8,10],"push_pul":10,"pushforward":[8,10],"put":[0,1,2,3,4,5,6,7,8,9,10],"q":[2,4,6,7,8,9,10],"qk":4,"quad":6,"quadrat":[5,6],"qualifi":5,"quantifi":[1,3,4,6,8,10,14],"quantiti":10,"quest":7,"question":[0,4,7,10,12],"quick":[4,8,9,11],"quicker":0,"quickli":[3,4,8,12],"quirki":4,"quit":[2,7,10],"quot":[6,9,10],"quotequivofeq":8,"quotient":[4,6,7,10,14],"quotient_mul_add_remainder_eq":6,"quotient_zero":6,"quotientgroup":8,"quotientinfringequivpiquoti":8,"quotientkerequivrang":8,"quotientmap":8,"quotientmonoid":7,"quotientmulequivofeq":8,"quotkerequivrang":9,"r":[1,2,4,5,6,7,8,9,10],"r_wellfound":6,"radiu":10,"raini":3,"rais":[1,4],"random":7,"rang":[0,2,3,4,5,8,9,10],"range_eq_map":9,"range_eq_top":9,"range_mkq":9,"rank":9,"rare":7,"rather":[0,1,2,4,5,6,7,8,9,10],"ration":[1,2,4,10],"rb":10,"rcase":[2,3,4,5,10],"rclike":11,"re":[4,6],"reach":[2,7],"read":[0,1,4,7,8,9,10],"readabl":[1,2,3,9,10],"reader":[1,9,10],"readi":[4,7,8,9,10,11],"real":[1,2,3,4,6,7,9,10,11,12],"real_norm_l":11,"realli":[1,2,3,4,7,8,9,10],"reason":[0,1,2,4,5,6,7,8,9,10],"rec_on":10,"recal":[1,2,4,6,8,10,12],"recaptur":10,"recast":10,"recent":6,"recogn":[1,2,4,5,6,7,10],"recommend":[0,3],"recon":10,"reconcil":2,"record":[6,7,9],"recov":10,"rectangl":5,"recurs":[2,3,5,6,14],"redefin":[6,7],"reduc":[0,2,3,4,5,6,7],"reduct":[2,3],"redund":[1,6,9,10,12],"refer":[0,1,2,4,6,7,9,10,11],"refin":[4,11],"refl":[2,3,6,7,8,9],"refl_tran":6,"reflect":[2,9],"reflex":[1,2,6,10],"reformul":10,"refus":10,"regiment":0,"region":3,"regist":[2,6,7,8,9],"regular":[7,10],"regularspac":10,"rel":[3,6,9],"relat":[1,2,3,4,5,6,7,8,9,10,11,12],"relatedli":10,"relationship":[3,4],"relativ":3,"relev":[0,1,2,4,5,6,7,8,9,10],"reli":[1,2,5,6,10],"remain":[0,1,2,3,6,7,10],"remaind":[4,6,8],"remainder_lt":6,"remark":[4,6,7],"rememb":[1,2,3,4,5,6,7,8,9,10],"remov":[4,5,10],"renam":[0,9],"render":[2,4],"repeat":[1,4,6,7],"repeatedli":[2,10],"repetit":[1,5,7],"replac":[0,1,2,3,4,5,7,8,9],"replai":0,"replicatecol":9,"replicaterow":9,"report":1,"repositori":[0,1],"repr":9,"repres":[0,1,2,3,4,5,6,7,11],"represent":[3,4,6,9],"reproduc":[4,6],"reprov":[1,8,9],"requir":[0,1,2,3,4,5,6,7,8,9,10,11,12],"resolut":7,"resolve_left":3,"resourc":0,"resp":9,"respect":[1,2,3,4,5,6,8,9,10],"respons":[0,1],"rest":[2,3,5,6,8,10],"restat":[2,7,8,9],"restor":7,"restrict":[3,4,10],"result":[0,1,2,3,4,5,6,7,8,9,10],"retri":7,"return":[0,2,3,4,6,8,9,10],"reus":7,"reusabl":7,"reveal":[1,9],"revers":[1,2,3,5,6,10],"reverse_append":5,"reverse_revers":5,"revert":[4,5],"review":[8,10],"rewrit":[0,1,2,3,4,5,7,9,10],"rewritten":3,"rfl":[0,1,2,3,4,5,6,7,8,9,10,11,12],"rich":[6,7],"rid":2,"right":[0,1,2,3,4,5,6,7,9,10,11],"right_distrib":[6,7],"right_inv":[5,6,9],"rightinvers":3,"rik":0,"ring":[0,1,2,3,4,6,7,9,14],"ringequiv":8,"ringhom":[7,8],"ringhomclass\u2083":7,"ringhom\u2081":7,"ring\u2081":7,"ring\u2083":7,"rintro":[0,2,3,4,5,8,9,10],"rise":[4,7,8],"road":6,"robust":[6,7],"role":[4,6,9,10],"roll":11,"rolland":0,"roman":6,"root":[5,6,7,8,9,14],"roots_mul":8,"roots_x_sub_c":8,"roughli":[2,3,4],"round":[0,1,6],"routin":2,"row":[5,9],"rpo":10,"rule":[0,2,4,6,7,9,10],"run":[0,4],"rush":0,"russel":9,"rw":[0,2,3,4,5,6,7,8,9,10,14],"rwa":[3,4,6],"r\u02e3":8,"s_":3,"s_0":[2,3],"s_1":2,"s_2":2,"s_n":[2,3],"sa":2,"sad":10,"safe":[7,8],"safer":8,"sage":9,"sai":[0,1,2,3,4,5,6,7,8,9,10,12],"said":[0,2,4,6],"sake":[1,4],"salient":10,"same":[0,1,2,3,4,5,6,7,8,9,10],"satisfi":[1,3,4,5,6,7,10,11],"satisfli":6,"save":2,"saw":[1,4,6,7,8,9,10],"sb":2,"sb_fun":3,"sb_inject":3,"sb_right_inv":3,"sb_surject":3,"sbaux":3,"sbfun":3,"sbset":3,"scalar":[6,7,8,9,11],"scale":3,"scari":6,"scheme":6,"schroeder_bernstein":3,"schr\u00f6der":14,"scienc":[5,7],"scientist":2,"scope":[1,2,3,6,8,9],"scratch":2,"script":1,"search":[1,4,6,7],"sebastian":0,"second":[0,1,2,3,4,5,6,7,8,9,10,12],"secretli":9,"section":[0,1,2,3,4,5,6,7,8,9,10,11,12],"see":[0,1,2,3,4,5,6,7,8,9,10,11,12],"seek":6,"seem":[1,2,4,7,10,11],"seen":[0,1,2,4,5,6,7,8,9,10],"segment":[10,12],"select":[0,10],"self":7,"self_of_nhd":10,"self_sub":1,"self_trans_symm":[6,8,9],"selfequivsigmaorbit":8,"selfmodul":7,"semi":[7,8,9],"semicolon":[2,4,9],"semigroup":7,"semigroup\u2080":7,"semigroup\u2081":7,"semigroup\u2082":7,"semigroup\u2083":7,"semir":[7,8,9],"send":[8,9,12],"sens":[0,2,3,4,6,7,8,9,10,11],"sensibl":10,"sent":[8,10],"separ":[0,1,2,4,5,6,9],"sequenc":[3,7,10,11,14],"seri":8,"seriou":[4,7,10],"serv":[1,3,4,6,12],"set":[0,1,2,4,5,6,7,8,11,12,14],"set_opt":[2,5,7],"setco":7,"setintegral_const":12,"setlik":7,"setminu":3,"setoid":[7,8],"sets_of_superset":10,"setub":2,"setup":[8,9],"seurin":0,"sever":[5,7,9,10,12],"shade":3,"shame":7,"sharp":0,"shift":[0,1,5,7,10],"short":[0,1,2,3,4,6,9],"shorten":[1,2,5,8],"shorter":[1,3,4,5,8,10],"shot":10,"should":[0,1,2,3,4,5,6,7,8,10,11],"shouldn":[9,10],"show":[0,1,2,3,4,5,6,7,8,9,10,11,12],"shown":[1,6,11,12],"side":[0,1,2,3,4,5,6,7,8,9,10,11],"sight":[2,7],"sigma":[6,12],"sigmafinit":12,"sign":10,"signatur":7,"signific":3,"silent":[6,7],"silli":7,"silva":0,"similar":[1,2,3,6,7,8,9,10],"similarli":[2,3,4,5,6,8,9],"simp":[0,2,3,4,5,6,7,8,9,10,11],"simp_al":5,"simp_rw":8,"simpa":[4,5,8,11],"simpl":[2,4,6,7,11],"simpler":[7,9],"simplex":6,"simpli":[0,1,2,3,4,6,7,8,9,10],"simplif":[2,3,4],"simplifi":[0,2,3,4,5,6,10,12],"sin":[2,11],"sinc":[0,1,2,3,4,5,6,7,8,9,10],"singl":[0,1,2,3,4,5,6,7,8,9,11],"singleton":[4,5],"sinter":3,"sinter_eq_biint":3,"situat":[1,3,7,8,10],"size":[5,9],"size_flip":5,"size_l":5,"skeleton":[6,9,10],"sketch":[2,3,4,10],"skill":[0,1,2,3,4],"slick":2,"slight":3,"slightli":[1,7,8,9,10,11],"slow":10,"small":[0,4,6,10],"smaller":[3,4,10],"smallest":[4,7,9,10],"smart":4,"smul":[6,7,8,9],"smul_add":[7,9],"smul_comm":9,"smul_distrib":6,"smul_mem":9,"smul\u2083":7,"snd":[6,9,10],"snippet":[2,4,6,8,9],"so":[0,1,2,3,4,5,6,7,8,9,10,11,12],"solut":[0,1,4,5,7],"solv":[0,1,2,3,4,6,7,9,10],"some":[0,1,2,3,4,5,6,7,8,9,10,11],"somehow":[8,9],"someth":[0,1,2,4,5,7,9,10],"sometim":[1,2,3,4,5,6,7,8,9,10],"somewhat":[1,3,5,10],"somewher":10,"soon":[0,2,7,8,9,10],"sophist":10,"sorri":[0,1,2,3,4,5,6,7,8,9,10,11],"sort":[1,3,4],"sosi":2,"sosx":2,"sound":[3,6],"sourc":[2,10],"space":[1,2,3,6,7,8,12,14],"span_eq":9,"span_induct":9,"span_l":9,"span_union":9,"sparingli":4,"speak":[2,6,8,10],"special":[3,4,6,7,8,9,10,12],"specif":[0,1,3,4,5,6,7],"specifi":[1,2,3,4,5,6,9,10,11,12],"spell":[9,10],"spent":5,"split":[1,2,3,4],"spot":2,"sq_ab":6,"sq_nonneg":1,"sqr_eq":4,"sqrt":[2,3,4,6],"squar":[1,2,4,5,6,7,8,9],"square_add_sq_eq_zero":6,"squiggli":2,"ss":3,"ssubt":3,"stabil":8,"stabl":9,"stage":[2,6,7],"stai":6,"stand":[0,1,2,4,5,6,7,8,9,10,11],"standard":[4,5,6,7,8,10],"standardsimplex":6,"standardtwosimplex":6,"start":[1,2,3,4,5,7,8,9,10,11,12,14],"state":[0,1,2,3,4,7,8,9,10,11],"statement":[0,1,2,3,4,6,7,8,9,10,11,12],"stdsimplex":6,"steep":0,"steinhau":11,"step":[0,1,2,3,4,5,6,7],"steven":0,"stick":[1,2,10,11],"still":[0,1,2,3,4,6,7,9,10,12],"stipul":11,"stop":7,"store":6,"stori":[7,9],"str":6,"straightforward":[2,4,5,7],"strang":[2,4,8,9],"strategi":[1,2,4],"strength":1,"strengthen":[1,2,4],"stretch":[4,6],"strict":[1,2],"stricter":11,"strictli":[1,2,11],"strictmono":10,"strike":[1,2],"strong":[2,4],"strong_induction_on":4,"stronger":10,"strongli":0,"stronglymeasurableatfilt":12,"struc":6,"structur":[2,4,5,7,8,10,11,12,14],"stuck":7,"studi":[5,7,10],"style":[0,1,4],"sub":[3,10,12,14],"sub_add":1,"sub_add_cancel":1,"sub_eq_add_neg":1,"sub_self":[1,2],"sub_sub":1,"sub_zero":1,"subercaseaux":0,"subgoal":2,"subgroup":7,"subgroupclass\u2081":7,"subgroupofmulact":8,"subgroup\u2081":7,"subject":6,"submodul":[8,9],"submodule_isup_eq_top":9,"submodule_isupindep":9,"submonoid":[7,8],"submonoidclass\u2081":7,"submonoid\u2081":7,"submonoid\u2081monoid":7,"subobject":7,"subproof":1,"subr":7,"subscript":[1,9],"subsequ":[2,4,5,10],"subset":[1,2,3,5,6,10,11],"subset_def":3,"subset_iff":4,"subspac":[1,7,14],"subst":5,"subst_eq_of_not_mem_var":5,"subst_eval_eq":5,"substant":4,"substanti":0,"substitut":[0,2,5],"subsum":4,"subtl":[5,6,8,9,10],"subtleti":[7,8,9],"subtract":[1,4,6],"subtre":5,"subtyp":[5,6,7,8,9,10],"succ":[4,7],"succ_add":4,"succ_le_succ":4,"succ_mul":4,"succ_ne_zero":4,"succ_po":4,"succe":7,"success":[5,7],"successor":[4,9],"suffic":[1,2,3,5,8,10],"suffici":[4,10],"suggest":[0,2,4,5,6,9,10],"suitabl":[0,1,2,6,10],"sum":[1,2,4,5,6,7,8,10],"sum_add_distrib":6,"sum_comm":5,"sum_eq":6,"sum_eq_on":6,"sum_fin_eq_sum_rang":5,"sum_id":4,"sum_le_sum":5,"sum_mul":6,"sum_range_id":5,"sum_range_succ":4,"sum_range_zero":4,"sum_repr":9,"sum_sqr":4,"summand":9,"summat":4,"sumofsquar":2,"sumofsquares_mul":2,"sunion":3,"sunion_eq_biunion":3,"sup":[1,4,5,10],"sup_assoc":1,"sup_comm":1,"sup_eq_closur":8,"sup_eq_top":9,"sup_inf_left":1,"sup_inf_right":1,"sup_inf_self":1,"sup_l":1,"superfici":10,"superscript":10,"supersed":9,"suppli":7,"support":[0,1,2,3,4,5,6,7,9,10],"suppos":[1,2,3,4,5,6,10],"suppress":1,"supremum":[1,4,7,8,9],"sure":[1,2,3,6,7,8,9],"surject":[2,3,8,9,10],"surjf":[2,3],"surjg":2,"surpris":7,"surprisingli":[6,7],"swap":[5,6],"swapxi":6,"sweet":3,"switch":[1,7],"sylow":8,"symbol":[0,1,2,5,6,7,8],"symm":[1,3,4,6,7,8,9,10,11],"symmetr":[2,3,8],"symmetri":[3,7],"synonym":8,"syntact":2,"syntax":[0,1,2,4,7,9],"synth":7,"synthes":[6,7],"synthesi":9,"synthinst":7,"system":[3,4,6,7,9],"s\u00e1nchez":0,"s\u02e3":8,"s\u1d9c":[10,12],"s\u2081":7,"s\u2082":7,"t":[0,1,2,3,4,5,6,7,8,9,10,12],"t2space":10,"t3space":10,"t_":10,"t_3":10,"t_x":10,"t_y":10,"t_z":10,"tab":[1,3,4],"tackl":7,"tactic":[0,1,2,3,4,5,6,7,8,9,10,11],"tag":[2,3,7],"tail":4,"take":[1,2,3,4,5,6,7,8,9,10,11,12],"taken":[1,2,4,5],"takeshi":0,"talk":[4,8,9,10,11],"tantamount":[1,3],"target":[1,7,8,9,10,12],"task":[0,2,4,6,7,10],"taught":8,"tauto":[4,5],"tautologi":4,"teach":0,"tear":7,"technic":[1,6,7,9],"techniqu":[2,10],"technologi":7,"tediou":[1,2,7],"tell":[0,1,2,3,4,6,7,8,9],"temporari":5,"temporarili":[1,2],"tempt":7,"tend":[1,10],"tendsto":[10,12],"tendsto_attop":10,"tendsto_congr":10,"tendsto_iff":10,"tendsto_integral_of_dominated_converg":12,"tendsto_nhds_uniqu":10,"tendsto_pow_attop_nhds_zero_of_lt_on":10,"tendsto_right_iff":10,"tendsto_subseq":10,"tendsto\u2081":10,"tendsto\u2082":10,"term":[0,1,2,3,4,5,6,8,9,10],"terminologi":[6,9],"terraf":0,"ters":7,"test":[4,5],"text":[0,3,6,10],"textbook":[0,1,2],"th":[4,9],"than":[0,1,2,3,4,5,6,7,8,9,10,11],"thank":7,"thei":[0,1,2,3,4,5,6,7,8,9,10,11],"them":[0,1,2,3,4,5,6,7,8,9,10],"theme":3,"themselv":[0,4,6],"theorem":[0,2,4,5,6,8,9,10,11,12,14],"theoret":[2,3,5,9,10],"theori":[0,1,2,3,7,8,9,10,11,14],"therefor":[1,4,6,9,10],"thereof":0,"thi":[0,1,2,3,4,5,6,7,8,9,10,11,12],"thing":[0,1,2,3,4,5,6,7,9,10],"think":[0,1,2,3,4,5,6,7,9,10,11],"third":[1,2,3,6,10],"thoma":0,"thorough":0,"those":[0,1,2,3,5,6,7,8,9,10,11],"though":[2,3,4,6],"three":[1,2,4,5,6,8,10],"through":[0,1,3,4,5,6,7,8,9,10],"throughout":5,"thu":[1,3,4,6,10],"thumb":4,"tick":4,"tighter":[1,3],"tightli":6,"time":[1,4,5,6,7,9,10,11,12],"timesav":1,"tiresom":10,"to_addit":7,"to_localinvers":11,"toaddcommgroup\u2083":7,"todiaoneclass\u2081":7,"todia\u2081":7,"tofun":[5,6,7,9],"togeth":[1,2,3,4,5,6,8,10],"togroup":8,"tolist":5,"tomatrix":9,"tomatrix_comp":9,"tomatrix_id":9,"tomatrix_mulvec_repr":9,"tomodul":9,"tomonoidhom\u2081":7,"too":[0,1,3,5,6,7,8,9,10],"toohei":0,"tool":[0,1,6,7],"toone\u2081":7,"top":[0,5,7,8,9,10,11],"topermhom":8,"topic":[4,6,7,8,9],"topolog":[6,7,11,14],"topologi":[1,6,7,11,14],"topologicalspac":[10,11],"toreal":12,"tortuou":9,"tosemigroup\u2081":7,"tosmul\u2083":7,"total":[1,5,7],"tour":[10,11],"toward":8,"trace":[7,9],"track":5,"tradeoff":3,"tradition":8,"train":[1,7],"tran":[1,2,4,5,6,7,8,9],"trans_assoc":6,"trans_l":11,"trans_refl":6,"transform":[2,3],"transit":[1,2,5,6,10],"translat":[4,7,8,10],"transport":5,"transpos":9,"trap":7,"treat":[2,3,6,7,8,10,11],"treatment":8,"tree":5,"tri":[1,2,4,7],"triangl":[1,2,5,6],"trick":[1,2,4,7,11],"tricki":[2,3,4,5,7,8],"trigger":[7,9],"tripl":3,"trivial":[3,4,5,8,9,10],"troubl":[2,3,6],"true":[1,2,3,7,9,10],"true_iff":4,"truncat":4,"trust":9,"truth":[1,4,5],"try":[0,1,2,3,4,5,6,7,9,10],"tucker":0,"tupl":6,"turn":[2,3,4,5,6,7,9,10,11],"tutori":[0,5],"twice":[0,1,10],"two":[0,1,2,3,4,5,6,7,8,9,10,12],"two_l":4,"two_le_of_mod_4_eq_3":4,"two_mul":1,"ty":8,"type":[0,1,2,3,4,6,7,8,9,10,11,12,14],"typeclass":[7,9],"typic":[1,8],"u":[1,2,3,4,5,6,7,8,9,10,11,12],"u_2":9,"u_n":9,"ubf":2,"ubfa":2,"ubg":2,"ubgb":2,"ulequiv":8,"ultim":0,"un":3,"unapp":1,"unbundl":7,"unchang":[1,2],"uncom":1,"uncount":10,"uncurri":10,"under":[5,6,7,8,9,10],"underli":[0,1,6,7,8,9],"underneath":[1,3],"underscor":[1,2,3,9],"understand":[0,2,3,4,6,7,8,9,10],"understood":[4,10],"unfold":[1,2,3,4,6,10],"unfortun":[5,8],"unicod":[1,3,7],"unif":7,"uniform":[3,10,11],"uniformcontinu":10,"uniformcontinuous_iff":10,"uniformli":11,"union":[1,3,4,5,6,7,8,9,11,12],"union_def":3,"uniqu":[1,2,3,4,6,8,9,10],"unit":[6,7,10],"units_eq_one_or":8,"univ":[3,5,10,11,12],"univ_set":10,"univari":8,"univers":[1,3,5,6,8,9,10,14],"unknown":7,"unless":[1,2,6],"unlik":[3,4],"unnecessari":[2,3,8],"unneed":9,"unpack":[2,3],"unpleas":[7,10],"unrel":7,"unshad":3,"unspecifi":[7,9],"unsurprisingli":3,"until":[1,2,4,7,10],"unus":2,"unusedvari":2,"up":[0,2,3,4,5,6,7,8,10],"updat":0,"upper":[0,1,2,5],"us":[0,2,3,4,5,6,7,8,9,10,11,12,14],"usabl":7,"usag":1,"useless":9,"user":[0,7],"usual":[1,2,3,4,6,8,9,10,12],"v":[0,1,2,3,5,6,9,10],"v1":5,"v2":5,"val":[5,6],"valid":2,"valu":[1,2,3,4,5,6,7,8,9,10,11,12],"van":0,"vandermond":9,"vanish":[8,9],"var":5,"varepsilon":[2,10],"variabl":[1,2,3,4,5,6,7,8,9,10,11,12],"variant":[1,2,4,8,10],"variat":[1,3,4,5,6,10,11],"varieti":10,"variou":[2,3,5,6,7,9,12],"vastli":2,"ve":[7,10],"vecmul":9,"vector":[1,3,7,8,11,14],"vee":5,"veniamin":0,"verbatim":8,"verbos":3,"veri":[0,2,4,7,8,9,10,12],"verifi":2,"versa":[1,3],"version":[0,1,2,3,4,5,6,7,8,9,10,11,12],"vertex":5,"vertic":[2,6,9],"vi":6,"via":10,"vice":[1,3],"victor":0,"view":[6,7,8,10],"viflyantsev":0,"virtual":9,"visibl":1,"vocabulari":[3,9],"volum":12,"w":[1,7,9],"wa":[1,3,5,8],"wai":[0,1,2,3,4,5,6,7,8,9,10,12],"want":[0,1,2,3,4,6,7,8,9,10,11,12],"warn":[2,7],"wasn":10,"wast":4,"watch":5,"we":[0,1,2,3,4,5,6,7,8,9,10,11,12],"weak":7,"weaker":[1,2],"weav":6,"web":[0,1,4],"wedg":5,"weight":6,"weightedaverag":6,"weird":[7,10],"weirder":11,"welcom":[0,1],"well":[0,1,2,3,4,5,6,7,8,9,10],"were":[2,4,6,7,9,10],"what":[0,1,2,3,4,5,6,7,8,9,10],"whatev":[0,2,4],"whats_new":7,"when":[0,1,2,3,4,5,6,7,8,9,10,11],"whenev":[1,2,4,6,9],"where":[0,1,2,3,4,5,6,7,8,9,10,11,12],"wherea":[0,1,2,3,6,8,10],"wherebi":[6,10],"whether":[2,3,4,5,7,10],"which":[0,1,2,3,4,5,6,7,8,9,10,11,12],"while":[0,1,2,7,8,9,10],"who":[0,10],"whole":[6,9],"whose":[1,2,4,5,6,7,8,9,10,11],"why":[0,2,4,7,8,9,10],"wieser":0,"window":[0,1,2,6],"winston":0,"wise":[6,9],"wish":10,"withbot":8,"within":[1,2,10],"without":[1,2,4,6,7,8,9,10,11],"withtop":11,"wlog":3,"won":[1,2,4,7,8,10],"wonder":9,"word":[1,2,3,4,5,6,8,9,10],"work":[0,1,2,3,4,5,6,7,8,9,10,11],"workhors":5,"world":0,"worri":[1,3,4,5,6,8],"worth":[1,2,6],"would":[1,2,3,4,5,6,7,8,9,10,11],"wouldn":7,"wrap":[7,10],"write":[0,1,2,4,5,6,7,8,9,10,11,12],"written":[1,2,3,4,5,6,7,8,9,10,11],"wrong":3,"wrote":4,"x":[0,1,2,3,4,5,6,7,8,9,10,11,12],"x_0":10,"x_1":[2,3],"x_2":[2,3],"x_i":10,"x_nonneg":6,"xa":3,"xai":3,"xeq":[2,3],"xgt":2,"xlt":2,"xltz":2,"xmem":3,"xnei":5,"xnt":3,"xnu":3,"xpo":3,"xstu":3,"xsu":3,"xt":3,"xtu":3,"xu":3,"xy":[2,6],"x\u2080":[10,11],"x\u2081":[2,3,6,10],"x\u2081a":3,"x\u2082":[2,3,6,10],"x\u2082a":3,"x\u2082eq":3,"x\u2082na":3,"y":[0,1,2,3,4,5,6,7,8,9,10,11,12],"y_nonneg":6,"yannick":0,"yball":10,"yeq":2,"yet":[2,3,4,5,6,7,9,10],"yield":[1,2,3,4,5,6,10],"ylim":10,"ylt":2,"you":[0,1,2,3,4,5,6,7,8,9,10,11,12],"your":[0,1,2,3,6,7,8,10],"yourself":[2,5,6],"ypo":3,"y\u2080":10,"y\u2081":[6,10],"y\u2082":[6,10],"z":[0,1,2,5,6,7,8,9,10,11,12],"z_nonneg":6,"zermelo":2,"zero":[2,3,4,6,7,8,9,10,11,12],"zero_add":[1,4,6,7],"zero_def":6,"zero_dvd_iff":4,"zero_im":6,"zero_l":[4,5,6],"zero_lt_of_mul_eq_on":4,"zero_lt_on":[2,4,11],"zero_lt_two":6,"zero_mem":[8,9],"zero_mul":[1,4,6,7],"zero_r":6,"zero_smul":7,"zeroth":9,"zf":2,"zlty":2,"zmod":8,"zsmul":[6,7],"zsmulrec":6,"zsmul\u2081":7,"zulip":[0,4],"z\u2080":10,"z\u2081":6,"z\u2082":6,"\u00b9":[1,3,6,7,8,9,10],"\u02e2":[5,10],"\u03b1":[1,2,3,4,5,6,7,8,9,10,11,12],"\u03b2":[1,2,3,5,6,7,9,10,12],"\u03b3":[1,2,5,6,10],"\u03b4":[2,10],"\u03b4po":10,"\u03b5":[2,10,11],"\u03b52po":2,"\u03b5_po":[10,11],"\u03b5k_po":11,"\u03b5po":[2,10],"\u03b8":9,"\u03b9":[8,9,10,11,12],"\u03bc":[10,12],"\u03bd":12,"\u03c0":[8,9,10,11],"\u03c3":[5,6,8],"\u03c6":[4,8,9,10],"\u03c8":[8,9],"\u03c9":[8,11],"\u1d40":9,"\u1d50":12,"\u1d65":[8,9],"\u1d9c":8,"\u1da0":[10,11,12],"\u2080":[3,9],"\u2081":7,"\u2090":8,"\u2097":9,"\u2102":[1,6,8,9,11],"\u2115":[0,1,2,3,4,5,6,7,8,9,10,11,12],"\u211a":[1,4,8,9,10],"\u211d":[1,2,3,4,6,7,8,9,10,11,12],"\u2124":[1,4,6,7,8,9],"\u2124\u02e3":8,"\ud835\udcdd":[10,11,12],"\ud835\udcdf":10,"\ud835\udce4":10,"\ud835\udd42":11,"\ud835\udd5c":[11,12],"\ud835\udfd9":7},"titles":["1. Introduction","2. Basics","3. Logic","4. Sets and Functions","5. Elementary Number Theory","6. Discrete Mathematics","7. Structures","8. Hierarchies","9. Groups and Rings","10. Linear algebra","11. Topology","12. Differential Calculus","13. Integration and Measure Theory","Index","Mathematics in Lean"],"titleterms":{"The":[2,3],"about":1,"action":8,"algebra":[1,6,8,9],"appli":1,"argument":5,"asymptot":11,"ball":10,"base":9,"basic":[1,7],"bernstein":3,"build":6,"calcul":1,"calculu":11,"close":10,"compact":10,"comparison":11,"complet":[9,10],"concret":8,"conjunct":2,"continu":[10,11],"converg":[2,10],"count":5,"countabl":10,"defin":[5,6],"differenti":11,"dimens":9,"direct":9,"discret":5,"disjunct":2,"elementari":[4,11,12],"endomorph":9,"exampl":1,"existenti":2,"fact":1,"filter":10,"finset":5,"fintyp":5,"function":[3,10],"fundament":10,"gaussian":6,"get":0,"group":8,"hierarchi":7,"ideal":8,"ident":1,"iff":2,"implic":2,"index":13,"induct":[4,5],"infinit":4,"integ":6,"integr":12,"intern":9,"introduct":0,"irrat":4,"lattic":9,"lean":14,"lemma":1,"linear":[9,11],"logic":2,"mani":4,"map":[9,11],"mathemat":[5,14],"matric":9,"measur":12,"metric":10,"monoid":8,"more":[1,4],"morphism":[7,8],"negat":2,"norm":11,"number":4,"object":7,"open":10,"overview":0,"polynomi":8,"prime":4,"product":9,"prove":1,"pull":9,"push":9,"quantifi":2,"quotient":[8,9],"recurs":4,"ring":8,"root":4,"rw":1,"schr\u00f6der":3,"separ":10,"sequenc":2,"set":[3,9,10],"space":[9,10,11],"span":9,"start":0,"structur":[1,6,9],"sub":7,"subgroup":8,"subr":8,"subspac":9,"sum":9,"theorem":[1,3],"theori":[4,12],"topolog":10,"topologi":10,"type":5,"uniformli":10,"unit":8,"univers":2,"us":1,"vector":9}}) \ No newline at end of file diff --git a/dev/vendor/mathematics_in_lean/lake-manifest.json b/dev/vendor/mathematics_in_lean/lake-manifest.json new file mode 100644 index 0000000..03db281 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/lake-manifest.json @@ -0,0 +1,96 @@ +{"version": "1.2.0", + "packagesDir": ".lake/packages", + "packages": + [{"url": "https://github.com/leanprover-community/mathlib4", + "type": "git", + "subDir": null, + "scope": "", + "rev": "5ed2965256430c3649e86755f9576b54eca72435", + "name": "mathlib", + "manifestFile": "lake-manifest.json", + "inputRev": "v4.34.0", + "inherited": false, + "configFile": "lakefile.lean"}, + {"url": "https://github.com/leanprover-community/plausible", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "118aa17ee84656b8bd727fef7c458ee8c833385c", + "name": "plausible", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/LeanSearchClient", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "ddf04cf3949fa556442341e87d47f9f6e6074707", + "name": "LeanSearchClient", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/import-graph", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "e928b72544873815af278d38681b31c0293588e3", + "name": "importGraph", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/ProofWidgets4", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "106ff4fafc74ef4ac99d81dbf3ab399118f497a5", + "name": "proofwidgets", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.lean"}, + {"url": "https://github.com/leanprover-community/aesop", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "355695d523e41d0554926416cba2a2b3544fbbc9", + "name": "aesop", + "manifestFile": "lake-manifest.json", + "inputRev": "master", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/quote4", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "6a489d9af5d0c47e5b259e2e8bcdfc1811b5a259", + "name": "Qq", + "manifestFile": "lake-manifest.json", + "inputRev": "master", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/batteries", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "f2effa3d803fda822b1f97b806c47cf2adfbcbc2", + "name": "batteries", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover/lean4-cli", + "type": "git", + "subDir": null, + "scope": "leanprover", + "rev": "e92c9f15fdfacc8536f31cfb3b7ad26c3c8cd204", + "name": "Cli", + "manifestFile": "lake-manifest.json", + "inputRev": "v4.34.0", + "inherited": true, + "configFile": "lakefile.toml"}], + "name": "mil", + "lakeDir": ".lake", + "fixedToolchain": false} diff --git a/dev/vendor/mathematics_in_lean/lakefile.toml b/dev/vendor/mathematics_in_lean/lakefile.toml new file mode 100644 index 0000000..0f67968 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/lakefile.toml @@ -0,0 +1,15 @@ +name = "mil" +defaultTargets = ["MIL"] + +[leanOptions] +pp.unicode.fun = true # pretty-prints `fun a ↦ b` +autoImplicit = false +relaxedAutoImplicit = false + +[[require]] +name = "mathlib" +git = "https://github.com/leanprover-community/mathlib4" +rev = "v4.34.0" + +[[lean_lib]] +name = "MIL" diff --git a/dev/vendor/mathematics_in_lean/lean-toolchain b/dev/vendor/mathematics_in_lean/lean-toolchain new file mode 100644 index 0000000..12359f9 --- /dev/null +++ b/dev/vendor/mathematics_in_lean/lean-toolchain @@ -0,0 +1 @@ +leanprover/lean4:v4.34.0 diff --git a/dev/vendor/mathematics_in_lean/mathematics_in_lean.pdf b/dev/vendor/mathematics_in_lean/mathematics_in_lean.pdf new file mode 100644 index 0000000..a8dffe3 Binary files /dev/null and b/dev/vendor/mathematics_in_lean/mathematics_in_lean.pdf differ diff --git a/tests/bcda/test_vendor.py b/tests/bcda/test_vendor.py index cdd98a0..2b67056 100644 --- a/tests/bcda/test_vendor.py +++ b/tests/bcda/test_vendor.py @@ -102,6 +102,21 @@ class TestVendoredTree: "Public Domain" in (ROOT / "dev/vendor/bcda-app/LICENSE").read_text() or (ROOT / "dev/vendor/bcda-app/LICENSE").stat().st_size > 0 ) + mil_license = (ROOT / "dev/vendor/mathematics_in_lean/LICENSE").read_text() + assert "Apache License" in mil_license and "Version 2.0" in mil_license + + def test_mathematics_in_lean_pin(self, vendor) -> None: + """The textbook is vendored beside the BCDA manifest, not on that screen.""" + pin = ROOT / "dev/vendor/mathematics_in_lean.toml" + m = vendor.load_manifest(pin) + mil = m["source"][0] + assert mil["repo"] == "leanprover-community/mathematics_in_lean" + assert mil["commit"] == "cff01285931648054c4fe6817baed0ccd45c0372" + for f in ("LICENSE", "mathematics_in_lean.pdf", "MIL.lean", "lean-toolchain"): + assert f in mil["files"] + assert vendor.verify(m) == [] + names = {s["name"] for s in vendor.load_manifest()["source"]} + assert "mathematics_in_lean" not in names class TestManifestIO: