34 | Home
35 |
36 | Documentation
37 | Upstreaming dashboard
38 | File dependencies
39 | {% if site.github.is_project_page %}
40 | View on GitHub
41 | {% endif %}
42 | {% if site.show_downloads %}
43 | Download .zip
44 | Download .tar.gz
45 | {% endif %}
46 |
47 |
48 |
49 | {{ content }}
50 |
51 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/tasks.py:
--------------------------------------------------------------------------------
1 | import os
2 | import shutil
3 | import subprocess
4 | from pathlib import Path
5 | from invoke import run, task
6 | import json
7 | import re
8 |
9 | from blueprint.tasks import web, bp, print_bp, serve
10 |
11 | ROOT = Path(__file__).parent
12 | BP_DIR = ROOT/'blueprint'
13 | PROJ = 'LeanCamCombi'
14 |
15 | @task(bp, web)
16 | def all(ctx):
17 | shutil.rmtree(ROOT/'docs'/'blueprint', ignore_errors=True)
18 | shutil.copytree(ROOT/'blueprint'/'web', ROOT/'docs'/'blueprint')
19 | shutil.copy2(ROOT/'blueprint'/'print'/'print.pdf', ROOT/'docs'/'blueprint.pdf')
20 |
21 | @task(web)
22 | def html(ctx):
23 | shutil.rmtree(ROOT/'docs'/'blueprint', ignore_errors=True)
24 | shutil.copytree(ROOT/'blueprint'/'web', ROOT/'docs'/'blueprint')
25 |
26 | @task(all)
27 | def dev(ctx):
28 | """
29 | Serve the blueprint website, rebuild PDF and the website on file changes
30 | """
31 |
32 | from watchfiles import run_process, DefaultFilter
33 |
34 | def callback(changes):
35 | print('Changes detected:', changes)
36 | bp(ctx)
37 | web(ctx)
38 |
39 | run_process(BP_DIR/'src', target='inv serve', callback=callback,
40 | watch_filter=DefaultFilter(
41 | ignore_entity_patterns=(
42 | '.*\.aux$',
43 | '.*\.log$',
44 | '.*\.fls$',
45 | '.*\.fdb_latexmk$',
46 | '.*\.bbl$',
47 | '.*\.paux$',
48 | '.*\.pdf$',
49 | '.*\.out$',
50 | '.*\.blg$',
51 | '.*\.synctex.*$',
52 | )
53 | ))
54 |
55 | @task
56 | def check(ctx):
57 | """
58 | Check for broken references in blueprint to Lean declarations
59 | """
60 |
61 | broken_decls = []
62 |
63 | DECLS_FILE = ROOT/'.lake/build/doc/declarations/declaration-data.bmp'
64 | if not DECLS_FILE.exists():
65 | print('[ERROR] Declarations file not found. Please run `lake -Kenv=dev build %s:docs` first.' % PROJ)
66 | exit(1)
67 |
68 | DEP_GRAPH_FILE = BP_DIR/'web/dep_graph_document.html'
69 | if not DEP_GRAPH_FILE.exists():
70 | print('[ERROR] Dependency graph file not found. Please run `inv all` (or only `inv web`) first.')
71 | exit(1)
72 |
73 | with open(DECLS_FILE) as f:
74 | lean_decls = json.load(f)['declarations']
75 |
76 | with open(DEP_GRAPH_FILE) as f:
77 | lean_decl_regex = re.compile(r'lean_decl.*href=".*/find/#doc/([^"]+)"')
78 | for line in f:
79 | match = lean_decl_regex.search(line)
80 | if match and match.lastindex == 1:
81 | blueprint_decl = match[1]
82 | if blueprint_decl not in lean_decls:
83 | broken_decls.append(blueprint_decl)
84 |
85 | if broken_decls:
86 | print('[WARN] The following Lean declarations are referenced in the blueprint but not in Lean:\n')
87 | for decl in broken_decls:
88 | print(decl)
89 | exit(1)
90 | else:
91 | print('[OK] All Lean declarations referenced in the blueprint exist.')
92 |
--------------------------------------------------------------------------------
/LeanCamCombi/GrowthInGroups/Lecture2.lean:
--------------------------------------------------------------------------------
1 | import Mathlib.Algebra.Order.Group.Pointwise.Interval
2 | import LeanCamCombi.Mathlib.Combinatorics.Additive.ApproximateSubgroup
3 |
4 | open Fin Finset List
5 | open scoped Pointwise
6 |
7 | namespace GrowthInGroups.Lecture2
8 | variable {G : Type*} [DecidableEq G] [Group G] {A : Finset G} {k K : ℝ} {m : ℕ}
9 |
10 | lemma lemma_2_2 (U V W : Finset G) : #U * #(V⁻¹ * W) ≤ #(U * V) * #(U * W) :=
11 | ruzsa_triangle_inequality_invMul_mul_mul ..
12 |
13 | lemma lemma_2_3_2 (hA : #(A ^ 2) ≤ K * #A) : #(A⁻¹ * A) ≤ K ^ 2 * #A := by
14 | obtain rfl | hA₀ := A.eq_empty_or_nonempty
15 | · simp
16 | have : 0 ≤ K := nonneg_of_mul_nonneg_left (hA.trans' <| by positivity) (by positivity)
17 | refine le_of_mul_le_mul_left ?_ (by positivity : (0 : ℝ) < #A)
18 | calc
19 | (#A * #(A⁻¹ * A) : ℝ) ≤ #(A * A) * #(A * A) := by norm_cast; exact lemma_2_2 ..
20 | _ ≤ (K * #A) * (K * #A) := by rw [← sq A]; gcongr
21 | _ = #A * (K ^ 2 * #A) := by ring
22 |
23 | lemma lemma_2_3_1 (hA : #(A ^ 2) ≤ K * #A) : #(A * A⁻¹) ≤ K ^ 2 * #A := by
24 | obtain rfl | hA₀ := A.eq_empty_or_nonempty
25 | · simp
26 | have : 0 ≤ K := nonneg_of_mul_nonneg_left (hA.trans' <| by positivity) (by positivity)
27 | refine le_of_mul_le_mul_left ?_ (by positivity : (0 : ℝ) < #A)
28 | calc
29 | (#A * #(A * A⁻¹) : ℝ) ≤ #(A * A) * #(A * A) := by
30 | norm_cast; simpa [← mul_inv_rev] using lemma_2_2 A⁻¹ A⁻¹ A⁻¹
31 | _ ≤ (K * #A) * (K * #A) := by rw [← sq A]; gcongr
32 | _ = #A * (K ^ 2 * #A) := by ring
33 |
34 | lemma lemma_2_4_1 (hm : 3 ≤ m) (hA : #(A ^ 3) ≤ K * #A) (ε : Fin m → ℤ) (hε : ∀ i, |ε i| = 1) :
35 | #((finRange m).map fun i ↦ A ^ ε i).prod ≤ K ^ (3 * (m - 2)) * #A :=
36 | small_alternating_pow_of_small_tripling hm hA ε hε
37 |
38 | lemma lemma_2_4_2 (hm : 3 ≤ m) (hA : #(A ^ 3) ≤ K * #A) (hAsymm : A⁻¹ = A) :
39 | #(A ^ m) ≤ K ^ (m - 2) * #A := small_pow_of_small_tripling hm hA hAsymm
40 |
41 | def def_2_5 (S : Set G) (K : ℝ) : Prop := IsApproximateSubgroup K S
42 |
43 | lemma remark_2_6_1 (k : ℕ) : IsApproximateAddSubgroup 2 (.Icc (-k) k : Set ℤ) where
44 | zero_mem := by simp
45 | neg_eq_self := by simp
46 | two_nsmul_covByVAdd :=
47 | ⟨{(-k : ℤ), (k : ℤ)}, mod_cast card_le_two, by simp [two_nsmul, Set.Icc_add_Icc, Set.pair_add]⟩
48 |
49 | lemma remark_2_6_2 {ι : Type*} [Fintype ι] (k : ι → ℕ) :
50 | IsApproximateAddSubgroup (2 ^ Fintype.card ι)
51 | (Set.univ.pi fun i ↦ .Icc (-k i) (k i) : Set (ι → ℤ)) := by
52 | simpa using IsApproximateAddSubgroup.pi fun i ↦ remark_2_6_1 (k i)
53 |
54 | lemma remark_2_6_3 : IsApproximateAddSubgroup 2 (.Icc (-1) 1 : Set ℝ) where
55 | zero_mem := by simp
56 | neg_eq_self := by simp
57 | two_nsmul_covByVAdd :=
58 | ⟨{-1, 1}, mod_cast card_le_two, by simp [two_nsmul, Set.Icc_add_Icc, Set.pair_add]⟩
59 |
60 | lemma lemma_2_7 {A : Finset G} (hA₁ : 1 ∈ A) (hsymm : A⁻¹ = A) (hA : #(A ^ 3) ≤ K * #A) :
61 | IsApproximateSubgroup (K ^ 3) (A ^ 2 : Set G) := .of_small_tripling hA₁ hsymm hA
62 |
63 | lemma lemma_2_8 {A B : Finset G} (hB : B.Nonempty) (hK : #(A * B) ≤ K * #B) :
64 | ∃ F ⊆ A, #F ≤ K ∧ A ⊆ F * (B / B) := ruzsa_covering_mul hB hK
65 |
66 | end GrowthInGroups.Lecture2
67 |
--------------------------------------------------------------------------------
/lake-manifest.json:
--------------------------------------------------------------------------------
1 | {"version": "1.1.0",
2 | "packagesDir": ".lake/packages",
3 | "packages":
4 | [{"url": "https://github.com/leanprover-community/mathlib4.git",
5 | "type": "git",
6 | "subDir": null,
7 | "scope": "",
8 | "rev": "2df2f0150c275ad53cb3c90f7c98ec15a56a1a67",
9 | "name": "mathlib",
10 | "manifestFile": "lake-manifest.json",
11 | "inputRev": "v4.26.0",
12 | "inherited": false,
13 | "configFile": "lakefile.lean"},
14 | {"url": "https://github.com/leanprover-community/plausible",
15 | "type": "git",
16 | "subDir": null,
17 | "scope": "leanprover-community",
18 | "rev": "160af9e8e7d4ae448f3c92edcc5b6a8522453f11",
19 | "name": "plausible",
20 | "manifestFile": "lake-manifest.json",
21 | "inputRev": "main",
22 | "inherited": true,
23 | "configFile": "lakefile.toml"},
24 | {"url": "https://github.com/leanprover-community/LeanSearchClient",
25 | "type": "git",
26 | "subDir": null,
27 | "scope": "leanprover-community",
28 | "rev": "3591c3f664ac3719c4c86e4483e21e228707bfa2",
29 | "name": "LeanSearchClient",
30 | "manifestFile": "lake-manifest.json",
31 | "inputRev": "main",
32 | "inherited": true,
33 | "configFile": "lakefile.toml"},
34 | {"url": "https://github.com/leanprover-community/import-graph",
35 | "type": "git",
36 | "subDir": null,
37 | "scope": "leanprover-community",
38 | "rev": "e9f31324f15ead11048b1443e62c5deaddd055d2",
39 | "name": "importGraph",
40 | "manifestFile": "lake-manifest.json",
41 | "inputRev": "main",
42 | "inherited": true,
43 | "configFile": "lakefile.toml"},
44 | {"url": "https://github.com/leanprover-community/ProofWidgets4",
45 | "type": "git",
46 | "subDir": null,
47 | "scope": "leanprover-community",
48 | "rev": "b4fb2aa5290ebf61bc5f80a5375ba642f0a49192",
49 | "name": "proofwidgets",
50 | "manifestFile": "lake-manifest.json",
51 | "inputRev": "v0.0.83",
52 | "inherited": true,
53 | "configFile": "lakefile.lean"},
54 | {"url": "https://github.com/leanprover-community/aesop",
55 | "type": "git",
56 | "subDir": null,
57 | "scope": "leanprover-community",
58 | "rev": "2f6d238744c4cb07fdc91240feaf5d4221a27931",
59 | "name": "aesop",
60 | "manifestFile": "lake-manifest.json",
61 | "inputRev": "master",
62 | "inherited": true,
63 | "configFile": "lakefile.toml"},
64 | {"url": "https://github.com/leanprover-community/quote4",
65 | "type": "git",
66 | "subDir": null,
67 | "scope": "leanprover-community",
68 | "rev": "9312503909aa8e8bb392530145cc1677a6298574",
69 | "name": "Qq",
70 | "manifestFile": "lake-manifest.json",
71 | "inputRev": "master",
72 | "inherited": true,
73 | "configFile": "lakefile.toml"},
74 | {"url": "https://github.com/leanprover-community/batteries",
75 | "type": "git",
76 | "subDir": null,
77 | "scope": "leanprover-community",
78 | "rev": "24241822ef9d3e7f6a3bcc53ad136e12663db8f3",
79 | "name": "batteries",
80 | "manifestFile": "lake-manifest.json",
81 | "inputRev": "main",
82 | "inherited": true,
83 | "configFile": "lakefile.toml"},
84 | {"url": "https://github.com/leanprover/lean4-cli",
85 | "type": "git",
86 | "subDir": null,
87 | "scope": "leanprover",
88 | "rev": "933fce7e893f65969714c60cdb4bd8376786044e",
89 | "name": "Cli",
90 | "manifestFile": "lake-manifest.json",
91 | "inputRev": "v4.26.0",
92 | "inherited": true,
93 | "configFile": "lakefile.toml"}],
94 | "name": "LeanCamCombi",
95 | "lakeDir": ".lake"}
96 |
--------------------------------------------------------------------------------
/scripts/upstreaming_dashboard.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | """
4 | This script parse the aggregate json file and filters all PRs which touch some given files.
5 | """
6 |
7 | import json
8 | import os
9 | from typing import List
10 | import subprocess
11 | import json
12 | import pathlib
13 |
14 | def main():
15 | pr_file = subprocess.run(["curl", "https://raw.githubusercontent.com/leanprover-community/queueboard/refs/heads/master/processed_data/open_pr_data.json"],
16 | capture_output = True,
17 | text = True)
18 | pr_json = json.loads(pr_file.stdout)["pr_statusses"]
19 | pr_dict = {pr["number"] : pr for pr in pr_json}
20 |
21 | file_touched_pr = {}
22 | for pr in pr_dict:
23 | for file in pr_dict[pr]["files"]:
24 | pr_data = {
25 | "number" : pr,
26 | "title" : pr_dict[pr]["title"],
27 | "num_files": len(pr_dict[pr]["files"]),
28 | "is_draft": pr_dict[pr]["is_draft"]
29 | }
30 | if file not in file_touched_pr: file_touched_pr[file] = [pr_data]
31 | else: file_touched_pr[file].append(pr_data)
32 |
33 | project_files = {}
34 | for entry in pathlib.Path("LeanCamCombi").rglob("*.lean"):
35 | code = None
36 | with open(entry, 'r') as reader:
37 | code = reader.read()
38 | entry = str(entry)
39 | file = "/".join(entry.split("/")[1:])
40 | project_files[entry] = {
41 | "prs" : [] if file not in file_touched_pr else file_touched_pr[file],
42 | "num_sorries" : code.count("sorry"),
43 | "depends" : "import LeanCamCombi" in code
44 | }
45 |
46 | folder_path = "./website/_includes"
47 | if not os.path.exists(folder_path):
48 | os.makedirs(folder_path)
49 |
50 | with open(f"{folder_path}/ready_to_upstream.md", 'w+') as writer:
51 | text = ""
52 | for file_path in project_files:
53 | if project_files[file_path]["num_sorries"] > 0: continue
54 | if project_files[file_path]["depends"]: continue
55 | module_name = file_path.replace('/','.')[:-5]
56 | text += f"* [`{module_name}`](https://github.com/YaelDillies/LeanCamCombi/blob/master/{file_path}) \n"
57 | for pr in project_files[file_path]["prs"]:
58 | if pr["title"][:4] == "perf": continue
59 | if pr["is_draft"]: continue
60 |
61 | text += f" * "
62 | text += f" ["
63 | text += ''
64 | text += f" {pr['title']} #{pr['number']}](https://github.com/leanprover-community/mathlib4/pull/{pr['number']})"
65 |
66 | text +="\n"
67 | writer.write(text)
68 |
69 | with open(f"{folder_path}/easy_to_unlock.md", 'w+') as writer:
70 | text = ""
71 | for file_path in project_files:
72 | if project_files[file_path]["num_sorries"] == 0: continue
73 | if project_files[file_path]["depends"]: continue
74 | num_sorries = project_files[file_path]["num_sorries"]
75 | module_name = file_path.replace('/','.')[:-5]
76 | if num_sorries == 1:
77 | text += f"* [`{module_name}`](https://github.com/YaelDillies/LeanCamCombi/blob/master/{file_path}) {num_sorries} sorry\n"
78 | else:
79 | text += f"* [`{module_name}`](https://github.com/YaelDillies/LeanCamCombi/blob/master/{file_path}) {num_sorries} sorries\n"
80 |
81 | writer.write(text)
82 |
83 | main()
84 |
--------------------------------------------------------------------------------
/LeanCamCombi/GraphTheory/ExampleSheet2.lean:
--------------------------------------------------------------------------------
1 | /-
2 | Copyright (c) 2022 Yaël Dillies, Kexing Ying. All rights reserved.
3 | Released under Apache 2.0 license as described in the file LICENSE.
4 | Authors: Yaël Dillies, Kexing Ying
5 | -/
6 | import Mathlib.Combinatorics.Hall.Basic
7 | import Mathlib.Combinatorics.SimpleGraph.Acyclic
8 | import Mathlib.Combinatorics.SimpleGraph.Clique
9 | import Mathlib.Data.Real.Sqrt
10 | import Mathlib.SetTheory.Cardinal.Basic
11 |
12 | /-!
13 | # Graph Theory, example sheet 2
14 |
15 | Here are the statements (and hopefully soon proofs!) of the questions from the second example sheet
16 | of the Cambridge Part II course Graph Theory.
17 |
18 | If you solve a question in Lean, feel free to open a Pull Request on Github!
19 | -/
20 |
21 |
22 | /-!
23 | ### Question 1
24 |
25 | For a graph $$G$$, show that $$κ(G) ≤ fun(G) ≤ δ(G)$$.
26 | -/
27 |
28 |
29 | /-!
30 | ### Question 2
31 |
32 | Let $$G be a graph. Show that $$e(G) > {χ(G) \choose 2}$$.
33 | -/
34 |
35 |
36 | /-!
37 | ### Question 3
38 |
39 | Let $$G$$ be a $$k$$-connected graph and let $$y, x_1, \dots, x_k$$ be distinct vertices in $$G$$.
40 | Show that there exists paths $$P_1, \dots, P_k$$, where $$P_i$$ is a $$y − x_i$$ path and
41 | $$P_1, \dots, P_k$$ have no vertices in common, apart from the vertex $$y$$.
42 | -/
43 |
44 |
45 | /-!
46 | ### Question 4
47 |
48 | An independent set in a graph $$G = (V, E)$$ is a subset $$I ⊆ V$$ so that $$x ≁ y$$ for all
49 | $$x, y ∈ I$$. Let $$G = (V, E)$$ be a connected graph with $$∆(G) ≤ 3$$ and $$|V| ≥ 10$$. Show that
50 | there exists an independent set $$I ⊆ V$$ so that every odd cycle in $$G$$ intersects $$I$$.
51 | -/
52 |
53 |
54 | /-!
55 | ### Question 5
56 |
57 | Determine the chromatic polynomial of the $$n$$-cycle $$C_n$$.
58 | -/
59 |
60 |
61 | /-!
62 | ### Question 6
63 |
64 | Let $$G$$ be a graph on $$n$$ vertices, show that the coefficients of the chromatic polynomial
65 | $$P_G$$ alternate in sign. That is, if $$P_G = P_ni=0 cit
66 | i
67 | , Then cn−j > 0 for even j and cn−j 6 0 for odd j. Also
68 | show that if G has m edges and k triangles then cn−2 =
69 | m
70 | 2
71 |
72 | − k.
73 | -/
74 |
75 |
76 | /-!
77 | ### Question 7
78 |
79 | Determine $$χ(K_{n,n}$$). Determine $$χ(K_n)$$.
80 | -/
81 |
82 |
83 | /-!
84 | ### Question 8
85 |
86 | Let $$G$$ be a graph that has an orientation where the longest directed path has length $$t$$ (that
87 | is, a sequence of oriented edges $$(v_1, v_2), \dots, (v_t, v_{t + 1})$$. Then $$χ(G) ≤ t + 1$$.
88 | -/
89 |
90 |
91 | /-!
92 | ### Question 9
93 |
94 | Can $$K_{4, 4}$$ be drawn on the torus? What about $$K_{5, 5}$$?
95 | -/
96 |
97 |
98 | /-!
99 | ### Question 10
100 |
101 | Let $$G$$ be a bipartite graph with maximum degree $$∆$$. Must we have $$χ(G) = ∆(G)$$?
102 | -/
103 |
104 |
105 | /-!
106 | ### Question 11
107 |
108 | Let $$G = (V, E)$$ be a graph where $$V$$, $$E$$ are countably infinite. Show that $$χ(G) ≤ k$$ if
109 | and only if $$χ(H) ≤ k$$ for every finite subgraph $$H$$ of $$G$$.
110 | -/
111 |
112 |
113 | /-!
114 | ### Question 12
115 |
116 | For $$k > 2$$, let $$G = (V, E)$$ be a $$k$$-connected graph and let $${x_1, \dots, x_k} ⊆ V$$. Show
117 | that there exists a cycle containing each of the vertices $$x_1, \dots, x_k$$.
118 | -/
119 |
120 |
121 | /-!
122 | ### Question 13
123 |
124 | For each $$r > 2$$, construct a graph $$G$$ that does not contain a $$K_{r + 1}$$ and $$χ(G) > r$$.
125 | -/
126 |
127 |
128 | /-!
129 | ### Question 14
130 |
131 | A graph is outer-planar if it can be drawn in the plane so that all of its vertices are on the
132 | infinite face. Articulate a conjecture of the form “Let $$G$$ be a graph with $$|G| > 5$$. $$G$$ is
133 | outer-planar if and only if ...”. Prove your conjecture.
134 | -/
135 |
136 |
137 | /-!
138 | ### Question 15
139 |
140 | Show there is a triangle free graph with chromatic number $$2022$$.
141 | -/
142 |
143 |
144 | /-!
145 | ### Question 16
146 |
147 | Let $$G$$ be a triangulation (a plane graph where every face is a triangle) and let $$G◦$$ be the
148 | planar dual of $$G$$: the vertices of $$G◦$$ are the faces of $$G$$ and edges in $$G◦$$ join faces
149 | that share a boundary edge (in $$G$$). Prove that $$χ(G) ≤ 4$$ if and only if $$χ(G◦) ≤ 3$$.
150 | -/
151 |
--------------------------------------------------------------------------------
/LeanCamCombi/PlainCombi/VanDenBergKesten.lean:
--------------------------------------------------------------------------------
1 | /-
2 | Copyright (c) 2022 Yaël Dillies. All rights reserved.
3 | Released under Apache 2.0 license as described in the file LICENSE.
4 | Authors: Yaël Dillies
5 | -/
6 | import Mathlib.Data.Finset.Sups
7 | import Mathlib.Data.Fintype.Basic
8 | import Mathlib.Order.UpperLower.Basic
9 |
10 | /-!
11 | # Set family certificates
12 |
13 | This file defines the certificator of two families of sets. If we consider set families `𝒜` and `ℬ`
14 | as probabilistic events, the size of the certificator `𝒜 □ ℬ` corresponds to the probability that
15 | `𝒜` and `ℬ` occur "disjointly".
16 |
17 | ## Main declarations
18 |
19 | * `finset.certificator`: Certificator of two elements of a Boolean algebra
20 | * `finset.card_certificator_le`: The Van den Berg-Kesten-Reimer inequality: The probability that `𝒜`
21 | and `ℬ` occur "disjointly" is less than the product of their probabilities.
22 |
23 | ## References
24 |
25 | * D. Reimer, *Proof of the Van den Berg–Kesten Conjecture*
26 | -/
27 |
28 | open scoped FinsetFamily
29 |
30 | variable {α : Type*}
31 |
32 | namespace Finset
33 | section BooleanAlgebra
34 | variable [BooleanAlgebra α] (s t u : Finset α) {a : α}
35 |
36 | noncomputable def certificator : Finset α :=
37 | open scoped Classical in
38 | {a ∈ s ∩ t | ∃ x y, IsCompl x y ∧ (∀ ⦃b⦄, a ⊓ x = b ⊓ x → b ∈ s) ∧ ∀ ⦃b⦄, a ⊓ y = b ⊓ y → b ∈ t}
39 |
40 | scoped[FinsetFamily] infixl:70 " □ " => Finset.certificator
41 |
42 | variable {s t u}
43 |
44 | @[simp] lemma mem_certificator :
45 | a ∈ s □ t ↔
46 | ∃ x y, IsCompl x y ∧ (∀ ⦃b⦄, a ⊓ x = b ⊓ x → b ∈ s) ∧ ∀ ⦃b⦄, a ⊓ y = b ⊓ y → b ∈ t := by
47 | classical
48 | rw [certificator, mem_filter, and_iff_right_of_imp]
49 | rintro ⟨u, v, _, hu, hv⟩
50 | exact mem_inter.2 ⟨hu rfl, hv rfl⟩
51 |
52 | lemma certificator_subset_inter [DecidableEq α] : s □ t ⊆ s ∩ t := by
53 | unfold certificator; convert filter_subset ..
54 |
55 | open scoped Classical in
56 | lemma certificator_subset_disjSups : s □ t ⊆ s ○ t := by
57 | simp_rw [subset_iff, mem_certificator, mem_disjSups]
58 | rintro x ⟨u, v, huv, hu, hv⟩
59 | refine ⟨x ⊓ u, hu (inf_right_idem _ _).symm, x ⊓ v, hv (inf_right_idem _ _).symm,
60 | huv.disjoint.mono inf_le_right inf_le_right, ?_⟩
61 | rw [← inf_sup_left, huv.codisjoint.eq_top, inf_top_eq]
62 |
63 | variable (s t u)
64 |
65 | lemma certificator_comm : s □ t = t □ s := by
66 | ext s; rw [mem_certificator, exists_comm]; simp [isCompl_comm, and_comm]
67 |
68 | lemma IsUpperSet.certificator_eq_inter [DecidableEq α] (hs : IsUpperSet (s : Set α))
69 | (ht : IsLowerSet (t : Set α)) : s □ t = s ∩ t := by
70 | refine
71 | certificator_subset_inter.antisymm fun a ha ↦ mem_certificator.2 ⟨a, aᶜ, isCompl_compl, ?_⟩
72 | rw [mem_inter] at ha
73 | simp only [@eq_comm _ ⊥, ← sdiff_eq, inf_idem, right_eq_inf, _root_.sdiff_self, sdiff_eq_bot_iff]
74 | exact ⟨fun b hab ↦ hs hab ha.1, fun b hab ↦ ht hab ha.2⟩
75 |
76 | lemma IsLowerSet.certificator_eq_inter [DecidableEq α] (hs : IsLowerSet (s : Set α))
77 | (ht : IsUpperSet (t : Set α)) : s □ t = s ∩ t := by
78 | refine certificator_subset_inter.antisymm fun a ha ↦
79 | mem_certificator.2 ⟨aᶜ, a, isCompl_compl.symm, ?_⟩
80 | rw [mem_inter] at ha
81 | simp only [@eq_comm _ ⊥, ← sdiff_eq, inf_idem, right_eq_inf, _root_.sdiff_self, sdiff_eq_bot_iff]
82 | exact ⟨fun b hab ↦ hs hab ha.1, fun b hab ↦ ht hab ha.2⟩
83 |
84 | open scoped Classical in
85 | lemma IsUpperSet.certificator_eq_disjSups (hs : IsUpperSet (s : Set α))
86 | (ht : IsUpperSet (t : Set α)) : s □ t = s ○ t := by
87 | refine certificator_subset_disjSups.antisymm fun a ha ↦ mem_certificator.2 ?_
88 | obtain ⟨x, hx, y, hy, hxy, rfl⟩ := mem_disjSups.1 ha
89 | refine ⟨x, xᶜ, isCompl_compl, ?_⟩
90 | simp only [inf_of_le_right, le_sup_left, right_eq_inf, ← sdiff_eq, hxy.sup_sdiff_cancel_left]
91 | exact ⟨fun b hab ↦ hs hab hx, fun b hab ↦ ht (hab.trans_le sdiff_le) hy⟩
92 |
93 | end BooleanAlgebra
94 |
95 | open scoped FinsetFamily
96 |
97 | variable [DecidableEq α] [Fintype α] {𝒜 ℬ 𝒞 : Finset (Finset α)}
98 |
99 | /-- The **Van den Berg-Kesten-Reimer Inequality**: The probability that `𝒜` and `ℬ` occur
100 | "disjointly" is less than the product of their probabilities. -/
101 | lemma card_certificator_le : 2 ^ Fintype.card α * #(𝒜 □ ℬ) ≤ #𝒜 * #ℬ := sorry
102 |
103 | end Finset
104 |
--------------------------------------------------------------------------------
/LeanCamCombi/GrowthInGroups/Lecture1.lean:
--------------------------------------------------------------------------------
1 | /-
2 | Copyright (c) 2024 Yaël Dillies. All rights reserved.
3 | Released under Apache 2.0 license as described in the file LICENSE.
4 | Authors: Yaël Dillies
5 | -/
6 | import Mathlib.Analysis.SpecialFunctions.Log.Basic
7 | import Mathlib.Combinatorics.Additive.DoublingConst
8 | import Mathlib.Combinatorics.Additive.VerySmallDoubling
9 | import Mathlib.Geometry.Group.Growth.LinearLowerBound
10 | import Mathlib.GroupTheory.Nilpotent
11 | import Mathlib.LinearAlgebra.Matrix.SpecialLinearGroup
12 | import LeanCamCombi.Util
13 |
14 | /-!
15 | # Growth in Groups - Lecture 1
16 |
17 | This file contains a Lean formalisation of the statements and proofs given in lecture 1 of the ETH
18 | course Growth in Groups lectured by Simon Machado in autumn/winter 2024.
19 |
20 | ## References
21 |
22 | [Lecture notes by Simon Machado](https://sites.google.com/view/simonmachado/teaching)
23 | -/
24 |
25 | open Finset Fintype Group MulOpposite Real
26 | open scoped Combinatorics.Additive MatrixGroups Pointwise
27 |
28 | namespace GrowthInGroups.Lecture1
29 | variable {G : Type*} [Group G] [DecidableEq G] {A X : Finset G} {n : ℕ} {K : ℝ}
30 |
31 | /-- The growth of a set generating an infinite group is at least linear. -/
32 | lemma fact_1_1_1 [Infinite G] (hX₁ : 1 ∈ X) (hXgen : Subgroup.closure (X : Set G) = ⊤) (n : ℕ) :
33 | n + 1 ≤ #(X ^ n) := add_one_le_card_pow hX₁ (by simp [hXgen, Set.infinite_univ]) _
34 |
35 | /-- The growth of a set is at most exponential. -/
36 | lemma fact_1_1_2 : #(X ^ n) ≤ #X ^ n := card_pow_le
37 |
38 | variable (G) in
39 | /-- A group **has polynomial growth** if any (equivalently, all) of its finite symmetric sets
40 | has polynomial growth. -/
41 | def HasPolynomialGrowth : Prop :=
42 | ∃ X : Finset G, X⁻¹ = X ∧ Subgroup.closure (X : Set G) = ⊤ ∧ ∃ d, ∀ n ≥ 2, #(X ^ n) ≤ n ^ d
43 |
44 | /-- **Gromov's theorem**.
45 |
46 | A group has polynomial growth iff it's virtually nilpotent. -/
47 | @[nolint unusedArguments]
48 | lemma theorem_1_2 [Group.FG G] : HasPolynomialGrowth G ↔ IsVirtuallyNilpotent G := showcased
49 |
50 | lemma fact_1_3 [Fintype G] (hn : X ^ n = univ) : log (card G) / log #X ≤ n := by
51 | obtain rfl | hX := X.eq_empty_or_nonempty
52 | · simp
53 | refine div_le_of_le_mul₀ (log_nonneg <| by simpa) (by positivity) ?_
54 | rw [← log_pow, ← Nat.cast_pow, ← card_univ, ← hn]
55 | gcongr
56 | exact card_pow_le
57 |
58 | /-- **Babai's conjecture**.
59 |
60 | For all finite sets `X` generating a simple group `G`, there exists a universal polynomial
61 | (in `log |G|`) upper bound to the number of steps `X` takes to generate `G`. -/
62 | lemma conjecture_1_4 :
63 | ∃ Cᵤ ≥ 0, ∃ dᵤ ≥ 0,
64 | ∀ {G} [Group G] [IsSimpleGroup G] [Fintype G] [DecidableEq G] (X : Finset G)
65 | (_hX₁ : 1 ∈ X) (_hXsymm : X⁻¹ = X) (_hXclos : Subgroup.closure (X : Set G) = ⊤),
66 | ∃ m : ℕ, m ≤ Cᵤ * log (card G) ^ dᵤ ∧ X ^ m = univ := showcased
67 |
68 | -- Not even trying to state the collar lemma
69 |
70 | open scoped Classical in
71 | /-- An auxiliary lemma used in the proof of the collar theorem. -/
72 | lemma proposition_1_7 :
73 | ∃ ε > 0, ∀ X : Finset SL(2, ℝ), #(X ^ 2) ≤ 1000 * #X → (∀ M ∈ X, ∀ i j, |M i j| ≤ ε) →
74 | ∃ A : Subgroup SL(2, ℝ), IsMulCommutative A ∧
75 | ∃ a : Fin 10000000 → SL(2, ℝ), (X : Set SL(2, ℝ)) ⊆ ⋃ i, a i • A := showcased
76 |
77 | /-- The **Breuillard-Green-Tao theorem**. -/
78 | lemma theorem_1_8 :
79 | ∃ C > 0, ∀ {G} [Group G] [DecidableEq G] (A : Finset G) (_hA : σₘ[A] ≤ K),
80 | ∃ (N : Subgroup G) (D : Subgroup N) (_hD : D.Normal),
81 | upperCentralSeries (N⧸ D) C = ⊤ ∧ ((↑) '' (D : Set N) : Set G) ⊆ (A / A) ^ 4 ∧
82 | ∃ a : Fin C → G, (A : Set G) ⊆ ⋃ i, a i • N := showcased
83 |
84 | open scoped Classical in
85 | /-- The **product theorem**, due Breuillard-Green-Tao and Pyber-Szabo.
86 |
87 | A set in `SLₙ(k)` either has big tripling or is very big. In other words, there is no small
88 | tripling, except in trivial situations. -/
89 | lemma theorem_1_9 :
90 | ∃ δ > 0, ∃ ε > 0,
91 | ∀ k [Field k] [Fintype k] [DecidableEq k] (A : Finset SL(n, k))
92 | (_hAgen : Subgroup.closure (A : Set SL(n, k)) = ⊤),
93 | #A ^ (1 + δ) ≤ #(A ^ 3) ∨ card SL(n, k) ^ (1 - ε) ≤ #A := proved_later
94 |
95 | open MulAction in
96 | open scoped RightActions in
97 | /-- A non-empty set `A` with no doubling is the coset of a subgroup `H`.
98 |
99 | Precisely, `H` can be taken to be the stabiliser of `A` and `A` then is both a left and right coset
100 | of `H`. -/
101 | lemma fact_1_10 (hA : #(A * A) ≤ #A) :
102 | ∃ H : Subgroup G, ∀ a ∈ A, a •> (H : Set G) = A ∧ (H : Set G) <• a = A :=
103 | ⟨stabilizer G A, fun _a ha ↦
104 | ⟨smul_stabilizer_of_no_doubling hA ha, op_smul_stabilizer_of_no_doubling hA ha⟩⟩
105 |
106 | open scoped Classical RightActions in
107 | /-- A set `A` of tripling strictly less than three halves can be contained in a coset of a subgroup
108 | `H` of size strictly `|H| < 3/2 |A|`.
109 |
110 | One can furthermore arrange for `A` to lie in the centraliser of `H`. -/
111 | lemma lemma_1_11 (hA : #(A * A) < (3 / 2 : ℚ) * #A) :
112 | ∃ (H : Subgroup G) (_ : Fintype H),
113 | (card H : ℚ≥0) < 3 / 2 * #A ∧ ∀ a ∈ A, (A : Set G) ⊆ a • H ∧ a • (H : Set G) = H <• a :=
114 | doubling_lt_three_halves hA
115 |
116 | end GrowthInGroups.Lecture1
117 |
--------------------------------------------------------------------------------
/LeanCamCombi/Mathlib/Probability/Distributions/Bernoulli.lean:
--------------------------------------------------------------------------------
1 | /-
2 | Copyright (c) 2025 Yaël Dillies. All rights reserved.
3 | Released under Apache 2.0 license as described in the file LICENSE.
4 | Authors: Yaël Dillies
5 | -/
6 | import LeanCamCombi.Mathlib.Probability.HasLaw
7 | import Mathlib.Probability.IdentDistrib
8 | import Mathlib.Probability.ProductMeasure
9 |
10 | /-!
11 | # Bernoulli random variables
12 |
13 | This file defines the binomial random distribution on a set. For a set `u : Set ι` and `p` between
14 | `0` and `1`, this is the measure on `Set ι` such that each `i ∈ u` belongs to the random set with
15 | probability `p`, and each `i ∉ u` doesn't belong to it.
16 |
17 | ## Notation
18 |
19 | `Ber(u, p)` is the product of `p`-Bernoulli distributions on `u`.
20 |
21 | ## TODO
22 |
23 | Add the characteristic predicate for a random variable to follow the Bernoulli distribution.
24 | -/
25 |
26 | open MeasureTheory Measure unitInterval
27 | open scoped Finset
28 |
29 | namespace ProbabilityTheory
30 | variable {ι Ω : Type*} {m : MeasurableSpace Ω} {X Y : Ω → Set ι} {s u : Set ι} {i j : ι} {p q : I}
31 | {P : Measure Ω}
32 |
33 | variable (u p) in
34 | /-- The binomial distribution with parameter `p` on the set `u : Set V` is the measure on `Set V`
35 | such that each element of `u` is taken with probability `p`, and the elements outside of `u` are
36 | never taken. -/
37 | noncomputable def bernoulliOn : Measure (Set ι) :=
38 | .comap (fun s i ↦ i ∈ s) <| infinitePi fun i ↦
39 | toNNReal p • dirac (i ∈ u) + toNNReal (σ p) • dirac False
40 |
41 | @[inherit_doc] scoped notation "Ber(" u ", " p ")" => bernoulliOn u p
42 |
43 | instance : IsProbabilityMeasure Ber(u, p) :=
44 | MeasurableEquiv.setOf.symm.measurableEmbedding.isProbabilityMeasure_comap <| .of_forall fun P ↦
45 | ⟨{a | P a}, rfl⟩
46 |
47 | variable (u p) in
48 | lemma bernoulliOn_eq_map :
49 | Ber(u, p) = .map (fun p ↦ {i | p i})
50 | (infinitePi fun i ↦ toNNReal p • dirac (i ∈ u) + toNNReal (σ p) • dirac False) :=
51 | MeasurableEquiv.setOf.comap_symm
52 |
53 | lemma bernoulliOn_apply (S : Set (Set ι)) :
54 | Ber(u, p) S = (infinitePi fun a ↦ toNNReal p • dirac (a ∈ u) + toNNReal (σ p) • dirac False)
55 | ((fun t a ↦ a ∈ t) '' S) := by
56 | convert MeasurableEquiv.setOf.symm.measurableEmbedding.comap_apply ..
57 |
58 | lemma bernoulliOn_apply' (S : Set (Set ι)) :
59 | Ber(u, p) S = (infinitePi fun a ↦ toNNReal p • dirac (a ∈ u) + toNNReal (σ p) • dirac False)
60 | ((fun p ↦ {a | p a}) ⁻¹' S) := by
61 | convert MeasurableEquiv.setOf.symm.comap_apply ..
62 |
63 | variable (u) in
64 | @[simp] lemma bernoulliOn_zero : Ber(u, 0) = dirac ∅ := by simp [bernoulliOn_eq_map]
65 |
66 | variable (u) in
67 | @[simp] lemma bernoulliOn_one : Ber(u, 1) = dirac u := by simp [bernoulliOn_eq_map]
68 |
69 | section Countable
70 | variable [Countable ι]
71 |
72 | -- TODO: Does this hold if `ι` isn't countable? Note: the current proof only needs `u` cocountable,
73 | -- but we don't bother doing this minigeneralisation.
74 | lemma bernoulliOn_ae_subset : ∀ᵐ s ∂Ber(u, p), s ⊆ u := by
75 | classical
76 | change _ = _
77 | simp only [Set.compl_setOf, Set.not_subset_iff_exists_mem_notMem, Set.setOf_exists, Set.setOf_and,
78 | measure_iUnion_null_iff]
79 | rintro a
80 | by_cases ha : a ∈ u
81 | · simp [*]
82 | calc
83 | Ber(u, p) ({s | a ∈ s} ∩ {s | a ∉ u})
84 | _ = Ber(u, p) {s | a ∈ s} := by simp [ha]
85 | _ = infinitePi (fun a ↦ toNNReal p • dirac (a ∈ u) + toNNReal (σ p) • dirac False)
86 | (cylinder {a} {fun _ ↦ True}) := by
87 | rw [bernoulliOn_apply']
88 | congr!
89 | ext
90 | simp [funext_iff]
91 | _ = 0 := by simp [infinitePi_cylinder _ (.singleton _), ha]
92 |
93 | end Countable
94 |
95 | variable (u p) in
96 | -- TODO: Generalise to countable `ι` and finite `u`. See the TODO on `infinitePi_pi`.
97 | @[simp] lemma bernoulliOn_singleton [Finite ι] (hsu : s ⊆ u) :
98 | Ber(u, p) {s} = toNNReal p ^ s.ncard * toNNReal (σ p) ^ (u \ s).ncard := by
99 | classical
100 | cases nonempty_fintype ι
101 | lift u to Finset ι using Set.toFinite _
102 | calc
103 | Ber(u, p) {s}
104 | _ = ∏ i, ((if i ∈ u ↔ i ∈ s then (toNNReal p : ENNReal) else 0) +
105 | if i ∈ s then 0 else (toNNReal (σ p) : ENNReal)) := by
106 | simp [bernoulliOn_apply, Set.image_singleton, Set.indicator]
107 | simp [ENNReal.smul_def]
108 | _ = ∏ i ∈ u, (if i ∈ s then (toNNReal p : ENNReal) else (toNNReal (σ p) : ENNReal)) := by
109 | rw [← Finset.prod_subset u.subset_univ (by
110 | simpa +contextual [ite_add_ite, ← ENNReal.coe_add] using fun _ ↦ mt (@hsu _))]
111 | simp +contextual [ite_add_ite]
112 | _ = toNNReal p ^ s.ncard * toNNReal (σ p) ^ (↑u \ s).ncard := by
113 | simp [Finset.prod_ite, ← Set.ncard_coe_finset, Set.setOf_and,
114 | Set.inter_eq_right.2 hsu, ← Set.compl_setOf, Set.diff_eq_compl_inter, Set.inter_comm]
115 |
116 | /-! ### Bernoulli random variables -/
117 |
118 | variable (X u p P) in
119 | /-- A random variable `X : Ω → Set ι` is `p`-bernoulli on a set `u : Set ι` if its distribution is
120 | the product over `u` of `p`-bernoulli random variables. -/
121 | abbrev IsBernoulliOn : Prop := HasLaw X Ber(u, p) P
122 |
123 | lemma isBernoulliOn_congr (hXY : X =ᵐ[P] Y) : IsBernoulliOn X u p P ↔ IsBernoulliOn Y u p P :=
124 | hasLaw_congr hXY
125 |
126 | lemma IsBernoulliOn.identDistrib_mem (hX : IsBernoulliOn X u p P) (hi : i ∈ u) (hj : j ∈ u) :
127 | IdentDistrib (fun ω ↦ i ∈ X ω) (fun ω ↦ j ∈ X ω) P P where
128 | aemeasurable_fst := by fun_prop
129 | aemeasurable_snd := by fun_prop
130 | map_eq := sorry
131 |
132 | lemma IsBernoulliOn.iIndepFun_mem (hX : IsBernoulliOn X u p P) :
133 | iIndepFun (fun i ω ↦ i ∈ X ω) P := sorry
134 |
135 | lemma IsBernoulliOn.sdiff (hX : IsBernoulliOn X u p P) :
136 | IsBernoulliOn (fun ω ↦ u \ X ω) u (σ p) P where
137 | map_eq := sorry
138 | aemeasurable := sorry
139 |
140 | lemma IsBernoulliOn.inter (hX : IsBernoulliOn X u p P) (hY : IsBernoulliOn Y u q P) :
141 | IsBernoulliOn (fun ω ↦ X ω ∩ Y ω) u (p * q) P where
142 | map_eq := sorry
143 | aemeasurable := sorry
144 |
145 | variable [Countable ι]
146 |
147 | lemma IsBernoulliOn.ae_subset (hX : IsBernoulliOn X u p P) : ∀ᵐ ω ∂P, X ω ⊆ u :=
148 | (hX.ae_iff sorry).2 bernoulliOn_ae_subset
149 |
150 | lemma IsBernoulliOn.union (hX : IsBernoulliOn X u p P) (hY : IsBernoulliOn Y u q P) :
151 | IsBernoulliOn (fun ω ↦ X ω ∪ Y ω) u (σ <| σ p * σ q) P := by
152 | convert (hX.sdiff.inter hY.sdiff).sdiff using 0
153 | refine isBernoulliOn_congr ?_
154 | filter_upwards [hX.ae_subset, hY.ae_subset] with ω hXω hYω
155 | rw [Set.diff_inter, Set.diff_diff_cancel_left hXω, Set.diff_diff_cancel_left hYω]
156 |
157 | end ProbabilityTheory
158 |
--------------------------------------------------------------------------------
/LeanCamCombi/Mathlib/Probability/Combinatorics/BinomialRandomGraph/Defs.lean:
--------------------------------------------------------------------------------
1 | /-
2 | Copyright (c) 2025 Yaël Dillies. All rights reserved.
3 | Released under Apache 2.0 license as described in the file LICENSE.
4 | Authors: Yaël Dillies
5 | -/
6 | import LeanCamCombi.Mathlib.Probability.Distributions.Bernoulli
7 | import Mathlib.Combinatorics.SimpleGraph.Basic
8 | import Mathlib.Data.Sym.Card
9 |
10 | /-!
11 | # Binomial random graphs
12 |
13 | This file defines the distribution of binomial random graphs.
14 | -/
15 |
16 | open MeasureTheory Measure ProbabilityTheory unitInterval Sym2
17 | open scoped Finset
18 |
19 | namespace SimpleGraph
20 | variable {V Ω : Type*} {m : MeasurableSpace Ω} {G H : Ω → SimpleGraph V} {e₁ e₂ : Sym2 V} {p q : I}
21 | {P : Measure Ω}
22 |
23 | /-!
24 | ### Sigma-algebra on simple graphs
25 |
26 | In this section, we pull back the sigma-algebra on `V → V → Prop` to a sigma-algebra on
27 | `SimpleGraph V` and prove that common operations are measurable.
28 |
29 | #### TODO
30 |
31 | This could move to an earlier file once/if we need this sigma-algebra in other contexts.
32 |
33 | ## Tags
34 |
35 | Erdős-Rényi graph, Erdős-Renyi graph, Erdös-Rényi graph, Erdös-Renyi graph, Erdos-Rényi graph,
36 | Erdos-Renyi graph
37 | -/
38 |
39 | instance : MeasurableSpace (SimpleGraph V) := .comap Adj inferInstance
40 |
41 | /-- A simple graph-valued map is measurable iff all induced adjacency maps are measurable. -/
42 | lemma measurable_iff_adj {Ω : Type*} {m : MeasurableSpace Ω} {G : Ω → SimpleGraph V} :
43 | Measurable G ↔ ∀ u v, Measurable fun ω ↦ (G ω).Adj u v := by
44 | simp [measurable_comap_iff, measurable_pi_iff]
45 |
46 | @[fun_prop]
47 | lemma measurable_adj : Measurable (Adj : SimpleGraph V → V → V → Prop) := comap_measurable _
48 |
49 | @[fun_prop]
50 | lemma measurable_edgeSet : Measurable (edgeSet : SimpleGraph V → Set (Sym2 V)) :=
51 | measurable_set_iff.2 <| by rintro ⟨u, v⟩; simp only [mem_edgeSet]; fun_prop
52 |
53 | set_option linter.flexible false in
54 | @[simp, fun_prop]
55 | lemma measurable_fromEdgeSet : Measurable (fromEdgeSet : Set (Sym2 V) → SimpleGraph V) := by
56 | simp [measurable_iff_adj]; fun_prop
57 |
58 | lemma measurableEmbedding_edgeSet [Countable V] :
59 | MeasurableEmbedding (edgeSet : SimpleGraph V → Set (Sym2 V)) where
60 | injective := edgeSet_injective
61 | measurable := measurable_edgeSet
62 | measurableSet_image' s hs := by
63 | simp only [← measurable_mem, Set.mem_image, edgeSet_eq_iff, ↓existsAndEq, true_and,
64 | Set.disjoint_right]
65 | refine .and (hs.mem.comp measurable_fromEdgeSet) <| .forall fun e ↦ .imp ?_ ?_ <;> fun_prop
66 |
67 | /-!
68 | ### Distribution of binomial random graphs
69 |
70 | In this section, we construct the binomial distribution with parameter `p` on simple graphs with
71 | vertices `V`. This is the law `G(V, p)` of binomial random graphs with probability `p`.
72 | -/
73 |
74 | variable (V p) in
75 | /-- The binomial distribution with parameter `p` on simple graphs with vertices `V`. -/
76 | @[expose]
77 | noncomputable def binomialRandom : Measure (SimpleGraph V) := Ber(diagSetᶜ, p).comap edgeSet
78 |
79 | @[inherit_doc] scoped notation "G(" V ", " p ")" => binomialRandom V p
80 |
81 | section Countable
82 | variable [Countable V]
83 |
84 | variable (V p) in
85 | lemma binomialRandom_eq_map : G(V, p) = map fromEdgeSet Ber(diagSetᶜ, p) := by
86 | refine (map_eq_comap measurable_fromEdgeSet measurableEmbedding_edgeSet ?_
87 | fromEdgeSet_edgeSet).symm
88 | filter_upwards [bernoulliOn_ae_subset] with S hS
89 | refine ⟨fromEdgeSet S, ?_⟩
90 | simpa [Sym2.diagSet_eq_setOf_isDiag, ← Set.compl_setOf, Set.subset_compl_iff_disjoint_right]
91 | using hS
92 |
93 | lemma isBernoulliOn_edgeSet_binomialRandom : IsBernoulliOn edgeSet diagSetᶜ p G(V, p) where
94 | map_eq := by
95 | rw [binomialRandom_eq_map, map_map (by fun_prop) (by fun_prop), Measure.map_congr,
96 | Measure.map_id]
97 | filter_upwards [bernoulliOn_ae_subset] with S hS
98 | simpa [Set.subset_compl_iff_disjoint_right] using hS
99 |
100 | variable (p) in
101 | lemma binomialRandom_apply' (S : Set (SimpleGraph V)) :
102 | G(V, p) S = Ber(diagSetᶜ, p) (edgeSet '' S) := by
103 | rw [binomialRandom, measurableEmbedding_edgeSet.comap_apply]
104 |
105 | variable (p) in
106 | lemma binomialRandom_apply (S : Set (SimpleGraph V)) :
107 | G(V, p) S = (infinitePi fun e : Sym2 V ↦
108 | toNNReal p • .dirac (¬ e.IsDiag) + toNNReal (σ p) • .dirac False)
109 | ((fun G e ↦ e ∈ G.edgeSet) '' S) := by
110 | simp [binomialRandom_apply', bernoulliOn_apply, ← Set.image_comp]
111 |
112 | instance : IsProbabilityMeasure G(V, p) := by
113 | refine measurableEmbedding_edgeSet.isProbabilityMeasure_comap ?_
114 | filter_upwards [bernoulliOn_ae_subset] with s hs
115 | refine ⟨.fromEdgeSet s, ?_⟩
116 | simpa [Sym2.diagSet_eq_setOf_isDiag, ← Set.disjoint_compl_right_iff_subset, ← Set.compl_setOf]
117 | using hs
118 |
119 | variable (V) in
120 | @[simp] lemma binomialRandom_zero : G(V, 0) = dirac ⊥ := by simp [binomialRandom_eq_map]
121 |
122 | variable (V) in
123 | @[simp] lemma binomialRandom_one : G(V, 1) = dirac ⊤ := by simp [binomialRandom_eq_map]
124 |
125 | end Countable
126 |
127 | variable (p) in
128 | @[simp] lemma binomialRandom_singleton [Finite V] (G : SimpleGraph V) :
129 | G(V, p) {G} = toNNReal p ^ G.edgeSet.ncard *
130 | toNNReal (σ p) ^ ((Nat.card V).choose 2 - G.edgeSet.ncard) := by
131 | classical
132 | cases nonempty_fintype V
133 | simp only [binomialRandom, measurableEmbedding_edgeSet.comap_apply, Set.image_singleton,
134 | edgeSet_subset_setOf_not_isDiag, bernoulliOn_singleton]
135 | rw [Set.ncard_diff (edgeSet_subset_setOf_not_isDiag _)]
136 | congr!
137 | rw [Nat.card_eq_fintype_card, ← Sym2.card_subtype_not_diag, Fintype.card_eq_nat_card,
138 | ← Nat.card_coe_set_eq]
139 | simp [diagSet_compl_eq_setOf_not_isDiag]
140 |
141 | /-! ### Binomial random graphs -/
142 |
143 | variable (G p P) in
144 | /-- A random variable `G : Ω → Set ι` is `p`-bernoulli on a set `u : Set ι` if its distribution is
145 | the product over `u` of `p`-bernoulli random variables. -/
146 | abbrev IsBinomialRandom : Prop := HasLaw G G(V, p) P
147 |
148 | lemma isBinomialRandom_congr (hGH : G =ᵐ[P] H) : IsBinomialRandom G p P ↔ IsBinomialRandom H p P :=
149 | hasLaw_congr hGH
150 |
151 | lemma IsBinomialRandom.identDistrib_mem_edgeSet (hG : IsBinomialRandom G p P) :
152 | IdentDistrib (fun ω ↦ e₁ ∈ (G ω).edgeSet) (fun ω ↦ e₂ ∈ (G ω).edgeSet) P P := sorry
153 |
154 | lemma IsBinomialRandom.iIndepFun_mem_edgeSet (hG : IsBinomialRandom G p P) :
155 | iIndepFun (fun e ω ↦ e ∈ (G ω).edgeSet) P := sorry
156 |
157 | lemma IsBinomialRandom.compl (hG : IsBinomialRandom G p P) :
158 | IsBinomialRandom (fun ω ↦ (G ω)ᶜ) (σ p) P where
159 | map_eq := sorry
160 | aemeasurable := sorry
161 |
162 | lemma IsBinomialRandom.inf (hG : IsBinomialRandom G p P) (hY : IsBinomialRandom H q P) :
163 | IsBinomialRandom (fun ω ↦ G ω ⊓ H ω) (p * q) P where
164 | map_eq := sorry
165 | aemeasurable := sorry
166 |
167 | variable [Countable V]
168 |
169 | lemma IsBinomialRandom.isBernoulliOn_edgeSet (hG : IsBinomialRandom G p P) :
170 | IsBernoulliOn (fun ω ↦ (G ω).edgeSet) diagSetᶜ p P :=
171 | isBernoulliOn_edgeSet_binomialRandom.comp hG
172 |
173 | lemma IsBinomialRandom.sup (hG : IsBinomialRandom G p P) (hY : IsBinomialRandom H q P) :
174 | IsBinomialRandom (fun ω ↦ G ω ⊔ H ω) (σ <| σ p * σ q) P where
175 | map_eq := sorry
176 | aemeasurable := sorry
177 |
178 | end SimpleGraph
179 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cambridge combinatorics in Lean
2 |
3 | [](https://github.com/YaelDillies/LeanCamCombi/actions/workflows/push.yml)
4 | [](https://gitpod.io/#https://github.com/YaelDillies/LeanCamCombi)
5 |
6 | This repository aims at formalising the mathematics courses relevant to combinatorics that are lectured in Cambridge, UK.
7 |
8 | ## What is formalisation?
9 |
10 | The purpose of this repository is to *digitise* some mathematical definitions, theorem statements and theorem proofs. Digitisation, or formalisation, is a process where the source material, typically a mathematical textbook or a PDF file is transformed into definitions in a target system consisting of a computer implementation of a logical theory (such as set theory or type theory).
11 |
12 | ### The source
13 |
14 | The definitions, theorems and proofs in this repository are (mostly) taken from six Cambridge courses, as well as a course from ETH Zürich:
15 | * Part IV Connections between Model Theory and Combinatorics, Lent 2019, lectured by Julia Wolf
16 | * Part II Graph Theory, Michaelmas 2022, lectured by Julian Sahasrabudhe
17 | * Part III Combinatorics, Michaelmas 2022 & [Michaelmas 2023](https://github.com/YaelDillies/maths-notes/blob/master/combinatorics.pdf), lectured by Béla Bollobás
18 | * Part III Extremal and Probabilistic Combinatorics, Michaelmas 2023, lectured by Julian Sahasrabudhe
19 | * Part III [Ramsey Theory on Graphs, Michaelmas 2024](https://github.com/YaelDillies/maths-notes/blob/master/ramsey_theory.pdf), lectured by Julian Sahasrabudhe
20 | * Part III [Additive Combinatorics, Lent 2024](https://github.com/YaelDillies/maths-notes/blob/master/additive_combinatorics.pdf), lectured by Julia Wolf
21 | * ETH Math-D [Growth in Groups, Winter 2024](https://sites.google.com/view/simonmachado/teaching), lectured by Simon Machado
22 |
23 | ### The target
24 |
25 | The formal system which we are using as a target is [Lean 4](https://lean-lang.org). Lean is a dependently typed theorem prover and programming language based on the Calculus of Inductive Constructions. It is being developed at the [Lean Focused Research Organization](https://lean-fro.org) by Leonardo de Moura and his team.
26 |
27 | Our project is backed by [mathlib](https://leanprover-community.github.io), the major classical maths library written in Lean 4.
28 |
29 | ## Content
30 |
31 | The Lean code is located within the `LeanCamCombi` folder. Within it, one can find:
32 | * One subfolder for each course, containing **formal lecture transcripts** in the files named `Lecture1`, `Lecture2`, etc... and **formal example sheet translations** in the files named `ExampleSheet1`, `ExampleSheet2`, etc... We follow the mathlib philosophy of aiming for the most general result within reach. This means that not all proofs follow the lecture notes, and might instead derive a result proved in the lectures from a general theorem. Those general theorems and prerequisite lemmas are proved in other folders. Read below.
33 | * A `Mathlib` subfolder for the **prerequisites** to be upstreamed to mathlib. Lemmas that belong in an existing mathlib file `Mathlib.X` will be located in `LeanCamCombi.Mathlib.X`. We aim to preserve the property that `LeanCamCombi.Mathlib.X` only imports `Mathlib.X` and files of the form `LeanCamCombi.Mathlib.Y` where `Mathlib.X` (transitively) imports `Mathlib.Y`. Prerequisites that do not belong in any existing mathlib file are placed in subtheory folders. See below.
34 | * One folder for each **theory development**. The formal lecture transcripts only contain what was stated in the lectures, but sometimes it makes sense for a theory to be developed as a whole before being incorporated by the prerequisites or imported in the formal lecture transcripts.
35 | * An `Archive` subfolder for **archived results**. It sometimes happens in mathlib that a long argument gets replaced by a shorter one, with a different proof. When the long argument was proved in a lecture, we salvage it to `LeanCamCombi` for conservation purposes.
36 |
37 | ### Content under development
38 |
39 | The following topics are under active development in LeanCamCombi.
40 |
41 | * The Erdős-Rényi model for random graphs, aka binomial random graph
42 | * The Littlewood-Offord problem
43 | * The van den Berg-Kesten-Reimer inequality
44 | * Approximate subgroups
45 | * Model theoretic stability and its relation to additive combinatorics
46 |
47 | See the [upstreaming dashboard](https://yaeldillies.github.io/LeanCamCombi/upstreaming) for more information.
48 |
49 | ### Current content
50 |
51 | The following topics are covered in LeanCamCombi and could be upstreamed to Mathlib.
52 |
53 | * Kneser's addition theorem
54 | * The Sylvester-Chvatal theorem
55 | * Containment of graphs
56 |
57 | See the [upstreaming dashboard](https://yaeldillies.github.io/LeanCamCombi/upstreaming) for more information.
58 |
59 | The following topics are archived because they are already covered by mathlib, but nevertheless display interesting proofs:
60 | * The Cauchy-Davenport theorem for `ℤ/pℤ` as a corollary of Kneser's theorem.
61 |
62 | ### Past content
63 |
64 | The following topics have been upstreamed to mathlib and no longer live in LeanCamCombi.
65 |
66 | * The Ahlswede-Zhang inequality
67 | * The four functions theorem and related discrete correlation inequalities: FKG inequality, Holley inequality, Daykin inequality, Marica-Schönheim inequality
68 | * The Marica-Schönheim proof of the squarefree special case of Graham's conjecture
69 | * The Cauchy-Davenport theorem for general groups, and also for linearly ordered cancellative semigroup
70 | * The Erdős-Ginzburg-Ziv theorem
71 | * Chevalley's theorem about constructible sets with and without a complexity bound
72 |
73 | ## Interacting with the project
74 |
75 | ### Getting the project
76 |
77 | To build the Lean files of this project, you need to have a working version of Lean.
78 | See [the installation instructions](https://leanprover-community.github.io/get_started.html) (under Regular install).
79 | Alternatively, click on the button below to open a Gitpod workspace containing the project.
80 |
81 | [](https://gitpod.io/#https://github.com/YaelDillies/LeanAPAP)
82 |
83 | In either case, run `lake exe cache get` and then `lake build` to build the project.
84 |
85 | ### Browsing the project
86 |
87 | With the project opened in VScode, you are all set to start exploring the code. There are two pieces of functionality that help a lot when browsing through Lean code:
88 |
89 | * "Go to definition": If you right-click on a name of a definition or lemma (such as `IsBinomialRandomGraph`), then you can choose "Go to definition" from the menu, and you will be taken to the relevant location in the source files. This also works by `Ctrl`-clicking on the name.
90 | * "Goal view": in the event that you would like to read a *proof*, you can step through the proof line-by-line, and see the internals of Lean's "brain" in the Goal window. If the Goal window is not open, you can open it by clicking on the forall icon in the top right hand corner.
91 |
92 | ### Contributing
93 |
94 | **This project is open to contribution**. You are in fact encouraged to have a look at the example sheet translations and try your hand at one of the problems. If you manage to prove one of them, please open a PR!
95 |
96 | If you want to contribute a theorem or theory development, please open a PR! Note however that the standard of code is pretty high and that is not because you have formalised a concept/proved a theorem that it can be included into LeanCamCombi as is. Nonetheless I am willing to review your code and put it in shape for incorporation.
97 |
--------------------------------------------------------------------------------
/website/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | activesupport (6.0.5)
5 | concurrent-ruby (~> 1.0, >= 1.0.2)
6 | i18n (>= 0.7, < 2)
7 | minitest (~> 5.1)
8 | tzinfo (~> 1.1)
9 | zeitwerk (~> 2.2, >= 2.2.2)
10 | addressable (2.8.0)
11 | public_suffix (>= 2.0.2, < 5.0)
12 | coffee-script (2.4.1)
13 | coffee-script-source
14 | execjs
15 | coffee-script-source (1.11.1)
16 | colorator (1.1.0)
17 | commonmarker (0.23.4)
18 | concurrent-ruby (1.1.10)
19 | dnsruby (1.61.9)
20 | simpleidn (~> 0.1)
21 | em-websocket (0.5.3)
22 | eventmachine (>= 0.12.9)
23 | http_parser.rb (~> 0)
24 | ethon (0.15.0)
25 | ffi (>= 1.15.0)
26 | eventmachine (1.2.7)
27 | execjs (2.8.1)
28 | faraday (1.10.0)
29 | faraday-em_http (~> 1.0)
30 | faraday-em_synchrony (~> 1.0)
31 | faraday-excon (~> 1.1)
32 | faraday-httpclient (~> 1.0)
33 | faraday-multipart (~> 1.0)
34 | faraday-net_http (~> 1.0)
35 | faraday-net_http_persistent (~> 1.0)
36 | faraday-patron (~> 1.0)
37 | faraday-rack (~> 1.0)
38 | faraday-retry (~> 1.0)
39 | ruby2_keywords (>= 0.0.4)
40 | faraday-em_http (1.0.0)
41 | faraday-em_synchrony (1.0.0)
42 | faraday-excon (1.1.0)
43 | faraday-httpclient (1.0.1)
44 | faraday-multipart (1.0.3)
45 | multipart-post (>= 1.2, < 3)
46 | faraday-net_http (1.0.1)
47 | faraday-net_http_persistent (1.2.0)
48 | faraday-patron (1.0.0)
49 | faraday-rack (1.0.0)
50 | faraday-retry (1.0.3)
51 | ffi (1.15.5)
52 | forwardable-extended (2.6.0)
53 | gemoji (3.0.1)
54 | github-pages (226)
55 | github-pages-health-check (= 1.17.9)
56 | jekyll (= 3.9.2)
57 | jekyll-avatar (= 0.7.0)
58 | jekyll-coffeescript (= 1.1.1)
59 | jekyll-commonmark-ghpages (= 0.2.0)
60 | jekyll-default-layout (= 0.1.4)
61 | jekyll-feed (= 0.15.1)
62 | jekyll-gist (= 1.5.0)
63 | jekyll-github-metadata (= 2.13.0)
64 | jekyll-include-cache (= 0.2.1)
65 | jekyll-mentions (= 1.6.0)
66 | jekyll-optional-front-matter (= 0.3.2)
67 | jekyll-paginate (= 1.1.0)
68 | jekyll-readme-index (= 0.3.0)
69 | jekyll-redirect-from (= 0.16.0)
70 | jekyll-relative-links (= 0.6.1)
71 | jekyll-remote-theme (= 0.4.3)
72 | jekyll-sass-converter (= 1.5.2)
73 | jekyll-seo-tag (= 2.8.0)
74 | jekyll-sitemap (= 1.4.0)
75 | jekyll-swiss (= 1.0.0)
76 | jekyll-theme-architect (= 0.2.0)
77 | jekyll-theme-cayman (= 0.2.0)
78 | jekyll-theme-dinky (= 0.2.0)
79 | jekyll-theme-hacker (= 0.2.0)
80 | jekyll-theme-leap-day (= 0.2.0)
81 | jekyll-theme-merlot (= 0.2.0)
82 | jekyll-theme-midnight (= 0.2.0)
83 | jekyll-theme-minimal (= 0.2.0)
84 | jekyll-theme-modernist (= 0.2.0)
85 | jekyll-theme-primer (= 0.6.0)
86 | jekyll-theme-slate (= 0.2.0)
87 | jekyll-theme-tactile (= 0.2.0)
88 | jekyll-theme-time-machine (= 0.2.0)
89 | jekyll-titles-from-headings (= 0.5.3)
90 | jemoji (= 0.12.0)
91 | kramdown (= 2.3.2)
92 | kramdown-parser-gfm (= 1.1.0)
93 | liquid (= 4.0.3)
94 | mercenary (~> 0.3)
95 | minima (= 2.5.1)
96 | nokogiri (>= 1.13.4, < 2.0)
97 | rouge (= 3.26.0)
98 | terminal-table (~> 1.4)
99 | github-pages-health-check (1.17.9)
100 | addressable (~> 2.3)
101 | dnsruby (~> 1.60)
102 | octokit (~> 4.0)
103 | public_suffix (>= 3.0, < 5.0)
104 | typhoeus (~> 1.3)
105 | html-pipeline (2.14.1)
106 | activesupport (>= 2)
107 | nokogiri (>= 1.4)
108 | http_parser.rb (0.8.0)
109 | i18n (0.9.5)
110 | concurrent-ruby (~> 1.0)
111 | jekyll (3.9.2)
112 | addressable (~> 2.4)
113 | colorator (~> 1.0)
114 | em-websocket (~> 0.5)
115 | i18n (~> 0.7)
116 | jekyll-sass-converter (~> 1.0)
117 | jekyll-watch (~> 2.0)
118 | kramdown (>= 1.17, < 3)
119 | liquid (~> 4.0)
120 | mercenary (~> 0.3.3)
121 | pathutil (~> 0.9)
122 | rouge (>= 1.7, < 4)
123 | safe_yaml (~> 1.0)
124 | jekyll-avatar (0.7.0)
125 | jekyll (>= 3.0, < 5.0)
126 | jekyll-coffeescript (1.1.1)
127 | coffee-script (~> 2.2)
128 | coffee-script-source (~> 1.11.1)
129 | jekyll-commonmark (1.4.0)
130 | commonmarker (~> 0.22)
131 | jekyll-commonmark-ghpages (0.2.0)
132 | commonmarker (~> 0.23.4)
133 | jekyll (~> 3.9.0)
134 | jekyll-commonmark (~> 1.4.0)
135 | rouge (>= 2.0, < 4.0)
136 | jekyll-default-layout (0.1.4)
137 | jekyll (~> 3.0)
138 | jekyll-feed (0.15.1)
139 | jekyll (>= 3.7, < 5.0)
140 | jekyll-gist (1.5.0)
141 | octokit (~> 4.2)
142 | jekyll-github-metadata (2.13.0)
143 | jekyll (>= 3.4, < 5.0)
144 | octokit (~> 4.0, != 4.4.0)
145 | jekyll-include-cache (0.2.1)
146 | jekyll (>= 3.7, < 5.0)
147 | jekyll-mentions (1.6.0)
148 | html-pipeline (~> 2.3)
149 | jekyll (>= 3.7, < 5.0)
150 | jekyll-optional-front-matter (0.3.2)
151 | jekyll (>= 3.0, < 5.0)
152 | jekyll-paginate (1.1.0)
153 | jekyll-readme-index (0.3.0)
154 | jekyll (>= 3.0, < 5.0)
155 | jekyll-redirect-from (0.16.0)
156 | jekyll (>= 3.3, < 5.0)
157 | jekyll-relative-links (0.6.1)
158 | jekyll (>= 3.3, < 5.0)
159 | jekyll-remote-theme (0.4.3)
160 | addressable (~> 2.0)
161 | jekyll (>= 3.5, < 5.0)
162 | jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0)
163 | rubyzip (>= 1.3.0, < 3.0)
164 | jekyll-sass-converter (1.5.2)
165 | sass (~> 3.4)
166 | jekyll-seo-tag (2.8.0)
167 | jekyll (>= 3.8, < 5.0)
168 | jekyll-sitemap (1.4.0)
169 | jekyll (>= 3.7, < 5.0)
170 | jekyll-swiss (1.0.0)
171 | jekyll-theme-architect (0.2.0)
172 | jekyll (> 3.5, < 5.0)
173 | jekyll-seo-tag (~> 2.0)
174 | jekyll-theme-cayman (0.2.0)
175 | jekyll (> 3.5, < 5.0)
176 | jekyll-seo-tag (~> 2.0)
177 | jekyll-theme-dinky (0.2.0)
178 | jekyll (> 3.5, < 5.0)
179 | jekyll-seo-tag (~> 2.0)
180 | jekyll-theme-hacker (0.2.0)
181 | jekyll (> 3.5, < 5.0)
182 | jekyll-seo-tag (~> 2.0)
183 | jekyll-theme-leap-day (0.2.0)
184 | jekyll (> 3.5, < 5.0)
185 | jekyll-seo-tag (~> 2.0)
186 | jekyll-theme-merlot (0.2.0)
187 | jekyll (> 3.5, < 5.0)
188 | jekyll-seo-tag (~> 2.0)
189 | jekyll-theme-midnight (0.2.0)
190 | jekyll (> 3.5, < 5.0)
191 | jekyll-seo-tag (~> 2.0)
192 | jekyll-theme-minimal (0.2.0)
193 | jekyll (> 3.5, < 5.0)
194 | jekyll-seo-tag (~> 2.0)
195 | jekyll-theme-modernist (0.2.0)
196 | jekyll (> 3.5, < 5.0)
197 | jekyll-seo-tag (~> 2.0)
198 | jekyll-theme-primer (0.6.0)
199 | jekyll (> 3.5, < 5.0)
200 | jekyll-github-metadata (~> 2.9)
201 | jekyll-seo-tag (~> 2.0)
202 | jekyll-theme-slate (0.2.0)
203 | jekyll (> 3.5, < 5.0)
204 | jekyll-seo-tag (~> 2.0)
205 | jekyll-theme-tactile (0.2.0)
206 | jekyll (> 3.5, < 5.0)
207 | jekyll-seo-tag (~> 2.0)
208 | jekyll-theme-time-machine (0.2.0)
209 | jekyll (> 3.5, < 5.0)
210 | jekyll-seo-tag (~> 2.0)
211 | jekyll-titles-from-headings (0.5.3)
212 | jekyll (>= 3.3, < 5.0)
213 | jekyll-watch (2.2.1)
214 | listen (~> 3.0)
215 | jemoji (0.12.0)
216 | gemoji (~> 3.0)
217 | html-pipeline (~> 2.2)
218 | jekyll (>= 3.0, < 5.0)
219 | kramdown (2.3.2)
220 | rexml
221 | kramdown-parser-gfm (1.1.0)
222 | kramdown (~> 2.0)
223 | liquid (4.0.3)
224 | listen (3.7.1)
225 | rb-fsevent (~> 0.10, >= 0.10.3)
226 | rb-inotify (~> 0.9, >= 0.9.10)
227 | mercenary (0.3.6)
228 | minima (2.5.1)
229 | jekyll (>= 3.5, < 5.0)
230 | jekyll-feed (~> 0.9)
231 | jekyll-seo-tag (~> 2.1)
232 | minitest (5.15.0)
233 | multipart-post (2.1.1)
234 | nokogiri (1.13.6-x86_64-linux)
235 | racc (~> 1.4)
236 | octokit (4.22.0)
237 | faraday (>= 0.9)
238 | sawyer (~> 0.8.0, >= 0.5.3)
239 | pathutil (0.16.2)
240 | forwardable-extended (~> 2.6)
241 | public_suffix (4.0.7)
242 | racc (1.6.0)
243 | rb-fsevent (0.11.1)
244 | rb-inotify (0.10.1)
245 | ffi (~> 1.0)
246 | rexml (3.2.5)
247 | rouge (3.26.0)
248 | ruby2_keywords (0.0.5)
249 | rubyzip (2.3.2)
250 | safe_yaml (1.0.5)
251 | sass (3.7.4)
252 | sass-listen (~> 4.0.0)
253 | sass-listen (4.0.0)
254 | rb-fsevent (~> 0.9, >= 0.9.4)
255 | rb-inotify (~> 0.9, >= 0.9.7)
256 | sawyer (0.8.2)
257 | addressable (>= 2.3.5)
258 | faraday (> 0.8, < 2.0)
259 | simpleidn (0.2.1)
260 | unf (~> 0.1.4)
261 | terminal-table (1.8.0)
262 | unicode-display_width (~> 1.1, >= 1.1.1)
263 | thread_safe (0.3.6)
264 | typhoeus (1.4.0)
265 | ethon (>= 0.9.0)
266 | tzinfo (1.2.9)
267 | thread_safe (~> 0.1)
268 | unf (0.1.4)
269 | unf_ext
270 | unf_ext (0.0.8.1)
271 | unicode-display_width (1.8.0)
272 | webrick (1.7.0)
273 | zeitwerk (2.5.4)
274 |
275 | PLATFORMS
276 | x86_64-linux
277 |
278 | DEPENDENCIES
279 | github-pages
280 | http_parser.rb (~> 0.6.0)
281 | tzinfo (~> 1.2)
282 | tzinfo-data
283 | wdm (~> 0.1.1)
284 | webrick (~> 1.7)
285 |
286 | BUNDLED WITH
287 | 2.3.14
288 |
--------------------------------------------------------------------------------
/LeanCamCombi/GraphTheory/ExampleSheet1.lean:
--------------------------------------------------------------------------------
1 | /-
2 | Copyright (c) 2022 Yaël Dillies, Kexing Ying. All rights reserved.
3 | Released under Apache 2.0 license as described in the file LICENSE.
4 | Authors: Yaël Dillies, Kexing Ying
5 | -/
6 | import Mathlib.Combinatorics.Hall.Basic
7 | import Mathlib.Combinatorics.SimpleGraph.Acyclic
8 | import Mathlib.Combinatorics.SimpleGraph.Clique
9 | import Mathlib.Data.Real.Sqrt
10 | import Mathlib.SetTheory.Cardinal.Basic
11 |
12 | /-!
13 | # Graph Theory, example sheet 1
14 |
15 | Here are the statements (and hopefully soon proofs!) of the questions from the first example sheet
16 | of the Cambridge Part II course Graph Theory.
17 |
18 | If you solve a question in Lean, feel free to open a Pull Request on Github!
19 | -/
20 |
21 | open Fintype (card)
22 | open Function SimpleGraph
23 | open scoped Cardinal SetRel
24 |
25 | namespace GraphTheory
26 | namespace ES1
27 | variable {ι α β γ : Type*}
28 |
29 | /-!
30 | ### Question 1
31 |
32 | Show that a graph $$G$$ which contains an odd circuit, contains an odd cycle.
33 | -/
34 |
35 |
36 | lemma q1 (G : SimpleGraph α) (a : α) (w : G.Walk a a) (hw : Odd w.length) :
37 | ∃ (b : _) (p : G.Path b b), Odd (p : G.Walk b b).length :=
38 | sorry
39 |
40 | /-!
41 | ### Question 2
42 |
43 | Show there are infinitely many planar graphs for which $$e(G) = 3(|G| − 2)$$. Can you give a nice
44 | description of all graphs that satisfy this equality?
45 | -/
46 |
47 |
48 | /-!
49 | ### Question 3
50 |
51 | Show that every graph $$G$$, with $$|G| > 2$$, has two vertices of the same degree.
52 | -/
53 |
54 | -- Planarity is hard
55 | lemma q3 [Fintype α] (G : SimpleGraph α) [DecidableRel G.Adj] :
56 | ∃ a b, a ≠ b ∧ G.degree a = G.degree b :=
57 | sorry
58 |
59 | /-!
60 | ### Question 4
61 |
62 | Show that in every connected graph with $$|G| ≥ 2$$ there exists a vertex $$v$$ so that $$G − v$$ is
63 | connected.
64 | -/
65 |
66 | -- This looks a bit painful as a translation. Probably better stated using connectivity on a set.
67 | lemma q4 [Finite α] [Nontrivial α] (G : SimpleGraph α) (hG : G.Connected) :
68 | ∃ a, ((⊤ : G.Subgraph).deleteVerts {a}).coe.Connected := by
69 | cases nonempty_fintype α
70 | sorry
71 |
72 | /-!
73 | ### Question 5
74 |
75 | Show that if $$G$$ is acyclic and $$|G| ≥ 1$$, then $$e(G) ≤ n − 1$$.
76 | -/
77 |
78 | -- Note: The statement is true without `nonempty α` due to nat subtraction.
79 | lemma q5 [Fintype α] (G : SimpleGraph α) [DecidableRel G.Adj] (hG : G.IsAcyclic) :
80 | G.edgeFinset.card ≤ card α - 1 := by
81 | cases isEmpty_or_nonempty α
82 | · simp
83 | sorry
84 |
85 | /-!
86 | ### Question 6
87 |
88 | The degree sequence of a graph $$G = ({x_1, . . . , x_n}, E)$$ is the sequence
89 | $$d(x_1), . . . , d(x_n)$$.
90 | For $$n ≥ 2$$, let $$1 ≤ d_1 ≤ d_2 ≤ \dots ≤ d_n$$ be integers. Show that $$(d_i)_{i = 1}^n$$ is a
91 | degree sequence of a tree if and only if $$\sum_{i=1}^n d_i = 2n − 2$$.
92 | -/
93 |
94 | /-- The finset of degrees of a finite graph. -/
95 | def degreeSequence [Fintype α] (G : SimpleGraph α) [DecidableRel G.Adj] : Multiset ℕ :=
96 | Finset.univ.val.map fun a ↦ G.degree a
97 |
98 | lemma q6 [Fintype α] (s : Multiset ℕ) (hs : Multiset.card s = card α) (h₀ : 0 ∉ s) :
99 | s.sum = 2 * card α - 2 ↔
100 | ∃ (G : SimpleGraph α) (_ : DecidableRel G.Adj), degreeSequence G = s :=
101 | sorry
102 |
103 | /-!
104 | ### Question 7
105 |
106 | Let $$T_1, \dots, T_k$$ be subtrees of a tree $$T$$. Show that if $$V(T_i) ∩ V(T_j) ≠ ∅$$ for all
107 | $$i, j ∈ [k]$$ then $$V(T_1) ∩ \dots ∩ V(T_k) ≠ ∅$$.
108 | -/
109 |
110 | lemma q7 (G : SimpleGraph α) (hG : G.IsAcyclic) (s : Finset ι) (f : ι → G.Subgraph)
111 | (hf : ∀ i ∈ s, (f i).coe.IsAcyclic) (h : ∀ i ∈ s, ∀ j ∈ s, f i ⊓ f j ≠ ⊥) :
112 | s.inf f ≠ ⊥ :=
113 | sorry
114 |
115 | /-!
116 | ### Question 8
117 |
118 | The average degree of a graph $$G = (V, E)$$ is $$n^{-1} \sum_{x ∈ V} d(x)$$. Show that if the
119 | average degree of $$G$$ is $$d$$ then $$G$$ contains a subgraph with minimum degree $≥ d/2$$.
120 | -/
121 |
122 | /-- The average degree of a simple graph is the average of its degrees. -/
123 | def averageDegree [Fintype α] (G : SimpleGraph α) [DecidableRel G.Adj] : ℚ :=
124 | ∑ a, G.degree a / card α
125 |
126 | lemma q8 [Fintype α] (G : SimpleGraph α) [DecidableRel G.Adj] :
127 | ∃ (H : Subgraph G) (_ : DecidableRel H.Adj), ∀ a, averageDegree G / 2 ≤ H.degree a :=
128 | sorry
129 |
130 | /-!
131 | ### Question 9
132 |
133 | Say that a graph $$G = (V, E)$$ can be decomposed into cycles if $$E$$ can be partitioned
134 | $$E = E_1 ∪ \dots ∪ E_k$$, where each $$E_i$$ is the edge set of a cycle. Show that $$G$$ can be
135 | decomposed into cycles if and only if all degrees of $$G$$ are even.
136 | -/
137 |
138 | -- This looks painful as a translation. It will likely get better once we have Kyle's eulerian paths
139 | lemma q9 [Fintype α] (G : SimpleGraph α) [DecidableRel G.Adj] :
140 | (∃ 𝒜 : Finset (Σ a, G.Path a a),
141 | (∀ p q : Σ a, G.Path a a,
142 | (p.2 : G.Walk p.1 p.1).edges.Disjoint (q.2 : G.Walk q.1 q.1).edges) ∧
143 | ∀ e, ∃ p : Σ a, G.Path a a, p ∈ 𝒜 ∧ e ∈ (p.2 : G.Walk p.1 p.1).edges) ↔
144 | ∀ a, Even (G.degree a) :=
145 | sorry
146 |
147 | /-!
148 | ### Question 10
149 |
150 | The clique number of a graph $$G$$ is the largest $$t$$ so that $$G$$ contains a complete graph on
151 | $$t$$ vertices.
152 | Show that the possible clique numbers for a regular graph on $$n$$ vertices are
153 | $$1, 2, \dots, n/2$$ and $$n$$.
154 | -/
155 |
156 | lemma q10 [Fintype α] (n : ℕ) :
157 | (∃ (G : SimpleGraph α) (_ : DecidableRel G.Adj) (k : _),
158 | G.IsRegularOfDegree k ∧ cliqueNum G = n) ↔
159 | n ≤ card α / 2 ∨ n = card α :=
160 | sorry
161 |
162 | /-!
163 | ### Question 11
164 |
165 | Show that the Petersen graph is non-planar.
166 | -/
167 |
168 |
169 | /-!
170 | ### Question 12
171 |
172 | Let $$G = (V, E)$$ be a graph. Show that there is a partition $$V = A ∪ B$$ so all the vertices in
173 | the graphs $$G[A]$$ and $$G[B]$$ are of even degree.
174 | -/
175 |
176 | -- Note: This is a bit more general than the statement, because we allow partitioning any set of
177 | -- vertices
178 | lemma q12 [DecidableEq α] (G : SimpleGraph α) [DecidableRel G.Adj] (s : Finset α) :
179 | ∃ u v, Disjoint u v ∧ u ∪ v = s ∧
180 | (∀ a ∈ u, Even #{b ∈ u | G.Adj a b}) ∧ ∀ a ∈ v, Even #{b ∈ v | G.Adj a b} :=
181 | sorry
182 |
183 | /-!
184 | ### Question 13
185 |
186 | A $$m × n$$ Latin rectangle is a $$m × n$$ matrix, with each entry from $${1, . . . , n}$$, such
187 | that no two entries in the same row or column are the same. Prove that every $$m × n$$ Latin
188 | rectangle may be extended to a $$n × n$$ Latin square.
189 | -/
190 |
191 | /-- A Latin rectangle is a binary function whose transversals are all injective. -/
192 | def IsLatin (f : α → β → γ) : Prop :=
193 | (∀ a, Injective (f a)) ∧ ∀ b, Injective fun a ↦ f a b
194 |
195 | lemma q13 [Finite α] (g : β ↪ α) (f : β → α → α) (hf : IsLatin f) :
196 | ∃ f', f' ∘ g = f ∧ IsLatin f :=
197 | sorry
198 |
199 | /-!
200 | ### Question 14
201 |
202 | Let $$G = (X ∪ Y, E)$$ be a countably infinite bipartite graph with the property that
203 | $$|N(A)| ≥ |A|$$ for all $$A ⊆ X$$. Give an example to show that $$G$$ need not contain a matching
204 | from $$X$$ to $$Y$$ . On the other hand, show that if all of the degrees of $$G$$ are finite then
205 | $$G$$ does contain a matching from $$X$$ to $$Y$$. Does this remain true if $$G$$ is uncountable and
206 | all degrees of $$X$$ are finite (while degrees in $$Y$$ have no restriction)?
207 | -/
208 |
209 | -- This translation looks slightly painful because of the `cardinal`.
210 | lemma q14_part1 :
211 | ∃ r : SetRel ℕ ℕ,
212 | (∀ A : Finset ℕ, (A.card : Cardinal) ≤ #(r.image A)) ∧
213 | ∀ f : ℕ → ℕ, Injective f → ∃ n, ¬ n ~[r] f n :=
214 | sorry
215 |
216 | lemma q14_part2 [DecidableEq β] [Countable α] [Countable β] (r : SetRel α β)
217 | [∀ a, Fintype (r.image {a})] (hr : ∀ A : Finset α, A.card ≤ card (r.image A)) :
218 | ∃ f : α → β, Injective f ∧ ∀ a, a ~[r] f a :=
219 | sorry
220 |
221 | lemma q14_part3 [DecidableEq β] (r : SetRel α β) [∀ a, Fintype (r.image {a})]
222 | (hr : ∀ A : Finset α, A.card ≤ card (r.image A)) :
223 | ∃ f : α → β, Injective f ∧ ∀ a, a ~[r] f a :=
224 | sorry
225 |
226 | /-!
227 | ### Question 15
228 |
229 | Let $$(X, d_X)$$ be a metric space. We say that a function $$f : X → ℝ^2$$ has distortion
230 | $$≤ D$$ if there exists an $$r > 0$$ so that
231 | $$rd_X(x, y) ≤ ‖f(x) − f(y)‖_2 ≤ Drd_X(x, y)$$.
232 | Show that there is some constant $$c > 0$$ such that for all $$n$$ there is a metric space
233 | $$M = ({x_1, \dots, x_n}, d_M)$$ on $$n$$ points so that every function $$f : M → ℝ^2$$ has
234 | distortion $$> cn^{1/2}$$. Does there exist some constant $$c > 0$$ such that for all $$n$$ there is
235 | a metric space $$M = ({x_1, \dots, x_n}, d_M)$$ on $$n$$ points so that every function
236 | $$f : M → ℝ^2$$ has distortion $$> cn$$?
237 | -/
238 |
239 | /-- The distortion of a function `f` between metric spaces is the ratio between the maximum and
240 | minimum of `dist (f a) (f b) / dist a b`. -/
241 | noncomputable def distortion [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β) : ℝ :=
242 | (⨆ (a) (b), dist (f a) (f b) / dist a b) / ⨅ (a) (b), dist (f a) (f b) / dist a b
243 |
244 | lemma q15_part1 :
245 | ∃ ε : ℝ, 0 < ε ∧ ∀ (α) [Fintype α],
246 | ∃ _ : MetricSpace α, ∀ f : α → ℝ × ℝ, ε * Real.sqrt (card α) ≤ distortion f :=
247 | sorry
248 |
249 | lemma q15_part2 :
250 | ∃ ε : ℝ, 0 < ε ∧ ∀ (α) [Fintype α],
251 | ∃ _ : MetricSpace α, ∀ f : α → ℝ × ℝ, ε * card α ≤ distortion f :=
252 | sorry
253 |
254 | end ES1
255 | end GraphTheory
256 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------