chore(vendor): pin Mathematics in Lean at cff0128
All checks were successful
CI / lint (push) Successful in 44s
CI / notebooks-smoke (push) Successful in 2m5s
Deploy / changes (push) Successful in 17s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Deploy / api (push) Has been skipped
Deploy / bcda (push) Has been skipped
Deploy / llm (push) Has been skipped
Deploy / mc (push) Has been skipped
Deploy / report (push) Successful in 14s
CI / test (push) Successful in 4m50s
All checks were successful
CI / lint (push) Successful in 44s
CI / notebooks-smoke (push) Successful in 2m5s
Deploy / changes (push) Successful in 17s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Deploy / api (push) Has been skipped
Deploy / bcda (push) Has been skipped
Deploy / llm (push) Has been skipped
Deploy / mc (push) Has been skipped
Deploy / report (push) Successful in 14s
CI / test (push) Successful in 4m50s
Apache-2.0 textbook, HTML, and MIL exercises from leanprover-community/mathematics_in_lean (Lean 4.34.0). Editor and CI scaffolding stays upstream. Mathlib stays a lake dependency, not a copy.
This commit is contained in:
@@ -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
|
||||
|
||||
402
dev/vendor/mathematics_in_lean.toml
vendored
Normal file
402
dev/vendor/mathematics_in_lean.toml
vendored
Normal file
@@ -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"
|
||||
6
dev/vendor/mathematics_in_lean/.gitignore
vendored
Normal file
6
dev/vendor/mathematics_in_lean/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/.vscode
|
||||
/build
|
||||
/lake-packages
|
||||
.lake
|
||||
/.cache
|
||||
.DS_Store
|
||||
201
dev/vendor/mathematics_in_lean/LICENSE
vendored
Normal file
201
dev/vendor/mathematics_in_lean/LICENSE
vendored
Normal file
@@ -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.
|
||||
44
dev/vendor/mathematics_in_lean/MIL.lean
vendored
Normal file
44
dev/vendor/mathematics_in_lean/MIL.lean
vendored
Normal file
@@ -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
|
||||
3
dev/vendor/mathematics_in_lean/MIL/C01_Introduction/S01_Getting_Started.lean
vendored
Normal file
3
dev/vendor/mathematics_in_lean/MIL/C01_Introduction/S01_Getting_Started.lean
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module
|
||||
#eval "Hello, World!"
|
||||
|
||||
56
dev/vendor/mathematics_in_lean/MIL/C01_Introduction/S02_Overview.lean
vendored
Normal file
56
dev/vendor/mathematics_in_lean/MIL/C01_Introduction/S02_Overview.lean
vendored
Normal file
@@ -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]
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
module
|
||||
6
dev/vendor/mathematics_in_lean/MIL/C01_Introduction/solutions/Solutions_S02_Overview.lean
vendored
Normal file
6
dev/vendor/mathematics_in_lean/MIL/C01_Introduction/solutions/Solutions_S02_Overview.lean
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
module
|
||||
public import MIL.Common
|
||||
|
||||
open Nat
|
||||
|
||||
-- There are no exercises in this section.
|
||||
145
dev/vendor/mathematics_in_lean/MIL/C02_Basics/S01_Calculating.lean
vendored
Normal file
145
dev/vendor/mathematics_in_lean/MIL/C02_Basics/S01_Calculating.lean
vendored
Normal file
@@ -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]
|
||||
147
dev/vendor/mathematics_in_lean/MIL/C02_Basics/S02_Proving_Identities_in_Algebraic_Structures.lean
vendored
Normal file
147
dev/vendor/mathematics_in_lean/MIL/C02_Basics/S02_Proving_Identities_in_Algebraic_Structures.lean
vendored
Normal file
@@ -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
|
||||
|
||||
127
dev/vendor/mathematics_in_lean/MIL/C02_Basics/S03_Using_Theorems_and_Lemmas.lean
vendored
Normal file
127
dev/vendor/mathematics_in_lean/MIL/C02_Basics/S03_Using_Theorems_and_Lemmas.lean
vendored
Normal file
@@ -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
|
||||
|
||||
85
dev/vendor/mathematics_in_lean/MIL/C02_Basics/S04_More_on_Order_and_Divisibility.lean
vendored
Normal file
85
dev/vendor/mathematics_in_lean/MIL/C02_Basics/S04_More_on_Order_and_Divisibility.lean
vendored
Normal file
@@ -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
|
||||
|
||||
|
||||
113
dev/vendor/mathematics_in_lean/MIL/C02_Basics/S05_Proving_Facts_about_Algebraic_Structures.lean
vendored
Normal file
113
dev/vendor/mathematics_in_lean/MIL/C02_Basics/S05_Proving_Facts_about_Algebraic_Structures.lean
vendored
Normal file
@@ -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
|
||||
|
||||
52
dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S01_Calculating.lean
vendored
Normal file
52
dev/vendor/mathematics_in_lean/MIL/C02_Basics/solutions/Solutions_S01_Calculating.lean
vendored
Normal file
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
181
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S01_Implication_and_the_Universal_Quantifier.lean
vendored
Normal file
181
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S01_Implication_and_the_Universal_Quantifier.lean
vendored
Normal file
@@ -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
|
||||
169
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S02_The_Existential_Quantifier.lean
vendored
Normal file
169
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S02_The_Existential_Quantifier.lean
vendored
Normal file
@@ -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
|
||||
140
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S03_Negation.lean
vendored
Normal file
140
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S03_Negation.lean
vendored
Normal file
@@ -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
|
||||
|
||||
158
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S04_Conjunction_and_Iff.lean
vendored
Normal file
158
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S04_Conjunction_and_Iff.lean
vendored
Normal file
@@ -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
|
||||
129
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S05_Disjunction.lean
vendored
Normal file
129
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S05_Disjunction.lean
vendored
Normal file
@@ -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
|
||||
|
||||
104
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S06_Sequences_and_Convergence.lean
vendored
Normal file
104
dev/vendor/mathematics_in_lean/MIL/C03_Logic/S06_Sequences_and_Convergence.lean
vendored
Normal file
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
112
dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S03_Negation.lean
vendored
Normal file
112
dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S03_Negation.lean
vendored
Normal file
@@ -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
|
||||
|
||||
95
dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S04_Conjunction_and_Iff.lean
vendored
Normal file
95
dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S04_Conjunction_and_Iff.lean
vendored
Normal file
@@ -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
|
||||
142
dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S05_Disjunction.lean
vendored
Normal file
142
dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S05_Disjunction.lean
vendored
Normal file
@@ -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
|
||||
132
dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S06_Sequences_and_Convergence.lean
vendored
Normal file
132
dev/vendor/mathematics_in_lean/MIL/C03_Logic/solutions/Solutions_S06_Sequences_and_Convergence.lean
vendored
Normal file
@@ -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
|
||||
|
||||
238
dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S01_Sets.lean
vendored
Normal file
238
dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S01_Sets.lean
vendored
Normal file
@@ -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
|
||||
|
||||
191
dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S02_Functions.lean
vendored
Normal file
191
dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/S02_Functions.lean
vendored
Normal file
@@ -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
|
||||
@@ -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
|
||||
150
dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S01_Sets.lean
vendored
Normal file
150
dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S01_Sets.lean
vendored
Normal file
@@ -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
|
||||
|
||||
249
dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S02_Functions.lean
vendored
Normal file
249
dev/vendor/mathematics_in_lean/MIL/C04_Sets_and_Functions/solutions/Solutions_S02_Functions.lean
vendored
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
121
dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S01_Irrational_Roots.lean
vendored
Normal file
121
dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S01_Irrational_Roots.lean
vendored
Normal file
@@ -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
|
||||
|
||||
147
dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S02_Induction_and_Recursion.lean
vendored
Normal file
147
dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S02_Induction_and_Recursion.lean
vendored
Normal file
@@ -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
|
||||
227
dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S03_Infinitely_Many_Primes.lean
vendored
Normal file
227
dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S03_Infinitely_Many_Primes.lean
vendored
Normal file
@@ -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
|
||||
|
||||
138
dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S04_More_Induction.lean
vendored
Normal file
138
dev/vendor/mathematics_in_lean/MIL/C05_Elementary_Number_Theory/S04_More_Induction.lean
vendored
Normal file
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
158
dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S01_Finsets_and_Fintypes.lean
vendored
Normal file
158
dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S01_Finsets_and_Fintypes.lean
vendored
Normal file
@@ -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
|
||||
|
||||
137
dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S02_Counting_Arguments.lean
vendored
Normal file
137
dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S02_Counting_Arguments.lean
vendored
Normal file
@@ -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
|
||||
161
dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S03_Inductive_Structures.lean
vendored
Normal file
161
dev/vendor/mathematics_in_lean/MIL/C06_Discrete_Mathematics/S03_Inductive_Structures.lean
vendored
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
@@ -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
|
||||
213
dev/vendor/mathematics_in_lean/MIL/C07_Structures/S01_Structures.lean
vendored
Normal file
213
dev/vendor/mathematics_in_lean/MIL/C07_Structures/S01_Structures.lean
vendored
Normal file
@@ -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
|
||||
|
||||
174
dev/vendor/mathematics_in_lean/MIL/C07_Structures/S02_Algebraic_Structures.lean
vendored
Normal file
174
dev/vendor/mathematics_in_lean/MIL/C07_Structures/S02_Algebraic_Structures.lean
vendored
Normal file
@@ -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
|
||||
278
dev/vendor/mathematics_in_lean/MIL/C07_Structures/S03_Building_the_Gaussian_Integers.lean
vendored
Normal file
278
dev/vendor/mathematics_in_lean/MIL/C07_Structures/S03_Building_the_Gaussian_Integers.lean
vendored
Normal file
@@ -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
|
||||
101
dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S01_Structures.lean
vendored
Normal file
101
dev/vendor/mathematics_in_lean/MIL/C07_Structures/solutions/Solutions_S01_Structures.lean
vendored
Normal file
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
316
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S01_Basics.lean
vendored
Normal file
316
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S01_Basics.lean
vendored
Normal file
@@ -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
|
||||
|
||||
118
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S02_Morphisms.lean
vendored
Normal file
118
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S02_Morphisms.lean
vendored
Normal file
@@ -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
|
||||
96
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S03_Subobjects.lean
vendored
Normal file
96
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/S03_Subobjects.lean
vendored
Normal file
@@ -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
|
||||
354
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S01_Basics.lean
vendored
Normal file
354
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S01_Basics.lean
vendored
Normal file
@@ -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
|
||||
130
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S02_Morphisms.lean
vendored
Normal file
130
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S02_Morphisms.lean
vendored
Normal file
@@ -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
|
||||
132
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S03_Subobjects.lean
vendored
Normal file
132
dev/vendor/mathematics_in_lean/MIL/C08_Hierarchies/solutions/Solutions_S03_Subobjects.lean
vendored
Normal file
@@ -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]
|
||||
296
dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/S01_Groups.lean
vendored
Normal file
296
dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/S01_Groups.lean
vendored
Normal file
@@ -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
|
||||
224
dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/S02_Rings.lean
vendored
Normal file
224
dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/S02_Rings.lean
vendored
Normal file
@@ -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
|
||||
171
dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S01_Groups.lean
vendored
Normal file
171
dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S01_Groups.lean
vendored
Normal file
@@ -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
|
||||
82
dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S02_Rings.lean
vendored
Normal file
82
dev/vendor/mathematics_in_lean/MIL/C09_Groups_and_Rings/solutions/Solutions_S02_Rings.lean
vendored
Normal file
@@ -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
|
||||
|
||||
175
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S01_Vector_Spaces.lean
vendored
Normal file
175
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S01_Vector_Spaces.lean
vendored
Normal file
@@ -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
|
||||
170
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S02_Subspaces.lean
vendored
Normal file
170
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S02_Subspaces.lean
vendored
Normal file
@@ -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
|
||||
73
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S03_Endomorphisms.lean
vendored
Normal file
73
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S03_Endomorphisms.lean
vendored
Normal file
@@ -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
|
||||
|
||||
269
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S04_Bases.lean
vendored
Normal file
269
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/S04_Bases.lean
vendored
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
129
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S02_Subspaces.lean
vendored
Normal file
129
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S02_Subspaces.lean
vendored
Normal file
@@ -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
|
||||
69
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S03_Endomorphisms.lean
vendored
Normal file
69
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S03_Endomorphisms.lean
vendored
Normal file
@@ -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]
|
||||
|
||||
112
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S04_Bases.lean
vendored
Normal file
112
dev/vendor/mathematics_in_lean/MIL/C10_Linear_Algebra/solutions/Solutions_S04_Bases.lean
vendored
Normal file
@@ -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
|
||||
|
||||
106
dev/vendor/mathematics_in_lean/MIL/C11_Topology/S01_Filters.lean
vendored
Normal file
106
dev/vendor/mathematics_in_lean/MIL/C11_Topology/S01_Filters.lean
vendored
Normal file
@@ -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
|
||||
|
||||
205
dev/vendor/mathematics_in_lean/MIL/C11_Topology/S02_Metric_Spaces.lean
vendored
Normal file
205
dev/vendor/mathematics_in_lean/MIL/C11_Topology/S02_Metric_Spaces.lean
vendored
Normal file
@@ -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
|
||||
|
||||
152
dev/vendor/mathematics_in_lean/MIL/C11_Topology/S03_Topological_Spaces.lean
vendored
Normal file
152
dev/vendor/mathematics_in_lean/MIL/C11_Topology/S03_Topological_Spaces.lean
vendored
Normal file
@@ -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
|
||||
73
dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S01_Filters.lean
vendored
Normal file
73
dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S01_Filters.lean
vendored
Normal file
@@ -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)
|
||||
305
dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S02_Metric_Spaces.lean
vendored
Normal file
305
dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S02_Metric_Spaces.lean
vendored
Normal file
@@ -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 _ _
|
||||
180
dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S03_Topological_Spaces.lean
vendored
Normal file
180
dev/vendor/mathematics_in_lean/MIL/C11_Topology/solutions/Solutions_S03_Topological_Spaces.lean
vendored
Normal file
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
50
dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S02_Measure_Theory.lean
vendored
Normal file
50
dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S02_Measure_Theory.lean
vendored
Normal file
@@ -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
|
||||
66
dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S03_Integration.lean
vendored
Normal file
66
dev/vendor/mathematics_in_lean/MIL/C13_Integration_and_Measure_Theory/S03_Integration.lean
vendored
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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 α}
|
||||
|
||||
@@ -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 α}
|
||||
|
||||
5
dev/vendor/mathematics_in_lean/MIL/Common.lean
vendored
Normal file
5
dev/vendor/mathematics_in_lean/MIL/Common.lean
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
module
|
||||
public import Mathlib.Tactic
|
||||
public import Mathlib.Util.Delaborators
|
||||
|
||||
set_option warningAsError false
|
||||
44
dev/vendor/mathematics_in_lean/MIL_solutions.lean
vendored
Normal file
44
dev/vendor/mathematics_in_lean/MIL_solutions.lean
vendored
Normal file
@@ -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
|
||||
80
dev/vendor/mathematics_in_lean/README.md
vendored
Normal file
80
dev/vendor/mathematics_in_lean/README.md
vendored
Normal file
@@ -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:
|
||||
|
||||
<a href='https://codespaces.new/leanprover-community/mathematics_in_lean' target="_blank" rel="noreferrer noopener"><img src='https://github.com/codespaces/badge.svg' alt='Open in GitHub Codespaces' style='max-width: 100%;'></a>
|
||||
|
||||
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 <https://github.com/codespaces>.
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
PRs and issues should be opened at the upstream
|
||||
[source repository](https://github.com/avigad/mathematics_in_lean_source).
|
||||
4
dev/vendor/mathematics_in_lean/html/.buildinfo
vendored
Normal file
4
dev/vendor/mathematics_in_lean/html/.buildinfo
vendored
Normal file
@@ -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
|
||||
403
dev/vendor/mathematics_in_lean/html/C01_Introduction.html
vendored
Normal file
403
dev/vendor/mathematics_in_lean/html/C01_Introduction.html
vendored
Normal file
@@ -0,0 +1,403 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html class="writer-html5" lang="en" data-content_root="./">
|
||||
<head>
|
||||
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>1. Introduction — Mathematics in Lean v4.34.0 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=b86133f3" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/css/custom.css?v=0731ccc3" />
|
||||
|
||||
|
||||
<link rel="shortcut icon" href="_static/favicon.ico"/>
|
||||
<script src="_static/jquery.js?v=5d32c60e"></script>
|
||||
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
|
||||
<script src="_static/documentation_options.js?v=007da34f"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
<link rel="next" title="2. Basics" href="C02_Basics.html" />
|
||||
<link rel="prev" title="Mathematics in Lean" href="index.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search" >
|
||||
|
||||
|
||||
|
||||
<a href="index.html" class="icon icon-home">
|
||||
Mathematics in Lean
|
||||
</a>
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul class="current">
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">1. Introduction</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#getting-started">1.1. Getting Started</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#overview">1.2. Overview</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C02_Basics.html">2. Basics</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C03_Logic.html">3. Logic</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C04_Sets_and_Functions.html">4. Sets and Functions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C05_Elementary_Number_Theory.html">5. Elementary Number Theory</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C06_Discrete_Mathematics.html">6. Discrete Mathematics</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C07_Structures.html">7. Structures</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C08_Hierarchies.html">8. Hierarchies</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C09_Groups_and_Rings.html">9. Groups and Rings</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C10_Linear_Algebra.html">10. Linear algebra</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C11_Topology.html">11. Topology</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C12_Differential_Calculus.html">12. Differential Calculus</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="C13_Integration_and_Measure_Theory.html">13. Integration and Measure Theory</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="genindex.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="index.html">Mathematics in Lean</a>
|
||||
</nav>
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
|
||||
<li class="breadcrumb-item active"><span class="section-number">1. </span>Introduction</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
<a href="_sources/C01_Introduction.rst.txt" rel="nofollow"> View page source</a>
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div itemprop="articleBody">
|
||||
|
||||
<section id="introduction">
|
||||
<span id="id1"></span><h1><span class="section-number">1. </span>Introduction<a class="headerlink" href="#introduction" title="Link to this heading"></a></h1>
|
||||
<section id="getting-started">
|
||||
<h2><span class="section-number">1.1. </span>Getting Started<a class="headerlink" href="#getting-started" title="Link to this heading"></a></h2>
|
||||
<p>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.</p>
|
||||
<p>You can learn more about Lean from the
|
||||
<a class="reference external" href="https://lean-lang.org">Lean project page</a>
|
||||
and the
|
||||
<a class="reference external" href="https://leanprover-community.github.io/">Lean community web pages</a>.
|
||||
This tutorial is based on Lean’s large and ever-growing library, <em>Mathlib</em>.
|
||||
We also strongly recommend joining the
|
||||
<a class="reference external" href="https://leanprover.zulipchat.com/">Lean Zulip online chat group</a>
|
||||
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.</p>
|
||||
<p>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:</p>
|
||||
<ol class="arabic simple">
|
||||
<li><p>Install Lean 4 and VS Code following
|
||||
these <a class="reference external" href="https://lean-lang.org/install/">installation instructions</a>.</p></li>
|
||||
<li><p>Fetch the repository by clicking on the forall symbol in the upper right corner of VS Code,
|
||||
and choose <cite>Open Project</cite>, <cite>Download Project</cite>, and <cite>Mathematics in Lean</cite>.</p></li>
|
||||
<li><p>Each section in this book has an associated Lean file with examples and exercises.
|
||||
You can find them in the folder <code class="docutils literal notranslate"><span class="pre">MIL</span></code>, 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 <code class="docutils literal notranslate"><span class="pre">my_files</span></code> or whatever you want and use it to create
|
||||
your own Lean files as well.</p></li>
|
||||
</ol>
|
||||
<p>At that point, you can open the textbook in a side panel in VS Code as follows:</p>
|
||||
<ol class="arabic simple">
|
||||
<li><p>Type <code class="docutils literal notranslate"><span class="pre">ctrl-shift-P</span></code> (<code class="docutils literal notranslate"><span class="pre">command-shift-P</span></code> in macOS).</p></li>
|
||||
<li><p>Type <code class="docutils literal notranslate"><span class="pre">Lean</span> <span class="pre">4:</span> <span class="pre">Docs:</span> <span class="pre">Show</span> <span class="pre">Documentation</span> <span class="pre">Resources</span></code> 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.)</p></li>
|
||||
<li><p>In the window that opens, click on <code class="docutils literal notranslate"><span class="pre">Mathematics</span> <span class="pre">in</span> <span class="pre">Lean</span></code>.</p></li>
|
||||
</ol>
|
||||
<p>Alternatively, you can run Lean and VS Code in the cloud,
|
||||
using <a class="reference external" href="https://github.com/codespaces">Codespaces</a>.
|
||||
You can find instructions as to how to do that on the Mathematics in Lean
|
||||
<a class="reference external" href="https://github.com/leanprover-community/mathematics_in_lean">project page</a>
|
||||
on Github. We still recommend working in a copy of the <cite>MIL</cite> folder,
|
||||
as described above.</p>
|
||||
<p>This textbook and the associated repository are still a work in progress.
|
||||
You can update the repository by typing <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">pull</span></code>
|
||||
followed by <code class="docutils literal notranslate"><span class="pre">lake</span> <span class="pre">exe</span> <span class="pre">cache</span> <span class="pre">get</span></code> inside the <code class="docutils literal notranslate"><span class="pre">mathematics_in_lean</span></code> folder.
|
||||
(This assumes that you have not changed the contents of the <code class="docutils literal notranslate"><span class="pre">MIL</span></code> folder,
|
||||
which is why we suggested making a copy.)</p>
|
||||
<p>We intend for you to work on the exercises in the <code class="docutils literal notranslate"><span class="pre">MIL</span></code> folder while reading the
|
||||
textbook, which contains explanations, instructions, and hints.
|
||||
The text will often include examples, like this one:</p>
|
||||
<div class="highlight-lean notranslate"><div class="highlight"><pre><span></span><span class="k">#eval</span><span class="w"> </span><span class="s2">"Hello, World!"</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>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 <code class="docutils literal notranslate"><span class="pre">Lean</span> <span class="pre">InfoView</span></code> window, and if you hover
|
||||
your cursor over the <code class="docutils literal notranslate"><span class="pre">#eval</span></code> 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.</p>
|
||||
<p>This book moreover provides lots of challenging exercises for you to try.
|
||||
Don’t rush past these!
|
||||
Lean is about <em>doing</em> 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 <code class="docutils literal notranslate"><span class="pre">solutions</span></code>
|
||||
folder associated with each section.</p>
|
||||
</section>
|
||||
<section id="overview">
|
||||
<h2><span class="section-number">1.2. </span>Overview<a class="headerlink" href="#overview" title="Link to this heading"></a></h2>
|
||||
<p>Put simply, Lean is a tool for building complex expressions in a formal language
|
||||
known as <em>dependent type theory</em>.</p>
|
||||
<p id="index-0">Every expression has a <em>type</em>, and you can use the <cite>#check</cite> command to
|
||||
print it.
|
||||
Some expressions have types like <cite>ℕ</cite> or <cite>ℕ → ℕ</cite>.
|
||||
These are mathematical objects.</p>
|
||||
<div class="highlight-lean notranslate"><div class="highlight"><pre><span></span><span class="k">#check</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="bp">+</span><span class="w"> </span><span class="mi">2</span>
|
||||
|
||||
<span class="kd">def</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="o">(</span><span class="n">x</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">ℕ</span><span class="o">)</span><span class="w"> </span><span class="o">:=</span>
|
||||
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="bp">+</span><span class="w"> </span><span class="mi">3</span>
|
||||
|
||||
<span class="k">#check</span><span class="w"> </span><span class="n">f</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Some expressions have type <cite>Prop</cite>.
|
||||
These are mathematical statements.</p>
|
||||
<div class="highlight-lean notranslate"><div class="highlight"><pre><span></span><span class="k">#check</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="bp">+</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="bp">=</span><span class="w"> </span><span class="mi">4</span>
|
||||
|
||||
<span class="kd">def</span><span class="w"> </span><span class="n">FermatLastTheorem</span><span class="w"> </span><span class="o">:=</span>
|
||||
<span class="w"> </span><span class="bp">∀</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">ℕ</span><span class="o">,</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">></span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="bp">∧</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="bp">≠</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="bp">→</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="bp">^</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">+</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="bp">^</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">≠</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="bp">^</span><span class="w"> </span><span class="n">n</span>
|
||||
|
||||
<span class="k">#check</span><span class="w"> </span><span class="n">FermatLastTheorem</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Some expressions have a type, <cite>P</cite>, where <cite>P</cite> itself has type <cite>Prop</cite>.
|
||||
Such an expression is a proof of the proposition <cite>P</cite>.</p>
|
||||
<div class="highlight-lean notranslate"><div class="highlight"><pre><span></span><span class="kd">theorem</span><span class="w"> </span><span class="n">easy</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="bp">+</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="bp">=</span><span class="w"> </span><span class="mi">4</span><span class="w"> </span><span class="o">:=</span>
|
||||
<span class="w"> </span><span class="n">rfl</span>
|
||||
|
||||
<span class="k">#check</span><span class="w"> </span><span class="n">easy</span>
|
||||
|
||||
<span class="kd">theorem</span><span class="w"> </span><span class="n">hard</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">FermatLastTheorem</span><span class="w"> </span><span class="o">:=</span>
|
||||
<span class="w"> </span><span class="gr">sorry</span>
|
||||
|
||||
<span class="k">#check</span><span class="w"> </span><span class="n">hard</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>If you manage to construct an expression of type <code class="docutils literal notranslate"><span class="pre">FermatLastTheorem</span></code> and
|
||||
Lean accepts it as a term of that type,
|
||||
you have done something very impressive.
|
||||
(Using <code class="docutils literal notranslate"><span class="pre">sorry</span></code> is cheating, and Lean knows it.)
|
||||
So now you know the game.
|
||||
All that is left to learn is the rules.</p>
|
||||
<p>This book is complementary to a companion tutorial,
|
||||
<a class="reference external" href="https://lean-lang.org/theorem_proving_in_lean4/">Theorem Proving in Lean</a>,
|
||||
which provides a more thorough introduction to the underlying logical framework
|
||||
and core syntax of Lean.
|
||||
<em>Theorem Proving in Lean</em> 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 <em>start</em> button and
|
||||
figure out how to activate the potscrubber feature later,
|
||||
it makes more sense to start here and refer back to
|
||||
<em>Theorem Proving in Lean</em> as necessary.</p>
|
||||
<p>Another thing that distinguishes <em>Mathematics in Lean</em> from
|
||||
<em>Theorem Proving in Lean</em> is that here we place a much greater
|
||||
emphasis on the use of <em>tactics</em>.
|
||||
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 <em>instructions</em> as to how to construct them.
|
||||
For example, the following expression represents a proof of the fact that
|
||||
if <code class="docutils literal notranslate"><span class="pre">n</span></code> is even then so is <code class="docutils literal notranslate"><span class="pre">m</span> <span class="pre">*</span> <span class="pre">n</span></code>:</p>
|
||||
<div class="highlight-lean notranslate"><div class="highlight"><pre><span></span><span class="kd">example</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="bp">∀</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">Nat</span><span class="o">,</span><span class="w"> </span><span class="n">Even</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">→</span><span class="w"> </span><span class="n">Even</span><span class="w"> </span><span class="o">(</span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">n</span><span class="o">)</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="k">fun</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">⟨</span><span class="n">k</span><span class="o">,</span><span class="w"> </span><span class="o">(</span><span class="n">hk</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">=</span><span class="w"> </span><span class="n">k</span><span class="w"> </span><span class="bp">+</span><span class="w"> </span><span class="n">k</span><span class="o">)⟩</span><span class="w"> </span><span class="bp">↦</span>
|
||||
<span class="w"> </span><span class="k">have</span><span class="w"> </span><span class="n">hmn</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">=</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">k</span><span class="w"> </span><span class="bp">+</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">k</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="kd">by</span><span class="w"> </span><span class="n">rw</span><span class="w"> </span><span class="o">[</span><span class="n">hk</span><span class="o">,</span><span class="w"> </span><span class="n">mul_add</span><span class="o">]</span>
|
||||
<span class="w"> </span><span class="k">show</span><span class="w"> </span><span class="bp">∃</span><span class="w"> </span><span class="n">l</span><span class="o">,</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">=</span><span class="w"> </span><span class="n">l</span><span class="w"> </span><span class="bp">+</span><span class="w"> </span><span class="n">l</span><span class="w"> </span><span class="k">from</span><span class="w"> </span><span class="o">⟨</span><span class="n">_</span><span class="o">,</span><span class="w"> </span><span class="n">hmn</span><span class="o">⟩</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The <em>proof term</em> can be compressed to a single line:</p>
|
||||
<div class="highlight-lean notranslate"><div class="highlight"><pre><span></span><span class="kd">example</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="bp">∀</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">Nat</span><span class="o">,</span><span class="w"> </span><span class="n">Even</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">→</span><span class="w"> </span><span class="n">Even</span><span class="w"> </span><span class="o">(</span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">n</span><span class="o">)</span><span class="w"> </span><span class="o">:=</span>
|
||||
<span class="k">fun</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">⟨</span><span class="n">k</span><span class="o">,</span><span class="w"> </span><span class="n">hk</span><span class="o">⟩</span><span class="w"> </span><span class="bp">↦</span><span class="w"> </span><span class="o">⟨</span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">k</span><span class="o">,</span><span class="w"> </span><span class="kd">by</span><span class="w"> </span><span class="n">rw</span><span class="w"> </span><span class="o">[</span><span class="n">hk</span><span class="o">,</span><span class="w"> </span><span class="n">mul_add</span><span class="o">]⟩</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The following is, instead, a <em>tactic-style</em> proof of the same theorem, where lines
|
||||
starting with <code class="docutils literal notranslate"><span class="pre">--</span></code> are comments, hence ignored by Lean:</p>
|
||||
<div class="highlight-lean notranslate"><div class="highlight"><pre><span></span><span class="kd">example</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="bp">∀</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">Nat</span><span class="o">,</span><span class="w"> </span><span class="n">Even</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">→</span><span class="w"> </span><span class="n">Even</span><span class="w"> </span><span class="o">(</span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">n</span><span class="o">)</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="kd">by</span>
|
||||
<span class="w"> </span><span class="c1">-- Say `m` and `n` are natural numbers, and assume `n = 2 * k`.</span>
|
||||
<span class="w"> </span><span class="n">rintro</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">⟨</span><span class="n">k</span><span class="o">,</span><span class="w"> </span><span class="n">hk</span><span class="o">⟩</span>
|
||||
<span class="w"> </span><span class="c1">-- We need to prove `m * n` is twice a natural number. Let's show it's twice `m * k`.</span>
|
||||
<span class="w"> </span><span class="n">use</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">k</span>
|
||||
<span class="w"> </span><span class="c1">-- Substitute for `n`,</span>
|
||||
<span class="w"> </span><span class="n">rw</span><span class="w"> </span><span class="o">[</span><span class="n">hk</span><span class="o">]</span>
|
||||
<span class="w"> </span><span class="c1">-- and now it's obvious.</span>
|
||||
<span class="w"> </span><span class="n">ring</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>As you enter each line of such a proof in VS Code,
|
||||
Lean displays the <em>proof state</em> 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 <code class="docutils literal notranslate"><span class="pre">m</span></code> and <code class="docutils literal notranslate"><span class="pre">n</span></code>
|
||||
(we could have renamed them at that point, if we wanted to),
|
||||
and also decomposes the hypothesis <code class="docutils literal notranslate"><span class="pre">Even</span> <span class="pre">n</span></code> to
|
||||
a <code class="docutils literal notranslate"><span class="pre">k</span></code> and the assumption that <code class="docutils literal notranslate"><span class="pre">n</span> <span class="pre">=</span> <span class="pre">2</span> <span class="pre">*</span> <span class="pre">k</span></code>.
|
||||
The second line, <code class="docutils literal notranslate"><span class="pre">use</span> <span class="pre">m</span> <span class="pre">*</span> <span class="pre">k</span></code>,
|
||||
declares that we are going to show that <code class="docutils literal notranslate"><span class="pre">m</span> <span class="pre">*</span> <span class="pre">n</span></code> is even by
|
||||
showing <code class="docutils literal notranslate"><span class="pre">m</span> <span class="pre">*</span> <span class="pre">n</span> <span class="pre">=</span> <span class="pre">2</span> <span class="pre">*</span> <span class="pre">(m</span> <span class="pre">*</span> <span class="pre">k)</span></code>.
|
||||
The next line uses the <code class="docutils literal notranslate"><span class="pre">rw</span></code> tactic
|
||||
to replace <code class="docutils literal notranslate"><span class="pre">n</span></code> by <code class="docutils literal notranslate"><span class="pre">2</span> <span class="pre">*</span> <span class="pre">k</span></code> in the goal (<code class="docutils literal notranslate"><span class="pre">rw</span></code> stands for “rewrite”),
|
||||
and the <code class="docutils literal notranslate"><span class="pre">ring</span></code> tactic solves the resulting goal <code class="docutils literal notranslate"><span class="pre">m</span> <span class="pre">*</span> <span class="pre">(2</span> <span class="pre">*</span> <span class="pre">k)</span> <span class="pre">=</span> <span class="pre">2</span> <span class="pre">*</span> <span class="pre">(m</span> <span class="pre">*</span> <span class="pre">k)</span></code>.</p>
|
||||
<p>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 <code class="docutils literal notranslate"><span class="pre">by</span> <span class="pre">rw</span> <span class="pre">[hk,</span> <span class="pre">mul_add]</span></code> 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.</p>
|
||||
<p>In our example, the tactic proof can also be reduced to a one-liner:</p>
|
||||
<div class="highlight-lean notranslate"><div class="highlight"><pre><span></span><span class="kd">example</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="bp">∀</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">Nat</span><span class="o">,</span><span class="w"> </span><span class="n">Even</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">→</span><span class="w"> </span><span class="n">Even</span><span class="w"> </span><span class="o">(</span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">n</span><span class="o">)</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="kd">by</span>
|
||||
<span class="w"> </span><span class="n">rintro</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">⟨</span><span class="n">k</span><span class="o">,</span><span class="w"> </span><span class="n">hk</span><span class="o">⟩</span><span class="bp">;</span><span class="w"> </span><span class="n">use</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">k</span><span class="bp">;</span><span class="w"> </span><span class="n">rw</span><span class="w"> </span><span class="o">[</span><span class="n">hk</span><span class="o">]</span><span class="bp">;</span><span class="w"> </span><span class="n">ring</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>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.</p>
|
||||
<div class="highlight-lean notranslate"><div class="highlight"><pre><span></span><span class="kd">example</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="bp">∀</span><span class="w"> </span><span class="n">m</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">Nat</span><span class="o">,</span><span class="w"> </span><span class="n">Even</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="bp">→</span><span class="w"> </span><span class="n">Even</span><span class="w"> </span><span class="o">(</span><span class="n">m</span><span class="w"> </span><span class="bp">*</span><span class="w"> </span><span class="n">n</span><span class="o">)</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="kd">by</span>
|
||||
<span class="w"> </span><span class="n">intros</span><span class="bp">;</span><span class="w"> </span><span class="n">simp</span><span class="w"> </span><span class="o">[</span><span class="bp">*</span><span class="o">,</span><span class="w"> </span><span class="n">parity_simps</span><span class="o">]</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Another big difference between the two introductions is that
|
||||
<em>Theorem Proving in Lean</em> depends only on core Lean and its built-in
|
||||
tactics, whereas <em>Mathematics in Lean</em> is built on top of Lean’s
|
||||
powerful and ever-growing library, <em>Mathlib</em>.
|
||||
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 <a class="reference external" href="https://leanprover-community.github.io/">community</a>
|
||||
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.</p>
|
||||
<p>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
|
||||
<a class="reference external" href="https://leanprover.zulipchat.com/">Lean Zulip chat group</a> 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 <em>Mathlib</em>.</p>
|
||||
<p>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.</p>
|
||||
<p><em>Acknowledgments.</em> 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.</p>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
||||
<a href="index.html" class="btn btn-neutral float-left" title="Mathematics in Lean" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
|
||||
<a href="C02_Basics.html" class="btn btn-neutral float-right" title="2. Basics" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>© Copyright 2020-2025, Jeremy Avigad, Patrick Massot. Text licensed under CC BY 4.0.</p>
|
||||
</div>
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1455
dev/vendor/mathematics_in_lean/html/C02_Basics.html
vendored
Normal file
1455
dev/vendor/mathematics_in_lean/html/C02_Basics.html
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1876
dev/vendor/mathematics_in_lean/html/C03_Logic.html
vendored
Normal file
1876
dev/vendor/mathematics_in_lean/html/C03_Logic.html
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1164
dev/vendor/mathematics_in_lean/html/C04_Sets_and_Functions.html
vendored
Normal file
1164
dev/vendor/mathematics_in_lean/html/C04_Sets_and_Functions.html
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1403
dev/vendor/mathematics_in_lean/html/C05_Elementary_Number_Theory.html
vendored
Normal file
1403
dev/vendor/mathematics_in_lean/html/C05_Elementary_Number_Theory.html
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user